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