]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/network/site-settings.php
WordPress 4.7-scripts
[autoinstalls/wordpress.git] / wp-admin / network / site-settings.php
1 <?php
2 /**
3  * Edit Site Settings Administration Screen
4  *
5  * @package WordPress
6  * @subpackage Multisite
7  * @since 3.1.0
8  */
9
10 /** Load WordPress Administration Bootstrap */
11 require_once( dirname( __FILE__ ) . '/admin.php' );
12
13 if ( ! current_user_can( 'manage_sites' ) )
14         wp_die( __( 'Sorry, you are not allowed to edit this site.' ) );
15
16 get_current_screen()->add_help_tab( array(
17         'id'      => 'overview',
18         'title'   => __('Overview'),
19         'content' =>
20                 '<p>' . __('The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.') . '</p>' .
21                 '<p>' . __('<strong>Info</strong> &mdash; The site URL is 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>' .
22                 '<p>' . __('<strong>Users</strong> &mdash; 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>' .
23                 '<p>' . sprintf( __('<strong>Themes</strong> &mdash; 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&#8217;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>' .
24                 '<p>' . __('<strong>Settings</strong> &mdash; 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>'
25 ) );
26
27 get_current_screen()->set_help_sidebar(
28         '<p><strong>' . __('For more information:') . '</strong></p>' .
29         '<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Sites_Screen">Documentation on Site Management</a>') . '</p>' .
30         '<p>' . __('<a href="https://wordpress.org/support/forum/multisite/">Support Forums</a>') . '</p>'
31 );
32
33 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
34
35 if ( ! $id )
36         wp_die( __('Invalid site ID.') );
37
38 $details = get_site( $id );
39 if ( ! $details ) {
40         wp_die( __( 'The requested site does not exist.' ) );
41 }
42
43 if ( !can_edit_network( $details->site_id ) )
44         wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
45
46 $is_main_site = is_main_site( $id );
47
48 if ( isset($_REQUEST['action']) && 'update-site' == $_REQUEST['action'] && is_array( $_POST['option'] ) ) {
49         check_admin_referer( 'edit-site' );
50
51         switch_to_blog( $id );
52
53         $skip_options = array( 'allowedthemes' ); // Don't update these options since they are handled elsewhere in the form.
54         foreach ( (array) $_POST['option'] as $key => $val ) {
55                 $key = wp_unslash( $key );
56                 $val = wp_unslash( $val );
57                 if ( $key === 0 || is_array( $val ) || in_array($key, $skip_options) )
58                         continue; // Avoids "0 is a protected WP option and may not be modified" error when edit blog options
59                 update_option( $key, $val );
60         }
61
62         /**
63          * Fires after the site options are updated.
64          *
65          * @since 3.0.0
66          * @since 4.4.0 Added `$id` parameter.
67          *
68          * @param int $id The ID of the site being updated.
69          */
70         do_action( 'wpmu_update_blog_options', $id );
71
72         restore_current_blog();
73         wp_redirect( add_query_arg( array( 'update' => 'updated', 'id' => $id ), 'site-settings.php') );
74         exit;
75 }
76
77 if ( isset($_GET['update']) ) {
78         $messages = array();
79         if ( 'updated' == $_GET['update'] )
80                 $messages[] = __('Site options updated.');
81 }
82
83 /* translators: %s: site name */
84 $title = sprintf( __( 'Edit Site: %s' ), esc_html( $details->blogname ) );
85
86 $parent_file = 'sites.php';
87 $submenu_file = 'sites.php';
88
89 require( ABSPATH . 'wp-admin/admin-header.php' );
90
91 ?>
92
93 <div class="wrap">
94 <h1 id="edit-site"><?php echo $title; ?></h1>
95 <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>
96
97 <?php
98
99 network_edit_site_nav( array(
100         'blog_id'  => $id,
101         'selected' => 'site-settings'
102 ) );
103
104 if ( ! empty( $messages ) ) {
105         foreach ( $messages as $msg )
106                 echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>';
107 } ?>
108 <form method="post" action="site-settings.php?action=update-site">
109         <?php wp_nonce_field( 'edit-site' ); ?>
110         <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
111         <table class="form-table">
112                 <?php
113                 $blog_prefix = $wpdb->get_blog_prefix( $id );
114                 $sql = "SELECT * FROM {$blog_prefix}options
115                         WHERE option_name NOT LIKE %s
116                         AND option_name NOT LIKE %s";
117                 $query = $wpdb->prepare( $sql,
118                         $wpdb->esc_like( '_' ) . '%',
119                         '%' . $wpdb->esc_like( 'user_roles' )
120                 );
121                 $options = $wpdb->get_results( $query );
122                 foreach ( $options as $option ) {
123                         if ( $option->option_name == 'default_role' )
124                                 $editblog_default_role = $option->option_value;
125                         $disabled = false;
126                         $class = 'all-options';
127                         if ( is_serialized( $option->option_value ) ) {
128                                 if ( is_serialized_string( $option->option_value ) ) {
129                                         $option->option_value = esc_html( maybe_unserialize( $option->option_value ) );
130                                 } else {
131                                         $option->option_value = 'SERIALIZED DATA';
132                                         $disabled = true;
133                                         $class = 'all-options disabled';
134                                 }
135                         }
136                         if ( strpos( $option->option_value, "\n" ) !== false ) {
137                         ?>
138                                 <tr class="form-field">
139                                         <th scope="row"><label for="<?php echo esc_attr( $option->option_name ) ?>"><?php echo ucwords( str_replace( "_", " ", $option->option_name ) ) ?></label></th>
140                                         <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>
141                                 </tr>
142                         <?php
143                         } else {
144                         ?>
145                                 <tr class="form-field">
146                                         <th scope="row"><label for="<?php echo esc_attr( $option->option_name ) ?>"><?php echo esc_html( ucwords( str_replace( "_", " ", $option->option_name ) ) ); ?></label></th>
147                                         <?php if ( $is_main_site && in_array( $option->option_name, array( 'siteurl', 'home' ) ) ) { ?>
148                                         <td><code><?php echo esc_html( $option->option_value ) ?></code></td>
149                                         <?php } else { ?>
150                                         <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>
151                                         <?php } ?>
152                                 </tr>
153                         <?php
154                         }
155                 } // End foreach
156                 /**
157                  * Fires at the end of the Edit Site form, before the submit button.
158                  *
159                  * @since 3.0.0
160                  *
161                  * @param int $id Site ID.
162                  */
163                 do_action( 'wpmueditblogaction', $id );
164                 ?>
165         </table>
166         <?php submit_button(); ?>
167 </form>
168
169 </div>
170 <?php
171 require( ABSPATH . 'wp-admin/admin-footer.php' );