wp/wp-admin/network/site-settings.php
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
equal deleted inserted replaced
4:346c88efed21 5:5e2f62d02dcd
    27 		'<p>' . __('<strong>Settings</strong> - This page shows a list of all settings associated with this site. Some are created by WordPress and others are created by plugins you activate. Note that some fields are grayed out and say Serialized Data. You cannot modify these values due to the way the setting is stored in the database.') . '</p>'
    27 		'<p>' . __('<strong>Settings</strong> - This page shows a list of all settings associated with this site. Some are created by WordPress and others are created by plugins you activate. Note that some fields are grayed out and say Serialized Data. You cannot modify these values due to the way the setting is stored in the database.') . '</p>'
    28 ) );
    28 ) );
    29 
    29 
    30 get_current_screen()->set_help_sidebar(
    30 get_current_screen()->set_help_sidebar(
    31 	'<p><strong>' . __('For more information:') . '</strong></p>' .
    31 	'<p><strong>' . __('For more information:') . '</strong></p>' .
    32 	'<p>' . __('<a href="http://codex.wordpress.org/Network_Admin_Sites_Screen" target="_blank">Documentation on Site Management</a>') . '</p>' .
    32 	'<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Sites_Screen" target="_blank">Documentation on Site Management</a>') . '</p>' .
    33 	'<p>' . __('<a href="http://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
    33 	'<p>' . __('<a href="https://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
    34 );
    34 );
    35 
    35 
    36 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
    36 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
    37 
    37 
    38 if ( ! $id )
    38 if ( ! $id )
    39 	wp_die( __('Invalid site ID.') );
    39 	wp_die( __('Invalid site ID.') );
    40 
    40 
    41 $details = get_blog_details( $id );
    41 $details = get_blog_details( $id );
    42 if ( !can_edit_network( $details->site_id ) )
    42 if ( !can_edit_network( $details->site_id ) )
    43 	wp_die( __( 'You do not have permission to access this page.' ) );
    43 	wp_die( __( 'You do not have permission to access this page.' ), 403 );
    44 
    44 
    45 $is_main_site = is_main_site( $id );
    45 $is_main_site = is_main_site( $id );
    46 
    46 
    47 if ( isset($_REQUEST['action']) && 'update-site' == $_REQUEST['action'] && is_array( $_POST['option'] ) ) {
    47 if ( isset($_REQUEST['action']) && 'update-site' == $_REQUEST['action'] && is_array( $_POST['option'] ) ) {
    48 	check_admin_referer( 'edit-site' );
    48 	check_admin_referer( 'edit-site' );
    56 		if ( $key === 0 || is_array( $val ) || in_array($key, $skip_options) )
    56 		if ( $key === 0 || is_array( $val ) || in_array($key, $skip_options) )
    57 			continue; // Avoids "0 is a protected WP option and may not be modified" error when edit blog options
    57 			continue; // Avoids "0 is a protected WP option and may not be modified" error when edit blog options
    58 		update_option( $key, $val );
    58 		update_option( $key, $val );
    59 	}
    59 	}
    60 
    60 
       
    61 /**
       
    62  * Fires after the site options are updated.
       
    63  *
       
    64  * @since 3.0.0
       
    65  */
    61 	do_action( 'wpmu_update_blog_options' );
    66 	do_action( 'wpmu_update_blog_options' );
    62 	restore_current_blog();
    67 	restore_current_blog();
    63 	wp_redirect( add_query_arg( array( 'update' => 'updated', 'id' => $id ), 'site-settings.php') );
    68 	wp_redirect( add_query_arg( array( 'update' => 'updated', 'id' => $id ), 'site-settings.php') );
    64 	exit;
    69 	exit;
    65 }
    70 }
    69 	if ( 'updated' == $_GET['update'] )
    74 	if ( 'updated' == $_GET['update'] )
    70 		$messages[] = __('Site options updated.');
    75 		$messages[] = __('Site options updated.');
    71 }
    76 }
    72 
    77 
    73 $site_url_no_http = preg_replace( '#^http(s)?://#', '', get_blogaddress_by_id( $id ) );
    78 $site_url_no_http = preg_replace( '#^http(s)?://#', '', get_blogaddress_by_id( $id ) );
    74 $title_site_url_linked = sprintf( __('Edit Site: <a href="%1$s">%2$s</a>'), get_blogaddress_by_id( $id ), $site_url_no_http );
    79 $title_site_url_linked = sprintf( __( 'Edit Site: %s' ), '<a href="' . get_blogaddress_by_id( $id ) . '">' . $site_url_no_http . '</a>' );
    75 $title = sprintf( __('Edit Site: %s'), $site_url_no_http );
    80 $title = sprintf( __( 'Edit Site: %s' ), $site_url_no_http );
    76 
    81 
    77 $parent_file = 'sites.php';
    82 $parent_file = 'sites.php';
    78 $submenu_file = 'sites.php';
    83 $submenu_file = 'sites.php';
    79 
    84 
    80 require( ABSPATH . 'wp-admin/admin-header.php' );
    85 require( ABSPATH . 'wp-admin/admin-header.php' );
    81 
    86 
    82 ?>
    87 ?>
    83 
    88 
    84 <div class="wrap">
    89 <div class="wrap">
    85 <?php screen_icon('ms-admin'); ?>
       
    86 <h2 id="edit-site"><?php echo $title_site_url_linked ?></h2>
    90 <h2 id="edit-site"><?php echo $title_site_url_linked ?></h2>
    87 <h3 class="nav-tab-wrapper">
    91 <h3 class="nav-tab-wrapper">
    88 <?php
    92 <?php
    89 $tabs = array(
    93 $tabs = array(
    90 	'site-info'     => array( 'label' => __( 'Info' ),     'url' => 'site-info.php'     ),
    94 	'site-info'     => array( 'label' => __( 'Info' ),     'url' => 'site-info.php'     ),
    99 ?>
   103 ?>
   100 </h3>
   104 </h3>
   101 <?php
   105 <?php
   102 if ( ! empty( $messages ) ) {
   106 if ( ! empty( $messages ) ) {
   103 	foreach ( $messages as $msg )
   107 	foreach ( $messages as $msg )
   104 		echo '<div id="message" class="updated"><p>' . $msg . '</p></div>';
   108 		echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>';
   105 } ?>
   109 } ?>
   106 <form method="post" action="site-settings.php?action=update-site">
   110 <form method="post" action="site-settings.php?action=update-site">
   107 	<?php wp_nonce_field( 'edit-site' ); ?>
   111 	<?php wp_nonce_field( 'edit-site' ); ?>
   108 	<input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
   112 	<input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
   109 	<table class="form-table">
   113 	<table class="form-table">
   110 		<?php
   114 		<?php
   111 		$blog_prefix = $wpdb->get_blog_prefix( $id );
   115 		$blog_prefix = $wpdb->get_blog_prefix( $id );
   112 		$options = $wpdb->get_results( "SELECT * FROM {$blog_prefix}options WHERE option_name NOT LIKE '\_%' AND option_name NOT LIKE '%user_roles'" );
   116 		$sql = "SELECT * FROM {$blog_prefix}options
       
   117 			WHERE option_name NOT LIKE %s
       
   118 			AND option_name NOT LIKE %s";
       
   119 		$query = $wpdb->prepare( $sql,
       
   120 			$wpdb->esc_like( '_' ) . '%',
       
   121 			'%' . $wpdb->esc_like( 'user_roles' )
       
   122 		);
       
   123 		$options = $wpdb->get_results( $query );
   113 		foreach ( $options as $option ) {
   124 		foreach ( $options as $option ) {
   114 			if ( $option->option_name == 'default_role' )
   125 			if ( $option->option_name == 'default_role' )
   115 				$editblog_default_role = $option->option_value;
   126 				$editblog_default_role = $option->option_value;
   116 			$disabled = false;
   127 			$disabled = false;
   117 			$class = 'all-options';
   128 			$class = 'all-options';
   125 				}
   136 				}
   126 			}
   137 			}
   127 			if ( strpos( $option->option_value, "\n" ) !== false ) {
   138 			if ( strpos( $option->option_value, "\n" ) !== false ) {
   128 			?>
   139 			?>
   129 				<tr class="form-field">
   140 				<tr class="form-field">
   130 					<th scope="row"><?php echo ucwords( str_replace( "_", " ", $option->option_name ) ) ?></th>
   141 					<th scope="row"><label for="<?php echo esc_attr( $option->option_name ) ?>"><?php echo ucwords( str_replace( "_", " ", $option->option_name ) ) ?></label></th>
   131 					<td><textarea class="<?php echo $class; ?>" rows="5" cols="40" name="option[<?php echo esc_attr( $option->option_name ) ?>]" id="<?php echo esc_attr( $option->option_name ) ?>"<?php disabled( $disabled ) ?>><?php echo esc_textarea( $option->option_value ) ?></textarea></td>
   142 					<td><textarea class="<?php echo $class; ?>" rows="5" cols="40" name="option[<?php echo esc_attr( $option->option_name ) ?>]" id="<?php echo esc_attr( $option->option_name ) ?>"<?php disabled( $disabled ) ?>><?php echo esc_textarea( $option->option_value ) ?></textarea></td>
   132 				</tr>
   143 				</tr>
   133 			<?php
   144 			<?php
   134 			} else {
   145 			} else {
   135 			?>
   146 			?>
   136 				<tr class="form-field">
   147 				<tr class="form-field">
   137 					<th scope="row"><?php echo esc_html( ucwords( str_replace( "_", " ", $option->option_name ) ) ); ?></th>
   148 					<th scope="row"><label for="<?php echo esc_attr( $option->option_name ) ?>"><?php echo esc_html( ucwords( str_replace( "_", " ", $option->option_name ) ) ); ?></label></th>
   138 					<?php if ( $is_main_site && in_array( $option->option_name, array( 'siteurl', 'home' ) ) ) { ?>
   149 					<?php if ( $is_main_site && in_array( $option->option_name, array( 'siteurl', 'home' ) ) ) { ?>
   139 					<td><code><?php echo esc_html( $option->option_value ) ?></code></td>
   150 					<td><code><?php echo esc_html( $option->option_value ) ?></code></td>
   140 					<?php } else { ?>
   151 					<?php } else { ?>
   141 					<td><input class="<?php echo $class; ?>" name="option[<?php echo esc_attr( $option->option_name ) ?>]" type="text" id="<?php echo esc_attr( $option->option_name ) ?>" value="<?php echo esc_attr( $option->option_value ) ?>" size="40" <?php disabled( $disabled ) ?> /></td>
   152 					<td><input class="<?php echo $class; ?>" name="option[<?php echo esc_attr( $option->option_name ) ?>]" type="text" id="<?php echo esc_attr( $option->option_name ) ?>" value="<?php echo esc_attr( $option->option_value ) ?>" size="40" <?php disabled( $disabled ) ?> /></td>
   142 					<?php } ?>
   153 					<?php } ?>
   143 				</tr>
   154 				</tr>
   144 			<?php
   155 			<?php
   145 			}
   156 			}
   146 		} // End foreach
   157 		} // End foreach
       
   158 		/**
       
   159 		 * Fires at the end of the Edit Site form, before the submit button.
       
   160 		 *
       
   161 		 * @since 3.0.0
       
   162 		 *
       
   163 		 * @param int $id Site ID.
       
   164 		 */
   147 		do_action( 'wpmueditblogaction', $id );
   165 		do_action( 'wpmueditblogaction', $id );
   148 		?>
   166 		?>
   149 	</table>
   167 	</table>
   150 	<?php submit_button(); ?>
   168 	<?php submit_button(); ?>
   151 </form>
   169 </form>