WordPress.org

Make WordPress Core

Changeset 47853


Ignore:
Timestamp:
05/24/2020 09:14:21 AM (16 months ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use strict comparison in wp-admin/network where static strings are involved.

Includes minor code layout fixes for better readability.

Follow-up to [47808].

See #49542.

Location:
trunk/src/wp-admin/network
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/network/plugin-install.php

    r47198 r47853  
    88 */
    99
    10 if ( isset( $_GET['tab'] ) && ( 'plugin-information' == $_GET['tab'] ) ) {
     10if ( isset( $_GET['tab'] ) && ( 'plugin-information' === $_GET['tab'] ) ) {
    1111    define( 'IFRAME_REQUEST', true );
    1212}
  • trunk/src/wp-admin/network/settings.php

    r47616 r47853  
    3333    wp_redirect( network_admin_url( $redirect ) );
    3434    exit;
    35 } elseif ( ! empty( $_GET['dismiss'] ) && 'new_network_admin_email' == $_GET['dismiss'] ) {
     35} elseif ( ! empty( $_GET['dismiss'] ) && 'new_network_admin_email' === $_GET['dismiss'] ) {
    3636    check_admin_referer( 'dismiss_new_network_admin_email' );
    3737    delete_site_option( 'network_admin_hash' );
     
    256256                    $limited_email_domains = get_site_option( 'limited_email_domains' );
    257257                    $limited_email_domains = str_replace( ' ', "\n", $limited_email_domains );
     258
     259                    if ( $limited_email_domains ) {
     260                        $limited_email_domains = implode( "\n", (array) $limited_email_domains );
     261                    }
    258262                    ?>
    259263                    <textarea name="limited_email_domains" id="limited_email_domains" aria-describedby="limited-email-domains-desc" cols="45" rows="5">
    260 <?php echo esc_textarea( '' == $limited_email_domains ? '' : implode( "\n", (array) $limited_email_domains ) ); ?></textarea>
     264<?php echo esc_textarea( $limited_email_domains ); ?></textarea>
    261265                    <p class="description" id="limited-email-domains-desc">
    262266                        <?php _e( 'If you want to limit site registrations to certain domains. One domain per line.' ); ?>
     
    268272                <th scope="row"><label for="banned_email_domains"><?php _e( 'Banned Email Domains' ); ?></label></th>
    269273                <td>
     274                    <?php
     275                    $banned_email_domains = get_site_option( 'banned_email_domains' );
     276
     277                    if ( $banned_email_domains ) {
     278                        $banned_email_domains = implode( "\n", (array) $banned_email_domains );
     279                    }
     280                    ?>
    270281                    <textarea name="banned_email_domains" id="banned_email_domains" aria-describedby="banned-email-domains-desc" cols="45" rows="5">
    271 <?php echo esc_textarea( get_site_option( 'banned_email_domains' ) == '' ? '' : implode( "\n", (array) get_site_option( 'banned_email_domains' ) ) ); ?></textarea>
     282<?php echo esc_textarea( $banned_email_domains ); ?></textarea>
    272283                    <p class="description" id="banned-email-domains-desc">
    273284                        <?php _e( 'If you want to ban domains from site registrations. One domain per line.' ); ?>
  • trunk/src/wp-admin/network/site-info.php

    r47557 r47853  
    3636$is_main_site  = is_main_site( $id );
    3737
    38 if ( isset( $_REQUEST['action'] ) && 'update-site' == $_REQUEST['action'] ) {
     38if ( isset( $_REQUEST['action'] ) && 'update-site' === $_REQUEST['action'] ) {
    3939    check_admin_referer( 'edit-site' );
    4040
     
    118118if ( isset( $_GET['update'] ) ) {
    119119    $messages = array();
    120     if ( 'updated' == $_GET['update'] ) {
     120    if ( 'updated' === $_GET['update'] ) {
    121121        $messages[] = __( 'Site info updated.' );
    122122    }
  • trunk/src/wp-admin/network/site-new.php

    r47606 r47853  
    3434);
    3535
    36 if ( isset( $_REQUEST['action'] ) && 'add-site' == $_REQUEST['action'] ) {
     36if ( isset( $_REQUEST['action'] ) && 'add-site' === $_REQUEST['action'] ) {
    3737    check_admin_referer( 'add-blog', '_wpnonce_add-blog' );
    3838
     
    140140    $id = wpmu_create_blog( $newdomain, $path, $title, $user_id, $meta, get_current_network_id() );
    141141    $wpdb->show_errors();
     142
    142143    if ( ! is_wp_error( $id ) ) {
    143144        if ( ! is_super_admin( $user_id ) && ! get_user_option( 'primary_blog', $user_id ) ) {
     
    188189if ( isset( $_GET['update'] ) ) {
    189190    $messages = array();
    190     if ( 'added' == $_GET['update'] ) {
     191    if ( 'added' === $_GET['update'] ) {
    191192        $messages[] = sprintf(
    192193            /* translators: 1: Dashboard URL, 2: Network admin edit URL. */
  • trunk/src/wp-admin/network/site-settings.php

    r47550 r47853  
    3535$is_main_site = is_main_site( $id );
    3636
    37 if ( isset( $_REQUEST['action'] ) && 'update-site' == $_REQUEST['action'] && is_array( $_POST['option'] ) ) {
     37if ( isset( $_REQUEST['action'] ) && 'update-site' === $_REQUEST['action'] && is_array( $_POST['option'] ) ) {
    3838    check_admin_referer( 'edit-site' );
    3939
     
    4545        $val = wp_unslash( $val );
    4646        if ( 0 === $key || is_array( $val ) || in_array( $key, $skip_options, true ) ) {
    47             continue; // Avoids "0 is a protected WP option and may not be modified" error when edit blog options.
     47            continue; // Avoids "0 is a protected WP option and may not be modified" error when editing blog options.
    4848        }
    4949        update_option( $key, $val );
     
    7575if ( isset( $_GET['update'] ) ) {
    7676    $messages = array();
    77     if ( 'updated' == $_GET['update'] ) {
     77    if ( 'updated' === $_GET['update'] ) {
    7878        $messages[] = __( 'Site options updated.' );
    7979    }
     
    124124        );
    125125        $options     = $wpdb->get_results( $query );
     126
    126127        foreach ( $options as $option ) {
    127128            if ( 'default_role' === $option->option_name ) {
    128129                $editblog_default_role = $option->option_value;
    129130            }
     131
    130132            $disabled = false;
    131133            $class    = 'all-options';
     134
    132135            if ( is_serialized( $option->option_value ) ) {
    133136                if ( is_serialized_string( $option->option_value ) ) {
     
    139142                }
    140143            }
     144
    141145            if ( strpos( $option->option_value, "\n" ) !== false ) {
    142146                ?>
     
    159163            }
    160164        } // End foreach.
     165
    161166        /**
    162167         * Fires at the end of the Edit Site form, before the submit button.
  • trunk/src/wp-admin/network/site-themes.php

    r47198 r47853  
    159159}
    160160
    161 if ( isset( $_GET['action'] ) && 'update-site' == $_GET['action'] ) {
     161if ( isset( $_GET['action'] ) && 'update-site' === $_GET['action'] ) {
    162162    wp_safe_redirect( $referer );
    163163    exit();
     
    189189if ( isset( $_GET['enabled'] ) ) {
    190190    $enabled = absint( $_GET['enabled'] );
    191     if ( 1 == $enabled ) {
     191    if ( 1 === $enabled ) {
    192192        $message = __( 'Theme enabled.' );
    193193    } else {
     
    198198} elseif ( isset( $_GET['disabled'] ) ) {
    199199    $disabled = absint( $_GET['disabled'] );
    200     if ( 1 == $disabled ) {
     200    if ( 1 === $disabled ) {
    201201        $message = __( 'Theme disabled.' );
    202202    } else {
     
    205205    }
    206206    echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $disabled ) ) . '</p></div>';
    207 } elseif ( isset( $_GET['error'] ) && 'none' == $_GET['error'] ) {
     207} elseif ( isset( $_GET['error'] ) && 'none' === $_GET['error'] ) {
    208208    echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'No theme selected.' ) . '</p></div>';
    209209}
  • trunk/src/wp-admin/network/site-users.php

    r47198 r47853  
    7878                    } else {
    7979                        $update = 'newuser';
     80
    8081                        /**
    8182                         * Fires after a user has been created via the network site-users.php page.
     
    179180            check_admin_referer( 'bulk-users' );
    180181            $userids = $_REQUEST['users'];
     182
    181183            /** This action is documented in wp-admin/network/site-themes.php */
    182184            $referer = apply_filters( 'handle_network_bulk_actions-' . get_current_screen()->id, $referer, $action, $userids, $id ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
    183             $update  = $action;
     185
     186            $update = $action;
    184187            break;
    185188    }
     
    191194restore_current_blog();
    192195
    193 if ( isset( $_GET['action'] ) && 'update-site' == $_GET['action'] ) {
     196if ( isset( $_GET['action'] ) && 'update-site' === $_GET['action'] ) {
    194197    wp_safe_redirect( $referer );
    195198    exit();
  • trunk/src/wp-admin/network/sites.php

    r47219 r47853  
    224224                    }
    225225                }
     226
    226227                if ( ! in_array( $doaction, array( 'delete', 'spam', 'notspam' ), true ) ) {
    227228                    $redirect_to = wp_get_referer();
    228229                    $blogs       = (array) $_POST['allblogs'];
     230
    229231                    /** This action is documented in wp-admin/network/site-themes.php */
    230232                    $redirect_to = apply_filters( 'handle_network_bulk_actions-' . get_current_screen()->id, $redirect_to, $doaction, $blogs, $id ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
     233
    231234                    wp_safe_redirect( $redirect_to );
    232235                    exit();
     
    238241                    add_query_arg( $_POST, network_admin_url( 'sites.php' ) )
    239242                );
     243
    240244                wp_redirect( $location );
    241245                exit;
     
    271275             */
    272276            do_action( 'deactivate_blog', $id );
     277
    273278            update_blog_status( $id, 'deleted', '1' );
    274279            break;
  • trunk/src/wp-admin/network/theme-install.php

    r47198 r47853  
    88 */
    99
    10 if ( isset( $_GET['tab'] ) && ( 'theme-information' == $_GET['tab'] ) ) {
     10if ( isset( $_GET['tab'] ) && ( 'theme-information' === $_GET['tab'] ) ) {
    1111    define( 'IFRAME_REQUEST', true );
    1212}
  • trunk/src/wp-admin/network/user-new.php

    r47198 r47853  
    3131);
    3232
    33 if ( isset( $_REQUEST['action'] ) && 'add-user' == $_REQUEST['action'] ) {
     33if ( isset( $_REQUEST['action'] ) && 'add-user' === $_REQUEST['action'] ) {
    3434    check_admin_referer( 'add-user', '_wpnonce_add-user' );
    3535
     
    4545
    4646    $user_details = wpmu_validate_user_signup( $user['username'], $user['email'] );
     47
    4748    if ( is_wp_error( $user_details['errors'] ) && $user_details['errors']->has_errors() ) {
    4849        $add_user_errors = $user_details['errors'];
     
    6263             */
    6364            do_action( 'network_user_new_created_user', $user_id );
     65
    6466            wp_redirect(
    6567                add_query_arg(
     
    7880if ( isset( $_GET['update'] ) ) {
    7981    $messages = array();
    80     if ( 'added' == $_GET['update'] ) {
     82    if ( 'added' === $_GET['update'] ) {
    8183        $edit_link = '';
    8284        if ( isset( $_GET['user_id'] ) ) {
  • trunk/src/wp-admin/network/users.php

    r47219 r47853  
    2828
    2929            $id = intval( $_GET['id'] );
    30             if ( '0' != $id && '1' != $id ) {
     30            if ( $id > 1 ) {
    3131                $_POST['allusers'] = array( $id ); // confirm_delete_users() can only handle arrays.
    3232                $title             = __( 'Users' );
     
    117117                if ( ! in_array( $doaction, array( 'delete', 'spam', 'notspam' ), true ) ) {
    118118                    $sendback = wp_get_referer();
    119 
    120119                    $user_ids = (array) $_POST['allusers'];
     120
    121121                    /** This action is documented in wp-admin/network/site-themes.php */
    122122                    $sendback = apply_filters( 'handle_network_bulk_actions-' . get_current_screen()->id, $sendback, $doaction, $user_ids ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
     
    158158                        }
    159159
    160                         if ( ! empty( $_POST['delete'] ) && 'reassign' == $_POST['delete'][ $blogid ][ $id ] ) {
     160                        if ( ! empty( $_POST['delete'] ) && 'reassign' === $_POST['delete'][ $blogid ][ $id ] ) {
    161161                            remove_user_from_blog( $id, $blogid, (int) $user_id );
    162162                        } else {
     
    166166                }
    167167            }
     168
    168169            $i = 0;
     170
    169171            if ( is_array( $_POST['user'] ) && ! empty( $_POST['user'] ) ) {
    170172                foreach ( $_POST['user'] as $id ) {
     
    177179            }
    178180
    179             if ( 1 == $i ) {
     181            if ( 1 === $i ) {
    180182                $deletefunction = 'delete';
    181183            } else {
Note: See TracChangeset for help on using the changeset viewer.