mirror of
https://github.com/WordPress/WordPress.git
synced 2024-10-30 23:39:42 +01:00
cc5ed3a485
The exceptions to this are update_post_meta() and add_post_meta() which are often used by plugins in POST handlers and will continue accepting slashed data for now. Introduce wp_upate_post_meta() and wp_add_post_meta() as unslashed alternatives to update_post_meta() and add_post_meta(). These functions could become methods in WP_Post so don't use them too heavily yet. Remove all escape() calls from wp_xmlrpc_server. Now that core expects unslashed data this is no longer needed. Remove addslashes(), addslashes_gpc(), add_magic_quotes() calls on data being prepared for handoff to core functions that until now expected slashed data. Adding slashes in no longer necessary. Introduce wp_unslash() and use to it remove slashes from GPCS data before using it in core API. Almost every instance of stripslashes() in core should now be wp_unslash(). In the future (a release or three) when GPCS is no longer slashed, wp_unslash() will stop stripping slashes and simply return what is passed. At this point wp_unslash() calls can be removed from core. Introduce wp_slash() for slashing GPCS data. This will also turn into a noop once GPCS is no longer slashed. wp_slash() should almost never be used. It is mainly of use in unit tests. Plugins should use wp_unslash() on data being passed to core API. Plugins should no longer slash data being passed to core. So when you get_post() and then wp_insert_post() the post data from get_post() no longer needs addslashes(). Most plugins were not bothering with this. They will magically start doing the right thing. Unfortunately, those few souls who did it properly will now have to avoid calling addslashes() for 3.6 and newer. Use wp_kses_post() and wp_kses_data(), which expect unslashed data, instead of wp_filter_post_kses() and wp_filter_kses(), which expect slashed data. Filters are no longer passed slashed data. Remove many no longer necessary calls to $wpdb->escape() and esc_sql(). In wp_get_referer() and wp_get_original_referer(), return unslashed data. Remove old stripslashes() calls from WP_Widget::update() handlers. These haven't been necessary since WP_Widget. Switch several queries over to prepare(). Expect something to break. Props alexkingorg see #21767 git-svn-id: http://core.svn.wordpress.org/trunk@23416 1a063a9b-81f0-0310-95a4-ce76da25c4cd
162 lines
7.1 KiB
PHP
162 lines
7.1 KiB
PHP
<?php
|
|
/**
|
|
* Edit Site Settings Administration Screen
|
|
*
|
|
* @package WordPress
|
|
* @subpackage Multisite
|
|
* @since 3.1.0
|
|
*/
|
|
|
|
/** Load WordPress Administration Bootstrap */
|
|
require_once( './admin.php' );
|
|
|
|
if ( ! is_multisite() )
|
|
wp_die( __( 'Multisite support is not enabled.' ) );
|
|
|
|
if ( ! current_user_can( 'manage_sites' ) )
|
|
wp_die( __( 'You do not have sufficient permissions to edit this site.' ) );
|
|
|
|
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>'
|
|
) );
|
|
|
|
get_current_screen()->set_help_sidebar(
|
|
'<p><strong>' . __('For more information:') . '</strong></p>' .
|
|
'<p>' . __('<a href="http://codex.wordpress.org/Network_Admin_Sites_Screen" target="_blank">Documentation on Site Management</a>') . '</p>' .
|
|
'<p>' . __('<a href="http://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
|
|
);
|
|
|
|
$id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
|
|
|
|
if ( ! $id )
|
|
wp_die( __('Invalid site ID.') );
|
|
|
|
$details = get_blog_details( $id );
|
|
if ( !can_edit_network( $details->site_id ) )
|
|
wp_die( __( 'You do not have permission to access this page.' ) );
|
|
|
|
$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 );
|
|
|
|
$c = 1;
|
|
$count = count( $_POST['option'] );
|
|
$skip_options = array( 'allowedthemes' ); // Don't update these options since they are handled elsewhere in the form.
|
|
foreach ( (array) $_POST['option'] as $key => $val ) {
|
|
$key = wp_unslash( $key );
|
|
$val = wp_unslash( $val );
|
|
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
|
|
if ( $c == $count )
|
|
update_option( $key, $val );
|
|
else
|
|
update_option( $key, $val, false ); // no need to refresh blog details yet
|
|
$c++;
|
|
}
|
|
|
|
do_action( 'wpmu_update_blog_options' );
|
|
restore_current_blog();
|
|
wp_redirect( add_query_arg( array( 'update' => 'updated', 'id' => $id ), 'site-settings.php') );
|
|
exit;
|
|
}
|
|
|
|
if ( isset($_GET['update']) ) {
|
|
$messages = array();
|
|
if ( 'updated' == $_GET['update'] )
|
|
$messages[] = __('Site options updated.');
|
|
}
|
|
|
|
$site_url_no_http = preg_replace( '#^http(s)?://#', '', get_blogaddress_by_id( $id ) );
|
|
$title_site_url_linked = sprintf( __('Edit Site: <a href="%1$s">%2$s</a>'), get_blogaddress_by_id( $id ), $site_url_no_http );
|
|
$title = sprintf( __('Edit Site: %s'), $site_url_no_http );
|
|
|
|
$parent_file = 'sites.php';
|
|
$submenu_file = 'sites.php';
|
|
|
|
require('../admin-header.php');
|
|
|
|
?>
|
|
|
|
<div class="wrap">
|
|
<?php screen_icon('ms-admin'); ?>
|
|
<h2 id="edit-site"><?php echo $title_site_url_linked ?></h2>
|
|
<h3 class="nav-tab-wrapper">
|
|
<?php
|
|
$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' ),
|
|
);
|
|
foreach ( $tabs as $tab_id => $tab ) {
|
|
$class = ( $tab['url'] == $pagenow ) ? ' nav-tab-active' : '';
|
|
echo '<a href="' . $tab['url'] . '?id=' . $id .'" class="nav-tab' . $class . '">' . esc_html( $tab['label'] ) . '</a>';
|
|
}
|
|
?>
|
|
</h3>
|
|
<?php
|
|
if ( ! empty( $messages ) ) {
|
|
foreach ( $messages as $msg )
|
|
echo '<div id="message" class="updated"><p>' . $msg . '</p></div>';
|
|
} ?>
|
|
<form method="post" action="site-settings.php?action=update-site">
|
|
<?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 );
|
|
$options = $wpdb->get_results( "SELECT * FROM {$blog_prefix}options WHERE option_name NOT LIKE '\_%' AND option_name NOT LIKE '%user_roles'" );
|
|
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 ) ) {
|
|
$option->option_value = esc_html( maybe_unserialize( $option->option_value ), 'single' );
|
|
} else {
|
|
$option->option_value = 'SERIALIZED DATA';
|
|
$disabled = true;
|
|
$class = 'all-options disabled';
|
|
}
|
|
}
|
|
if ( strpos( $option->option_value, "\n" ) !== false ) {
|
|
?>
|
|
<tr class="form-field">
|
|
<th scope="row"><?php echo ucwords( str_replace( "_", " ", $option->option_name ) ) ?></th>
|
|
<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>
|
|
</tr>
|
|
<?php
|
|
} else {
|
|
?>
|
|
<tr class="form-field">
|
|
<th scope="row"><?php echo esc_html( ucwords( str_replace( "_", " ", $option->option_name ) ) ); ?></th>
|
|
<?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
|
|
do_action( 'wpmueditblogaction', $id );
|
|
?>
|
|
</table>
|
|
<?php submit_button(); ?>
|
|
</form>
|
|
|
|
</div>
|
|
<?php
|
|
require('../admin-footer.php');
|