2010-10-21 20:35:52 +02:00
< ? php
/**
2010-12-16 08:13:01 +01:00
* Edit Site Settings Administration Screen
2010-10-21 20:35:52 +02:00
*
* @ package WordPress
2010-11-10 15:27:15 +01:00
* @ subpackage Multisite
2010-10-21 20:35:52 +02:00
* @ since 3.1 . 0
*/
/** Load WordPress Administration Bootstrap */
2013-09-25 02:18:11 +02:00
require_once ( dirname ( __FILE__ ) . '/admin.php' );
2010-10-21 20:35:52 +02:00
if ( ! is_multisite () )
wp_die ( __ ( 'Multisite support is not enabled.' ) );
2010-12-16 08:41:38 +01:00
if ( ! current_user_can ( 'manage_sites' ) )
wp_die ( __ ( 'You do not have sufficient permissions to edit this site.' ) );
2010-10-21 20:35:52 +02:00
2011-12-01 03:22:07 +01: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>' .
'<p>' . __ ( '<strong>Info</strong> - The domain and path are 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>' .
'<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-02 22:42:57 +01:00
get_current_screen () -> set_help_sidebar (
2010-12-16 07:52:47 +01:00
'<p><strong>' . __ ( 'For more information:' ) . '</strong></p>' .
2015-04-12 23:29:32 +02:00
'<p>' . __ ( '<a href="https://codex.wordpress.org/Network_Admin_Sites_Screen" target="_blank">Documentation on Site Management</a>' ) . '</p>' .
2014-03-08 05:14:15 +01:00
'<p>' . __ ( '<a href="https://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>' ) . '</p>'
2010-12-16 07:52:47 +01:00
);
2010-10-21 20:35:52 +02:00
$id = isset ( $_REQUEST [ 'id' ] ) ? intval ( $_REQUEST [ 'id' ] ) : 0 ;
if ( ! $id )
wp_die ( __ ( 'Invalid site ID.' ) );
$details = get_blog_details ( $id );
2010-12-09 13:36:39 +01:00
if ( ! can_edit_network ( $details -> site_id ) )
2015-04-20 05:27:27 +02:00
wp_die ( __ ( 'You do not have permission to access this page.' ), 403 );
2010-10-21 20:35:52 +02:00
$is_main_site = is_main_site ( $id );
if ( isset ( $_REQUEST [ 'action' ]) && 'update-site' == $_REQUEST [ 'action' ] && is_array ( $_POST [ 'option' ] ) ) {
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 18:14:09 +01:00
$key = wp_unslash ( $key );
$val = wp_unslash ( $val );
2010-10-21 20:35:52 +02: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-29 02:26:49 +02:00
update_option ( $key , $val );
2010-10-21 20:35:52 +02:00
}
2013-10-27 21:05:10 +01:00
/**
2013-10-30 15:39:10 +01:00
* Fires after the site options are updated .
2013-12-04 21:03:09 +01:00
*
2013-10-27 21:05:10 +01:00
* @ since 3.0 . 0
*/
2010-11-30 21:29:02 +01:00
do_action ( 'wpmu_update_blog_options' );
2010-10-21 20:35:52 +02:00
restore_current_blog ();
2010-12-16 08:14:34 +01:00
wp_redirect ( add_query_arg ( array ( 'update' => 'updated' , 'id' => $id ), 'site-settings.php' ) );
2010-12-09 19:02:54 +01:00
exit ;
2010-10-21 20:35:52 +02:00
}
if ( isset ( $_GET [ 'update' ]) ) {
$messages = array ();
if ( 'updated' == $_GET [ 'update' ] )
$messages [] = __ ( 'Site options updated.' );
}
2011-06-03 17:35:45 +02:00
$site_url_no_http = preg_replace ( '#^http(s)?://#' , '' , get_blogaddress_by_id ( $id ) );
2015-04-01 20:00:28 +02:00
$title_site_url_linked = sprintf ( __ ( 'Edit Site: %s' ), '<a href="' . get_blogaddress_by_id ( $id ) . '">' . $site_url_no_http . '</a>' );
$title = sprintf ( __ ( 'Edit Site: %s' ), $site_url_no_http );
2011-06-03 17:35:45 +02:00
2010-10-21 20:35:52 +02:00
$parent_file = 'sites.php' ;
$submenu_file = 'sites.php' ;
2013-09-25 02:18:11 +02:00
require ( ABSPATH . 'wp-admin/admin-header.php' );
2010-10-21 20:35:52 +02:00
?>
< div class = " wrap " >
2011-06-03 17:35:45 +02:00
< h2 id = " edit-site " >< ? php echo $title_site_url_linked ?> </h2>
2010-10-25 22:45:58 +02:00
< h3 class = " nav-tab-wrapper " >
2010-10-21 20:35:52 +02:00
< ? php
2010-12-16 08:13:01 +01: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 20:35:52 +02:00
foreach ( $tabs as $tab_id => $tab ) {
$class = ( $tab [ 'url' ] == $pagenow ) ? ' nav-tab-active' : '' ;
2011-12-14 00:45:31 +01:00
echo '<a href="' . $tab [ 'url' ] . '?id=' . $id . '" class="nav-tab' . $class . '">' . esc_html ( $tab [ 'label' ] ) . '</a>' ;
2010-10-21 20:35:52 +02:00
}
?>
</ h3 >
< ? php
if ( ! empty ( $messages ) ) {
foreach ( $messages as $msg )
2015-04-02 00:06:28 +02:00
echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>' ;
2010-10-21 20:35:52 +02:00
} ?>
2010-12-16 08:14:34 +01:00
< form method = " post " action = " site-settings.php?action=update-site " >
2010-10-21 20:35:52 +02: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-10 02:44:15 +02: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 20:35:52 +02: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-29 02:26:49 +02:00
$option -> option_value = esc_html ( maybe_unserialize ( $option -> option_value ) );
2010-10-21 20:35:52 +02: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-23 03:29:26 +01: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 18:12:01 +01: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 20:35:52 +02:00
</ tr >
< ? php
} else {
?>
< tr class = " form-field " >
2015-02-23 03:29:26 +01: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 20:35:52 +02: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 21:05:10 +01:00
/**
* Fires at the end of the Edit Site form , before the submit button .
2013-12-04 21:03:09 +01:00
*
2013-10-27 21:05:10 +01:00
* @ since 3.0 . 0
2013-12-04 21:03:09 +01:00
*
2013-10-27 21:05:10 +01:00
* @ param int $id Site ID .
*/
2010-11-30 21:29:02 +01:00
do_action ( 'wpmueditblogaction' , $id );
2010-10-21 20:35:52 +02:00
?>
</ table >
< ? php submit_button (); ?>
</ form >
</ div >
< ? php
2013-09-25 02:18:11 +02:00
require ( ABSPATH . 'wp-admin/admin-footer.php' );