Edit File by line
/home/barbar84/public_h.../wp-admin/network
File: site-info.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Edit Site Info Administration Screen
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Multisite
[5] Fix | Delete
* @since 3.1.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 edit this site.' ) );
[13] Fix | Delete
}
[14] Fix | Delete
[15] Fix | Delete
get_current_screen()->add_help_tab( get_site_screen_help_tab_args() );
[16] Fix | Delete
get_current_screen()->set_help_sidebar( get_site_screen_help_sidebar_content() );
[17] Fix | Delete
[18] Fix | Delete
$id = isset( $_REQUEST['id'] ) ? (int) $_REQUEST['id'] : 0;
[19] Fix | Delete
[20] Fix | Delete
if ( ! $id ) {
[21] Fix | Delete
wp_die( __( 'Invalid site ID.' ) );
[22] Fix | Delete
}
[23] Fix | Delete
[24] Fix | Delete
$details = get_site( $id );
[25] Fix | Delete
if ( ! $details ) {
[26] Fix | Delete
wp_die( __( 'The requested site does not exist.' ) );
[27] Fix | Delete
}
[28] Fix | Delete
[29] Fix | Delete
if ( ! can_edit_network( $details->site_id ) ) {
[30] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
[31] Fix | Delete
}
[32] Fix | Delete
[33] Fix | Delete
$parsed_scheme = parse_url( $details->siteurl, PHP_URL_SCHEME );
[34] Fix | Delete
$is_main_site = is_main_site( $id );
[35] Fix | Delete
[36] Fix | Delete
if ( isset( $_REQUEST['action'] ) && 'update-site' === $_REQUEST['action'] ) {
[37] Fix | Delete
check_admin_referer( 'edit-site' );
[38] Fix | Delete
[39] Fix | Delete
switch_to_blog( $id );
[40] Fix | Delete
[41] Fix | Delete
// Rewrite rules can't be flushed during switch to blog.
[42] Fix | Delete
delete_option( 'rewrite_rules' );
[43] Fix | Delete
[44] Fix | Delete
$blog_data = wp_unslash( $_POST['blog'] );
[45] Fix | Delete
$blog_data['scheme'] = $parsed_scheme;
[46] Fix | Delete
[47] Fix | Delete
if ( $is_main_site ) {
[48] Fix | Delete
// On the network's main site, don't allow the domain or path to change.
[49] Fix | Delete
$blog_data['domain'] = $details->domain;
[50] Fix | Delete
$blog_data['path'] = $details->path;
[51] Fix | Delete
} else {
[52] Fix | Delete
// For any other site, the scheme, domain, and path can all be changed. We first
[53] Fix | Delete
// need to ensure a scheme has been provided, otherwise fallback to the existing.
[54] Fix | Delete
$new_url_scheme = parse_url( $blog_data['url'], PHP_URL_SCHEME );
[55] Fix | Delete
[56] Fix | Delete
if ( ! $new_url_scheme ) {
[57] Fix | Delete
$blog_data['url'] = esc_url( $parsed_scheme . '://' . $blog_data['url'] );
[58] Fix | Delete
}
[59] Fix | Delete
$update_parsed_url = parse_url( $blog_data['url'] );
[60] Fix | Delete
[61] Fix | Delete
// If a path is not provided, use the default of `/`.
[62] Fix | Delete
if ( ! isset( $update_parsed_url['path'] ) ) {
[63] Fix | Delete
$update_parsed_url['path'] = '/';
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
$blog_data['scheme'] = $update_parsed_url['scheme'];
[67] Fix | Delete
$blog_data['domain'] = $update_parsed_url['host'];
[68] Fix | Delete
$blog_data['path'] = $update_parsed_url['path'];
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
$existing_details = get_site( $id );
[72] Fix | Delete
$blog_data_checkboxes = array( 'public', 'archived', 'spam', 'mature', 'deleted' );
[73] Fix | Delete
[74] Fix | Delete
foreach ( $blog_data_checkboxes as $c ) {
[75] Fix | Delete
if ( ! in_array( (int) $existing_details->$c, array( 0, 1 ), true ) ) {
[76] Fix | Delete
$blog_data[ $c ] = $existing_details->$c;
[77] Fix | Delete
} else {
[78] Fix | Delete
$blog_data[ $c ] = isset( $_POST['blog'][ $c ] ) ? 1 : 0;
[79] Fix | Delete
}
[80] Fix | Delete
}
[81] Fix | Delete
[82] Fix | Delete
update_blog_details( $id, $blog_data );
[83] Fix | Delete
[84] Fix | Delete
// Maybe update home and siteurl options.
[85] Fix | Delete
$new_details = get_site( $id );
[86] Fix | Delete
[87] Fix | Delete
$old_home_url = trailingslashit( esc_url( get_option( 'home' ) ) );
[88] Fix | Delete
$old_home_parsed = parse_url( $old_home_url );
[89] Fix | Delete
[90] Fix | Delete
if ( $old_home_parsed['host'] === $existing_details->domain && $old_home_parsed['path'] === $existing_details->path ) {
[91] Fix | Delete
$new_home_url = untrailingslashit( esc_url_raw( $blog_data['scheme'] . '://' . $new_details->domain . $new_details->path ) );
[92] Fix | Delete
update_option( 'home', $new_home_url );
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
$old_site_url = trailingslashit( esc_url( get_option( 'siteurl' ) ) );
[96] Fix | Delete
$old_site_parsed = parse_url( $old_site_url );
[97] Fix | Delete
[98] Fix | Delete
if ( $old_site_parsed['host'] === $existing_details->domain && $old_site_parsed['path'] === $existing_details->path ) {
[99] Fix | Delete
$new_site_url = untrailingslashit( esc_url_raw( $blog_data['scheme'] . '://' . $new_details->domain . $new_details->path ) );
[100] Fix | Delete
update_option( 'siteurl', $new_site_url );
[101] Fix | Delete
}
[102] Fix | Delete
[103] Fix | Delete
restore_current_blog();
[104] Fix | Delete
wp_redirect(
[105] Fix | Delete
add_query_arg(
[106] Fix | Delete
array(
[107] Fix | Delete
'update' => 'updated',
[108] Fix | Delete
'id' => $id,
[109] Fix | Delete
),
[110] Fix | Delete
'site-info.php'
[111] Fix | Delete
)
[112] Fix | Delete
);
[113] Fix | Delete
exit;
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
if ( isset( $_GET['update'] ) ) {
[117] Fix | Delete
$messages = array();
[118] Fix | Delete
if ( 'updated' === $_GET['update'] ) {
[119] Fix | Delete
$messages[] = __( 'Site info updated.' );
[120] Fix | Delete
}
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
/* translators: %s: Site title. */
[124] Fix | Delete
$title = sprintf( __( 'Edit Site: %s' ), esc_html( $details->blogname ) );
[125] Fix | Delete
[126] Fix | Delete
$parent_file = 'sites.php';
[127] Fix | Delete
$submenu_file = 'sites.php';
[128] Fix | Delete
[129] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-header.php';
[130] Fix | Delete
[131] Fix | Delete
?>
[132] Fix | Delete
[133] Fix | Delete
<div class="wrap">
[134] Fix | Delete
<h1 id="edit-site"><?php echo $title; ?></h1>
[135] Fix | Delete
<p class="edit-site-actions"><a href="<?php echo esc_url( get_home_url( $id, '/' ) ); ?>"><?php _e( 'Visit' ); ?></a> | <a href="<?php echo esc_url( get_admin_url( $id ) ); ?>"><?php _e( 'Dashboard' ); ?></a></p>
[136] Fix | Delete
<?php
[137] Fix | Delete
[138] Fix | Delete
network_edit_site_nav(
[139] Fix | Delete
array(
[140] Fix | Delete
'blog_id' => $id,
[141] Fix | Delete
'selected' => 'site-info',
[142] Fix | Delete
)
[143] Fix | Delete
);
[144] Fix | Delete
[145] Fix | Delete
if ( ! empty( $messages ) ) {
[146] Fix | Delete
foreach ( $messages as $msg ) {
[147] Fix | Delete
echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>';
[148] Fix | Delete
}
[149] Fix | Delete
}
[150] Fix | Delete
?>
[151] Fix | Delete
<form method="post" action="site-info.php?action=update-site">
[152] Fix | Delete
<?php wp_nonce_field( 'edit-site' ); ?>
[153] Fix | Delete
<input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
[154] Fix | Delete
<table class="form-table" role="presentation">
[155] Fix | Delete
<?php
[156] Fix | Delete
// The main site of the network should not be updated on this page.
[157] Fix | Delete
if ( $is_main_site ) :
[158] Fix | Delete
?>
[159] Fix | Delete
<tr class="form-field">
[160] Fix | Delete
<th scope="row"><?php _e( 'Site Address (URL)' ); ?></th>
[161] Fix | Delete
<td><?php echo esc_url( $parsed_scheme . '://' . $details->domain . $details->path ); ?></td>
[162] Fix | Delete
</tr>
[163] Fix | Delete
<?php
[164] Fix | Delete
// For any other site, the scheme, domain, and path can all be changed.
[165] Fix | Delete
else :
[166] Fix | Delete
?>
[167] Fix | Delete
<tr class="form-field form-required">
[168] Fix | Delete
<th scope="row"><label for="url"><?php _e( 'Site Address (URL)' ); ?></label></th>
[169] Fix | Delete
<td><input name="blog[url]" type="text" id="url" value="<?php echo $parsed_scheme . '://' . esc_attr( $details->domain ) . esc_attr( $details->path ); ?>" /></td>
[170] Fix | Delete
</tr>
[171] Fix | Delete
<?php endif; ?>
[172] Fix | Delete
[173] Fix | Delete
<tr class="form-field">
[174] Fix | Delete
<th scope="row"><label for="blog_registered"><?php _ex( 'Registered', 'site' ); ?></label></th>
[175] Fix | Delete
<td><input name="blog[registered]" type="text" id="blog_registered" value="<?php echo esc_attr( $details->registered ); ?>" /></td>
[176] Fix | Delete
</tr>
[177] Fix | Delete
<tr class="form-field">
[178] Fix | Delete
<th scope="row"><label for="blog_last_updated"><?php _e( 'Last Updated' ); ?></label></th>
[179] Fix | Delete
<td><input name="blog[last_updated]" type="text" id="blog_last_updated" value="<?php echo esc_attr( $details->last_updated ); ?>" /></td>
[180] Fix | Delete
</tr>
[181] Fix | Delete
<?php
[182] Fix | Delete
$attribute_fields = array( 'public' => _x( 'Public', 'site' ) );
[183] Fix | Delete
if ( ! $is_main_site ) {
[184] Fix | Delete
$attribute_fields['archived'] = __( 'Archived' );
[185] Fix | Delete
$attribute_fields['spam'] = _x( 'Spam', 'site' );
[186] Fix | Delete
$attribute_fields['deleted'] = __( 'Deleted' );
[187] Fix | Delete
}
[188] Fix | Delete
$attribute_fields['mature'] = __( 'Mature' );
[189] Fix | Delete
?>
[190] Fix | Delete
<tr>
[191] Fix | Delete
<th scope="row"><?php _e( 'Attributes' ); ?></th>
[192] Fix | Delete
<td>
[193] Fix | Delete
<fieldset>
[194] Fix | Delete
<legend class="screen-reader-text"><?php _e( 'Set site attributes' ); ?></legend>
[195] Fix | Delete
<?php foreach ( $attribute_fields as $field_key => $field_label ) : ?>
[196] Fix | Delete
<label><input type="checkbox" name="blog[<?php echo $field_key; ?>]" value="1" <?php checked( (bool) $details->$field_key, true ); ?> <?php disabled( ! in_array( (int) $details->$field_key, array( 0, 1 ), true ) ); ?> />
[197] Fix | Delete
<?php echo $field_label; ?></label><br/>
[198] Fix | Delete
<?php endforeach; ?>
[199] Fix | Delete
<fieldset>
[200] Fix | Delete
</td>
[201] Fix | Delete
</tr>
[202] Fix | Delete
</table>
[203] Fix | Delete
[204] Fix | Delete
<?php
[205] Fix | Delete
/**
[206] Fix | Delete
* Fires at the end of the site info form in network admin.
[207] Fix | Delete
*
[208] Fix | Delete
* @since 5.6.0
[209] Fix | Delete
*
[210] Fix | Delete
* @param int $id The site ID.
[211] Fix | Delete
*/
[212] Fix | Delete
do_action( 'network_site_info_form', $id );
[213] Fix | Delete
[214] Fix | Delete
submit_button();
[215] Fix | Delete
?>
[216] Fix | Delete
</form>
[217] Fix | Delete
[218] Fix | Delete
</div>
[219] Fix | Delete
<?php
[220] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-footer.php';
[221] Fix | Delete
[222] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function