wp/wp-admin/network/settings.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
     6  * @subpackage Multisite
     6  * @subpackage Multisite
     7  * @since 3.0.0
     7  * @since 3.0.0
     8  */
     8  */
     9 
     9 
    10 /** Load WordPress Administration Bootstrap */
    10 /** Load WordPress Administration Bootstrap */
    11 require_once( dirname( __FILE__ ) . '/admin.php' );
    11 require_once __DIR__ . '/admin.php';
    12 
    12 
    13 /** WordPress Translation Installation API */
    13 /** WordPress Translation Installation API */
    14 require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
    14 require_once ABSPATH . 'wp-admin/includes/translation-install.php';
    15 
    15 
    16 if ( ! current_user_can( 'manage_network_options' ) ) {
    16 if ( ! current_user_can( 'manage_network_options' ) ) {
    17 	wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
    17 	wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
    18 }
    18 }
    19 
    19 
    20 $title       = __( 'Network Settings' );
    20 $title       = __( 'Network Settings' );
    21 $parent_file = 'settings.php';
    21 $parent_file = 'settings.php';
    22 
    22 
    23 // Handle network admin email change requests
    23 // Handle network admin email change requests.
    24 if ( ! empty( $_GET['network_admin_hash'] ) ) {
    24 if ( ! empty( $_GET['network_admin_hash'] ) ) {
    25 	$new_admin_details = get_site_option( 'network_admin_hash' );
    25 	$new_admin_details = get_site_option( 'network_admin_hash' );
    26 	$redirect          = 'settings.php?updated=false';
    26 	$redirect          = 'settings.php?updated=false';
    27 	if ( is_array( $new_admin_details ) && hash_equals( $new_admin_details['hash'], $_GET['network_admin_hash'] ) && ! empty( $new_admin_details['newemail'] ) ) {
    27 	if ( is_array( $new_admin_details ) && hash_equals( $new_admin_details['hash'], $_GET['network_admin_hash'] ) && ! empty( $new_admin_details['newemail'] ) ) {
    28 		update_site_option( 'admin_email', $new_admin_details['newemail'] );
    28 		update_site_option( 'admin_email', $new_admin_details['newemail'] );
    30 		delete_site_option( 'new_admin_email' );
    30 		delete_site_option( 'new_admin_email' );
    31 		$redirect = 'settings.php?updated=true';
    31 		$redirect = 'settings.php?updated=true';
    32 	}
    32 	}
    33 	wp_redirect( network_admin_url( $redirect ) );
    33 	wp_redirect( network_admin_url( $redirect ) );
    34 	exit;
    34 	exit;
    35 } elseif ( ! empty( $_GET['dismiss'] ) && 'new_network_admin_email' == $_GET['dismiss'] ) {
    35 } elseif ( ! empty( $_GET['dismiss'] ) && 'new_network_admin_email' === $_GET['dismiss'] ) {
    36 	check_admin_referer( 'dismiss_new_network_admin_email' );
    36 	check_admin_referer( 'dismiss_new_network_admin_email' );
    37 	delete_site_option( 'network_admin_hash' );
    37 	delete_site_option( 'network_admin_hash' );
    38 	delete_site_option( 'new_admin_email' );
    38 	delete_site_option( 'new_admin_email' );
    39 	wp_redirect( network_admin_url( 'settings.php?updated=true' ) );
    39 	wp_redirect( network_admin_url( 'settings.php?updated=true' ) );
    40 	exit;
    40 	exit;
   130 	 * @since MU (3.0.0)
   130 	 * @since MU (3.0.0)
   131 	 */
   131 	 */
   132 	do_action( 'update_wpmu_options' );
   132 	do_action( 'update_wpmu_options' );
   133 
   133 
   134 	wp_redirect( add_query_arg( 'updated', 'true', network_admin_url( 'settings.php' ) ) );
   134 	wp_redirect( add_query_arg( 'updated', 'true', network_admin_url( 'settings.php' ) ) );
   135 	exit();
   135 	exit;
   136 }
   136 }
   137 
   137 
   138 include( ABSPATH . 'wp-admin/admin-header.php' );
   138 require_once ABSPATH . 'wp-admin/admin-header.php';
   139 
   139 
   140 if ( isset( $_GET['updated'] ) ) {
   140 if ( isset( $_GET['updated'] ) ) {
   141 	?><div id="message" class="updated notice is-dismissible"><p><?php _e( 'Settings saved.' ); ?></p></div>
   141 	?><div id="message" class="updated notice is-dismissible"><p><?php _e( 'Settings saved.' ); ?></p></div>
   142 	<?php
   142 	<?php
   143 }
   143 }
   159 			<tr>
   159 			<tr>
   160 				<th scope="row"><label for="admin_email"><?php _e( 'Network Admin Email' ); ?></label></th>
   160 				<th scope="row"><label for="admin_email"><?php _e( 'Network Admin Email' ); ?></label></th>
   161 				<td>
   161 				<td>
   162 					<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' ) ); ?>" />
   162 					<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' ) ); ?>" />
   163 					<p class="description" id="admin-email-desc">
   163 					<p class="description" id="admin-email-desc">
   164 						<?php _e( 'This address is used for admin purposes. If you change this we will send you an email at your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>' ); ?>
   164 						<?php _e( 'This address is used for admin purposes. If you change this, we will send you an email at your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>' ); ?>
   165 					</p>
   165 					</p>
   166 					<?php
   166 					<?php
   167 					$new_admin_email = get_site_option( 'new_admin_email' );
   167 					$new_admin_email = get_site_option( 'new_admin_email' );
   168 					if ( $new_admin_email && $new_admin_email != get_site_option( 'admin_email' ) ) :
   168 					if ( $new_admin_email && get_site_option( 'admin_email' ) !== $new_admin_email ) :
   169 						?>
   169 						?>
   170 						<div class="updated inline">
   170 						<div class="updated inline">
   171 						<p>
   171 						<p>
   172 						<?php
   172 						<?php
   173 							printf(
   173 							printf(
   174 								/* translators: %s: new network admin email */
   174 								/* translators: %s: New network admin email. */
   175 								__( 'There is a pending change of the network admin email to %s.' ),
   175 								__( 'There is a pending change of the network admin email to %s.' ),
   176 								'<code>' . esc_html( $new_admin_email ) . '</code>'
   176 								'<code>' . esc_html( $new_admin_email ) . '</code>'
   177 							);
   177 							);
   178 							printf(
   178 							printf(
   179 								' <a href="%1$s">%2$s</a>',
   179 								' <a href="%1$s">%2$s</a>',
   205 					<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 />
   205 					<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 />
   206 					<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>
   206 					<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>
   207 					<?php
   207 					<?php
   208 					if ( is_subdomain_install() ) {
   208 					if ( is_subdomain_install() ) {
   209 						echo '<p class="description">';
   209 						echo '<p class="description">';
   210 						/* translators: 1: NOBLOGREDIRECT, 2: wp-config.php */
       
   211 						printf(
   210 						printf(
       
   211 							/* translators: 1: NOBLOGREDIRECT, 2: wp-config.php */
   212 							__( '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.' ),
   212 							__( '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.' ),
   213 							'<code>NOBLOGREDIRECT</code>',
   213 							'<code>NOBLOGREDIRECT</code>',
   214 							'<code>wp-config.php</code>'
   214 							'<code>wp-config.php</code>'
   215 						);
   215 						);
   216 						echo '</p>';
   216 						echo '</p>';
   253 				<th scope="row"><label for="limited_email_domains"><?php _e( 'Limited Email Registrations' ); ?></label></th>
   253 				<th scope="row"><label for="limited_email_domains"><?php _e( 'Limited Email Registrations' ); ?></label></th>
   254 				<td>
   254 				<td>
   255 					<?php
   255 					<?php
   256 					$limited_email_domains = get_site_option( 'limited_email_domains' );
   256 					$limited_email_domains = get_site_option( 'limited_email_domains' );
   257 					$limited_email_domains = str_replace( ' ', "\n", $limited_email_domains );
   257 					$limited_email_domains = str_replace( ' ', "\n", $limited_email_domains );
       
   258 
       
   259 					if ( $limited_email_domains ) {
       
   260 						$limited_email_domains = implode( "\n", (array) $limited_email_domains );
       
   261 					}
   258 					?>
   262 					?>
   259 					<textarea name="limited_email_domains" id="limited_email_domains" aria-describedby="limited-email-domains-desc" cols="45" rows="5">
   263 					<textarea name="limited_email_domains" id="limited_email_domains" aria-describedby="limited-email-domains-desc" cols="45" rows="5">
   260 <?php echo esc_textarea( $limited_email_domains == '' ? '' : implode( "\n", (array) $limited_email_domains ) ); ?></textarea>
   264 <?php echo esc_textarea( $limited_email_domains ); ?></textarea>
   261 					<p class="description" id="limited-email-domains-desc">
   265 					<p class="description" id="limited-email-domains-desc">
   262 						<?php _e( 'If you want to limit site registrations to certain domains. One domain per line.' ); ?>
   266 						<?php _e( 'If you want to limit site registrations to certain domains. One domain per line.' ); ?>
   263 					</p>
   267 					</p>
   264 				</td>
   268 				</td>
   265 			</tr>
   269 			</tr>
   266 
   270 
   267 			<tr>
   271 			<tr>
   268 				<th scope="row"><label for="banned_email_domains"><?php _e( 'Banned Email Domains' ); ?></label></th>
   272 				<th scope="row"><label for="banned_email_domains"><?php _e( 'Banned Email Domains' ); ?></label></th>
   269 				<td>
   273 				<td>
       
   274 					<?php
       
   275 					$banned_email_domains = get_site_option( 'banned_email_domains' );
       
   276 
       
   277 					if ( $banned_email_domains ) {
       
   278 						$banned_email_domains = implode( "\n", (array) $banned_email_domains );
       
   279 					}
       
   280 					?>
   270 					<textarea name="banned_email_domains" id="banned_email_domains" aria-describedby="banned-email-domains-desc" cols="45" rows="5">
   281 					<textarea name="banned_email_domains" id="banned_email_domains" aria-describedby="banned-email-domains-desc" cols="45" rows="5">
   271 <?php echo esc_textarea( get_site_option( 'banned_email_domains' ) == '' ? '' : implode( "\n", (array) get_site_option( 'banned_email_domains' ) ) ); ?></textarea>
   282 <?php echo esc_textarea( $banned_email_domains ); ?></textarea>
   272 					<p class="description" id="banned-email-domains-desc">
   283 					<p class="description" id="banned-email-domains-desc">
   273 						<?php _e( 'If you want to ban domains from site registrations. One domain per line.' ); ?>
   284 						<?php _e( 'If you want to ban domains from site registrations. One domain per line.' ); ?>
   274 					</p>
   285 					</p>
   275 				</td>
   286 				</td>
   276 			</tr>
   287 			</tr>
   360 		<h2><?php _e( 'Upload Settings' ); ?></h2>
   371 		<h2><?php _e( 'Upload Settings' ); ?></h2>
   361 		<table class="form-table" role="presentation">
   372 		<table class="form-table" role="presentation">
   362 			<tr>
   373 			<tr>
   363 				<th scope="row"><?php _e( 'Site upload space' ); ?></th>
   374 				<th scope="row"><?php _e( 'Site upload space' ); ?></th>
   364 				<td>
   375 				<td>
   365 					<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 />
   376 					<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 ); ?>/>
       
   377 						<?php
       
   378 						printf(
       
   379 							/* translators: %s: Number of megabytes to limit uploads to. */
       
   380 							__( 'Limit total size of files uploaded to %s MB' ),
       
   381 							'</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 ) ) . '" />'
       
   382 						);
       
   383 						?>
       
   384 					</label><br />
   366 					<p class="screen-reader-text" id="blog-upload-space-desc">
   385 					<p class="screen-reader-text" id="blog-upload-space-desc">
   367 						<?php _e( 'Size in megabytes' ); ?>
   386 						<?php _e( 'Size in megabytes' ); ?>
   368 					</p>
   387 					</p>
   369 				</td>
   388 				</td>
   370 			</tr>
   389 			</tr>
   382 			<tr>
   401 			<tr>
   383 				<th scope="row"><label for="fileupload_maxk"><?php _e( 'Max upload file size' ); ?></label></th>
   402 				<th scope="row"><label for="fileupload_maxk"><?php _e( 'Max upload file size' ); ?></label></th>
   384 				<td>
   403 				<td>
   385 					<?php
   404 					<?php
   386 						printf(
   405 						printf(
   387 							/* translators: %s: File size in kilobytes */
   406 							/* translators: %s: File size in kilobytes. */
   388 							__( '%s KB' ),
   407 							__( '%s KB' ),
   389 							'<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 ) ) . '" />'
   408 							'<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 ) ) . '" />'
   390 						);
   409 						);
   391 						?>
   410 						?>
   392 					<p class="screen-reader-text" id="fileupload-maxk-desc">
   411 					<p class="screen-reader-text" id="fileupload-maxk-desc">
   406 				<tr>
   425 				<tr>
   407 					<th><label for="WPLANG"><?php _e( 'Default Language' ); ?></label></th>
   426 					<th><label for="WPLANG"><?php _e( 'Default Language' ); ?></label></th>
   408 					<td>
   427 					<td>
   409 						<?php
   428 						<?php
   410 						$lang = get_site_option( 'WPLANG' );
   429 						$lang = get_site_option( 'WPLANG' );
   411 						if ( ! in_array( $lang, $languages ) ) {
   430 						if ( ! in_array( $lang, $languages, true ) ) {
   412 							$lang = '';
   431 							$lang = '';
   413 						}
   432 						}
   414 
   433 
   415 						wp_dropdown_languages(
   434 						wp_dropdown_languages(
   416 							array(
   435 							array(
   428 			</table>
   447 			</table>
   429 			<?php
   448 			<?php
   430 		}
   449 		}
   431 		?>
   450 		?>
   432 
   451 
   433 		<h2><?php _e( 'Menu Settings' ); ?></h2>
   452 		<?php
   434 		<table id="menu" class="form-table">
   453 		$menu_perms = get_site_option( 'menu_items' );
   435 			<tr>
   454 		/**
   436 				<th scope="row"><?php _e( 'Enable administration menus' ); ?></th>
   455 		 * Filters available network-wide administration menu options.
   437 				<td>
   456 		 *
       
   457 		 * Options returned to this filter are output as individual checkboxes that, when selected,
       
   458 		 * enable site administrator access to the specified administration menu in certain contexts.
       
   459 		 *
       
   460 		 * Adding options for specific menus here hinges on the appropriate checks and capabilities
       
   461 		 * being in place in the site dashboard on the other side. For instance, when the single
       
   462 		 * default option, 'plugins' is enabled, site administrators are granted access to the Plugins
       
   463 		 * screen in their individual sites' dashboards.
       
   464 		 *
       
   465 		 * @since MU (3.0.0)
       
   466 		 *
       
   467 		 * @param string[] $admin_menus Associative array of the menu items available.
       
   468 		 */
       
   469 		$menu_items = apply_filters( 'mu_menu_items', array( 'plugins' => __( 'Plugins' ) ) );
       
   470 
       
   471 		if ( $menu_items ) :
       
   472 			?>
       
   473 			<h2><?php _e( 'Menu Settings' ); ?></h2>
       
   474 			<table id="menu" class="form-table">
       
   475 				<tr>
       
   476 					<th scope="row"><?php _e( 'Enable administration menus' ); ?></th>
       
   477 					<td>
       
   478 						<?php
       
   479 						echo '<fieldset><legend class="screen-reader-text">' . __( 'Enable menus' ) . '</legend>';
       
   480 
       
   481 						foreach ( (array) $menu_items as $key => $val ) {
       
   482 							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/>';
       
   483 						}
       
   484 
       
   485 						echo '</fieldset>';
       
   486 						?>
       
   487 					</td>
       
   488 				</tr>
       
   489 			</table>
   438 			<?php
   490 			<?php
   439 			$menu_perms = get_site_option( 'menu_items' );
   491 		endif;
   440 			/**
   492 		?>
   441 			 * Filters available network-wide administration menu options.
       
   442 			 *
       
   443 			 * Options returned to this filter are output as individual checkboxes that, when selected,
       
   444 			 * enable site administrator access to the specified administration menu in certain contexts.
       
   445 			 *
       
   446 			 * Adding options for specific menus here hinges on the appropriate checks and capabilities
       
   447 			 * being in place in the site dashboard on the other side. For instance, when the single
       
   448 			 * default option, 'plugins' is enabled, site administrators are granted access to the Plugins
       
   449 			 * screen in their individual sites' dashboards.
       
   450 			 *
       
   451 			 * @since MU (3.0.0)
       
   452 			 *
       
   453 			 * @param string[] $admin_menus Associative array of the menu items available.
       
   454 			 */
       
   455 			$menu_items = apply_filters( 'mu_menu_items', array( 'plugins' => __( 'Plugins' ) ) );
       
   456 
       
   457 			echo '<fieldset><legend class="screen-reader-text">' . __( 'Enable menus' ) . '</legend>';
       
   458 
       
   459 			foreach ( (array) $menu_items as $key => $val ) {
       
   460 				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/>';
       
   461 			}
       
   462 
       
   463 			echo '</fieldset>';
       
   464 			?>
       
   465 				</td>
       
   466 			</tr>
       
   467 		</table>
       
   468 
   493 
   469 		<?php
   494 		<?php
   470 		/**
   495 		/**
   471 		 * Fires at the end of the Network Settings form, before the submit button.
   496 		 * Fires at the end of the Network Settings form, before the submit button.
   472 		 *
   497 		 *
   476 		?>
   501 		?>
   477 		<?php submit_button(); ?>
   502 		<?php submit_button(); ?>
   478 	</form>
   503 	</form>
   479 </div>
   504 </div>
   480 
   505 
   481 <?php include( ABSPATH . 'wp-admin/admin-footer.php' ); ?>
   506 <?php require_once ABSPATH . 'wp-admin/admin-footer.php'; ?>