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 */
|
2020-02-06 07:33:11 +01:00
|
|
|
require_once __DIR__ . '/admin.php';
|
2010-10-21 20:35:52 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( ! current_user_can( 'manage_sites' ) ) {
|
2016-06-29 17:16:29 +02:00
|
|
|
wp_die( __( 'Sorry, you are not allowed to edit this site.' ) );
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2010-10-21 20:35:52 +02:00
|
|
|
|
2017-07-17 22:53:45 +02:00
|
|
|
get_current_screen()->add_help_tab( get_site_screen_help_tab_args() );
|
|
|
|
get_current_screen()->set_help_sidebar( get_site_screen_help_sidebar_content() );
|
2010-12-16 07:52:47 +01:00
|
|
|
|
2020-10-08 23:15:13 +02:00
|
|
|
$id = isset( $_REQUEST['id'] ) ? (int) $_REQUEST['id'] : 0;
|
2010-10-21 20:35:52 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( ! $id ) {
|
|
|
|
wp_die( __( 'Invalid site ID.' ) );
|
|
|
|
}
|
2010-10-21 20:35:52 +02:00
|
|
|
|
2016-10-19 08:08:28 +02:00
|
|
|
$details = get_site( $id );
|
2015-07-09 18:29:24 +02:00
|
|
|
if ( ! $details ) {
|
|
|
|
wp_die( __( 'The requested site does not exist.' ) );
|
|
|
|
}
|
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( ! can_edit_network( $details->site_id ) ) {
|
2016-06-29 17:16:29 +02:00
|
|
|
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2010-10-21 20:35:52 +02:00
|
|
|
|
|
|
|
$is_main_site = is_main_site( $id );
|
|
|
|
|
2020-05-24 11:17:09 +02:00
|
|
|
if ( isset( $_REQUEST['action'] ) && 'update-site' === $_REQUEST['action'] && is_array( $_POST['option'] ) ) {
|
2010-10-21 20:35:52 +02: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 18:14:09 +01:00
|
|
|
$key = wp_unslash( $key );
|
|
|
|
$val = wp_unslash( $val );
|
2020-04-05 05:02:11 +02:00
|
|
|
if ( 0 === $key || is_array( $val ) || in_array( $key, $skip_options, true ) ) {
|
2020-05-24 11:17:09 +02:00
|
|
|
continue; // Avoids "0 is a protected WP option and may not be modified" error when editing blog options.
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2013-04-29 02:26:49 +02:00
|
|
|
update_option( $key, $val );
|
2010-10-21 20:35:52 +02:00
|
|
|
}
|
|
|
|
|
2015-09-05 22:39:24 +02: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 20:35:52 +02:00
|
|
|
restore_current_blog();
|
2017-12-01 00:11:00 +01:00
|
|
|
wp_redirect(
|
|
|
|
add_query_arg(
|
|
|
|
array(
|
|
|
|
'update' => 'updated',
|
|
|
|
'id' => $id,
|
2018-08-17 03:51:36 +02:00
|
|
|
),
|
|
|
|
'site-settings.php'
|
2017-12-01 00:11:00 +01:00
|
|
|
)
|
|
|
|
);
|
2010-12-09 19:02:54 +01:00
|
|
|
exit;
|
2010-10-21 20:35:52 +02:00
|
|
|
}
|
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( isset( $_GET['update'] ) ) {
|
2010-10-21 20:35:52 +02:00
|
|
|
$messages = array();
|
2020-05-24 11:17:09 +02:00
|
|
|
if ( 'updated' === $_GET['update'] ) {
|
2017-12-01 00:11:00 +01:00
|
|
|
$messages[] = __( 'Site options updated.' );
|
|
|
|
}
|
2010-10-21 20:35:52 +02:00
|
|
|
}
|
|
|
|
|
2021-07-22 15:53:00 +02:00
|
|
|
// Used in the HTML title tag.
|
2019-09-03 02:41:05 +02:00
|
|
|
/* translators: %s: Site title. */
|
2015-07-13 02:27:24 +02:00
|
|
|
$title = sprintf( __( 'Edit Site: %s' ), esc_html( $details->blogname ) );
|
2011-06-03 17:35:45 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
$parent_file = 'sites.php';
|
2010-10-21 20:35:52 +02:00
|
|
|
$submenu_file = 'sites.php';
|
|
|
|
|
2020-02-06 07:33:11 +01:00
|
|
|
require_once ABSPATH . 'wp-admin/admin-header.php';
|
2010-10-21 20:35:52 +02:00
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
<div class="wrap">
|
2015-07-13 02:27:24 +02:00
|
|
|
<h1 id="edit-site"><?php echo $title; ?></h1>
|
2015-08-10 20:11:25 +02: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>
|
2016-05-19 23:48:30 +02:00
|
|
|
|
2010-10-21 20:35:52 +02:00
|
|
|
<?php
|
2016-05-19 23:48:30 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
network_edit_site_nav(
|
|
|
|
array(
|
|
|
|
'blog_id' => $id,
|
|
|
|
'selected' => 'site-settings',
|
|
|
|
)
|
|
|
|
);
|
2016-05-19 23:48:30 +02:00
|
|
|
|
2010-10-21 20:35:52 +02:00
|
|
|
if ( ! empty( $messages ) ) {
|
2023-08-17 23:03:19 +02:00
|
|
|
$notice_args = array(
|
|
|
|
'type' => 'success',
|
|
|
|
'dismissible' => true,
|
|
|
|
'id' => 'message',
|
|
|
|
);
|
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
foreach ( $messages as $msg ) {
|
2023-08-17 23:03:19 +02:00
|
|
|
wp_admin_notice( $msg, $notice_args );
|
2017-12-01 00:11:00 +01: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' ); ?>
|
2017-12-01 00:11:00 +01:00
|
|
|
<input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
|
2019-05-24 23:56:54 +02:00
|
|
|
<table class="form-table" role="presentation">
|
2010-10-21 20:35:52 +02:00
|
|
|
<?php
|
|
|
|
$blog_prefix = $wpdb->get_blog_prefix( $id );
|
2017-12-01 00:11:00 +01:00
|
|
|
$sql = "SELECT * FROM {$blog_prefix}options
|
2014-06-10 02:44:15 +02:00
|
|
|
WHERE option_name NOT LIKE %s
|
|
|
|
AND option_name NOT LIKE %s";
|
2017-12-01 00:11:00 +01:00
|
|
|
$query = $wpdb->prepare(
|
|
|
|
$sql,
|
2014-06-10 02:44:15 +02:00
|
|
|
$wpdb->esc_like( '_' ) . '%',
|
|
|
|
'%' . $wpdb->esc_like( 'user_roles' )
|
|
|
|
);
|
2017-12-01 00:11:00 +01:00
|
|
|
$options = $wpdb->get_results( $query );
|
2020-05-24 11:17:09 +02:00
|
|
|
|
2010-10-21 20:35:52 +02:00
|
|
|
foreach ( $options as $option ) {
|
2020-02-09 17:55:09 +01:00
|
|
|
if ( 'default_role' === $option->option_name ) {
|
2010-10-21 20:35:52 +02:00
|
|
|
$editblog_default_role = $option->option_value;
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2020-05-24 11:17:09 +02:00
|
|
|
|
2010-10-21 20:35:52 +02:00
|
|
|
$disabled = false;
|
2017-12-01 00:11:00 +01:00
|
|
|
$class = 'all-options';
|
2020-05-24 11:17:09 +02:00
|
|
|
|
2010-10-21 20:35:52 +02:00
|
|
|
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';
|
2017-12-01 00:11:00 +01:00
|
|
|
$disabled = true;
|
|
|
|
$class = 'all-options disabled';
|
2010-10-21 20:35:52 +02:00
|
|
|
}
|
|
|
|
}
|
2020-05-24 11:17:09 +02:00
|
|
|
|
Code Modernization: Replace usage of `strpos()` with `str_contains()`.
`str_contains()` was introduced in PHP 8.0 to perform a case-sensitive check indicating if the string to search in (haystack) contains the given substring (needle).
WordPress core includes a polyfill for `str_contains()` on PHP < 8.0 as of WordPress 5.9.
This commit replaces `false !== strpos( ... )` with `str_contains()` in core files, making the code more readable and consistent, as well as better aligned with modern development practices.
Follow-up to [52039], [52040], [52326], [55703], [55710], [55987].
Props Soean, spacedmonkey, costdev, dingo_d, azaozz, mikeschroder, flixos90, peterwilsoncc, SergeyBiryukov.
Fixes #58206.
Built from https://develop.svn.wordpress.org/trunk@55988
git-svn-id: http://core.svn.wordpress.org/trunk@55500 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-22 16:36:26 +02:00
|
|
|
if ( str_contains( $option->option_value, "\n" ) ) {
|
2018-08-17 03:51:36 +02:00
|
|
|
?>
|
2010-10-21 20:35:52 +02:00
|
|
|
<tr class="form-field">
|
2023-02-22 21:57:18 +01:00
|
|
|
<th scope="row"><label for="<?php echo esc_attr( $option->option_name ); ?>" class="code"><?php echo esc_html( $option->option_name ); ?></label></th>
|
2017-12-01 00:11:00 +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>
|
2018-08-17 03:51:36 +02:00
|
|
|
<?php
|
2010-10-21 20:35:52 +02:00
|
|
|
} else {
|
2018-08-17 03:51:36 +02:00
|
|
|
?>
|
2010-10-21 20:35:52 +02:00
|
|
|
<tr class="form-field">
|
2023-02-22 21:57:18 +01:00
|
|
|
<th scope="row"><label for="<?php echo esc_attr( $option->option_name ); ?>" class="code"><?php echo esc_html( $option->option_name ); ?></label></th>
|
2020-04-05 05:02:11 +02:00
|
|
|
<?php if ( $is_main_site && in_array( $option->option_name, array( 'siteurl', 'home' ), true ) ) { ?>
|
2017-12-01 00:11:00 +01:00
|
|
|
<td><code><?php echo esc_html( $option->option_value ); ?></code></td>
|
2010-10-21 20:35:52 +02:00
|
|
|
<?php } else { ?>
|
2017-12-01 00:11:00 +01:00
|
|
|
<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>
|
2010-10-21 20:35:52 +02:00
|
|
|
<?php } ?>
|
|
|
|
</tr>
|
2018-08-17 03:51:36 +02:00
|
|
|
<?php
|
2010-10-21 20:35:52 +02:00
|
|
|
}
|
2020-01-29 01:45:18 +01:00
|
|
|
} // End foreach.
|
2020-05-24 11:17:09 +02:00
|
|
|
|
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
|
2020-02-06 07:33:11 +01:00
|
|
|
require_once ABSPATH . 'wp-admin/admin-footer.php';
|