Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (7 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/network/site-settings.php

    r41065 r42343  
    1111require_once( dirname( __FILE__ ) . '/admin.php' );
    1212
    13 if ( ! current_user_can( 'manage_sites' ) )
     13if ( ! current_user_can( 'manage_sites' ) ) {
    1414    wp_die( __( 'Sorry, you are not allowed to edit this site.' ) );
     15}
    1516
    1617get_current_screen()->add_help_tab( get_site_screen_help_tab_args() );
     
    1920$id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
    2021
    21 if ( ! $id )
    22     wp_die( __('Invalid site ID.') );
     22if ( ! $id ) {
     23    wp_die( __( 'Invalid site ID.' ) );
     24}
    2325
    2426$details = get_site( $id );
     
    2729}
    2830
    29 if ( !can_edit_network( $details->site_id ) )
     31if ( ! can_edit_network( $details->site_id ) ) {
    3032    wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
     33}
    3134
    3235$is_main_site = is_main_site( $id );
    3336
    34 if ( isset($_REQUEST['action']) && 'update-site' == $_REQUEST['action'] && is_array( $_POST['option'] ) ) {
     37if ( isset( $_REQUEST['action'] ) && 'update-site' == $_REQUEST['action'] && is_array( $_POST['option'] ) ) {
    3538    check_admin_referer( 'edit-site' );
    3639
     
    4144        $key = wp_unslash( $key );
    4245        $val = wp_unslash( $val );
    43         if ( $key === 0 || is_array( $val ) || in_array($key, $skip_options) )
     46        if ( $key === 0 || is_array( $val ) || in_array( $key, $skip_options ) ) {
    4447            continue; // Avoids "0 is a protected WP option and may not be modified" error when edit blog options
     48        }
    4549        update_option( $key, $val );
    4650    }
     
    5761
    5862    restore_current_blog();
    59     wp_redirect( add_query_arg( array( 'update' => 'updated', 'id' => $id ), 'site-settings.php') );
     63    wp_redirect(
     64        add_query_arg(
     65            array(
     66                'update' => 'updated',
     67                'id'     => $id,
     68            ), 'site-settings.php'
     69        )
     70    );
    6071    exit;
    6172}
    6273
    63 if ( isset($_GET['update']) ) {
     74if ( isset( $_GET['update'] ) ) {
    6475    $messages = array();
    65     if ( 'updated' == $_GET['update'] )
    66         $messages[] = __('Site options updated.');
     76    if ( 'updated' == $_GET['update'] ) {
     77        $messages[] = __( 'Site options updated.' );
     78    }
    6779}
    6880
     
    7082$title = sprintf( __( 'Edit Site: %s' ), esc_html( $details->blogname ) );
    7183
    72 $parent_file = 'sites.php';
     84$parent_file  = 'sites.php';
    7385$submenu_file = 'sites.php';
    7486
     
    8395<?php
    8496
    85 network_edit_site_nav( array(
    86     'blog_id'  => $id,
    87     'selected' => 'site-settings'
    88 ) );
     97network_edit_site_nav(
     98    array(
     99        'blog_id'  => $id,
     100        'selected' => 'site-settings',
     101    )
     102);
    89103
    90104if ( ! empty( $messages ) ) {
    91     foreach ( $messages as $msg )
     105    foreach ( $messages as $msg ) {
    92106        echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>';
    93 } ?>
     107    }
     108}
     109?>
    94110<form method="post" action="site-settings.php?action=update-site">
    95111    <?php wp_nonce_field( 'edit-site' ); ?>
    96     <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
     112    <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
    97113    <table class="form-table">
    98114        <?php
    99115        $blog_prefix = $wpdb->get_blog_prefix( $id );
    100         $sql = "SELECT * FROM {$blog_prefix}options
     116        $sql         = "SELECT * FROM {$blog_prefix}options
    101117            WHERE option_name NOT LIKE %s
    102118            AND option_name NOT LIKE %s";
    103         $query = $wpdb->prepare( $sql,
     119        $query       = $wpdb->prepare(
     120            $sql,
    104121            $wpdb->esc_like( '_' ) . '%',
    105122            '%' . $wpdb->esc_like( 'user_roles' )
    106123        );
    107         $options = $wpdb->get_results( $query );
     124        $options     = $wpdb->get_results( $query );
    108125        foreach ( $options as $option ) {
    109             if ( $option->option_name == 'default_role' )
     126            if ( $option->option_name == 'default_role' ) {
    110127                $editblog_default_role = $option->option_value;
     128            }
    111129            $disabled = false;
    112             $class = 'all-options';
     130            $class    = 'all-options';
    113131            if ( is_serialized( $option->option_value ) ) {
    114132                if ( is_serialized_string( $option->option_value ) ) {
     
    116134                } else {
    117135                    $option->option_value = 'SERIALIZED DATA';
    118                     $disabled = true;
    119                     $class = 'all-options disabled';
     136                    $disabled             = true;
     137                    $class                = 'all-options disabled';
    120138                }
    121139            }
     
    123141            ?>
    124142                <tr class="form-field">
    125                     <th scope="row"><label for="<?php echo esc_attr( $option->option_name ) ?>"><?php echo ucwords( str_replace( "_", " ", $option->option_name ) ) ?></label></th>
    126                     <td><textarea class="<?php echo $class; ?>" rows="5" cols="40" name="option[<?php echo esc_attr( $option->option_name ) ?>]" id="<?php echo esc_attr( $option->option_name ) ?>"<?php disabled( $disabled ) ?>><?php echo esc_textarea( $option->option_value ) ?></textarea></td>
     143                    <th scope="row"><label for="<?php echo esc_attr( $option->option_name ); ?>"><?php echo ucwords( str_replace( '_', ' ', $option->option_name ) ); ?></label></th>
     144                    <td><textarea class="<?php echo $class; ?>" rows="5" cols="40" name="option[<?php echo esc_attr( $option->option_name ); ?>]" id="<?php echo esc_attr( $option->option_name ); ?>"<?php disabled( $disabled ); ?>><?php echo esc_textarea( $option->option_value ); ?></textarea></td>
    127145                </tr>
    128146            <?php
     
    130148            ?>
    131149                <tr class="form-field">
    132                     <th scope="row"><label for="<?php echo esc_attr( $option->option_name ) ?>"><?php echo esc_html( ucwords( str_replace( "_", " ", $option->option_name ) ) ); ?></label></th>
     150                    <th scope="row"><label for="<?php echo esc_attr( $option->option_name ); ?>"><?php echo esc_html( ucwords( str_replace( '_', ' ', $option->option_name ) ) ); ?></label></th>
    133151                    <?php if ( $is_main_site && in_array( $option->option_name, array( 'siteurl', 'home' ) ) ) { ?>
    134                     <td><code><?php echo esc_html( $option->option_value ) ?></code></td>
     152                    <td><code><?php echo esc_html( $option->option_value ); ?></code></td>
    135153                    <?php } else { ?>
    136                     <td><input class="<?php echo $class; ?>" name="option[<?php echo esc_attr( $option->option_name ) ?>]" type="text" id="<?php echo esc_attr( $option->option_name ) ?>" value="<?php echo esc_attr( $option->option_value ) ?>" size="40" <?php disabled( $disabled ) ?> /></td>
     154                    <td><input class="<?php echo $class; ?>" name="option[<?php echo esc_attr( $option->option_name ); ?>]" type="text" id="<?php echo esc_attr( $option->option_name ); ?>" value="<?php echo esc_attr( $option->option_value ); ?>" size="40" <?php disabled( $disabled ); ?> /></td>
    137155                    <?php } ?>
    138156                </tr>
Note: See TracChangeset for help on using the changeset viewer.