2010-10-21 14:35:52 -04:00
|
|
|
<?php
|
|
|
|
/**
|
2010-12-16 02:13:01 -05:00
|
|
|
* Edit Site Settings Administration Screen
|
2010-10-21 14:35:52 -04:00
|
|
|
*
|
|
|
|
* @package WordPress
|
2010-11-10 09:27:15 -05:00
|
|
|
* @subpackage Multisite
|
2010-10-21 14:35:52 -04:00
|
|
|
* @since 3.1.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** Load WordPress Administration Bootstrap */
|
2020-02-06 01:33:11 -05:00
|
|
|
require_once __DIR__ . '/admin.php';
|
2010-10-21 14:35:52 -04:00
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( ! current_user_can( 'manage_sites' ) ) {
|
2016-06-29 11:16:29 -04:00
|
|
|
wp_die( __( 'Sorry, you are not allowed to edit this site.' ) );
|
2017-11-30 18:11:00 -05:00
|
|
|
}
|
2010-10-21 14:35:52 -04:00
|
|
|
|
2017-07-17 16:53:45 -04:00
|
|
|
get_current_screen()->add_help_tab( get_site_screen_help_tab_args() );
|
|
|
|
get_current_screen()->set_help_sidebar( get_site_screen_help_sidebar_content() );
|
2010-12-16 01:52:47 -05:00
|
|
|
|
2010-10-21 14:35:52 -04:00
|
|
|
$id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
|
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( ! $id ) {
|
|
|
|
wp_die( __( 'Invalid site ID.' ) );
|
|
|
|
}
|
2010-10-21 14:35:52 -04:00
|
|
|
|
2016-10-19 02:08:28 -04:00
|
|
|
$details = get_site( $id );
|
2015-07-09 12:29:24 -04:00
|
|
|
if ( ! $details ) {
|
|
|
|
wp_die( __( 'The requested site does not exist.' ) );
|
|
|
|
}
|
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( ! can_edit_network( $details->site_id ) ) {
|
2016-06-29 11:16:29 -04:00
|
|
|
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
|
2017-11-30 18:11:00 -05:00
|
|
|
}
|
2010-10-21 14:35:52 -04:00
|
|
|
|
|
|
|
$is_main_site = is_main_site( $id );
|
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( isset( $_REQUEST['action'] ) && 'update-site' == $_REQUEST['action'] && is_array( $_POST['option'] ) ) {
|
2010-10-21 14:35:52 -04:00
|
|
|
check_admin_referer( 'edit-site' );
|
|
|
|
|
|
|
|
switch_to_blog( $id );
|
|
|
|
|
|
|
|
$skip_options = array( 'allowedthemes' ); // Don't update these options since they are handled elsewhere in the form.
|
|
|
|
foreach ( (array) $_POST['option'] as $key => $val ) {
|
2013-03-01 12:14:09 -05:00
|
|
|
$key = wp_unslash( $key );
|
|
|
|
$val = wp_unslash( $val );
|
2020-02-09 11:55:09 -05:00
|
|
|
if ( 0 === $key || is_array( $val ) || in_array( $key, $skip_options ) ) {
|
2020-01-28 19:45:18 -05:00
|
|
|
continue; // Avoids "0 is a protected WP option and may not be modified" error when edit blog options.
|
2017-11-30 18:11:00 -05:00
|
|
|
}
|
2013-04-28 20:26:49 -04:00
|
|
|
update_option( $key, $val );
|
2010-10-21 14:35:52 -04:00
|
|
|
}
|
|
|
|
|
2015-09-05 16:39:24 -04:00
|
|
|
/**
|
|
|
|
* Fires after the site options are updated.
|
|
|
|
*
|
|
|
|
* @since 3.0.0
|
|
|
|
* @since 4.4.0 Added `$id` parameter.
|
|
|
|
*
|
|
|
|
* @param int $id The ID of the site being updated.
|
|
|
|
*/
|
|
|
|
do_action( 'wpmu_update_blog_options', $id );
|
|
|
|
|
2010-10-21 14:35:52 -04:00
|
|
|
restore_current_blog();
|
2017-11-30 18:11:00 -05:00
|
|
|
wp_redirect(
|
|
|
|
add_query_arg(
|
|
|
|
array(
|
|
|
|
'update' => 'updated',
|
|
|
|
'id' => $id,
|
2018-08-16 21:51:36 -04:00
|
|
|
),
|
|
|
|
'site-settings.php'
|
2017-11-30 18:11:00 -05:00
|
|
|
)
|
|
|
|
);
|
2010-12-09 13:02:54 -05:00
|
|
|
exit;
|
2010-10-21 14:35:52 -04:00
|
|
|
}
|
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( isset( $_GET['update'] ) ) {
|
2010-10-21 14:35:52 -04:00
|
|
|
$messages = array();
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( 'updated' == $_GET['update'] ) {
|
|
|
|
$messages[] = __( 'Site options updated.' );
|
|
|
|
}
|
2010-10-21 14:35:52 -04:00
|
|
|
}
|
|
|
|
|
2019-09-02 20:41:05 -04:00
|
|
|
/* translators: %s: Site title. */
|
2015-07-12 20:27:24 -04:00
|
|
|
$title = sprintf( __( 'Edit Site: %s' ), esc_html( $details->blogname ) );
|
2011-06-03 11:35:45 -04:00
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
$parent_file = 'sites.php';
|
2010-10-21 14:35:52 -04:00
|
|
|
$submenu_file = 'sites.php';
|
|
|
|
|
2020-02-06 01:33:11 -05:00
|
|
|
require_once ABSPATH . 'wp-admin/admin-header.php';
|
2010-10-21 14:35:52 -04:00
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
<div class="wrap">
|
2015-07-12 20:27:24 -04:00
|
|
|
<h1 id="edit-site"><?php echo $title; ?></h1>
|
2015-08-10 14:11:25 -04:00
|
|
|
<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>
|
2016-05-19 17:48:30 -04:00
|
|
|
|
2010-10-21 14:35:52 -04:00
|
|
|
<?php
|
2016-05-19 17:48:30 -04:00
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
network_edit_site_nav(
|
|
|
|
array(
|
|
|
|
'blog_id' => $id,
|
|
|
|
'selected' => 'site-settings',
|
|
|
|
)
|
|
|
|
);
|
2016-05-19 17:48:30 -04:00
|
|
|
|
2010-10-21 14:35:52 -04:00
|
|
|
if ( ! empty( $messages ) ) {
|
2017-11-30 18:11:00 -05:00
|
|
|
foreach ( $messages as $msg ) {
|
2015-04-01 18:06:28 -04:00
|
|
|
echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>';
|
2017-11-30 18:11:00 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
2010-12-16 02:14:34 -05:00
|
|
|
<form method="post" action="site-settings.php?action=update-site">
|
2010-10-21 14:35:52 -04:00
|
|
|
<?php wp_nonce_field( 'edit-site' ); ?>
|
2017-11-30 18:11:00 -05:00
|
|
|
<input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
|
2019-05-24 17:56:54 -04:00
|
|
|
<table class="form-table" role="presentation">
|
2010-10-21 14:35:52 -04:00
|
|
|
<?php
|
|
|
|
$blog_prefix = $wpdb->get_blog_prefix( $id );
|
2017-11-30 18:11:00 -05:00
|
|
|
$sql = "SELECT * FROM {$blog_prefix}options
|
2014-06-09 20:44:15 -04:00
|
|
|
WHERE option_name NOT LIKE %s
|
|
|
|
AND option_name NOT LIKE %s";
|
2017-11-30 18:11:00 -05:00
|
|
|
$query = $wpdb->prepare(
|
|
|
|
$sql,
|
2014-06-09 20:44:15 -04:00
|
|
|
$wpdb->esc_like( '_' ) . '%',
|
|
|
|
'%' . $wpdb->esc_like( 'user_roles' )
|
|
|
|
);
|
2017-11-30 18:11:00 -05:00
|
|
|
$options = $wpdb->get_results( $query );
|
2010-10-21 14:35:52 -04:00
|
|
|
foreach ( $options as $option ) {
|
2020-02-09 11:55:09 -05:00
|
|
|
if ( 'default_role' === $option->option_name ) {
|
2010-10-21 14:35:52 -04:00
|
|
|
$editblog_default_role = $option->option_value;
|
2017-11-30 18:11:00 -05:00
|
|
|
}
|
2010-10-21 14:35:52 -04:00
|
|
|
$disabled = false;
|
2017-11-30 18:11:00 -05:00
|
|
|
$class = 'all-options';
|
2010-10-21 14:35:52 -04:00
|
|
|
if ( is_serialized( $option->option_value ) ) {
|
|
|
|
if ( is_serialized_string( $option->option_value ) ) {
|
2013-04-28 20:26:49 -04:00
|
|
|
$option->option_value = esc_html( maybe_unserialize( $option->option_value ) );
|
2010-10-21 14:35:52 -04:00
|
|
|
} else {
|
|
|
|
$option->option_value = 'SERIALIZED DATA';
|
2017-11-30 18:11:00 -05:00
|
|
|
$disabled = true;
|
|
|
|
$class = 'all-options disabled';
|
2010-10-21 14:35:52 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( strpos( $option->option_value, "\n" ) !== false ) {
|
2018-08-16 21:51:36 -04:00
|
|
|
?>
|
2010-10-21 14:35:52 -04:00
|
|
|
<tr class="form-field">
|
2017-11-30 18:11:00 -05:00
|
|
|
<th scope="row"><label for="<?php echo esc_attr( $option->option_name ); ?>"><?php echo ucwords( str_replace( '_', ' ', $option->option_name ) ); ?></label></th>
|
|
|
|
<td><textarea class="<?php echo $class; ?>" rows="5" cols="40" name="option[<?php echo esc_attr( $option->option_name ); ?>]" id="<?php echo esc_attr( $option->option_name ); ?>"<?php disabled( $disabled ); ?>><?php echo esc_textarea( $option->option_value ); ?></textarea></td>
|
2010-10-21 14:35:52 -04:00
|
|
|
</tr>
|
2018-08-16 21:51:36 -04:00
|
|
|
<?php
|
2010-10-21 14:35:52 -04:00
|
|
|
} else {
|
2018-08-16 21:51:36 -04:00
|
|
|
?>
|
2010-10-21 14:35:52 -04:00
|
|
|
<tr class="form-field">
|
2017-11-30 18:11:00 -05:00
|
|
|
<th scope="row"><label for="<?php echo esc_attr( $option->option_name ); ?>"><?php echo esc_html( ucwords( str_replace( '_', ' ', $option->option_name ) ) ); ?></label></th>
|
2010-10-21 14:35:52 -04:00
|
|
|
<?php if ( $is_main_site && in_array( $option->option_name, array( 'siteurl', 'home' ) ) ) { ?>
|
2017-11-30 18:11:00 -05:00
|
|
|
<td><code><?php echo esc_html( $option->option_value ); ?></code></td>
|
2010-10-21 14:35:52 -04:00
|
|
|
<?php } else { ?>
|
2017-11-30 18:11:00 -05:00
|
|
|
<td><input class="<?php echo $class; ?>" name="option[<?php echo esc_attr( $option->option_name ); ?>]" type="text" id="<?php echo esc_attr( $option->option_name ); ?>" value="<?php echo esc_attr( $option->option_value ); ?>" size="40" <?php disabled( $disabled ); ?> /></td>
|
2010-10-21 14:35:52 -04:00
|
|
|
<?php } ?>
|
|
|
|
</tr>
|
2018-08-16 21:51:36 -04:00
|
|
|
<?php
|
2010-10-21 14:35:52 -04:00
|
|
|
}
|
2020-01-28 19:45:18 -05:00
|
|
|
} // End foreach.
|
2013-10-27 16:05:10 -04:00
|
|
|
/**
|
|
|
|
* Fires at the end of the Edit Site form, before the submit button.
|
2013-12-04 15:03:09 -05:00
|
|
|
*
|
2013-10-27 16:05:10 -04:00
|
|
|
* @since 3.0.0
|
2013-12-04 15:03:09 -05:00
|
|
|
*
|
2013-10-27 16:05:10 -04:00
|
|
|
* @param int $id Site ID.
|
|
|
|
*/
|
2010-11-30 15:29:02 -05:00
|
|
|
do_action( 'wpmueditblogaction', $id );
|
2010-10-21 14:35:52 -04:00
|
|
|
?>
|
|
|
|
</table>
|
|
|
|
<?php submit_button(); ?>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<?php
|
2020-02-06 01:33:11 -05:00
|
|
|
require_once ABSPATH . 'wp-admin/admin-footer.php';
|