Make WordPress Core


Ignore:
Timestamp:
09/27/2012 05:11:07 PM (14 years ago)
Author:
ryan
Message:

Remove dupe/deprecated code from sites.php.

Props wonderboymusic
fixes #21553

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/network/sites.php

    r21003 r22064  
    1717        wp_die( __( 'You do not have permission to access this page.' ) );
    1818
    19 $wp_list_table = _get_list_table('WP_MS_Sites_List_Table');
     19$wp_list_table = _get_list_table( 'WP_MS_Sites_List_Table' );
    2020$pagenum = $wp_list_table->get_pagenum();
    2121
     
    2323$parent_file = 'sites.php';
    2424
    25 add_screen_option( 'per_page', array('label' => _x( 'Sites', 'sites per page (screen options)' )) );
     25add_screen_option( 'per_page', array( 'label' => _x( 'Sites', 'sites per page (screen options)' ) ) );
    2626
    2727get_current_screen()->add_help_tab( array(
     
    5252        do_action( 'wpmuadminedit' , '' );
    5353
     54        if ( 'confirm' === $_GET['action'] ) {
     55                check_admin_referer( 'confirm' );
     56               
     57                if ( ! headers_sent() ) {
     58                        nocache_headers();
     59                        header( 'Content-Type: text/html; charset=utf-8' );
     60                }
     61                if ( $current_site->blog_id == $id )
     62                        wp_die( __( 'You are not allowed to change the current site.' ) );
     63                ?>
     64                <!DOCTYPE html>
     65                <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
     66                        <head>
     67                                <title><?php _e( 'WordPress &rsaquo; Confirm your action' ); ?></title>
     68
     69                                <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     70                                <?php
     71                                wp_admin_css( 'install', true );
     72                                wp_admin_css( 'ie', true );
     73                                ?>
     74                        </head>
     75                        <body>
     76                                <h1 id="logo"><img alt="WordPress" src="<?php echo esc_attr( admin_url( 'images/wordpress-logo.png?ver=20120216' ) ); ?>" /></h1>
     77                                <form action="sites.php?action=<?php echo esc_attr( $_GET['action2'] ) ?>" method="post">
     78                                        <input type="hidden" name="action" value="<?php echo esc_attr( $_GET['action2'] ) ?>" />
     79                                        <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
     80                                        <input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr( wp_get_referer() ); ?>" />
     81                                        <?php wp_nonce_field( $_GET['action2'], '_wpnonce', false ); ?>
     82                                        <p><?php echo esc_html( stripslashes( $_GET['msg'] ) ); ?></p>
     83                                        <?php submit_button( __('Confirm'), 'button' ); ?>
     84                                </form>
     85                        </body>
     86                </html>
     87                <?php
     88                exit();
     89        }
     90       
     91        $updated_action = '';
     92       
     93        $manage_actions = array( 'deleteblog', 'allblogs', 'archiveblog', 'unarchiveblog', 'activateblog', 'deactivateblog', 'unspamblog', 'spamblog', 'unmatureblog', 'matureblog' );
     94        if ( in_array( $_GET['action'], $manage_actions ) ) {           
     95                $action = $_GET['action'];
     96                if ( 'allblogs' === $action )
     97                        $action = 'bulk-sites';
     98
     99                check_admin_referer( $action );
     100        }
     101               
    54102        switch ( $_GET['action'] ) {
    55                 case 'updateblog':
    56                         // No longer used.
    57                 break;
    58103
    59104                case 'deleteblog':
    60                         check_admin_referer('deleteblog');
    61                         if ( ! ( current_user_can( 'manage_sites' ) && current_user_can( 'delete_sites' ) ) )
     105                        if ( ! current_user_can( 'delete_sites' ) )
    62106                                wp_die( __( 'You do not have permission to access this page.' ) );
    63107
     108                        $updated_action = 'not_deleted';
    64109                        if ( $id != '0' && $id != $current_site->blog_id && current_user_can( 'delete_site', $id ) ) {
    65110                                wpmu_delete_blog( $id, true );
    66                                 wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'delete' ), wp_get_referer() ) );
    67                         } else {
    68                                 wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'not_deleted' ), wp_get_referer() ) );
     111                                $updated_action = 'delete';     
    69112                        }
    70 
    71                         exit();
    72113                break;
    73114
    74115                case 'allblogs':
    75116                        if ( ( isset( $_POST['action'] ) || isset( $_POST['action2'] ) ) && isset( $_POST['allblogs'] ) ) {
    76                                 check_admin_referer( 'bulk-sites' );
    77 
    78                                 if ( ! current_user_can( 'manage_sites' ) )
    79                                         wp_die( __( 'You do not have permission to access this page.' ) );
    80 
    81117                                $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2'];
    82                                 $blogfunction = '';
    83 
     118                               
    84119                                foreach ( (array) $_POST['allblogs'] as $key => $val ) {
    85120                                        if ( $val != '0' && $val != $current_site->blog_id ) {
     
    88123                                                                if ( ! current_user_can( 'delete_site', $val ) )
    89124                                                                        wp_die( __( 'You are not allowed to delete the site.' ) );
    90                                                                 $blogfunction = 'all_delete';
     125                                                               
     126                                                                $updated_action = 'all_delete';
    91127                                                                wpmu_delete_blog( $val, true );
    92128                                                        break;
    93129
    94130                                                        case 'spam':
    95                                                                 $blogfunction = 'all_spam';
    96                                                                 update_blog_status( $val, 'spam', '1' );
    97                                                                 set_time_limit( 60 );
    98                                                         break;
    99 
    100131                                                        case 'notspam':
    101                                                                 $blogfunction = 'all_notspam';
    102                                                                 update_blog_status( $val, 'spam', '0' );
     132                                                                $updated_action = ( 'spam' === $doaction ) ? 'all_spam' : 'all_notspam';
     133                                                                update_blog_status( $val, 'spam', ( 'spam' === $doaction ) ? '1' : '0' );
    103134                                                                set_time_limit( 60 );
    104135                                                        break;
     
    108139                                        }
    109140                                }
    110 
    111                                 wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $blogfunction ), wp_get_referer() ) );
    112141                        } else {
    113142                                wp_redirect( network_admin_url( 'sites.php' ) );
     143                                exit();
    114144                        }
    115                         exit();
    116145                break;
    117146
    118147                case 'archiveblog':
    119                         check_admin_referer( 'archiveblog' );
    120                         if ( ! current_user_can( 'manage_sites' ) )
    121                                 wp_die( __( 'You do not have permission to access this page.' ) );
    122 
    123                         update_blog_status( $id, 'archived', '1' );
    124                         wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'archive' ), wp_get_referer() ) );
    125                         exit();
    126                 break;
    127 
    128148                case 'unarchiveblog':
    129                         check_admin_referer( 'unarchiveblog' );
    130                         if ( ! current_user_can( 'manage_sites' ) )
    131                                 wp_die( __( 'You do not have permission to access this page.' ) );
    132 
    133                         update_blog_status( $id, 'archived', '0' );
    134                         wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unarchive' ), wp_get_referer() ) );
    135                         exit();
     149                        update_blog_status( $id, 'archived', ( 'archiveblog' === $_GET['action'] ) ? '1' : '0' );
    136150                break;
    137151
    138152                case 'activateblog':
    139                         check_admin_referer( 'activateblog' );
    140                         if ( ! current_user_can( 'manage_sites' ) )
    141                                 wp_die( __( 'You do not have permission to access this page.' ) );
    142 
    143153                        update_blog_status( $id, 'deleted', '0' );
    144154                        do_action( 'activate_blog', $id );
    145                         wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'activate' ), wp_get_referer() ) );
    146                         exit();
    147155                break;
    148156
    149157                case 'deactivateblog':
    150                         check_admin_referer( 'deactivateblog' );
    151                         if ( ! current_user_can( 'manage_sites' ) )
    152                                 wp_die( __( 'You do not have permission to access this page.' ) );
    153 
    154158                        do_action( 'deactivate_blog', $id );
    155159                        update_blog_status( $id, 'deleted', '1' );
    156                         wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'deactivate' ), wp_get_referer() ) );
    157                         exit();
    158160                break;
    159161
    160162                case 'unspamblog':
    161                         check_admin_referer( 'unspamblog' );
    162                         if ( ! current_user_can( 'manage_sites' ) )
    163                                 wp_die( __( 'You do not have permission to access this page.' ) );
    164 
    165                         update_blog_status( $id, 'spam', '0' );
    166                         wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unspam' ), wp_get_referer() ) );
    167                         exit();
    168                 break;
    169 
    170163                case 'spamblog':
    171                         check_admin_referer( 'spamblog' );
    172                         if ( ! current_user_can( 'manage_sites' ) )
    173                                 wp_die( __( 'You do not have permission to access this page.' ) );
    174 
    175                         update_blog_status( $id, 'spam', '1' );
    176                         wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'spam' ), wp_get_referer() ) );
    177                         exit();
    178                 break;
    179 
     164                        update_blog_status( $id, 'spam', ( 'spamblog' === $_GET['action'] ) ? '1' : '0' );
     165                break;
     166       
    180167                case 'unmatureblog':
    181                         check_admin_referer( 'unmatureblog' );
    182                         if ( ! current_user_can( 'manage_sites' ) )
    183                                 wp_die( __( 'You do not have permission to access this page.' ) );
    184 
    185                         update_blog_status( $id, 'mature', '0' );
    186                         wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unmature' ), wp_get_referer() ) );
    187                         exit();
    188                 break;
    189 
    190168                case 'matureblog':
    191                         check_admin_referer( 'matureblog' );
    192                         if ( ! current_user_can( 'manage_sites' ) )
    193                                 wp_die( __( 'You do not have permission to access this page.' ) );
    194 
    195                         update_blog_status( $id, 'mature', '1' );
    196                         wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'mature' ), wp_get_referer() ) );
    197                         exit();
    198                 break;
    199 
    200                 // Common
    201                 case 'confirm':
    202                         check_admin_referer( 'confirm' );
    203                         if ( !headers_sent() ) {
    204                                 nocache_headers();
    205                                 header( 'Content-Type: text/html; charset=utf-8' );
    206                         }
    207                         if ( $current_site->blog_id == $id )
    208                                 wp_die( __( 'You are not allowed to change the current site.' ) );
    209                         ?>
    210                         <!DOCTYPE html>
    211                         <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
    212                                 <head>
    213                                         <title><?php _e( 'WordPress &rsaquo; Confirm your action' ); ?></title>
    214 
    215                                         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    216                                         <?php
    217                                         wp_admin_css( 'install', true );
    218                                         wp_admin_css( 'ie', true );
    219                                         ?>
    220                                 </head>
    221                                 <body>
    222                                         <h1 id="logo"><img alt="WordPress" src="<?php echo esc_attr( admin_url( 'images/wordpress-logo.png?ver=20120216' ) ); ?>" /></h1>
    223                                         <form action="sites.php?action=<?php echo esc_attr( $_GET['action2'] ) ?>" method="post">
    224                                                 <input type="hidden" name="action" value="<?php echo esc_attr( $_GET['action2'] ) ?>" />
    225                                                 <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
    226                                                 <input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr( wp_get_referer() ); ?>" />
    227                                                 <?php wp_nonce_field( $_GET['action2'], '_wpnonce', false ); ?>
    228                                                 <p><?php echo esc_html( stripslashes( $_GET['msg'] ) ); ?></p>
    229                                                 <?php submit_button( __('Confirm'), 'button' ); ?>
    230                                         </form>
    231                                 </body>
    232                         </html>
    233                         <?php
    234                         exit();
    235                 break;
     169                        update_blog_status( $id, 'mature', ( 'matureblog' === $_GET['action'] ) ? '1' : '0' );
     170                break;
     171        }
     172       
     173        if ( empty( $updated_action ) && in_array( $_GET['action'], $manage_actions ) )
     174                $updated_action = $_GET['action'];
     175       
     176        if ( ! empty( $updated_action ) ) {
     177                wp_safe_redirect( add_query_arg( array( 'updated' => $updated_action ), wp_get_referer() ) );
     178                exit();
    236179        }
    237180}
    238181
    239182$msg = '';
    240 if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty( $_REQUEST['action'] ) ) {
    241         switch ( $_REQUEST['action'] ) {
     183if ( isset( $_GET['updated'] ) ) {
     184        switch ( $_GET['updated'] ) {
    242185                case 'all_notspam':
    243186                        $msg = __( 'Sites removed from spam.' );
     
    255198                        $msg = __( 'You do not have permission to delete that site.' );
    256199                break;
    257                 case 'archive':
     200                case 'archiveblog':
    258201                        $msg = __( 'Site archived.' );
    259202                break;
    260                 case 'unarchive':
     203                case 'unarchiveblog':
    261204                        $msg = __( 'Site unarchived.' );
    262205                break;
    263                 case 'activate':
     206                case 'activateblog':
    264207                        $msg = __( 'Site activated.' );
    265208                break;
    266                 case 'deactivate':
     209                case 'deactivateblog':
    267210                        $msg = __( 'Site deactivated.' );
    268211                break;
    269                 case 'unspam':
     212                case 'unspamblog':
    270213                        $msg = __( 'Site removed from spam.' );
    271214                break;
    272                 case 'spam':
     215                case 'spamblog':
    273216                        $msg = __( 'Site marked as spam.' );
    274217                break;
    275218                default:
    276                         $msg = apply_filters( 'network_sites_updated_message_' . $_REQUEST['action'] , __( 'Settings saved.' ) );
    277                 break;
    278         }
    279         if ( $msg )
     219                        $msg = apply_filters( 'network_sites_updated_message_' . $_GET['updated'], __( 'Settings saved.' ) );
     220                break;
     221        }
     222       
     223        if ( ! empty( $msg ) )
    280224                $msg = '<div class="updated" id="message"><p>' . $msg . '</p></div>';
    281225}
     
    287231
    288232<div class="wrap">
    289 <?php screen_icon('ms-admin'); ?>
    290 <h2><?php _e('Sites') ?>
    291 <?php echo $msg; ?>
     233<?php screen_icon( 'ms-admin' ); ?>
     234<h2><?php _e( 'Sites' ) ?>
     235       
    292236<?php if ( current_user_can( 'create_sites') ) : ?>
    293         <a href="<?php echo network_admin_url('site-new.php'); ?>" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'site' ); ?></a>
     237        <a href="<?php echo network_admin_url('site-new.php'); ?>" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'site' ); ?></a>
    294238<?php endif; ?>
    295239
     
    299243</h2>
    300244
     245<?php echo $msg; ?>     
     246       
    301247<form action="" method="get" id="ms-search">
    302248<?php $wp_list_table->search_box( __( 'Search Sites' ), 'site' ); ?>
Note: See TracChangeset for help on using the changeset viewer.