mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 09:07:59 +01:00
Coding Standards: Use strict comparison in wp-admin/network
where static strings are involved.
Includes minor code layout fixes for better readability. Follow-up to [47808]. See #49542. Built from https://develop.svn.wordpress.org/trunk@47853 git-svn-id: http://core.svn.wordpress.org/trunk@47629 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5899bf0f32
commit
786ac48c84
@ -7,7 +7,7 @@
|
||||
* @since 3.1.0
|
||||
*/
|
||||
|
||||
if ( isset( $_GET['tab'] ) && ( 'plugin-information' == $_GET['tab'] ) ) {
|
||||
if ( isset( $_GET['tab'] ) && ( 'plugin-information' === $_GET['tab'] ) ) {
|
||||
define( 'IFRAME_REQUEST', true );
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ if ( ! empty( $_GET['network_admin_hash'] ) ) {
|
||||
}
|
||||
wp_redirect( network_admin_url( $redirect ) );
|
||||
exit;
|
||||
} elseif ( ! empty( $_GET['dismiss'] ) && 'new_network_admin_email' == $_GET['dismiss'] ) {
|
||||
} elseif ( ! empty( $_GET['dismiss'] ) && 'new_network_admin_email' === $_GET['dismiss'] ) {
|
||||
check_admin_referer( 'dismiss_new_network_admin_email' );
|
||||
delete_site_option( 'network_admin_hash' );
|
||||
delete_site_option( 'new_admin_email' );
|
||||
@ -255,9 +255,13 @@ if ( isset( $_GET['updated'] ) ) {
|
||||
<?php
|
||||
$limited_email_domains = get_site_option( 'limited_email_domains' );
|
||||
$limited_email_domains = str_replace( ' ', "\n", $limited_email_domains );
|
||||
|
||||
if ( $limited_email_domains ) {
|
||||
$limited_email_domains = implode( "\n", (array) $limited_email_domains );
|
||||
}
|
||||
?>
|
||||
<textarea name="limited_email_domains" id="limited_email_domains" aria-describedby="limited-email-domains-desc" cols="45" rows="5">
|
||||
<?php echo esc_textarea( '' == $limited_email_domains ? '' : implode( "\n", (array) $limited_email_domains ) ); ?></textarea>
|
||||
<?php echo esc_textarea( $limited_email_domains ); ?></textarea>
|
||||
<p class="description" id="limited-email-domains-desc">
|
||||
<?php _e( 'If you want to limit site registrations to certain domains. One domain per line.' ); ?>
|
||||
</p>
|
||||
@ -267,8 +271,15 @@ if ( isset( $_GET['updated'] ) ) {
|
||||
<tr>
|
||||
<th scope="row"><label for="banned_email_domains"><?php _e( 'Banned Email Domains' ); ?></label></th>
|
||||
<td>
|
||||
<?php
|
||||
$banned_email_domains = get_site_option( 'banned_email_domains' );
|
||||
|
||||
if ( $banned_email_domains ) {
|
||||
$banned_email_domains = implode( "\n", (array) $banned_email_domains );
|
||||
}
|
||||
?>
|
||||
<textarea name="banned_email_domains" id="banned_email_domains" aria-describedby="banned-email-domains-desc" cols="45" rows="5">
|
||||
<?php echo esc_textarea( get_site_option( 'banned_email_domains' ) == '' ? '' : implode( "\n", (array) get_site_option( 'banned_email_domains' ) ) ); ?></textarea>
|
||||
<?php echo esc_textarea( $banned_email_domains ); ?></textarea>
|
||||
<p class="description" id="banned-email-domains-desc">
|
||||
<?php _e( 'If you want to ban domains from site registrations. One domain per line.' ); ?>
|
||||
</p>
|
||||
|
@ -35,7 +35,7 @@ if ( ! can_edit_network( $details->site_id ) ) {
|
||||
$parsed_scheme = parse_url( $details->siteurl, PHP_URL_SCHEME );
|
||||
$is_main_site = is_main_site( $id );
|
||||
|
||||
if ( isset( $_REQUEST['action'] ) && 'update-site' == $_REQUEST['action'] ) {
|
||||
if ( isset( $_REQUEST['action'] ) && 'update-site' === $_REQUEST['action'] ) {
|
||||
check_admin_referer( 'edit-site' );
|
||||
|
||||
switch_to_blog( $id );
|
||||
@ -117,7 +117,7 @@ if ( isset( $_REQUEST['action'] ) && 'update-site' == $_REQUEST['action'] ) {
|
||||
|
||||
if ( isset( $_GET['update'] ) ) {
|
||||
$messages = array();
|
||||
if ( 'updated' == $_GET['update'] ) {
|
||||
if ( 'updated' === $_GET['update'] ) {
|
||||
$messages[] = __( 'Site info updated.' );
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ get_current_screen()->set_help_sidebar(
|
||||
'<p>' . __( '<a href="https://wordpress.org/support/forum/multisite/">Support Forums</a>' ) . '</p>'
|
||||
);
|
||||
|
||||
if ( isset( $_REQUEST['action'] ) && 'add-site' == $_REQUEST['action'] ) {
|
||||
if ( isset( $_REQUEST['action'] ) && 'add-site' === $_REQUEST['action'] ) {
|
||||
check_admin_referer( 'add-blog', '_wpnonce_add-blog' );
|
||||
|
||||
if ( ! is_array( $_POST['blog'] ) ) {
|
||||
@ -139,6 +139,7 @@ if ( isset( $_REQUEST['action'] ) && 'add-site' == $_REQUEST['action'] ) {
|
||||
$wpdb->hide_errors();
|
||||
$id = wpmu_create_blog( $newdomain, $path, $title, $user_id, $meta, get_current_network_id() );
|
||||
$wpdb->show_errors();
|
||||
|
||||
if ( ! is_wp_error( $id ) ) {
|
||||
if ( ! is_super_admin( $user_id ) && ! get_user_option( 'primary_blog', $user_id ) ) {
|
||||
update_user_option( $user_id, 'primary_blog', $id, true );
|
||||
@ -187,7 +188,7 @@ Name: %3$s'
|
||||
|
||||
if ( isset( $_GET['update'] ) ) {
|
||||
$messages = array();
|
||||
if ( 'added' == $_GET['update'] ) {
|
||||
if ( 'added' === $_GET['update'] ) {
|
||||
$messages[] = sprintf(
|
||||
/* translators: 1: Dashboard URL, 2: Network admin edit URL. */
|
||||
__( 'Site added. <a href="%1$s">Visit Dashboard</a> or <a href="%2$s">Edit Site</a>' ),
|
||||
|
@ -34,7 +34,7 @@ if ( ! can_edit_network( $details->site_id ) ) {
|
||||
|
||||
$is_main_site = is_main_site( $id );
|
||||
|
||||
if ( isset( $_REQUEST['action'] ) && 'update-site' == $_REQUEST['action'] && is_array( $_POST['option'] ) ) {
|
||||
if ( isset( $_REQUEST['action'] ) && 'update-site' === $_REQUEST['action'] && is_array( $_POST['option'] ) ) {
|
||||
check_admin_referer( 'edit-site' );
|
||||
|
||||
switch_to_blog( $id );
|
||||
@ -44,7 +44,7 @@ if ( isset( $_REQUEST['action'] ) && 'update-site' == $_REQUEST['action'] && is_
|
||||
$key = wp_unslash( $key );
|
||||
$val = wp_unslash( $val );
|
||||
if ( 0 === $key || is_array( $val ) || in_array( $key, $skip_options, true ) ) {
|
||||
continue; // Avoids "0 is a protected WP option and may not be modified" error when edit blog options.
|
||||
continue; // Avoids "0 is a protected WP option and may not be modified" error when editing blog options.
|
||||
}
|
||||
update_option( $key, $val );
|
||||
}
|
||||
@ -74,7 +74,7 @@ if ( isset( $_REQUEST['action'] ) && 'update-site' == $_REQUEST['action'] && is_
|
||||
|
||||
if ( isset( $_GET['update'] ) ) {
|
||||
$messages = array();
|
||||
if ( 'updated' == $_GET['update'] ) {
|
||||
if ( 'updated' === $_GET['update'] ) {
|
||||
$messages[] = __( 'Site options updated.' );
|
||||
}
|
||||
}
|
||||
@ -123,12 +123,15 @@ if ( ! empty( $messages ) ) {
|
||||
'%' . $wpdb->esc_like( 'user_roles' )
|
||||
);
|
||||
$options = $wpdb->get_results( $query );
|
||||
|
||||
foreach ( $options as $option ) {
|
||||
if ( 'default_role' === $option->option_name ) {
|
||||
$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 ) );
|
||||
@ -138,6 +141,7 @@ if ( ! empty( $messages ) ) {
|
||||
$class = 'all-options disabled';
|
||||
}
|
||||
}
|
||||
|
||||
if ( strpos( $option->option_value, "\n" ) !== false ) {
|
||||
?>
|
||||
<tr class="form-field">
|
||||
@ -158,6 +162,7 @@ if ( ! empty( $messages ) ) {
|
||||
<?php
|
||||
}
|
||||
} // End foreach.
|
||||
|
||||
/**
|
||||
* Fires at the end of the Edit Site form, before the submit button.
|
||||
*
|
||||
|
@ -158,7 +158,7 @@ if ( $action ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( isset( $_GET['action'] ) && 'update-site' == $_GET['action'] ) {
|
||||
if ( isset( $_GET['action'] ) && 'update-site' === $_GET['action'] ) {
|
||||
wp_safe_redirect( $referer );
|
||||
exit();
|
||||
}
|
||||
@ -188,7 +188,7 @@ network_edit_site_nav(
|
||||
|
||||
if ( isset( $_GET['enabled'] ) ) {
|
||||
$enabled = absint( $_GET['enabled'] );
|
||||
if ( 1 == $enabled ) {
|
||||
if ( 1 === $enabled ) {
|
||||
$message = __( 'Theme enabled.' );
|
||||
} else {
|
||||
/* translators: %s: Number of themes. */
|
||||
@ -197,14 +197,14 @@ if ( isset( $_GET['enabled'] ) ) {
|
||||
echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $enabled ) ) . '</p></div>';
|
||||
} elseif ( isset( $_GET['disabled'] ) ) {
|
||||
$disabled = absint( $_GET['disabled'] );
|
||||
if ( 1 == $disabled ) {
|
||||
if ( 1 === $disabled ) {
|
||||
$message = __( 'Theme disabled.' );
|
||||
} else {
|
||||
/* translators: %s: Number of themes. */
|
||||
$message = _n( '%s theme disabled.', '%s themes disabled.', $disabled );
|
||||
}
|
||||
echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $disabled ) ) . '</p></div>';
|
||||
} elseif ( isset( $_GET['error'] ) && 'none' == $_GET['error'] ) {
|
||||
} elseif ( isset( $_GET['error'] ) && 'none' === $_GET['error'] ) {
|
||||
echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'No theme selected.' ) . '</p></div>';
|
||||
}
|
||||
?>
|
||||
|
@ -77,6 +77,7 @@ if ( $action ) {
|
||||
$update = 'err_add_fail';
|
||||
} else {
|
||||
$update = 'newuser';
|
||||
|
||||
/**
|
||||
* Fires after a user has been created via the network site-users.php page.
|
||||
*
|
||||
@ -178,9 +179,11 @@ if ( $action ) {
|
||||
}
|
||||
check_admin_referer( 'bulk-users' );
|
||||
$userids = $_REQUEST['users'];
|
||||
|
||||
/** This action is documented in wp-admin/network/site-themes.php */
|
||||
$referer = apply_filters( 'handle_network_bulk_actions-' . get_current_screen()->id, $referer, $action, $userids, $id ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
|
||||
$update = $action;
|
||||
|
||||
$update = $action;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -190,7 +193,7 @@ if ( $action ) {
|
||||
|
||||
restore_current_blog();
|
||||
|
||||
if ( isset( $_GET['action'] ) && 'update-site' == $_GET['action'] ) {
|
||||
if ( isset( $_GET['action'] ) && 'update-site' === $_GET['action'] ) {
|
||||
wp_safe_redirect( $referer );
|
||||
exit();
|
||||
}
|
||||
|
@ -223,11 +223,14 @@ if ( isset( $_GET['action'] ) ) {
|
||||
wp_die( __( 'Sorry, you are not allowed to change the current site.' ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! in_array( $doaction, array( 'delete', 'spam', 'notspam' ), true ) ) {
|
||||
$redirect_to = wp_get_referer();
|
||||
$blogs = (array) $_POST['allblogs'];
|
||||
|
||||
/** This action is documented in wp-admin/network/site-themes.php */
|
||||
$redirect_to = apply_filters( 'handle_network_bulk_actions-' . get_current_screen()->id, $redirect_to, $doaction, $blogs, $id ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
|
||||
|
||||
wp_safe_redirect( $redirect_to );
|
||||
exit();
|
||||
}
|
||||
@ -237,6 +240,7 @@ if ( isset( $_GET['action'] ) ) {
|
||||
array( '_wp_http_referer', '_wpnonce' ),
|
||||
add_query_arg( $_POST, network_admin_url( 'sites.php' ) )
|
||||
);
|
||||
|
||||
wp_redirect( $location );
|
||||
exit;
|
||||
}
|
||||
@ -270,6 +274,7 @@ if ( isset( $_GET['action'] ) ) {
|
||||
* @param string $id The ID of the site being deactivated.
|
||||
*/
|
||||
do_action( 'deactivate_blog', $id );
|
||||
|
||||
update_blog_status( $id, 'deleted', '1' );
|
||||
break;
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
* @since 3.1.0
|
||||
*/
|
||||
|
||||
if ( isset( $_GET['tab'] ) && ( 'theme-information' == $_GET['tab'] ) ) {
|
||||
if ( isset( $_GET['tab'] ) && ( 'theme-information' === $_GET['tab'] ) ) {
|
||||
define( 'IFRAME_REQUEST', true );
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ get_current_screen()->set_help_sidebar(
|
||||
'<p>' . __( '<a href="https://wordpress.org/support/forum/multisite/">Support Forums</a>' ) . '</p>'
|
||||
);
|
||||
|
||||
if ( isset( $_REQUEST['action'] ) && 'add-user' == $_REQUEST['action'] ) {
|
||||
if ( isset( $_REQUEST['action'] ) && 'add-user' === $_REQUEST['action'] ) {
|
||||
check_admin_referer( 'add-user', '_wpnonce_add-user' );
|
||||
|
||||
if ( ! current_user_can( 'manage_network_users' ) ) {
|
||||
@ -44,6 +44,7 @@ if ( isset( $_REQUEST['action'] ) && 'add-user' == $_REQUEST['action'] ) {
|
||||
$user = wp_unslash( $_POST['user'] );
|
||||
|
||||
$user_details = wpmu_validate_user_signup( $user['username'], $user['email'] );
|
||||
|
||||
if ( is_wp_error( $user_details['errors'] ) && $user_details['errors']->has_errors() ) {
|
||||
$add_user_errors = $user_details['errors'];
|
||||
} else {
|
||||
@ -61,6 +62,7 @@ if ( isset( $_REQUEST['action'] ) && 'add-user' == $_REQUEST['action'] ) {
|
||||
* @param int $user_id ID of the newly created user.
|
||||
*/
|
||||
do_action( 'network_user_new_created_user', $user_id );
|
||||
|
||||
wp_redirect(
|
||||
add_query_arg(
|
||||
array(
|
||||
@ -77,7 +79,7 @@ if ( isset( $_REQUEST['action'] ) && 'add-user' == $_REQUEST['action'] ) {
|
||||
|
||||
if ( isset( $_GET['update'] ) ) {
|
||||
$messages = array();
|
||||
if ( 'added' == $_GET['update'] ) {
|
||||
if ( 'added' === $_GET['update'] ) {
|
||||
$edit_link = '';
|
||||
if ( isset( $_GET['user_id'] ) ) {
|
||||
$user_id_new = absint( $_GET['user_id'] );
|
||||
|
@ -27,7 +27,7 @@ if ( isset( $_GET['action'] ) ) {
|
||||
check_admin_referer( 'deleteuser' );
|
||||
|
||||
$id = intval( $_GET['id'] );
|
||||
if ( '0' != $id && '1' != $id ) {
|
||||
if ( $id > 1 ) {
|
||||
$_POST['allusers'] = array( $id ); // confirm_delete_users() can only handle arrays.
|
||||
$title = __( 'Users' );
|
||||
$parent_file = 'users.php';
|
||||
@ -116,8 +116,8 @@ if ( isset( $_GET['action'] ) ) {
|
||||
|
||||
if ( ! in_array( $doaction, array( 'delete', 'spam', 'notspam' ), true ) ) {
|
||||
$sendback = wp_get_referer();
|
||||
|
||||
$user_ids = (array) $_POST['allusers'];
|
||||
|
||||
/** This action is documented in wp-admin/network/site-themes.php */
|
||||
$sendback = apply_filters( 'handle_network_bulk_actions-' . get_current_screen()->id, $sendback, $doaction, $user_ids ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
|
||||
|
||||
@ -157,7 +157,7 @@ if ( isset( $_GET['action'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ! empty( $_POST['delete'] ) && 'reassign' == $_POST['delete'][ $blogid ][ $id ] ) {
|
||||
if ( ! empty( $_POST['delete'] ) && 'reassign' === $_POST['delete'][ $blogid ][ $id ] ) {
|
||||
remove_user_from_blog( $id, $blogid, (int) $user_id );
|
||||
} else {
|
||||
remove_user_from_blog( $id, $blogid );
|
||||
@ -165,7 +165,9 @@ if ( isset( $_GET['action'] ) ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
|
||||
if ( is_array( $_POST['user'] ) && ! empty( $_POST['user'] ) ) {
|
||||
foreach ( $_POST['user'] as $id ) {
|
||||
if ( ! current_user_can( 'delete_user', $id ) ) {
|
||||
@ -176,7 +178,7 @@ if ( isset( $_GET['action'] ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( 1 == $i ) {
|
||||
if ( 1 === $i ) {
|
||||
$deletefunction = 'delete';
|
||||
} else {
|
||||
$deletefunction = 'all_delete';
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.5-alpha-47852';
|
||||
$wp_version = '5.5-alpha-47853';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user