diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index dd701fa766..168dc3bc07 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -691,13 +691,19 @@ function meta_form( $post = null ) { * @param int $limit Number of custom fields to retrieve. Default 30. */ $limit = apply_filters( 'postmeta_form_limit', 30 ); - $sql = "SELECT DISTINCT meta_key - FROM $wpdb->postmeta - WHERE meta_key NOT BETWEEN '_' AND '_z' - HAVING meta_key NOT LIKE %s - ORDER BY meta_key - LIMIT %d"; - $keys = $wpdb->get_col( $wpdb->prepare( $sql, $wpdb->esc_like( '_' ) . '%', $limit ) ); + + $keys = $wpdb->get_col( + $wpdb->prepare( + "SELECT DISTINCT meta_key + FROM $wpdb->postmeta + WHERE meta_key NOT BETWEEN '_' AND '_z' + HAVING meta_key NOT LIKE %s + ORDER BY meta_key + LIMIT %d", + $wpdb->esc_like( '_' ) . '%', + $limit + ) + ); } if ( $keys ) { @@ -784,7 +790,7 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) { $post = get_post(); if ( $for_post ) { - $edit = ! ( in_array( $post->post_status, array( 'draft', 'pending' ), true ) && ( ! $post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) ); + $edit = ! ( in_array( $post->post_status, array( 'draft', 'pending' ), true ) && ( ! $post->post_date_gmt || '0000-00-00 00:00:00' === $post->post_date_gmt ) ); } $tab_index_attribute = ''; @@ -896,13 +902,14 @@ function page_template_dropdown( $default = '', $post_type = 'page' ) { */ function parent_dropdown( $default = 0, $parent = 0, $level = 0, $post = null ) { global $wpdb; + $post = get_post( $post ); $items = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent ) ); if ( $items ) { foreach ( $items as $item ) { // A page cannot be its own parent. - if ( $post && $post->ID && $item->ID == $post->ID ) { + if ( $post && $post->ID && (int) $item->ID === $post->ID ) { continue; } @@ -932,7 +939,7 @@ function wp_dropdown_roles( $selected = '' ) { foreach ( $editable_roles as $role => $details ) { $name = translate_user_role( $details['name'] ); // Preselect specified role. - if ( $selected == $role ) { + if ( $selected === $role ) { $r .= "\n\t"; } else { $r .= "\n\t"; @@ -1057,7 +1064,7 @@ function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advan } // If a core box was previously added or removed by a plugin, don't add. - if ( 'core' == $priority ) { + if ( 'core' === $priority ) { // If core box previously deleted, don't add. if ( false === $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] ) { return; @@ -1067,7 +1074,7 @@ function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advan * If box was added with default priority, give it core priority to * maintain sort order. */ - if ( 'default' == $a_priority ) { + if ( 'default' === $a_priority ) { $wp_meta_boxes[ $page ][ $a_context ]['core'][ $id ] = $wp_meta_boxes[ $page ][ $a_context ]['default'][ $id ]; unset( $wp_meta_boxes[ $page ][ $a_context ]['default'][ $id ] ); } @@ -1080,13 +1087,14 @@ function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advan * Else, if we're adding to the sorted priority, we don't know the title * or callback. Grab them from the previously added context/priority. */ - } elseif ( 'sorted' == $priority ) { + } elseif ( 'sorted' === $priority ) { $title = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['title']; $callback = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['callback']; $callback_args = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['args']; } + // An ID can be in only one priority and one context. - if ( $priority != $a_priority || $context != $a_context ) { + if ( $priority !== $a_priority || $context !== $a_context ) { unset( $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] ); } } @@ -1227,15 +1235,15 @@ function _get_plugin_from_callback( $callback ) { * * @staticvar bool $already_sorted * - * @param string|WP_Screen $screen Screen identifier. If you have used add_menu_page() or + * @param string|WP_Screen $screen The screen identifier. If you have used add_menu_page() or * add_submenu_page() to create a new screen (and hence screen_id) * make sure your menu slug conforms to the limits of sanitize_key() * otherwise the 'screen' menu may not correctly render on your page. * @param string $context The screen context for which to display meta boxes. - * @param mixed $object Gets passed to the first parameter of the meta box callback function. + * @param mixed $object Gets passed to the meta box callback function as the first parameter. * Often this is the object that's the focus of the current screen, for * example a `WP_Post` or `WP_Comment` object. - * @return int number of meta_boxes + * @return int Number of meta_boxes. */ function do_meta_boxes( $screen, $context, $object ) { global $wp_meta_boxes; @@ -1275,7 +1283,7 @@ function do_meta_boxes( $screen, $context, $object ) { foreach ( array( 'high', 'sorted', 'core', 'default', 'low' ) as $priority ) { if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { foreach ( (array) $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { - if ( false == $box || ! $box['title'] ) { + if ( false === $box || ! $box['title'] ) { continue; } @@ -1307,7 +1315,7 @@ function do_meta_boxes( $screen, $context, $object ) { // get_hidden_meta_boxes() doesn't apply in the block editor. $hidden_class = ( ! $screen->is_block_editor() && in_array( $box['id'], $hidden, true ) ) ? ' hide-if-js' : ''; echo '
' . "\n"; - if ( 'dashboard_browser_nag' != $box['id'] ) { + if ( 'dashboard_browser_nag' !== $box['id'] ) { $widget_title = $box['title']; if ( is_array( $box['args'] ) && isset( $box['args']['__widget_basename'] ) ) { @@ -1428,9 +1436,9 @@ function remove_meta_box( $id, $screen, $context ) { * @uses global $wp_meta_boxes Used to retrieve registered meta boxes. * * @param string|object $screen The screen identifier. - * @param string $context The meta box context. - * @param mixed $object gets passed to the section callback function as first parameter. - * @return int number of meta boxes as accordion sections. + * @param string $context The screen context for which to display accordion sections. + * @param mixed $object Gets passed to the section callback function as the first parameter. + * @return int Number of meta boxes as accordion sections. */ function do_accordion_sections( $screen, $context, $object ) { global $wp_meta_boxes; @@ -1457,9 +1465,10 @@ function do_accordion_sections( $screen, $context, $object ) { foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { - if ( false == $box || ! $box['title'] ) { + if ( false === $box || ! $box['title'] ) { continue; } + $i++; $hidden_class = in_array( $box['id'], $hidden, true ) ? 'hide-if-js' : ''; @@ -1517,7 +1526,7 @@ function do_accordion_sections( $screen, $context, $object ) { function add_settings_section( $id, $title, $callback, $page ) { global $wp_settings_sections; - if ( 'misc' == $page ) { + if ( 'misc' === $page ) { _deprecated_argument( __FUNCTION__, '3.0.0', @@ -1530,7 +1539,7 @@ function add_settings_section( $id, $title, $callback, $page ) { $page = 'general'; } - if ( 'privacy' == $page ) { + if ( 'privacy' === $page ) { _deprecated_argument( __FUNCTION__, '3.5.0', @@ -1588,7 +1597,7 @@ function add_settings_section( $id, $title, $callback, $page ) { function add_settings_field( $id, $title, $callback, $page, $section = 'default', $args = array() ) { global $wp_settings_fields; - if ( 'misc' == $page ) { + if ( 'misc' === $page ) { _deprecated_argument( __FUNCTION__, '3.0.0', @@ -1601,7 +1610,7 @@ function add_settings_field( $id, $title, $callback, $page, $section = 'default' $page = 'general'; } - if ( 'privacy' == $page ) { + if ( 'privacy' === $page ) { _deprecated_argument( __FUNCTION__, '3.5.0', @@ -1790,7 +1799,7 @@ function get_settings_errors( $setting = '', $sanitize = false ) { $setting_errors = array(); foreach ( (array) $wp_settings_errors as $key => $details ) { - if ( $setting == $details['setting'] ) { + if ( $setting === $details['setting'] ) { $setting_errors[] = $wp_settings_errors[ $key ]; } } @@ -2098,9 +2107,9 @@ function _post_states( $post, $echo = true ) { $post_states_string .= ' — '; foreach ( $post_states as $state ) { - ++$i; - ( $i == $state_count ) ? $sep = '' : $sep = ', '; - $post_states_string .= "$state$sep"; + $sep = ( ++$i === $state_count ) ? '' : ', '; + + $post_states_string .= "$state$sep"; } } @@ -2131,7 +2140,7 @@ function get_post_states( $post ) { $post_states['protected'] = _x( 'Password protected', 'post status' ); } - if ( 'private' == $post->post_status && 'private' != $post_status ) { + if ( 'private' === $post->post_status && 'private' !== $post_status ) { $post_states['private'] = _x( 'Private', 'post status' ); } @@ -2145,7 +2154,7 @@ function get_post_states( $post ) { $post_states[] = _x( 'Customization Draft', 'post status' ); } - if ( 'pending' == $post->post_status && 'pending' != $post_status ) { + if ( 'pending' === $post->post_status && 'pending' !== $post_status ) { $post_states['pending'] = _x( 'Pending', 'post status' ); } @@ -2201,7 +2210,7 @@ function _media_states( $post ) { if ( is_random_header_image() ) { $header_images = wp_list_pluck( get_uploaded_header_images(), 'attachment_id' ); - if ( $meta_header == $stylesheet && in_array( $post->ID, $header_images, true ) ) { + if ( $meta_header === $stylesheet && in_array( $post->ID, $header_images, true ) ) { $media_states[] = __( 'Header Image' ); } } else { @@ -2232,11 +2241,11 @@ function _media_states( $post ) { } } - if ( get_option( 'site_icon' ) == $post->ID ) { + if ( (int) get_option( 'site_icon' ) === $post->ID ) { $media_states[] = __( 'Site Icon' ); } - if ( get_theme_mod( 'custom_logo' ) == $post->ID ) { + if ( (int) get_theme_mod( 'custom_logo' ) === $post->ID ) { $media_states[] = __( 'Logo' ); } @@ -2259,8 +2268,8 @@ function _media_states( $post ) { echo ' — '; foreach ( $media_states as $state ) { - ++$i; - ( $i == $state_count ) ? $sep = '' : $sep = ', '; + $sep = ( ++$i === $state_count ) ? '' : ', '; + echo "$state$sep"; } } diff --git a/wp-includes/version.php b/wp-includes/version.php index 5d4dffd2f8..f11ed8303e 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-alpha-47774'; +$wp_version = '5.5-alpha-47775'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.