WordPress 4.7
[autoinstalls/wordpress.git] / wp-admin / network / settings.php
1 <?php
2 /**
3  * Multisite network settings administration panel.
4  *
5  * @package WordPress
6  * @subpackage Multisite
7  * @since 3.0.0
8  */
9
10 /** Load WordPress Administration Bootstrap */
11 require_once( dirname( __FILE__ ) . '/admin.php' );
12
13 /** WordPress Translation Install API */
14 require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
15
16 if ( ! current_user_can( 'manage_network_options' ) )
17         wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
18
19 $title = __( 'Network Settings' );
20 $parent_file = 'settings.php';
21
22 add_action( 'admin_head', 'network_settings_add_js' );
23
24 get_current_screen()->add_help_tab( array(
25                 'id'      => 'overview',
26                 'title'   => __('Overview'),
27                 'content' =>
28                         '<p>' . __('This screen sets and changes options for the network as a whole. The first site is the main site in the network and network options are pulled from that original site&#8217;s options.') . '</p>' .
29                         '<p>' . __('Operational settings has fields for the network&#8217;s name and admin email.') . '</p>' .
30                         '<p>' . __('Registration settings can disable/enable public signups. If you let others sign up for a site, install spam plugins. Spaces, not commas, should separate names banned as sites for this network.') . '</p>' .
31                         '<p>' . __('New site settings are defaults applied when a new site is created in the network. These include welcome email for when a new site or user account is registered, and what&#8127;s put in the first post, page, comment, comment author, and comment URL.') . '</p>' .
32                         '<p>' . __('Upload settings control the size of the uploaded files and the amount of available upload space for each site. You can change the default value for specific sites when you edit a particular site. Allowed file types are also listed (space separated only).') . '</p>' .
33                         '<p>' . __( 'You can set the language, and the translation files will be automatically downloaded and installed (available if your filesystem is writable).' ) . '</p>' .
34                         '<p>' . __('Menu setting enables/disables the plugin menus from appearing for non super admins, so that only super admins, not site admins, have access to activate plugins.') . '</p>' .
35                         '<p>' . __('Super admins can no longer be added on the Options screen. You must now go to the list of existing users on Network Admin > Users and click on Username or the Edit action link below that name. This goes to an Edit User page where you can check a box to grant super admin privileges.') . '</p>'
36 ) );
37
38 get_current_screen()->set_help_sidebar(
39         '<p><strong>' . __('For more information:') . '</strong></p>' .
40         '<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Settings_Screen">Documentation on Network Settings</a>') . '</p>' .
41         '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
42 );
43
44 if ( $_POST ) {
45         /** This action is documented in wp-admin/network/edit.php */
46         do_action( 'wpmuadminedit' );
47
48         check_admin_referer( 'siteoptions' );
49
50         $checked_options = array( 'menu_items' => array(), 'registrationnotification' => 'no', 'upload_space_check_disabled' => 1, 'add_new_users' => 0 );
51         foreach ( $checked_options as $option_name => $option_unchecked_value ) {
52                 if ( ! isset( $_POST[$option_name] ) )
53                         $_POST[$option_name] = $option_unchecked_value;
54         }
55
56         $options = array(
57                 'registrationnotification', 'registration', 'add_new_users', 'menu_items',
58                 'upload_space_check_disabled', 'blog_upload_space', 'upload_filetypes', 'site_name',
59                 'first_post', 'first_page', 'first_comment', 'first_comment_url', 'first_comment_author',
60                 'welcome_email', 'welcome_user_email', 'fileupload_maxk', 'global_terms_enabled',
61                 'illegal_names', 'limited_email_domains', 'banned_email_domains', 'WPLANG', 'admin_email',
62                 'first_comment_email',
63         );
64
65         // Handle translation install.
66         if ( ! empty( $_POST['WPLANG'] ) && wp_can_install_language_pack() ) {  // @todo: Skip if already installed
67                 $language = wp_download_language_pack( $_POST['WPLANG'] );
68                 if ( $language ) {
69                         $_POST['WPLANG'] = $language;
70                 }
71         }
72
73         foreach ( $options as $option_name ) {
74                 if ( ! isset($_POST[$option_name]) )
75                         continue;
76                 $value = wp_unslash( $_POST[$option_name] );
77                 update_site_option( $option_name, $value );
78         }
79
80         /**
81          * Fires after the network options are updated.
82          *
83          * @since MU
84          */
85         do_action( 'update_wpmu_options' );
86
87         wp_redirect( add_query_arg( 'updated', 'true', network_admin_url( 'settings.php' ) ) );
88         exit();
89 }
90
91 include( ABSPATH . 'wp-admin/admin-header.php' );
92
93 if ( isset( $_GET['updated'] ) ) {
94         ?><div id="message" class="updated notice is-dismissible"><p><?php _e( 'Settings saved.' ) ?></p></div><?php
95 }
96 ?>
97
98 <div class="wrap">
99         <h1><?php echo esc_html( $title ); ?></h1>
100         <form method="post" action="settings.php" novalidate="novalidate">
101                 <?php wp_nonce_field( 'siteoptions' ); ?>
102                 <h2><?php _e( 'Operational Settings' ); ?></h2>
103                 <table class="form-table">
104                         <tr>
105                                 <th scope="row"><label for="site_name"><?php _e( 'Network Title' ) ?></label></th>
106                                 <td>
107                                         <input name="site_name" type="text" id="site_name" class="regular-text" value="<?php echo esc_attr( get_network()->site_name ) ?>" />
108                                 </td>
109                         </tr>
110
111                         <tr>
112                                 <th scope="row"><label for="admin_email"><?php _e( 'Network Admin Email' ) ?></label></th>
113                                 <td>
114                                         <input name="admin_email" type="email" id="admin_email" aria-describedby="admin-email-desc" class="regular-text" value="<?php echo esc_attr( get_site_option( 'admin_email' ) ) ?>" />
115                                         <p class="description" id="admin-email-desc">
116                                                 <?php _e( 'This email address will receive notifications. Registration and support emails will also come from this address.' ); ?>
117                                         </p>
118                                 </td>
119                         </tr>
120                 </table>
121                 <h2><?php _e( 'Registration Settings' ); ?></h2>
122                 <table class="form-table">
123                         <tr>
124                                 <th scope="row"><?php _e( 'Allow new registrations' ) ?></th>
125                                 <?php
126                                 if ( !get_site_option( 'registration' ) )
127                                         update_site_option( 'registration', 'none' );
128                                 $reg = get_site_option( 'registration' );
129                                 ?>
130                                 <td>
131                                         <fieldset>
132                                         <legend class="screen-reader-text"><?php _e( 'New registrations settings' ) ?></legend>
133                                         <label><input name="registration" type="radio" id="registration1" value="none"<?php checked( $reg, 'none') ?> /> <?php _e( 'Registration is disabled.' ); ?></label><br />
134                                         <label><input name="registration" type="radio" id="registration2" value="user"<?php checked( $reg, 'user') ?> /> <?php _e( 'User accounts may be registered.' ); ?></label><br />
135                                         <label><input name="registration" type="radio" id="registration3" value="blog"<?php checked( $reg, 'blog') ?> /> <?php _e( 'Logged in users may register new sites.' ); ?></label><br />
136                                         <label><input name="registration" type="radio" id="registration4" value="all"<?php checked( $reg, 'all') ?> /> <?php _e( 'Both sites and user accounts can be registered.' ); ?></label>
137                                         <?php if ( is_subdomain_install() ) {
138                                                 echo '<p class="description">';
139                                                 /* translators: 1: NOBLOGREDIRECT 2: wp-config.php */
140                                                 printf( __( 'If registration is disabled, please set %1$s in %2$s to a URL you will redirect visitors to if they visit a non-existent site.' ),
141                                                         '<code>NOBLOGREDIRECT</code>',
142                                                         '<code>wp-config.php</code>'
143                                                 );
144                                                 echo '</p>';
145                                         } ?>
146                                         </fieldset>
147                                 </td>
148                         </tr>
149
150                         <tr>
151                                 <th scope="row"><?php _e( 'Registration notification' ) ?></th>
152                                 <?php
153                                 if ( !get_site_option( 'registrationnotification' ) )
154                                         update_site_option( 'registrationnotification', 'yes' );
155                                 ?>
156                                 <td>
157                                         <label><input name="registrationnotification" type="checkbox" id="registrationnotification" value="yes"<?php checked( get_site_option( 'registrationnotification' ), 'yes' ) ?> /> <?php _e( 'Send the network admin an email notification every time someone registers a site or user account.' ) ?></label>
158                                 </td>
159                         </tr>
160
161                         <tr id="addnewusers">
162                                 <th scope="row"><?php _e( 'Add New Users' ) ?></th>
163                                 <td>
164                                         <label><input name="add_new_users" type="checkbox" id="add_new_users" value="1"<?php checked( get_site_option( 'add_new_users' ) ) ?> /> <?php _e( 'Allow site administrators to add new users to their site via the "Users &rarr; Add New" page.' ); ?></label>
165                                 </td>
166                         </tr>
167
168                         <tr>
169                                 <th scope="row"><label for="illegal_names"><?php _e( 'Banned Names' ) ?></label></th>
170                                 <td>
171                                         <input name="illegal_names" type="text" id="illegal_names" aria-describedby="illegal-names-desc" class="large-text" value="<?php echo esc_attr( implode( " ", (array) get_site_option( 'illegal_names' ) ) ); ?>" size="45" />
172                                         <p class="description" id="illegal-names-desc">
173                                                 <?php _e( 'Users are not allowed to register these sites. Separate names by spaces.' ) ?>
174                                         </p>
175                                 </td>
176                         </tr>
177
178                         <tr>
179                                 <th scope="row"><label for="limited_email_domains"><?php _e( 'Limited Email Registrations' ) ?></label></th>
180                                 <td>
181                                         <?php $limited_email_domains = get_site_option( 'limited_email_domains' );
182                                         $limited_email_domains = str_replace( ' ', "\n", $limited_email_domains ); ?>
183                                         <textarea name="limited_email_domains" id="limited_email_domains" aria-describedby="limited-email-domains-desc" cols="45" rows="5">
184 <?php echo esc_textarea( $limited_email_domains == '' ? '' : implode( "\n", (array) $limited_email_domains ) ); ?></textarea>
185                                         <p class="description" id="limited-email-domains-desc">
186                                                 <?php _e( 'If you want to limit site registrations to certain domains. One domain per line.' ) ?>
187                                         </p>
188                                 </td>
189                         </tr>
190
191                         <tr>
192                                 <th scope="row"><label for="banned_email_domains"><?php _e('Banned Email Domains') ?></label></th>
193                                 <td>
194                                         <textarea name="banned_email_domains" id="banned_email_domains" aria-describedby="banned-email-domains-desc" cols="45" rows="5">
195 <?php echo esc_textarea( get_site_option( 'banned_email_domains' ) == '' ? '' : implode( "\n", (array) get_site_option( 'banned_email_domains' ) ) ); ?></textarea>
196                                         <p class="description" id="banned-email-domains-desc">
197                                                 <?php _e( 'If you want to ban domains from site registrations. One domain per line.' ) ?>
198                                         </p>
199                                 </td>
200                         </tr>
201
202                 </table>
203                 <h2><?php _e( 'New Site Settings' ); ?></h2>
204                 <table class="form-table">
205
206                         <tr>
207                                 <th scope="row"><label for="welcome_email"><?php _e( 'Welcome Email' ) ?></label></th>
208                                 <td>
209                                         <textarea name="welcome_email" id="welcome_email" aria-describedby="welcome-email-desc" rows="5" cols="45" class="large-text">
210 <?php echo esc_textarea( get_site_option( 'welcome_email' ) ) ?></textarea>
211                                         <p class="description" id="welcome-email-desc">
212                                                 <?php _e( 'The welcome email sent to new site owners.' ) ?>
213                                         </p>
214                                 </td>
215                         </tr>
216                         <tr>
217                                 <th scope="row"><label for="welcome_user_email"><?php _e( 'Welcome User Email' ) ?></label></th>
218                                 <td>
219                                         <textarea name="welcome_user_email" id="welcome_user_email" aria-describedby="welcome-user-email-desc" rows="5" cols="45" class="large-text">
220 <?php echo esc_textarea( get_site_option( 'welcome_user_email' ) ) ?></textarea>
221                                         <p class="description" id="welcome-user-email-desc">
222                                                 <?php _e( 'The welcome email sent to new users.' ) ?>
223                                         </p>
224                                 </td>
225                         </tr>
226                         <tr>
227                                 <th scope="row"><label for="first_post"><?php _e( 'First Post' ) ?></label></th>
228                                 <td>
229                                         <textarea name="first_post" id="first_post" aria-describedby="first-post-desc" rows="5" cols="45" class="large-text">
230 <?php echo esc_textarea( get_site_option( 'first_post' ) ) ?></textarea>
231                                         <p class="description" id="first-post-desc">
232                                                 <?php _e( 'The first post on a new site.' ) ?>
233                                         </p>
234                                 </td>
235                         </tr>
236                         <tr>
237                                 <th scope="row"><label for="first_page"><?php _e( 'First Page' ) ?></label></th>
238                                 <td>
239                                         <textarea name="first_page" id="first_page" aria-describedby="first-page-desc" rows="5" cols="45" class="large-text">
240 <?php echo esc_textarea( get_site_option( 'first_page' ) ) ?></textarea>
241                                         <p class="description" id="first-page-desc">
242                                                 <?php _e( 'The first page on a new site.' ) ?>
243                                         </p>
244                                 </td>
245                         </tr>
246                         <tr>
247                                 <th scope="row"><label for="first_comment"><?php _e( 'First Comment' ) ?></label></th>
248                                 <td>
249                                         <textarea name="first_comment" id="first_comment" aria-describedby="first-comment-desc" rows="5" cols="45" class="large-text">
250 <?php echo esc_textarea( get_site_option( 'first_comment' ) ) ?></textarea>
251                                         <p class="description" id="first-comment-desc">
252                                                 <?php _e( 'The first comment on a new site.' ) ?>
253                                         </p>
254                                 </td>
255                         </tr>
256                         <tr>
257                                 <th scope="row"><label for="first_comment_author"><?php _e( 'First Comment Author' ) ?></label></th>
258                                 <td>
259                                         <input type="text" size="40" name="first_comment_author" id="first_comment_author" aria-describedby="first-comment-author-desc" value="<?php echo esc_attr( get_site_option('first_comment_author') ); ?>" />
260                                         <p class="description" id="first-comment-author-desc">
261                                                 <?php _e( 'The author of the first comment on a new site.' ) ?>
262                                         </p>
263                                 </td>
264                         </tr>
265                         <tr>
266                                 <th scope="row"><label for="first_comment_email"><?php _e( 'First Comment Email' ) ?></label></th>
267                                 <td>
268                                         <input type="text" size="40" name="first_comment_email" id="first_comment_email" aria-describedby="first-comment-email-desc" value="<?php echo esc_attr( get_site_option( 'first_comment_email' ) ); ?>" />
269                                         <p class="description" id="first-comment-email-desc">
270                                                 <?php _e( 'The email address of the first comment author on a new site.' ) ?>
271                                         </p>
272                                 </td>
273                         </tr>
274                         <tr>
275                                 <th scope="row"><label for="first_comment_url"><?php _e( 'First Comment URL' ) ?></label></th>
276                                 <td>
277                                         <input type="text" size="40" name="first_comment_url" id="first_comment_url" aria-describedby="first-comment-url-desc" value="<?php echo esc_attr( get_site_option( 'first_comment_url' ) ) ?>" />
278                                         <p class="description" id="first-comment-url-desc">
279                                                 <?php _e( 'The URL for the first comment on a new site.' ) ?>
280                                         </p>
281                                 </td>
282                         </tr>
283                 </table>
284                 <h2><?php _e( 'Upload Settings' ); ?></h2>
285                 <table class="form-table">
286                         <tr>
287                                 <th scope="row"><?php _e( 'Site upload space' ) ?></th>
288                                 <td>
289                                         <label><input type="checkbox" id="upload_space_check_disabled" name="upload_space_check_disabled" value="0"<?php checked( (bool) get_site_option( 'upload_space_check_disabled' ), false ) ?>/> <?php printf( __( 'Limit total size of files uploaded to %s MB' ), '</label><label><input name="blog_upload_space" type="number" min="0" style="width: 100px" id="blog_upload_space" aria-describedby="blog-upload-space-desc" value="' . esc_attr( get_site_option('blog_upload_space', 100) ) . '" />' ); ?></label><br />
290                                         <p class="screen-reader-text" id="blog-upload-space-desc">
291                                                 <?php _e( 'Size in megabytes' ) ?>
292                                         </p>
293                                 </td>
294                         </tr>
295
296                         <tr>
297                                 <th scope="row"><label for="upload_filetypes"><?php _e( 'Upload file types' ) ?></label></th>
298                                 <td>
299                                         <input name="upload_filetypes" type="text" id="upload_filetypes" aria-describedby="upload-filetypes-desc" class="large-text" value="<?php echo esc_attr( get_site_option( 'upload_filetypes', 'jpg jpeg png gif' ) ) ?>" size="45" />
300                                         <p class="description" id="upload-filetypes-desc">
301                                                 <?php _e( 'Allowed file types. Separate types by spaces.' ) ?>
302                                         </p>
303                                 </td>
304                         </tr>
305
306                         <tr>
307                                 <th scope="row"><label for="fileupload_maxk"><?php _e( 'Max upload file size' ) ?></label></th>
308                                 <td>
309                                         <?php
310                                                 printf(
311                                                         /* translators: %s: File size in kilobytes */
312                                                         __( '%s KB' ),
313                                                         '<input name="fileupload_maxk" type="number" min="0" style="width: 100px" id="fileupload_maxk" aria-describedby="fileupload-maxk-desc" value="' . esc_attr( get_site_option( 'fileupload_maxk', 300 ) ) . '" />'
314                                                 );
315                                         ?>
316                                         <p class="screen-reader-text" id="fileupload-maxk-desc">
317                                                 <?php _e( 'Size in kilobytes' ) ?>
318                                         </p>
319                                 </td>
320                         </tr>
321                 </table>
322
323                 <?php
324                 $languages = get_available_languages();
325                 $translations = wp_get_available_translations();
326                 if ( ! empty( $languages ) || ! empty( $translations ) ) {
327                         ?>
328                         <h2><?php _e( 'Language Settings' ); ?></h2>
329                         <table class="form-table">
330                                 <tr>
331                                         <th><label for="WPLANG"><?php _e( 'Default Language' ); ?></label></th>
332                                         <td>
333                                                 <?php
334                                                 $lang = get_site_option( 'WPLANG' );
335                                                 if ( ! in_array( $lang, $languages ) ) {
336                                                         $lang = '';
337                                                 }
338
339                                                 wp_dropdown_languages( array(
340                                                         'name'         => 'WPLANG',
341                                                         'id'           => 'WPLANG',
342                                                         'selected'     => $lang,
343                                                         'languages'    => $languages,
344                                                         'translations' => $translations,
345                                                         'show_available_translations' => wp_can_install_language_pack(),
346                                                 ) );
347                                                 ?>
348                                         </td>
349                                 </tr>
350                         </table>
351                         <?php
352                 }
353                 ?>
354
355                 <h2><?php _e( 'Menu Settings' ); ?></h2>
356                 <table id="menu" class="form-table">
357                         <tr>
358                                 <th scope="row"><?php _e( 'Enable administration menus' ); ?></th>
359                                 <td>
360                         <?php
361                         $menu_perms = get_site_option( 'menu_items' );
362                         /**
363                          * Filters available network-wide administration menu options.
364                          *
365                          * Options returned to this filter are output as individual checkboxes that, when selected,
366                          * enable site administrator access to the specified administration menu in certain contexts.
367                          *
368                          * Adding options for specific menus here hinges on the appropriate checks and capabilities
369                          * being in place in the site dashboard on the other side. For instance, when the single
370                          * default option, 'plugins' is enabled, site administrators are granted access to the Plugins
371                          * screen in their individual sites' dashboards.
372                          *
373                          * @since MU
374                          *
375                          * @param array $admin_menus The menu items available.
376                          */
377                         $menu_items = apply_filters( 'mu_menu_items', array( 'plugins' => __( 'Plugins' ) ) );
378                         $fieldset_end = '';
379                         if ( count( (array) $menu_items ) > 1 ) {
380                                 echo '<fieldset><legend class="screen-reader-text">' . __( 'Enable menus' ) . '</legend>';
381                                 $fieldset_end = '</fieldset>';
382                         }
383                         foreach ( (array) $menu_items as $key => $val ) {
384                                 echo "<label><input type='checkbox' name='menu_items[" . $key . "]' value='1'" . ( isset( $menu_perms[$key] ) ? checked( $menu_perms[$key], '1', false ) : '' ) . " /> " . esc_html( $val ) . "</label><br/>";
385                         }
386                         echo $fieldset_end;
387                         ?>
388                                 </td>
389                         </tr>
390                 </table>
391
392                 <?php
393                 /**
394                  * Fires at the end of the Network Settings form, before the submit button.
395                  *
396                  * @since MU
397                  */
398                 do_action( 'wpmu_options' ); ?>
399                 <?php submit_button(); ?>
400         </form>
401 </div>
402
403 <?php include( ABSPATH . 'wp-admin/admin-footer.php' ); ?>