WordPress.org

Make WordPress Core

Changeset 47775


Ignore:
Timestamp:
05/08/2020 04:34:50 PM (17 months ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Fix WPCS issues in wp-admin/includes/template.php.

See #49542.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/template.php

    r47771 r47775  
    692692         */
    693693        $limit = apply_filters( 'postmeta_form_limit', 30 );
    694         $sql   = "SELECT DISTINCT meta_key
    695             FROM $wpdb->postmeta
    696             WHERE meta_key NOT BETWEEN '_' AND '_z'
    697             HAVING meta_key NOT LIKE %s
    698             ORDER BY meta_key
    699             LIMIT %d";
    700         $keys  = $wpdb->get_col( $wpdb->prepare( $sql, $wpdb->esc_like( '_' ) . '%', $limit ) );
     694
     695        $keys = $wpdb->get_col(
     696            $wpdb->prepare(
     697                "SELECT DISTINCT meta_key
     698                FROM $wpdb->postmeta
     699                WHERE meta_key NOT BETWEEN '_' AND '_z'
     700                HAVING meta_key NOT LIKE %s
     701                ORDER BY meta_key
     702                LIMIT %d",
     703                $wpdb->esc_like( '_' ) . '%',
     704                $limit
     705            )
     706        );
    701707    }
    702708
     
    785791
    786792    if ( $for_post ) {
    787         $edit = ! ( in_array( $post->post_status, array( 'draft', 'pending' ), true ) && ( ! $post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) );
     793        $edit = ! ( in_array( $post->post_status, array( 'draft', 'pending' ), true ) && ( ! $post->post_date_gmt || '0000-00-00 00:00:00' === $post->post_date_gmt ) );
    788794    }
    789795
     
    897903function parent_dropdown( $default = 0, $parent = 0, $level = 0, $post = null ) {
    898904    global $wpdb;
     905
    899906    $post  = get_post( $post );
    900907    $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 ) );
     
    903910        foreach ( $items as $item ) {
    904911            // A page cannot be its own parent.
    905             if ( $post && $post->ID && $item->ID == $post->ID ) {
     912            if ( $post && $post->ID && (int) $item->ID === $post->ID ) {
    906913                continue;
    907914            }
     
    933940        $name = translate_user_role( $details['name'] );
    934941        // Preselect specified role.
    935         if ( $selected == $role ) {
     942        if ( $selected === $role ) {
    936943            $r .= "\n\t<option selected='selected' value='" . esc_attr( $role ) . "'>$name</option>";
    937944        } else {
     
    10581065
    10591066            // If a core box was previously added or removed by a plugin, don't add.
    1060             if ( 'core' == $priority ) {
     1067            if ( 'core' === $priority ) {
    10611068                // If core box previously deleted, don't add.
    10621069                if ( false === $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] ) {
     
    10681075                 * maintain sort order.
    10691076                 */
    1070                 if ( 'default' == $a_priority ) {
     1077                if ( 'default' === $a_priority ) {
    10711078                    $wp_meta_boxes[ $page ][ $a_context ]['core'][ $id ] = $wp_meta_boxes[ $page ][ $a_context ]['default'][ $id ];
    10721079                    unset( $wp_meta_boxes[ $page ][ $a_context ]['default'][ $id ] );
     
    10811088                * or callback. Grab them from the previously added context/priority.
    10821089                */
    1083             } elseif ( 'sorted' == $priority ) {
     1090            } elseif ( 'sorted' === $priority ) {
    10841091                $title         = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['title'];
    10851092                $callback      = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['callback'];
    10861093                $callback_args = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['args'];
    10871094            }
     1095
    10881096            // An ID can be in only one priority and one context.
    1089             if ( $priority != $a_priority || $context != $a_context ) {
     1097            if ( $priority !== $a_priority || $context !== $a_context ) {
    10901098                unset( $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] );
    10911099            }
     
    12281236 * @staticvar bool $already_sorted
    12291237 *
    1230  * @param string|WP_Screen $screen  Screen identifier. If you have used add_menu_page() or
     1238 * @param string|WP_Screen $screen  The screen identifier. If you have used add_menu_page() or
    12311239 *                                  add_submenu_page() to create a new screen (and hence screen_id)
    12321240 *                                  make sure your menu slug conforms to the limits of sanitize_key()
    12331241 *                                  otherwise the 'screen' menu may not correctly render on your page.
    12341242 * @param string           $context The screen context for which to display meta boxes.
    1235  * @param mixed            $object  Gets passed to the first parameter of the meta box callback function.
     1243 * @param mixed            $object  Gets passed to the meta box callback function as the first parameter.
    12361244 *                                  Often this is the object that's the focus of the current screen, for
    12371245 *                                  example a `WP_Post` or `WP_Comment` object.
    1238  * @return int number of meta_boxes
     1246 * @return int Number of meta_boxes.
    12391247 */
    12401248function do_meta_boxes( $screen, $context, $object ) {
     
    12761284            if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
    12771285                foreach ( (array) $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
    1278                     if ( false == $box || ! $box['title'] ) {
     1286                    if ( false === $box || ! $box['title'] ) {
    12791287                        continue;
    12801288                    }
     
    13081316                    $hidden_class = ( ! $screen->is_block_editor() && in_array( $box['id'], $hidden, true ) ) ? ' hide-if-js' : '';
    13091317                    echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes( $box['id'], $page ) . $hidden_class . '" ' . '>' . "\n";
    1310                     if ( 'dashboard_browser_nag' != $box['id'] ) {
     1318                    if ( 'dashboard_browser_nag' !== $box['id'] ) {
    13111319                        $widget_title = $box['title'];
    13121320
     
    14291437 *
    14301438 * @param string|object $screen  The screen identifier.
    1431  * @param string        $context The meta box context.
    1432  * @param mixed         $object  gets passed to the section callback function as first parameter.
    1433  * @return int number of meta boxes as accordion sections.
     1439 * @param string        $context The screen context for which to display accordion sections.
     1440 * @param mixed         $object  Gets passed to the section callback function as the first parameter.
     1441 * @return int Number of meta boxes as accordion sections.
    14341442 */
    14351443function do_accordion_sections( $screen, $context, $object ) {
     
    14581466            if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
    14591467                foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
    1460                     if ( false == $box || ! $box['title'] ) {
     1468                    if ( false === $box || ! $box['title'] ) {
    14611469                        continue;
    14621470                    }
     1471
    14631472                    $i++;
    14641473                    $hidden_class = in_array( $box['id'], $hidden, true ) ? 'hide-if-js' : '';
     
    15181527    global $wp_settings_sections;
    15191528
    1520     if ( 'misc' == $page ) {
     1529    if ( 'misc' === $page ) {
    15211530        _deprecated_argument(
    15221531            __FUNCTION__,
     
    15311540    }
    15321541
    1533     if ( 'privacy' == $page ) {
     1542    if ( 'privacy' === $page ) {
    15341543        _deprecated_argument(
    15351544            __FUNCTION__,
     
    15891598    global $wp_settings_fields;
    15901599
    1591     if ( 'misc' == $page ) {
     1600    if ( 'misc' === $page ) {
    15921601        _deprecated_argument(
    15931602            __FUNCTION__,
     
    16021611    }
    16031612
    1604     if ( 'privacy' == $page ) {
     1613    if ( 'privacy' === $page ) {
    16051614        _deprecated_argument(
    16061615            __FUNCTION__,
     
    17911800
    17921801        foreach ( (array) $wp_settings_errors as $key => $details ) {
    1793             if ( $setting == $details['setting'] ) {
     1802            if ( $setting === $details['setting'] ) {
    17941803                $setting_errors[] = $wp_settings_errors[ $key ];
    17951804            }
     
    20992108
    21002109        foreach ( $post_states as $state ) {
    2101             ++$i;
    2102             ( $i == $state_count ) ? $sep = '' : $sep = ', ';
    2103             $post_states_string          .= "<span class='post-state'>$state$sep</span>";
     2110            $sep = ( ++$i === $state_count ) ? '' : ', ';
     2111
     2112            $post_states_string .= "<span class='post-state'>$state$sep</span>";
    21042113        }
    21052114    }
     
    21322141    }
    21332142
    2134     if ( 'private' == $post->post_status && 'private' != $post_status ) {
     2143    if ( 'private' === $post->post_status && 'private' !== $post_status ) {
    21352144        $post_states['private'] = _x( 'Private', 'post status' );
    21362145    }
     
    21462155    }
    21472156
    2148     if ( 'pending' == $post->post_status && 'pending' != $post_status ) {
     2157    if ( 'pending' === $post->post_status && 'pending' !== $post_status ) {
    21492158        $post_states['pending'] = _x( 'Pending', 'post status' );
    21502159    }
     
    22022211            $header_images = wp_list_pluck( get_uploaded_header_images(), 'attachment_id' );
    22032212
    2204             if ( $meta_header == $stylesheet && in_array( $post->ID, $header_images, true ) ) {
     2213            if ( $meta_header === $stylesheet && in_array( $post->ID, $header_images, true ) ) {
    22052214                $media_states[] = __( 'Header Image' );
    22062215            }
     
    22332242    }
    22342243
    2235     if ( get_option( 'site_icon' ) == $post->ID ) {
     2244    if ( (int) get_option( 'site_icon' ) === $post->ID ) {
    22362245        $media_states[] = __( 'Site Icon' );
    22372246    }
    22382247
    2239     if ( get_theme_mod( 'custom_logo' ) == $post->ID ) {
     2248    if ( (int) get_theme_mod( 'custom_logo' ) === $post->ID ) {
    22402249        $media_states[] = __( 'Logo' );
    22412250    }
     
    22602269
    22612270        foreach ( $media_states as $state ) {
    2262             ++$i;
    2263             ( $i == $state_count ) ? $sep = '' : $sep = ', ';
     2271            $sep = ( ++$i === $state_count ) ? '' : ', ';
     2272
    22642273            echo "<span class='post-state'>$state$sep</span>";
    22652274        }
Note: See TracChangeset for help on using the changeset viewer.