3 * Edit Site Settings Administration Screen
6 * @subpackage Multisite
10 /** Load WordPress Administration Bootstrap */
11 require_once( dirname( __FILE__ ) . '/admin.php' );
13 if ( ! is_multisite() )
14 wp_die( __( 'Multisite support is not enabled.' ) );
16 if ( ! current_user_can( 'manage_sites' ) )
17 wp_die( __( 'You do not have sufficient permissions to edit this site.' ) );
19 get_current_screen()->add_help_tab( array(
21 'title' => __('Overview'),
23 '<p>' . __('The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.') . '</p>' .
24 '<p>' . __('<strong>Info</strong> - The domain and path are rarely edited as this can cause the site to not work properly. The Registered date and Last Updated date are displayed. Network admins can mark a site as archived, spam, deleted and mature, to remove from public listings or disable.') . '</p>' .
25 '<p>' . __('<strong>Users</strong> - This displays the users associated with this site. You can also change their role, reset their password, or remove them from the site. Removing the user from the site does not remove the user from the network.') . '</p>' .
26 '<p>' . sprintf( __('<strong>Themes</strong> - This area shows themes that are not already enabled across the network. Enabling a theme in this menu makes it accessible to this site. It does not activate the theme, but allows it to show in the site’s Appearance menu. To enable a theme for the entire network, see the <a href="%s">Network Themes</a> screen.' ), network_admin_url( 'themes.php' ) ) . '</p>' .
27 '<p>' . __('<strong>Settings</strong> - This page shows a list of all settings associated with this site. Some are created by WordPress and others are created by plugins you activate. Note that some fields are grayed out and say Serialized Data. You cannot modify these values due to the way the setting is stored in the database.') . '</p>'
30 get_current_screen()->set_help_sidebar(
31 '<p><strong>' . __('For more information:') . '</strong></p>' .
32 '<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Sites_Screen" target="_blank">Documentation on Site Management</a>') . '</p>' .
33 '<p>' . __('<a href="https://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
36 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
39 wp_die( __('Invalid site ID.') );
41 $details = get_blog_details( $id );
43 wp_die( __( 'The requested site does not exist.' ) );
46 if ( !can_edit_network( $details->site_id ) )
47 wp_die( __( 'You do not have permission to access this page.' ), 403 );
49 $is_main_site = is_main_site( $id );
51 if ( isset($_REQUEST['action']) && 'update-site' == $_REQUEST['action'] && is_array( $_POST['option'] ) ) {
52 check_admin_referer( 'edit-site' );
54 switch_to_blog( $id );
56 $skip_options = array( 'allowedthemes' ); // Don't update these options since they are handled elsewhere in the form.
57 foreach ( (array) $_POST['option'] as $key => $val ) {
58 $key = wp_unslash( $key );
59 $val = wp_unslash( $val );
60 if ( $key === 0 || is_array( $val ) || in_array($key, $skip_options) )
61 continue; // Avoids "0 is a protected WP option and may not be modified" error when edit blog options
62 update_option( $key, $val );
66 * Fires after the site options are updated.
70 do_action( 'wpmu_update_blog_options' );
71 restore_current_blog();
72 wp_redirect( add_query_arg( array( 'update' => 'updated', 'id' => $id ), 'site-settings.php') );
76 if ( isset($_GET['update']) ) {
78 if ( 'updated' == $_GET['update'] )
79 $messages[] = __('Site options updated.');
82 $title = sprintf( __( 'Edit Site: %s' ), esc_html( $details->blogname ) );
84 $parent_file = 'sites.php';
85 $submenu_file = 'sites.php';
87 require( ABSPATH . 'wp-admin/admin-header.php' );
92 <h1 id="edit-site"><?php echo $title; ?></h1>
93 <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>
94 <h3 class="nav-tab-wrapper">
97 'site-info' => array( 'label' => __( 'Info' ), 'url' => 'site-info.php' ),
98 'site-users' => array( 'label' => __( 'Users' ), 'url' => 'site-users.php' ),
99 'site-themes' => array( 'label' => __( 'Themes' ), 'url' => 'site-themes.php' ),
100 'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php' ),
102 foreach ( $tabs as $tab_id => $tab ) {
103 $class = ( $tab['url'] == $pagenow ) ? ' nav-tab-active' : '';
104 echo '<a href="' . $tab['url'] . '?id=' . $id .'" class="nav-tab' . $class . '">' . esc_html( $tab['label'] ) . '</a>';
109 if ( ! empty( $messages ) ) {
110 foreach ( $messages as $msg )
111 echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>';
113 <form method="post" action="site-settings.php?action=update-site">
114 <?php wp_nonce_field( 'edit-site' ); ?>
115 <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
116 <table class="form-table">
118 $blog_prefix = $wpdb->get_blog_prefix( $id );
119 $sql = "SELECT * FROM {$blog_prefix}options
120 WHERE option_name NOT LIKE %s
121 AND option_name NOT LIKE %s";
122 $query = $wpdb->prepare( $sql,
123 $wpdb->esc_like( '_' ) . '%',
124 '%' . $wpdb->esc_like( 'user_roles' )
126 $options = $wpdb->get_results( $query );
127 foreach ( $options as $option ) {
128 if ( $option->option_name == 'default_role' )
129 $editblog_default_role = $option->option_value;
131 $class = 'all-options';
132 if ( is_serialized( $option->option_value ) ) {
133 if ( is_serialized_string( $option->option_value ) ) {
134 $option->option_value = esc_html( maybe_unserialize( $option->option_value ) );
136 $option->option_value = 'SERIALIZED DATA';
138 $class = 'all-options disabled';
141 if ( strpos( $option->option_value, "\n" ) !== false ) {
143 <tr class="form-field">
144 <th scope="row"><label for="<?php echo esc_attr( $option->option_name ) ?>"><?php echo ucwords( str_replace( "_", " ", $option->option_name ) ) ?></label></th>
145 <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>
150 <tr class="form-field">
151 <th scope="row"><label for="<?php echo esc_attr( $option->option_name ) ?>"><?php echo esc_html( ucwords( str_replace( "_", " ", $option->option_name ) ) ); ?></label></th>
152 <?php if ( $is_main_site && in_array( $option->option_name, array( 'siteurl', 'home' ) ) ) { ?>
153 <td><code><?php echo esc_html( $option->option_value ) ?></code></td>
155 <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>
162 * Fires at the end of the Edit Site form, before the submit button.
166 * @param int $id Site ID.
168 do_action( 'wpmueditblogaction', $id );
171 <?php submit_button(); ?>
176 require( ABSPATH . 'wp-admin/admin-footer.php' );