2010-10-21 14:35:52 -04:00
< ? php
/**
2010-12-16 02:13:01 -05:00
* Edit Site Settings Administration Screen
2010-10-21 14:35:52 -04:00
*
* @ package WordPress
2010-11-10 09:27:15 -05:00
* @ subpackage Multisite
2010-10-21 14:35:52 -04:00
* @ since 3.1 . 0
*/
/** Load WordPress Administration Bootstrap */
2013-09-24 20:18:11 -04:00
require_once ( dirname ( __FILE__ ) . '/admin.php' );
2010-10-21 14:35:52 -04:00
if ( ! is_multisite () )
wp_die ( __ ( 'Multisite support is not enabled.' ) );
2010-12-16 02:41:38 -05:00
if ( ! current_user_can ( 'manage_sites' ) )
wp_die ( __ ( 'You do not have sufficient permissions to edit this site.' ) );
2010-10-21 14:35:52 -04:00
2011-11-30 21:22:07 -05:00
get_current_screen () -> add_help_tab ( array (
'id' => 'overview' ,
'title' => __ ( 'Overview' ),
'content' =>
'<p>' . __ ( 'The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.' ) . '</p>' .
2015-09-05 16:53:24 -04:00
'<p>' . __ ( '<strong>Info</strong> — The site URL is rarely edited as this can cause the site to not work properly. The Registered date and Last Updated date are displayed. Network admins can mark a site as archived, spam, deleted and mature, to remove from public listings or disable.' ) . '</p>' .
2015-08-19 00:53:25 -04:00
'<p>' . __ ( '<strong>Users</strong> — This displays the users associated with this site. You can also change their role, reset their password, or remove them from the site. Removing the user from the site does not remove the user from the network.' ) . '</p>' .
'<p>' . sprintf ( __ ( '<strong>Themes</strong> — This area shows themes that are not already enabled across the network. Enabling a theme in this menu makes it accessible to this site. It does not activate the theme, but allows it to show in the site’s Appearance menu. To enable a theme for the entire network, see the <a href="%s">Network Themes</a> screen.' ), network_admin_url ( 'themes.php' ) ) . '</p>' .
'<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>'
2011-11-30 21:22:07 -05:00
) );
2011-11-02 17:42:57 -04:00
get_current_screen () -> set_help_sidebar (
2010-12-16 01:52:47 -05:00
'<p><strong>' . __ ( 'For more information:' ) . '</strong></p>' .
2015-04-12 17:29:32 -04:00
'<p>' . __ ( '<a href="https://codex.wordpress.org/Network_Admin_Sites_Screen" target="_blank">Documentation on Site Management</a>' ) . '</p>' .
2014-03-07 23:14:15 -05:00
'<p>' . __ ( '<a href="https://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>' ) . '</p>'
2010-12-16 01:52:47 -05:00
);
2010-10-21 14:35:52 -04:00
$id = isset ( $_REQUEST [ 'id' ] ) ? intval ( $_REQUEST [ 'id' ] ) : 0 ;
if ( ! $id )
wp_die ( __ ( 'Invalid site ID.' ) );
$details = get_blog_details ( $id );
2015-07-09 12:29:24 -04:00
if ( ! $details ) {
wp_die ( __ ( 'The requested site does not exist.' ) );
}
2010-12-09 07:36:39 -05:00
if ( ! can_edit_network ( $details -> site_id ) )
2015-04-19 23:27:27 -04:00
wp_die ( __ ( 'You do not have permission to access this page.' ), 403 );
2010-10-21 14:35:52 -04:00
$is_main_site = is_main_site ( $id );
2015-09-17 08:33:26 -04:00
if ( isset ( $_REQUEST [ 'action' ]) && 'update-site' == $_REQUEST [ 'action' ] && is_array ( $_POST [ 'option' ] ) ) {
2010-10-21 14:35:52 -04:00
check_admin_referer ( 'edit-site' );
switch_to_blog ( $id );
$skip_options = array ( 'allowedthemes' ); // Don't update these options since they are handled elsewhere in the form.
foreach ( ( array ) $_POST [ 'option' ] as $key => $val ) {
2013-03-01 12:14:09 -05:00
$key = wp_unslash ( $key );
$val = wp_unslash ( $val );
2010-10-21 14:35:52 -04:00
if ( $key === 0 || is_array ( $val ) || in_array ( $key , $skip_options ) )
continue ; // Avoids "0 is a protected WP option and may not be modified" error when edit blog options
2013-04-28 20:26:49 -04:00
update_option ( $key , $val );
2010-10-21 14:35:52 -04:00
}
2015-09-05 16:39:24 -04:00
/**
* Fires after the site options are updated .
*
* @ since 3.0 . 0
* @ since 4.4 . 0 Added `$id` parameter .
*
* @ param int $id The ID of the site being updated .
*/
do_action ( 'wpmu_update_blog_options' , $id );
2010-10-21 14:35:52 -04:00
restore_current_blog ();
2010-12-16 02:14:34 -05:00
wp_redirect ( add_query_arg ( array ( 'update' => 'updated' , 'id' => $id ), 'site-settings.php' ) );
2010-12-09 13:02:54 -05:00
exit ;
2010-10-21 14:35:52 -04:00
}
if ( isset ( $_GET [ 'update' ]) ) {
$messages = array ();
if ( 'updated' == $_GET [ 'update' ] )
$messages [] = __ ( 'Site options updated.' );
}
2015-07-12 20:27:24 -04:00
$title = sprintf ( __ ( 'Edit Site: %s' ), esc_html ( $details -> blogname ) );
2011-06-03 11:35:45 -04:00
2010-10-21 14:35:52 -04:00
$parent_file = 'sites.php' ;
$submenu_file = 'sites.php' ;
2013-09-24 20:18:11 -04:00
require ( ABSPATH . 'wp-admin/admin-header.php' );
2010-10-21 14:35:52 -04:00
?>
< div class = " wrap " >
2015-07-12 20:27:24 -04:00
< h1 id = " edit-site " >< ? php echo $title ; ?> </h1>
2015-08-10 14:11:25 -04:00
< p class = " edit-site-actions " >< a href = " <?php echo esc_url( get_home_url( $id , '/' ) ); ?> " >< ? php _e ( 'Visit' ); ?> </a> | <a href="<?php echo esc_url( get_admin_url( $id ) ); ?>"><?php _e( 'Dashboard' ); ?></a></p>
2010-10-25 16:45:58 -04:00
< h3 class = " nav-tab-wrapper " >
2010-10-21 14:35:52 -04:00
< ? php
2010-12-16 02:13:01 -05:00
$tabs = array (
'site-info' => array ( 'label' => __ ( 'Info' ), 'url' => 'site-info.php' ),
'site-users' => array ( 'label' => __ ( 'Users' ), 'url' => 'site-users.php' ),
'site-themes' => array ( 'label' => __ ( 'Themes' ), 'url' => 'site-themes.php' ),
'site-settings' => array ( 'label' => __ ( 'Settings' ), 'url' => 'site-settings.php' ),
);
2010-10-21 14:35:52 -04:00
foreach ( $tabs as $tab_id => $tab ) {
$class = ( $tab [ 'url' ] == $pagenow ) ? ' nav-tab-active' : '' ;
2011-12-13 18:45:31 -05:00
echo '<a href="' . $tab [ 'url' ] . '?id=' . $id . '" class="nav-tab' . $class . '">' . esc_html ( $tab [ 'label' ] ) . '</a>' ;
2010-10-21 14:35:52 -04:00
}
?>
</ h3 >
< ? php
if ( ! empty ( $messages ) ) {
foreach ( $messages as $msg )
2015-04-01 18:06:28 -04:00
echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>' ;
2010-10-21 14:35:52 -04:00
} ?>
2010-12-16 02:14:34 -05:00
< form method = " post " action = " site-settings.php?action=update-site " >
2010-10-21 14:35:52 -04:00
< ? php wp_nonce_field ( 'edit-site' ); ?>
< input type = " hidden " name = " id " value = " <?php echo esc_attr( $id ) ?> " />
< table class = " form-table " >
< ? php
$blog_prefix = $wpdb -> get_blog_prefix ( $id );
2014-06-09 20:44:15 -04:00
$sql = " SELECT * FROM { $blog_prefix } options
WHERE option_name NOT LIKE % s
AND option_name NOT LIKE % s " ;
$query = $wpdb -> prepare ( $sql ,
$wpdb -> esc_like ( '_' ) . '%' ,
'%' . $wpdb -> esc_like ( 'user_roles' )
);
$options = $wpdb -> get_results ( $query );
2010-10-21 14:35:52 -04:00
foreach ( $options as $option ) {
if ( $option -> option_name == 'default_role' )
$editblog_default_role = $option -> option_value ;
$disabled = false ;
$class = 'all-options' ;
if ( is_serialized ( $option -> option_value ) ) {
if ( is_serialized_string ( $option -> option_value ) ) {
2013-04-28 20:26:49 -04:00
$option -> option_value = esc_html ( maybe_unserialize ( $option -> option_value ) );
2010-10-21 14:35:52 -04:00
} else {
$option -> option_value = 'SERIALIZED DATA' ;
$disabled = true ;
$class = 'all-options disabled' ;
}
}
if ( strpos ( $option -> option_value , " \n " ) !== false ) {
?>
< tr class = " form-field " >
2015-02-22 21:29:26 -05:00
< th scope = " row " >< label for = " <?php echo esc_attr( $option->option_name ) ?> " >< ? php echo ucwords ( str_replace ( " _ " , " " , $option -> option_name ) ) ?> </label></th>
2010-11-17 12:12:01 -05:00
< 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>
2010-10-21 14:35:52 -04:00
</ tr >
< ? php
} else {
?>
< tr class = " form-field " >
2015-02-22 21:29:26 -05:00
< th scope = " row " >< label for = " <?php echo esc_attr( $option->option_name ) ?> " >< ? php echo esc_html ( ucwords ( str_replace ( " _ " , " " , $option -> option_name ) ) ); ?> </label></th>
2010-10-21 14:35:52 -04:00
< ? php if ( $is_main_site && in_array ( $option -> option_name , array ( 'siteurl' , 'home' ) ) ) { ?>
< td >< code >< ? php echo esc_html ( $option -> option_value ) ?> </code></td>
< ? php } else { ?>
< 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>
< ? php } ?>
</ tr >
< ? php
}
} // End foreach
2013-10-27 16:05:10 -04:00
/**
* Fires at the end of the Edit Site form , before the submit button .
2013-12-04 15:03:09 -05:00
*
2013-10-27 16:05:10 -04:00
* @ since 3.0 . 0
2013-12-04 15:03:09 -05:00
*
2013-10-27 16:05:10 -04:00
* @ param int $id Site ID .
*/
2010-11-30 15:29:02 -05:00
do_action ( 'wpmueditblogaction' , $id );
2010-10-21 14:35:52 -04:00
?>
</ table >
< ? php submit_button (); ?>
</ form >
</ div >
< ? php
2013-09-24 20:18:11 -04:00
require ( ABSPATH . 'wp-admin/admin-footer.php' );