Update WordPress to 5.2

This commit is contained in:
Oliver Davies 2019-05-08 08:05:39 +01:00
parent 489b5a5914
commit e00f87f2f5
599 changed files with 119573 additions and 55990 deletions

View file

@ -731,23 +731,26 @@ function get_default_post_to_edit( $post_type = 'post', $create_in_db = false )
}
/**
* Determine if a post exists based on title, content, and date
* Determines if a post exists based on title, content, date and type.
*
* @since 2.0.0
* @since 5.2.0 Added the `$type` parameter.
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param string $title Post title
* @param string $content Optional post content
* @param string $date Optional post date
* @param string $title Post title.
* @param string $content Optional post content.
* @param string $date Optional post date.
* @param string $type Optional post type.
* @return int Post ID if post exists, 0 otherwise.
*/
function post_exists( $title, $content = '', $date = '' ) {
function post_exists( $title, $content = '', $date = '', $type = '' ) {
global $wpdb;
$post_title = wp_unslash( sanitize_post_field( 'post_title', $title, 0, 'db' ) );
$post_content = wp_unslash( sanitize_post_field( 'post_content', $content, 0, 'db' ) );
$post_date = wp_unslash( sanitize_post_field( 'post_date', $date, 0, 'db' ) );
$post_type = wp_unslash( sanitize_post_field( 'post_type', $type, 0, 'db' ) );
$query = "SELECT ID FROM $wpdb->posts WHERE 1=1";
$args = array();
@ -767,6 +770,11 @@ function post_exists( $title, $content = '', $date = '' ) {
$args[] = $post_content;
}
if ( ! empty( $type ) ) {
$query .= ' AND post_type = %s';
$args[] = $post_type;
}
if ( ! empty( $args ) ) {
return (int) $wpdb->get_var( $wpdb->prepare( $query, $args ) );
}
@ -1176,23 +1184,6 @@ function wp_edit_posts_query( $q = false ) {
return $avail_post_stati;
}
/**
* Get all available post MIME types for a given post type.
*
* @since 2.5.0
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param string $type
* @return mixed
*/
function get_available_post_mime_types( $type = 'attachment' ) {
global $wpdb;
$types = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT post_mime_type FROM $wpdb->posts WHERE post_type = %s", $type ) );
return $types;
}
/**
* Get the query variables for the current attachments request.
*
@ -1283,34 +1274,34 @@ function wp_edit_attachments_query( $q = false ) {
*
* @since 2.5.0
*
* @param string $id
* @param string $page
* @return string
* @param string $box_id Meta box ID (used in the 'id' attribute for the meta box).
* @param string $screen_id The screen on which the meta box is shown.
* @return string Space-separated string of class names.
*/
function postbox_classes( $id, $page ) {
if ( isset( $_GET['edit'] ) && $_GET['edit'] == $id ) {
function postbox_classes( $box_id, $screen_id ) {
if ( isset( $_GET['edit'] ) && $_GET['edit'] == $box_id ) {
$classes = array( '' );
} elseif ( $closed = get_user_option( 'closedpostboxes_' . $page ) ) {
} elseif ( $closed = get_user_option( 'closedpostboxes_' . $screen_id ) ) {
if ( ! is_array( $closed ) ) {
$classes = array( '' );
} else {
$classes = in_array( $id, $closed ) ? array( 'closed' ) : array( '' );
$classes = in_array( $box_id, $closed ) ? array( 'closed' ) : array( '' );
}
} else {
$classes = array( '' );
}
/**
* Filters the postbox classes for a specific screen and screen ID combo.
* Filters the postbox classes for a specific screen and box ID combo.
*
* The dynamic portions of the hook name, `$page` and `$id`, refer to
* the screen and screen ID, respectively.
* The dynamic portions of the hook name, `$screen_id` and `$box_id`, refer to
* the screen ID and meta box ID, respectively.
*
* @since 3.2.0
*
* @param string[] $classes An array of postbox classes.
*/
$classes = apply_filters( "postbox_classes_{$page}_{$id}", $classes );
$classes = apply_filters( "postbox_classes_{$screen_id}_{$box_id}", $classes );
return implode( ' ', $classes );
}
@ -2071,7 +2062,7 @@ function use_block_editor_for_post( $post ) {
// We're in the meta box loader, so don't use the block editor.
if ( isset( $_GET['meta-box-loader'] ) ) {
check_admin_referer( 'meta-box-loader' );
check_admin_referer( 'meta-box-loader', 'meta-box-loader-nonce' );
return false;
}