wp/wp-admin/network/sites.php
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
equal deleted inserted replaced
4:346c88efed21 5:5e2f62d02dcd
    12 
    12 
    13 if ( ! is_multisite() )
    13 if ( ! is_multisite() )
    14 	wp_die( __( 'Multisite support is not enabled.' ) );
    14 	wp_die( __( 'Multisite support is not enabled.' ) );
    15 
    15 
    16 if ( ! current_user_can( 'manage_sites' ) )
    16 if ( ! current_user_can( 'manage_sites' ) )
    17 	wp_die( __( 'You do not have permission to access this page.' ) );
    17 	wp_die( __( 'You do not have permission to access this page.' ), 403 );
    18 
    18 
    19 $wp_list_table = _get_list_table( 'WP_MS_Sites_List_Table' );
    19 $wp_list_table = _get_list_table( 'WP_MS_Sites_List_Table' );
    20 $pagenum = $wp_list_table->get_pagenum();
    20 $pagenum = $wp_list_table->get_pagenum();
    21 
    21 
    22 $title = __( 'Sites' );
    22 $title = __( 'Sites' );
    23 $parent_file = 'sites.php';
    23 $parent_file = 'sites.php';
    24 
    24 
    25 add_screen_option( 'per_page', array( 'label' => _x( 'Sites', 'sites per page (screen options)' ) ) );
    25 add_screen_option( 'per_page' );
    26 
    26 
    27 get_current_screen()->add_help_tab( array(
    27 get_current_screen()->add_help_tab( array(
    28 	'id'      => 'overview',
    28 	'id'      => 'overview',
    29 	'title'   => __('Overview'),
    29 	'title'   => __('Overview'),
    30 	'content' =>
    30 	'content' =>
    40 		'<p>' . __('Clicking on bold headings can re-sort this table.') . '</p>'
    40 		'<p>' . __('Clicking on bold headings can re-sort this table.') . '</p>'
    41 ) );
    41 ) );
    42 
    42 
    43 get_current_screen()->set_help_sidebar(
    43 get_current_screen()->set_help_sidebar(
    44 	'<p><strong>' . __('For more information:') . '</strong></p>' .
    44 	'<p><strong>' . __('For more information:') . '</strong></p>' .
    45 	'<p>' . __('<a href="http://codex.wordpress.org/Network_Admin_Sites_Screen" target="_blank">Documentation on Site Management</a>') . '</p>' .
    45 	'<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Sites_Screen" target="_blank">Documentation on Site Management</a>') . '</p>' .
    46 	'<p>' . __('<a href="http://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
    46 	'<p>' . __('<a href="https://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
    47 );
    47 );
    48 
    48 
    49 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
    49 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
    50 
    50 
    51 if ( isset( $_GET['action'] ) ) {
    51 if ( isset( $_GET['action'] ) ) {
    52 	do_action( 'wpmuadminedit' , '' );
    52 	/** This action is documented in wp-admin/network/edit.php */
       
    53 	do_action( 'wpmuadminedit' );
    53 
    54 
    54 	if ( 'confirm' === $_GET['action'] ) {
    55 	if ( 'confirm' === $_GET['action'] ) {
    55 		check_admin_referer( 'confirm' );
    56 		check_admin_referer( 'confirm' );
    56 
    57 
    57 		if ( ! headers_sent() ) {
    58 		if ( ! headers_sent() ) {
    58 			nocache_headers();
    59 			nocache_headers();
    59 			header( 'Content-Type: text/html; charset=utf-8' );
    60 			header( 'Content-Type: text/html; charset=utf-8' );
    60 		}
    61 		}
    61 		if ( $current_site->blog_id == $id )
    62 
       
    63 		if ( $current_site->blog_id == $id ) {
    62 			wp_die( __( 'You are not allowed to change the current site.' ) );
    64 			wp_die( __( 'You are not allowed to change the current site.' ) );
       
    65 		}
       
    66 
       
    67 		require_once( ABSPATH . 'wp-admin/admin-header.php' );
    63 		?>
    68 		?>
    64 		<!DOCTYPE html>
    69 			<div class="wrap">
    65 		<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
    70 				<h2><?php _e( 'Confirm your action' ); ?></h2>
    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 class="wp-core-ui">
       
    76 				<h1 id="logo"><a href="<?php echo esc_url( __( 'http://wordpress.org/' ) ); ?>"><?php _e( 'WordPress' ); ?></a></h1>
       
    77 				<form action="sites.php?action=<?php echo esc_attr( $_GET['action2'] ) ?>" method="post">
    71 				<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'] ) ?>" />
    72 					<input type="hidden" name="action" value="<?php echo esc_attr( $_GET['action2'] ) ?>" />
    79 					<input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
    73 					<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() ); ?>" />
    74 					<input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr( wp_get_referer() ); ?>" />
    81 					<?php wp_nonce_field( $_GET['action2'], '_wpnonce', false ); ?>
    75 					<?php wp_nonce_field( $_GET['action2'], '_wpnonce', false ); ?>
    82 					<p><?php echo esc_html( wp_unslash( $_GET['msg'] ) ); ?></p>
    76 					<p><?php echo esc_html( wp_unslash( $_GET['msg'] ) ); ?></p>
    83 					<?php submit_button( __('Confirm'), 'button' ); ?>
    77 					<?php submit_button( __( 'Confirm' ), 'button' ); ?>
    84 				</form>
    78 				</form>
    85 			</body>
    79 			</div>
    86 		</html>
       
    87 		<?php
    80 		<?php
       
    81 		require_once( ABSPATH . 'wp-admin/admin-footer.php' );
    88 		exit();
    82 		exit();
    89 	}
    83 	}
    90 
    84 
    91 	$updated_action = '';
    85 	$updated_action = '';
    92 
    86 
   101 
    95 
   102 	switch ( $_GET['action'] ) {
    96 	switch ( $_GET['action'] ) {
   103 
    97 
   104 		case 'deleteblog':
    98 		case 'deleteblog':
   105 			if ( ! current_user_can( 'delete_sites' ) )
    99 			if ( ! current_user_can( 'delete_sites' ) )
   106 				wp_die( __( 'You do not have permission to access this page.' ) );
   100 				wp_die( __( 'You do not have permission to access this page.' ), '', array( 'response' => 403 ) );
   107 
   101 
   108 			$updated_action = 'not_deleted';
   102 			$updated_action = 'not_deleted';
   109 			if ( $id != '0' && $id != $current_site->blog_id && current_user_can( 'delete_site', $id ) ) {
   103 			if ( $id != '0' && $id != $current_site->blog_id && current_user_can( 'delete_site', $id ) ) {
   110 				wpmu_delete_blog( $id, true );
   104 				wpmu_delete_blog( $id, true );
   111 				$updated_action = 'delete';
   105 				$updated_action = 'delete';
   148 			update_blog_status( $id, 'archived', ( 'archiveblog' === $_GET['action'] ) ? '1' : '0' );
   142 			update_blog_status( $id, 'archived', ( 'archiveblog' === $_GET['action'] ) ? '1' : '0' );
   149 		break;
   143 		break;
   150 
   144 
   151 		case 'activateblog':
   145 		case 'activateblog':
   152 			update_blog_status( $id, 'deleted', '0' );
   146 			update_blog_status( $id, 'deleted', '0' );
       
   147 
       
   148 			/**
       
   149 			 * Fires after a network site is activated.
       
   150 			 *
       
   151 			 * @since MU
       
   152 			 *
       
   153 			 * @param string $id The ID of the activated site.
       
   154 			 */
   153 			do_action( 'activate_blog', $id );
   155 			do_action( 'activate_blog', $id );
   154 		break;
   156 		break;
   155 
   157 
   156 		case 'deactivateblog':
   158 		case 'deactivateblog':
       
   159 			/**
       
   160 			 * Fires before a network site is deactivated.
       
   161 			 *
       
   162 			 * @since MU
       
   163 			 *
       
   164 			 * @param string $id The ID of the site being deactivated.
       
   165 			 */
   157 			do_action( 'deactivate_blog', $id );
   166 			do_action( 'deactivate_blog', $id );
   158 			update_blog_status( $id, 'deleted', '1' );
   167 			update_blog_status( $id, 'deleted', '1' );
   159 		break;
   168 		break;
   160 
   169 
   161 		case 'unspamblog':
   170 		case 'unspamblog':
   213 		break;
   222 		break;
   214 		case 'spamblog':
   223 		case 'spamblog':
   215 			$msg = __( 'Site marked as spam.' );
   224 			$msg = __( 'Site marked as spam.' );
   216 		break;
   225 		break;
   217 		default:
   226 		default:
       
   227 			/**
       
   228 			 * Filter a specific, non-default site-updated message in the Network admin.
       
   229 			 *
       
   230 			 * The dynamic portion of the hook name, `$_GET['updated']`, refers to the
       
   231 			 * non-default site update action.
       
   232 			 *
       
   233 			 * @since 3.1.0
       
   234 			 *
       
   235 			 * @param string $msg The update message. Default 'Settings saved'.
       
   236 			 */
   218 			$msg = apply_filters( 'network_sites_updated_message_' . $_GET['updated'], __( 'Settings saved.' ) );
   237 			$msg = apply_filters( 'network_sites_updated_message_' . $_GET['updated'], __( 'Settings saved.' ) );
   219 		break;
   238 		break;
   220 	}
   239 	}
   221 
   240 
   222 	if ( ! empty( $msg ) )
   241 	if ( ! empty( $msg ) )
   223 		$msg = '<div class="updated" id="message"><p>' . $msg . '</p></div>';
   242 		$msg = '<div class="updated" id="message notice is-dismissible"><p>' . $msg . '</p></div>';
   224 }
   243 }
   225 
   244 
   226 $wp_list_table->prepare_items();
   245 $wp_list_table->prepare_items();
   227 
   246 
   228 require_once( ABSPATH . 'wp-admin/admin-header.php' );
   247 require_once( ABSPATH . 'wp-admin/admin-header.php' );
   229 ?>
   248 ?>
   230 
   249 
   231 <div class="wrap">
   250 <div class="wrap">
   232 <?php screen_icon( 'ms-admin' ); ?>
       
   233 <h2><?php _e( 'Sites' ) ?>
   251 <h2><?php _e( 'Sites' ) ?>
   234 
   252 
   235 <?php if ( current_user_can( 'create_sites') ) : ?>
   253 <?php if ( current_user_can( 'create_sites') ) : ?>
   236 	<a href="<?php echo network_admin_url('site-new.php'); ?>" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'site' ); ?></a>
   254 	<a href="<?php echo network_admin_url('site-new.php'); ?>" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'site' ); ?></a>
   237 <?php endif; ?>
   255 <?php endif; ?>
   241 } ?>
   259 } ?>
   242 </h2>
   260 </h2>
   243 
   261 
   244 <?php echo $msg; ?>
   262 <?php echo $msg; ?>
   245 
   263 
   246 <form action="" method="get" id="ms-search">
   264 <form method="get" id="ms-search">
   247 <?php $wp_list_table->search_box( __( 'Search Sites' ), 'site' ); ?>
   265 <?php $wp_list_table->search_box( __( 'Search Sites' ), 'site' ); ?>
   248 <input type="hidden" name="action" value="blogs" />
   266 <input type="hidden" name="action" value="blogs" />
   249 </form>
   267 </form>
   250 
   268 
   251 <form id="form-site-list" action="sites.php?action=allblogs" method="post">
   269 <form id="form-site-list" action="sites.php?action=allblogs" method="post">