<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[22064] trunk/wp-admin/network/sites.php: Remove dupe/deprecated code from sites.php.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/22064">22064</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2012-09-27 17:11:07 +0000 (Thu, 27 Sep 2012)</dd>
</dl>
<h3>Log Message</h3>
<pre>Remove dupe/deprecated code from sites.php.
Props wonderboymusic
fixes <a href="http://core.trac.wordpress.org/ticket/21553">#21553</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminnetworksitesphp">trunk/wp-admin/network/sites.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminnetworksitesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/network/sites.php (22063 => 22064)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/network/sites.php        2012-09-27 17:08:32 UTC (rev 22063)
+++ trunk/wp-admin/network/sites.php        2012-09-27 17:11:07 UTC (rev 22064)
</span><span class="lines">@@ -16,13 +16,13 @@
</span><span class="cx"> if ( ! current_user_can( 'manage_sites' ) )
</span><span class="cx">         wp_die( __( 'You do not have permission to access this page.' ) );
</span><span class="cx">
</span><del>-$wp_list_table = _get_list_table('WP_MS_Sites_List_Table');
</del><ins>+$wp_list_table = _get_list_table( 'WP_MS_Sites_List_Table' );
</ins><span class="cx"> $pagenum = $wp_list_table->get_pagenum();
</span><span class="cx">
</span><span class="cx"> $title = __( 'Sites' );
</span><span class="cx"> $parent_file = 'sites.php';
</span><span class="cx">
</span><del>-add_screen_option( 'per_page', array('label' => _x( 'Sites', 'sites per page (screen options)' )) );
</del><ins>+add_screen_option( 'per_page', array( 'label' => _x( 'Sites', 'sites per page (screen options)' ) ) );
</ins><span class="cx">
</span><span class="cx"> get_current_screen()->add_help_tab( array(
</span><span class="cx">         'id' => 'overview',
</span><span class="lines">@@ -51,55 +51,86 @@
</span><span class="cx"> if ( isset( $_GET['action'] ) ) {
</span><span class="cx">         do_action( 'wpmuadminedit' , '' );
</span><span class="cx">
</span><ins>+        if ( 'confirm' === $_GET['action'] ) {
+                check_admin_referer( 'confirm' );
+                
+                if ( ! headers_sent() ) {
+                        nocache_headers();
+                        header( 'Content-Type: text/html; charset=utf-8' );
+                }
+                if ( $current_site->blog_id == $id )
+                        wp_die( __( 'You are not allowed to change the current site.' ) );
+                ?>
+                <!DOCTYPE html>
+                <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
+                        <head>
+                                <title><?php _e( 'WordPress &rsaquo; Confirm your action' ); ?></title>
+
+                                <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+                                <?php
+                                wp_admin_css( 'install', true );
+                                wp_admin_css( 'ie', true );
+                                ?>
+                        </head>
+                        <body>
+                                <h1 id="logo"><img alt="WordPress" src="<?php echo esc_attr( admin_url( 'images/wordpress-logo.png?ver=20120216' ) ); ?>" /></h1>
+                                <form action="sites.php?action=<?php echo esc_attr( $_GET['action2'] ) ?>" method="post">
+                                        <input type="hidden" name="action" value="<?php echo esc_attr( $_GET['action2'] ) ?>" />
+                                        <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
+                                        <input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr( wp_get_referer() ); ?>" />
+                                        <?php wp_nonce_field( $_GET['action2'], '_wpnonce', false ); ?>
+                                        <p><?php echo esc_html( stripslashes( $_GET['msg'] ) ); ?></p>
+                                        <?php submit_button( __('Confirm'), 'button' ); ?>
+                                </form>
+                        </body>
+                </html>
+                <?php
+                exit();        
+        }
+        
+        $updated_action = '';
+        
+        $manage_actions = array( 'deleteblog', 'allblogs', 'archiveblog', 'unarchiveblog', 'activateblog', 'deactivateblog', 'unspamblog', 'spamblog', 'unmatureblog', 'matureblog' );
+        if ( in_array( $_GET['action'], $manage_actions ) ) {                
+                $action = $_GET['action'];
+                if ( 'allblogs' === $action )
+                        $action = 'bulk-sites';
+
+                check_admin_referer( $action );
+        }
+                
</ins><span class="cx">         switch ( $_GET['action'] ) {
</span><del>-                case 'updateblog':
-                        // No longer used.
-                break;
</del><span class="cx">
</span><span class="cx">                 case 'deleteblog':
</span><del>-                        check_admin_referer('deleteblog');
-                        if ( ! ( current_user_can( 'manage_sites' ) && current_user_can( 'delete_sites' ) ) )
</del><ins>+                        if ( ! current_user_can( 'delete_sites' ) )
</ins><span class="cx">                                 wp_die( __( 'You do not have permission to access this page.' ) );
</span><span class="cx">
</span><ins>+                        $updated_action = 'not_deleted';
</ins><span class="cx">                         if ( $id != '0' && $id != $current_site->blog_id && current_user_can( 'delete_site', $id ) ) {
</span><span class="cx">                                 wpmu_delete_blog( $id, true );
</span><del>-                                wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'delete' ), wp_get_referer() ) );
-                        } else {
-                                wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'not_deleted' ), wp_get_referer() ) );
</del><ins>+                                $updated_action = 'delete';        
</ins><span class="cx">                         }
</span><del>-
-                        exit();
</del><span class="cx">                 break;
</span><span class="cx">
</span><span class="cx">                 case 'allblogs':
</span><span class="cx">                         if ( ( isset( $_POST['action'] ) || isset( $_POST['action2'] ) ) && isset( $_POST['allblogs'] ) ) {
</span><del>-                                check_admin_referer( 'bulk-sites' );
-
-                                if ( ! current_user_can( 'manage_sites' ) )
-                                        wp_die( __( 'You do not have permission to access this page.' ) );
-
</del><span class="cx">                                 $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2'];
</span><del>-                                $blogfunction = '';
-
</del><ins>+                                
</ins><span class="cx">                                 foreach ( (array) $_POST['allblogs'] as $key => $val ) {
</span><span class="cx">                                         if ( $val != '0' && $val != $current_site->blog_id ) {
</span><span class="cx">                                                 switch ( $doaction ) {
</span><span class="cx">                                                         case 'delete':
</span><span class="cx">                                                                 if ( ! current_user_can( 'delete_site', $val ) )
</span><span class="cx">                                                                         wp_die( __( 'You are not allowed to delete the site.' ) );
</span><del>-                                                                $blogfunction = 'all_delete';
</del><ins>+                                                                
+                                                                $updated_action = 'all_delete';
</ins><span class="cx">                                                                 wpmu_delete_blog( $val, true );
</span><span class="cx">                                                         break;
</span><span class="cx">
</span><span class="cx">                                                         case 'spam':
</span><del>-                                                                $blogfunction = 'all_spam';
-                                                                update_blog_status( $val, 'spam', '1' );
-                                                                set_time_limit( 60 );
-                                                        break;
-
</del><span class="cx">                                                         case 'notspam':
</span><del>-                                                                $blogfunction = 'all_notspam';
-                                                                update_blog_status( $val, 'spam', '0' );
</del><ins>+                                                                $updated_action = ( 'spam' === $doaction ) ? 'all_spam' : 'all_notspam';
+                                                                update_blog_status( $val, 'spam', ( 'spam' === $doaction ) ? '1' : '0' );
</ins><span class="cx">                                                                 set_time_limit( 60 );
</span><span class="cx">                                                         break;
</span><span class="cx">                                                 }
</span><span class="lines">@@ -107,138 +138,50 @@
</span><span class="cx">                                                 wp_die( __( 'You are not allowed to change the current site.' ) );
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><del>-
-                                wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $blogfunction ), wp_get_referer() ) );
</del><span class="cx">                         } else {
</span><span class="cx">                                 wp_redirect( network_admin_url( 'sites.php' ) );
</span><ins>+                                exit();
</ins><span class="cx">                         }
</span><del>-                        exit();
</del><span class="cx">                 break;
</span><span class="cx">
</span><span class="cx">                 case 'archiveblog':
</span><del>-                        check_admin_referer( 'archiveblog' );
-                        if ( ! current_user_can( 'manage_sites' ) )
-                                wp_die( __( 'You do not have permission to access this page.' ) );
-
-                        update_blog_status( $id, 'archived', '1' );
-                        wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'archive' ), wp_get_referer() ) );
-                        exit();
-                break;
-
</del><span class="cx">                 case 'unarchiveblog':
</span><del>-                        check_admin_referer( 'unarchiveblog' );
-                        if ( ! current_user_can( 'manage_sites' ) )
-                                wp_die( __( 'You do not have permission to access this page.' ) );
-
-                        update_blog_status( $id, 'archived', '0' );
-                        wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unarchive' ), wp_get_referer() ) );
-                        exit();
</del><ins>+                        update_blog_status( $id, 'archived', ( 'archiveblog' === $_GET['action'] ) ? '1' : '0' );
</ins><span class="cx">                 break;
</span><span class="cx">
</span><span class="cx">                 case 'activateblog':
</span><del>-                        check_admin_referer( 'activateblog' );
-                        if ( ! current_user_can( 'manage_sites' ) )
-                                wp_die( __( 'You do not have permission to access this page.' ) );
-
</del><span class="cx">                         update_blog_status( $id, 'deleted', '0' );
</span><span class="cx">                         do_action( 'activate_blog', $id );
</span><del>-                        wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'activate' ), wp_get_referer() ) );
-                        exit();
</del><span class="cx">                 break;
</span><span class="cx">
</span><span class="cx">                 case 'deactivateblog':
</span><del>-                        check_admin_referer( 'deactivateblog' );
-                        if ( ! current_user_can( 'manage_sites' ) )
-                                wp_die( __( 'You do not have permission to access this page.' ) );
-
</del><span class="cx">                         do_action( 'deactivate_blog', $id );
</span><span class="cx">                         update_blog_status( $id, 'deleted', '1' );
</span><del>-                        wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'deactivate' ), wp_get_referer() ) );
-                        exit();
</del><span class="cx">                 break;
</span><span class="cx">
</span><span class="cx">                 case 'unspamblog':
</span><del>-                        check_admin_referer( 'unspamblog' );
-                        if ( ! current_user_can( 'manage_sites' ) )
-                                wp_die( __( 'You do not have permission to access this page.' ) );
-
-                        update_blog_status( $id, 'spam', '0' );
-                        wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unspam' ), wp_get_referer() ) );
-                        exit();
-                break;
-
</del><span class="cx">                 case 'spamblog':
</span><del>-                        check_admin_referer( 'spamblog' );
-                        if ( ! current_user_can( 'manage_sites' ) )
-                                wp_die( __( 'You do not have permission to access this page.' ) );
-
-                        update_blog_status( $id, 'spam', '1' );
-                        wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'spam' ), wp_get_referer() ) );
-                        exit();
</del><ins>+                        update_blog_status( $id, 'spam', ( 'spamblog' === $_GET['action'] ) ? '1' : '0' );
</ins><span class="cx">                 break;
</span><del>-
</del><ins>+        
</ins><span class="cx">                 case 'unmatureblog':
</span><del>-                        check_admin_referer( 'unmatureblog' );
-                        if ( ! current_user_can( 'manage_sites' ) )
-                                wp_die( __( 'You do not have permission to access this page.' ) );
-
-                        update_blog_status( $id, 'mature', '0' );
-                        wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unmature' ), wp_get_referer() ) );
-                        exit();
-                break;
-
</del><span class="cx">                 case 'matureblog':
</span><del>-                        check_admin_referer( 'matureblog' );
-                        if ( ! current_user_can( 'manage_sites' ) )
-                                wp_die( __( 'You do not have permission to access this page.' ) );
-
-                        update_blog_status( $id, 'mature', '1' );
-                        wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'mature' ), wp_get_referer() ) );
-                        exit();
</del><ins>+                        update_blog_status( $id, 'mature', ( 'matureblog' === $_GET['action'] ) ? '1' : '0' );
</ins><span class="cx">                 break;
</span><del>-
-                // Common
-                case 'confirm':
-                        check_admin_referer( 'confirm' );
-                        if ( !headers_sent() ) {
-                                nocache_headers();
-                                header( 'Content-Type: text/html; charset=utf-8' );
-                        }
-                        if ( $current_site->blog_id == $id )
-                                wp_die( __( 'You are not allowed to change the current site.' ) );
-                        ?>
-                        <!DOCTYPE html>
-                        <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
-                                <head>
-                                        <title><?php _e( 'WordPress &rsaquo; Confirm your action' ); ?></title>
-
-                                        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-                                        <?php
-                                        wp_admin_css( 'install', true );
-                                        wp_admin_css( 'ie', true );
-                                        ?>
-                                </head>
-                                <body>
-                                        <h1 id="logo"><img alt="WordPress" src="<?php echo esc_attr( admin_url( 'images/wordpress-logo.png?ver=20120216' ) ); ?>" /></h1>
-                                        <form action="sites.php?action=<?php echo esc_attr( $_GET['action2'] ) ?>" method="post">
-                                                <input type="hidden" name="action" value="<?php echo esc_attr( $_GET['action2'] ) ?>" />
-                                                <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
-                                                <input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr( wp_get_referer() ); ?>" />
-                                                <?php wp_nonce_field( $_GET['action2'], '_wpnonce', false ); ?>
-                                                <p><?php echo esc_html( stripslashes( $_GET['msg'] ) ); ?></p>
-                                                <?php submit_button( __('Confirm'), 'button' ); ?>
-                                        </form>
-                                </body>
-                        </html>
-                        <?php
-                        exit();
-                break;
</del><span class="cx">         }
</span><ins>+        
+        if ( empty( $updated_action ) && in_array( $_GET['action'], $manage_actions ) )
+                $updated_action = $_GET['action'];
+        
+        if ( ! empty( $updated_action ) ) {
+                wp_safe_redirect( add_query_arg( array( 'updated' => $updated_action ), wp_get_referer() ) );
+                exit();
+        }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> $msg = '';
</span><del>-if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty( $_REQUEST['action'] ) ) {
-        switch ( $_REQUEST['action'] ) {
</del><ins>+if ( isset( $_GET['updated'] ) ) {
+        switch ( $_GET['updated'] ) {
</ins><span class="cx">                 case 'all_notspam':
</span><span class="cx">                         $msg = __( 'Sites removed from spam.' );
</span><span class="cx">                 break;
</span><span class="lines">@@ -254,29 +197,30 @@
</span><span class="cx">                 case 'not_deleted':
</span><span class="cx">                         $msg = __( 'You do not have permission to delete that site.' );
</span><span class="cx">                 break;
</span><del>-                case 'archive':
</del><ins>+                case 'archiveblog':
</ins><span class="cx">                         $msg = __( 'Site archived.' );
</span><span class="cx">                 break;
</span><del>-                case 'unarchive':
</del><ins>+                case 'unarchiveblog':
</ins><span class="cx">                         $msg = __( 'Site unarchived.' );
</span><span class="cx">                 break;
</span><del>-                case 'activate':
</del><ins>+                case 'activateblog':
</ins><span class="cx">                         $msg = __( 'Site activated.' );
</span><span class="cx">                 break;
</span><del>-                case 'deactivate':
</del><ins>+                case 'deactivateblog':
</ins><span class="cx">                         $msg = __( 'Site deactivated.' );
</span><span class="cx">                 break;
</span><del>-                case 'unspam':
</del><ins>+                case 'unspamblog':
</ins><span class="cx">                         $msg = __( 'Site removed from spam.' );
</span><span class="cx">                 break;
</span><del>-                case 'spam':
</del><ins>+                case 'spamblog':
</ins><span class="cx">                         $msg = __( 'Site marked as spam.' );
</span><span class="cx">                 break;
</span><span class="cx">                 default:
</span><del>-                        $msg = apply_filters( 'network_sites_updated_message_' . $_REQUEST['action'] , __( 'Settings saved.' ) );
</del><ins>+                        $msg = apply_filters( 'network_sites_updated_message_' . $_GET['updated'], __( 'Settings saved.' ) );
</ins><span class="cx">                 break;
</span><span class="cx">         }
</span><del>-        if ( $msg )
</del><ins>+        
+        if ( ! empty( $msg ) )
</ins><span class="cx">                 $msg = '<div class="updated" id="message"><p>' . $msg . '</p></div>';
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -286,11 +230,11 @@
</span><span class="cx"> ?>
</span><span class="cx">
</span><span class="cx"> <div class="wrap">
</span><del>-<?php screen_icon('ms-admin'); ?>
-<h2><?php _e('Sites') ?>
-<?php echo $msg; ?>
</del><ins>+<?php screen_icon( 'ms-admin' ); ?>
+<h2><?php _e( 'Sites' ) ?>
+        
</ins><span class="cx"> <?php if ( current_user_can( 'create_sites') ) : ?>
</span><del>- <a href="<?php echo network_admin_url('site-new.php'); ?>" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'site' ); ?></a>
</del><ins>+        <a href="<?php echo network_admin_url('site-new.php'); ?>" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'site' ); ?></a>
</ins><span class="cx"> <?php endif; ?>
</span><span class="cx">
</span><span class="cx"> <?php if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] ) {
</span><span class="lines">@@ -298,6 +242,8 @@
</span><span class="cx"> } ?>
</span><span class="cx"> </h2>
</span><span class="cx">
</span><ins>+<?php echo $msg; ?>        
+        
</ins><span class="cx"> <form action="" method="get" id="ms-search">
</span><span class="cx"> <?php $wp_list_table->search_box( __( 'Search Sites' ), 'site' ); ?>
</span><span class="cx"> <input type="hidden" name="action" value="blogs" />
</span></span></pre>
</div>
</div>
</body>
</html>