Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (8 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-themes.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 manage themes for this site.' ) );
     15}
    1516
    1617get_current_screen()->add_help_tab( get_site_screen_help_tab_args() );
    1718get_current_screen()->set_help_sidebar( get_site_screen_help_sidebar_content() );
    1819
    19 get_current_screen()->set_screen_reader_content( array(
    20     'heading_views'      => __( 'Filter site themes list' ),
    21     'heading_pagination' => __( 'Site themes list navigation' ),
    22     'heading_list'       => __( 'Site themes list' ),
    23 ) );
    24 
    25 $wp_list_table = _get_list_table('WP_MS_Themes_List_Table');
     20get_current_screen()->set_screen_reader_content(
     21    array(
     22        'heading_views'      => __( 'Filter site themes list' ),
     23        'heading_pagination' => __( 'Site themes list navigation' ),
     24        'heading_list'       => __( 'Site themes list' ),
     25    )
     26);
     27
     28$wp_list_table = _get_list_table( 'WP_MS_Themes_List_Table' );
    2629
    2730$action = $wp_list_table->current_action();
    2831
    29 $s = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
     32$s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
    3033
    3134// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
    32 $temp_args = array( 'enabled', 'disabled', 'error' );
     35$temp_args              = array( 'enabled', 'disabled', 'error' );
    3336$_SERVER['REQUEST_URI'] = remove_query_arg( $temp_args, $_SERVER['REQUEST_URI'] );
    34 $referer = remove_query_arg( $temp_args, wp_get_referer() );
     37$referer                = remove_query_arg( $temp_args, wp_get_referer() );
    3538
    3639if ( ! empty( $_REQUEST['paged'] ) ) {
     
    4043$id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
    4144
    42 if ( ! $id )
    43     wp_die( __('Invalid site ID.') );
     45if ( ! $id ) {
     46    wp_die( __( 'Invalid site ID.' ) );
     47}
    4448
    4549$wp_list_table->prepare_items();
     
    5054}
    5155
    52 if ( !can_edit_network( $details->site_id ) )
     56if ( ! can_edit_network( $details->site_id ) ) {
    5357    wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
     58}
    5459
    5560$is_main_site = is_main_site( $id );
     
    6267        case 'enable':
    6368            check_admin_referer( 'enable-theme_' . $_GET['theme'] );
    64             $theme = $_GET['theme'];
     69            $theme  = $_GET['theme'];
    6570            $action = 'enabled';
    66             $n = 1;
    67             if ( !$allowed_themes )
     71            $n      = 1;
     72            if ( ! $allowed_themes ) {
    6873                $allowed_themes = array( $theme => true );
    69             else
    70                 $allowed_themes[$theme] = true;
     74            } else {
     75                $allowed_themes[ $theme ] = true;
     76            }
    7177            break;
    7278        case 'disable':
    7379            check_admin_referer( 'disable-theme_' . $_GET['theme'] );
    74             $theme = $_GET['theme'];
     80            $theme  = $_GET['theme'];
    7581            $action = 'disabled';
    76             $n = 1;
    77             if ( !$allowed_themes )
     82            $n      = 1;
     83            if ( ! $allowed_themes ) {
    7884                $allowed_themes = array();
    79             else
    80                 unset( $allowed_themes[$theme] );
     85            } else {
     86                unset( $allowed_themes[ $theme ] );
     87            }
    8188            break;
    8289        case 'enable-selected':
     
    8592                $themes = (array) $_POST['checked'];
    8693                $action = 'enabled';
    87                 $n = count( $themes );
    88                 foreach ( (array) $themes as $theme )
     94                $n      = count( $themes );
     95                foreach ( (array) $themes as $theme ) {
    8996                    $allowed_themes[ $theme ] = true;
     97                }
    9098            } else {
    9199                $action = 'error';
    92                 $n = 'none';
     100                $n      = 'none';
    93101            }
    94102            break;
     
    98106                $themes = (array) $_POST['checked'];
    99107                $action = 'disabled';
    100                 $n = count( $themes );
    101                 foreach ( (array) $themes as $theme )
     108                $n      = count( $themes );
     109                foreach ( (array) $themes as $theme ) {
    102110                    unset( $allowed_themes[ $theme ] );
     111                }
    103112            } else {
    104113                $action = 'error';
    105                 $n = 'none';
     114                $n      = 'none';
    106115            }
    107116            break;
     
    110119                check_admin_referer( 'bulk-themes' );
    111120                $themes = (array) $_POST['checked'];
    112                 $n = count( $themes );
     121                $n      = count( $themes );
    113122                $screen = get_current_screen()->id;
    114123
     
    131140            } else {
    132141                $action = 'error';
    133                 $n = 'none';
     142                $n      = 'none';
    134143            }
    135144    }
     
    138147    restore_current_blog();
    139148
    140     wp_safe_redirect( add_query_arg( array( 'id' => $id, $action => $n ), $referer ) );
     149    wp_safe_redirect(
     150        add_query_arg(
     151            array(
     152                'id'    => $id,
     153                $action => $n,
     154            ), $referer
     155        )
     156    );
    141157    exit;
    142158}
     
    153169$title = sprintf( __( 'Edit Site: %s' ), esc_html( $details->blogname ) );
    154170
    155 $parent_file = 'sites.php';
     171$parent_file  = 'sites.php';
    156172$submenu_file = 'sites.php';
    157173
     
    163179<?php
    164180
    165 network_edit_site_nav( array(
    166     'blog_id'  => $id,
    167     'selected' => 'site-themes'
    168 ) );
     181network_edit_site_nav(
     182    array(
     183        'blog_id'  => $id,
     184        'selected' => 'site-themes',
     185    )
     186);
    169187
    170188if ( isset( $_GET['enabled'] ) ) {
     
    186204} elseif ( isset( $_GET['error'] ) && 'none' == $_GET['error'] ) {
    187205    echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'No theme selected.' ) . '</p></div>';
    188 } ?>
    189 
    190 <p><?php _e( 'Network enabled themes are not shown on this screen.' ) ?></p>
     206}
     207?>
     208
     209<p><?php _e( 'Network enabled themes are not shown on this screen.' ); ?></p>
    191210
    192211<form method="get">
    193212<?php $wp_list_table->search_box( __( 'Search Installed Themes' ), 'theme' ); ?>
    194 <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
     213<input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
    195214</form>
    196215
     
    198217
    199218<form method="post" action="site-themes.php?action=update-site">
    200     <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
     219    <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
    201220
    202221<?php $wp_list_table->display(); ?>
     
    205224
    206225</div>
    207 <?php include(ABSPATH . 'wp-admin/admin-footer.php'); ?>
     226<?php include( ABSPATH . 'wp-admin/admin-footer.php' ); ?>
Note: See TracChangeset for help on using the changeset viewer.