Coding Standards: Use strict comparison in some `wp-admin` files.

Props pikamander2, mukesh27, SergeyBiryukov.
Fixes #49239.
Built from https://develop.svn.wordpress.org/trunk@47785


git-svn-id: http://core.svn.wordpress.org/trunk@47561 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-05-12 18:32:08 +00:00
parent 2eef7ee2ac
commit aa69c25d5f
25 changed files with 152 additions and 106 deletions

View File

@ -44,7 +44,7 @@ if ( is_network_admin() ) {
$admin_title = get_bloginfo( 'name' );
}
if ( $admin_title == $title ) {
if ( $admin_title === $title ) {
/* translators: Admin screen title. %s: Admin screen name. */
$admin_title = sprintf( __( '%s — WordPress' ), $title );
} else {
@ -147,7 +147,7 @@ do_action( "admin_head-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConven
*/
do_action( 'admin_head' );
if ( get_user_setting( 'mfold' ) == 'f' ) {
if ( get_user_setting( 'mfold' ) === 'f' ) {
$admin_body_class .= ' folded';
}

View File

@ -45,7 +45,7 @@ if ( get_option( 'db_upgraded' ) ) {
* @since 2.8.0
*/
do_action( 'after_db_upgrade' );
} elseif ( get_option( 'db_version' ) != $wp_db_version && empty( $_POST ) ) {
} elseif ( get_option( 'db_version' ) !== $wp_db_version && empty( $_POST ) ) {
if ( ! is_multisite() ) {
wp_redirect( admin_url( 'upgrade.php?_wp_http_referer=' . urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) );
exit;

View File

@ -42,7 +42,7 @@ if ( ! current_user_can( 'upload_files' ) ) {
if ( isset( $_REQUEST['attachment_id'] ) && intval( $_REQUEST['attachment_id'] ) && $_REQUEST['fetch'] ) {
$id = intval( $_REQUEST['attachment_id'] );
$post = get_post( $id );
if ( 'attachment' != $post->post_type ) {
if ( 'attachment' !== $post->post_type ) {
wp_die( __( 'Invalid post type.' ) );
}
if ( ! current_user_can( 'edit_post', $id ) ) {

View File

@ -22,16 +22,16 @@ if ( isset( $_POST['deletecomment'] ) ) {
$action = 'deletecomment';
}
if ( 'cdc' == $action ) {
if ( 'cdc' === $action ) {
$action = 'delete';
} elseif ( 'mac' == $action ) {
} elseif ( 'mac' === $action ) {
$action = 'approve';
}
if ( isset( $_GET['dt'] ) ) {
if ( 'spam' == $_GET['dt'] ) {
if ( 'spam' === $_GET['dt'] ) {
$action = 'spam';
} elseif ( 'trash' == $_GET['dt'] ) {
} elseif ( 'trash' === $_GET['dt'] ) {
$action = 'trash';
}
}
@ -71,7 +71,7 @@ switch ( $action ) {
comment_footer_die( __( 'Sorry, you are not allowed to edit this comment.' ) );
}
if ( 'trash' == $comment->comment_approved ) {
if ( 'trash' === $comment->comment_approved ) {
comment_footer_die( __( 'This comment is in the Trash. Please move it out of the Trash if you want to edit it.' ) );
}
@ -101,7 +101,7 @@ switch ( $action ) {
}
// No need to re-approve/re-trash/re-spam a comment.
if ( str_replace( '1', 'approve', $comment->comment_approved ) == $action ) {
if ( str_replace( '1', 'approve', $comment->comment_approved ) === $action ) {
wp_redirect( admin_url( 'edit-comments.php?same=' . $comment_id ) );
die();
}
@ -109,7 +109,7 @@ switch ( $action ) {
require_once ABSPATH . 'wp-admin/admin-header.php';
$formaction = $action . 'comment';
$nonce_action = 'approve' == $action ? 'approve-comment_' : 'delete-comment_';
$nonce_action = ( 'approve' === $action ) ? 'approve-comment_' : 'delete-comment_';
$nonce_action .= $comment_id;
?>
@ -137,7 +137,7 @@ switch ( $action ) {
break;
}
if ( '0' != $comment->comment_approved ) { // If not unapproved.
if ( '0' !== $comment->comment_approved ) { // If not unapproved.
$message = '';
switch ( $comment->comment_approved ) {
case '1':
@ -271,9 +271,9 @@ switch ( $action ) {
comment_footer_die( __( 'Sorry, you are not allowed to edit comments on this post.' ) );
}
if ( '' != wp_get_referer() && ! $noredir && false === strpos( wp_get_referer(), 'comment.php' ) ) {
if ( wp_get_referer() && ! $noredir && false === strpos( wp_get_referer(), 'comment.php' ) ) {
$redir = wp_get_referer();
} elseif ( '' != wp_get_original_referer() && ! $noredir ) {
} elseif ( wp_get_original_referer() && ! $noredir ) {
$redir = wp_get_original_referer();
} elseif ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ), true ) ) {
$redir = admin_url( 'edit-comments.php?p=' . absint( $comment->comment_post_ID ) );
@ -348,9 +348,9 @@ switch ( $action ) {
* @param int $comment_id The ID of the comment being edited.
*/
$location = apply_filters( 'comment_edit_redirect', $location, $comment_id );
wp_redirect( $location );
exit();
wp_redirect( $location );
exit;
default:
wp_die( __( 'Unknown action.' ) );

View File

@ -24,14 +24,14 @@ $doaction = $wp_list_table->current_action();
if ( $doaction ) {
check_admin_referer( 'bulk-comments' );
if ( 'delete_all' == $doaction && ! empty( $_REQUEST['pagegen_timestamp'] ) ) {
if ( 'delete_all' === $doaction && ! empty( $_REQUEST['pagegen_timestamp'] ) ) {
$comment_status = wp_unslash( $_REQUEST['comment_status'] );
$delete_time = wp_unslash( $_REQUEST['pagegen_timestamp'] );
$comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_approved = %s AND %s > comment_date_gmt", $comment_status, $delete_time ) );
$doaction = 'delete';
} elseif ( isset( $_REQUEST['delete_comments'] ) ) {
$comment_ids = $_REQUEST['delete_comments'];
$doaction = ( -1 != $_REQUEST['action'] ) ? $_REQUEST['action'] : $_REQUEST['action2'];
$doaction = ( '-1' !== $_REQUEST['action'] ) ? $_REQUEST['action'] : $_REQUEST['action2'];
} elseif ( isset( $_REQUEST['ids'] ) ) {
$comment_ids = array_map( 'absint', explode( ',', $_REQUEST['ids'] ) );
} elseif ( wp_get_referer() ) {

View File

@ -76,7 +76,7 @@ $post_ID = isset( $post_ID ) ? (int) $post_ID : 0;
$user_ID = isset( $user_ID ) ? (int) $user_ID : 0;
$action = isset( $action ) ? $action : '';
if ( get_option( 'page_for_posts' ) == $post_ID && empty( $post->post_content ) ) {
if ( (int) get_option( 'page_for_posts' ) === $post_ID && empty( $post->post_content ) ) {
add_action( 'edit_form_after_title', '_wp_posts_page_notice' );
remove_post_type_support( $post_type, 'editor' );
}
@ -228,8 +228,8 @@ if ( isset( $_GET['message'] ) ) {
$notice = false;
$form_extra = '';
if ( 'auto-draft' == $post->post_status ) {
if ( 'edit' == $action ) {
if ( 'auto-draft' === $post->post_status ) {
if ( 'edit' === $action ) {
$post->post_title = '';
}
$autosave = false;
@ -276,7 +276,7 @@ add_screen_option(
)
);
if ( 'post' == $post_type ) {
if ( 'post' === $post_type ) {
$customize_display = '<p>' . __( 'The title field and the big Post Editing Area are fixed in place, but you can reposition all the other boxes using drag and drop. You can also minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to unhide more boxes (Excerpt, Send Trackbacks, Custom Fields, Discussion, Slug, Author) or to choose a 1- or 2-column layout for this screen.' ) . '</p>';
get_current_screen()->add_help_tab(
@ -313,7 +313,7 @@ if ( 'post' == $post_type ) {
'<p>' . __( '<a href="https://wordpress.org/support/article/wordpress-editor/">Documentation on Writing and Editing Posts</a>' ) . '</p>' .
'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
);
} elseif ( 'page' == $post_type ) {
} elseif ( 'page' === $post_type ) {
$about_pages = '<p>' . __( 'Pages are similar to posts in that they have a title, body text, and associated metadata, but they are different in that they are not part of the chronological blog stream, kind of like permanent posts. Pages are not categorized or tagged, but can have a hierarchy. You can nest pages under other pages by making one the &#8220;Parent&#8221; of the other, creating a group of pages.' ) . '</p>' .
'<p>' . __( 'Creating a Page is very similar to creating a Post, and the screens can be customized in the same way using drag and drop, the Screen Options tab, and expanding/collapsing boxes as you choose. This screen also has the distraction-free writing space, available in both the Visual and Text modes via the Fullscreen buttons. The Page editor mostly works the same as the Post editor, but there are some Page-specific features in the Page Attributes box.' ) . '</p>';
@ -331,7 +331,7 @@ if ( 'post' == $post_type ) {
'<p>' . __( '<a href="https://wordpress.org/support/article/pages-screen/">Documentation on Editing Pages</a>' ) . '</p>' .
'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
);
} elseif ( 'attachment' == $post_type ) {
} elseif ( 'attachment' === $post_type ) {
get_current_screen()->add_help_tab(
array(
'id' => 'overview',
@ -351,7 +351,7 @@ if ( 'post' == $post_type ) {
);
}
if ( 'post' == $post_type || 'page' == $post_type ) {
if ( 'post' === $post_type || 'page' === $post_type ) {
$inserting_media = '<p>' . __( 'You can upload and insert media (images, audio, documents, etc.) by clicking the Add Media button. You can select from the images and files already uploaded to the Media Library, or upload new media to add to your page or post. To create an image gallery, select the images to add and click the &#8220;Create a new gallery&#8221; button.' ) . '</p>';
$inserting_media .= '<p>' . __( 'You can also embed media from many popular websites including Twitter, YouTube, Flickr and others by pasting the media URL on its own line into the content of your post/page. <a href="https://wordpress.org/support/article/embeds/">Learn more about embeds</a>.' ) . '</p>';
@ -364,7 +364,7 @@ if ( 'post' == $post_type || 'page' == $post_type ) {
);
}
if ( 'post' == $post_type ) {
if ( 'post' === $post_type ) {
$publish_box = '<p>' . __( 'Several boxes on this screen contain settings for how your content will be published, including:' ) . '</p>';
$publish_box .= '<ul><li>' .
__( '<strong>Publish</strong> &mdash; You can set the terms of publishing your post in the Publish box. For Status, Visibility, and Publish (immediately), click on the Edit link to reveal more options. Visibility includes options for password-protecting a post or making it stay at the top of your blog indefinitely (sticky). The Password protected option allows you to set an arbitrary password for each post. The Private option hides the post from everyone except editors and administrators. Publish (immediately) allows you to set a future or past date and time, so you can schedule a post to be published in the future or backdate a post.' ) .
@ -402,7 +402,7 @@ if ( 'post' == $post_type ) {
'content' => $discussion_settings,
)
);
} elseif ( 'page' == $post_type ) {
} elseif ( 'page' === $post_type ) {
$page_attributes = '<p>' . __( '<strong>Parent</strong> &mdash; You can arrange your pages in hierarchies. For example, you could have an &#8220;About&#8221; page that has &#8220;Life Story&#8221; and &#8220;My Dog&#8221; pages under it. There are no limits to how many levels you can nest pages.' ) . '</p>' .
'<p>' . __( '<strong>Template</strong> &mdash; Some themes have custom templates you can use for certain pages that might have additional features or custom layouts. If so, you&#8217;ll see them in this dropdown menu.' ) . '</p>' .
'<p>' . __( '<strong>Order</strong> &mdash; Pages are usually ordered alphabetically, but you can choose your own order by entering a number (1 for first, etc.) in this field.' ) . '</p>';
@ -471,7 +471,7 @@ $referer = wp_get_referer();
<input type="hidden" id="active_post_lock" value="<?php echo esc_attr( implode( ':', $active_post_lock ) ); ?>" />
<?php
}
if ( 'draft' != get_post_status( $post ) ) {
if ( 'draft' !== get_post_status( $post ) ) {
wp_original_referer_field( true, 'previous' );
}
@ -495,7 +495,7 @@ do_action( 'edit_form_top', $post );
?>
<div id="poststuff">
<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
<div id="post-body" class="metabox-holder columns-<?php echo ( 1 === get_current_screen()->get_columns() ) ? '1' : '2'; ?>">
<div id="post-body-content">
<?php if ( post_type_supports( $post_type, 'title' ) ) { ?>
@ -535,12 +535,17 @@ do_action( 'edit_form_top', $post );
$shortlink = wp_get_shortlink( $post->ID, 'post' );
if ( ! empty( $shortlink ) && $shortlink !== $permalink && home_url( '?page_id=' . $post->ID ) !== $permalink ) {
$sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr( $shortlink ) . '" /><button type="button" class="button button-small" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val());">' . __( 'Get Shortlink' ) . '</button>';
$sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr( $shortlink ) . '" />' .
'<button type="button" class="button button-small" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val());">' .
__( 'Get Shortlink' ) .
'</button>';
}
}
if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) {
$has_sample_permalink = $sample_permalink_html && 'auto-draft' != $post->post_status;
if ( $post_type_object->public
&& ! ( 'pending' === get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) )
) {
$has_sample_permalink = $sample_permalink_html && 'auto-draft' !== $post->post_status;
?>
<div id="edit-slug-box" class="hide-if-no-js">
<?php
@ -608,7 +613,7 @@ if ( post_type_supports( $post_type, 'editor' ) ) {
<td class="autosave-info">
<span class="autosave-message">&nbsp;</span>
<?php
if ( 'auto-draft' != $post->post_status ) {
if ( 'auto-draft' !== $post->post_status ) {
echo '<span id="last-edit">';
$last_user = get_userdata( get_post_meta( $post_ID, '_edit_last', true ) );
if ( $last_user ) {
@ -642,7 +647,7 @@ do_action( 'edit_form_after_editor', $post );
<div id="postbox-container-1" class="postbox-container">
<?php
if ( 'page' == $post_type ) {
if ( 'page' === $post_type ) {
/**
* Fires before meta boxes with 'side' context are output for the 'page' post type.
*
@ -676,7 +681,7 @@ do_meta_boxes( $post_type, 'side', $post );
do_meta_boxes( null, 'normal', $post );
if ( 'page' == $post_type ) {
if ( 'page' === $post_type ) {
/**
* Fires after 'normal' context meta boxes have been output for the 'page' post type.
*

View File

@ -118,7 +118,7 @@ switch ( $comment->comment_approved ) {
<label><input type="radio"<?php checked( $comment->comment_approved, 'spam' ); ?> name="comment_status" value="spam" /><?php _ex( 'Spam', 'comment status' ); ?></label>
</fieldset>
</div><!-- .misc-pub-section -->
<div class="misc-pub-section curtime misc-pub-curtime">
<?php
$submitted = sprintf(

View File

@ -108,7 +108,7 @@ wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
<div id="poststuff">
<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
<div id="post-body" class="metabox-holder columns-<?php echo ( 1 === get_current_screen()->get_columns() ) ? '1' : '2'; ?>">
<div id="post-body-content">
<div id="namediv" class="stuffbox">
<h2><label for="link_name"><?php _ex( 'Name', 'link name' ); ?></label></h2>

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
}
// Back compat hooks.
if ( 'category' == $taxonomy ) {
if ( 'category' === $taxonomy ) {
/**
* Fires before the Edit Category form.
*
@ -22,7 +22,7 @@ if ( 'category' == $taxonomy ) {
* @param WP_Term $tag Current category term object.
*/
do_action_deprecated( 'edit_category_form_pre', array( $tag ), '3.0.0', '{$taxonomy}_pre_edit_form' );
} elseif ( 'link_category' == $taxonomy ) {
} elseif ( 'link_category' === $taxonomy ) {
/**
* Fires before the Edit Link Category form.
*
@ -177,7 +177,7 @@ if ( isset( $tag->name ) ) {
$dropdown_args = apply_filters( 'taxonomy_parent_dropdown_args', $dropdown_args, $taxonomy, 'edit' );
wp_dropdown_categories( $dropdown_args );
?>
<?php if ( 'category' == $taxonomy ) : ?>
<?php if ( 'category' === $taxonomy ) : ?>
<p class="description"><?php _e( 'Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.' ); ?></p>
<?php else : ?>
<p class="description"><?php _e( 'Assign a parent term to create a hierarchy. The term Jazz, for example, would be the parent of Bebop and Big Band.' ); ?></p>
@ -192,7 +192,7 @@ if ( isset( $tag->name ) ) {
</tr>
<?php
// Back compat hooks.
if ( 'category' == $taxonomy ) {
if ( 'category' === $taxonomy ) {
/**
* Fires after the Edit Category form fields are displayed.
*
@ -202,7 +202,7 @@ if ( isset( $tag->name ) ) {
* @param WP_Term $tag Current category term object.
*/
do_action_deprecated( 'edit_category_form_fields', array( $tag ), '3.0.0', '{$taxonomy}_edit_form_fields' );
} elseif ( 'link_category' == $taxonomy ) {
} elseif ( 'link_category' === $taxonomy ) {
/**
* Fires after the Edit Link Category form fields are displayed.
*
@ -239,10 +239,10 @@ if ( isset( $tag->name ) ) {
</table>
<?php
// Back compat hooks.
if ( 'category' == $taxonomy ) {
if ( 'category' === $taxonomy ) {
/** This action is documented in wp-admin/edit-tags.php */
do_action_deprecated( 'edit_category_form', array( $tag ), '3.0.0', '{$taxonomy}_add_form' );
} elseif ( 'link_category' == $taxonomy ) {
} elseif ( 'link_category' === $taxonomy ) {
/** This action is documented in wp-admin/edit-tags.php */
do_action_deprecated( 'edit_link_category_form', array( $tag ), '3.0.0', '{$taxonomy}_add_form' );
} else {

View File

@ -332,7 +332,7 @@ $bulk_messages = array();
$bulk_messages['post'] = array(
/* translators: %s: Number of posts. */
'updated' => _n( '%s post updated.', '%s posts updated.', $bulk_counts['updated'] ),
'locked' => ( 1 == $bulk_counts['locked'] ) ? __( '1 post not updated, somebody is editing it.' ) :
'locked' => ( 1 === $bulk_counts['locked'] ) ? __( '1 post not updated, somebody is editing it.' ) :
/* translators: %s: Number of posts. */
_n( '%s post not updated, somebody is editing it.', '%s posts not updated, somebody is editing them.', $bulk_counts['locked'] ),
/* translators: %s: Number of posts. */
@ -345,7 +345,7 @@ $bulk_messages['post'] = array(
$bulk_messages['page'] = array(
/* translators: %s: Number of pages. */
'updated' => _n( '%s page updated.', '%s pages updated.', $bulk_counts['updated'] ),
'locked' => ( 1 == $bulk_counts['locked'] ) ? __( '1 page not updated, somebody is editing it.' ) :
'locked' => ( 1 === $bulk_counts['locked'] ) ? __( '1 page not updated, somebody is editing it.' ) :
/* translators: %s: Number of pages. */
_n( '%s page not updated, somebody is editing it.', '%s pages not updated, somebody is editing them.', $bulk_counts['locked'] ),
/* translators: %s: Number of pages. */
@ -358,7 +358,7 @@ $bulk_messages['page'] = array(
$bulk_messages['wp_block'] = array(
/* translators: %s: Number of blocks. */
'updated' => _n( '%s block updated.', '%s blocks updated.', $bulk_counts['updated'] ),
'locked' => ( 1 == $bulk_counts['locked'] ) ? __( '1 block not updated, somebody is editing it.' ) :
'locked' => ( 1 === $bulk_counts['locked'] ) ? __( '1 block not updated, somebody is editing it.' ) :
/* translators: %s: Number of blocks. */
_n( '%s block not updated, somebody is editing it.', '%s blocks not updated, somebody is editing them.', $bulk_counts['locked'] ),
/* translators: %s: Number of blocks. */

View File

@ -62,9 +62,9 @@ get_current_screen()->set_help_sidebar(
if ( isset( $_GET['download'] ) ) {
$args = array();
if ( ! isset( $_GET['content'] ) || 'all' == $_GET['content'] ) {
if ( ! isset( $_GET['content'] ) || 'all' === $_GET['content'] ) {
$args['content'] = 'all';
} elseif ( 'posts' == $_GET['content'] ) {
} elseif ( 'posts' === $_GET['content'] ) {
$args['content'] = 'post';
if ( $_GET['cat'] ) {
@ -83,7 +83,7 @@ if ( isset( $_GET['download'] ) ) {
if ( $_GET['post_status'] ) {
$args['status'] = $_GET['post_status'];
}
} elseif ( 'pages' == $_GET['content'] ) {
} elseif ( 'pages' === $_GET['content'] ) {
$args['content'] = 'page';
if ( $_GET['page_author'] ) {
@ -98,7 +98,7 @@ if ( isset( $_GET['download'] ) ) {
if ( $_GET['page_status'] ) {
$args['status'] = $_GET['page_status'];
}
} elseif ( 'attachment' == $_GET['content'] ) {
} elseif ( 'attachment' === $_GET['content'] ) {
$args['content'] = 'attachment';
if ( $_GET['attachment_start_date'] || $_GET['attachment_end_date'] ) {
@ -144,18 +144,18 @@ function export_date_options( $post_type = 'post' ) {
FROM $wpdb->posts
WHERE post_type = %s AND post_status != 'auto-draft'
ORDER BY post_date DESC
",
",
$post_type
)
);
$month_count = count( $months );
if ( ! $month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) {
if ( ! $month_count || ( 1 === $month_count && 0 === (int) $months[0]->month ) ) {
return;
}
foreach ( $months as $date ) {
if ( 0 == $date->year ) {
if ( 0 === (int) $date->year ) {
continue;
}

View File

@ -42,7 +42,7 @@ if ( current_user_can( 'install_plugins' ) ) {
// Detect and redirect invalid importers like 'movabletype', which is registered as 'mt'.
if ( ! empty( $_GET['invalid'] ) && isset( $popular_importers[ $_GET['invalid'] ] ) ) {
$importer_id = $popular_importers[ $_GET['invalid'] ]['importer-id'];
if ( $importer_id != $_GET['invalid'] ) { // Prevent redirect loops.
if ( $importer_id !== $_GET['invalid'] ) { // Prevent redirect loops.
wp_redirect( admin_url( 'admin.php?import=' . $importer_id ) );
exit;
}

View File

@ -2346,7 +2346,7 @@ function maybe_create_table( $table_name, $create_ddl ) {
$query = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $table_name ) );
if ( $wpdb->get_var( $query ) == $table_name ) {
if ( $wpdb->get_var( $query ) === $table_name ) {
return true;
}
@ -2354,9 +2354,10 @@ function maybe_create_table( $table_name, $create_ddl ) {
$wpdb->query( $create_ddl );
// We cannot directly tell that whether this succeeded!
if ( $wpdb->get_var( $query ) == $table_name ) {
if ( $wpdb->get_var( $query ) === $table_name ) {
return true;
}
return false;
}
@ -2373,13 +2374,18 @@ function maybe_create_table( $table_name, $create_ddl ) {
*/
function drop_index( $table, $index ) {
global $wpdb;
$wpdb->hide_errors();
$wpdb->query( "ALTER TABLE `$table` DROP INDEX `$index`" );
// Now we need to take out all the extra ones we may have created.
for ( $i = 0; $i < 25; $i++ ) {
$wpdb->query( "ALTER TABLE `$table` DROP INDEX `{$index}_$i`" );
}
$wpdb->show_errors();
return true;
}
@ -2396,8 +2402,10 @@ function drop_index( $table, $index ) {
*/
function add_clean_index( $table, $index ) {
global $wpdb;
drop_index( $table, $index );
$wpdb->query( "ALTER TABLE `$table` ADD INDEX ( `$index` )" );
return true;
}
@ -2415,8 +2423,9 @@ function add_clean_index( $table, $index ) {
*/
function maybe_add_column( $table_name, $column_name, $create_ddl ) {
global $wpdb;
foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) {
if ( $column == $column_name ) {
if ( $column === $column_name ) {
return true;
}
}
@ -2426,10 +2435,11 @@ function maybe_add_column( $table_name, $column_name, $create_ddl ) {
// We cannot directly tell that whether this succeeded!
foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) {
if ( $column == $column_name ) {
if ( $column === $column_name ) {
return true;
}
}
return false;
}

View File

@ -51,20 +51,23 @@ if ( ! function_exists( 'maybe_create_table' ) ) :
*/
function maybe_create_table( $table_name, $create_ddl ) {
global $wpdb;
foreach ( $wpdb->get_col( 'SHOW TABLES', 0 ) as $table ) {
if ( $table == $table_name ) {
if ( $table === $table_name ) {
return true;
}
}
// Didn't find it, so try to create it.
$wpdb->query( $create_ddl );
// We cannot directly tell that whether this succeeded!
foreach ( $wpdb->get_col( 'SHOW TABLES', 0 ) as $table ) {
if ( $table == $table_name ) {
if ( $table === $table_name ) {
return true;
}
}
return false;
}
endif;
@ -84,9 +87,9 @@ if ( ! function_exists( 'maybe_add_column' ) ) :
*/
function maybe_add_column( $table_name, $column_name, $create_ddl ) {
global $wpdb;
foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) {
if ( $column == $column_name ) {
foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) {
if ( $column === $column_name ) {
return true;
}
}
@ -96,10 +99,11 @@ if ( ! function_exists( 'maybe_add_column' ) ) :
// We cannot directly tell that whether this succeeded!
foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) {
if ( $column == $column_name ) {
if ( $column === $column_name ) {
return true;
}
}
return false;
}
endif;
@ -118,20 +122,22 @@ endif;
*/
function maybe_drop_column( $table_name, $column_name, $drop_ddl ) {
global $wpdb;
foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) {
if ( $column == $column_name ) {
if ( $column === $column_name ) {
// Found it, so try to drop it.
$wpdb->query( $drop_ddl );
// We cannot directly tell that whether this succeeded!
foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) {
if ( $column == $column_name ) {
if ( $column === $column_name ) {
return false;
}
}
}
}
// Else didn't find it.
return true;
}
@ -167,34 +173,38 @@ function maybe_drop_column( $table_name, $column_name, $drop_ddl ) {
*/
function check_column( $table_name, $col_name, $col_type, $is_null = null, $key = null, $default = null, $extra = null ) {
global $wpdb;
$diffs = 0;
$results = $wpdb->get_results( "DESC $table_name" );
foreach ( $results as $row ) {
if ( $row->Field == $col_name ) {
if ( $row->Field === $col_name ) {
// Got our column, check the params.
if ( ( null != $col_type ) && ( $row->Type != $col_type ) ) {
if ( ( null !== $col_type ) && ( $row->Type !== $col_type ) ) {
++$diffs;
}
if ( ( null != $is_null ) && ( $row->Null != $is_null ) ) {
if ( ( null !== $is_null ) && ( $row->Null !== $is_null ) ) {
++$diffs;
}
if ( ( null != $key ) && ( $row->Key != $key ) ) {
if ( ( null !== $key ) && ( $row->Key !== $key ) ) {
++$diffs;
}
if ( ( null != $default ) && ( $row->Default != $default ) ) {
if ( ( null !== $default ) && ( $row->Default !== $default ) ) {
++$diffs;
}
if ( ( null != $extra ) && ( $row->Extra != $extra ) ) {
if ( ( null !== $extra ) && ( $row->Extra !== $extra ) ) {
++$diffs;
}
if ( $diffs > 0 ) {
return false;
}
return true;
} // End if found our column.
}
return false;
}

View File

@ -91,8 +91,7 @@ function display_header( $body_classes = '' ) {
function display_setup_form( $error = null ) {
global $wpdb;
$sql = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $wpdb->users ) );
$user_table = ( $wpdb->get_var( $sql ) != null );
$user_table = ( $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $wpdb->users ) ) ) !== null );
// Ensure that sites appear in search engines by default.
$blog_public = 1;
@ -369,10 +368,10 @@ switch ( $step ) {
// TODO: Poka-yoke.
display_setup_form( __( 'Please provide a valid username.' ) );
$error = true;
} elseif ( sanitize_user( $user_name, true ) != $user_name ) {
} elseif ( sanitize_user( $user_name, true ) !== $user_name ) {
display_setup_form( __( 'The username you provided has invalid characters.' ) );
$error = true;
} elseif ( $admin_password != $admin_password_check ) {
} elseif ( $admin_password !== $admin_password_check ) {
// TODO: Poka-yoke.
display_setup_form( __( 'Your passwords do not match. Please try again.' ) );
$error = true;

View File

@ -23,7 +23,7 @@ if ( $doaction && isset( $_REQUEST['linkcheck'] ) ) {
$redirect_to = admin_url( 'link-manager.php' );
$bulklinks = (array) $_REQUEST['linkcheck'];
if ( 'delete' == $doaction ) {
if ( 'delete' === $doaction ) {
foreach ( $bulklinks as $link_id ) {
$link_id = (int) $link_id;

View File

@ -27,14 +27,14 @@ global $opml;
* @global array $descriptions
* @global array $feeds
*
* @param resource $parser XML Parser resource.
* @param string $tagName XML element name.
* @param array $attrs XML element attributes.
* @param resource $parser XML Parser resource.
* @param string $tag_name XML element name.
* @param array $attrs XML element attributes.
*/
function startElement( $parser, $tagName, $attrs ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
function startElement( $parser, $tag_name, $attrs ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
global $names, $urls, $targets, $descriptions, $feeds;
if ( 'OUTLINE' === $tagName ) {
if ( 'OUTLINE' === $tag_name ) {
$name = '';
if ( isset( $attrs['TEXT'] ) ) {
$name = $attrs['TEXT'];
@ -65,10 +65,10 @@ function startElement( $parser, $tagName, $attrs ) { // phpcs:ignore WordPress.N
* @since 0.71
* @access private
*
* @param resource $parser XML Parser resource.
* @param string $tagName XML tag name.
* @param resource $parser XML Parser resource.
* @param string $tag_name XML tag name.
*/
function endElement( $parser, $tagName ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
function endElement( $parser, $tag_name ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
// Nothing to do.
}

View File

@ -35,7 +35,7 @@ switch ( $action ) {
check_admin_referer( 'bulk-bookmarks' );
// For each link id (in $linkcheck[]) change category to selected value.
if ( count( $linkcheck ) == 0 ) {
if ( count( $linkcheck ) === 0 ) {
wp_redirect( $this_file );
exit;
}
@ -56,7 +56,7 @@ switch ( $action ) {
check_admin_referer( 'bulk-bookmarks' );
// For each link id (in $linkcheck[]) change category to selected value.
if ( count( $linkcheck ) == 0 ) {
if ( count( $linkcheck ) === 0 ) {
wp_redirect( $this_file );
exit;
}

View File

@ -37,7 +37,7 @@ if ( empty( $load ) ) {
exit;
}
$rtl = ( isset( $_GET['dir'] ) && 'rtl' == $_GET['dir'] );
$rtl = ( isset( $_GET['dir'] ) && 'rtl' === $_GET['dir'] );
$expires_offset = 31536000; // 1 year.
$out = '';

View File

@ -29,11 +29,11 @@ wp_enqueue_script( 'media-gallery' );
header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
// IDs should be integers.
$ID = isset( $ID ) ? (int) $ID : 0;
$ID = isset( $ID ) ? (int) $ID : 0; // phpcs:ignore WordPress.NamingConventions.ValidVariableName
$post_id = isset( $post_id ) ? (int) $post_id : 0;
// Require an ID for the edit screen.
if ( isset( $action ) && 'edit' == $action && ! $ID ) {
if ( isset( $action ) && 'edit' === $action && ! $ID ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName
wp_die(
'<h1>' . __( 'Something went wrong.' ) . '</h1>' .
'<p>' . __( 'Invalid item ID.' ) . '</p>',
@ -81,7 +81,7 @@ if ( isset( $_GET['tab'] ) ) {
$body_id = 'media-upload';
// Let the action code decide how to handle the request.
if ( 'type' == $tab || 'type_url' == $tab || ! array_key_exists( $tab, media_upload_tabs() ) ) {
if ( 'type' === $tab || 'type_url' === $tab || ! array_key_exists( $tab, media_upload_tabs() ) ) {
/**
* Fires inside specific upload-type views in the legacy (pre-3.5.0)
* media popup based on the current tab.

View File

@ -29,7 +29,7 @@ switch ( $action ) {
$location = 'media.php';
$referer = wp_get_original_referer();
if ( $referer ) {
if ( false !== strpos( $referer, 'upload.php' ) || ( url_to_postid( $referer ) == $attachment_id ) ) {
if ( false !== strpos( $referer, 'upload.php' ) || ( url_to_postid( $referer ) === $attachment_id ) ) {
$location = $referer;
}
}
@ -69,7 +69,7 @@ switch ( $action ) {
if ( 'attachment' !== $att->post_type ) {
wp_die( __( 'You attempted to edit an item that isn&#8217;t an attachment. Please go back and try again.' ) );
}
if ( 'trash' == $att->post_status ) {
if ( 'trash' === $att->post_status ) {
wp_die( __( 'You can&#8217;t edit this attachment because it is in the Trash. Please move it out of the Trash and try again.' ) );
}

View File

@ -88,7 +88,7 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
$submenu_items = $submenu[ $item[2] ];
}
if ( ( $parent_file && $item[2] == $parent_file ) || ( empty( $typenow ) && $self == $item[2] ) ) {
if ( ( $parent_file && $item[2] === $parent_file ) || ( empty( $typenow ) && $self === $item[2] ) ) {
if ( ! empty( $submenu_items ) ) {
$class[] = 'wp-has-current-submenu wp-menu-open';
} else {
@ -154,10 +154,16 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
$menu_hook = get_plugin_page_hook( $submenu_items[0][2], $item[2] );
$menu_file = $submenu_items[0][2];
$pos = strpos( $menu_file, '?' );
if ( false !== $pos ) {
$menu_file = substr( $menu_file, 0, $pos );
}
if ( ! empty( $menu_hook ) || ( ( 'index.php' != $submenu_items[0][2] ) && file_exists( WP_PLUGIN_DIR . "/$menu_file" ) && ! file_exists( ABSPATH . "/wp-admin/$menu_file" ) ) ) {
if ( ! empty( $menu_hook )
|| ( ( 'index.php' !== $submenu_items[0][2] )
&& file_exists( WP_PLUGIN_DIR . "/$menu_file" )
&& ! file_exists( ABSPATH . "/wp-admin/$menu_file" ) )
) {
$admin_is_parent = true;
echo "<a href='admin.php?page={$submenu_items[0][2]}'$class $aria_attributes>$arrow<div class='wp-menu-image$img_class'$img_style>$img</div><div class='wp-menu-name'>$title</div></a>";
} else {
@ -167,10 +173,16 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
$menu_hook = get_plugin_page_hook( $item[2], 'admin.php' );
$menu_file = $item[2];
$pos = strpos( $menu_file, '?' );
if ( false !== $pos ) {
$menu_file = substr( $menu_file, 0, $pos );
}
if ( ! empty( $menu_hook ) || ( ( 'index.php' != $item[2] ) && file_exists( WP_PLUGIN_DIR . "/$menu_file" ) && ! file_exists( ABSPATH . "/wp-admin/$menu_file" ) ) ) {
if ( ! empty( $menu_hook )
|| ( ( 'index.php' !== $item[2] )
&& file_exists( WP_PLUGIN_DIR . "/$menu_file" )
&& ! file_exists( ABSPATH . "/wp-admin/$menu_file" ) )
) {
$admin_is_parent = true;
echo "\n\t<a href='admin.php?page={$item[2]}'$class $aria_attributes>$arrow<div class='wp-menu-image$img_class'$img_style>$img</div><div class='wp-menu-name'>{$item[0]}</div></a>";
} else {
@ -192,14 +204,15 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
$class = array();
$aria_attributes = '';
if ( $first ) {
$class[] = 'wp-first-item';
$first = false;
}
$menu_file = $item[2];
$pos = strpos( $menu_file, '?' );
$pos = strpos( $menu_file, '?' );
if ( false !== $pos ) {
$menu_file = substr( $menu_file, 0, $pos );
}
@ -208,15 +221,16 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
$self_type = ! empty( $typenow ) ? $self . '?post_type=' . $typenow : 'nothing';
if ( isset( $submenu_file ) ) {
if ( $submenu_file == $sub_item[2] ) {
if ( $submenu_file === $sub_item[2] ) {
$class[] = 'current';
$aria_attributes .= ' aria-current="page"';
}
// If plugin_page is set the parent must either match the current page or not physically exist.
// This allows plugin pages with the same hook to exist under different parents.
} elseif (
( ! isset( $plugin_page ) && $self == $sub_item[2] ) ||
( isset( $plugin_page ) && $plugin_page == $sub_item[2] && ( $item[2] == $self_type || $item[2] == $self || file_exists( $menu_file ) === false ) )
( ! isset( $plugin_page ) && $self === $sub_item[2] )
|| ( isset( $plugin_page ) && $plugin_page === $sub_item[2]
&& ( $item[2] === $self_type || $item[2] === $self || file_exists( $menu_file ) === false ) )
) {
$class[] = 'current';
$aria_attributes .= ' aria-current="page"';
@ -237,7 +251,11 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
$title = wptexturize( $sub_item[0] );
if ( ! empty( $menu_hook ) || ( ( 'index.php' != $sub_item[2] ) && file_exists( WP_PLUGIN_DIR . "/$sub_file" ) && ! file_exists( ABSPATH . "/wp-admin/$sub_file" ) ) ) {
if ( ! empty( $menu_hook )
|| ( ( 'index.php' !== $sub_item[2] )
&& file_exists( WP_PLUGIN_DIR . "/$sub_file" )
&& ! file_exists( ABSPATH . "/wp-admin/$sub_file" ) )
) {
// If admin.php is the current page or if the parent exists as a file in the plugins or admin directory.
if ( ( ! $admin_is_parent && file_exists( WP_PLUGIN_DIR . "/$menu_file" ) && ! is_dir( WP_PLUGIN_DIR . "/{$item[2]}" ) ) || file_exists( $menu_file ) ) {
$sub_item_url = add_query_arg( array( 'page' => $sub_item[2] ), $item[2] );

View File

@ -17,7 +17,7 @@ if ( ! current_user_can( 'delete_site' ) ) {
wp_die( __( 'Sorry, you are not allowed to delete this site.' ) );
}
if ( isset( $_GET['h'] ) && '' != $_GET['h'] && false != get_option( 'delete_blog_hash' ) ) {
if ( isset( $_GET['h'] ) && '' !== $_GET['h'] && false !== get_option( 'delete_blog_hash' ) ) {
if ( hash_equals( get_option( 'delete_blog_hash' ), $_GET['h'] ) ) {
wpmu_delete_blog( get_current_blog_id() );
wp_die(
@ -42,7 +42,7 @@ require_once ABSPATH . 'wp-admin/admin-header.php';
echo '<div class="wrap">';
echo '<h1>' . esc_html( $title ) . '</h1>';
if ( isset( $_POST['action'] ) && 'deleteblog' == $_POST['action'] && isset( $_POST['confirmdelete'] ) && '1' == $_POST['confirmdelete'] ) {
if ( isset( $_POST['action'] ) && 'deleteblog' === $_POST['action'] && isset( $_POST['confirmdelete'] ) && '1' === $_POST['confirmdelete'] ) {
check_admin_referer( 'delete-blog' );
$hash = wp_generate_password( 20, false );

View File

@ -22,7 +22,7 @@ $action = isset( $_POST['action'] ) ? $_POST['action'] : 'splash';
$blogs = get_blogs_of_user( $current_user->ID );
$updated = false;
if ( 'updateblogsettings' == $action && isset( $_POST['primary_blog'] ) ) {
if ( 'updateblogsettings' === $action && isset( $_POST['primary_blog'] ) ) {
check_admin_referer( 'update-my-sites' );
$blog = get_site( (int) $_POST['primary_blog'] );
@ -107,10 +107,12 @@ else :
* @param string $context Context of the setting (global or site-specific). Default 'global'.
*/
$settings_html = apply_filters( 'myblogs_options', '', 'global' );
if ( '' != $settings_html ) {
if ( $settings_html ) {
echo '<h3>' . __( 'Global Settings' ) . '</h3>';
echo $settings_html;
}
reset( $blogs );
foreach ( $blogs as $user_blog ) {
@ -134,10 +136,12 @@ else :
* @param object $user_blog An object containing the site data.
*/
$actions = apply_filters( 'myblogs_blog_actions', $actions, $user_blog );
echo "<p class='my-sites-actions'>" . $actions . '</p>';
/** This filter is documented in wp-admin/my-sites.php */
echo apply_filters( 'myblogs_options', '', $user_blog );
echo '</li>';
restore_current_blog();

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.5-alpha-47784';
$wp_version = '5.5-alpha-47785';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.