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