[ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
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 __DIR__ . '/admin.php'; 12 13 /** WordPress Translation Installation 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 20 // Used in the HTML title tag. 21 $title = __( 'Network Settings' ); 22 $parent_file = 'settings.php'; 23 24 // Handle network admin email change requests. 25 if ( ! empty( $_GET['network_admin_hash'] ) ) { 26 $new_admin_details = get_site_option( 'network_admin_hash' ); 27 $redirect = 'settings.php?updated=false'; 28 if ( is_array( $new_admin_details ) && hash_equals( $new_admin_details['hash'], $_GET['network_admin_hash'] ) && ! empty( $new_admin_details['newemail'] ) ) { 29 update_site_option( 'admin_email', $new_admin_details['newemail'] ); 30 delete_site_option( 'network_admin_hash' ); 31 delete_site_option( 'new_admin_email' ); 32 $redirect = 'settings.php?updated=true'; 33 } 34 wp_redirect( network_admin_url( $redirect ) ); 35 exit; 36 } elseif ( ! empty( $_GET['dismiss'] ) && 'new_network_admin_email' === $_GET['dismiss'] ) { 37 check_admin_referer( 'dismiss_new_network_admin_email' ); 38 delete_site_option( 'network_admin_hash' ); 39 delete_site_option( 'new_admin_email' ); 40 wp_redirect( network_admin_url( 'settings.php?updated=true' ) ); 41 exit; 42 } 43 44 add_action( 'admin_head', 'network_settings_add_js' ); 45 46 get_current_screen()->add_help_tab( 47 array( 48 'id' => 'overview', 49 'title' => __( 'Overview' ), 50 'content' => 51 '<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’s options.' ) . '</p>' . 52 '<p>' . __( 'Operational settings has fields for the network’s name and admin email.' ) . '</p>' . 53 '<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>' . 54 '<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᾿s put in the first post, page, comment, comment author, and comment URL.' ) . '</p>' . 55 '<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>' . 56 '<p>' . __( 'You can set the language, and the translation files will be automatically downloaded and installed (available if your filesystem is writable).' ) . '</p>' . 57 '<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>' . 58 '<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>', 59 ) 60 ); 61 62 get_current_screen()->set_help_sidebar( 63 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . 64 '<p>' . __( '<a href="https://wordpress.org/support/article/network-admin-settings-screen/">Documentation on Network Settings</a>' ) . '</p>' . 65 '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' 66 ); 67 68 if ( $_POST ) { 69 /** This action is documented in wp-admin/network/edit.php */ 70 do_action( 'wpmuadminedit' ); 71 72 check_admin_referer( 'siteoptions' ); 73 74 $checked_options = array( 75 'menu_items' => array(), 76 'registrationnotification' => 'no', 77 'upload_space_check_disabled' => 1, 78 'add_new_users' => 0, 79 ); 80 foreach ( $checked_options as $option_name => $option_unchecked_value ) { 81 if ( ! isset( $_POST[ $option_name ] ) ) { 82 $_POST[ $option_name ] = $option_unchecked_value; 83 } 84 } 85 86 $options = array( 87 'registrationnotification', 88 'registration', 89 'add_new_users', 90 'menu_items', 91 'upload_space_check_disabled', 92 'blog_upload_space', 93 'upload_filetypes', 94 'site_name', 95 'first_post', 96 'first_page', 97 'first_comment', 98 'first_comment_url', 99 'first_comment_author', 100 'welcome_email', 101 'welcome_user_email', 102 'fileupload_maxk', 103 'global_terms_enabled', 104 'illegal_names', 105 'limited_email_domains', 106 'banned_email_domains', 107 'WPLANG', 108 'new_admin_email', 109 'first_comment_email', 110 ); 111 112 // Handle translation installation. 113 if ( ! empty( $_POST['WPLANG'] ) && current_user_can( 'install_languages' ) && wp_can_install_language_pack() ) { 114 $language = wp_download_language_pack( $_POST['WPLANG'] ); 115 if ( $language ) { 116 $_POST['WPLANG'] = $language; 117 } 118 } 119 120 foreach ( $options as $option_name ) { 121 if ( ! isset( $_POST[ $option_name ] ) ) { 122 continue; 123 } 124 $value = wp_unslash( $_POST[ $option_name ] ); 125 update_site_option( $option_name, $value ); 126 } 127 128 /** 129 * Fires after the network options are updated. 130 * 131 * @since MU (3.0.0) 132 */ 133 do_action( 'update_wpmu_options' ); 134 135 wp_redirect( add_query_arg( 'updated', 'true', network_admin_url( 'settings.php' ) ) ); 136 exit; 137 } 138 139 require_once ABSPATH . 'wp-admin/admin-header.php'; 140 141 if ( isset( $_GET['updated'] ) ) { 142 ?><div id="message" class="updated notice is-dismissible"><p><?php _e( 'Settings saved.' ); ?></p></div> 143 <?php 144 } 145 ?> 146 147 <div class="wrap"> 148 <h1><?php echo esc_html( $title ); ?></h1> 149 <form method="post" action="settings.php" novalidate="novalidate"> 150 <?php wp_nonce_field( 'siteoptions' ); ?> 151 <h2><?php _e( 'Operational Settings' ); ?></h2> 152 <table class="form-table" role="presentation"> 153 <tr> 154 <th scope="row"><label for="site_name"><?php _e( 'Network Title' ); ?></label></th> 155 <td> 156 <input name="site_name" type="text" id="site_name" class="regular-text" value="<?php echo esc_attr( get_network()->site_name ); ?>" /> 157 </td> 158 </tr> 159 160 <tr> 161 <th scope="row"><label for="admin_email"><?php _e( 'Network Admin Email' ); ?></label></th> 162 <td> 163 <input name="new_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' ) ); ?>" /> 164 <p class="description" id="admin-email-desc"> 165 <?php _e( 'This address is used for admin purposes. If you change this, an email will be sent to your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>' ); ?> 166 </p> 167 <?php 168 $new_admin_email = get_site_option( 'new_admin_email' ); 169 if ( $new_admin_email && get_site_option( 'admin_email' ) !== $new_admin_email ) : 170 ?> 171 <div class="updated inline"> 172 <p> 173 <?php 174 printf( 175 /* translators: %s: New network admin email. */ 176 __( 'There is a pending change of the network admin email to %s.' ), 177 '<code>' . esc_html( $new_admin_email ) . '</code>' 178 ); 179 printf( 180 ' <a href="%1$s">%2$s</a>', 181 esc_url( wp_nonce_url( network_admin_url( 'settings.php?dismiss=new_network_admin_email' ), 'dismiss_new_network_admin_email' ) ), 182 __( 'Cancel' ) 183 ); 184 ?> 185 </p> 186 </div> 187 <?php endif; ?> 188 </td> 189 </tr> 190 </table> 191 <h2><?php _e( 'Registration Settings' ); ?></h2> 192 <table class="form-table" role="presentation"> 193 <tr> 194 <th scope="row"><?php _e( 'Allow new registrations' ); ?></th> 195 <?php 196 if ( ! get_site_option( 'registration' ) ) { 197 update_site_option( 'registration', 'none' ); 198 } 199 $reg = get_site_option( 'registration' ); 200 ?> 201 <td> 202 <fieldset> 203 <legend class="screen-reader-text"><?php _e( 'New registrations settings' ); ?></legend> 204 <label><input name="registration" type="radio" id="registration1" value="none"<?php checked( $reg, 'none' ); ?> /> <?php _e( 'Registration is disabled' ); ?></label><br /> 205 <label><input name="registration" type="radio" id="registration2" value="user"<?php checked( $reg, 'user' ); ?> /> <?php _e( 'User accounts may be registered' ); ?></label><br /> 206 <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 /> 207 <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> 208 <?php 209 if ( is_subdomain_install() ) { 210 echo '<p class="description">'; 211 printf( 212 /* translators: 1: NOBLOGREDIRECT, 2: wp-config.php */ 213 __( '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.' ), 214 '<code>NOBLOGREDIRECT</code>', 215 '<code>wp-config.php</code>' 216 ); 217 echo '</p>'; 218 } 219 ?> 220 </fieldset> 221 </td> 222 </tr> 223 224 <tr> 225 <th scope="row"><?php _e( 'Registration notification' ); ?></th> 226 <?php 227 if ( ! get_site_option( 'registrationnotification' ) ) { 228 update_site_option( 'registrationnotification', 'yes' ); 229 } 230 ?> 231 <td> 232 <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> 233 </td> 234 </tr> 235 236 <tr id="addnewusers"> 237 <th scope="row"><?php _e( 'Add New Users' ); ?></th> 238 <td> 239 <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 → Add New" page' ); ?></label> 240 </td> 241 </tr> 242 243 <tr> 244 <th scope="row"><label for="illegal_names"><?php _e( 'Banned Names' ); ?></label></th> 245 <td> 246 <?php 247 $illegal_names = get_site_option( 'illegal_names' ); 248 249 if ( empty( $illegal_names ) ) { 250 $illegal_names = ''; 251 } elseif ( is_array( $illegal_names ) ) { 252 $illegal_names = implode( ' ', $illegal_names ); 253 } 254 ?> 255 <input name="illegal_names" type="text" id="illegal_names" aria-describedby="illegal-names-desc" class="large-text" value="<?php echo esc_attr( $illegal_names ); ?>" size="45" /> 256 <p class="description" id="illegal-names-desc"> 257 <?php _e( 'Users are not allowed to register these sites. Separate names by spaces.' ); ?> 258 </p> 259 </td> 260 </tr> 261 262 <tr> 263 <th scope="row"><label for="limited_email_domains"><?php _e( 'Limited Email Registrations' ); ?></label></th> 264 <td> 265 <?php 266 $limited_email_domains = get_site_option( 'limited_email_domains' ); 267 268 if ( empty( $limited_email_domains ) ) { 269 $limited_email_domains = ''; 270 } else { 271 // Convert from an input field. Back-compat for WPMU < 1.0. 272 $limited_email_domains = str_replace( ' ', "\n", $limited_email_domains ); 273 274 if ( is_array( $limited_email_domains ) ) { 275 $limited_email_domains = implode( "\n", $limited_email_domains ); 276 } 277 } 278 ?> 279 <textarea name="limited_email_domains" id="limited_email_domains" aria-describedby="limited-email-domains-desc" cols="45" rows="5"> 280 <?php echo esc_textarea( $limited_email_domains ); ?></textarea> 281 <p class="description" id="limited-email-domains-desc"> 282 <?php _e( 'If you want to limit site registrations to certain domains. One domain per line.' ); ?> 283 </p> 284 </td> 285 </tr> 286 287 <tr> 288 <th scope="row"><label for="banned_email_domains"><?php _e( 'Banned Email Domains' ); ?></label></th> 289 <td> 290 <?php 291 $banned_email_domains = get_site_option( 'banned_email_domains' ); 292 293 if ( empty( $banned_email_domains ) ) { 294 $banned_email_domains = ''; 295 } elseif ( is_array( $banned_email_domains ) ) { 296 $banned_email_domains = implode( "\n", $banned_email_domains ); 297 } 298 ?> 299 <textarea name="banned_email_domains" id="banned_email_domains" aria-describedby="banned-email-domains-desc" cols="45" rows="5"> 300 <?php echo esc_textarea( $banned_email_domains ); ?></textarea> 301 <p class="description" id="banned-email-domains-desc"> 302 <?php _e( 'If you want to ban domains from site registrations. One domain per line.' ); ?> 303 </p> 304 </td> 305 </tr> 306 307 </table> 308 <h2><?php _e( 'New Site Settings' ); ?></h2> 309 <table class="form-table" role="presentation"> 310 311 <tr> 312 <th scope="row"><label for="welcome_email"><?php _e( 'Welcome Email' ); ?></label></th> 313 <td> 314 <textarea name="welcome_email" id="welcome_email" aria-describedby="welcome-email-desc" rows="5" cols="45" class="large-text"> 315 <?php echo esc_textarea( get_site_option( 'welcome_email' ) ); ?></textarea> 316 <p class="description" id="welcome-email-desc"> 317 <?php _e( 'The welcome email sent to new site owners.' ); ?> 318 </p> 319 </td> 320 </tr> 321 <tr> 322 <th scope="row"><label for="welcome_user_email"><?php _e( 'Welcome User Email' ); ?></label></th> 323 <td> 324 <textarea name="welcome_user_email" id="welcome_user_email" aria-describedby="welcome-user-email-desc" rows="5" cols="45" class="large-text"> 325 <?php echo esc_textarea( get_site_option( 'welcome_user_email' ) ); ?></textarea> 326 <p class="description" id="welcome-user-email-desc"> 327 <?php _e( 'The welcome email sent to new users.' ); ?> 328 </p> 329 </td> 330 </tr> 331 <tr> 332 <th scope="row"><label for="first_post"><?php _e( 'First Post' ); ?></label></th> 333 <td> 334 <textarea name="first_post" id="first_post" aria-describedby="first-post-desc" rows="5" cols="45" class="large-text"> 335 <?php echo esc_textarea( get_site_option( 'first_post' ) ); ?></textarea> 336 <p class="description" id="first-post-desc"> 337 <?php _e( 'The first post on a new site.' ); ?> 338 </p> 339 </td> 340 </tr> 341 <tr> 342 <th scope="row"><label for="first_page"><?php _e( 'First Page' ); ?></label></th> 343 <td> 344 <textarea name="first_page" id="first_page" aria-describedby="first-page-desc" rows="5" cols="45" class="large-text"> 345 <?php echo esc_textarea( get_site_option( 'first_page' ) ); ?></textarea> 346 <p class="description" id="first-page-desc"> 347 <?php _e( 'The first page on a new site.' ); ?> 348 </p> 349 </td> 350 </tr> 351 <tr> 352 <th scope="row"><label for="first_comment"><?php _e( 'First Comment' ); ?></label></th> 353 <td> 354 <textarea name="first_comment" id="first_comment" aria-describedby="first-comment-desc" rows="5" cols="45" class="large-text"> 355 <?php echo esc_textarea( get_site_option( 'first_comment' ) ); ?></textarea> 356 <p class="description" id="first-comment-desc"> 357 <?php _e( 'The first comment on a new site.' ); ?> 358 </p> 359 </td> 360 </tr> 361 <tr> 362 <th scope="row"><label for="first_comment_author"><?php _e( 'First Comment Author' ); ?></label></th> 363 <td> 364 <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' ) ); ?>" /> 365 <p class="description" id="first-comment-author-desc"> 366 <?php _e( 'The author of the first comment on a new site.' ); ?> 367 </p> 368 </td> 369 </tr> 370 <tr> 371 <th scope="row"><label for="first_comment_email"><?php _e( 'First Comment Email' ); ?></label></th> 372 <td> 373 <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' ) ); ?>" /> 374 <p class="description" id="first-comment-email-desc"> 375 <?php _e( 'The email address of the first comment author on a new site.' ); ?> 376 </p> 377 </td> 378 </tr> 379 <tr> 380 <th scope="row"><label for="first_comment_url"><?php _e( 'First Comment URL' ); ?></label></th> 381 <td> 382 <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' ) ); ?>" /> 383 <p class="description" id="first-comment-url-desc"> 384 <?php _e( 'The URL for the first comment on a new site.' ); ?> 385 </p> 386 </td> 387 </tr> 388 </table> 389 <h2><?php _e( 'Upload Settings' ); ?></h2> 390 <table class="form-table" role="presentation"> 391 <tr> 392 <th scope="row"><?php _e( 'Site upload space' ); ?></th> 393 <td> 394 <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 ); ?>/> 395 <?php 396 printf( 397 /* translators: %s: Number of megabytes to limit uploads to. */ 398 __( 'Limit total size of files uploaded to %s MB' ), 399 '</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 ) ) . '" />' 400 ); 401 ?> 402 </label><br /> 403 <p class="screen-reader-text" id="blog-upload-space-desc"> 404 <?php _e( 'Size in megabytes' ); ?> 405 </p> 406 </td> 407 </tr> 408 409 <tr> 410 <th scope="row"><label for="upload_filetypes"><?php _e( 'Upload file types' ); ?></label></th> 411 <td> 412 <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" /> 413 <p class="description" id="upload-filetypes-desc"> 414 <?php _e( 'Allowed file types. Separate types by spaces.' ); ?> 415 </p> 416 </td> 417 </tr> 418 419 <tr> 420 <th scope="row"><label for="fileupload_maxk"><?php _e( 'Max upload file size' ); ?></label></th> 421 <td> 422 <?php 423 printf( 424 /* translators: %s: File size in kilobytes. */ 425 __( '%s KB' ), 426 '<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 ) ) . '" />' 427 ); 428 ?> 429 <p class="screen-reader-text" id="fileupload-maxk-desc"> 430 <?php _e( 'Size in kilobytes' ); ?> 431 </p> 432 </td> 433 </tr> 434 </table> 435 436 <?php 437 $languages = get_available_languages(); 438 $translations = wp_get_available_translations(); 439 if ( ! empty( $languages ) || ! empty( $translations ) ) { 440 ?> 441 <h2><?php _e( 'Language Settings' ); ?></h2> 442 <table class="form-table" role="presentation"> 443 <tr> 444 <th><label for="WPLANG"><?php _e( 'Default Language' ); ?><span class="dashicons dashicons-translation" aria-hidden="true"></span></label></th> 445 <td> 446 <?php 447 $lang = get_site_option( 'WPLANG' ); 448 if ( ! in_array( $lang, $languages, true ) ) { 449 $lang = ''; 450 } 451 452 wp_dropdown_languages( 453 array( 454 'name' => 'WPLANG', 455 'id' => 'WPLANG', 456 'selected' => $lang, 457 'languages' => $languages, 458 'translations' => $translations, 459 'show_available_translations' => current_user_can( 'install_languages' ) && wp_can_install_language_pack(), 460 ) 461 ); 462 ?> 463 </td> 464 </tr> 465 </table> 466 <?php 467 } 468 ?> 469 470 <?php 471 $menu_perms = get_site_option( 'menu_items' ); 472 /** 473 * Filters available network-wide administration menu options. 474 * 475 * Options returned to this filter are output as individual checkboxes that, when selected, 476 * enable site administrator access to the specified administration menu in certain contexts. 477 * 478 * Adding options for specific menus here hinges on the appropriate checks and capabilities 479 * being in place in the site dashboard on the other side. For instance, when the single 480 * default option, 'plugins' is enabled, site administrators are granted access to the Plugins 481 * screen in their individual sites' dashboards. 482 * 483 * @since MU (3.0.0) 484 * 485 * @param string[] $admin_menus Associative array of the menu items available. 486 */ 487 $menu_items = apply_filters( 'mu_menu_items', array( 'plugins' => __( 'Plugins' ) ) ); 488 489 if ( $menu_items ) : 490 ?> 491 <h2><?php _e( 'Menu Settings' ); ?></h2> 492 <table id="menu" class="form-table"> 493 <tr> 494 <th scope="row"><?php _e( 'Enable administration menus' ); ?></th> 495 <td> 496 <?php 497 echo '<fieldset><legend class="screen-reader-text">' . __( 'Enable menus' ) . '</legend>'; 498 499 foreach ( (array) $menu_items as $key => $val ) { 500 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/>'; 501 } 502 503 echo '</fieldset>'; 504 ?> 505 </td> 506 </tr> 507 </table> 508 <?php 509 endif; 510 ?> 511 512 <?php 513 /** 514 * Fires at the end of the Network Settings form, before the submit button. 515 * 516 * @since MU (3.0.0) 517 */ 518 do_action( 'wpmu_options' ); 519 ?> 520 <?php submit_button(); ?> 521 </form> 522 </div> 523 524 <?php require_once ABSPATH . 'wp-admin/admin-footer.php'; ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Nov 21 01:00:03 2024 | Cross-referenced by PHPXref 0.7.1 |