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