Make WordPress Core

Changeset 55656


Ignore:
Timestamp:
04/18/2023 08:35:11 AM (3 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use strict comparison in wp-admin/includes/class-wp-ms-sites-list-table.php.

Includes minor code layout fixes for better readability.

Follow-up to [12603], [32630], [32755], [46441].

Props mujuonly, audrasjb, jankyz, krupalpanchal, SergeyBiryukov.
Fixes #58139.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-ms-sites-list-table.php

    r54378 r55656  
    110110                if ( empty( $s ) ) {
    111111                        // Nothing to do.
    112                 } elseif ( preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $s ) ||
    113                                         preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) ||
    114                                         preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) ||
    115                                         preg_match( '/^[0-9]{1,3}\.$/', $s ) ) {
     112                } elseif ( preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $s )
     113                        || preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s )
     114                        || preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s )
     115                        || preg_match( '/^[0-9]{1,3}\.$/', $s )
     116                ) {
    116117                        // IPv4 address.
    117                         $sql          = $wpdb->prepare( "SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE %s", $wpdb->esc_like( $s ) . ( ! empty( $wild ) ? '%' : '' ) );
     118                        $sql = $wpdb->prepare(
     119                                "SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE %s",
     120                                $wpdb->esc_like( $s ) . ( ! empty( $wild ) ? '%' : '' )
     121                        );
     122
    118123                        $reg_blog_ids = $wpdb->get_col( $sql );
    119124
     
    263268                foreach ( $statuses as $status => $label_count ) {
    264269                        if ( (int) $counts[ $status ] > 0 ) {
    265                                 $label    = sprintf( translate_nooped_plural( $label_count, $counts[ $status ] ), number_format_i18n( $counts[ $status ] ) );
     270                                $label = sprintf(
     271                                        translate_nooped_plural( $label_count, $counts[ $status ] ),
     272                                        number_format_i18n( $counts[ $status ] )
     273                                );
     274
    266275                                $full_url = 'all' === $status ? $url : add_query_arg( 'status', $status, $url );
    267276
     
    409418                                ?>
    410419                        </label>
    411                         <input type="checkbox" id="blog_<?php echo $blog['blog_id']; ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ); ?>" />
     420                        <input type="checkbox" id="blog_<?php echo $blog['blog_id']; ?>" name="allblogs[]"
     421                                value="<?php echo esc_attr( $blog['blog_id'] ); ?>" />
    412422                        <?php
    413423                endif;
     
    441451                ?>
    442452                <strong>
    443                         <a href="<?php echo esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname; ?></a>
    444                         <?php $this->site_states( $blog ); ?>
     453                        <?php
     454                        printf(
     455                                '<a href="%1$s" class="edit">%2$s</a>',
     456                                esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ),
     457                                $blogname
     458                        );
     459
     460                        $this->site_states( $blog );
     461                        ?>
    445462                </strong>
    446463                <?php
     
    477494                }
    478495
    479                 echo ( '0000-00-00 00:00:00' === $blog['last_updated'] ) ? __( 'Never' ) : mysql2date( $date, $blog['last_updated'] );
     496                if ( '0000-00-00 00:00:00' === $blog['last_updated'] ) {
     497                        _e( 'Never' );
     498                } else {
     499                        echo mysql2date( $date, $blog['last_updated'] );
     500                }
    480501        }
    481502
     
    528549
    529550                printf(
    530                         '<a href="%s">%s</a>',
     551                        '<a href="%1$s">%2$s</a>',
    531552                        esc_url( network_admin_url( 'site-users.php?id=' . $blog['blog_id'] ) ),
    532553                        number_format_i18n( $user_count )
     
    587608
    588609                        foreach ( $this->status_list as $status => $col ) {
    589                                 if ( 1 == $blog[ $status ] ) {
     610                                if ( '1' === $blog[ $status ] ) {
    590611                                        $class = " class='{$col[0]}'";
    591612                                }
     
    621642                $site_status = isset( $_REQUEST['status'] ) ? wp_unslash( trim( $_REQUEST['status'] ) ) : '';
    622643                foreach ( $this->status_list as $status => $col ) {
    623                         if ( ( 1 === (int) $_site->{$status} ) && ( $site_status !== $status ) ) {
     644                        if ( '1' === $_site->{$status} && $site_status !== $status ) {
    624645                                $site_states[ $col[0] ] = $col[1];
    625646                        }
     
    700721                );
    701722
    702                 $actions['edit']    = '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a>';
    703                 $actions['backend'] = "<a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a>';
    704                 if ( get_network()->site_id != $blog['blog_id'] ) {
    705                         if ( '1' == $blog['deleted'] ) {
    706                                 $actions['activate'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=activateblog&amp;id=' . $blog['blog_id'] ), 'activateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Activate' ) . '</a>';
     723                $actions['edit'] = sprintf(
     724                        '<a href="%1$s">%2$s</a>',
     725                        esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ),
     726                        __( 'Edit' )
     727                );
     728
     729                $actions['backend'] = sprintf(
     730                        '<a href="%1$s" class="edit">%2$s</a>',
     731                        esc_url( get_admin_url( $blog['blog_id'] ) ),
     732                        __( 'Dashboard' )
     733                );
     734
     735                if ( get_network()->site_id !== (int) $blog['blog_id'] ) {
     736                        if ( '1' === $blog['deleted'] ) {
     737                                $actions['activate'] = sprintf(
     738                                        '<a href="%1$s">%2$s</a>',
     739                                        esc_url(
     740                                                wp_nonce_url(
     741                                                        network_admin_url( 'sites.php?action=confirm&amp;action2=activateblog&amp;id=' . $blog['blog_id'] ),
     742                                                        'activateblog_' . $blog['blog_id']
     743                                                )
     744                                        ),
     745                                        __( 'Activate' )
     746                                );
    707747                        } else {
    708                                 $actions['deactivate'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=deactivateblog&amp;id=' . $blog['blog_id'] ), 'deactivateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Deactivate' ) . '</a>';
    709                         }
    710 
    711                         if ( '1' == $blog['archived'] ) {
    712                                 $actions['unarchive'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=unarchiveblog&amp;id=' . $blog['blog_id'] ), 'unarchiveblog_' . $blog['blog_id'] ) ) . '">' . __( 'Unarchive' ) . '</a>';
     748                                $actions['deactivate'] = sprintf(
     749                                        '<a href="%1$s">%2$s</a>',
     750                                        esc_url(
     751                                                wp_nonce_url(
     752                                                        network_admin_url( 'sites.php?action=confirm&amp;action2=deactivateblog&amp;id=' . $blog['blog_id'] ),
     753                                                        'deactivateblog_' . $blog['blog_id']
     754                                                )
     755                                        ),
     756                                        __( 'Deactivate' )
     757                                );
     758                        }
     759
     760                        if ( '1' === $blog['archived'] ) {
     761                                $actions['unarchive'] = sprintf(
     762                                        '<a href="%1$s">%2$s</a>',
     763                                        esc_url(
     764                                                wp_nonce_url(
     765                                                        network_admin_url( 'sites.php?action=confirm&amp;action2=unarchiveblog&amp;id=' . $blog['blog_id'] ),
     766                                                        'unarchiveblog_' . $blog['blog_id']
     767                                                )
     768                                        ),
     769                                        __( 'Unarchive' )
     770                                );
    713771                        } else {
    714                                 $actions['archive'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=archiveblog&amp;id=' . $blog['blog_id'] ), 'archiveblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Archive', 'verb; site' ) . '</a>';
    715                         }
    716 
    717                         if ( '1' == $blog['spam'] ) {
    718                                 $actions['unspam'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=unspamblog&amp;id=' . $blog['blog_id'] ), 'unspamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Not Spam', 'site' ) . '</a>';
     772                                $actions['archive'] = sprintf(
     773                                        '<a href="%1$s">%2$s</a>',
     774                                        esc_url(
     775                                                wp_nonce_url(
     776                                                        network_admin_url( 'sites.php?action=confirm&amp;action2=archiveblog&amp;id=' . $blog['blog_id'] ),
     777                                                        'archiveblog_' . $blog['blog_id']
     778                                                )
     779                                        ),
     780                                        _x( 'Archive', 'verb; site' )
     781                                );
     782                        }
     783
     784                        if ( '1' === $blog['spam'] ) {
     785                                $actions['unspam'] = sprintf(
     786                                        '<a href="%1$s">%2$s</a>',
     787                                        esc_url(
     788                                                wp_nonce_url(
     789                                                        network_admin_url( 'sites.php?action=confirm&amp;action2=unspamblog&amp;id=' . $blog['blog_id'] ),
     790                                                        'unspamblog_' . $blog['blog_id']
     791                                                )
     792                                        ),
     793                                        _x( 'Not Spam', 'site' )
     794                                );
    719795                        } else {
    720                                 $actions['spam'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=spamblog&amp;id=' . $blog['blog_id'] ), 'spamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Spam', 'site' ) . '</a>';
     796                                $actions['spam'] = sprintf(
     797                                        '<a href="%1$s">%2$s</a>',
     798                                        esc_url(
     799                                                wp_nonce_url(
     800                                                        network_admin_url( 'sites.php?action=confirm&amp;action2=spamblog&amp;id=' . $blog['blog_id'] ),
     801                                                        'spamblog_' . $blog['blog_id']
     802                                                )
     803                                        ),
     804                                        _x( 'Spam', 'site' )
     805                                );
    721806                        }
    722807
    723808                        if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) {
    724                                 $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=deleteblog&amp;id=' . $blog['blog_id'] ), 'deleteblog_' . $blog['blog_id'] ) ) . '">' . __( 'Delete' ) . '</a>';
    725                         }
    726                 }
    727 
    728                 $actions['visit'] = "<a href='" . esc_url( get_home_url( $blog['blog_id'], '/' ) ) . "' rel='bookmark'>" . __( 'Visit' ) . '</a>';
     809                                $actions['delete'] = sprintf(
     810                                        '<a href="%1$s">%2$s</a>',
     811                                        esc_url(
     812                                                wp_nonce_url(
     813                                                        network_admin_url( 'sites.php?action=confirm&amp;action2=deleteblog&amp;id=' . $blog['blog_id'] ),
     814                                                        'deleteblog_' . $blog['blog_id']
     815                                                )
     816                                        ),
     817                                        __( 'Delete' )
     818                                );
     819                        }
     820                }
     821
     822                $actions['visit'] = sprintf(
     823                        '<a href="%1$s" rel="bookmark">%2$s</a>',
     824                        esc_url( get_home_url( $blog['blog_id'], '/' ) ),
     825                        __( 'Visit' )
     826                );
    729827
    730828                /**
Note: See TracChangeset for help on using the changeset viewer.