[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Multisite sites administration panel. 4 * 5 * @package WordPress 6 * @subpackage Multisite 7 * @since 3.0.0 8 */ 9 10 /** Load WordPress Administration Bootstrap */ 11 require_once __DIR__ . '/admin.php'; 12 13 if ( ! current_user_can( 'manage_sites' ) ) { 14 wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 ); 15 } 16 17 $wp_list_table = _get_list_table( 'WP_MS_Sites_List_Table' ); 18 $pagenum = $wp_list_table->get_pagenum(); 19 20 // Used in the HTML title tag. 21 $title = __( 'Sites' ); 22 $parent_file = 'sites.php'; 23 24 add_screen_option( 'per_page' ); 25 26 get_current_screen()->add_help_tab( 27 array( 28 'id' => 'overview', 29 'title' => __( 'Overview' ), 30 'content' => 31 '<p>' . __( 'Add New takes you to the Add New Site screen. You can search for a site by Name, ID number, or IP address. Screen Options allows you to choose how many sites to display on one page.' ) . '</p>' . 32 '<p>' . __( 'This is the main table of all sites on this network. Switch between list and excerpt views by using the icons above the right side of the table.' ) . '</p>' . 33 '<p>' . __( 'Hovering over each site reveals seven options (three for the primary site):' ) . '</p>' . 34 '<ul><li>' . __( 'An Edit link to a separate Edit Site screen.' ) . '</li>' . 35 '<li>' . __( 'Dashboard leads to the Dashboard for that site.' ) . '</li>' . 36 '<li>' . __( 'Deactivate, Archive, and Spam which lead to confirmation screens. These actions can be reversed later.' ) . '</li>' . 37 '<li>' . __( 'Delete which is a permanent action after the confirmation screens.' ) . '</li>' . 38 '<li>' . __( 'Visit to go to the front-end site live.' ) . '</li></ul>' . 39 '<p>' . __( 'The site ID is used internally, and is not shown on the front end of the site or to users/viewers.' ) . '</p>' . 40 '<p>' . __( 'Clicking on bold headings can re-sort this table.' ) . '</p>', 41 ) 42 ); 43 44 get_current_screen()->set_help_sidebar( 45 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . 46 '<p>' . __( '<a href="https://developer.wordpress.org/advanced-administration/multisite/admin/">Documentation on Site Management</a>' ) . '</p>' . 47 '<p>' . __( '<a href="https://wordpress.org/support/forum/multisite/">Support forums</a>' ) . '</p>' 48 ); 49 50 get_current_screen()->set_screen_reader_content( 51 array( 52 'heading_pagination' => __( 'Sites list navigation' ), 53 'heading_list' => __( 'Sites list' ), 54 ) 55 ); 56 57 $id = isset( $_REQUEST['id'] ) ? (int) $_REQUEST['id'] : 0; 58 59 if ( isset( $_GET['action'] ) ) { 60 /** This action is documented in wp-admin/network/edit.php */ 61 do_action( 'wpmuadminedit' ); 62 63 // A list of valid actions and their associated messaging for confirmation output. 64 $manage_actions = array( 65 /* translators: %s: Site URL. */ 66 'activateblog' => __( 'You are about to activate the site %s.' ), 67 /* translators: %s: Site URL. */ 68 'deactivateblog' => __( 'You are about to deactivate the site %s.' ), 69 /* translators: %s: Site URL. */ 70 'unarchiveblog' => __( 'You are about to unarchive the site %s.' ), 71 /* translators: %s: Site URL. */ 72 'archiveblog' => __( 'You are about to archive the site %s.' ), 73 /* translators: %s: Site URL. */ 74 'unspamblog' => __( 'You are about to unspam the site %s.' ), 75 /* translators: %s: Site URL. */ 76 'spamblog' => __( 'You are about to mark the site %s as spam.' ), 77 /* translators: %s: Site URL. */ 78 'deleteblog' => __( 'You are about to delete the site %s.' ), 79 /* translators: %s: Site URL. */ 80 'unmatureblog' => __( 'You are about to mark the site %s as mature.' ), 81 /* translators: %s: Site URL. */ 82 'matureblog' => __( 'You are about to mark the site %s as not mature.' ), 83 ); 84 85 if ( 'confirm' === $_GET['action'] ) { 86 // The action2 parameter contains the action being taken on the site. 87 $site_action = $_GET['action2']; 88 89 if ( ! array_key_exists( $site_action, $manage_actions ) ) { 90 wp_die( __( 'The requested action is not valid.' ) ); 91 } 92 93 // The mature/unmature UI exists only as external code. Check the "confirm" nonce for backward compatibility. 94 if ( 'matureblog' === $site_action || 'unmatureblog' === $site_action ) { 95 check_admin_referer( 'confirm' ); 96 } else { 97 check_admin_referer( $site_action . '_' . $id ); 98 } 99 100 if ( ! headers_sent() ) { 101 nocache_headers(); 102 header( 'Content-Type: text/html; charset=utf-8' ); 103 } 104 105 if ( is_main_site( $id ) ) { 106 wp_die( __( 'Sorry, you are not allowed to change the current site.' ) ); 107 } 108 109 $site_details = get_site( $id ); 110 $site_address = untrailingslashit( $site_details->domain . $site_details->path ); 111 112 require_once ABSPATH . 'wp-admin/admin-header.php'; 113 ?> 114 <div class="wrap"> 115 <h1><?php _e( 'Confirm your action' ); ?></h1> 116 <form action="sites.php?action=<?php echo esc_attr( $site_action ); ?>" method="post"> 117 <input type="hidden" name="action" value="<?php echo esc_attr( $site_action ); ?>" /> 118 <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" /> 119 <input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr( wp_get_referer() ); ?>" /> 120 <?php wp_nonce_field( $site_action . '_' . $id, '_wpnonce', false ); ?> 121 <?php 122 if ( 'deleteblog' === $site_action ) { 123 $submit = __( 'Delete this site permanently' ); 124 ?> 125 <div class="notice notice-warning inline"> 126 <p><?php _e( 'Deleting a site is a permanent action that cannot be undone. This will delete the entire site and its uploads directory.' ); ?> 127 </div> 128 <?php 129 } else { 130 $submit = __( 'Confirm' ); 131 } 132 ?> 133 <p><?php printf( $manage_actions[ $site_action ], "<strong>{$site_address}</strong>" ); ?></p> 134 <?php submit_button( $submit, 'primary' ); ?> 135 </form> 136 </div> 137 <?php 138 require_once ABSPATH . 'wp-admin/admin-footer.php'; 139 exit; 140 } elseif ( array_key_exists( $_GET['action'], $manage_actions ) ) { 141 $action = $_GET['action']; 142 check_admin_referer( $action . '_' . $id ); 143 } elseif ( 'allblogs' === $_GET['action'] ) { 144 check_admin_referer( 'bulk-sites' ); 145 } 146 147 $updated_action = ''; 148 149 switch ( $_GET['action'] ) { 150 151 case 'deleteblog': 152 if ( ! current_user_can( 'delete_sites' ) ) { 153 wp_die( __( 'Sorry, you are not allowed to access this page.' ), '', array( 'response' => 403 ) ); 154 } 155 156 $updated_action = 'not_deleted'; 157 if ( 0 !== $id && ! is_main_site( $id ) && current_user_can( 'delete_site', $id ) ) { 158 wpmu_delete_blog( $id, true ); 159 $updated_action = 'delete'; 160 } 161 break; 162 163 case 'delete_sites': 164 check_admin_referer( 'ms-delete-sites' ); 165 166 foreach ( (array) $_POST['site_ids'] as $site_id ) { 167 $site_id = (int) $site_id; 168 169 if ( is_main_site( $site_id ) ) { 170 continue; 171 } 172 173 if ( ! current_user_can( 'delete_site', $site_id ) ) { 174 $site = get_site( $site_id ); 175 $site_address = untrailingslashit( $site->domain . $site->path ); 176 177 wp_die( 178 sprintf( 179 /* translators: %s: Site URL. */ 180 __( 'Sorry, you are not allowed to delete the site %s.' ), 181 $site_address 182 ), 183 403 184 ); 185 } 186 187 $updated_action = 'all_delete'; 188 wpmu_delete_blog( $site_id, true ); 189 } 190 break; 191 192 case 'allblogs': 193 if ( isset( $_POST['action'] ) && isset( $_POST['allblogs'] ) ) { 194 $doaction = $_POST['action']; 195 196 foreach ( (array) $_POST['allblogs'] as $site_id ) { 197 $site_id = (int) $site_id; 198 199 if ( 0 !== $site_id && ! is_main_site( $site_id ) ) { 200 switch ( $doaction ) { 201 case 'delete': 202 require_once ABSPATH . 'wp-admin/admin-header.php'; 203 ?> 204 <div class="wrap"> 205 <h1><?php _e( 'Confirm your action' ); ?></h1> 206 <form action="sites.php?action=delete_sites" method="post"> 207 <input type="hidden" name="action" value="delete_sites" /> 208 <input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr( wp_get_referer() ); ?>" /> 209 <?php wp_nonce_field( 'ms-delete-sites', '_wpnonce', false ); ?> 210 <p><?php _e( 'You are about to delete the following sites:' ); ?></p> 211 <ul class="ul-disc"> 212 <?php 213 foreach ( $_POST['allblogs'] as $site_id ) : 214 $site_id = (int) $site_id; 215 216 $site = get_site( $site_id ); 217 $site_address = untrailingslashit( $site->domain . $site->path ); 218 ?> 219 <li> 220 <?php echo $site_address; ?> 221 <input type="hidden" name="site_ids[]" value="<?php echo esc_attr( $site_id ); ?>" /> 222 </li> 223 <?php endforeach; ?> 224 </ul> 225 <?php submit_button( __( 'Confirm' ), 'primary' ); ?> 226 </form> 227 </div> 228 <?php 229 require_once ABSPATH . 'wp-admin/admin-footer.php'; 230 exit; 231 break; 232 233 case 'spam': 234 case 'notspam': 235 $updated_action = ( 'spam' === $doaction ) ? 'all_spam' : 'all_notspam'; 236 update_blog_status( $site_id, 'spam', ( 'spam' === $doaction ) ? '1' : '0' ); 237 break; 238 } 239 } else { 240 wp_die( __( 'Sorry, you are not allowed to change the current site.' ) ); 241 } 242 } 243 244 if ( ! in_array( $doaction, array( 'delete', 'spam', 'notspam' ), true ) ) { 245 $redirect_to = wp_get_referer(); 246 $blogs = (array) $_POST['allblogs']; 247 248 /** This action is documented in wp-admin/network/site-themes.php */ 249 $redirect_to = apply_filters( 'handle_network_bulk_actions-' . get_current_screen()->id, $redirect_to, $doaction, $blogs, $id ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores 250 251 wp_safe_redirect( $redirect_to ); 252 exit; 253 } 254 } else { 255 // Process query defined by WP_MS_Site_List_Table::extra_table_nav(). 256 $location = remove_query_arg( 257 array( '_wp_http_referer', '_wpnonce' ), 258 add_query_arg( $_POST, network_admin_url( 'sites.php' ) ) 259 ); 260 261 wp_redirect( $location ); 262 exit; 263 } 264 265 break; 266 267 case 'archiveblog': 268 case 'unarchiveblog': 269 update_blog_status( $id, 'archived', ( 'archiveblog' === $_GET['action'] ) ? '1' : '0' ); 270 break; 271 272 case 'activateblog': 273 update_blog_status( $id, 'deleted', '0' ); 274 275 /** 276 * Fires after a network site is activated. 277 * 278 * @since MU (3.0.0) 279 * 280 * @param int $id The ID of the activated site. 281 */ 282 do_action( 'activate_blog', $id ); 283 break; 284 285 case 'deactivateblog': 286 /** 287 * Fires before a network site is deactivated. 288 * 289 * @since MU (3.0.0) 290 * 291 * @param int $id The ID of the site being deactivated. 292 */ 293 do_action( 'deactivate_blog', $id ); 294 295 update_blog_status( $id, 'deleted', '1' ); 296 break; 297 298 case 'unspamblog': 299 case 'spamblog': 300 update_blog_status( $id, 'spam', ( 'spamblog' === $_GET['action'] ) ? '1' : '0' ); 301 break; 302 303 case 'unmatureblog': 304 case 'matureblog': 305 update_blog_status( $id, 'mature', ( 'matureblog' === $_GET['action'] ) ? '1' : '0' ); 306 break; 307 } 308 309 if ( empty( $updated_action ) && array_key_exists( $_GET['action'], $manage_actions ) ) { 310 $updated_action = $_GET['action']; 311 } 312 313 if ( ! empty( $updated_action ) ) { 314 wp_safe_redirect( add_query_arg( array( 'updated' => $updated_action ), wp_get_referer() ) ); 315 exit; 316 } 317 } 318 319 $msg = ''; 320 if ( isset( $_GET['updated'] ) ) { 321 $action = $_GET['updated']; 322 323 switch ( $action ) { 324 case 'all_notspam': 325 $msg = __( 'Sites removed from spam.' ); 326 break; 327 case 'all_spam': 328 $msg = __( 'Sites marked as spam.' ); 329 break; 330 case 'all_delete': 331 $msg = __( 'Sites deleted.' ); 332 break; 333 case 'delete': 334 $msg = __( 'Site deleted.' ); 335 break; 336 case 'not_deleted': 337 $msg = __( 'Sorry, you are not allowed to delete that site.' ); 338 break; 339 case 'archiveblog': 340 $msg = __( 'Site archived.' ); 341 break; 342 case 'unarchiveblog': 343 $msg = __( 'Site unarchived.' ); 344 break; 345 case 'activateblog': 346 $msg = __( 'Site activated.' ); 347 break; 348 case 'deactivateblog': 349 $msg = __( 'Site deactivated.' ); 350 break; 351 case 'unspamblog': 352 $msg = __( 'Site removed from spam.' ); 353 break; 354 case 'spamblog': 355 $msg = __( 'Site marked as spam.' ); 356 break; 357 default: 358 /** 359 * Filters a specific, non-default, site-updated message in the Network admin. 360 * 361 * The dynamic portion of the hook name, `$action`, refers to the non-default 362 * site update action. 363 * 364 * @since 3.1.0 365 * 366 * @param string $msg The update message. Default 'Settings saved'. 367 */ 368 $msg = apply_filters( "network_sites_updated_message_{$action}", __( 'Settings saved.' ) ); 369 break; 370 } 371 372 if ( ! empty( $msg ) ) { 373 $msg = wp_get_admin_notice( 374 $msg, 375 array( 376 'type' => 'success', 377 'dismissible' => true, 378 'id' => 'message', 379 ) 380 ); 381 } 382 } 383 384 $wp_list_table->prepare_items(); 385 386 require_once ABSPATH . 'wp-admin/admin-header.php'; 387 ?> 388 389 <div class="wrap"> 390 <h1 class="wp-heading-inline"><?php _e( 'Sites' ); ?></h1> 391 392 <?php if ( current_user_can( 'create_sites' ) ) : ?> 393 <a href="<?php echo esc_url( network_admin_url( 'site-new.php' ) ); ?>" class="page-title-action"><?php echo esc_html__( 'Add New Site' ); ?></a> 394 <?php endif; ?> 395 396 <?php 397 if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) { 398 echo '<span class="subtitle">'; 399 printf( 400 /* translators: %s: Search query. */ 401 __( 'Search results for: %s' ), 402 '<strong>' . esc_html( $s ) . '</strong>' 403 ); 404 echo '</span>'; 405 } 406 ?> 407 408 <hr class="wp-header-end"> 409 410 <?php $wp_list_table->views(); ?> 411 412 <?php echo $msg; ?> 413 414 <form method="get" id="ms-search" class="wp-clearfix"> 415 <?php $wp_list_table->search_box( __( 'Search Sites' ), 'site' ); ?> 416 <input type="hidden" name="action" value="blogs" /> 417 </form> 418 419 <form id="form-site-list" action="sites.php?action=allblogs" method="post"> 420 <?php $wp_list_table->display(); ?> 421 </form> 422 </div> 423 <?php 424 425 require_once ABSPATH . 'wp-admin/admin-footer.php'; ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Thu May 9 08:20:02 2024 | Cross-referenced by PHPXref |