Coding Standards: Use Yoda conditions where appropriate.

See #49222.
Built from https://develop.svn.wordpress.org/trunk@47219


git-svn-id: http://core.svn.wordpress.org/trunk@47019 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-02-09 16:55:09 +00:00
parent 5e6c949861
commit 641c632b0c
125 changed files with 555 additions and 555 deletions

View File

@ -288,6 +288,6 @@ if ( is_network_admin() ) {
*/
do_action( 'all_admin_notices' );
if ( $parent_file == 'options-general.php' ) {
if ( 'options-general.php' === $parent_file ) {
require ABSPATH . 'wp-admin/options-head.php';
}

View File

@ -101,7 +101,7 @@ switch ( $action ) {
}
// No need to re-approve/re-trash/re-spam a comment.
if ( $action == str_replace( '1', 'approve', $comment->comment_approved ) ) {
if ( str_replace( '1', 'approve', $comment->comment_approved ) == $action ) {
wp_redirect( admin_url( 'edit-comments.php?same=' . $comment_id ) );
die();
}
@ -137,7 +137,7 @@ switch ( $action ) {
break;
}
if ( $comment->comment_approved != '0' ) { // If not unapproved.
if ( '0' != $comment->comment_approved ) { // If not unapproved.
$message = '';
switch ( $comment->comment_approved ) {
case '1':

View File

@ -31,7 +31,7 @@ if ( $doaction ) {
$doaction = 'delete';
} elseif ( isset( $_REQUEST['delete_comments'] ) ) {
$comment_ids = $_REQUEST['delete_comments'];
$doaction = ( $_REQUEST['action'] != -1 ) ? $_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 ( $post_ID == get_option( 'page_for_posts' ) && empty( $post->post_content ) ) {
if ( 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' );
}
@ -534,7 +534,7 @@ do_action( 'edit_form_top', $post );
if ( has_filter( 'pre_get_shortlink' ) || has_filter( 'get_shortlink' ) ) {
$shortlink = wp_get_shortlink( $post->ID, 'post' );
if ( ! empty( $shortlink ) && $shortlink !== $permalink && $permalink !== home_url( '?page_id=' . $post->ID ) ) {
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>';
}
}

View File

@ -149,7 +149,7 @@ function wp_ajax_ajax_tag_search() {
* Require $term_search_min_chars chars for matching (default: 2)
* ensure it's a non-negative, non-zero integer.
*/
if ( ( $term_search_min_chars == 0 ) || ( strlen( $s ) < $term_search_min_chars ) ) {
if ( ( 0 == $term_search_min_chars ) || ( strlen( $s ) < $term_search_min_chars ) ) {
wp_die();
}
@ -295,14 +295,14 @@ function wp_ajax_autocomplete_user() {
$id = get_current_blog_id();
}
$include_blog_users = ( $type == 'search' ? get_users(
$include_blog_users = ( 'search' === $type ? get_users(
array(
'blog_id' => $id,
'fields' => 'ID',
)
) : array() );
$exclude_blog_users = ( $type == 'add' ? get_users(
$exclude_blog_users = ( 'add' === $type ? get_users(
array(
'blog_id' => $id,
'fields' => 'ID',
@ -391,7 +391,7 @@ function wp_ajax_dashboard_widgets() {
require_once ABSPATH . 'wp-admin/includes/dashboard.php';
$pagenow = $_GET['pagenow'];
if ( $pagenow === 'dashboard-user' || $pagenow === 'dashboard-network' || $pagenow === 'dashboard' ) {
if ( 'dashboard-user' === $pagenow || 'dashboard-network' === $pagenow || 'dashboard' === $pagenow ) {
set_current_screen( $pagenow );
}
@ -573,7 +573,7 @@ function _wp_ajax_add_hierarchical_term() {
$parent = 0;
}
if ( $taxonomy->name == 'category' ) {
if ( 'category' === $taxonomy->name ) {
$post_category = isset( $_POST['post_category'] ) ? (array) $_POST['post_category'] : array();
} else {
$post_category = ( isset( $_POST['tax_input'] ) && isset( $_POST['tax_input'][ $taxonomy->name ] ) ) ? (array) $_POST['tax_input'][ $taxonomy->name ] : array();
@ -717,7 +717,7 @@ function wp_ajax_delete_comment() {
$r = wp_untrash_comment( $comment );
// Undo trash, not in trash.
if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) {
if ( ! isset( $_POST['comment_status'] ) || 'trash' !== $_POST['comment_status'] ) {
$delta = 1;
}
} elseif ( isset( $_POST['spam'] ) && 1 == $_POST['spam'] ) {
@ -734,7 +734,7 @@ function wp_ajax_delete_comment() {
$r = wp_unspam_comment( $comment );
// Undo spam, not in spam.
if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) {
if ( ! isset( $_POST['comment_status'] ) || 'spam' !== $_POST['comment_status'] ) {
$delta = 1;
}
} elseif ( isset( $_POST['delete'] ) && 1 == $_POST['delete'] ) {
@ -1318,7 +1318,7 @@ function wp_ajax_replyto_comment( $action ) {
if ( ! empty( $_POST['approve_parent'] ) ) {
$parent = get_comment( $comment_parent );
if ( $parent && $parent->comment_approved === '0' && $parent->comment_post_ID == $comment_post_ID ) {
if ( $parent && '0' === $parent->comment_approved && $parent->comment_post_ID == $comment_post_ID ) {
if ( ! current_user_can( 'edit_comment', $parent->comment_ID ) ) {
wp_die( -1 );
}
@ -1549,7 +1549,7 @@ function wp_ajax_add_meta() {
}
// If the post is an autodraft, save the post as a draft and then attempt to save the meta.
if ( $post->post_status == 'auto-draft' ) {
if ( 'auto-draft' === $post->post_status ) {
$post_data = array();
$post_data['action'] = 'draft'; // Warning fix.
$post_data['post_ID'] = $pid;
@ -1720,7 +1720,7 @@ function wp_ajax_closed_postboxes() {
$page = isset( $_POST['page'] ) ? $_POST['page'] : '';
if ( $page != sanitize_key( $page ) ) {
if ( sanitize_key( $page ) != $page ) {
wp_die( 0 );
}
@ -1751,7 +1751,7 @@ function wp_ajax_hidden_columns() {
check_ajax_referer( 'screen-options-nonce', 'screenoptionnonce' );
$page = isset( $_POST['page'] ) ? $_POST['page'] : '';
if ( $page != sanitize_key( $page ) ) {
if ( sanitize_key( $page ) != $page ) {
wp_die( 0 );
}
@ -1900,13 +1900,13 @@ function wp_ajax_meta_box_order() {
$order = isset( $_POST['order'] ) ? (array) $_POST['order'] : false;
$page_columns = isset( $_POST['page_columns'] ) ? $_POST['page_columns'] : 'auto';
if ( $page_columns != 'auto' ) {
if ( 'auto' !== $page_columns ) {
$page_columns = (int) $page_columns;
}
$page = isset( $_POST['page'] ) ? $_POST['page'] : '';
if ( $page != sanitize_key( $page ) ) {
if ( sanitize_key( $page ) != $page ) {
wp_die( 0 );
}
@ -2003,7 +2003,7 @@ function wp_ajax_inline_save() {
/* translators: %s: User's display name. */
$msg_template = __( 'Saving is disabled: %s is currently editing this post.' );
if ( $_POST['post_type'] == 'page' ) {
if ( 'page' === $_POST['post_type'] ) {
/* translators: %s: User's display name. */
$msg_template = __( 'Saving is disabled: %s is currently editing this page.' );
}
@ -2067,7 +2067,7 @@ function wp_ajax_inline_save() {
$wp_list_table = _get_list_table( 'WP_Posts_List_Table', array( 'screen' => $_POST['screen'] ) );
$mode = $_POST['post_view'] === 'excerpt' ? 'excerpt' : 'list';
$mode = 'excerpt' === $_POST['post_view'] ? 'excerpt' : 'list';
$level = 0;
if ( is_post_type_hierarchical( $wp_list_table->screen->post_type ) ) {
@ -2639,7 +2639,7 @@ function wp_ajax_set_post_thumbnail() {
check_ajax_referer( "set_post_thumbnail-$post_ID" );
}
if ( $thumbnail_id == '-1' ) {
if ( '-1' == $thumbnail_id ) {
if ( delete_post_thumbnail( $post_ID ) ) {
$return = _wp_post_thumbnail_html( null, $post_ID );
$json ? wp_send_json_success( $return ) : wp_die( $return );
@ -2819,7 +2819,7 @@ function wp_ajax_wp_remove_post_lock() {
$active_lock = array_map( 'absint', explode( ':', $_POST['active_post_lock'] ) );
if ( $active_lock[1] != get_current_user_id() ) {
if ( get_current_user_id() != $active_lock[1] ) {
wp_die( 0 );
}
@ -2844,7 +2844,7 @@ function wp_ajax_wp_remove_post_lock() {
function wp_ajax_dismiss_wp_pointer() {
$pointer = $_POST['pointer'];
if ( $pointer != sanitize_key( $pointer ) ) {
if ( sanitize_key( $pointer ) != $pointer ) {
wp_die( 0 );
}
@ -3022,7 +3022,7 @@ function wp_ajax_save_attachment() {
if ( isset( $changes['alt'] ) ) {
$alt = wp_unslash( $changes['alt'] );
if ( $alt != get_post_meta( $id, '_wp_attachment_image_alt', true ) ) {
if ( get_post_meta( $id, '_wp_attachment_image_alt', true ) !== $alt ) {
$alt = wp_strip_all_tags( $alt, true );
update_post_meta( $id, '_wp_attachment_image_alt', wp_slash( $alt ) );
}
@ -3816,7 +3816,7 @@ function wp_ajax_destroy_sessions() {
$sessions = WP_Session_Tokens::get_instance( $user->ID );
if ( $user->ID === get_current_user_id() ) {
if ( get_current_user_id() === $user->ID ) {
$sessions->destroy_others( wp_get_session_token() );
$message = __( 'You are now logged out everywhere else.' );
} else {

View File

@ -78,7 +78,7 @@ class Core_Upgrader extends WP_Upgrader {
$this->upgrade_strings();
// Is an update available?
if ( ! isset( $current->response ) || $current->response == 'latest' ) {
if ( ! isset( $current->response ) || 'latest' === $current->response ) {
return new WP_Error( 'up_to_date', $this->strings['up_to_date'] );
}

View File

@ -812,7 +812,7 @@ endif;
// If flexible height isn't supported and the image is the exact right size.
if ( ! current_theme_supports( 'custom-header', 'flex-height' ) && ! current_theme_supports( 'custom-header', 'flex-width' )
&& $width == get_theme_support( 'custom-header', 'width' ) && $height == get_theme_support( 'custom-header', 'height' ) ) {
&& get_theme_support( 'custom-header', 'width' ) == $width && get_theme_support( 'custom-header', 'height' ) == $height ) {
// Add the metadata.
if ( file_exists( $file ) ) {
wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) );

View File

@ -89,19 +89,19 @@ class Plugin_Installer_Skin extends WP_Upgrader_Skin {
unset( $install_actions['activate_plugin'] );
}
if ( 'import' == $from ) {
if ( 'import' === $from ) {
$install_actions['importers_page'] = sprintf(
'<a href="%s" target="_parent">%s</a>',
admin_url( 'import.php' ),
__( 'Return to Importers' )
);
} elseif ( $this->type == 'web' ) {
} elseif ( 'web' === $this->type ) {
$install_actions['plugins_page'] = sprintf(
'<a href="%s" target="_parent">%s</a>',
self_admin_url( 'plugin-install.php' ),
__( 'Return to Plugin Installer' )
);
} elseif ( 'upload' == $this->type && 'plugins' == $from ) {
} elseif ( 'upload' === $this->type && 'plugins' === $from ) {
$install_actions['plugins_page'] = sprintf(
'<a href="%s">%s</a>',
self_admin_url( 'plugin-install.php' ),

View File

@ -114,7 +114,7 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin {
);
}
if ( $this->type == 'web' ) {
if ( 'web' === $this->type ) {
$install_actions['themes_page'] = sprintf(
'<a href="%s" target="_parent">%s</a>',
self_admin_url( 'theme-install.php' ),

View File

@ -367,7 +367,7 @@ class Theme_Upgrader extends WP_Upgrader {
*/
$maintenance = ( is_multisite() && ! empty( $themes ) );
foreach ( $themes as $theme ) {
$maintenance = $maintenance || $theme == get_stylesheet() || $theme == get_template();
$maintenance = $maintenance || get_stylesheet() === $theme || get_template() === $theme;
}
if ( $maintenance ) {
$this->maintenance_mode( true );
@ -539,7 +539,7 @@ class Theme_Upgrader extends WP_Upgrader {
$theme = isset( $theme['theme'] ) ? $theme['theme'] : '';
if ( $theme != get_stylesheet() ) { // If not current.
if ( get_stylesheet() !== $theme ) { // If not current.
return $return;
}
@ -570,12 +570,12 @@ class Theme_Upgrader extends WP_Upgrader {
$theme = isset( $theme['theme'] ) ? $theme['theme'] : '';
if ( $theme != get_stylesheet() ) { // If not current.
if ( get_stylesheet() !== $theme ) { // If not current.
return $return;
}
// Ensure stylesheet name hasn't changed after the upgrade:
if ( $theme == get_stylesheet() && $theme != $this->result['destination_name'] ) {
if ( get_stylesheet() === $theme && $theme != $this->result['destination_name'] ) {
wp_clean_themes_cache();
$stylesheet = $this->result['destination_name'];
switch_theme( $stylesheet );

View File

@ -75,7 +75,7 @@ class Walker_Category_Checklist extends Walker {
$taxonomy = $args['taxonomy'];
}
if ( $taxonomy == 'category' ) {
if ( 'category' === $taxonomy ) {
$name = 'post_category';
} else {
$name = 'tax_input[' . $taxonomy . ']';

View File

@ -73,7 +73,7 @@ class WP_Automatic_Updater {
*/
public function is_vcs_checkout( $context ) {
$context_dirs = array( untrailingslashit( $context ) );
if ( $context !== ABSPATH ) {
if ( ABSPATH !== $context ) {
$context_dirs[] = untrailingslashit( ABSPATH );
}
@ -86,7 +86,7 @@ class WP_Automatic_Updater {
$check_dirs[] = $context_dir;
// Once we've hit '/' or 'C:\', we need to stop. dirname will keep returning the input here.
if ( $context_dir == dirname( $context_dir ) ) {
if ( dirname( $context_dir ) === $context_dir ) {
break;
}
@ -227,7 +227,7 @@ class WP_Automatic_Updater {
$notified = get_site_option( 'auto_core_update_notified' );
// Don't notify if we've already notified the same email address of the same version.
if ( $notified && $notified['email'] == get_site_option( 'admin_email' ) && $notified['version'] == $item->current ) {
if ( $notified && get_site_option( 'admin_email' ) === $notified['email'] && $notified['version'] == $item->current ) {
return false;
}
@ -536,9 +536,9 @@ class WP_Automatic_Updater {
// Any of these WP_Error codes are critical failures, as in they occurred after we started to copy core files.
// We should not try to perform a background update again until there is a successful one-click update performed by the user.
$critical = false;
if ( $error_code === 'disk_full' || false !== strpos( $error_code, '__copy_dir' ) ) {
if ( 'disk_full' === $error_code || false !== strpos( $error_code, '__copy_dir' ) ) {
$critical = true;
} elseif ( $error_code === 'rollback_was_required' && is_wp_error( $result->get_error_data()->rollback ) ) {
} elseif ( 'rollback_was_required' === $error_code && is_wp_error( $result->get_error_data()->rollback ) ) {
// A rollback is only critical if it failed too.
$critical = true;
$rollback_result = $result->get_error_data()->rollback;
@ -584,7 +584,7 @@ class WP_Automatic_Updater {
$n = get_site_option( 'auto_core_update_notified' );
// Don't notify if we've already notified the same email address of the same version of the same notification type.
if ( $n && 'fail' == $n['type'] && $n['email'] == get_site_option( 'admin_email' ) && $n['version'] == $core_update->current ) {
if ( $n && 'fail' === $n['type'] && get_site_option( 'admin_email' ) === $n['email'] && $n['version'] == $core_update->current ) {
$send = false;
}
@ -762,7 +762,7 @@ class WP_Automatic_Updater {
}
// Updates are important!
if ( $type != 'success' || $newer_version_available ) {
if ( 'success' !== $type || $newer_version_available ) {
$body .= "\n\n" . __( 'Keeping your site updated is important for security. It also makes the internet a safer place for you and your readers.' );
}
@ -771,7 +771,7 @@ class WP_Automatic_Updater {
}
// If things are successful and we're now on the latest, mention plugins and themes if any are out of date.
if ( $type == 'success' && ! $newer_version_available && ( get_plugin_updates() || get_theme_updates() ) ) {
if ( 'success' === $type && ! $newer_version_available && ( get_plugin_updates() || get_theme_updates() ) ) {
$body .= "\n\n" . __( 'You also have some plugins or themes with updates available. Update them now:' );
$body .= "\n" . network_admin_url();
}

View File

@ -749,7 +749,7 @@ class WP_Comments_List_Table extends WP_List_Table {
// Reply and quickedit need a hide-if-no-js span when not added with ajax.
if ( ( 'reply' === $action || 'quickedit' === $action ) && ! wp_doing_ajax() ) {
$action .= ' hide-if-no-js';
} elseif ( ( $action === 'untrash' && $the_comment_status === 'trash' ) || ( $action === 'unspam' && $the_comment_status === 'spam' ) ) {
} elseif ( ( 'untrash' === $action && 'trash' === $the_comment_status ) || ( 'unspam' === $action && 'spam' === $the_comment_status ) ) {
if ( '1' == get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ) ) {
$action .= ' approve';
} else {

View File

@ -471,10 +471,10 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
* @return bool True on success, false on failure.
*/
public function touch( $file, $time = 0, $atime = 0 ) {
if ( $time == 0 ) {
if ( 0 == $time ) {
$time = time();
}
if ( $atime == 0 ) {
if ( 0 == $atime ) {
$atime = time();
}
return touch( $file, $time, $atime );

View File

@ -574,7 +574,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
} else {
$lucifer[3] += 1900; // 4-digit year fix.
}
$b['isdir'] = ( $lucifer[7] == '<DIR>' );
$b['isdir'] = ( '<DIR>' === $lucifer[7] );
if ( $b['isdir'] ) {
$b['type'] = 'd';
} else {
@ -598,8 +598,8 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
return '';
}
$b = array();
$b['isdir'] = $lucifer[0][0] === 'd';
$b['islink'] = $lucifer[0][0] === 'l';
$b['isdir'] = 'd' === $lucifer[0][0];
$b['islink'] = 'l' === $lucifer[0][0];
if ( $b['isdir'] ) {
$b['type'] = 'd';
} elseif ( $b['islink'] ) {
@ -613,7 +613,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
$b['owner'] = $lucifer[2];
$b['group'] = $lucifer[3];
$b['size'] = $lucifer[4];
if ( $lcount == 8 ) {
if ( 8 == $lcount ) {
sscanf( $lucifer[5], '%d-%d-%d', $b['year'], $b['month'], $b['day'] );
sscanf( $lucifer[6], '%d:%d', $b['hour'], $b['minute'] );
$b['time'] = mktime( $b['hour'], $b['minute'], 0, $b['month'], $b['day'], $b['year'] );

View File

@ -202,7 +202,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
mbstring_binary_safe_encoding();
$bytes_written = fwrite( $temphandle, $contents );
if ( false === $bytes_written || $bytes_written != strlen( $contents ) ) {
if ( false === $bytes_written || strlen( $contents ) != $bytes_written ) {
fclose( $temphandle );
unlink( $temp );

View File

@ -238,7 +238,7 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
fclose( $stream );
if ( $returnbool ) {
return ( $data === false ) ? false : '' != trim( $data );
return ( false === $data ) ? false : '' != trim( $data );
} else {
return $data;
}
@ -285,7 +285,7 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
public function put_contents( $file, $contents, $mode = false ) {
$ret = file_put_contents( $this->sftp_path( $file ), $contents );
if ( $ret !== strlen( $contents ) ) {
if ( strlen( $contents ) !== $ret ) {
return false;
}

View File

@ -312,7 +312,7 @@ function get_cli_args( $param, $required = false ) {
}
$last_arg = $key;
} elseif ( $last_arg !== null ) {
} elseif ( null !== $last_arg ) {
$out[ $last_arg ] = $args[ $i ];
}
}

View File

@ -830,18 +830,18 @@ class WP_List_Table {
$disable_prev = false;
$disable_next = false;
if ( $current == 1 ) {
if ( 1 == $current ) {
$disable_first = true;
$disable_prev = true;
}
if ( $current == 2 ) {
if ( 2 == $current ) {
$disable_first = true;
}
if ( $current == $total_pages ) {
if ( $total_pages == $current ) {
$disable_last = true;
$disable_next = true;
}
if ( $current == $total_pages - 1 ) {
if ( $total_pages - 1 == $current ) {
$disable_last = true;
}

View File

@ -626,8 +626,8 @@ class WP_Media_List_Table extends WP_List_Table {
while ( have_posts() ) :
the_post();
if (
( $this->is_trash && $post->post_status != 'trash' )
|| ( ! $this->is_trash && $post->post_status === 'trash' )
( $this->is_trash && 'trash' !== $post->post_status )
|| ( ! $this->is_trash && 'trash' === $post->post_status )
) {
continue;
}

View File

@ -70,7 +70,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
global $s, $mode, $wpdb;
if ( ! empty( $_REQUEST['mode'] ) ) {
$mode = $_REQUEST['mode'] === 'excerpt' ? 'excerpt' : 'list';
$mode = 'excerpt' === $_REQUEST['mode'] ? 'excerpt' : 'list';
set_user_setting( 'sites_list_mode', $mode );
} else {
$mode = get_user_setting( 'sites_list_mode', 'list' );
@ -263,7 +263,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
$url = 'sites.php';
foreach ( $statuses as $status => $label_count ) {
$current_link_attributes = $requested_status === $status || ( $requested_status === '' && 'all' === $status )
$current_link_attributes = $requested_status === $status || ( '' === $requested_status && 'all' === $status )
? ' class="current" aria-current="page"'
: '';
if ( (int) $counts[ $status ] > 0 ) {
@ -476,7 +476,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
$date = __( 'Y/m/d g:i:s a' );
}
echo ( $blog['last_updated'] === '0000-00-00 00:00:00' ) ? __( 'Never' ) : mysql2date( $date, $blog['last_updated'] );
echo ( '0000-00-00 00:00:00' === $blog['last_updated'] ) ? __( 'Never' ) : mysql2date( $date, $blog['last_updated'] );
}
/**
@ -497,7 +497,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
$date = __( 'Y/m/d g:i:s a' );
}
if ( $blog['registered'] === '0000-00-00 00:00:00' ) {
if ( '0000-00-00 00:00:00' === $blog['registered'] ) {
echo '&#x2014;';
} else {
echo mysql2date( $date, $blog['registered'] );
@ -585,7 +585,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
reset( $this->status_list );
foreach ( $this->status_list as $status => $col ) {
if ( $blog[ $status ] == 1 ) {
if ( 1 == $blog[ $status ] ) {
$class = " class='{$col[0]}'";
}
}
@ -693,19 +693,19 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
$actions['edit'] = '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a>';
$actions['backend'] = "<a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a>';
if ( get_network()->site_id != $blog['blog_id'] ) {
if ( $blog['deleted'] == '1' ) {
if ( '1' == $blog['deleted'] ) {
$actions['activate'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=activateblog&amp;id=' . $blog['blog_id'] ), 'activateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Activate' ) . '</a>';
} else {
$actions['deactivate'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=deactivateblog&amp;id=' . $blog['blog_id'] ), 'deactivateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Deactivate' ) . '</a>';
}
if ( $blog['archived'] == '1' ) {
if ( '1' == $blog['archived'] ) {
$actions['unarchive'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=unarchiveblog&amp;id=' . $blog['blog_id'] ), 'unarchiveblog_' . $blog['blog_id'] ) ) . '">' . __( 'Unarchive' ) . '</a>';
} else {
$actions['archive'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=archiveblog&amp;id=' . $blog['blog_id'] ), 'archiveblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Archive', 'verb; site' ) . '</a>';
}
if ( $blog['spam'] == '1' ) {
if ( '1' == $blog['spam'] ) {
$actions['unspam'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=unspamblog&amp;id=' . $blog['blog_id'] ), 'unspamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Not Spam', 'site' ) . '</a>';
} else {
$actions['spam'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=spamblog&amp;id=' . $blog['blog_id'] ), 'spamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Spam', 'site' ) . '</a>';

View File

@ -166,7 +166,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
$orderby = ucfirst( $orderby );
$order = strtoupper( $order );
if ( $orderby === 'Name' ) {
if ( 'Name' === $orderby ) {
if ( 'ASC' === $order ) {
$this->items = array_reverse( $this->items );
}
@ -502,7 +502,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
);
}
if ( ! $allowed && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && $stylesheet != get_option( 'stylesheet' ) && $stylesheet != get_option( 'template' ) ) {
if ( ! $allowed && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && get_option( 'stylesheet' ) !== $stylesheet && get_option( 'template' ) !== $stylesheet ) {
$url = add_query_arg(
array(
'action' => 'delete-selected',
@ -580,7 +580,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
public function column_description( $theme ) {
global $status, $totals;
if ( $theme->errors() ) {
$pre = $status === 'broken' ? __( 'Broken Theme:' ) . ' ' : '';
$pre = 'broken' === $status ? __( 'Broken Theme:' ) . ' ' : '';
echo '<p><strong class="error-message">' . $pre . $theme->errors()->get_error_message() . '</strong></p>';
}

View File

@ -54,7 +54,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
$args['search'] = '*' . $args['search'] . '*';
}
if ( $role === 'super' ) {
if ( 'super' === $role ) {
$args['login__in'] = get_super_admins();
}
@ -84,7 +84,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
}
if ( ! empty( $_REQUEST['mode'] ) ) {
$mode = $_REQUEST['mode'] === 'excerpt' ? 'excerpt' : 'list';
$mode = 'excerpt' === $_REQUEST['mode'] ? 'excerpt' : 'list';
set_user_setting( 'network_users_list_mode', $mode );
} else {
$mode = get_user_setting( 'network_users_list_mode', 'list' );
@ -137,7 +137,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
$super_admins = get_super_admins();
$total_admins = count( $super_admins );
$current_link_attributes = $role !== 'super' ? ' class="current" aria-current="page"' : '';
$current_link_attributes = 'super' !== $role ? ' class="current" aria-current="page"' : '';
$role_links = array();
$role_links['all'] = sprintf(
'<a href="%s"%s>%s</a>',
@ -154,7 +154,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
number_format_i18n( $total_users )
)
);
$current_link_attributes = $role === 'super' ? ' class="current" aria-current="page"' : '';
$current_link_attributes = 'super' === $role ? ' class="current" aria-current="page"' : '';
$role_links['super'] = sprintf(
'<a href="%s"%s>%s</a>',
network_admin_url( 'users.php?role=super' ),
@ -371,7 +371,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
continue;
}
$path = ( $val->path === '/' ) ? '' : $val->path;
$path = ( '/' === $val->path ) ? '' : $val->path;
$site_classes = array( 'site-' . $val->site_id );
/**
* Filters the span class for a site listing on the mulisite user list table.
@ -396,16 +396,16 @@ class WP_MS_Users_List_Table extends WP_List_Table {
$actions['edit'] = '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) . '">' . __( 'Edit' ) . '</a>';
$class = '';
if ( $val->spam == 1 ) {
if ( 1 == $val->spam ) {
$class .= 'site-spammed ';
}
if ( $val->mature == 1 ) {
if ( 1 == $val->mature ) {
$class .= 'site-mature ';
}
if ( $val->deleted == 1 ) {
if ( 1 == $val->deleted ) {
$class .= 'site-deleted ';
}
if ( $val->archived == 1 ) {
if ( 1 == $val->archived ) {
$class .= 'site-archived ';
}

View File

@ -101,7 +101,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
if ( 'search' === $tab ) {
$tabs['search'] = __( 'Search Results' );
}
if ( $tab === 'beta' || false !== strpos( get_bloginfo( 'version' ), '-' ) ) {
if ( 'beta' === $tab || false !== strpos( get_bloginfo( 'version' ), '-' ) ) {
$tabs['beta'] = _x( 'Beta Testing', 'Plugin Installer' );
}
$tabs['featured'] = _x( 'Featured', 'Plugin Installer' );
@ -369,7 +369,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
* @param string $which
*/
protected function display_tablenav( $which ) {
if ( $GLOBALS['tab'] === 'featured' ) {
if ( 'featured' === $GLOBALS['tab'] ) {
return;
}

View File

@ -165,7 +165,7 @@ class WP_Posts_List_Table extends WP_List_Table {
$total_items = $post_counts[ $_REQUEST['post_status'] ];
} elseif ( isset( $_REQUEST['show_sticky'] ) && $_REQUEST['show_sticky'] ) {
$total_items = $this->sticky_posts_count;
} elseif ( isset( $_GET['author'] ) && $_GET['author'] == get_current_user_id() ) {
} elseif ( isset( $_GET['author'] ) && get_current_user_id() == $_GET['author'] ) {
$total_items = $this->user_posts_count;
} else {
$total_items = array_sum( $post_counts );
@ -178,13 +178,13 @@ class WP_Posts_List_Table extends WP_List_Table {
}
if ( ! empty( $_REQUEST['mode'] ) ) {
$mode = $_REQUEST['mode'] === 'excerpt' ? 'excerpt' : 'list';
$mode = 'excerpt' === $_REQUEST['mode'] ? 'excerpt' : 'list';
set_user_setting( 'posts_list_mode', $mode );
} else {
$mode = get_user_setting( 'posts_list_mode', 'list' );
}
$this->is_trash = isset( $_REQUEST['post_status'] ) && $_REQUEST['post_status'] === 'trash';
$this->is_trash = isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'];
$this->set_pagination_args(
array(
@ -993,7 +993,7 @@ class WP_Posts_List_Table extends WP_List_Table {
$can_edit_post = current_user_can( 'edit_post', $post->ID );
if ( $can_edit_post && $post->post_status != 'trash' ) {
if ( $can_edit_post && 'trash' !== $post->post_status ) {
$lock_holder = wp_check_post_lock( $post->ID );
if ( $lock_holder ) {
@ -1014,7 +1014,7 @@ class WP_Posts_List_Table extends WP_List_Table {
$title = _draft_or_post_title();
if ( $can_edit_post && $post->post_status != 'trash' ) {
if ( $can_edit_post && 'trash' !== $post->post_status ) {
printf(
'<a class="row-title" href="%s" aria-label="%s">%s%s</a>',
get_edit_post_link( $post->ID ),
@ -1633,7 +1633,7 @@ class WP_Posts_List_Table extends WP_List_Table {
<?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?>
<span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ); ?></span>
<input type="hidden" name="<?php echo ( $taxonomy->name === 'category' ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" />
<input type="hidden" name="<?php echo ( 'category' === $taxonomy->name ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" />
<ul class="cat-checklist <?php echo esc_attr( $taxonomy->name ); ?>-checklist">
<?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ); ?>
</ul>

View File

@ -373,7 +373,7 @@ final class WP_Screen {
if ( isset( self::$_registry[ $id ] ) ) {
$screen = self::$_registry[ $id ];
if ( $screen === get_current_screen() ) {
if ( get_current_screen() === $screen ) {
return $screen;
}
} else {
@ -454,7 +454,7 @@ final class WP_Screen {
* @return bool True if the block editor is being loaded, false otherwise.
*/
public function is_block_editor( $set = null ) {
if ( $set !== null ) {
if ( null !== $set ) {
$this->is_block_editor = (bool) $set;
}

View File

@ -509,7 +509,7 @@ function wp_dashboard_quick_press( $error_msg = false ) {
$last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID.
if ( $last_post_id ) {
$post = get_post( $last_post_id );
if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore.
if ( empty( $post ) || 'auto-draft' !== $post->post_status ) { // auto-draft doesn't exist anymore.
$post = get_default_post_to_edit( 'post', true );
update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID.
} else {

View File

@ -168,7 +168,7 @@ function export_wp( $args = array() ) {
// Put categories in order with no child going before its parent.
while ( $cat = array_shift( $categories ) ) {
if ( $cat->parent == 0 || isset( $cats[ $cat->parent ] ) ) {
if ( 0 == $cat->parent || isset( $cats[ $cat->parent ] ) ) {
$cats[ $cat->term_id ] = $cat;
} else {
$categories[] = $cat;
@ -177,7 +177,7 @@ function export_wp( $args = array() ) {
// Put terms in order with no child going before its parent.
while ( $t = array_shift( $custom_terms ) ) {
if ( $t->parent == 0 || isset( $terms[ $t->parent ] ) ) {
if ( 0 == $t->parent || isset( $terms[ $t->parent ] ) ) {
$terms[ $t->term_id ] = $t;
} else {
$custom_terms[] = $t;
@ -585,7 +585,7 @@ function export_wp( $args = array() ) {
<wp:post_type><?php echo wxr_cdata( $post->post_type ); ?></wp:post_type>
<wp:post_password><?php echo wxr_cdata( $post->post_password ); ?></wp:post_password>
<wp:is_sticky><?php echo intval( $is_sticky ); ?></wp:is_sticky>
<?php if ( $post->post_type == 'attachment' ) : ?>
<?php if ( 'attachment' === $post->post_type ) : ?>
<wp:attachment_url><?php echo wxr_cdata( wp_get_attachment_url( $post->ID ) ); ?></wp:attachment_url>
<?php endif; ?>
<?php wxr_post_taxonomy(); ?>

View File

@ -1886,7 +1886,7 @@ function get_filesystem_method( $args = array(), $context = '', $allow_relaxed_f
$temp_file_owner = @fileowner( $temp_file_name );
}
if ( $wp_file_owner !== false && $wp_file_owner === $temp_file_owner ) {
if ( false !== $wp_file_owner && $wp_file_owner === $temp_file_owner ) {
/*
* WordPress is creating files as the same owner as the WordPress files,
* this means it's safe to modify & create new files via PHP.
@ -2234,7 +2234,7 @@ function wp_print_request_filesystem_credentials_modal() {
ob_start();
$filesystem_credentials_are_stored = request_filesystem_credentials( self_admin_url() );
ob_end_clean();
$request_filesystem_credentials = ( $filesystem_method != 'direct' && ! $filesystem_credentials_are_stored );
$request_filesystem_credentials = ( 'direct' !== $filesystem_method && ! $filesystem_credentials_are_stored );
if ( ! $request_filesystem_credentials ) {
return;
}

View File

@ -33,7 +33,7 @@ function wp_image_editor( $post_id, $msg = false ) {
$backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
$can_restore = false;
if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) ) {
$can_restore = $backup_sizes['full-orig']['file'] != wp_basename( $meta['file'] );
$can_restore = wp_basename( $meta['file'] ) !== $backup_sizes['full-orig']['file'];
}
if ( $msg ) {
@ -576,7 +576,7 @@ function image_edit_apply_changes( $image, $changes ) {
foreach ( $changes as $operation ) {
switch ( $operation->type ) {
case 'rotate':
if ( $operation->angle != 0 ) {
if ( 0 != $operation->angle ) {
if ( $image instanceof WP_Image_Editor ) {
$image->rotate( $operation->angle );
} else {
@ -585,7 +585,7 @@ function image_edit_apply_changes( $image, $changes ) {
}
break;
case 'flip':
if ( $operation->axis != 0 ) {
if ( 0 != $operation->axis ) {
if ( $image instanceof WP_Image_Editor ) {
$image->flip( ( $operation->axis & 1 ) != 0, ( $operation->axis & 2 ) != 0 );
} else {
@ -954,7 +954,7 @@ function wp_save_image( $post_id ) {
wp_update_attachment_metadata( $post_id, $meta );
update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes );
if ( $target == 'thumbnail' || $target == 'all' || $target == 'full' ) {
if ( 'thumbnail' === $target || 'all' === $target || 'full' === $target ) {
// Check if it's an image edit from attachment edit screen.
if ( ! empty( $_REQUEST['context'] ) && 'edit-attachment' == $_REQUEST['context'] ) {
$thumb_url = wp_get_attachment_image_src( $post_id, array( 900, 600 ), true );

View File

@ -247,7 +247,7 @@ function wp_create_image_subsizes( $file, $attachment_id ) {
}
// Do not scale (large) PNG images. May result in sub-sizes that have greater file size than the original. See #48736.
if ( $imagesize['mime'] !== 'image/png' ) {
if ( 'image/png' !== $imagesize['mime'] ) {
/**
* Filters the "BIG image" threshold value.
@ -310,7 +310,7 @@ function wp_create_image_subsizes( $file, $attachment_id ) {
} else {
// TODO: Log errors.
}
} elseif ( ! empty( $exif_meta['orientation'] ) && (int) $exif_meta['orientation'] !== 1 ) {
} elseif ( ! empty( $exif_meta['orientation'] ) && 1 !== (int) $exif_meta['orientation'] ) {
// Rotate the whole original image if there is EXIF data and "orientation" is not 1.
$editor = wp_get_image_editor( $file );

View File

@ -176,7 +176,7 @@ function wp_get_popular_importers() {
foreach ( $popular_importers['importers'] as &$importer ) {
// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
$importer['description'] = translate( $importer['description'] );
if ( $importer['name'] != 'WordPress' ) {
if ( 'WordPress' !== $importer['name'] ) {
// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
$importer['name'] = translate( $importer['name'] );
}

View File

@ -635,7 +635,7 @@ function media_buttons( $editor_id = 'content' ) {
$img = '<span class="wp-media-buttons-icon"></span> ';
$id_attribute = $instance === 1 ? ' id="insert-media-button"' : '';
$id_attribute = 1 === $instance ? ' id="insert-media-button"' : '';
printf(
'<button type="button"%s class="button insert-media add_media" data-editor="%s">%s</button>',
@ -767,7 +767,7 @@ function media_upload_form_handler() {
if ( isset( $attachment['image_alt'] ) ) {
$image_alt = wp_unslash( $attachment['image_alt'] );
if ( $image_alt != get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) ) {
if ( get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) !== $image_alt ) {
$image_alt = wp_strip_all_tags( $image_alt, true );
// update_post_meta() expects slashed.
@ -947,7 +947,7 @@ function wp_media_upload_handler() {
}
}
if ( isset( $_GET['tab'] ) && $_GET['tab'] == 'type_url' ) {
if ( isset( $_GET['tab'] ) && 'type_url' === $_GET['tab'] ) {
$type = 'image';
if ( isset( $_GET['type'] ) && in_array( $_GET['type'], array( 'video', 'audio', 'file' ) ) ) {
@ -1003,7 +1003,7 @@ function media_sideload_image( $file, $post_id = 0, $desc = null, $return = 'htm
@unlink( $file_array['tmp_name'] );
return $id;
// If attachment id was requested, return it early.
} elseif ( $return === 'id' ) {
} elseif ( 'id' === $return ) {
return $id;
}
@ -1012,7 +1012,7 @@ function media_sideload_image( $file, $post_id = 0, $desc = null, $return = 'htm
// Finally, check to make sure the file has been saved, then return the HTML.
if ( ! empty( $src ) ) {
if ( $return === 'src' ) {
if ( 'src' === $return ) {
return $src;
}
@ -1211,9 +1211,9 @@ function image_link_input_fields( $post, $url_type = '' ) {
$url = '';
if ( $url_type == 'file' ) {
if ( 'file' === $url_type ) {
$url = $file;
} elseif ( $url_type == 'post' ) {
} elseif ( 'post' === $url_type ) {
$url = $link;
}
@ -1324,7 +1324,7 @@ function image_media_send_to_editor( $html, $attachment_id, $attachment ) {
$align = ! empty( $attachment['align'] ) ? $attachment['align'] : 'none';
$size = ! empty( $attachment['image-size'] ) ? $attachment['image-size'] : 'medium';
$alt = ! empty( $attachment['image_alt'] ) ? $attachment['image_alt'] : '';
$rel = ( strpos( $url, 'attachment_id' ) || $url === get_attachment_link( $attachment_id ) );
$rel = ( strpos( $url, 'attachment_id' ) || get_attachment_link( $attachment_id ) === $url );
return get_image_send_to_editor( $attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size, $alt );
}
@ -1491,7 +1491,7 @@ function get_media_items( $post_id, $errors ) {
if ( $post_id ) {
$post = get_post( $post_id );
if ( $post && $post->post_type == 'attachment' ) {
if ( $post && 'attachment' === $post->post_type ) {
$attachments = array( $post->ID => $post );
} else {
$attachments = get_children(
@ -1513,7 +1513,7 @@ function get_media_items( $post_id, $errors ) {
$output = '';
foreach ( (array) $attachments as $id => $attachment ) {
if ( $attachment->post_status == 'trash' ) {
if ( 'trash' === $attachment->post_status ) {
continue;
}
@ -1735,7 +1735,7 @@ function get_media_item( $attachment_id, $args = null ) {
$hidden_fields = array();
foreach ( $form_fields as $id => $field ) {
if ( $id[0] == '_' ) {
if ( '_' === $id[0] ) {
continue;
}
@ -1747,7 +1747,7 @@ function get_media_item( $attachment_id, $args = null ) {
$field = array_merge( $defaults, $field );
$name = "attachments[$attachment_id][$id]";
if ( $field['input'] == 'hidden' ) {
if ( 'hidden' === $field['input'] ) {
$hidden_fields[ $name ] = $field['value'];
continue;
}
@ -1761,7 +1761,7 @@ function get_media_item( $attachment_id, $args = null ) {
if ( ! empty( $field[ $field['input'] ] ) ) {
$item .= $field[ $field['input'] ];
} elseif ( $field['input'] == 'textarea' ) {
} elseif ( 'textarea' === $field['input'] ) {
if ( 'post_content' == $id && user_can_richedit() ) {
// Sanitize_post() skips the post_content when user_can_richedit.
$field['value'] = htmlspecialchars( $field['value'], ENT_QUOTES );
@ -1919,7 +1919,7 @@ function get_compat_media_markup( $attachment_id, $args = null ) {
$item = '';
foreach ( $form_fields as $id => $field ) {
if ( $id[0] == '_' ) {
if ( '_' === $id[0] ) {
continue;
}
@ -1937,7 +1937,7 @@ function get_compat_media_markup( $attachment_id, $args = null ) {
continue;
}
if ( $field['input'] == 'hidden' ) {
if ( 'hidden' === $field['input'] ) {
$hidden_fields[ $name ] = $field['value'];
continue;
}
@ -1954,7 +1954,7 @@ function get_compat_media_markup( $attachment_id, $args = null ) {
if ( ! empty( $field[ $field['input'] ] ) ) {
$item .= $field[ $field['input'] ];
} elseif ( $field['input'] == 'textarea' ) {
} elseif ( 'textarea' === $field['input'] ) {
if ( 'post_content' == $id && user_can_richedit() ) {
// sanitize_post() skips the post_content when user_can_richedit.
$field['value'] = htmlspecialchars( $field['value'], ENT_QUOTES );
@ -2716,7 +2716,7 @@ function media_upload_library_form( $errors ) {
$_GET['post_mime_type'] = $type;
list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
}
if ( empty( $_GET['post_mime_type'] ) || $_GET['post_mime_type'] == 'all' ) {
if ( empty( $_GET['post_mime_type'] ) || 'all' === $_GET['post_mime_type'] ) {
$class = ' class="current"';
} else {
$class = '';
@ -2800,7 +2800,7 @@ function media_upload_library_form( $errors ) {
<?php
foreach ( $arc_result as $arc_row ) {
if ( $arc_row->yyear == 0 ) {
if ( 0 == $arc_row->yyear ) {
continue;
}
@ -2926,13 +2926,13 @@ function wp_media_insert_url_form( $default_view = 'image' ) {
<tr class="align image-only">
<th scope="row" class="label"><p><label for="align">' . __( 'Alignment' ) . '</label></p></th>
<td class="field">
<input name="align" id="align-none" value="none" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ( $default_align == 'none' ? ' checked="checked"' : '' ) . ' />
<input name="align" id="align-none" value="none" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ( 'none' === $default_align ? ' checked="checked"' : '' ) . ' />
<label for="align-none" class="align image-align-none-label">' . __( 'None' ) . '</label>
<input name="align" id="align-left" value="left" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ( $default_align == 'left' ? ' checked="checked"' : '' ) . ' />
<input name="align" id="align-left" value="left" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ( 'left' === $default_align ? ' checked="checked"' : '' ) . ' />
<label for="align-left" class="align image-align-left-label">' . __( 'Left' ) . '</label>
<input name="align" id="align-center" value="center" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ( $default_align == 'center' ? ' checked="checked"' : '' ) . ' />
<input name="align" id="align-center" value="center" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ( 'center' === $default_align ? ' checked="checked"' : '' ) . ' />
<label for="align-center" class="align image-align-center-label">' . __( 'Center' ) . '</label>
<input name="align" id="align-right" value="right" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ( $default_align == 'right' ? ' checked="checked"' : '' ) . ' />
<input name="align" id="align-right" value="right" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ( 'right' === $default_align ? ' checked="checked"' : '' ) . ' />
<label for="align-right" class="align image-align-right-label">' . __( 'Right' ) . '</label>
</td>
</tr>
@ -3272,8 +3272,8 @@ function attachment_submitbox_metadata() {
if ( preg_match( '/^.*?\.(\w+)$/', get_attached_file( $post->ID ), $matches ) ) {
echo esc_html( strtoupper( $matches[1] ) );
list( $mime_type ) = explode( '/', $post->post_mime_type );
if ( $mime_type !== 'image' && ! empty( $meta['mime_type'] ) ) {
if ( $meta['mime_type'] !== "$mime_type/" . strtolower( $matches[1] ) ) {
if ( 'image' !== $mime_type && ! empty( $meta['mime_type'] ) ) {
if ( "$mime_type/" . strtolower( $matches[1] ) !== $meta['mime_type'] ) {
echo ' (' . $meta['mime_type'] . ')';
}
}
@ -3535,7 +3535,7 @@ function wp_read_video_metadata( $file ) {
if ( empty( $metadata['created_timestamp'] ) ) {
$created_timestamp = wp_get_media_creation_timestamp( $data );
if ( $created_timestamp !== false ) {
if ( false !== $created_timestamp ) {
$metadata['created_timestamp'] = $created_timestamp;
}
}

View File

@ -157,14 +157,14 @@ function post_submit_meta_box( $post, $args = array() ) {
<?php _e( 'Visibility:' ); ?> <span id="post-visibility-display">
<?php
if ( 'private' == $post->post_status ) {
if ( 'private' === $post->post_status ) {
$post->post_password = '';
$visibility = 'private';
$visibility_trans = __( 'Private' );
} elseif ( ! empty( $post->post_password ) ) {
$visibility = 'password';
$visibility_trans = __( 'Password protected' );
} elseif ( $post_type == 'post' && is_sticky( $post->ID ) ) {
} elseif ( 'post' === $post_type && is_sticky( $post->ID ) ) {
$visibility = 'public';
$visibility_trans = __( 'Public, Sticky' );
} else {
@ -180,12 +180,12 @@ function post_submit_meta_box( $post, $args = array() ) {
<div id="post-visibility-select" class="hide-if-js">
<input type="hidden" name="hidden_post_password" id="hidden-post-password" value="<?php echo esc_attr( $post->post_password ); ?>" />
<?php if ( $post_type == 'post' ) : ?>
<?php if ( 'post' === $post_type ) : ?>
<input type="checkbox" style="display:none" name="hidden_post_sticky" id="hidden-post-sticky" value="sticky" <?php checked( is_sticky( $post->ID ) ); ?> />
<?php endif; ?>
<input type="hidden" name="hidden_post_visibility" id="hidden-post-visibility" value="<?php echo esc_attr( $visibility ); ?>" />
<input type="radio" name="visibility" id="visibility-radio-public" value="public" <?php checked( $visibility, 'public' ); ?> /> <label for="visibility-radio-public" class="selectit"><?php _e( 'Public' ); ?></label><br />
<?php if ( $post_type == 'post' && current_user_can( 'edit_others_posts' ) ) : ?>
<?php if ( 'post' === $post_type && current_user_can( 'edit_others_posts' ) ) : ?>
<span id="sticky-span"><input id="sticky" name="sticky" type="checkbox" value="sticky" <?php checked( is_sticky( $post->ID ) ); ?> /> <label for="sticky" class="selectit"><?php _e( 'Stick this post to the front page' ); ?></label><br /></span>
<?php endif; ?>
<input type="radio" name="visibility" id="visibility-radio-password" value="password" <?php checked( $visibility, 'password' ); ?> /> <label for="visibility-radio-password" class="selectit"><?php _e( 'Password protected' ); ?></label><br />
@ -263,7 +263,7 @@ endif;
</a>
<fieldset id="timestampdiv" class="hide-if-js">
<legend class="screen-reader-text"><?php _e( 'Date and time' ); ?></legend>
<?php touch_time( ( $action === 'edit' ), 1 ); ?>
<?php touch_time( ( 'edit' === $action ), 1 ); ?>
</fieldset>
</div><?php // /misc-pub-section ?>
<?php endif; ?>
@ -598,7 +598,7 @@ function post_categories_meta_box( $post, $box ) {
<div id="<?php echo $tax_name; ?>-all" class="tabs-panel">
<?php
$name = ( $tax_name == 'category' ) ? 'post_category' : 'tax_input[' . $tax_name . ']';
$name = ( 'category' === $tax_name ) ? 'post_category' : 'tax_input[' . $tax_name . ']';
// Allows for an empty term set to be sent. 0 is an invalid term ID and will be ignored by empty() checks.
echo "<input type='hidden' name='{$name}[]' value='0' />";
?>
@ -1148,13 +1148,13 @@ function link_target_meta_box( $link ) {
?>
<fieldset><legend class="screen-reader-text"><span><?php _e( 'Target' ); ?></span></legend>
<p><label for="link_target_blank" class="selectit">
<input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo ( isset( $link->link_target ) && ( $link->link_target == '_blank' ) ? 'checked="checked"' : '' ); ?> />
<input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo ( isset( $link->link_target ) && ( '_blank' === $link->link_target ) ? 'checked="checked"' : '' ); ?> />
<?php _e( '<code>_blank</code> &mdash; new window or tab.' ); ?></label></p>
<p><label for="link_target_top" class="selectit">
<input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo ( isset( $link->link_target ) && ( $link->link_target == '_top' ) ? 'checked="checked"' : '' ); ?> />
<input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo ( isset( $link->link_target ) && ( '_top' === $link->link_target ) ? 'checked="checked"' : '' ); ?> />
<?php _e( '<code>_top</code> &mdash; current window or tab, with no frames.' ); ?></label></p>
<p><label for="link_target_none" class="selectit">
<input id="link_target_none" type="radio" name="link_target" value="" <?php echo ( isset( $link->link_target ) && ( $link->link_target == '' ) ? 'checked="checked"' : '' ); ?> />
<input id="link_target_none" type="radio" name="link_target" value="" <?php echo ( isset( $link->link_target ) && ( '' === $link->link_target ) ? 'checked="checked"' : '' ); ?> />
<?php _e( '<code>_none</code> &mdash; same window or tab.' ); ?></label></p>
</fieldset>
<p><?php _e( 'Choose the target frame for your link.' ); ?></p>

View File

@ -649,7 +649,7 @@ function set_screen_options() {
$option = $_POST['wp_screen_options']['option'];
$value = $_POST['wp_screen_options']['value'];
if ( $option != sanitize_key( $option ) ) {
if ( sanitize_key( $option ) != $option ) {
return;
}
@ -744,7 +744,7 @@ function iis7_rewrite_rule_exists( $filename ) {
}
$xpath = new DOMXPath( $doc );
$rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' );
if ( $rules->length == 0 ) {
if ( 0 == $rules->length ) {
return false;
} else {
return true;
@ -1289,7 +1289,7 @@ function wp_page_reload_on_back_button_js() {
* @param string $value The proposed new site admin email address.
*/
function update_option_new_admin_email( $old_value, $value ) {
if ( $value == get_option( 'admin_email' ) || ! is_email( $value ) ) {
if ( get_option( 'admin_email' ) === $value || ! is_email( $value ) ) {
return;
}

View File

@ -20,7 +20,7 @@ function check_upload_size( $file ) {
return $file;
}
if ( $file['error'] != '0' ) { // There's already an error.
if ( '0' != $file['error'] ) { // There's already an error.
return $file;
}
@ -45,7 +45,7 @@ function check_upload_size( $file ) {
$file['error'] = __( 'You have used your space quota. Please delete files before uploading.' );
}
if ( $file['error'] != '0' && ! isset( $_POST['html-upload'] ) && ! wp_doing_ajax() ) {
if ( '0' != $file['error'] && ! isset( $_POST['html-upload'] ) && ! wp_doing_ajax() ) {
wp_die( $file['error'] . ' <a href="javascript:history.go(-1)">' . __( 'Back' ) . '</a>' );
}
@ -548,7 +548,7 @@ function format_code_lang( $code = '' ) {
* if `$taxonomy` is 'category' or 'post_tag'.
*/
function sync_category_tag_slugs( $term, $taxonomy ) {
if ( global_terms_enabled() && ( $taxonomy == 'category' || $taxonomy == 'post_tag' ) ) {
if ( global_terms_enabled() && ( 'category' === $taxonomy || 'post_tag' === $taxonomy ) ) {
if ( is_object( $term ) ) {
$term->slug = sanitize_title( $term->name );
} else {
@ -644,11 +644,11 @@ function mu_dropdown_languages( $lang_files = array(), $current = '' ) {
foreach ( (array) $lang_files as $val ) {
$code_lang = basename( $val, '.mo' );
if ( $code_lang == 'en_US' ) { // American English.
if ( 'en_US' === $code_lang ) { // American English.
$flag = true;
$ae = __( 'American English' );
$output[ $ae ] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $ae . '</option>';
} elseif ( $code_lang == 'en_GB' ) { // British English.
} elseif ( 'en_GB' === $code_lang ) { // British English.
$flag = true;
$be = __( 'British English' );
$output[ $be ] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $be . '</option>';
@ -658,7 +658,7 @@ function mu_dropdown_languages( $lang_files = array(), $current = '' ) {
}
}
if ( $flag === false ) { // WordPress English.
if ( false === $flag ) { // WordPress English.
$output[] = '<option value=""' . selected( $current, '', false ) . '>' . __( 'English' ) . '</option>';
}
@ -725,10 +725,10 @@ function avoid_blog_page_permalink_collision( $data, $postarr ) {
if ( is_subdomain_install() ) {
return $data;
}
if ( $data['post_type'] != 'page' ) {
if ( 'page' !== $data['post_type'] ) {
return $data;
}
if ( ! isset( $data['post_name'] ) || $data['post_name'] == '' ) {
if ( ! isset( $data['post_name'] ) || '' === $data['post_name'] ) {
return $data;
}
if ( ! is_main_site() ) {
@ -813,7 +813,7 @@ function choose_primary_blog() {
* @return bool True if network can be edited, otherwise false.
*/
function can_edit_network( $network_id ) {
if ( $network_id == get_current_network_id() ) {
if ( get_current_network_id() == $network_id ) {
$result = true;
} else {
$result = false;
@ -873,7 +873,7 @@ function confirm_delete_users( $users ) {
<?php
$allusers = (array) $_POST['allusers'];
foreach ( $allusers as $user_id ) {
if ( $user_id != '' && $user_id != '0' ) {
if ( '' != $user_id && '0' != $user_id ) {
$delete_user = get_userdata( $user_id );
if ( ! current_user_can( 'delete_user', $delete_user->ID ) ) {

View File

@ -1266,7 +1266,7 @@ function _wp_expand_nav_menu_post_data() {
// Build the new array value from leaf to trunk.
for ( $i = count( $array_bits ) - 1; $i >= 0; $i-- ) {
if ( $i == count( $array_bits ) - 1 ) {
if ( count( $array_bits ) - 1 == $i ) {
$new_post_data[ $array_bits[ $i ] ] = wp_slash( $post_input_data->value );
} else {
$new_post_data = array( $array_bits[ $i ] => $new_post_data );

View File

@ -1834,7 +1834,7 @@ function get_admin_page_parent( $parent = '' ) {
return $parent;
}
if ( $pagenow == 'admin.php' && isset( $plugin_page ) ) {
if ( 'admin.php' === $pagenow && isset( $plugin_page ) ) {
foreach ( (array) $menu as $parent_menu ) {
if ( $parent_menu[2] == $plugin_page ) {
$parent_file = $plugin_page;
@ -1866,7 +1866,7 @@ function get_admin_page_parent( $parent = '' ) {
if ( isset( $_wp_real_parent_file[ $parent ] ) ) {
$parent = $_wp_real_parent_file[ $parent ];
}
if ( ! empty( $typenow ) && ( $submenu_array[2] == "$pagenow?post_type=$typenow" ) ) {
if ( ! empty( $typenow ) && ( "$pagenow?post_type=$typenow" === $submenu_array[2] ) ) {
$parent_file = $parent;
return $parent;
} elseif ( $submenu_array[2] == $pagenow && empty( $typenow ) && ( empty( $parent_file ) || false === strpos( $parent_file, '?' ) ) ) {
@ -1935,7 +1935,7 @@ function get_admin_page_title() {
( $parent == $pagenow ) ||
( $parent == $plugin_page ) ||
( $plugin_page == $hook ) ||
( $pagenow == 'admin.php' && $parent1 != $submenu_array[2] ) ||
( 'admin.php' === $pagenow && $parent1 != $submenu_array[2] ) ||
( ! empty( $typenow ) && $parent == $pagenow . '?post_type=' . $typenow )
)
) {
@ -1960,7 +1960,7 @@ function get_admin_page_title() {
foreach ( $menu as $menu_array ) {
if ( isset( $plugin_page ) &&
( $plugin_page == $menu_array[2] ) &&
( $pagenow == 'admin.php' ) &&
( 'admin.php' === $pagenow ) &&
( $parent1 == $menu_array[2] ) ) {
$title = $menu_array[3];
return $menu_array[3];
@ -2156,7 +2156,7 @@ function option_update_filter( $options ) {
* @return array
*/
function add_option_whitelist( $new_options, $options = '' ) {
if ( $options == '' ) {
if ( '' == $options ) {
global $whitelist_options;
} else {
$whitelist_options = $options;
@ -2169,7 +2169,7 @@ function add_option_whitelist( $new_options, $options = '' ) {
$whitelist_options[ $page ][] = $key;
} else {
$pos = array_search( $key, $whitelist_options[ $page ] );
if ( $pos === false ) {
if ( false === $pos ) {
$whitelist_options[ $page ][] = $key;
}
}
@ -2191,7 +2191,7 @@ function add_option_whitelist( $new_options, $options = '' ) {
* @return array
*/
function remove_option_whitelist( $del_options, $options = '' ) {
if ( $options == '' ) {
if ( '' == $options ) {
global $whitelist_options;
} else {
$whitelist_options = $options;
@ -2201,7 +2201,7 @@ function remove_option_whitelist( $del_options, $options = '' ) {
foreach ( $keys as $key ) {
if ( isset( $whitelist_options[ $page ] ) && is_array( $whitelist_options[ $page ] ) ) {
$pos = array_search( $key, $whitelist_options[ $page ] );
if ( $pos !== false ) {
if ( false !== $pos ) {
unset( $whitelist_options[ $page ][ $pos ] );
}
}

View File

@ -109,7 +109,7 @@ function _wp_translate_postdata( $update = false, $post_data = null ) {
if ( isset( $post_data['saveasprivate'] ) && '' != $post_data['saveasprivate'] ) {
$post_data['post_status'] = 'private';
}
if ( isset( $post_data['publish'] ) && ( '' != $post_data['publish'] ) && ( ! isset( $post_data['post_status'] ) || $post_data['post_status'] != 'private' ) ) {
if ( isset( $post_data['publish'] ) && ( '' != $post_data['publish'] ) && ( ! isset( $post_data['post_status'] ) || 'private' !== $post_data['post_status'] ) ) {
$post_data['post_status'] = 'publish';
}
if ( isset( $post_data['advanced'] ) && '' != $post_data['advanced'] ) {
@ -377,7 +377,7 @@ function edit_post( $post_data = null ) {
if ( isset( $post_data['_wp_attachment_image_alt'] ) ) {
$image_alt = wp_unslash( $post_data['_wp_attachment_image_alt'] );
if ( $image_alt != get_post_meta( $post_ID, '_wp_attachment_image_alt', true ) ) {
if ( get_post_meta( $post_ID, '_wp_attachment_image_alt', true ) !== $image_alt ) {
$image_alt = wp_strip_all_tags( $image_alt, true );
// update_post_meta() expects slashed.
@ -1452,7 +1452,7 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
}
// Encourage a pretty permalink setting.
if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && ! ( 'page' == get_option( 'show_on_front' ) && $id == get_option( 'page_on_front' ) ) ) {
if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && ! ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $id ) ) {
$return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">' . __( 'Change Permalinks' ) . "</a></span>\n";
}
} else {
@ -1596,7 +1596,7 @@ function wp_check_post_lock( $post_id ) {
/** This filter is documented in wp-admin/includes/ajax-actions.php */
$time_window = apply_filters( 'wp_check_post_lock_window', 150 );
if ( $time && $time > time() - $time_window && $user != get_current_user_id() ) {
if ( $time && $time > time() - $time_window && get_current_user_id() != $user ) {
return $user;
}
@ -1951,7 +1951,7 @@ function wp_autosave( $post_data ) {
$post_data['post_status'] = 'draft';
}
if ( $post_data['post_type'] != 'page' && ! empty( $post_data['catslist'] ) ) {
if ( 'page' !== $post_data['post_type'] && ! empty( $post_data['catslist'] ) ) {
$post_data['post_category'] = explode( ',', $post_data['catslist'] );
}

View File

@ -694,7 +694,7 @@ function wp_privacy_process_personal_data_export_page( $response, $exporter_inde
// If we are not yet on the last page of the last exporter, return now.
/** This filter is documented in wp-admin/includes/ajax-actions.php */
$exporters = apply_filters( 'wp_privacy_personal_data_exporters', array() );
$is_last_exporter = $exporter_index === count( $exporters );
$is_last_exporter = count( $exporters ) === $exporter_index;
$exporter_done = $response['done'];
if ( ! $is_last_exporter || ! $exporter_done ) {
return $response;

View File

@ -432,7 +432,7 @@ function wp_comment_reply( $position = 1, $checkbox = false, $mode = 'single', $
}
if ( ! $wp_list_table ) {
if ( $mode == 'single' ) {
if ( 'single' === $mode ) {
$wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table' );
} else {
$wp_list_table = _get_list_table( 'WP_Comments_List_Table' );
@ -2195,12 +2195,12 @@ function _media_states( $post ) {
$header_image = get_header_image();
// Display "Header Image" if the image was ever used as a header image.
if ( ! empty( $meta_header ) && $meta_header == $stylesheet && $header_image !== wp_get_attachment_url( $post->ID ) ) {
if ( ! empty( $meta_header ) && $meta_header === $stylesheet && wp_get_attachment_url( $post->ID ) !== $header_image ) {
$media_states[] = __( 'Header Image' );
}
// Display "Current Header Image" if the image is currently the header image.
if ( $header_image && $header_image == wp_get_attachment_url( $post->ID ) ) {
if ( $header_image && wp_get_attachment_url( $post->ID ) === $header_image ) {
$media_states[] = __( 'Current Header Image' );
}
}
@ -2209,21 +2209,21 @@ function _media_states( $post ) {
if ( current_theme_supports( 'custom-background' ) ) {
$meta_background = get_post_meta( $post->ID, '_wp_attachment_is_custom_background', true );
if ( ! empty( $meta_background ) && $meta_background == $stylesheet ) {
if ( ! empty( $meta_background ) && $meta_background === $stylesheet ) {
$media_states[] = __( 'Background Image' );
$background_image = get_background_image();
if ( $background_image && $background_image == wp_get_attachment_url( $post->ID ) ) {
if ( $background_image && wp_get_attachment_url( $post->ID ) === $background_image ) {
$media_states[] = __( 'Current Background Image' );
}
}
}
if ( $post->ID == get_option( 'site_icon' ) ) {
if ( get_option( 'site_icon' ) == $post->ID ) {
$media_states[] = __( 'Site Icon' );
}
if ( $post->ID == get_theme_mod( 'custom_logo' ) ) {
if ( get_theme_mod( 'custom_logo' ) == $post->ID ) {
$media_states[] = __( 'Logo' );
}

View File

@ -56,7 +56,7 @@ function get_core_updates( $options = array() ) {
$updates = $from_api->updates;
$result = array();
foreach ( $updates as $update ) {
if ( $update->response == 'autoupdate' ) {
if ( 'autoupdate' === $update->response ) {
continue;
}
@ -291,7 +291,7 @@ function update_nag() {
$cur = get_preferred_from_update_core();
if ( ! isset( $cur->response ) || $cur->response != 'upgrade' ) {
if ( ! isset( $cur->response ) || 'upgrade' !== $cur->response ) {
return false;
}
@ -337,7 +337,7 @@ function update_right_now_message() {
if ( current_user_can( 'update_core' ) ) {
$cur = get_preferred_from_update_core();
if ( isset( $cur->response ) && $cur->response == 'upgrade' ) {
if ( isset( $cur->response ) && 'upgrade' === $cur->response ) {
$msg .= sprintf(
'<a href="%s" class="button" aria-describedby="wp-version">%s</a> ',
network_admin_url( 'update-core.php' ),

View File

@ -161,7 +161,7 @@ if ( ! function_exists( 'wp_install_defaults' ) ) :
if ( global_terms_enabled() ) {
$cat_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) );
if ( $cat_id == null ) {
if ( null == $cat_id ) {
$wpdb->insert(
$wpdb->sitecategories,
array(
@ -495,7 +495,7 @@ Commenter avatars come from <a href="https://gravatar.com">Gravatar</a>.'
// Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.)
// TODO: Get previous_blog_id.
if ( ! is_super_admin( $user_id ) && $user_id != 1 ) {
if ( ! is_super_admin( $user_id ) && 1 != $user_id ) {
$wpdb->delete(
$wpdb->usermeta,
array(
@ -566,7 +566,7 @@ function wp_install_maybe_enable_pretty_permalinks() {
*/
$response = wp_remote_get( $test_url, array( 'timeout' => 5 ) );
$x_pingback_header = wp_remote_retrieve_header( $response, 'x-pingback' );
$pretty_permalinks = $x_pingback_header && $x_pingback_header === get_bloginfo( 'pingback_url' );
$pretty_permalinks = $x_pingback_header && get_bloginfo( 'pingback_url' ) === $x_pingback_header;
if ( $pretty_permalinks ) {
return true;
@ -1127,22 +1127,22 @@ function upgrade_160() {
if ( isset( $user->user_idmode ) ) :
$idmode = $user->user_idmode;
if ( $idmode == 'nickname' ) {
if ( 'nickname' === $idmode ) {
$id = $user->user_nickname;
}
if ( $idmode == 'login' ) {
if ( 'login' === $idmode ) {
$id = $user->user_login;
}
if ( $idmode == 'firstname' ) {
if ( 'firstname' === $idmode ) {
$id = $user->user_firstname;
}
if ( $idmode == 'lastname' ) {
if ( 'lastname' === $idmode ) {
$id = $user->user_lastname;
}
if ( $idmode == 'namefl' ) {
if ( 'namefl' === $idmode ) {
$id = $user->user_firstname . ' ' . $user->user_lastname;
}
if ( $idmode == 'namelf' ) {
if ( 'namelf' === $idmode ) {
$id = $user->user_lastname . ' ' . $user->user_firstname;
}
if ( ! $idmode ) {
@ -2249,7 +2249,7 @@ function upgrade_network() {
}
// 4.2
if ( $wp_current_db_version < 31351 && $wpdb->charset === 'utf8mb4' ) {
if ( $wp_current_db_version < 31351 && 'utf8mb4' === $wpdb->charset ) {
if ( wp_should_upgrade_global_tables() ) {
$wpdb->query( "ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
$wpdb->query( "ALTER TABLE $wpdb->site DROP INDEX domain, ADD INDEX domain(domain(140),path(51))" );
@ -2499,21 +2499,21 @@ function get_alloptions_110() {
function __get_option( $setting ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
global $wpdb;
if ( $setting == 'home' && defined( 'WP_HOME' ) ) {
if ( 'home' === $setting && defined( 'WP_HOME' ) ) {
return untrailingslashit( WP_HOME );
}
if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) ) {
if ( 'siteurl' === $setting && defined( 'WP_SITEURL' ) ) {
return untrailingslashit( WP_SITEURL );
}
$option = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s", $setting ) );
if ( 'home' == $setting && '' == $option ) {
if ( 'home' === $setting && '' == $option ) {
return __get_option( 'siteurl' );
}
if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting || 'tag_base' == $setting ) {
if ( 'siteurl' === $setting || 'home' === $setting || 'category_base' === $setting || 'tag_base' === $setting ) {
$option = untrailingslashit( $option );
}
@ -2861,7 +2861,7 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N
'fieldname' => $tableindex->Column_name,
'subpart' => $tableindex->Sub_part,
);
$index_ary[ $keyname ]['unique'] = ( $tableindex->Non_unique == 0 ) ? true : false;
$index_ary[ $keyname ]['unique'] = ( 0 == $tableindex->Non_unique ) ? true : false;
$index_ary[ $keyname ]['index_type'] = $tableindex->Index_type;
}
@ -2870,7 +2870,7 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N
// Build a create string to compare to the query.
$index_string = '';
if ( $index_name == 'primary' ) {
if ( 'primary' === $index_name ) {
$index_string .= 'PRIMARY ';
} elseif ( $index_data['unique'] ) {
$index_string .= 'UNIQUE ';
@ -2889,7 +2889,7 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N
// For each column in the index.
foreach ( $index_data['columns'] as $column_data ) {
if ( $index_columns != '' ) {
if ( '' != $index_columns ) {
$index_columns .= ',';
}
@ -3000,14 +3000,14 @@ function make_site_theme_from_oldschool( $theme_name, $template ) {
);
foreach ( $files as $oldfile => $newfile ) {
if ( $oldfile == 'index.php' ) {
if ( 'index.php' === $oldfile ) {
$oldpath = $home_path;
} else {
$oldpath = ABSPATH;
}
// Check to make sure it's not a new index.
if ( $oldfile == 'index.php' ) {
if ( 'index.php' === $oldfile ) {
$index = implode( '', file( "$oldpath/$oldfile" ) );
if ( strpos( $index, 'WP_USE_THEMES' ) !== false ) {
if ( ! copy( WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile" ) ) {
@ -3183,7 +3183,7 @@ function make_site_theme() {
// Make the new site theme active.
$current_template = __get_option( 'template' );
if ( $current_template == WP_DEFAULT_THEME ) {
if ( WP_DEFAULT_THEME == $current_template ) {
update_option( 'template', $template );
update_option( 'stylesheet', $template );
}

View File

@ -70,7 +70,7 @@ function edit_user( $user_id = 0 ) {
*/
if (
( is_multisite() && current_user_can( 'manage_network_users' ) ) ||
$user_id !== get_current_user_id() ||
get_current_user_id() !== $user_id ||
( $potential_role && $potential_role->has_cap( 'promote_users' ) )
) {
$user->role = $new_role;
@ -81,7 +81,7 @@ function edit_user( $user_id = 0 ) {
$user->user_email = sanitize_text_field( wp_unslash( $_POST['email'] ) );
}
if ( isset( $_POST['url'] ) ) {
if ( empty( $_POST['url'] ) || $_POST['url'] == 'http://' ) {
if ( empty( $_POST['url'] ) || 'http://' === $_POST['url'] ) {
$user->user_url = '';
} else {
$user->user_url = esc_url_raw( $_POST['url'] );
@ -143,7 +143,7 @@ function edit_user( $user_id = 0 ) {
$errors = new WP_Error();
/* checking that username has been typed */
if ( $user->user_login == '' ) {
if ( '' == $user->user_login ) {
$errors->add( 'user_login', __( '<strong>Error</strong>: Please enter a username.' ) );
}

View File

@ -175,19 +175,19 @@ function check_column( $table_name, $col_name, $col_type, $is_null = null, $key
if ( $row->Field == $col_name ) {
// Got our column, check the params.
if ( ( $col_type != null ) && ( $row->Type != $col_type ) ) {
if ( ( null != $col_type ) && ( $row->Type != $col_type ) ) {
++$diffs;
}
if ( ( $is_null != null ) && ( $row->Null != $is_null ) ) {
if ( ( null != $is_null ) && ( $row->Null != $is_null ) ) {
++$diffs;
}
if ( ( $key != null ) && ( $row->Key != $key ) ) {
if ( ( null != $key ) && ( $row->Key != $key ) ) {
++$diffs;
}
if ( ( $default != null ) && ( $row->Default != $default ) ) {
if ( ( null != $default ) && ( $row->Default != $default ) ) {
++$diffs;
}
if ( ( $extra != null ) && ( $row->Extra != $extra ) ) {
if ( ( null != $extra ) && ( $row->Extra != $extra ) ) {
++$diffs;
}
if ( $diffs > 0 ) {

View File

@ -120,7 +120,7 @@ $builtin = array( 'post', 'page' );
foreach ( array_merge( $builtin, $types ) as $ptype ) {
$ptype_obj = get_post_type_object( $ptype );
// Check if it should be a submenu.
if ( $ptype_obj->show_in_menu !== true ) {
if ( true !== $ptype_obj->show_in_menu ) {
continue;
}
$ptype_menu_position = is_int( $ptype_obj->menu_position ) ? $ptype_obj->menu_position : ++$_wp_last_object_menu; // If we're to use $_wp_last_object_menu, increment it first.

View File

@ -107,7 +107,7 @@ 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;
}

View File

@ -165,7 +165,7 @@ if ( isset( $_GET['updated'] ) ) {
</p>
<?php
$new_admin_email = get_site_option( 'new_admin_email' );
if ( $new_admin_email && $new_admin_email != get_site_option( 'admin_email' ) ) :
if ( $new_admin_email && get_site_option( 'admin_email' ) !== $new_admin_email ) :
?>
<div class="updated inline">
<p>
@ -257,7 +257,7 @@ if ( isset( $_GET['updated'] ) ) {
$limited_email_domains = str_replace( ' ', "\n", $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 ? '' : implode( "\n", (array) $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>

View File

@ -43,7 +43,7 @@ if ( isset( $_REQUEST['action'] ) && 'update-site' == $_REQUEST['action'] && is_
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 ) ) {
if ( 0 === $key || 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.
}
update_option( $key, $val );
@ -124,7 +124,7 @@ if ( ! empty( $messages ) ) {
);
$options = $wpdb->get_results( $query );
foreach ( $options as $option ) {
if ( $option->option_name == 'default_role' ) {
if ( 'default_role' === $option->option_name ) {
$editblog_default_role = $option->option_value;
}
$disabled = false;

View File

@ -141,7 +141,7 @@ if ( isset( $_GET['action'] ) ) {
}
$updated_action = 'not_deleted';
if ( $id != '0' && $id != get_network()->site_id && current_user_can( 'delete_site', $id ) ) {
if ( '0' != $id && get_network()->site_id != $id && current_user_can( 'delete_site', $id ) ) {
wpmu_delete_blog( $id, true );
$updated_action = 'delete';
}
@ -153,7 +153,7 @@ if ( isset( $_GET['action'] ) ) {
foreach ( (array) $_POST['site_ids'] as $site_id ) {
$site_id = (int) $site_id;
if ( $site_id == get_network()->site_id ) {
if ( get_network()->site_id == $site_id ) {
continue;
}
@ -178,10 +178,10 @@ if ( isset( $_GET['action'] ) ) {
case 'allblogs':
if ( ( isset( $_POST['action'] ) || isset( $_POST['action2'] ) ) && isset( $_POST['allblogs'] ) ) {
$doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2'];
$doaction = -1 != $_POST['action'] ? $_POST['action'] : $_POST['action2'];
foreach ( (array) $_POST['allblogs'] as $key => $val ) {
if ( $val != '0' && $val != get_network()->site_id ) {
if ( '0' != $val && get_network()->site_id != $val ) {
switch ( $doaction ) {
case 'delete':
require_once ABSPATH . 'wp-admin/admin-header.php';

View File

@ -27,7 +27,7 @@ if ( isset( $_GET['action'] ) ) {
check_admin_referer( 'deleteuser' );
$id = intval( $_GET['id'] );
if ( $id != '0' && $id != '1' ) {
if ( '0' != $id && '1' != $id ) {
$_POST['allusers'] = array( $id ); // confirm_delete_users() can only handle arrays.
$title = __( 'Users' );
$parent_file = 'users.php';
@ -49,7 +49,7 @@ if ( isset( $_GET['action'] ) ) {
if ( ( isset( $_POST['action'] ) || isset( $_POST['action2'] ) ) && isset( $_POST['allusers'] ) ) {
check_admin_referer( 'bulk-users-network' );
$doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2'];
$doaction = -1 != $_POST['action'] ? $_POST['action'] : $_POST['action2'];
$userfunction = '';
foreach ( (array) $_POST['allusers'] as $user_id ) {
@ -84,7 +84,7 @@ if ( isset( $_GET['action'] ) ) {
$blogs = get_blogs_of_user( $user_id, true );
foreach ( (array) $blogs as $details ) {
if ( $details->userblog_id != get_network()->site_id ) { // Main blog is not a spam!
if ( get_network()->site_id != $details->userblog_id ) { // Main blog is not a spam!
update_blog_status( $details->userblog_id, 'spam', '1' );
}
}
@ -176,7 +176,7 @@ if ( isset( $_GET['action'] ) ) {
}
}
if ( $i == 1 ) {
if ( 1 == $i ) {
$deletefunction = 'delete';
} else {
$deletefunction = 'all_delete';
@ -239,7 +239,7 @@ get_current_screen()->set_screen_reader_content(
require_once ABSPATH . 'wp-admin/admin-header.php';
if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty( $_REQUEST['action'] ) ) {
if ( isset( $_REQUEST['updated'] ) && 'true' == $_REQUEST['updated'] && ! empty( $_REQUEST['action'] ) ) {
?>
<div id="message" class="updated notice is-dismissible"><p>
<?php

View File

@ -113,7 +113,7 @@ if ( ! is_multisite() ) {
<p class="description" id="new-admin-email-description"><?php _e( 'This address is used for admin purposes. If you change this, we will send you an email at your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>' ); ?></p>
<?php
$new_admin_email = get_option( 'new_admin_email' );
if ( $new_admin_email && $new_admin_email != get_option( 'admin_email' ) ) :
if ( $new_admin_email && get_option( 'admin_email' ) !== $new_admin_email ) :
?>
<div class="updated inline">
<p>
@ -183,7 +183,7 @@ if ( ! empty( $languages ) || ! empty( $translations ) ) {
);
// Add note about deprecated WPLANG constant.
if ( defined( 'WPLANG' ) && ( '' !== WPLANG ) && $locale !== WPLANG ) {
if ( defined( 'WPLANG' ) && ( '' !== WPLANG ) && WPLANG !== $locale ) {
_deprecated_argument(
'define()',
'4.0.0',

View File

@ -34,7 +34,7 @@ if ( 'post' == $post_type ) {
}
} else {
$submenu_file = "post-new.php?post_type=$post_type";
if ( isset( $post_type_object ) && $post_type_object->show_in_menu && $post_type_object->show_in_menu !== true ) {
if ( isset( $post_type_object ) && $post_type_object->show_in_menu && true !== $post_type_object->show_in_menu ) {
$parent_file = $post_type_object->show_in_menu;
// What if there isn't a post-new.php item for this post type?
if ( ! isset( $_registered_pages[ get_plugin_page_hookname( "post-new.php?post_type=$post_type", $post_type_object->show_in_menu ) ] ) ) {

View File

@ -9,10 +9,10 @@
if ( isset( $_GET['page'] ) && ! empty( $_POST ) ) {
// Ensure POST-ing to `tools.php?page=export_personal_data` and `tools.php?page=remove_personal_data`
// continues to work after creating the new files for exporting and erasing of personal data.
if ( $_GET['page'] === 'export_personal_data' ) {
if ( 'export_personal_data' === $_GET['page'] ) {
require_once ABSPATH . 'wp-admin/export-personal-data.php';
return;
} elseif ( $_GET['page'] === 'remove_personal_data' ) {
} elseif ( 'remove_personal_data' === $_GET['page'] ) {
require_once ABSPATH . 'wp-admin/erase-personal-data.php';
return;
}
@ -27,10 +27,10 @@ if ( isset( $_GET['wp-privacy-policy-guide'] ) ) {
exit;
} elseif ( isset( $_GET['page'] ) ) {
// These were also moved to files in WP 5.3.
if ( $_GET['page'] === 'export_personal_data' ) {
if ( 'export_personal_data' === $_GET['page'] ) {
wp_redirect( admin_url( 'export-personal-data.php' ), 301 );
exit;
} elseif ( $_GET['page'] === 'remove_personal_data' ) {
} elseif ( 'remove_personal_data' === $_GET['page'] ) {
wp_redirect( admin_url( 'erase-personal-data.php' ), 301 );
exit;
}

View File

@ -319,7 +319,7 @@ if ( ! function_exists( 'twentyeleven_header_style' ) ) :
$text_color = get_header_textcolor();
// If no custom options for text are set, let's bail.
if ( $text_color == HEADER_TEXTCOLOR ) {
if ( HEADER_TEXTCOLOR == $text_color ) {
return;
}
@ -416,7 +416,7 @@ if ( ! function_exists( 'twentyeleven_admin_header_image' ) ) :
$color = get_header_textcolor();
$image = get_header_image();
$style = 'display: none;';
if ( $color && $color != 'blank' ) {
if ( $color && 'blank' !== $color ) {
$style = 'color: #' . $color . ';';
}
?>

View File

@ -63,7 +63,7 @@ if ( ! function_exists( 'twentyfourteen_header_style' ) ) :
$text_color = get_header_textcolor();
// If no custom color for text is set, let's bail.
if ( display_header_text() && $text_color === get_theme_support( 'custom-header', 'default-text-color' ) ) {
if ( display_header_text() && get_theme_support( 'custom-header', 'default-text-color' ) === $text_color ) {
return;
}
@ -82,7 +82,7 @@ if ( ! function_exists( 'twentyfourteen_header_style' ) ) :
}
<?php
// If the user has set a custom color for the text, use that.
elseif ( $text_color != get_theme_support( 'custom-header', 'default-text-color' ) ) :
elseif ( get_theme_support( 'custom-header', 'default-text-color' ) != $text_color ) :
?>
.site-title a {
color: #<?php echo esc_attr( $text_color ); ?>;

View File

@ -90,7 +90,7 @@ function twentythirteen_header_style() {
$text_color = get_header_textcolor();
// If no custom options for text are set, let's bail.
if ( empty( $header_image ) && $text_color == get_theme_support( 'custom-header', 'default-text-color' ) ) {
if ( empty( $header_image ) && get_theme_support( 'custom-header', 'default-text-color' ) == $text_color ) {
return;
}
@ -136,7 +136,7 @@ function twentythirteen_header_style() {
endif;
// If the user has set a custom color for the text, use that.
elseif ( $text_color != get_theme_support( 'custom-header', 'default-text-color' ) ) :
elseif ( get_theme_support( 'custom-header', 'default-text-color' ) != $text_color ) :
?>
.site-title,
.site-description {

View File

@ -71,7 +71,7 @@ function twentytwelve_header_style() {
$text_color = get_header_textcolor();
// If no custom options for text are set, let's bail.
if ( $text_color == get_theme_support( 'custom-header', 'default-text-color' ) ) {
if ( get_theme_support( 'custom-header', 'default-text-color' ) == $text_color ) {
return;
}

View File

@ -113,7 +113,7 @@ function _walk_bookmarks( $bookmarks, $args = '' ) {
$output .= $parsed_args['link_before'];
if ( $bookmark->link_image != null && $parsed_args['show_images'] ) {
if ( null != $bookmark->link_image && $parsed_args['show_images'] ) {
if ( strpos( $bookmark->link_image, 'http' ) === 0 ) {
$output .= "<img src=\"$bookmark->link_image\" $alt $title />";
} else { // If it's a relative path.

View File

@ -52,11 +52,11 @@ function get_bookmark( $bookmark, $output = OBJECT, $filter = 'raw' ) {
$_bookmark = sanitize_bookmark( $_bookmark, $filter );
if ( $output == OBJECT ) {
if ( OBJECT == $output ) {
return $_bookmark;
} elseif ( $output == ARRAY_A ) {
} elseif ( ARRAY_A == $output ) {
return get_object_vars( $_bookmark );
} elseif ( $output == ARRAY_N ) {
} elseif ( ARRAY_N == $output ) {
return array_values( get_object_vars( $_bookmark ) );
} else {
return $_bookmark;
@ -305,7 +305,7 @@ function get_bookmarks( $args = '' ) {
$query = "SELECT * $length $recently_updated_test $get_updated FROM $wpdb->links $join WHERE 1=1 $visible $category_query";
$query .= " $exclusions $inclusions $search";
$query .= " ORDER BY $orderby $order";
if ( $parsed_args['limit'] != -1 ) {
if ( -1 != $parsed_args['limit'] ) {
$query .= ' LIMIT ' . $parsed_args['limit'];
}

View File

@ -534,7 +534,7 @@ function map_meta_cap( $cap, $user_id, ...$args ) {
break;
}
if ( 'delete_term' === $cap && ( $term->term_id == get_option( 'default_' . $term->taxonomy ) ) ) {
if ( 'delete_term' === $cap && ( get_option( 'default_' . $term->taxonomy ) == $term->term_id ) ) {
$caps[] = 'do_not_allow';
break;
}
@ -867,7 +867,7 @@ function get_super_admins() {
* @return bool True if the user is a site admin.
*/
function is_super_admin( $user_id = false ) {
if ( ! $user_id || $user_id == get_current_user_id() ) {
if ( ! $user_id || get_current_user_id() == $user_id ) {
$user = wp_get_current_user();
} else {
$user = get_userdata( $user_id );

View File

@ -836,7 +836,7 @@ function wp_generate_tag_cloud( $tags, $args = '' ) {
$translate_nooped_plural = $args['topic_count_text'];
} elseif ( ! empty( $args['topic_count_text_callback'] ) ) {
// Look for the alternative callback style. Ignore the previous default.
if ( $args['topic_count_text_callback'] === 'default_topic_count_text' ) {
if ( 'default_topic_count_text' === $args['topic_count_text_callback'] ) {
/* translators: %s: Number of items (tags). */
$translate_nooped_plural = _n_noop( '%s item', '%s items' );
} else {

View File

@ -127,7 +127,7 @@ function get_category_by_path( $category_path, $full_match = true, $output = OBJ
$category_paths = explode( '/', $category_paths );
$full_path = '';
foreach ( (array) $category_paths as $pathdir ) {
$full_path .= ( $pathdir != '' ? '/' : '' ) . sanitize_title( $pathdir );
$full_path .= ( '' != $pathdir ? '/' : '' ) . sanitize_title( $pathdir );
}
$categories = get_terms(
array(
@ -144,7 +144,7 @@ function get_category_by_path( $category_path, $full_match = true, $output = OBJ
foreach ( $categories as $category ) {
$path = '/' . $leaf_path;
$curcategory = $category;
while ( ( $curcategory->parent != 0 ) && ( $curcategory->parent != $curcategory->term_id ) ) {
while ( ( 0 != $curcategory->parent ) && ( $curcategory->parent != $curcategory->term_id ) ) {
$curcategory = get_term( $curcategory->parent, 'category' );
if ( is_wp_error( $curcategory ) ) {
return $curcategory;

View File

@ -485,7 +485,7 @@ class WP_Http {
*/
public static function browser_redirect_compatibility( $location, $headers, $data, &$options, $original ) {
// Browser compatibility.
if ( $original->status_code === 302 ) {
if ( 302 === $original->status_code ) {
$options['type'] = Requests::GET;
}
}

View File

@ -130,7 +130,7 @@ class Walker_Page extends Walker {
} elseif ( $_current_page && $page->ID == $_current_page->post_parent ) {
$css_class[] = 'current_page_parent';
}
} elseif ( $page->ID == get_option( 'page_for_posts' ) ) {
} elseif ( get_option( 'page_for_posts' ) == $page->ID ) {
$css_class[] = 'current_page_parent';
}

View File

@ -318,7 +318,7 @@ class WP_Admin_Bar {
}
foreach ( $this->_get_nodes() as $node ) {
if ( 'root' == $node->id ) {
if ( 'root' === $node->id ) {
continue;
}
@ -329,9 +329,9 @@ class WP_Admin_Bar {
}
// Generate the group class (we distinguish between top level and other level groups).
$group_class = ( $node->parent == 'root' ) ? 'ab-top-menu' : 'ab-submenu';
$group_class = ( 'root' === $node->parent ) ? 'ab-top-menu' : 'ab-submenu';
if ( $node->type == 'group' ) {
if ( 'group' === $node->type ) {
if ( empty( $node->meta['class'] ) ) {
$node->meta['class'] = $group_class;
} else {
@ -340,7 +340,7 @@ class WP_Admin_Bar {
}
// Items in items aren't allowed. Wrap nested items in 'default' groups.
if ( $parent->type == 'item' && $node->type == 'item' ) {
if ( 'item' === $parent->type && 'item' === $node->type ) {
$default_id = $parent->id . '-default';
$default = $this->_get_node( $default_id );
@ -369,7 +369,7 @@ class WP_Admin_Bar {
// Groups in groups aren't allowed. Add a special 'container' node.
// The container will invisibly wrap both groups.
} elseif ( $parent->type == 'group' && $node->type == 'group' ) {
} elseif ( 'group' === $parent->type && 'group' === $node->type ) {
$container_id = $parent->id . '-container';
$container = $this->_get_node( $container_id );
@ -398,7 +398,7 @@ class WP_Admin_Bar {
$container->parent = $grandparent->id;
$index = array_search( $parent, $grandparent->children, true );
if ( $index === false ) {
if ( false === $index ) {
$grandparent->children[] = $container;
} else {
array_splice( $grandparent->children, $index, 1, array( $container ) );
@ -469,7 +469,7 @@ class WP_Admin_Bar {
* @param object $node
*/
final protected function _render_container( $node ) {
if ( $node->type != 'container' || empty( $node->children ) ) {
if ( 'container' !== $node->type || empty( $node->children ) ) {
return;
}
@ -484,11 +484,11 @@ class WP_Admin_Bar {
* @param object $node
*/
final protected function _render_group( $node ) {
if ( $node->type == 'container' ) {
if ( 'container' === $node->type ) {
$this->_render_container( $node );
return;
}
if ( $node->type != 'group' || empty( $node->children ) ) {
if ( 'group' !== $node->type || empty( $node->children ) ) {
return;
}
@ -509,7 +509,7 @@ class WP_Admin_Bar {
* @param object $node
*/
final protected function _render_item( $node ) {
if ( $node->type != 'item' ) {
if ( 'item' !== $node->type ) {
return;
}

View File

@ -1138,11 +1138,11 @@ class WP_Comment_Query {
}
$parsed = false;
if ( $orderby == $this->query_vars['meta_key'] || $orderby == 'meta_value' ) {
if ( $this->query_vars['meta_key'] === $orderby || 'meta_value' === $orderby ) {
$parsed = "$wpdb->commentmeta.meta_value";
} elseif ( $orderby == 'meta_value_num' ) {
} elseif ( 'meta_value_num' === $orderby ) {
$parsed = "$wpdb->commentmeta.meta_value+0";
} elseif ( $orderby == 'comment__in' ) {
} elseif ( 'comment__in' === $orderby ) {
$comment__in = implode( ',', array_map( 'absint', $this->query_vars['comment__in'] ) );
$parsed = "FIELD( {$wpdb->comments}.comment_ID, $comment__in )";
} elseif ( in_array( $orderby, $allowed_keys ) ) {

View File

@ -1007,7 +1007,7 @@ final class WP_Customize_Widgets {
'temp_id' => isset( $args['_temp_id'] ) ? $args['_temp_id'] : null,
'is_multi' => $is_multi_widget,
'control_tpl' => $control_tpl,
'multi_number' => ( $args['_add'] === 'multi' ) ? $args['_multi_num'] : false,
'multi_number' => ( 'multi' === $args['_add'] ) ? $args['_multi_num'] : false,
'is_disabled' => $is_disabled,
'id_base' => $id_base,
'transport' => $this->is_widget_selective_refreshable( $id_base ) ? 'postMessage' : 'refresh',
@ -1313,7 +1313,7 @@ final class WP_Customize_Widgets {
* @return array|void Sanitized widget instance.
*/
public function sanitize_widget_instance( $value ) {
if ( $value === array() ) {
if ( array() === $value ) {
return $value;
}

View File

@ -243,7 +243,7 @@ final class _WP_Editors {
$quicktags_toolbar = '';
if ( self::$this_quicktags ) {
if ( 'content' === $editor_id && ! empty( $GLOBALS['current_screen'] ) && $GLOBALS['current_screen']->base === 'post' ) {
if ( 'content' === $editor_id && ! empty( $GLOBALS['current_screen'] ) && 'post' === $GLOBALS['current_screen']->base ) {
$toolbar_id = 'ed_toolbar';
} else {
$toolbar_id = 'qt_' . $editor_id_attr . '_toolbar';
@ -743,7 +743,7 @@ final class _WP_Editors {
$page_template = get_page_template_slug( $post );
if ( $page_template !== false ) {
if ( false !== $page_template ) {
$page_template = empty( $page_template ) ? 'default' : str_replace( '.', '-', basename( $page_template, '.php' ) );
$body_class .= ' page-template-' . sanitize_html_class( $page_template );
}

View File

@ -281,7 +281,7 @@ final class WP_Hook implements Iterator, ArrayAccess {
}
// Avoid the array_slice() if possible.
if ( $the_['accepted_args'] == 0 ) {
if ( 0 == $the_['accepted_args'] ) {
$value = call_user_func( $the_['function'] );
} elseif ( $the_['accepted_args'] >= $num_args ) {
$value = call_user_func_array( $the_['function'], $args );

View File

@ -129,7 +129,7 @@ class WP_Http_Curl {
curl_setopt( $handle, CURLOPT_URL, $url );
curl_setopt( $handle, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $handle, CURLOPT_SSL_VERIFYHOST, ( $ssl_verify === true ) ? 2 : false );
curl_setopt( $handle, CURLOPT_SSL_VERIFYHOST, ( true === $ssl_verify ) ? 2 : false );
curl_setopt( $handle, CURLOPT_SSL_VERIFYPEER, $ssl_verify );
if ( $ssl_verify ) {
@ -209,7 +209,7 @@ class WP_Http_Curl {
curl_setopt( $handle, CURLOPT_HTTPHEADER, $headers );
}
if ( $parsed_args['httpversion'] == '1.0' ) {
if ( '1.0' === $parsed_args['httpversion'] ) {
curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0 );
} else {
curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 );

View File

@ -76,7 +76,7 @@ class WP_HTTP_IXR_Client extends IXR_Client {
*/
$args['headers'] = apply_filters( 'wp_http_ixr_client_headers', $args['headers'] );
if ( $this->timeout !== false ) {
if ( false !== $this->timeout ) {
$args['timeout'] = $this->timeout;
}
@ -112,7 +112,7 @@ class WP_HTTP_IXR_Client extends IXR_Client {
}
// Is the message a fault?
if ( $this->message->messageType == 'fault' ) {
if ( 'fault' === $this->message->messageType ) {
$this->error = new IXR_Error( $this->message->faultCode, $this->message->faultString );
return false;
}

View File

@ -174,7 +174,7 @@ class WP_HTTP_Proxy {
$check = @parse_url( $uri );
// Malformed URL, can not process, but this could mean ssl, so let through anyway.
if ( $check === false ) {
if ( false === $check ) {
return true;
}

View File

@ -55,9 +55,9 @@ class WP_Http_Streams {
$connect_host = $arrURL['host'];
$secure_transport = ( $arrURL['scheme'] == 'ssl' || $arrURL['scheme'] == 'https' );
$secure_transport = ( 'ssl' === $arrURL['scheme'] || 'https' === $arrURL['scheme'] );
if ( ! isset( $arrURL['port'] ) ) {
if ( $arrURL['scheme'] == 'ssl' || $arrURL['scheme'] == 'https' ) {
if ( 'ssl' === $arrURL['scheme'] || 'https' === $arrURL['scheme'] ) {
$arrURL['port'] = 443;
$secure_transport = true;
} else {
@ -390,7 +390,7 @@ class WP_Http_Streams {
$match_against = preg_split( '/,\s*/', $cert['extensions']['subjectAltName'] );
foreach ( $match_against as $match ) {
list( $match_type, $match_host ) = explode( ':', $match );
if ( $host_type == strtolower( trim( $match_type ) ) ) { // IP: or DNS:
if ( strtolower( trim( $match_type ) ) === $host_type ) { // IP: or DNS:
$certificate_hostnames[] = strtolower( trim( $match_host ) );
}
}

View File

@ -103,7 +103,7 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor {
// setIteratorIndex is optional unless mime is an animated format.
// Here, we just say no if you are missing it and aren't loading a jpeg.
if ( ! method_exists( 'Imagick', 'setIteratorIndex' ) && $mime_type !== 'image/jpeg' ) {
if ( ! method_exists( 'Imagick', 'setIteratorIndex' ) && 'image/jpeg' !== $mime_type ) {
return false;
}

View File

@ -418,7 +418,7 @@ abstract class WP_Image_Editor {
*/
$orientation = apply_filters( 'wp_image_maybe_exif_rotate', $orientation, $this->file );
if ( ! $orientation || $orientation === 1 ) {
if ( ! $orientation || 1 === $orientation ) {
return false;
}

View File

@ -545,10 +545,10 @@ class WP_Network_Query {
);
$parsed = false;
if ( $orderby == 'network__in' ) {
if ( 'network__in' === $orderby ) {
$network__in = implode( ',', array_map( 'absint', $this->query_vars['network__in'] ) );
$parsed = "FIELD( {$wpdb->site}.id, $network__in )";
} elseif ( $orderby == 'domain_length' || $orderby == 'path_length' ) {
} elseif ( 'domain_length' === $orderby || 'path_length' === $orderby ) {
$field = substr( $orderby, 0, -7 );
$parsed = "CHAR_LENGTH($wpdb->site.$field)";
} elseif ( in_array( $orderby, $allowed_keys ) ) {

View File

@ -910,7 +910,7 @@ class WP_Query {
}
unset( $tax_query );
if ( empty( $qv['author'] ) || ( $qv['author'] == '0' ) ) {
if ( empty( $qv['author'] ) || ( '0' == $qv['author'] ) ) {
$this->is_author = false;
} else {
$this->is_author = true;
@ -1017,25 +1017,25 @@ class WP_Query {
unset( $this->queried_object );
}
if ( 'page' == get_option( 'show_on_front' ) && isset( $this->queried_object_id ) && $this->queried_object_id == get_option( 'page_for_posts' ) ) {
if ( 'page' === get_option( 'show_on_front' ) && isset( $this->queried_object_id ) && get_option( 'page_for_posts' ) == $this->queried_object_id ) {
$this->is_page = false;
$this->is_home = true;
$this->is_posts_page = true;
}
if ( isset( $this->queried_object_id ) && $this->queried_object_id == get_option( 'wp_page_for_privacy_policy' ) ) {
if ( isset( $this->queried_object_id ) && get_option( 'wp_page_for_privacy_policy' ) == $this->queried_object_id ) {
$this->is_privacy_policy = true;
}
}
if ( $qv['page_id'] ) {
if ( 'page' == get_option( 'show_on_front' ) && $qv['page_id'] == get_option( 'page_for_posts' ) ) {
if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) == $qv['page_id'] ) {
$this->is_page = false;
$this->is_home = true;
$this->is_posts_page = true;
}
if ( $qv['page_id'] == get_option( 'wp_page_for_privacy_policy' ) ) {
if ( get_option( 'wp_page_for_privacy_policy' ) == $qv['page_id'] ) {
$this->is_privacy_policy = true;
}
}
@ -1377,7 +1377,7 @@ class WP_Query {
foreach ( $q['search_terms'] as $term ) {
// If there is an $exclusion_prefix, terms prefixed with it should be excluded.
$exclude = $exclusion_prefix && ( $exclusion_prefix === substr( $term, 0, 1 ) );
$exclude = $exclusion_prefix && ( substr( $term, 0, 1 ) === $exclusion_prefix );
if ( $exclude ) {
$like_op = 'NOT LIKE';
$andor_op = 'AND';
@ -1861,11 +1861,11 @@ class WP_Query {
$q['showposts'] = (int) $q['showposts'];
$q['posts_per_page'] = $q['showposts'];
}
if ( ( isset( $q['posts_per_archive_page'] ) && $q['posts_per_archive_page'] != 0 ) && ( $this->is_archive || $this->is_search ) ) {
if ( ( isset( $q['posts_per_archive_page'] ) && 0 != $q['posts_per_archive_page'] ) && ( $this->is_archive || $this->is_search ) ) {
$q['posts_per_page'] = $q['posts_per_archive_page'];
}
if ( ! isset( $q['nopaging'] ) ) {
if ( $q['posts_per_page'] == -1 ) {
if ( -1 == $q['posts_per_page'] ) {
$q['nopaging'] = true;
} else {
$q['nopaging'] = false;
@ -1884,15 +1884,15 @@ class WP_Query {
$q['posts_per_page'] = (int) $q['posts_per_page'];
if ( $q['posts_per_page'] < -1 ) {
$q['posts_per_page'] = abs( $q['posts_per_page'] );
} elseif ( $q['posts_per_page'] == 0 ) {
} elseif ( 0 == $q['posts_per_page'] ) {
$q['posts_per_page'] = 1;
}
if ( ! isset( $q['comments_per_page'] ) || $q['comments_per_page'] == 0 ) {
if ( ! isset( $q['comments_per_page'] ) || 0 == $q['comments_per_page'] ) {
$q['comments_per_page'] = get_option( 'comments_per_page' );
}
if ( $this->is_home && ( empty( $this->query ) || $q['preview'] == 'true' ) && ( 'page' == get_option( 'show_on_front' ) ) && get_option( 'page_on_front' ) ) {
if ( $this->is_home && ( empty( $this->query ) || 'true' === $q['preview'] ) && ( 'page' === get_option( 'show_on_front' ) ) && get_option( 'page_on_front' ) ) {
$this->is_page = true;
$this->is_home = false;
$q['page_id'] = get_option( 'page_on_front' );
@ -2096,7 +2096,7 @@ class WP_Query {
}
if ( $q['page_id'] ) {
if ( ( 'page' != get_option( 'show_on_front' ) ) || ( $q['page_id'] != get_option( 'page_for_posts' ) ) ) {
if ( ( 'page' !== get_option( 'show_on_front' ) ) || ( get_option( 'page_for_posts' ) != $q['page_id'] ) ) {
$q['p'] = $q['page_id'];
$where = " AND {$wpdb->posts}.ID = " . $q['page_id'];
}
@ -2135,7 +2135,7 @@ class WP_Query {
$post_type = array();
$taxonomies = array_keys( $this->tax_query->queried_terms );
foreach ( get_post_types( array( 'exclude_from_search' => false ) ) as $pt ) {
$object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies( $pt );
$object_taxonomies = 'attachment' === $pt ? get_taxonomies_for_attachments() : get_object_taxonomies( $pt );
if ( array_intersect( $taxonomies, $object_taxonomies ) ) {
$post_type[] = $pt;
}
@ -2214,7 +2214,7 @@ class WP_Query {
// Author/user stuff.
if ( ! empty( $q['author'] ) && $q['author'] != '0' ) {
if ( ! empty( $q['author'] ) && '0' != $q['author'] ) {
$q['author'] = addslashes_gpc( '' . urldecode( $q['author'] ) );
$authors = array_unique( array_map( 'intval', preg_split( '/[,\s]+/', $q['author'] ) ) );
foreach ( $authors as $author ) {
@ -3290,7 +3290,7 @@ class WP_Query {
global $post;
$this->in_the_loop = true;
if ( $this->current_post == -1 ) { // Loop has just started.
if ( -1 == $this->current_post ) { // Loop has just started.
/**
* Fires once the loop is started.
*
@ -3380,7 +3380,7 @@ class WP_Query {
$comment = $this->next_comment();
if ( $this->current_comment == 0 ) {
if ( 0 == $this->current_comment ) {
/**
* Fires once the comment loop is started.
*
@ -4300,7 +4300,7 @@ class WP_Query {
* Force full post content when viewing the permalink for the $post,
* or when on an RSS feed. Otherwise respect the 'more' tag.
*/
if ( $post->ID === get_queried_object_id() && ( $this->is_page() || $this->is_single() ) ) {
if ( get_queried_object_id() === $post->ID && ( $this->is_page() || $this->is_single() ) ) {
$more = 1;
} elseif ( $this->is_feed() ) {
$more = 1;

View File

@ -920,7 +920,7 @@ class WP_Rewrite {
// Get the structure, minus any cruft (stuff that isn't tags) at the front.
$structure = $permalink_structure;
if ( $front != '/' ) {
if ( '/' !== $front ) {
$structure = str_replace( $front, '', $structure );
}
@ -1909,7 +1909,7 @@ class WP_Rewrite {
* @param string $category_base Category permalink structure base.
*/
public function set_category_base( $category_base ) {
if ( $category_base != get_option( 'category_base' ) ) {
if ( get_option( 'category_base' ) !== $category_base ) {
update_option( 'category_base', $category_base );
$this->init();
}
@ -1927,7 +1927,7 @@ class WP_Rewrite {
* @param string $tag_base Tag permalink structure base.
*/
public function set_tag_base( $tag_base ) {
if ( $tag_base != get_option( 'tag_base' ) ) {
if ( get_option( 'tag_base' ) !== $tag_base ) {
update_option( 'tag_base', $tag_base );
$this->init();
}

View File

@ -356,7 +356,7 @@ class WP_Roles {
return $wp_user_roles;
}
if ( is_multisite() && $this->site_id != get_current_blog_id() ) {
if ( is_multisite() && get_current_blog_id() != $this->site_id ) {
remove_action( 'switch_blog', 'wp_switch_roles_and_user', 1 );
$roles = get_blog_option( $this->site_id, $this->role_key, array() );

View File

@ -46,7 +46,7 @@ class WP_SimplePie_Sanitize_KSES extends SimplePie_Sanitize {
}
if ( $type & ( SIMPLEPIE_CONSTRUCT_HTML | SIMPLEPIE_CONSTRUCT_XHTML ) ) {
$data = wp_kses_post( $data );
if ( $this->output_encoding !== 'UTF-8' ) {
if ( 'UTF-8' !== $this->output_encoding ) {
$data = $this->registry->call( 'Misc', 'change_encoding', array( $data, 'UTF-8', $this->output_encoding ) );
}
return $data;

View File

@ -1516,7 +1516,7 @@ final class WP_Theme implements ArrayAccess {
return (array) apply_filters( 'site_allowed_themes', $allowed_themes[ $blog_id ], $blog_id );
}
$current = $blog_id == get_current_blog_id();
$current = get_current_blog_id() == $blog_id;
if ( $current ) {
$allowed_themes[ $blog_id ] = get_option( 'allowedthemes' );

View File

@ -493,7 +493,7 @@ class WP_User {
*/
public function get_role_caps() {
$switch_site = false;
if ( is_multisite() && $this->site_id != get_current_blog_id() ) {
if ( is_multisite() && get_current_blog_id() != $this->site_id ) {
$switch_site = true;
switch_to_blog( $this->site_id );
@ -590,7 +590,7 @@ class WP_User {
* @param string $role Role name.
*/
public function set_role( $role ) {
if ( 1 == count( $this->roles ) && $role == current( $this->roles ) ) {
if ( 1 == count( $this->roles ) && current( $this->roles ) == $role ) {
return;
}

View File

@ -144,7 +144,7 @@ class Walker {
$this->start_el( $output, $element, $depth, ...array_values( $args ) );
// Descend only when the depth is right and there are childrens for this element.
if ( ( $max_depth == 0 || $max_depth > $depth + 1 ) && isset( $children_elements[ $id ] ) ) {
if ( ( 0 == $max_depth || $max_depth > $depth + 1 ) && isset( $children_elements[ $id ] ) ) {
foreach ( $children_elements[ $id ] as $child ) {
@ -248,7 +248,7 @@ class Walker {
* If we are displaying all levels, and remaining children_elements is not empty,
* then we got orphans, which should be displayed regardless.
*/
if ( ( $max_depth == 0 ) && count( $children_elements ) > 0 ) {
if ( ( 0 == $max_depth ) && count( $children_elements ) > 0 ) {
$empty_array = array();
foreach ( $children_elements as $orphans ) {
foreach ( $orphans as $op ) {

View File

@ -696,7 +696,7 @@ class wp_xmlrpc_server extends IXR_Server {
foreach ( $blogs as $blog ) {
// Don't include blogs that aren't hosted at this site.
if ( $blog->site_id != get_current_network_id() ) {
if ( get_current_network_id() != $blog->site_id ) {
continue;
}
@ -827,7 +827,7 @@ class wp_xmlrpc_server extends IXR_Server {
* @return IXR_Date IXR_Date object.
*/
protected function _convert_date( $date ) {
if ( $date === '0000-00-00 00:00:00' ) {
if ( '0000-00-00 00:00:00' === $date ) {
return new IXR_Date( '00000000T00:00:00Z' );
}
return new IXR_Date( mysql2date( 'Ymd\TH:i:s', $date, false ) );
@ -841,7 +841,7 @@ class wp_xmlrpc_server extends IXR_Server {
* @return IXR_Date IXR_Date object.
*/
protected function _convert_date_gmt( $date_gmt, $date ) {
if ( $date !== '0000-00-00 00:00:00' && $date_gmt === '0000-00-00 00:00:00' ) {
if ( '0000-00-00 00:00:00' !== $date && '0000-00-00 00:00:00' === $date_gmt ) {
return new IXR_Date( get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $date, false ), 'Ymd\TH:i:s' ) );
}
return $this->_convert_date( $date_gmt );
@ -879,7 +879,7 @@ class wp_xmlrpc_server extends IXR_Server {
'menu_order' => intval( $post['menu_order'] ),
'comment_status' => $post['comment_status'],
'ping_status' => $post['ping_status'],
'sticky' => ( $post['post_type'] === 'post' && is_sticky( $post['ID'] ) ),
'sticky' => ( 'post' === $post['post_type'] && is_sticky( $post['ID'] ) ),
);
// Thumbnail.
@ -891,7 +891,7 @@ class wp_xmlrpc_server extends IXR_Server {
}
// Consider future posts as published.
if ( $post_fields['post_status'] === 'future' ) {
if ( 'future' === $post_fields['post_status'] ) {
$post_fields['post_status'] = 'publish';
}
@ -1286,7 +1286,7 @@ class wp_xmlrpc_server extends IXR_Server {
* since _insert_post() will ignore the non-GMT date if the GMT date is set.
*/
if ( isset( $content_struct['post_date_gmt'] ) && ! ( $content_struct['post_date_gmt'] instanceof IXR_Date ) ) {
if ( $content_struct['post_date_gmt'] == '0000-00-00 00:00:00' || isset( $content_struct['post_date'] ) ) {
if ( '0000-00-00 00:00:00' === $content_struct['post_date_gmt'] || isset( $content_struct['post_date'] ) ) {
unset( $content_struct['post_date_gmt'] );
} else {
$content_struct['post_date_gmt'] = $this->_convert_date( $content_struct['post_date_gmt'] );
@ -1401,7 +1401,7 @@ class wp_xmlrpc_server extends IXR_Server {
if ( ! current_user_can( 'edit_post', $post_data['ID'] ) ) {
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
}
if ( $post_data['post_type'] != get_post_type( $post_data['ID'] ) ) {
if ( get_post_type( $post_data['ID'] ) !== $post_data['post_type'] ) {
return new IXR_Error( 401, __( 'The post type may not be changed.' ) );
}
} else {
@ -1451,11 +1451,11 @@ class wp_xmlrpc_server extends IXR_Server {
$post_data['post_author'] = $user->ID;
}
if ( isset( $post_data['comment_status'] ) && $post_data['comment_status'] != 'open' && $post_data['comment_status'] != 'closed' ) {
if ( isset( $post_data['comment_status'] ) && 'open' !== $post_data['comment_status'] && 'closed' !== $post_data['comment_status'] ) {
unset( $post_data['comment_status'] );
}
if ( isset( $post_data['ping_status'] ) && $post_data['ping_status'] != 'open' && $post_data['ping_status'] != 'closed' ) {
if ( isset( $post_data['ping_status'] ) && 'open' !== $post_data['ping_status'] && 'closed' !== $post_data['ping_status'] ) {
unset( $post_data['ping_status'] );
}
@ -1483,7 +1483,7 @@ class wp_xmlrpc_server extends IXR_Server {
}
$post_ID = $post_data['ID'];
if ( $post_data['post_type'] == 'post' ) {
if ( 'post' === $post_data['post_type'] ) {
$error = $this->_toggle_sticky( $post_data, $update );
if ( $error ) {
return $error;
@ -1708,7 +1708,7 @@ class wp_xmlrpc_server extends IXR_Server {
* Ignore the existing GMT date if it is empty or a non-GMT date was supplied in $content_struct,
* since _insert_post() will ignore the non-GMT date if the GMT date is set.
*/
if ( $post['post_date_gmt'] == '0000-00-00 00:00:00' || isset( $content_struct['post_date'] ) ) {
if ( '0000-00-00 00:00:00' === $post['post_date_gmt'] || isset( $content_struct['post_date'] ) ) {
unset( $post['post_date_gmt'] );
} else {
$post['post_date_gmt'] = $this->_convert_date( $post['post_date_gmt'] );
@ -2929,7 +2929,7 @@ class wp_xmlrpc_server extends IXR_Server {
do_action( 'xmlrpc_call', 'wp.getPage' );
// If we found the page then format the data.
if ( $page->ID && ( $page->post_type == 'page' ) ) {
if ( $page->ID && ( 'page' === $page->post_type ) ) {
return $this->_prepare_page( $page );
} else {
// If the page doesn't exist, indicate that.
@ -3066,7 +3066,7 @@ class wp_xmlrpc_server extends IXR_Server {
// Get the current page based on the 'page_id' and
// make sure it is a page and not a post.
$actual_page = get_post( $page_id, ARRAY_A );
if ( ! $actual_page || ( $actual_page['post_type'] != 'page' ) ) {
if ( ! $actual_page || ( 'page' !== $actual_page['post_type'] ) ) {
return new IXR_Error( 404, __( 'Sorry, no such page.' ) );
}
@ -3132,7 +3132,7 @@ class wp_xmlrpc_server extends IXR_Server {
// Get the page data and make sure it is a page.
$actual_page = get_post( $page_id, ARRAY_A );
if ( ! $actual_page || ( $actual_page['post_type'] != 'page' ) ) {
if ( ! $actual_page || ( 'page' !== $actual_page['post_type'] ) ) {
return new IXR_Error( 404, __( 'Sorry, no such page.' ) );
}
@ -4238,7 +4238,7 @@ class wp_xmlrpc_server extends IXR_Server {
continue;
}
if ( $this->blog_options[ $o_name ]['readonly'] == true ) {
if ( true == $this->blog_options[ $o_name ]['readonly'] ) {
continue;
}
@ -5114,7 +5114,7 @@ class wp_xmlrpc_server extends IXR_Server {
$actual_post = get_post( $post_ID, ARRAY_A );
if ( ! $actual_post || $actual_post['post_type'] != 'post' ) {
if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) {
return new IXR_Error( 404, __( 'Sorry, no such post.' ) );
}
@ -5123,7 +5123,7 @@ class wp_xmlrpc_server extends IXR_Server {
if ( ! current_user_can( 'edit_post', $post_ID ) ) {
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
}
if ( 'publish' == $actual_post['post_status'] && ! current_user_can( 'publish_posts' ) ) {
if ( 'publish' === $actual_post['post_status'] && ! current_user_can( 'publish_posts' ) ) {
return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) );
}
@ -5188,7 +5188,7 @@ class wp_xmlrpc_server extends IXR_Server {
$actual_post = get_post( $post_ID, ARRAY_A );
if ( ! $actual_post || $actual_post['post_type'] != 'post' ) {
if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) {
return new IXR_Error( 404, __( 'Sorry, no such post.' ) );
}
@ -5276,10 +5276,10 @@ class wp_xmlrpc_server extends IXR_Server {
$page_template = '';
if ( ! empty( $content_struct['post_type'] ) ) {
if ( $content_struct['post_type'] == 'page' ) {
if ( 'page' === $content_struct['post_type'] ) {
if ( $publish ) {
$cap = 'publish_pages';
} elseif ( isset( $content_struct['page_status'] ) && 'publish' == $content_struct['page_status'] ) {
} elseif ( isset( $content_struct['page_status'] ) && 'publish' === $content_struct['page_status'] ) {
$cap = 'publish_pages';
} else {
$cap = 'edit_pages';
@ -5289,10 +5289,10 @@ class wp_xmlrpc_server extends IXR_Server {
if ( ! empty( $content_struct['wp_page_template'] ) ) {
$page_template = $content_struct['wp_page_template'];
}
} elseif ( $content_struct['post_type'] == 'post' ) {
} elseif ( 'post' === $content_struct['post_type'] ) {
if ( $publish ) {
$cap = 'publish_posts';
} elseif ( isset( $content_struct['post_status'] ) && 'publish' == $content_struct['post_status'] ) {
} elseif ( isset( $content_struct['post_status'] ) && 'publish' === $content_struct['post_status'] ) {
$cap = 'publish_posts';
} else {
$cap = 'edit_posts';
@ -5306,7 +5306,7 @@ class wp_xmlrpc_server extends IXR_Server {
} else {
if ( $publish ) {
$cap = 'publish_posts';
} elseif ( isset( $content_struct['post_status'] ) && 'publish' == $content_struct['post_status'] ) {
} elseif ( isset( $content_struct['post_status'] ) && 'publish' === $content_struct['post_status'] ) {
$cap = 'publish_posts';
} else {
$cap = 'edit_posts';
@ -5513,7 +5513,7 @@ class wp_xmlrpc_server extends IXR_Server {
$postdata['ID'] = $post_ID;
// Only posts can be sticky.
if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) {
if ( 'post' === $post_type && isset( $content_struct['sticky'] ) ) {
$data = $postdata;
$data['sticky'] = $content_struct['sticky'];
$error = $this->_toggle_sticky( $data );
@ -5846,7 +5846,7 @@ class wp_xmlrpc_server extends IXR_Server {
$tags_input = isset( $content_struct['mt_keywords'] ) ? $content_struct['mt_keywords'] : null;
if ( 'publish' == $post_status || 'private' == $post_status ) {
if ( 'publish' === $post_status || 'private' === $post_status ) {
if ( 'page' == $post_type && ! current_user_can( 'publish_pages' ) ) {
return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this page.' ) );
} elseif ( ! current_user_can( 'publish_posts' ) ) {
@ -5901,7 +5901,7 @@ class wp_xmlrpc_server extends IXR_Server {
}
// Only posts can be sticky.
if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) {
if ( 'post' === $post_type && isset( $content_struct['sticky'] ) ) {
$data = $newpost;
$data['sticky'] = $content_struct['sticky'];
$data['post_type'] = 'post';
@ -5991,7 +5991,7 @@ class wp_xmlrpc_server extends IXR_Server {
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'metaWeblog.getPost' );
if ( $postdata['post_date'] != '' ) {
if ( '' != $postdata['post_date'] ) {
$post_date = $this->_convert_date( $postdata['post_date'] );
$post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] );
$post_modified = $this->_convert_date( $postdata['post_modified'] );
@ -6024,7 +6024,7 @@ class wp_xmlrpc_server extends IXR_Server {
$allow_pings = ( 'open' == $postdata['ping_status'] ) ? 1 : 0;
// Consider future posts as published.
if ( $postdata['post_status'] === 'future' ) {
if ( 'future' === $postdata['post_status'] ) {
$postdata['post_status'] = 'publish';
}
@ -6041,7 +6041,7 @@ class wp_xmlrpc_server extends IXR_Server {
$enclosure = array();
foreach ( (array) get_post_custom( $post_ID ) as $key => $val ) {
if ( $key == 'enclosure' ) {
if ( 'enclosure' === $key ) {
foreach ( (array) $val as $enc ) {
$encdata = explode( "\n", $enc );
$enclosure['url'] = trim( htmlspecialchars( $encdata[0] ) );
@ -6176,7 +6176,7 @@ class wp_xmlrpc_server extends IXR_Server {
$allow_pings = ( 'open' == $entry['ping_status'] ) ? 1 : 0;
// Consider future posts as published.
if ( $entry['post_status'] === 'future' ) {
if ( 'future' === $entry['post_status'] ) {
$entry['post_status'] = 'publish';
}
@ -6213,7 +6213,7 @@ class wp_xmlrpc_server extends IXR_Server {
'wp_post_format' => $post_format,
'date_modified' => $post_modified,
'date_modified_gmt' => $post_modified_gmt,
'sticky' => ( $entry['post_type'] === 'post' && is_sticky( $entry['ID'] ) ),
'sticky' => ( 'post' === $entry['post_type'] && is_sticky( $entry['ID'] ) ),
'wp_post_thumbnail' => get_post_thumbnail_id( $entry['ID'] ),
);
}
@ -6839,7 +6839,7 @@ class wp_xmlrpc_server extends IXR_Server {
return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either doesn&#8217;t exist, or it is not a pingback-enabled resource.' ) );
}
if ( $post_ID == url_to_postid( $pagelinkedfrom ) ) {
if ( url_to_postid( $pagelinkedfrom ) == $post_ID ) {
return $this->pingback_error( 0, __( 'The source URL and the target URL cannot both point to the same resource.' ) );
}

View File

@ -475,7 +475,7 @@ class WP_Scripts extends WP_Dependencies {
* @return bool True on success, false on failure.
*/
public function localize( $handle, $object_name, $l10n ) {
if ( $handle === 'jquery' ) {
if ( 'jquery' === $handle ) {
$handle = 'jquery-core';
}
@ -521,7 +521,7 @@ class WP_Scripts extends WP_Dependencies {
* @return bool Not already in the group or a lower group.
*/
public function set_group( $handle, $recursion, $group = false ) {
if ( isset( $this->registered[ $handle ]->args ) && $this->registered[ $handle ]->args === 1 ) {
if ( isset( $this->registered[ $handle ]->args ) && 1 === $this->registered[ $handle ]->args ) {
$grp = 1;
} else {
$grp = (int) $this->get_data( $handle, 'group' );

View File

@ -268,7 +268,7 @@ class WP_Styles extends WP_Dependencies {
/** This filter is documented in wp-includes/class.wp-styles.php */
$rtl_tag = apply_filters( 'style_loader_tag', $rtl_tag, $handle, $rtl_href, $media );
if ( $obj->extra['rtl'] === 'replace' ) {
if ( 'replace' === $obj->extra['rtl'] ) {
$tag = $rtl_tag;
} else {
$tag .= $rtl_tag;

View File

@ -192,8 +192,8 @@ function get_comment_author_email_link( $linktext = '', $before = '', $after = '
*/
$email = apply_filters( 'comment_email', $comment->comment_author_email, $comment );
if ( ( ! empty( $email ) ) && ( $email != '@' ) ) {
$display = ( $linktext != '' ) ? $linktext : $email;
if ( ( ! empty( $email ) ) && ( '@' !== $email ) ) {
$display = ( '' != $linktext ) ? $linktext : $email;
$return = $before;
$return .= sprintf( '<a href="%1$s">%2$s</a>', esc_url( 'mailto:' . $email ), esc_html( $display ) );
$return .= $after;
@ -376,7 +376,7 @@ function comment_author_url( $comment_ID = 0 ) {
*/
function get_comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 ) {
$url = get_comment_author_url( $comment );
$display = ( $linktext != '' ) ? $linktext : $url;
$display = ( '' != $linktext ) ? $linktext : $url;
$display = str_replace( 'http://www.', '', $display );
$display = str_replace( 'http://', '', $display );
@ -925,7 +925,7 @@ function get_comments_number_text( $zero = false, $one = false, $more = false )
$output = str_replace( '%', number_format_i18n( $number ), $more );
}
} elseif ( $number == 0 ) {
} elseif ( 0 == $number ) {
$output = ( false === $zero ) ? __( 'No Comments' ) : $zero;
} else { // Must be one.
$output = ( false === $one ) ? __( '1 Comment' ) : $one;
@ -2138,7 +2138,7 @@ function wp_list_comments( $args = array(), $comments = null ) {
* When first page shows oldest comments, post permalink is the same as
* the comment permalink.
*/
} elseif ( $cpage == 1 ) {
} elseif ( 1 == $cpage ) {
$parsed_args['cpage'] = '';
} else {
$parsed_args['cpage'] = $cpage;

View File

@ -127,7 +127,7 @@ function check_comment( $author, $email, $url, $comment, $user_ip, $user_agent,
* email address. If both checks pass, return true. Otherwise, return false.
*/
if ( 1 == get_option( 'comment_whitelist' ) ) {
if ( 'trackback' != $comment_type && 'pingback' != $comment_type && $author != '' && $email != '' ) {
if ( 'trackback' !== $comment_type && 'pingback' !== $comment_type && '' != $author && '' != $email ) {
$comment_user = get_user_by( 'email', wp_unslash( $email ) );
if ( ! empty( $comment_user->ID ) ) {
$ok_to_comment = $wpdb->get_var( $wpdb->prepare( "SELECT comment_approved FROM $wpdb->comments WHERE user_id = %d AND comment_approved = '1' LIMIT 1", $comment_user->ID ) );
@ -217,11 +217,11 @@ function get_comment( &$comment = null, $output = OBJECT ) {
*/
$_comment = apply_filters( 'get_comment', $_comment );
if ( $output == OBJECT ) {
if ( OBJECT == $output ) {
return $_comment;
} elseif ( $output == ARRAY_A ) {
} elseif ( ARRAY_A == $output ) {
return $_comment->to_array();
} elseif ( $output == ARRAY_N ) {
} elseif ( ARRAY_N == $output ) {
return array_values( $_comment->to_array() );
}
return $_comment;
@ -1429,7 +1429,7 @@ function wp_delete_comment( $comment_id, $force_delete = false ) {
do_action( 'deleted_comment', $comment->comment_ID, $comment );
$post_id = $comment->comment_post_ID;
if ( $post_id && $comment->comment_approved == 1 ) {
if ( $post_id && 1 == $comment->comment_approved ) {
wp_update_comment_count( $post_id );
}
@ -1655,15 +1655,15 @@ function wp_get_comment_status( $comment_id ) {
$approved = $comment->comment_approved;
if ( $approved == null ) {
if ( null == $approved ) {
return false;
} elseif ( $approved == '1' ) {
} elseif ( '1' == $approved ) {
return 'approved';
} elseif ( $approved == '0' ) {
} elseif ( '0' == $approved ) {
return 'unapproved';
} elseif ( $approved == 'spam' ) {
} elseif ( 'spam' == $approved ) {
return 'spam';
} elseif ( $approved == 'trash' ) {
} elseif ( 'trash' == $approved ) {
return 'trash';
} else {
return false;
@ -1913,7 +1913,7 @@ function wp_insert_comment( $commentdata ) {
$id = (int) $wpdb->insert_id;
if ( $comment_approved == 1 ) {
if ( 1 == $comment_approved ) {
wp_update_comment_count( $comment_post_ID );
foreach ( array( 'server', 'gmt', 'blog' ) as $timezone ) {
@ -2632,7 +2632,7 @@ function discover_pingback_server_uri( $url, $deprecated = '' ) {
$pingback_link_offset_squote = strpos( $contents, $pingback_str_squote );
if ( $pingback_link_offset_dquote || $pingback_link_offset_squote ) {
$quote = ( $pingback_link_offset_dquote ) ? '"' : '\'';
$pingback_link_offset = ( $quote == '"' ) ? $pingback_link_offset_dquote : $pingback_link_offset_squote;
$pingback_link_offset = ( '"' === $quote ) ? $pingback_link_offset_dquote : $pingback_link_offset_squote;
$pingback_href_pos = strpos( $contents, 'href=', $pingback_link_offset );
$pingback_href_start = $pingback_href_pos + 6;
$pingback_href_end = strpos( $contents, $quote, $pingback_href_start );
@ -2843,7 +2843,7 @@ function pingback( $content, $post_id ) {
if ( $test ) {
if ( isset( $test['query'] ) ) {
$post_links[] = $link_test;
} elseif ( isset( $test['path'] ) && ( $test['path'] != '/' ) && ( $test['path'] != '' ) ) {
} elseif ( isset( $test['path'] ) && ( '/' !== $test['path'] ) && ( '' !== $test['path'] ) ) {
$post_links[] = $link_test;
}
}
@ -3005,7 +3005,7 @@ function pingback_ping_source_uri( $source_uri ) {
* @return IXR_Error
*/
function xmlrpc_pingback_error( $ixr_error ) {
if ( $ixr_error->code === 48 ) {
if ( 48 === $ixr_error->code ) {
return $ixr_error;
}
return new IXR_Error( 0, '' );

View File

@ -312,7 +312,7 @@ if ( ! function_exists( 'hash_equals' ) ) :
*/
function hash_equals( $a, $b ) {
$a_length = strlen( $a );
if ( $a_length !== strlen( $b ) ) {
if ( strlen( $b ) !== $a_length ) {
return false;
}
$result = 0;
@ -322,7 +322,7 @@ if ( ! function_exists( 'hash_equals' ) ) :
$result |= ord( $a[ $i ] ) ^ ord( $b[ $i ] );
}
return $result === 0;
return 0 === $result;
}
endif;

View File

@ -211,7 +211,7 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting {
* @return array|false Instance data array, or false if the item is marked for deletion.
*/
public function value() {
if ( $this->is_previewed && $this->_previewed_blog_id === get_current_blog_id() ) {
if ( $this->is_previewed && get_current_blog_id() === $this->_previewed_blog_id ) {
$undefined = new stdClass(); // Symbol.
$post_value = $this->post_value( $undefined );
@ -798,7 +798,7 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting {
return;
}
if ( $nav_menu_setting->previous_term_id !== intval( $value['nav_menu_term_id'] ) ) {
if ( intval( $value['nav_menu_term_id'] ) !== $nav_menu_setting->previous_term_id ) {
$this->update_status = 'error';
$this->update_error = new WP_Error( 'unexpected_previous_term_id' );
return;
@ -824,7 +824,7 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting {
return;
}
if ( $parent_nav_menu_item_setting->previous_post_id !== intval( $value['menu_item_parent'] ) ) {
if ( intval( $value['menu_item_parent'] ) !== $parent_nav_menu_item_setting->previous_post_id ) {
$this->update_status = 'error';
$this->update_error = new WP_Error( 'unexpected_previous_post_id' );
return;

View File

@ -156,7 +156,7 @@ class WP_Customize_Nav_Menu_Setting extends WP_Customize_Setting {
* @return array Instance data.
*/
public function value() {
if ( $this->is_previewed && $this->_previewed_blog_id === get_current_blog_id() ) {
if ( $this->is_previewed && get_current_blog_id() === $this->_previewed_blog_id ) {
$undefined = new stdClass(); // Symbol.
$post_value = $this->post_value( $undefined );
@ -384,7 +384,7 @@ class WP_Customize_Nav_Menu_Setting extends WP_Customize_Setting {
* @return array (Maybe) modified nav menu options.
*/
public function filter_nav_menu_options( $nav_menu_options ) {
if ( $this->_previewed_blog_id !== get_current_blog_id() ) {
if ( get_current_blog_id() !== $this->_previewed_blog_id ) {
return $nav_menu_options;
}
@ -555,7 +555,7 @@ class WP_Customize_Nav_Menu_Setting extends WP_Customize_Setting {
}
$post_value = $setting->post_value( null );
if ( ! is_null( $post_value ) && $this->previous_term_id === intval( $post_value ) ) {
if ( ! is_null( $post_value ) && intval( $post_value ) === $this->previous_term_id ) {
$this->manager->set_post_value( $setting->id, $this->term_id );
$setting->save();
}

View File

@ -614,7 +614,7 @@ function get_oembed_response_data_for_url( $url, $args ) {
$sites = get_sites( $qv );
$site = reset( $sites );
if ( $site && (int) $site->blog_id !== get_current_blog_id() ) {
if ( $site && get_current_blog_id() !== (int) $site->blog_id ) {
switch_to_blog( $site->blog_id );
$switched_blog = true;
}

View File

@ -110,7 +110,7 @@ while ( have_comments() ) :
<?php
// Return comment threading information (https://www.ietf.org/rfc/rfc4685.txt).
if ( $comment->comment_parent == 0 ) : // This comment is top-level.
if ( 0 == $comment->comment_parent ) : // This comment is top-level.
?>
<thr:in-reply-to ref="<?php the_guid(); ?>" href="<?php the_permalink_rss(); ?>" type="<?php bloginfo_rss( 'html_type' ); ?>" />
<?php

View File

@ -471,7 +471,7 @@ function rss_enclosure() {
}
foreach ( (array) get_post_custom() as $key => $val ) {
if ( $key == 'enclosure' ) {
if ( 'enclosure' === $key ) {
foreach ( (array) $val as $enc ) {
$enclosure = explode( "\n", $enc );
@ -511,7 +511,7 @@ function atom_enclosure() {
}
foreach ( (array) get_post_custom() as $key => $val ) {
if ( $key == 'enclosure' ) {
if ( 'enclosure' === $key ) {
foreach ( (array) $val as $enc ) {
$enclosure = explode( "\n", $enc );
/**

View File

@ -479,7 +479,7 @@ function wpautop( $pee, $br = true ) {
$start = strpos( $pee_part, '<pre' );
// Malformed HTML?
if ( $start === false ) {
if ( false === $start ) {
$pee .= $pee_part;
continue;
}
@ -984,10 +984,10 @@ function _wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = fals
$_quote_style = $quote_style;
if ( $quote_style === 'double' ) {
if ( 'double' === $quote_style ) {
$quote_style = ENT_COMPAT;
$_quote_style = ENT_COMPAT;
} elseif ( $quote_style === 'single' ) {
} elseif ( 'single' === $quote_style ) {
$quote_style = ENT_NOQUOTES;
}
@ -1080,16 +1080,16 @@ function wp_specialchars_decode( $string, $quote_style = ENT_NOQUOTES ) {
'/&#x0*26;/i' => '&#x26;',
);
if ( $quote_style === ENT_QUOTES ) {
if ( ENT_QUOTES === $quote_style ) {
$translation = array_merge( $single, $double, $others );
$translation_preg = array_merge( $single_preg, $double_preg, $others_preg );
} elseif ( $quote_style === ENT_COMPAT || $quote_style === 'double' ) {
} elseif ( ENT_COMPAT === $quote_style || 'double' === $quote_style ) {
$translation = array_merge( $double, $others );
$translation_preg = array_merge( $double_preg, $others_preg );
} elseif ( $quote_style === 'single' ) {
} elseif ( 'single' === $quote_style ) {
$translation = array_merge( $single, $others );
$translation_preg = array_merge( $single_preg, $others_preg );
} elseif ( $quote_style === ENT_NOQUOTES ) {
} elseif ( ENT_NOQUOTES === $quote_style ) {
$translation = $others;
$translation_preg = $others_preg;
}
@ -2793,11 +2793,11 @@ function antispambot( $email_address, $hex_encoding = 0 ) {
$email_no_spam_address = '';
for ( $i = 0, $len = strlen( $email_address ); $i < $len; $i++ ) {
$j = rand( 0, 1 + $hex_encoding );
if ( $j == 0 ) {
if ( 0 == $j ) {
$email_no_spam_address .= '&#' . ord( $email_address[ $i ] ) . ';';
} elseif ( $j == 1 ) {
} elseif ( 1 == $j ) {
$email_no_spam_address .= $email_address[ $i ];
} elseif ( $j == 2 ) {
} elseif ( 2 == $j ) {
$email_no_spam_address .= '%' . zeroise( dechex( ord( $email_address[ $i ] ) ), 2 );
}
}
@ -2938,7 +2938,7 @@ function make_clickable( $text ) {
$nested_code_pre--;
}
if ( $nested_code_pre || empty( $piece ) || ( $piece[0] === '<' && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) ) ) {
if ( $nested_code_pre || empty( $piece ) || ( '<' === $piece[0] && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) ) ) {
$r .= $piece;
continue;
}
@ -3552,7 +3552,7 @@ function get_date_from_gmt( $string, $format = 'Y-m-d H:i:s' ) {
*/
function iso8601_timezone_to_offset( $timezone ) {
// $timezone is either 'Z' or '[+|-]hhmm'.
if ( $timezone == 'Z' ) {
if ( 'Z' === $timezone ) {
$offset = 0;
} else {
$sign = ( substr( $timezone, 0, 1 ) == '+' ) ? 1 : -1;
@ -4626,7 +4626,7 @@ function sanitize_option( $option, $value ) {
case 'default_ping_status':
case 'default_comment_status':
// Options that if not there have 0 value but need to be something like "closed".
if ( $value == '0' || $value == '' ) {
if ( '0' == $value || '' == $value ) {
$value = 'closed';
}
break;
@ -4972,7 +4972,7 @@ function wp_sprintf( $pattern, ...$args ) {
$fragment = substr( $pattern, $start, $end - $start );
// Fragment has a specifier.
if ( $pattern[ $start ] == '%' ) {
if ( '%' === $pattern[ $start ] ) {
// Find numbered arguments or take the next one in order.
if ( preg_match( '/^%(\d+)\$/', $fragment, $matches ) ) {
$index = $matches[1] - 1; // 0-based array vs 1-based sprintf() arguments.

View File

@ -686,7 +686,7 @@ function is_serialized_string( $data ) {
return false;
} elseif ( ';' !== substr( $data, -1 ) ) {
return false;
} elseif ( $data[0] !== 's' ) {
} elseif ( 's' !== $data[0] ) {
return false;
} elseif ( '"' !== substr( $data, -2, 1 ) ) {
return false;
@ -1013,15 +1013,15 @@ function _http_build_query( $data, $prefix = null, $sep = null, $key = '', $urle
if ( $urlencode ) {
$k = urlencode( $k );
}
if ( is_int( $k ) && $prefix != null ) {
if ( is_int( $k ) && null != $prefix ) {
$k = $prefix . $k;
}
if ( ! empty( $key ) ) {
$k = $key . '%5B' . $k . '%5D';
}
if ( $v === null ) {
if ( null === $v ) {
continue;
} elseif ( $v === false ) {
} elseif ( false === $v ) {
$v = '0';
}
@ -1132,7 +1132,7 @@ function add_query_arg( ...$args ) {
}
foreach ( $qs as $k => $v ) {
if ( $v === false ) {
if ( false === $v ) {
unset( $qs[ $k ] );
}
}
@ -1539,7 +1539,7 @@ function do_feed() {
// Remove the pad, if present.
$feed = preg_replace( '/^_+/', '', $feed );
if ( $feed == '' || $feed == 'feed' ) {
if ( '' == $feed || 'feed' === $feed ) {
$feed = get_default_feed();
}
@ -1885,7 +1885,7 @@ function wp_get_referer() {
$ref = wp_get_raw_referer();
if ( $ref && $ref !== wp_unslash( $_SERVER['REQUEST_URI'] ) && $ref !== home_url() . wp_unslash( $_SERVER['REQUEST_URI'] ) ) {
if ( $ref && wp_unslash( $_SERVER['REQUEST_URI'] ) !== $ref && home_url() . wp_unslash( $_SERVER['REQUEST_URI'] ) !== $ref ) {
return wp_validate_redirect( $ref, false );
}
@ -1947,7 +1947,7 @@ function wp_mkdir_p( $target ) {
$target = str_replace( '//', '/', $target );
// Put the wrapper back on the target.
if ( $wrapper !== null ) {
if ( null !== $wrapper ) {
$target = $wrapper . '://' . $target;
}
@ -1989,7 +1989,7 @@ function wp_mkdir_p( $target ) {
* If a umask is set that modifies $dir_perms, we'll have to re-set
* the $dir_perms correctly with chmod()
*/
if ( $dir_perms != ( $dir_perms & ~umask() ) ) {
if ( ( $dir_perms & ~umask() ) != $dir_perms ) {
$folder_parts = explode( '/', substr( $target, strlen( $target_parent ) + 1 ) );
for ( $i = 1, $c = count( $folder_parts ); $i <= $c; $i++ ) {
chmod( $target_parent . '/' . implode( '/', array_slice( $folder_parts, 0, $i ) ), $dir_perms );
@ -2029,7 +2029,7 @@ function path_is_absolute( $path ) {
return true;
}
if ( strlen( $path ) == 0 || $path[0] == '.' ) {
if ( strlen( $path ) == 0 || '.' === $path[0] ) {
return false;
}
@ -2039,7 +2039,7 @@ function path_is_absolute( $path ) {
}
// A path starting with / or \ is absolute; anything else is relative.
return ( $path[0] == '/' || $path[0] == '\\' );
return ( '/' === $path[0] || '\\' === $path[0] );
}
/**
@ -2185,7 +2185,7 @@ function wp_is_writable( $path ) {
* @return bool Whether the path is writable.
*/
function win_is_writable( $path ) {
if ( $path[ strlen( $path ) - 1 ] == '/' ) {
if ( '/' === $path[ strlen( $path ) - 1 ] ) {
// If it looks like a directory, check a random file within the directory.
return win_is_writable( $path . uniqid( mt_rand() ) . '.tmp' );
} elseif ( is_dir( $path ) ) {
@ -2197,7 +2197,7 @@ function win_is_writable( $path ) {
$should_delete_tmp_file = ! file_exists( $path );
$f = @fopen( $path, 'a' );
if ( $f === false ) {
if ( false === $f ) {
return false;
}
fclose( $f );
@ -2633,7 +2633,7 @@ function wp_upload_bits( $name, $deprecated, $bits, $time = null ) {
$upload = wp_upload_dir( $time );
if ( $upload['error'] !== false ) {
if ( false !== $upload['error'] ) {
return $upload;
}
@ -4321,7 +4321,7 @@ function smilies_init() {
// New subpattern?
if ( $firstchar != $subchar ) {
if ( $subchar != '' ) {
if ( '' != $subchar ) {
$wp_smiliessearch .= ')(?=' . $spaces . '|$)'; // End previous "subpattern".
$wp_smiliessearch .= '|(?<=' . $spaces . '|^)'; // Begin another "subpattern".
}
@ -5461,7 +5461,7 @@ function is_main_site( $site_id = null, $network_id = null ) {
$site_id = (int) $site_id;
return $site_id === get_main_site_id( $network_id );
return get_main_site_id( $network_id ) === $site_id;
}
/**
@ -5505,7 +5505,7 @@ function is_main_network( $network_id = null ) {
$network_id = (int) $network_id;
return ( $network_id === get_main_network_id() );
return ( get_main_network_id() === $network_id );
}
/**
@ -7513,7 +7513,7 @@ function recurse_dirsize( $directory, $exclude = null, $max_execution_time = nul
return false;
}
if ( $max_execution_time === null ) {
if ( null === $max_execution_time ) {
// Keep the previous behavior but attempt to prevent fatal errors from timeout if possible.
if ( function_exists( 'ini_get' ) ) {
$max_execution_time = ini_get( 'max_execution_time' );
@ -7532,7 +7532,7 @@ function recurse_dirsize( $directory, $exclude = null, $max_execution_time = nul
if ( $handle ) {
while ( ( $file = readdir( $handle ) ) !== false ) {
$path = $directory . '/' . $file;
if ( $file != '.' && $file != '..' ) {
if ( '.' !== $file && '..' !== $file ) {
if ( is_file( $path ) ) {
$size += filesize( $path );
} elseif ( is_dir( $path ) ) {

View File

@ -856,7 +856,7 @@ function get_bloginfo( $show = '', $filter = 'raw' ) {
function get_site_icon_url( $size = 512, $url = '', $blog_id = 0 ) {
$switched_blog = false;
if ( is_multisite() && ! empty( $blog_id ) && (int) $blog_id !== get_current_blog_id() ) {
if ( is_multisite() && ! empty( $blog_id ) && get_current_blog_id() !== (int) $blog_id ) {
switch_to_blog( $blog_id );
$switched_blog = true;
}
@ -924,7 +924,7 @@ function has_site_icon( $blog_id = 0 ) {
function has_custom_logo( $blog_id = 0 ) {
$switched_blog = false;
if ( is_multisite() && ! empty( $blog_id ) && (int) $blog_id !== get_current_blog_id() ) {
if ( is_multisite() && ! empty( $blog_id ) && get_current_blog_id() !== (int) $blog_id ) {
switch_to_blog( $blog_id );
$switched_blog = true;
}
@ -950,7 +950,7 @@ function get_custom_logo( $blog_id = 0 ) {
$html = '';
$switched_blog = false;
if ( is_multisite() && ! empty( $blog_id ) && (int) $blog_id !== get_current_blog_id() ) {
if ( is_multisite() && ! empty( $blog_id ) && get_current_blog_id() !== (int) $blog_id ) {
switch_to_blog( $blog_id );
$switched_blog = true;
}
@ -1846,7 +1846,7 @@ function wp_get_archives( $args = '' ) {
}
$order = strtoupper( $parsed_args['order'] );
if ( $order !== 'ASC' ) {
if ( 'ASC' !== $order ) {
$order = 'DESC';
}
@ -2006,7 +2006,7 @@ function wp_get_archives( $args = '' ) {
}
if ( $results ) {
foreach ( (array) $results as $result ) {
if ( $result->post_date != '0000-00-00 00:00:00' ) {
if ( '0000-00-00 00:00:00' !== $result->post_date ) {
$url = get_permalink( $result );
if ( $result->post_title ) {
/** This filter is documented in wp-includes/post-template.php */
@ -2014,7 +2014,7 @@ function wp_get_archives( $args = '' ) {
} else {
$text = $result->ID;
}
$selected = $result->ID === get_the_ID();
$selected = get_the_ID() === $result->ID;
$output .= get_archives_link( $url, $text, $parsed_args['format'], $parsed_args['before'], $parsed_args['after'], $selected );
}
}
@ -2227,9 +2227,9 @@ function get_calendar( $initial = true, $echo = true ) {
}
$newrow = false;
if ( $day == current_time( 'j' ) &&
$thismonth == current_time( 'm' ) &&
$thisyear == current_time( 'Y' ) ) {
if ( current_time( 'j' ) == $day &&
current_time( 'm' ) == $thismonth &&
current_time( 'Y' ) == $thisyear ) {
$calendar_output .= '<td id="today">';
} else {
$calendar_output .= '<td>';
@ -2257,7 +2257,7 @@ function get_calendar( $initial = true, $echo = true ) {
}
$pad = 7 - calendar_week_mod( gmdate( 'w', mktime( 0, 0, 0, $thismonth, $day, $thisyear ) ) - $week_begins );
if ( $pad != 0 && $pad != 7 ) {
if ( 0 != $pad && 7 != $pad ) {
$calendar_output .= "\n\t\t" . '<td class="pad" colspan="' . esc_attr( $pad ) . '">&nbsp;</td>';
}
$calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
@ -3960,11 +3960,11 @@ function get_language_attributes( $doctype = 'html' ) {
$lang = get_bloginfo( 'language' );
if ( $lang ) {
if ( get_option( 'html_type' ) == 'text/html' || $doctype == 'html' ) {
if ( 'text/html' === get_option( 'html_type' ) || 'html' === $doctype ) {
$attributes[] = 'lang="' . esc_attr( $lang ) . '"';
}
if ( get_option( 'html_type' ) != 'text/html' || $doctype == 'xhtml' ) {
if ( 'text/html' !== get_option( 'html_type' ) || 'xhtml' === $doctype ) {
$attributes[] = 'xml:lang="' . esc_attr( $lang ) . '"';
}
}

View File

@ -632,7 +632,7 @@ function ms_allowed_http_request_hosts( $is_external, $host ) {
if ( $is_external ) {
return $is_external;
}
if ( $host === get_network()->domain ) {
if ( get_network()->domain === $host ) {
return true;
}
if ( isset( $queried[ $host ] ) ) {

View File

@ -1046,10 +1046,10 @@ function wp_kses_split2( $string, $allowed_html, $allowed_protocols ) {
// Allow HTML comments.
if ( '<!--' == substr( $string, 0, 4 ) ) {
$string = str_replace( array( '<!--', '-->' ), '', $string );
while ( $string != ( $newstring = wp_kses( $string, $allowed_html, $allowed_protocols ) ) ) {
while ( ( $newstring = wp_kses( $string, $allowed_html, $allowed_protocols ) ) != $string ) {
$string = $newstring;
}
if ( $string == '' ) {
if ( '' == $string ) {
return '';
}
// Prevent multiple dashes in comments.
@ -1078,7 +1078,7 @@ function wp_kses_split2( $string, $allowed_html, $allowed_protocols ) {
}
// No attributes are allowed for closing elements.
if ( $slash != '' ) {
if ( '' != $slash ) {
return "</$elem>";
}
@ -1348,13 +1348,13 @@ function wp_kses_hair( $attr, $allowed_protocols ) {
break;
} // End switch.
if ( $working == 0 ) { // Not well-formed, remove and try again.
if ( 0 == $working ) { // Not well-formed, remove and try again.
$attr = wp_kses_html_error( $attr );
$mode = 0;
}
} // End while.
if ( $mode == 1 && false === array_key_exists( $attrname, $attrarr ) ) {
if ( 1 == $mode && false === array_key_exists( $attrname, $attrarr ) ) {
// Special case, for when the attribute list ends with a valueless
// attribute like "selected".
$attrarr[ $attrname ] = array(
@ -1845,10 +1845,10 @@ function wp_kses_normalize_entities3( $matches ) {
* @return bool Whether or not the codepoint is a valid Unicode codepoint.
*/
function valid_unicode( $i ) {
return ( $i == 0x9 || $i == 0xa || $i == 0xd ||
( $i >= 0x20 && $i <= 0xd7ff ) ||
( $i >= 0xe000 && $i <= 0xfffd ) ||
( $i >= 0x10000 && $i <= 0x10ffff ) );
return ( 0x9 == $i || 0xa == $i || 0xd == $i ||
( 0x20 <= $i && $i <= 0xd7ff ) ||
( 0xe000 <= $i && $i <= 0xfffd ) ||
( 0x10000 <= $i && $i <= 0x10ffff ) );
}
/**
@ -2244,7 +2244,7 @@ function safecss_filter_attr( $css, $deprecated = '' ) {
$css = '';
foreach ( $css_array as $css_item ) {
if ( $css_item == '' ) {
if ( '' == $css_item ) {
continue;
}
@ -2282,7 +2282,7 @@ function safecss_filter_attr( $css, $deprecated = '' ) {
$url = trim( $url_pieces[2] );
if ( empty( $url ) || $url !== wp_kses_bad_protocol( $url, $allowed_protocols ) ) {
if ( empty( $url ) || wp_kses_bad_protocol( $url, $allowed_protocols ) !== $url ) {
$found = false;
break;
} else {
@ -2302,7 +2302,7 @@ function safecss_filter_attr( $css, $deprecated = '' ) {
// Remove any CSS containing containing \ ( & } = or comments, except for url() useage checked above.
if ( $found && ! preg_match( '%[\\\(&=}]|/\*%', $css_test_string ) ) {
if ( $css != '' ) {
if ( '' != $css ) {
$css .= ';';
}

Some files were not shown because too many files have changed in this diff Show More