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