diff options
160 files changed, 1144 insertions, 1008 deletions
diff --git a/src/wp-admin/admin-header.php b/src/wp-admin/admin-header.php index 43f91483bc..9045620aa8 100644 --- a/src/wp-admin/admin-header.php +++ b/src/wp-admin/admin-header.php @@ -147,7 +147,7 @@ do_action( "admin_head-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConven */ do_action( 'admin_head' ); -if ( get_user_setting( 'mfold' ) === 'f' ) { +if ( 'f' === get_user_setting( 'mfold' ) ) { $admin_body_class .= ' folded'; } diff --git a/src/wp-admin/edit-form-advanced.php b/src/wp-admin/edit-form-advanced.php index 20aea33a3f..390fe7d254 100644 --- a/src/wp-admin/edit-form-advanced.php +++ b/src/wp-admin/edit-form-advanced.php @@ -59,7 +59,7 @@ if ( post_type_supports( $post_type, 'editor' ) && ! wp_is_mobile() && wp_enqueue_script( 'editor-expand' ); $_content_editor_dfw = true; - $_wp_editor_expand = ( get_user_setting( 'editor_expand', 'on' ) === 'on' ); + $_wp_editor_expand = ( 'on' === get_user_setting( 'editor_expand', 'on' ) ); } if ( wp_is_mobile() ) { diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php index 3b551db6c0..8f0d1f8822 100644 --- a/src/wp-admin/includes/ajax-actions.php +++ b/src/wp-admin/includes/ajax-actions.php @@ -176,7 +176,7 @@ function wp_ajax_wp_compression_test() { wp_die( -1 ); } - if ( ini_get( 'zlib.output_compression' ) || 'ob_gzhandler' == ini_get( 'output_handler' ) ) { + if ( ini_get( 'zlib.output_compression' ) || 'ob_gzhandler' === ini_get( 'output_handler' ) ) { update_site_option( 'can_compress_scripts', 0 ); wp_die( 0 ); } @@ -209,10 +209,10 @@ function wp_ajax_wp_compression_test() { echo $out; wp_die(); - } elseif ( 'no' == $_GET['test'] ) { + } elseif ( 'no' === $_GET['test'] ) { check_ajax_referer( 'update_can_compress_scripts' ); update_site_option( 'can_compress_scripts', 0 ); - } elseif ( 'yes' == $_GET['test'] ) { + } elseif ( 'yes' === $_GET['test'] ) { check_ajax_referer( 'update_can_compress_scripts' ); update_site_option( 'can_compress_scripts', 1 ); } @@ -704,13 +704,13 @@ function wp_ajax_delete_comment() { $delta = -1; if ( isset( $_POST['trash'] ) && 1 == $_POST['trash'] ) { - if ( 'trash' == $status ) { + if ( 'trash' === $status ) { wp_die( time() ); } $r = wp_trash_comment( $comment ); } elseif ( isset( $_POST['untrash'] ) && 1 == $_POST['untrash'] ) { - if ( 'trash' != $status ) { + if ( 'trash' !== $status ) { wp_die( time() ); } @@ -721,13 +721,13 @@ function wp_ajax_delete_comment() { $delta = 1; } } elseif ( isset( $_POST['spam'] ) && 1 == $_POST['spam'] ) { - if ( 'spam' == $status ) { + if ( 'spam' === $status ) { wp_die( time() ); } $r = wp_spam_comment( $comment ); } elseif ( isset( $_POST['unspam'] ) && 1 == $_POST['unspam'] ) { - if ( 'spam' != $status ) { + if ( 'spam' !== $status ) { wp_die( time() ); } @@ -883,7 +883,7 @@ function wp_ajax_trash_post( $action ) { wp_die( 1 ); } - if ( 'trash-post' == $action ) { + if ( 'trash-post' === $action ) { $done = wp_trash_post( $id ); } else { $done = wp_untrash_post( $id ); @@ -1301,7 +1301,7 @@ function wp_ajax_replyto_comment( $action ) { wp_die( __( 'Sorry, you must be logged in to reply to a comment.' ) ); } - if ( '' == $comment_content ) { + if ( '' === $comment_content ) { wp_die( __( 'Error: Please type a comment.' ) ); } @@ -1344,11 +1344,11 @@ function wp_ajax_replyto_comment( $action ) { $position = ( isset( $_POST['position'] ) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1'; ob_start(); - if ( isset( $_REQUEST['mode'] ) && 'dashboard' == $_REQUEST['mode'] ) { + if ( isset( $_REQUEST['mode'] ) && 'dashboard' === $_REQUEST['mode'] ) { require_once ABSPATH . 'wp-admin/includes/dashboard.php'; _wp_dashboard_recent_comments_row( $comment ); } else { - if ( isset( $_REQUEST['mode'] ) && 'single' == $_REQUEST['mode'] ) { + if ( isset( $_REQUEST['mode'] ) && 'single' === $_REQUEST['mode'] ) { $wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) ); } else { $wp_list_table = _get_list_table( 'WP_Comments_List_Table', array( 'screen' => 'edit-comments' ) ); @@ -1403,7 +1403,7 @@ function wp_ajax_edit_comment() { wp_die( -1 ); } - if ( '' == $_POST['content'] ) { + if ( '' === $_POST['content'] ) { wp_die( __( 'Error: Please type a comment.' ) ); } @@ -1461,7 +1461,7 @@ function wp_ajax_add_menu_item() { foreach ( (array) $_POST['menu-item'] as $menu_item_data ) { if ( ! empty( $menu_item_data['menu-item-type'] ) && - 'custom' != $menu_item_data['menu-item-type'] && + 'custom' !== $menu_item_data['menu-item-type'] && ! empty( $menu_item_data['menu-item-object-id'] ) ) { switch ( $menu_item_data['menu-item-type'] ) { @@ -1544,7 +1544,7 @@ function wp_ajax_add_meta() { wp_die( -1 ); } - if ( isset( $_POST['metakeyselect'] ) && '#NONE#' == $_POST['metakeyselect'] && empty( $_POST['metakeyinput'] ) ) { + if ( isset( $_POST['metakeyselect'] ) && '#NONE#' === $_POST['metakeyselect'] && empty( $_POST['metakeyinput'] ) ) { wp_die( 1 ); } @@ -1604,7 +1604,7 @@ function wp_ajax_add_meta() { $key = wp_unslash( $_POST['meta'][ $mid ]['key'] ); $value = wp_unslash( $_POST['meta'][ $mid ]['value'] ); - if ( '' == trim( $key ) ) { + if ( '' === trim( $key ) ) { wp_die( __( 'Please provide a custom field name.' ) ); } @@ -1795,11 +1795,11 @@ function wp_ajax_menu_get_metabox() { require_once ABSPATH . 'wp-admin/includes/nav-menu.php'; - if ( isset( $_POST['item-type'] ) && 'post_type' == $_POST['item-type'] ) { + if ( isset( $_POST['item-type'] ) && 'post_type' === $_POST['item-type'] ) { $type = 'posttype'; $callback = 'wp_nav_menu_item_post_type_meta_box'; $items = (array) get_post_types( array( 'show_in_nav_menus' => true ), 'object' ); - } elseif ( isset( $_POST['item-type'] ) && 'taxonomy' == $_POST['item-type'] ) { + } elseif ( isset( $_POST['item-type'] ) && 'taxonomy' === $_POST['item-type'] ) { $type = 'taxonomy'; $callback = 'wp_nav_menu_item_taxonomy_meta_box'; $items = (array) get_taxonomies( array( 'show_ui' => true ), 'object' ); @@ -1985,7 +1985,7 @@ function wp_ajax_inline_save() { $post_ID = (int) $_POST['post_ID']; - if ( 'page' == $_POST['post_type'] ) { + if ( 'page' === $_POST['post_type'] ) { if ( ! current_user_can( 'edit_page', $post_ID ) ) { wp_die( __( 'Sorry, you are not allowed to edit this page.' ) ); } @@ -2030,7 +2030,7 @@ function wp_ajax_inline_save() { } // Status. - if ( isset( $data['keep_private'] ) && 'private' == $data['keep_private'] ) { + if ( isset( $data['keep_private'] ) && 'private' === $data['keep_private'] ) { $data['visibility'] = 'private'; $data['post_status'] = 'private'; } else { @@ -2180,7 +2180,7 @@ function wp_ajax_find_posts() { $alt = ''; foreach ( $posts as $post ) { $title = trim( $post->post_title ) ? $post->post_title : __( '(no title)' ); - $alt = ( 'alternate' == $alt ) ? '' : 'alternate'; + $alt = ( 'alternate' === $alt ) ? '' : 'alternate'; switch ( $post->post_status ) { case 'publish': @@ -2198,7 +2198,7 @@ function wp_ajax_find_posts() { break; } - if ( '0000-00-00 00:00:00' == $post->post_date ) { + if ( '0000-00-00 00:00:00' === $post->post_date ) { $time = ''; } else { /* translators: Date format in table columns, see https://www.php.net/date */ @@ -2883,7 +2883,7 @@ function wp_ajax_get_attachment() { wp_send_json_error(); } - if ( 'attachment' != $post->post_type ) { + if ( 'attachment' !== $post->post_type ) { wp_send_json_error(); } @@ -2996,7 +2996,7 @@ function wp_ajax_save_attachment() { $changes = $_REQUEST['changes']; $post = get_post( $id, ARRAY_A ); - if ( 'attachment' != $post['post_type'] ) { + if ( 'attachment' !== $post['post_type'] ) { wp_send_json_error(); } @@ -3087,7 +3087,7 @@ function wp_ajax_save_attachment_compat() { $post = get_post( $id, ARRAY_A ); - if ( 'attachment' != $post['post_type'] ) { + if ( 'attachment' !== $post['post_type'] ) { wp_send_json_error(); } @@ -3154,7 +3154,7 @@ function wp_ajax_save_attachment_order() { continue; } - if ( 'attachment' != $attachment->post_type ) { + if ( 'attachment' !== $attachment->post_type ) { continue; } @@ -3190,7 +3190,7 @@ function wp_ajax_send_attachment_to_editor() { wp_send_json_error(); } - if ( 'attachment' != $post->post_type ) { + if ( 'attachment' !== $post->post_type ) { wp_send_json_error(); } @@ -3304,7 +3304,7 @@ function wp_ajax_send_link_to_editor() { $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src ); if ( $ext ) { $ext_type = wp_ext2type( $ext ); - if ( 'audio' == $ext_type || 'video' == $ext_type ) { + if ( 'audio' === $ext_type || 'video' === $ext_type ) { $type = $ext_type; } } diff --git a/src/wp-admin/includes/bookmark.php b/src/wp-admin/includes/bookmark.php index ededc33fa4..124f9cf698 100644 --- a/src/wp-admin/includes/bookmark.php +++ b/src/wp-admin/includes/bookmark.php @@ -39,7 +39,7 @@ function edit_link( $link_id = 0 ) { $_POST['link_name'] = esc_html( $_POST['link_name'] ); $_POST['link_image'] = esc_html( $_POST['link_image'] ); $_POST['link_rss'] = esc_url( $_POST['link_rss'] ); - if ( ! isset( $_POST['link_visible'] ) || 'N' != $_POST['link_visible'] ) { + if ( ! isset( $_POST['link_visible'] ) || 'N' !== $_POST['link_visible'] ) { $_POST['link_visible'] = 'Y'; } @@ -174,15 +174,15 @@ function wp_insert_link( $linkdata, $wp_error = false ) { $update = true; } - if ( trim( $link_name ) == '' ) { - if ( trim( $link_url ) != '' ) { + if ( '' === trim( $link_name ) ) { + if ( '' !== trim( $link_url ) ) { $link_name = $link_url; } else { return 0; } } - if ( trim( $link_url ) == '' ) { + if ( '' === trim( $link_url ) ) { return 0; } @@ -309,7 +309,8 @@ function wp_update_link( $linkdata ) { */ function wp_link_manager_disabled_message() { global $pagenow; - if ( 'link-manager.php' != $pagenow && 'link-add.php' != $pagenow && 'link.php' != $pagenow ) { + + if ( ! in_array( $pagenow, array( 'link-manager.php', 'link-add.php', 'link.php' ), true ) ) { return; } diff --git a/src/wp-admin/includes/class-core-upgrader.php b/src/wp-admin/includes/class-core-upgrader.php index 7c782606d3..7ef49f1f1c 100644 --- a/src/wp-admin/includes/class-core-upgrader.php +++ b/src/wp-admin/includes/class-core-upgrader.php @@ -104,7 +104,7 @@ class Core_Upgrader extends WP_Upgrader { */ if ( $parsed_args['do_rollback'] && $current->packages->rollback ) { $to_download = 'rollback'; - } elseif ( $current->packages->partial && 'reinstall' != $current->response && $wp_version == $current->partial_version && $partial ) { + } elseif ( $current->packages->partial && 'reinstall' !== $current->response && $wp_version == $current->partial_version && $partial ) { $to_download = 'partial'; } elseif ( $current->packages->new_bundled && version_compare( $wp_version, $current->new_bundled, '<' ) && ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' ) || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) ) { @@ -402,7 +402,7 @@ class Core_Upgrader extends WP_Upgrader { foreach ( $checksums as $file => $checksum ) { // Skip files which get updated. - if ( 'wp-content' == substr( $file, 0, 10 ) ) { + if ( 'wp-content' === substr( $file, 0, 10 ) ) { continue; } if ( ! file_exists( ABSPATH . $file ) || md5_file( ABSPATH . $file ) !== $checksum ) { diff --git a/src/wp-admin/includes/class-custom-image-header.php b/src/wp-admin/includes/class-custom-image-header.php index a8264d5bb7..fe0a2e5015 100644 --- a/src/wp-admin/includes/class-custom-image-header.php +++ b/src/wp-admin/includes/class-custom-image-header.php @@ -281,7 +281,7 @@ class Custom_Image_Header { * or 'uploaded' (for the Uploaded Images control). */ public function show_header_selector( $type = 'default' ) { - if ( 'default' == $type ) { + if ( 'default' === $type ) { $headers = $this->default_headers; } else { $headers = get_uploaded_header_images(); @@ -359,7 +359,7 @@ class Custom_Image_Header { if ( ! checked ) return; text_color = $('#text-color'); - if ( '' == text_color.val().replace('#', '') ) { + if ( '' === text_color.val().replace('#', '') ) { text_color.val( default_color ); pickColor( default_color ); } else { diff --git a/src/wp-admin/includes/class-language-pack-upgrader.php b/src/wp-admin/includes/class-language-pack-upgrader.php index 0ae18d9e50..e88db55848 100644 --- a/src/wp-admin/includes/class-language-pack-upgrader.php +++ b/src/wp-admin/includes/class-language-pack-upgrader.php @@ -188,7 +188,7 @@ class Language_Pack_Upgrader extends WP_Upgrader { return true; } - if ( 'upgrader_process_complete' == current_filter() ) { + if ( 'upgrader_process_complete' === current_filter() ) { $this->skin->feedback( 'starting_upgrade' ); } @@ -232,9 +232,9 @@ class Language_Pack_Upgrader extends WP_Upgrader { $this->skin->language_update = $language_update; $destination = WP_LANG_DIR; - if ( 'plugin' == $language_update->type ) { + if ( 'plugin' === $language_update->type ) { $destination .= '/plugins'; - } elseif ( 'theme' == $language_update->type ) { + } elseif ( 'theme' === $language_update->type ) { $destination .= '/themes'; } @@ -335,9 +335,9 @@ class Language_Pack_Upgrader extends WP_Upgrader { $po = false; $mo = false; foreach ( (array) $files as $file => $filedata ) { - if ( '.po' == substr( $file, -3 ) ) { + if ( '.po' === substr( $file, -3 ) ) { $po = true; - } elseif ( '.mo' == substr( $file, -3 ) ) { + } elseif ( '.mo' === substr( $file, -3 ) ) { $mo = true; } } diff --git a/src/wp-admin/includes/class-plugin-installer-skin.php b/src/wp-admin/includes/class-plugin-installer-skin.php index 9ee23be90b..cb44919c66 100644 --- a/src/wp-admin/includes/class-plugin-installer-skin.php +++ b/src/wp-admin/includes/class-plugin-installer-skin.php @@ -60,13 +60,13 @@ class Plugin_Installer_Skin extends WP_Upgrader_Skin { $from = isset( $_GET['from'] ) ? wp_unslash( $_GET['from'] ) : 'plugins'; - if ( 'import' == $from ) { + if ( 'import' === $from ) { $install_actions['activate_plugin'] = sprintf( '<a class="button button-primary" href="%s" target="_parent">%s</a>', wp_nonce_url( 'plugins.php?action=activate&from=import&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ), __( 'Activate Plugin & Run Importer' ) ); - } elseif ( 'press-this' == $from ) { + } elseif ( 'press-this' === $from ) { $install_actions['activate_plugin'] = sprintf( '<a class="button button-primary" href="%s" target="_parent">%s</a>', wp_nonce_url( 'plugins.php?action=activate&from=press-this&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ), diff --git a/src/wp-admin/includes/class-walker-nav-menu-checklist.php b/src/wp-admin/includes/class-walker-nav-menu-checklist.php index f166a8803d..11e78dd529 100644 --- a/src/wp-admin/includes/class-walker-nav-menu-checklist.php +++ b/src/wp-admin/includes/class-walker-nav-menu-checklist.php @@ -75,7 +75,7 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu { global $_nav_menu_placeholder, $nav_menu_selected_id; $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval( $_nav_menu_placeholder ) - 1 : -1; - $possible_object_id = isset( $item->post_type ) && 'nav_menu_item' == $item->post_type ? $item->object_id : $_nav_menu_placeholder; + $possible_object_id = isset( $item->post_type ) && 'nav_menu_item' === $item->post_type ? $item->object_id : $_nav_menu_placeholder; $possible_db_id = ( ! empty( $item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $item->ID : 0; $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; diff --git a/src/wp-admin/includes/class-walker-nav-menu-edit.php b/src/wp-admin/includes/class-walker-nav-menu-edit.php index 183077aab7..fd5ea85219 100644 --- a/src/wp-admin/includes/class-walker-nav-menu-edit.php +++ b/src/wp-admin/includes/class-walker-nav-menu-edit.php @@ -72,17 +72,17 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu { $original_title = false; - if ( 'taxonomy' == $item->type ) { + if ( 'taxonomy' === $item->type ) { $original_object = get_term( (int) $item->object_id, $item->object ); if ( $original_object && ! is_wp_error( $original_title ) ) { $original_title = $original_object->name; } - } elseif ( 'post_type' == $item->type ) { + } elseif ( 'post_type' === $item->type ) { $original_object = get_post( $item->object_id ); if ( $original_object ) { $original_title = get_the_title( $original_object->ID ); } - } elseif ( 'post_type_archive' == $item->type ) { + } elseif ( 'post_type_archive' === $item->type ) { $original_object = get_post_type_object( $item->object ); if ( $original_object ) { $original_title = $original_object->labels->archives; @@ -101,13 +101,13 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu { $classes[] = 'menu-item-invalid'; /* translators: %s: Title of an invalid menu item. */ $title = sprintf( __( '%s (Invalid)' ), $item->title ); - } elseif ( isset( $item->post_status ) && 'draft' == $item->post_status ) { + } elseif ( isset( $item->post_status ) && 'draft' === $item->post_status ) { $classes[] = 'pending'; /* translators: %s: Title of a menu item in draft status. */ $title = sprintf( __( '%s (Pending)' ), $item->title ); } - $title = ( ! isset( $item->label ) || '' == $item->label ) ? $title : $item->label; + $title = ( ! isset( $item->label ) || '' === $item->label ) ? $title : $item->label; $submenu_text = ''; if ( 0 == $depth ) { @@ -181,7 +181,7 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu { </div> <div class="menu-item-settings wp-clearfix" id="menu-item-settings-<?php echo $item_id; ?>"> - <?php if ( 'custom' == $item->type ) : ?> + <?php if ( 'custom' === $item->type ) : ?> <p class="field-url description description-wide"> <label for="edit-menu-item-url-<?php echo $item_id; ?>"> <?php _e( 'URL' ); ?><br /> diff --git a/src/wp-admin/includes/class-wp-automatic-updater.php b/src/wp-admin/includes/class-wp-automatic-updater.php index 10461f8f50..3780512efa 100644 --- a/src/wp-admin/includes/class-wp-automatic-updater.php +++ b/src/wp-admin/includes/class-wp-automatic-updater.php @@ -143,20 +143,20 @@ class WP_Automatic_Updater { // Only relax the filesystem checks when the update doesn't include new files. $allow_relaxed_file_ownership = false; - if ( 'core' == $type && isset( $item->new_files ) && ! $item->new_files ) { + if ( 'core' === $type && isset( $item->new_files ) && ! $item->new_files ) { $allow_relaxed_file_ownership = true; } // If we can't do an auto core update, we may still be able to email the user. if ( ! $skin->request_filesystem_credentials( false, $context, $allow_relaxed_file_ownership ) || $this->is_vcs_checkout( $context ) ) { - if ( 'core' == $type ) { + if ( 'core' === $type ) { $this->send_core_update_notification_email( $item ); } return false; } // Next up, is this an item we can update? - if ( 'core' == $type ) { + if ( 'core' === $type ) { $update = Core_Upgrader::should_update_to_version( $item->current ); } else { $update = ! empty( $item->autoupdate ); @@ -184,14 +184,14 @@ class WP_Automatic_Updater { $update = apply_filters( "auto_update_{$type}", $update, $item ); if ( ! $update ) { - if ( 'core' == $type ) { + if ( 'core' === $type ) { $this->send_core_update_notification_email( $item ); } return false; } // If it's a core update, are we actually compatible with its requirements? - if ( 'core' == $type ) { + if ( 'core' === $type ) { global $wpdb; $php_compat = version_compare( phpversion(), $item->php_version, '>=' ); @@ -344,7 +344,7 @@ class WP_Automatic_Updater { } $allow_relaxed_file_ownership = false; - if ( 'core' == $type && isset( $item->new_files ) && ! $item->new_files ) { + if ( 'core' === $type && isset( $item->new_files ) && ! $item->new_files ) { $allow_relaxed_file_ownership = true; } @@ -367,9 +367,13 @@ class WP_Automatic_Updater { $upgrade_result = new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.' ) ); } - if ( 'core' == $type ) { - if ( is_wp_error( $upgrade_result ) && ( 'up_to_date' == $upgrade_result->get_error_code() || 'locked' == $upgrade_result->get_error_code() ) ) { - // These aren't actual errors, treat it as a skipped-update instead to avoid triggering the post-core update failure routines. + if ( 'core' === $type ) { + if ( is_wp_error( $upgrade_result ) + && ( 'up_to_date' === $upgrade_result->get_error_code() + || 'locked' === $upgrade_result->get_error_code() ) + ) { + // These aren't actual errors, treat it as a skipped-update instead + // to avoid triggering the post-core update failure routines. return false; } @@ -626,11 +630,13 @@ class WP_Automatic_Updater { ); $next_user_core_update = get_preferred_from_update_core(); + // If the update transient is empty, use the update we just performed. if ( ! $next_user_core_update ) { $next_user_core_update = $core_update; } - $newer_version_available = ( 'upgrade' == $next_user_core_update->response && version_compare( $next_user_core_update->version, $core_update->version, '>' ) ); + + $newer_version_available = ( 'upgrade' === $next_user_core_update->response && version_compare( $next_user_core_update->version, $core_update->version, '>' ) ); /** * Filters whether to send an email following an automatic background core update. @@ -715,7 +721,7 @@ class WP_Automatic_Updater { // Don't show this message if there is a newer version available. // Potential for confusion, and also not useful for them to know at this point. - if ( 'fail' == $type && ! $newer_version_available ) { + if ( 'fail' === $type && ! $newer_version_available ) { $body .= __( 'We tried but were unable to update your site automatically.' ) . ' '; } @@ -778,7 +784,7 @@ class WP_Automatic_Updater { $body .= "\n\n" . __( 'The WordPress Team' ) . "\n"; - if ( 'critical' == $type && is_wp_error( $result ) ) { + if ( 'critical' === $type && is_wp_error( $result ) ) { $body .= "\n***\n\n"; /* translators: %s: WordPress version. */ $body .= sprintf( __( 'Your site was running version %s.' ), get_bloginfo( 'version' ) ); @@ -787,7 +793,7 @@ class WP_Automatic_Updater { // If we had a rollback and we're still critical, then the rollback failed too. // Loop through all errors (the main WP_Error, the update result, the rollback result) for code, data, etc. - if ( 'rollback_was_required' == $result->get_error_code() ) { + if ( 'rollback_was_required' === $result->get_error_code() ) { $errors = array( $result, $result->get_error_data()->update, $result->get_error_data()->rollback ); } else { $errors = array( $result ); @@ -797,20 +803,25 @@ class WP_Automatic_Updater { if ( ! is_wp_error( $error ) ) { continue; } + $error_code = $error->get_error_code(); /* translators: %s: Error code. */ $body .= "\n\n" . sprintf( __( 'Error code: %s' ), $error_code ); - if ( 'rollback_was_required' == $error_code ) { + + if ( 'rollback_was_required' === $error_code ) { continue; } + if ( $error->get_error_message() ) { $body .= "\n" . $error->get_error_message(); } + $error_data = $error->get_error_data(); if ( $error_data ) { $body .= "\n" . implode( ', ', (array) $error_data ); } } + $body .= "\n"; } diff --git a/src/wp-admin/includes/class-wp-comments-list-table.php b/src/wp-admin/includes/class-wp-comments-list-table.php index 9b273f42fb..e3678b60d5 100644 --- a/src/wp-admin/includes/class-wp-comments-list-table.php +++ b/src/wp-admin/includes/class-wp-comments-list-table.php @@ -276,7 +276,7 @@ class WP_Comments_List_Table extends WP_List_Table { } $link = admin_url( 'edit-comments.php' ); - if ( ! empty( $comment_type ) && 'all' != $comment_type ) { + if ( ! empty( $comment_type ) && 'all' !== $comment_type ) { $link = add_query_arg( 'comment_type', $comment_type, $link ); } @@ -634,7 +634,7 @@ class WP_Comments_List_Table extends WP_List_Table { ); // Not looking at all comments. - if ( $comment_status && 'all' != $comment_status ) { + if ( $comment_status && 'all' !== $comment_status ) { if ( 'approved' === $the_comment_status ) { $actions['unapprove'] = sprintf( '<a href="%s" data-wp-lists="%s" class="vim-u vim-destructive aria-button-if-js" aria-label="%s">%s</a>', diff --git a/src/wp-admin/includes/class-wp-filesystem-base.php b/src/wp-admin/includes/class-wp-filesystem-base.php index fe96929b5c..7d96de0676 100644 --- a/src/wp-admin/includes/class-wp-filesystem-base.php +++ b/src/wp-admin/includes/class-wp-filesystem-base.php @@ -98,7 +98,7 @@ class WP_Filesystem_Base { $theme_root = get_theme_root( $theme ); // Account for relative theme roots. - if ( '/themes' == $theme_root || ! is_dir( $theme_root ) ) { + if ( '/themes' === $theme_root || ! is_dir( $theme_root ) ) { $theme_root = WP_CONTENT_DIR . $theme_root; } @@ -208,7 +208,7 @@ class WP_Filesystem_Base { } } } - } elseif ( 'direct' == $this->method ) { + } elseif ( 'direct' === $this->method ) { $folder = str_replace( '\\', '/', $folder ); // Windows path sanitisation. return trailingslashit( $folder ); } @@ -245,7 +245,7 @@ class WP_Filesystem_Base { * @return string|false The location of the remote path, false to cease looping. */ public function search_for_folder( $folder, $base = '.', $loop = false ) { - if ( empty( $base ) || '.' == $base ) { + if ( empty( $base ) || '.' === $base ) { $base = trailingslashit( $this->cwd() ); } @@ -305,7 +305,7 @@ class WP_Filesystem_Base { // Prevent this function from looping again. // No need to proceed if we've just searched in `/`. - if ( $loop || '/' == $base ) { + if ( $loop || '/' === $base ) { return false; } diff --git a/src/wp-admin/includes/class-wp-filesystem-direct.php b/src/wp-admin/includes/class-wp-filesystem-direct.php index 1676a55658..7551e3d273 100644 --- a/src/wp-admin/includes/class-wp-filesystem-direct.php +++ b/src/wp-admin/includes/class-wp-filesystem-direct.php @@ -333,7 +333,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { } $file = str_replace( '\\', '/', $file ); // For Win32, occasional problems deleting files otherwise. - if ( 'f' == $type || $this->is_file( $file ) ) { + if ( 'f' === $type || $this->is_file( $file ) ) { return @unlink( $file ); } if ( ! $recursive && $this->is_dir( $file ) ) { @@ -580,11 +580,11 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { $struc = array(); $struc['name'] = $entry; - if ( '.' == $struc['name'] || '..' == $struc['name'] ) { + if ( '.' === $struc['name'] || '..' === $struc['name'] ) { continue; } - if ( ! $include_hidden && '.' == $struc['name'][0] ) { + if ( ! $include_hidden && '.' === $struc['name'][0] ) { continue; } @@ -603,7 +603,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { $struc['time'] = gmdate( 'h:i:s', $struc['lastmodunix'] ); $struc['type'] = $this->is_dir( $path . '/' . $entry ) ? 'd' : 'f'; - if ( 'd' == $struc['type'] ) { + if ( 'd' === $struc['type'] ) { if ( $recursive ) { $struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive ); } else { diff --git a/src/wp-admin/includes/class-wp-filesystem-ftpext.php b/src/wp-admin/includes/class-wp-filesystem-ftpext.php index 241621e852..b1a65fc524 100644 --- a/src/wp-admin/includes/class-wp-filesystem-ftpext.php +++ b/src/wp-admin/includes/class-wp-filesystem-ftpext.php @@ -69,7 +69,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { } $this->options['ssl'] = false; - if ( isset( $opt['connection_type'] ) && 'ftps' == $opt['connection_type'] ) { + if ( isset( $opt['connection_type'] ) && 'ftps' === $opt['connection_type'] ) { $this->options['ssl'] = true; } } @@ -373,7 +373,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { if ( empty( $file ) ) { return false; } - if ( 'f' == $type || $this->is_file( $file ) ) { + if ( 'f' === $type || $this->is_file( $file ) ) { return ftp_delete( $this->link, $file ); } if ( ! $recursive ) { @@ -695,11 +695,11 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { continue; } - if ( '.' == $entry['name'] || '..' == $entry['name'] ) { + if ( '.' === $entry['name'] || '..' === $entry['name'] ) { continue; } - if ( ! $include_hidden && '.' == $entry['name'][0] ) { + if ( ! $include_hidden && '.' === $entry['name'][0] ) { continue; } @@ -712,7 +712,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { $ret = array(); foreach ( (array) $dirlist as $struc ) { - if ( 'd' == $struc['type'] ) { + if ( 'd' === $struc['type'] ) { if ( $recursive ) { $struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive ); } else { diff --git a/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php b/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php index 26ee71c0d5..c200372788 100644 --- a/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php +++ b/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php @@ -383,7 +383,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base { if ( empty( $file ) ) { return false; } - if ( 'f' == $type || $this->is_file( $file ) ) { + if ( 'f' === $type || $this->is_file( $file ) ) { return $this->ftp->delete( $file ); } if ( ! $recursive ) { @@ -615,11 +615,11 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base { $ret = array(); foreach ( $list as $struc ) { - if ( '.' == $struc['name'] || '..' == $struc['name'] ) { + if ( '.' === $struc['name'] || '..' === $struc['name'] ) { continue; } - if ( ! $include_hidden && '.' == $struc['name'][0] ) { + if ( ! $include_hidden && '.' === $struc['name'][0] ) { continue; } @@ -627,7 +627,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base { continue; } - if ( 'd' == $struc['type'] ) { + if ( 'd' === $struc['type'] ) { if ( $recursive ) { $struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive ); } else { diff --git a/src/wp-admin/includes/class-wp-filesystem-ssh2.php b/src/wp-admin/includes/class-wp-filesystem-ssh2.php index 03e0f798b7..c099259e1f 100644 --- a/src/wp-admin/includes/class-wp-filesystem-ssh2.php +++ b/src/wp-admin/includes/class-wp-filesystem-ssh2.php @@ -227,7 +227,7 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base { fclose( $stream ); if ( $returnbool ) { - return ( false === $data ) ? false : '' != trim( $data ); + return ( false === $data ) ? false : '' !== trim( $data ); } else { return $data; } @@ -499,7 +499,7 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base { * @return bool True on success, false on failure. */ public function delete( $file, $recursive = false, $type = false ) { - if ( 'f' == $type || $this->is_file( $file ) ) { + if ( 'f' === $type || $this->is_file( $file ) ) { return ssh2_sftp_unlink( $this->sftp_link, $file ); } if ( ! $recursive ) { @@ -725,11 +725,11 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base { $struc = array(); $struc['name'] = $entry; - if ( '.' == $struc['name'] || '..' == $struc['name'] ) { + if ( '.' === $struc['name'] || '..' === $struc['name'] ) { continue; // Do not care about these folders. } - if ( ! $include_hidden && '.' == $struc['name'][0] ) { + if ( ! $include_hidden && '.' === $struc['name'][0] ) { continue; } @@ -748,7 +748,7 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base { $struc['time'] = gmdate( 'h:i:s', $struc['lastmodunix'] ); $struc['type'] = $this->is_dir( $path . '/' . $entry ) ? 'd' : 'f'; - if ( 'd' == $struc['type'] ) { + if ( 'd' === $struc['type'] ) { if ( $recursive ) { $struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive ); } else { diff --git a/src/wp-admin/includes/class-wp-ms-themes-list-table.php b/src/wp-admin/includes/class-wp-ms-themes-list-table.php index 03441acbe6..169f783ec8 100644 --- a/src/wp-admin/includes/class-wp-ms-themes-list-table.php +++ b/src/wp-admin/includes/class-wp-ms-themes-list-table.php @@ -352,7 +352,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table { $url = 'themes.php'; } - if ( 'search' != $type ) { + if ( 'search' !== $type ) { $status_links[ $type ] = sprintf( "<a href='%s'%s>%s</a>", esc_url( add_query_arg( 'theme_status', $type, $url ) ), @@ -374,10 +374,10 @@ class WP_MS_Themes_List_Table extends WP_List_Table { global $status; $actions = array(); - if ( 'enabled' != $status ) { + if ( 'enabled' !== $status ) { $actions['enable-selected'] = $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ); } - if ( 'disabled' != $status ) { + if ( 'disabled' !== $status ) { $actions['disable-selected'] = $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ); } if ( ! $this->is_site_themes ) { diff --git a/src/wp-admin/includes/class-wp-plugins-list-table.php b/src/wp-admin/includes/class-wp-plugins-list-table.php index 9334f86347..b67d75c4b0 100644 --- a/src/wp-admin/includes/class-wp-plugins-list-table.php +++ b/src/wp-admin/includes/class-wp-plugins-list-table.php @@ -517,11 +517,11 @@ class WP_Plugins_List_Table extends WP_List_Table { $actions = array(); - if ( 'active' != $status ) { + if ( 'active' !== $status ) { $actions['activate-selected'] = $this->screen->in_admin( 'network' ) ? __( 'Network Activate' ) : __( 'Activate' ); } - if ( 'inactive' != $status && 'recent' != $status ) { + if ( 'inactive' !== $status && 'recent' !== $status ) { $actions['deactivate-selected'] = $this->screen->in_admin( 'network' ) ? __( 'Network Deactivate' ) : __( 'Deactivate' ); } @@ -530,7 +530,7 @@ class WP_Plugins_List_Table extends WP_List_Table { $actions['update-selected'] = __( 'Update' ); } - if ( current_user_can( 'delete_plugins' ) && ( 'active' != $status ) ) { + if ( current_user_can( 'delete_plugins' ) && ( 'active' !== $status ) ) { $actions['delete-selected'] = __( 'Delete' ); } } @@ -565,7 +565,7 @@ class WP_Plugins_List_Table extends WP_List_Table { echo '<div class="alignleft actions">'; - if ( 'recently_activated' == $status ) { + if ( 'recently_activated' === $status ) { submit_button( __( 'Clear List' ), '', 'clear-recent-list', false ); } elseif ( 'top' === $which && 'mustuse' === $status ) { echo '<p>' . sprintf( @@ -858,7 +858,7 @@ class WP_Plugins_List_Table extends WP_List_Table { esc_attr( $plugin_file ) ); } - if ( 'dropins' != $context ) { + if ( 'dropins' !== $context ) { $description = '<p>' . ( $plugin_data['Description'] ? $plugin_data['Description'] : ' ' ) . '</p>'; $plugin_name = $plugin_data['Name']; } diff --git a/src/wp-admin/includes/class-wp-posts-list-table.php b/src/wp-admin/includes/class-wp-posts-list-table.php index 871feeb84e..3b29dce7d2 100644 --- a/src/wp-admin/includes/class-wp-posts-list-table.php +++ b/src/wp-admin/includes/class-wp-posts-list-table.php @@ -1190,7 +1190,7 @@ class WP_Posts_List_Table extends WP_List_Table { $term_links = array(); foreach ( $terms as $t ) { $posts_in_term_qv = array(); - if ( 'post' != $post->post_type ) { + if ( 'post' !== $post->post_type ) { $posts_in_term_qv['post_type'] = $post->post_type; } if ( $taxonomy_object->query_var ) { @@ -1335,7 +1335,7 @@ class WP_Posts_List_Table extends WP_List_Table { $actions = array(); $title = _draft_or_post_title(); - if ( $can_edit_post && 'trash' != $post->post_status ) { + if ( $can_edit_post && 'trash' !== $post->post_status ) { $actions['edit'] = sprintf( '<a href="%s" aria-label="%s">%s</a>', get_edit_post_link( $post->ID ), @@ -1395,7 +1395,7 @@ class WP_Posts_List_Table extends WP_List_Table { __( 'Preview' ) ); } - } elseif ( 'trash' != $post->post_status ) { + } elseif ( 'trash' !== $post->post_status ) { $actions['view'] = sprintf( '<a href="%s" rel="bookmark" aria-label="%s">%s</a>', get_permalink( $post->ID ), diff --git a/src/wp-admin/includes/class-wp-site-health-auto-updates.php b/src/wp-admin/includes/class-wp-site-health-auto-updates.php index f69f9540c2..b67d509a25 100644 --- a/src/wp-admin/includes/class-wp-site-health-auto-updates.php +++ b/src/wp-admin/includes/class-wp-site-health-auto-updates.php @@ -347,7 +347,7 @@ class WP_Site_Health_Auto_Updates { WP_Filesystem(); - if ( 'direct' != $wp_filesystem->method ) { + if ( 'direct' !== $wp_filesystem->method ) { return false; } @@ -378,7 +378,7 @@ class WP_Site_Health_Auto_Updates { $unwritable_files = array(); foreach ( array_keys( $checksums ) as $file ) { - if ( 'wp-content' == substr( $file, 0, 10 ) ) { + if ( 'wp-content' === substr( $file, 0, 10 ) ) { continue; } if ( ! file_exists( ABSPATH . $file ) ) { diff --git a/src/wp-admin/includes/class-wp-terms-list-table.php b/src/wp-admin/includes/class-wp-terms-list-table.php index 4808793577..24cdaf2b14 100644 --- a/src/wp-admin/includes/class-wp-terms-list-table.php +++ b/src/wp-admin/includes/class-wp-terms-list-table.php @@ -576,7 +576,7 @@ class WP_Terms_List_Table extends WP_List_Table { ); } - if ( 'post' != $this->screen->post_type ) { + if ( 'post' !== $this->screen->post_type ) { $args['post_type'] = $this->screen->post_type; } diff --git a/src/wp-admin/includes/class-wp-upgrader.php b/src/wp-admin/includes/class-wp-upgrader.php index fb1bd4722c..902b160de3 100644 --- a/src/wp-admin/includes/class-wp-upgrader.php +++ b/src/wp-admin/includes/class-wp-upgrader.php @@ -331,7 +331,7 @@ class WP_Upgrader { if ( is_wp_error( $result ) ) { $wp_filesystem->delete( $working_dir, true ); - if ( 'incompatible_archive' == $result->get_error_code() ) { + if ( 'incompatible_archive' === $result->get_error_code() ) { return new WP_Error( 'incompatible_archive', $this->strings['incompatible_archive'], $result->get_error_data() ); } return $result; @@ -398,7 +398,7 @@ class WP_Upgrader { foreach ( $files as $filename => $file_details ) { if ( ! $wp_filesystem->is_writable( $remote_destination . $filename ) ) { // Attempt to alter permissions to allow writes and try again. - $wp_filesystem->chmod( $remote_destination . $filename, ( 'd' == $file_details['type'] ? FS_CHMOD_DIR : FS_CHMOD_FILE ) ); + $wp_filesystem->chmod( $remote_destination . $filename, ( 'd' === $file_details['type'] ? FS_CHMOD_DIR : FS_CHMOD_FILE ) ); if ( ! $wp_filesystem->is_writable( $remote_destination . $filename ) ) { $unwritable_files[] = $filename; } @@ -603,7 +603,7 @@ class WP_Upgrader { } $destination_name = basename( str_replace( $local_destination, '', $destination ) ); - if ( '.' == $destination_name ) { + if ( '.' === $destination_name ) { $destination_name = ''; } @@ -744,7 +744,7 @@ class WP_Upgrader { if ( is_wp_error( $download ) && $download->get_error_data( 'softfail-filename' ) ) { // Don't output the 'no signature could be found' failure message for now. - if ( 'signature_verification_no_signature' != $download->get_error_code() || WP_DEBUG ) { + if ( 'signature_verification_no_signature' !== $download->get_error_code() || WP_DEBUG ) { // Output the failure error as a normal feedback, and not as an error. $this->skin->feedback( $download->get_error_message() ); diff --git a/src/wp-admin/includes/comment.php b/src/wp-admin/includes/comment.php index 9683c72883..4571cd4b76 100644 --- a/src/wp-admin/includes/comment.php +++ b/src/wp-admin/includes/comment.php @@ -197,7 +197,7 @@ function floated_admin_avatar( $name ) { * @since 2.7.0 */ function enqueue_comment_hotkeys_js() { - if ( 'true' == get_user_option( 'comment_shortcuts' ) ) { + if ( 'true' === get_user_option( 'comment_shortcuts' ) ) { wp_enqueue_script( 'jquery-table-hotkeys' ); } } diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php index c7edaf6c08..e17ca73251 100644 --- a/src/wp-admin/includes/dashboard.php +++ b/src/wp-admin/includes/dashboard.php @@ -137,7 +137,7 @@ function wp_dashboard_setup() { wp_add_dashboard_widget( $widget_id, $name, $wp_registered_widgets[ $widget_id ]['callback'], $wp_registered_widget_controls[ $widget_id ]['callback'] ); } - if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget_id'] ) ) { + if ( 'POST' === $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget_id'] ) ) { check_admin_referer( 'edit-dashboard-widget_' . $_POST['widget_id'], 'dashboard-widget-nonce' ); ob_start(); // Hack - but the same hack wp-admin/widgets.php uses. wp_dashboard_trigger_widget_control( $_POST['widget_id'] ); @@ -282,7 +282,7 @@ function wp_dashboard_right_now() { foreach ( array( 'post', 'page' ) as $post_type ) { $num_posts = wp_count_posts( $post_type ); if ( $num_posts && $num_posts->publish ) { - if ( 'post' == $post_type ) { + if ( 'post' === $post_type ) { /* translators: %s: Number of posts. */ $text = _n( '%s Post', '%s Posts', $num_posts->publish ); } else { @@ -758,16 +758,22 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) { $i = 0; foreach ( $actions as $action => $link ) { ++$i; - ( ( ( 'approve' == $action || 'unapprove' == $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | '; + + if ( ( ( 'approve' === $action || 'unapprove' === $action ) && 2 === $i ) || 1 === $i ) { + $sep = ''; + } else { + $sep = ' | '; + } // Reply and quickedit need a hide-if-no-js span. - if ( 'reply' == $action || 'quickedit' == $action ) { + if ( 'reply' === $action || 'quickedit' === $action ) { $action .= ' hide-if-no-js'; } if ( 'view' === $action && '1' !== $comment->comment_approved ) { $action .= ' hidden'; } + $actions_string .= "<span class='$action'>$sep$link</span>"; } } @@ -784,7 +790,7 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) { } ?> - <?php if ( ! $comment->comment_type || 'comment' == $comment->comment_type ) : ?> + <?php if ( ! $comment->comment_type || 'comment' === $comment->comment_type ) : ?> <div class="dashboard-comment-wrap has-row-actions <?php echo $comment_row_class; ?>"> <p class="comment-meta"> @@ -1174,7 +1180,7 @@ function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) { $widget_options[ $widget_id ]['number'] = $number; - if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget-rss'][ $number ] ) ) { + if ( 'POST' === $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget-rss'][ $number ] ) ) { $_POST['widget-rss'][ $number ] = wp_unslash( $_POST['widget-rss'][ $number ] ); $widget_options[ $widget_id ] = wp_widget_rss_process( $_POST['widget-rss'][ $number ] ); $widget_options[ $widget_id ]['number'] = $number; @@ -1891,10 +1897,10 @@ function wp_welcome_panel() { <div class="welcome-panel-column"> <h3><?php _e( 'Next Steps' ); ?></h3> <ul> - <?php if ( 'page' == get_option( 'show_on_front' ) && ! get_option( 'page_for_posts' ) ) : ?> + <?php if ( 'page' === get_option( 'show_on_front' ) && ! get_option( 'page_for_posts' ) ) : ?> <li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li> <li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add additional pages' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li> - <?php elseif ( 'page' == get_option( 'show_on_front' ) ) : ?> + <?php elseif ( 'page' === get_option( 'show_on_front' ) ) : ?> <li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li> <li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add additional pages' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li> <li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Add a blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li> diff --git a/src/wp-admin/includes/export.php b/src/wp-admin/includes/export.php index 19b4630072..315785738d 100644 --- a/src/wp-admin/includes/export.php +++ b/src/wp-admin/includes/export.php @@ -96,7 +96,7 @@ function export_wp( $args = array() ) { header( 'Content-Disposition: attachment; filename=' . $filename ); header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true ); - if ( 'all' != $args['content'] && post_type_exists( $args['content'] ) ) { + if ( 'all' !== $args['content'] && post_type_exists( $args['content'] ) ) { $ptype = get_post_type_object( $args['content'] ); if ( ! $ptype->can_export ) { $args['content'] = 'post'; @@ -111,14 +111,14 @@ function export_wp( $args = array() ) { $where = $wpdb->prepare( "{$wpdb->posts}.post_type IN (" . implode( ',', $esses ) . ')', $post_types ); } - if ( $args['status'] && ( 'post' == $args['content'] || 'page' == $args['content'] ) ) { + if ( $args['status'] && ( 'post' === $args['content'] || 'page' === $args['content'] ) ) { $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_status = %s", $args['status'] ); } else { $where .= " AND {$wpdb->posts}.post_status != 'auto-draft'"; } $join = ''; - if ( $args['category'] && 'post' == $args['content'] ) { + if ( $args['category'] && 'post' === $args['content'] ) { $term = term_exists( $args['category'], 'category' ); if ( $term ) { $join = "INNER JOIN {$wpdb->term_relationships} ON ({$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id)"; @@ -126,7 +126,7 @@ function export_wp( $args = array() ) { } } - if ( 'post' == $args['content'] || 'page' == $args['content'] || 'attachment' == $args['content'] ) { + if ( in_array( $args['content'], array( 'post', 'page', 'attachment' ), true ) ) { if ( $args['author'] ) { $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_author = %d", $args['author'] ); } @@ -154,7 +154,7 @@ function export_wp( $args = array() ) { $cat = get_term( $term['term_id'], 'category' ); $cats = array( $cat->term_id => $cat ); unset( $term, $cat ); - } elseif ( 'all' == $args['content'] ) { + } elseif ( 'all' === $args['content'] ) { $categories = (array) get_categories( array( 'get' => 'all' ) ); $tags = (array) get_tags( array( 'get' => 'all' ) ); @@ -428,7 +428,7 @@ function export_wp( $args = array() ) { * @return bool */ function wxr_filter_postmeta( $return_me, $meta_key ) { - if ( '_edit_lock' == $meta_key ) { + if ( '_edit_lock' === $meta_key ) { $return_me = true; } return $return_me; @@ -513,7 +513,7 @@ function export_wp( $args = array() ) { </wp:term> <?php endforeach; ?> <?php - if ( 'all' == $args['content'] ) { + if ( 'all' === $args['content'] ) { wxr_nav_menu_terms();} ?> diff --git a/src/wp-admin/includes/file.php b/src/wp-admin/includes/file.php index 9933061321..fb31e5aa6b 100644 --- a/src/wp-admin/includes/file.php +++ b/src/wp-admin/includes/file.php @@ -648,7 +648,7 @@ function wp_tempnam( $filename = '', $dir = '' ) { $dir = get_temp_dir(); } - if ( empty( $filename ) || '.' == $filename || '/' == $filename || '\\' == $filename ) { + if ( empty( $filename ) || in_array( $filename, array( '.', '/', '\\' ), true ) ) { $filename = uniqid(); } @@ -1103,7 +1103,8 @@ function download_url( $url, $timeout = 300, $signature_verification = false ) { $signature_url = false; $url_path = parse_url( $url, PHP_URL_PATH ); - if ( substr( $url_path, -4 ) == '.zip' || substr( $url_path, -7 ) == '.tar.gz' ) { + + if ( '.zip' === substr( $url_path, -4 ) || '.tar.gz' === substr( $url_path, -7 ) ) { $signature_url = str_replace( $url_path, $url_path . '.sig', $url ); } @@ -1450,7 +1451,7 @@ function unzip_file( $file, $to ) { if ( true === $result ) { return $result; } elseif ( is_wp_error( $result ) ) { - if ( 'incompatible_archive' != $result->get_error_code() ) { + if ( 'incompatible_archive' !== $result->get_error_code() ) { return $result; } } @@ -1562,7 +1563,7 @@ function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) { return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) ); } - if ( '/' == substr( $info['name'], -1 ) ) { // Directory. + if ( '/' === substr( $info['name'], -1 ) ) { // Directory. continue; } @@ -1732,7 +1733,7 @@ function copy_dir( $from, $to, $skip_list = array() ) { continue; } - if ( 'f' == $fileinfo['type'] ) { + if ( 'f' === $fileinfo['type'] ) { if ( ! $wp_filesystem->copy( $from . $filename, $to . $filename, true, FS_CHMOD_FILE ) ) { // If copy failed, chmod file to 0644 and try again. $wp_filesystem->chmod( $to . $filename, FS_CHMOD_FILE ); @@ -1740,7 +1741,7 @@ function copy_dir( $from, $to, $skip_list = array() ) { return new WP_Error( 'copy_failed_copy_dir', __( 'Could not copy file.' ), $to . $filename ); } } - } elseif ( 'd' == $fileinfo['type'] ) { + } elseif ( 'd' === $fileinfo['type'] ) { if ( ! $wp_filesystem->is_dir( $to . $filename ) ) { if ( ! $wp_filesystem->mkdir( $to . $filename, FS_CHMOD_DIR ) ) { return new WP_Error( 'mkdir_failed_copy_dir', __( 'Could not create directory.' ), $to . $filename ); @@ -1761,6 +1762,7 @@ function copy_dir( $from, $to, $skip_list = array() ) { } } } + return true; } @@ -1924,7 +1926,7 @@ function get_filesystem_method( $args = array(), $context = '', $allow_relaxed_f } } - if ( ! $method && isset( $args['connection_type'] ) && 'ssh' == $args['connection_type'] && extension_loaded( 'ssh2' ) ) { + if ( ! $method && isset( $args['connection_type'] ) && 'ssh' === $args['connection_type'] && extension_loaded( 'ssh2' ) ) { $method = 'ssh2'; } if ( ! $method && extension_loaded( 'ftp' ) ) { @@ -2010,7 +2012,7 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false, $type = get_filesystem_method( array(), $context, $allow_relaxed_file_ownership ); } - if ( 'direct' == $type ) { + if ( 'direct' === $type ) { return true; } @@ -2061,29 +2063,32 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false, unset( $credentials['port'] ); } - if ( ( defined( 'FTP_SSH' ) && FTP_SSH ) || ( defined( 'FS_METHOD' ) && 'ssh2' == FS_METHOD ) ) { + if ( ( defined( 'FTP_SSH' ) && FTP_SSH ) || ( defined( 'FS_METHOD' ) && 'ssh2' === FS_METHOD ) ) { $credentials['connection_type'] = 'ssh'; - } elseif ( ( defined( 'FTP_SSL' ) && FTP_SSL ) && 'ftpext' == $type ) { // Only the FTP Extension understands SSL. + } elseif ( ( defined( 'FTP_SSL' ) && FTP_SSL ) && 'ftpext' === $type ) { // Only the FTP Extension understands SSL. $credentials['connection_type'] = 'ftps'; } elseif ( ! empty( $submitted_form['connection_type'] ) ) { $credentials['connection_type'] = $submitted_form['connection_type']; } elseif ( ! isset( $credentials['connection_type'] ) ) { // All else fails (and it's not defaulted to something else saved), default to FTP. $credentials['connection_type'] = 'ftp'; } - if ( ! $error && - ( - ( ! empty( $credentials['password'] ) && ! empty( $credentials['username'] ) && ! empty( $credentials['hostname'] ) ) || - ( 'ssh' == $credentials['connection_type'] && ! empty( $credentials['public_key'] ) && ! empty( $credentials['private_key'] ) ) - ) ) { + if ( ! $error + && ( ( ! empty( $credentials['password'] ) && ! empty( $credentials['username'] ) && ! empty( $credentials['hostname'] ) ) + || ( 'ssh' === $credentials['connection_type'] && ! empty( $credentials['public_key'] ) && ! empty( $credentials['private_key'] ) ) + ) + ) { $stored_credentials = $credentials; + if ( ! empty( $stored_credentials['port'] ) ) { // Save port as part of hostname to simplify above code. $stored_credentials['hostname'] .= ':' . $stored_credentials['port']; } unset( $stored_credentials['password'], $stored_credentials['port'], $stored_credentials['private_key'], $stored_credentials['public_key'] ); + if ( ! wp_installing() ) { update_option( 'ftp_credentials', $stored_credentials ); } + return $credentials; } $hostname = isset( $credentials['hostname'] ) ? $credentials['hostname'] : ''; @@ -2208,7 +2213,7 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false, <?php if ( isset( $types['ssh'] ) ) { $hidden_class = ''; - if ( 'ssh' != $connection_type || empty( $connection_type ) ) { + if ( 'ssh' !== $connection_type || empty( $connection_type ) ) { $hidden_class = ' class="hidden"'; } ?> @@ -2251,9 +2256,11 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false, */ function wp_print_request_filesystem_credentials_modal() { $filesystem_method = get_filesystem_method(); + ob_start(); $filesystem_credentials_are_stored = request_filesystem_credentials( self_admin_url() ); ob_end_clean(); + $request_filesystem_credentials = ( 'direct' !== $filesystem_method && ! $filesystem_credentials_are_stored ); if ( ! $request_filesystem_credentials ) { return; diff --git a/src/wp-admin/includes/image-edit.php b/src/wp-admin/includes/image-edit.php index b48be674f3..701473679e 100644 --- a/src/wp-admin/includes/image-edit.php +++ b/src/wp-admin/includes/image-edit.php @@ -776,7 +776,7 @@ function wp_save_image( $post_id ) { $fwidth = ! empty( $_REQUEST['fwidth'] ) ? intval( $_REQUEST['fwidth'] ) : 0; $fheight = ! empty( $_REQUEST['fheight'] ) ? intval( $_REQUEST['fheight'] ) : 0; $target = ! empty( $_REQUEST['target'] ) ? preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['target'] ) : ''; - $scale = ! empty( $_REQUEST['do'] ) && 'scale' == $_REQUEST['do']; + $scale = ! empty( $_REQUEST['do'] ) && 'scale' === $_REQUEST['do']; if ( $scale && $fwidth > 0 && $fheight > 0 ) { $size = $img->get_size(); @@ -830,7 +830,7 @@ function wp_save_image( $post_id ) { if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE && isset( $backup_sizes['full-orig'] ) && $backup_sizes['full-orig']['file'] != $basename ) { - if ( 'thumbnail' == $target ) { + if ( 'thumbnail' === $target ) { $new_path = "{$dirname}/{$filename}-temp.{$ext}"; } else { $new_path = $path; @@ -880,16 +880,16 @@ function wp_save_image( $post_id ) { $meta['width'] = $size['width']; $meta['height'] = $size['height']; - if ( $success && ( 'nothumb' == $target || 'all' == $target ) ) { + if ( $success && ( 'nothumb' === $target || 'all' === $target ) ) { $sizes = get_intermediate_image_sizes(); - if ( 'nothumb' == $target ) { + if ( 'nothumb' === $target ) { $sizes = array_diff( $sizes, array( 'thumbnail' ) ); } } $return->fw = $meta['width']; $return->fh = $meta['height']; - } elseif ( 'thumbnail' == $target ) { + } elseif ( 'thumbnail' === $target ) { $sizes = array( 'thumbnail' ); $success = true; $delete = true; @@ -958,7 +958,7 @@ function wp_save_image( $post_id ) { 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'] ) { + if ( ! empty( $_REQUEST['context'] ) && 'edit-attachment' === $_REQUEST['context'] ) { $thumb_url = wp_get_attachment_image_src( $post_id, array( 900, 600 ), true ); $return->thumbnail = $thumb_url[0]; } else { diff --git a/src/wp-admin/includes/media.php b/src/wp-admin/includes/media.php index fc05bd6f72..feebbd9bff 100644 --- a/src/wp-admin/includes/media.php +++ b/src/wp-admin/includes/media.php @@ -680,7 +680,7 @@ function get_upload_iframe_src( $type = null, $post_id = null, $tab = null ) { $upload_iframe_src = add_query_arg( 'post_id', (int) $post_id, admin_url( 'media-upload.php' ) ); - if ( $type && 'media' != $type ) { + if ( $type && 'media' !== $type ) { $upload_iframe_src = add_query_arg( 'type', $type, $upload_iframe_src ); } @@ -865,7 +865,7 @@ function wp_media_upload_handler() { $src = "http://$src"; } - if ( isset( $_POST['media_type'] ) && 'image' != $_POST['media_type'] ) { + if ( isset( $_POST['media_type'] ) && 'image' !== $_POST['media_type'] ) { $title = esc_html( wp_unslash( $_POST['title'] ) ); if ( empty( $title ) ) { $title = esc_html( wp_basename( $src ) ); @@ -880,7 +880,7 @@ function wp_media_upload_handler() { if ( $ext ) { $ext_type = wp_ext2type( $ext ); - if ( 'audio' == $ext_type || 'video' == $ext_type ) { + if ( 'audio' === $ext_type || 'video' === $ext_type ) { $type = $ext_type; } } @@ -1159,7 +1159,7 @@ function image_size_input_fields( $post, $check = '' ) { $checked = ''; // Is this size selectable? - $enabled = ( $downsize[3] || 'full' == $size ); + $enabled = ( $downsize[3] || 'full' === $size ); $css_id = "image-size-{$size}-{$post->ID}"; // If this size is the default but that's not available, don't select it. @@ -1169,7 +1169,7 @@ function image_size_input_fields( $post, $check = '' ) { } else { $check = ''; } - } elseif ( ! $check && $enabled && 'thumbnail' != $size ) { + } elseif ( ! $check && $enabled && 'thumbnail' !== $size ) { /* * If $check is not enabled, default to the first available size * that's bigger than a thumbnail. @@ -1302,7 +1302,7 @@ function media_post_single_attachment_fields_to_edit( $form_fields, $post ) { * @return array Filtered attachment post object. */ function image_attachment_fields_to_save( $post, $attachment ) { - if ( substr( $post['post_mime_type'], 0, 5 ) == 'image' ) { + if ( 'image' === substr( $post['post_mime_type'], 0, 5 ) ) { if ( strlen( trim( $post['post_title'] ) ) == 0 ) { $attachment_url = ( isset( $post['attachment_url'] ) ) ? $post['attachment_url'] : $post['guid']; $post['post_title'] = preg_replace( '/\.\w+$/', '', wp_basename( $attachment_url ) ); @@ -1326,7 +1326,7 @@ function image_attachment_fields_to_save( $post, $attachment ) { function image_media_send_to_editor( $html, $attachment_id, $attachment ) { $post = get_post( $attachment_id ); - if ( substr( $post->post_mime_type, 0, 5 ) == 'image' ) { + if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) { $url = $attachment['url']; $align = ! empty( $attachment['align'] ) ? $attachment['align'] : 'none'; $size = ! empty( $attachment['image-size'] ) ? $attachment['image-size'] : 'medium'; @@ -1437,7 +1437,7 @@ function get_attachment_fields_to_edit( $post, $errors = null ) { $form_fields = array_merge_recursive( $form_fields, (array) $errors ); // This was formerly in image_attachment_fields_to_edit(). - if ( substr( $post->post_mime_type, 0, 5 ) == 'image' ) { + if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) { $alt = get_post_meta( $post->ID, '_wp_attachment_image_alt', true ); if ( empty( $alt ) ) { @@ -1610,11 +1610,11 @@ function get_media_item( $attachment_id, $args = null ) { $display_title = ( ! empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case. $display_title = $parsed_args['show_title'] ? "<div class='filename new'><span class='title'>" . wp_html_excerpt( $display_title, 60, '…' ) . '</span></div>' : ''; - $gallery = ( ( isset( $_REQUEST['tab'] ) && 'gallery' == $_REQUEST['tab'] ) || ( isset( $redir_tab ) && 'gallery' == $redir_tab ) ); + $gallery = ( ( isset( $_REQUEST['tab'] ) && 'gallery' === $_REQUEST['tab'] ) || ( isset( $redir_tab ) && 'gallery' === $redir_tab ) ); $order = ''; foreach ( $form_fields as $key => $val ) { - if ( 'menu_order' == $key ) { + if ( 'menu_order' === $key ) { if ( $gallery ) { $order = "<div class='menu_order'> <input class='menu_order_input' type='text' id='attachments[$attachment_id][menu_order]' name='attachments[$attachment_id][menu_order]' value='" . esc_attr( $val['value'] ) . "' /></div>"; } else { @@ -1725,8 +1725,11 @@ function get_media_item( $attachment_id, $args = null ) { $calling_post_id = $post->post_parent; } - if ( 'image' == $type && $calling_post_id && current_theme_supports( 'post-thumbnails', get_post_type( $calling_post_id ) ) - && post_type_supports( get_post_type( $calling_post_id ), 'thumbnail' ) && get_post_thumbnail_id( $calling_post_id ) != $attachment_id ) { + if ( 'image' === $type && $calling_post_id + && current_theme_supports( 'post-thumbnails', get_post_type( $calling_post_id ) ) + && post_type_supports( get_post_type( $calling_post_id ), 'thumbnail' ) + && get_post_thumbnail_id( $calling_post_id ) != $attachment_id + ) { $calling_post = get_post( $calling_post_id ); $calling_post_type_object = get_post_type_object( $calling_post->post_type ); @@ -1769,7 +1772,7 @@ function get_media_item( $attachment_id, $args = null ) { if ( ! empty( $field[ $field['input'] ] ) ) { $item .= $field[ $field['input'] ]; } elseif ( 'textarea' === $field['input'] ) { - if ( 'post_content' == $id && user_can_richedit() ) { + if ( 'post_content' === $id && user_can_richedit() ) { // Sanitize_post() skips the post_content when user_can_richedit. $field['value'] = htmlspecialchars( $field['value'], ENT_QUOTES ); } @@ -1962,7 +1965,7 @@ function get_compat_media_markup( $attachment_id, $args = null ) { if ( ! empty( $field[ $field['input'] ] ) ) { $item .= $field[ $field['input'] ]; } elseif ( 'textarea' === $field['input'] ) { - if ( 'post_content' == $id && user_can_richedit() ) { + if ( 'post_content' === $id && user_can_richedit() ) { // sanitize_post() skips the post_content when user_can_richedit. $field['value'] = htmlspecialchars( $field['value'], ENT_QUOTES ); } @@ -2383,7 +2386,7 @@ function media_upload_type_url_form( $type = null, $errors = null, $id = null ) insert : function() { var t = this, html, f = document.forms[0], cls, title = '', alt = '', caption = ''; - if ( '' == f.src.value || '' == t.width ) + if ( '' === f.src.value || '' === t.width ) return false; if ( f.alt.value ) @@ -2890,7 +2893,7 @@ function wp_media_insert_url_form( $default_view = 'image' ) { $default_align = 'none'; } - if ( 'image' == $default_view ) { + if ( 'image' === $default_view ) { $view = 'image-only'; $table_class = ''; } else { diff --git a/src/wp-admin/includes/menu.php b/src/wp-admin/includes/menu.php index 4fe351b11e..d3a09a36c3 100644 --- a/src/wp-admin/includes/menu.php +++ b/src/wp-admin/includes/menu.php @@ -333,7 +333,7 @@ unset( $id, $data, $prev_menu_was_separator ); // Remove the last menu item if it is a separator. $last_menu_key = array_keys( $menu ); $last_menu_key = array_pop( $last_menu_key ); -if ( ! empty( $menu ) && 'wp-menu-separator' == $menu[ $last_menu_key ][4] ) { +if ( ! empty( $menu ) && 'wp-menu-separator' === $menu[ $last_menu_key ][4] ) { unset( $menu[ $last_menu_key ] ); } unset( $last_menu_key ); diff --git a/src/wp-admin/includes/meta-boxes.php b/src/wp-admin/includes/meta-boxes.php index 2b4760a6da..3b66b9a0f0 100644 --- a/src/wp-admin/includes/meta-boxes.php +++ b/src/wp-admin/includes/meta-boxes.php @@ -46,15 +46,15 @@ function post_submit_meta_box( $post, $args = array() ) { <div id="minor-publishing-actions"> <div id="save-action"> <?php - if ( 'publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { + if ( ! in_array( $post->post_status, array( 'publish', 'future', 'pending' ), true ) ) { $private_style = ''; - if ( 'private' == $post->post_status ) { + if ( 'private' === $post->post_status ) { $private_style = 'style="display:none"'; } ?> <input <?php echo $private_style; ?> type="submit" name="save" id="save-post" value="<?php esc_attr_e( 'Save Draft' ); ?>" class="button" /> <span class="spinner"></span> -<?php } elseif ( 'pending' == $post->post_status && $can_publish ) { ?> +<?php } elseif ( 'pending' === $post->post_status && $can_publish ) { ?> <input type="submit" name="save" id="save-post" value="<?php esc_attr_e( 'Save as Pending' ); ?>" class="button" /> <span class="spinner"></span> <?php } ?> @@ -63,7 +63,7 @@ function post_submit_meta_box( $post, $args = array() ) { <div id="preview-action"> <?php $preview_link = esc_url( get_preview_post_link( $post ) ); - if ( 'publish' == $post->post_status ) { + if ( 'publish' === $post->post_status ) { $preview_button_text = __( 'Preview Changes' ); } else { $preview_button_text = __( 'Preview' ); @@ -120,27 +120,27 @@ function post_submit_meta_box( $post, $args = array() ) { ?> </span> <?php - if ( 'publish' == $post->post_status || 'private' == $post->post_status || $can_publish ) { + if ( 'publish' === $post->post_status || 'private' === $post->post_status || $can_publish ) { $private_style = ''; - if ( 'private' == $post->post_status ) { + if ( 'private' === $post->post_status ) { $private_style = 'style="display:none"'; } ?> <a href="#post_status" <?php echo $private_style; ?> class="edit-post-status hide-if-no-js" role="button"><span aria-hidden="true"><?php _e( 'Edit' ); ?></span> <span class="screen-reader-text"><?php _e( 'Edit status' ); ?></span></a> <div id="post-status-select" class="hide-if-js"> -<input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr( ( 'auto-draft' == $post->post_status ) ? 'draft' : $post->post_status ); ?>" /> +<input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr( ( 'auto-draft' === $post->post_status ) ? 'draft' : $post->post_status ); ?>" /> <label for="post_status" class="screen-reader-text"><?php _e( 'Set status' ); ?></label> <select name="post_status" id="post_status"> - <?php if ( 'publish' == $post->post_status ) : ?> + <?php if ( 'publish' === $post->post_status ) : ?> <option<?php selected( $post->post_status, 'publish' ); ?> value='publish'><?php _e( 'Published' ); ?></option> -<?php elseif ( 'private' == $post->post_status ) : ?> +<?php elseif ( 'private' === $post->post_status ) : ?> <option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e( 'Privately Published' ); ?></option> -<?php elseif ( 'future' == $post->post_status ) : ?> +<?php elseif ( 'future' === $post->post_status ) : ?> <option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e( 'Scheduled' ); ?></option> <?php endif; ?> <option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e( 'Pending Review' ); ?></option> - <?php if ( 'auto-draft' == $post->post_status ) : ?> + <?php if ( 'auto-draft' === $post->post_status ) : ?> <option<?php selected( $post->post_status, 'auto-draft' ); ?> value='draft'><?php _e( 'Draft' ); ?></option> <?php else : ?> <option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e( 'Draft' ); ?></option> @@ -210,13 +210,13 @@ function post_submit_meta_box( $post, $args = array() ) { $time_format = _x( 'H:i', 'publish box time format' ); if ( 0 != $post->ID ) { - if ( 'future' == $post->post_status ) { // Scheduled for publishing at a future date. + if ( 'future' === $post->post_status ) { // Scheduled for publishing at a future date. /* translators: Post date information. %s: Date on which the post is currently scheduled to be published. */ $stamp = __( 'Scheduled for: %s' ); - } elseif ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // Already published. + } elseif ( 'publish' === $post->post_status || 'private' === $post->post_status ) { // Already published. /* translators: Post date information. %s: Date on which the post was published. */ $stamp = __( 'Published on: %s' ); - } elseif ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // Draft, 1 or more saves, no date specified. + } elseif ( '0000-00-00 00:00:00' === $post->post_date_gmt ) { // Draft, 1 or more saves, no date specified. $stamp = __( 'Publish <b>immediately</b>' ); } elseif ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // Draft, 1 or more saves, future date specified. /* translators: Post date information. %s: Date on which the post is to be published. */ @@ -708,7 +708,8 @@ function post_excerpt_meta_box( $post ) { function post_trackback_meta_box( $post ) { $form_trackback = '<input type="text" name="trackback_url" id="trackback_url" class="code" value="' . esc_attr( str_replace( "\n", ' ', $post->to_ping ) ) . '" aria-describedby="trackback-url-desc" />'; - if ( '' != $post->pinged ) { + + if ( '' !== $post->pinged ) { $pings = '<p>' . __( 'Already pinged:' ) . '</p><ul>'; $already_pinged = explode( "\n", trim( $post->pinged ) ); foreach ( $already_pinged as $pinged_url ) { @@ -1002,7 +1003,7 @@ function page_attributes_meta_box( $post ) { */ do_action( 'page_attributes_misc_attributes', $post ); ?> - <?php if ( 'page' == $post->post_type && get_current_screen()->get_help_tabs() ) : ?> + <?php if ( 'page' === $post->post_type && get_current_screen()->get_help_tabs() ) : ?> <p class="post-attributes-help-text"><?php _e( 'Need help? Use the Help tab above the screen title.' ); ?></p> <?php endif; @@ -1055,7 +1056,7 @@ function link_submit_meta_box( $link ) { ?> <div id="delete-action"> <?php - if ( ! empty( $_GET['action'] ) && 'edit' == $_GET['action'] && current_user_can( 'manage_links' ) ) { + if ( ! empty( $_GET['action'] ) && 'edit' === $_GET['action'] && current_user_can( 'manage_links' ) ) { printf( '<a class="submitdelete deletion" href="%s" onclick="return confirm( \'%s\' );">%s</a>', wp_nonce_url( "link.php?action=delete&link_id=$link->link_id", 'delete-bookmark_' . $link->link_id ), @@ -1182,21 +1183,21 @@ function xfn_check( $class, $value = '', $deprecated = '' ) { $link_rel = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: ''; $rels = preg_split( '/\s+/', $link_rel ); - if ( '' != $value && in_array( $value, $rels, true ) ) { + if ( '' !== $value && in_array( $value, $rels, true ) ) { echo ' checked="checked"'; } - if ( '' == $value ) { - if ( 'family' == $class && strpos( $link_rel, 'child' ) === false && strpos( $link_rel, 'parent' ) === false && strpos( $link_rel, 'sibling' ) === false && strpos( $link_rel, 'spouse' ) === false && strpos( $link_rel, 'kin' ) === false ) { + if ( '' === $value ) { + if ( 'family' === $class && strpos( $link_rel, 'child' ) === false && strpos( $link_rel, 'parent' ) === false && strpos( $link_rel, 'sibling' ) === false && strpos( $link_rel, 'spouse' ) === false && strpos( $link_rel, 'kin' ) === false ) { echo ' checked="checked"'; } - if ( 'friendship' == $class && strpos( $link_rel, 'friend' ) === false && strpos( $link_rel, 'acquaintance' ) === false && strpos( $link_rel, 'contact' ) === false ) { + if ( 'friendship' === $class && strpos( $link_rel, 'friend' ) === false && strpos( $link_rel, 'acquaintance' ) === false && strpos( $link_rel, 'contact' ) === false ) { echo ' checked="checked"'; } - if ( 'geographical' == $class && strpos( $link_rel, 'co-resident' ) === false && strpos( $link_rel, 'neighbor' ) === false ) { + if ( 'geographical' === $class && strpos( $link_rel, 'co-resident' ) === false && strpos( $link_rel, 'neighbor' ) === false ) { echo ' checked="checked"'; } - if ( 'identity' == $class && in_array( 'me', $rels, true ) ) { + if ( 'identity' === $class && in_array( 'me', $rels, true ) ) { echo ' checked="checked"'; } } @@ -1421,7 +1422,7 @@ function register_and_do_post_meta_boxes( $post ) { } $publish_callback_args = array( '__back_compat_meta_box' => true ); - if ( post_type_supports( $post_type, 'revisions' ) && 'auto-draft' != $post->post_status ) { + if ( post_type_supports( $post_type, 'revisions' ) && 'auto-draft' !== $post->post_status ) { $revisions = wp_get_post_revisions( $post->ID ); // We should aim to show the revisions meta box only when there are revisions. @@ -1436,7 +1437,7 @@ function register_and_do_post_meta_boxes( $post ) { } } - if ( 'attachment' == $post_type ) { + if ( 'attachment' === $post_type ) { wp_enqueue_script( 'image-edit' ); wp_enqueue_style( 'imgareaselect' ); add_meta_box( 'submitdiv', __( 'Save' ), 'attachment_submit_meta_box', null, 'side', 'core', array( '__back_compat_meta_box' => true ) ); @@ -1543,7 +1544,7 @@ function register_and_do_post_meta_boxes( $post ) { } } - if ( ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) { + if ( ! ( 'pending' === get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) { add_meta_box( 'slugdiv', __( 'Slug' ), 'post_slug_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); } diff --git a/src/wp-admin/includes/misc.php b/src/wp-admin/includes/misc.php index 628ec7bb7b..51fa058393 100644 --- a/src/wp-admin/includes/misc.php +++ b/src/wp-admin/includes/misc.php @@ -597,7 +597,7 @@ function wp_doc_link_parse( $content ) { continue; } - if ( T_STRING == $tokens[ $t ][0] && ( '(' == $tokens[ $t + 1 ] || '(' == $tokens[ $t + 2 ] ) ) { + if ( T_STRING == $tokens[ $t ][0] && ( '(' === $tokens[ $t + 1 ] || '(' === $tokens[ $t + 2 ] ) ) { // If it's a function or class defined locally, there's not going to be any docs available. if ( ( isset( $tokens[ $t - 2 ][1] ) && in_array( $tokens[ $t - 2 ][1], array( 'function', 'class' ), true ) ) || ( isset( $tokens[ $t - 2 ][0] ) && T_OBJECT_OPERATOR == $tokens[ $t - 1 ][0] ) diff --git a/src/wp-admin/includes/ms.php b/src/wp-admin/includes/ms.php index f683c737ef..aaffbd2266 100644 --- a/src/wp-admin/includes/ms.php +++ b/src/wp-admin/includes/ms.php @@ -696,7 +696,7 @@ function site_admin_notice() { return false; } - if ( 'upgrade.php' == $pagenow ) { + if ( 'upgrade.php' === $pagenow ) { return; } @@ -873,7 +873,7 @@ function confirm_delete_users( $users ) { <?php $allusers = (array) $_POST['allusers']; foreach ( $allusers as $user_id ) { - if ( '' != $user_id && '0' != $user_id ) { + if ( '' !== $user_id && '0' != $user_id ) { $delete_user = get_userdata( $user_id ); if ( ! current_user_can( 'delete_user', $delete_user->ID ) ) { @@ -935,7 +935,7 @@ function confirm_delete_users( $users ) { } } - if ( '' == $user_list ) { + if ( '' === $user_list ) { $user_list = $admin_out; } diff --git a/src/wp-admin/includes/nav-menu.php b/src/wp-admin/includes/nav-menu.php index 3cd7f53459..b4ba257153 100644 --- a/src/wp-admin/includes/nav-menu.php +++ b/src/wp-admin/includes/nav-menu.php @@ -31,17 +31,17 @@ function _wp_ajax_menu_quick_search( $request = array() ) { $response_format = 'json'; } - if ( 'markup' == $response_format ) { + if ( 'markup' === $response_format ) { $args['walker'] = new Walker_Nav_Menu_Checklist; } - if ( 'get-post-item' == $type ) { + if ( 'get-post-item' === $type ) { if ( post_type_exists( $object_type ) ) { if ( isset( $request['ID'] ) ) { $object_id = (int) $request['ID']; - if ( 'markup' == $response_format ) { + if ( 'markup' === $response_format ) { echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( get_post( $object_id ) ) ), 0, (object) $args ); - } elseif ( 'json' == $response_format ) { + } elseif ( 'json' === $response_format ) { echo wp_json_encode( array( 'ID' => $object_id, @@ -55,9 +55,9 @@ function _wp_ajax_menu_quick_search( $request = array() ) { } elseif ( taxonomy_exists( $object_type ) ) { if ( isset( $request['ID'] ) ) { $object_id = (int) $request['ID']; - if ( 'markup' == $response_format ) { + if ( 'markup' === $response_format ) { echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( get_term( $object_id, $object_type ) ) ), 0, (object) $args ); - } elseif ( 'json' == $response_format ) { + } elseif ( 'json' === $response_format ) { $post_obj = get_term( $object_id, $object_type ); echo wp_json_encode( array( @@ -71,7 +71,7 @@ function _wp_ajax_menu_quick_search( $request = array() ) { } } } elseif ( preg_match( '/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\b)/', $type, $matches ) ) { - if ( 'posttype' == $matches[1] && get_post_type_object( $matches[2] ) ) { + if ( 'posttype' === $matches[1] && get_post_type_object( $matches[2] ) ) { $post_type_obj = _wp_nav_menu_meta_box_object( get_post_type_object( $matches[2] ) ); $args = array_merge( $args, @@ -93,10 +93,10 @@ function _wp_ajax_menu_quick_search( $request = array() ) { } while ( $search_results_query->have_posts() ) { $post = $search_results_query->next_post(); - if ( 'markup' == $response_format ) { + if ( 'markup' === $response_format ) { $var_by_ref = $post->ID; echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( get_post( $var_by_ref ) ) ), 0, (object) $args ); - } elseif ( 'json' == $response_format ) { + } elseif ( 'json' === $response_format ) { echo wp_json_encode( array( 'ID' => $post->ID, @@ -107,7 +107,7 @@ function _wp_ajax_menu_quick_search( $request = array() ) { echo "\n"; } } - } elseif ( 'taxonomy' == $matches[1] ) { + } elseif ( 'taxonomy' === $matches[1] ) { $terms = get_terms( array( 'taxonomy' => $matches[2], @@ -120,9 +120,9 @@ function _wp_ajax_menu_quick_search( $request = array() ) { return; } foreach ( (array) $terms as $term ) { - if ( 'markup' == $response_format ) { + if ( 'markup' === $response_format ) { echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args ); - } elseif ( 'json' == $response_format ) { + } elseif ( 'json' === $response_format ) { echo wp_json_encode( array( 'ID' => $term->term_id, @@ -231,7 +231,7 @@ function wp_nav_menu_post_type_meta_boxes() { if ( $post_type ) { $id = $post_type->name; // Give pages a higher priority. - $priority = ( 'page' == $post_type->name ? 'core' : 'default' ); + $priority = ( 'page' === $post_type->name ? 'core' : 'default' ); add_meta_box( "add-post-type-{$id}", $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', $priority, $post_type ); } } @@ -368,11 +368,11 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) { * Posts Page and Privacy Policy Page at the top of the list. */ $important_pages = array(); - if ( 'page' == $post_type_name ) { + if ( 'page' === $post_type_name ) { $suppress_page_ids = array(); // Insert Front Page or custom Home link. - $front_page = 'page' == get_option( 'show_on_front' ) ? (int) get_option( 'page_on_front' ) : 0; + $front_page = 'page' === get_option( 'show_on_front' ) ? (int) get_option( 'page_on_front' ) : 0; $front_page_obj = null; if ( ! empty( $front_page ) ) { @@ -400,7 +400,7 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) { } // Insert Posts Page. - $posts_page = 'page' == get_option( 'show_on_front' ) ? (int) get_option( 'page_for_posts' ) : 0; + $posts_page = 'page' === get_option( 'show_on_front' ) ? (int) get_option( 'page_for_posts' ) : 0; if ( ! empty( $posts_page ) ) { $posts_page_obj = get_post( $posts_page ); @@ -508,24 +508,24 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) { ?> <div id="posttype-<?php echo $post_type_name; ?>" class="posttypediv"> <ul id="posttype-<?php echo $post_type_name; ?>-tabs" class="posttype-tabs add-menu-item-tabs"> - <li <?php echo ( 'most-recent' == $current_tab ? ' class="tabs"' : '' ); ?>> + <li <?php echo ( 'most-recent' === $current_tab ? ' class="tabs"' : '' ); ?>> <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-most-recent" href="<?php echo $most_recent_url; ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent"> <?php _e( 'Most Recent' ); ?> </a> </li> - <li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>> + <li <?php echo ( 'all' === $current_tab ? ' class="tabs"' : '' ); ?>> <a class="nav-tab-link" data-type="<?php echo esc_attr( $post_type_name ); ?>-all" href="<?php echo $view_all_url; ?>#<?php echo $post_type_name; ?>-all"> <?php _e( 'View All' ); ?> </a> </li> - <li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>> + <li <?php echo ( 'search' === $current_tab ? ' class="tabs"' : '' ); ?>> <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-search" href="<?php echo $search_url; ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search"> <?php _e( 'Search' ); ?> </a> </li> </ul><!-- .posttype-tabs --> - <div id="tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent" class="tabs-panel <?php echo ( 'most-recent' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php _e( 'Most Recent' ); ?>" tabindex="0"> + <div id="tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent" class="tabs-panel <?php echo ( 'most-recent' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php _e( 'Most Recent' ); ?>" tabindex="0"> <ul id="<?php echo $post_type_name; ?>checklist-most-recent" class="categorychecklist form-no-clear"> <?php $recent_args = array_merge( @@ -560,7 +560,7 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) { </ul> </div><!-- /.tabs-panel --> - <div class="tabs-panel <?php echo ( 'search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" id="tabs-panel-posttype-<?php echo $post_type_name; ?>-search" role="region" aria-label="<?php echo $post_type->labels->search_items; ?>" tabindex="0"> + <div class="tabs-panel <?php echo ( 'search' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" id="tabs-panel-posttype-<?php echo $post_type_name; ?>-search" role="region" aria-label="<?php echo $post_type->labels->search_items; ?>" tabindex="0"> <?php if ( isset( $_REQUEST[ 'quick-search-posttype-' . $post_type_name ] ) ) { $searched = esc_attr( $_REQUEST[ 'quick-search-posttype-' . $post_type_name ] ); @@ -598,7 +598,7 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) { </ul> </div><!-- /.tabs-panel --> - <div id="<?php echo $post_type_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php echo $post_type->labels->all_items; ?>" tabindex="0"> + <div id="<?php echo $post_type_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php echo ( 'all' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php echo $post_type->labels->all_items; ?>" tabindex="0"> <?php if ( ! empty( $page_links ) ) : ?> <div class="add-menu-item-pagelinks"> <?php echo $page_links; ?> @@ -795,24 +795,24 @@ function wp_nav_menu_item_taxonomy_meta_box( $object, $box ) { ?> <div id="taxonomy-<?php echo $taxonomy_name; ?>" class="taxonomydiv"> <ul id="taxonomy-<?php echo $taxonomy_name; ?>-tabs" class="taxonomy-tabs add-menu-item-tabs"> - <li <?php echo ( 'most-used' == $current_tab ? ' class="tabs"' : '' ); ?>> + <li <?php echo ( 'most-used' === $current_tab ? ' class="tabs"' : '' ); ?>> <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-pop" href="<?php echo $most_used_url; ?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop"> <?php echo esc_html( $taxonomy->labels->most_used ); ?> </a> </li> - <li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>> + <li <?php echo ( 'all' === $current_tab ? ' class="tabs"' : '' ); ?>> <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-all" href="<?php echo $view_all_url; ?>#tabs-panel-<?php echo $taxonomy_name; ?>-all"> <?php _e( 'View All' ); ?> </a> </li> - <li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>> + <li <?php echo ( 'search' === $current_tab ? ' class="tabs"' : '' ); ?>> <a class="nav-tab-link" data-type="tabs-panel-search-taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>" href="<?php echo $search_url; ?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>"> <?php _e( 'Search' ); ?> </a> </li> </ul><!-- .taxonomy-tabs --> - <div id="tabs-panel-<?php echo $taxonomy_name; ?>-pop" class="tabs-panel <?php echo ( 'most-used' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php echo $taxonomy->labels->most_used; ?>" tabindex="0"> + <div id="tabs-panel-<?php echo $taxonomy_name; ?>-pop" class="tabs-panel <?php echo ( 'most-used' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php echo $taxonomy->labels->most_used; ?>" tabindex="0"> <ul id="<?php echo $taxonomy_name; ?>checklist-pop" class="categorychecklist form-no-clear" > <?php $popular_terms = get_terms( @@ -830,7 +830,7 @@ function wp_nav_menu_item_taxonomy_meta_box( $object, $box ) { </ul> </div><!-- /.tabs-panel --> - <div id="tabs-panel-<?php echo $taxonomy_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php echo $taxonomy->labels->all_items; ?>" tabindex="0"> + <div id="tabs-panel-<?php echo $taxonomy_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php echo ( 'all' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php echo $taxonomy->labels->all_items; ?>" tabindex="0"> <?php if ( ! empty( $page_links ) ) : ?> <div class="add-menu-item-pagelinks"> <?php echo $page_links; ?> @@ -849,7 +849,7 @@ function wp_nav_menu_item_taxonomy_meta_box( $object, $box ) { <?php endif; ?> </div><!-- /.tabs-panel --> - <div class="tabs-panel <?php echo ( 'search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" id="tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>" role="region" aria-label="<?php echo $taxonomy->labels->search_items; ?>" tabindex="0"> + <div class="tabs-panel <?php echo ( 'search' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" id="tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>" role="region" aria-label="<?php echo $taxonomy->labels->search_items; ?>" tabindex="0"> <?php if ( isset( $_REQUEST[ 'quick-search-taxonomy-' . $taxonomy_name ] ) ) { $searched = esc_attr( $_REQUEST[ 'quick-search-taxonomy-' . $taxonomy_name ] ); @@ -931,7 +931,7 @@ function wp_save_nav_menu_items( $menu_id = 0, $menu_data = array() ) { // Or URL is the default. in_array( $_item_object_data['menu-item-url'], array( 'https://', 'http://', '' ), true ) || // Or it's not a custom menu item (but not the custom home page). - ! ( 'custom' == $_item_object_data['menu-item-type'] && ! isset( $_item_object_data['menu-item-db-id'] ) ) || + ! ( 'custom' === $_item_object_data['menu-item-type'] && ! isset( $_item_object_data['menu-item-db-id'] ) ) || // Or it *is* a custom menu item that already exists. ! empty( $_item_object_data['menu-item-db-id'] ) ) @@ -987,20 +987,20 @@ function wp_save_nav_menu_items( $menu_id = 0, $menu_data = array() ) { function _wp_nav_menu_meta_box_object( $object = null ) { if ( isset( $object->name ) ) { - if ( 'page' == $object->name ) { + if ( 'page' === $object->name ) { $object->_default_query = array( 'orderby' => 'menu_order title', 'post_status' => 'publish', ); // Posts should show only published items. - } elseif ( 'post' == $object->name ) { + } elseif ( 'post' === $object->name ) { $object->_default_query = array( 'post_status' => 'publish', ); // Categories should be in reverse chronological order. - } elseif ( 'category' == $object->name ) { + } elseif ( 'category' === $object->name ) { $object->_default_query = array( 'orderby' => 'id', 'order' => 'DESC', @@ -1066,7 +1066,7 @@ function wp_get_nav_menu_to_edit( $menu_id = 0 ) { $some_pending_menu_items = false; $some_invalid_menu_items = false; foreach ( (array) $menu_items as $menu_item ) { - if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status ) { + if ( isset( $menu_item->post_status ) && 'draft' === $menu_item->post_status ) { $some_pending_menu_items = true; } if ( ! empty( $menu_item->_invalid ) ) { @@ -1182,7 +1182,7 @@ function wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selecte foreach ( (array) $_POST['menu-item-db-id'] as $_key => $k ) { // Menu item title can't be blank. - if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] ) { + if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' === $_POST['menu-item-title'][ $_key ] ) { continue; } diff --git a/src/wp-admin/includes/options.php b/src/wp-admin/includes/options.php index 7911abcfba..c7fe3c8779 100644 --- a/src/wp-admin/includes/options.php +++ b/src/wp-admin/includes/options.php @@ -49,16 +49,17 @@ function options_general_add_js() { $siteName.text( title ); }); - $("input[name='date_format']").click(function(){ - if ( "date_format_custom_radio" != $(this).attr("id") ) + $( 'input[name="date_format"]' ).click( function() { + if ( 'date_format_custom_radio' !== $(this).attr( 'id' ) ) $( 'input[name="date_format_custom"]' ).val( $( this ).val() ).closest( 'fieldset' ).find( '.example' ).text( $( this ).parent( 'label' ).children( '.format-i18n' ).text() ); }); + $( 'input[name="date_format_custom"]' ).on( 'click input', function() { $( '#date_format_custom_radio' ).prop( 'checked', true ); }); - $("input[name='time_format']").click(function(){ - if ( "time_format_custom_radio" != $(this).attr("id") ) + $( 'input[name="time_format"]' ).click( function() { + if ( 'time_format_custom_radio' !== $(this).attr( 'id' ) ) $( 'input[name="time_format_custom"]' ).val( $( this ).val() ).closest( 'fieldset' ).find( '.example' ).text( $( this ).parent( 'label' ).children( '.format-i18n' ).text() ); }); @@ -80,7 +81,7 @@ function options_general_add_js() { spinner.addClass( 'is-active' ); $.post( ajaxurl, { - action: 'date_format_custom' == format.attr( 'name' ) ? 'date_format' : 'time_format', + action: 'date_format_custom' === format.attr( 'name' ) ? 'date_format' : 'time_format', date : format.val() }, function( d ) { spinner.removeClass( 'is-active' ); example.text( d ); } ); } diff --git a/src/wp-admin/includes/plugin-install.php b/src/wp-admin/includes/plugin-install.php index 9f90f84cb5..f58f6cb31a 100644 --- a/src/wp-admin/includes/plugin-install.php +++ b/src/wp-admin/includes/plugin-install.php @@ -107,7 +107,7 @@ function plugins_api( $action, $args = array() ) { $args = (object) $args; } - if ( 'query_plugins' == $action ) { + if ( 'query_plugins' === $action ) { if ( ! isset( $args->per_page ) ) { $args->per_page = 24; } @@ -462,7 +462,7 @@ function install_plugin_install_status( $api, $loop = false ) { } } - if ( 'install' == $status ) { + if ( 'install' === $status ) { if ( is_dir( WP_PLUGIN_DIR . '/' . $api->slug ) ) { $installed_plugin = get_plugins( '/' . $api->slug ); if ( empty( $installed_plugin ) ) { diff --git a/src/wp-admin/includes/plugin.php b/src/wp-admin/includes/plugin.php index 222dcf8f73..ca3f1fc054 100644 --- a/src/wp-admin/includes/plugin.php +++ b/src/wp-admin/includes/plugin.php @@ -91,7 +91,7 @@ function get_plugin_data( $plugin_file, $markup = true, $translate = true ) { _deprecated_argument( __FUNCTION__, '3.0.0', sprintf( __( 'The %1$s plugin header is deprecated. Use %2$s instead.' ), '<code>Site Wide Only: true</code>', '<code>Network: true</code>' ) ); $plugin_data['Network'] = $plugin_data['_sitewide']; } - $plugin_data['Network'] = ( 'true' == strtolower( $plugin_data['Network'] ) ); + $plugin_data['Network'] = ( 'true' === strtolower( $plugin_data['Network'] ) ); unset( $plugin_data['_sitewide'] ); // If no text domain is defined fall back to the plugin slug. @@ -156,7 +156,7 @@ function _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) ); } } - } elseif ( 'hello.php' == basename( $plugin_file ) ) { + } elseif ( 'hello.php' === basename( $plugin_file ) ) { $textdomain = 'default'; } if ( $textdomain ) { @@ -295,30 +295,36 @@ function get_plugins( $plugin_folder = '' ) { // Files in wp-content/plugins directory. $plugins_dir = @ opendir( $plugin_root ); $plugin_files = array(); + if ( $plugins_dir ) { while ( ( $file = readdir( $plugins_dir ) ) !== false ) { - if ( substr( $file, 0, 1 ) == '.' ) { + if ( '.' === substr( $file, 0, 1 ) ) { continue; } + if ( is_dir( $plugin_root . '/' . $file ) ) { $plugins_subdir = @ opendir( $plugin_root . '/' . $file ); + if ( $plugins_subdir ) { while ( ( $subfile = readdir( $plugins_subdir ) ) !== false ) { - if ( substr( $subfile, 0, 1 ) == '.' ) { + if ( '.' === substr( $subfile, 0, 1 ) ) { continue; } - if ( substr( $subfile, -4 ) == '.php' ) { + + if ( '.php' === substr( $subfile, -4 ) ) { $plugin_files[] = "$file/$subfile"; } } + closedir( $plugins_subdir ); } } else { - if ( substr( $file, -4 ) == '.php' ) { + if ( '.php' === substr( $file, -4 ) ) { $plugin_files[] = $file; } } } + closedir( $plugins_dir ); } @@ -369,7 +375,7 @@ function get_mu_plugins() { $plugins_dir = @opendir( WPMU_PLUGIN_DIR ); if ( $plugins_dir ) { while ( ( $file = readdir( $plugins_dir ) ) !== false ) { - if ( substr( $file, -4 ) == '.php' ) { + if ( '.php' === substr( $file, -4 ) ) { $plugin_files[] = $file; } } @@ -1444,7 +1450,7 @@ function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, * Backward-compatibility for plugins using add_management_page(). * See wp-admin/admin.php for redirect from edit.php to tools.php. */ - if ( 'tools.php' == $parent_slug ) { + if ( 'tools.php' === $parent_slug ) { $_registered_pages[ get_plugin_page_hookname( $menu_slug, 'edit.php' ) ] = true; } @@ -1836,7 +1842,7 @@ function get_admin_page_parent( $parent = '' ) { global $parent_file, $menu, $submenu, $pagenow, $typenow, $plugin_page, $_wp_real_parent_file, $_wp_menu_nopriv, $_wp_submenu_nopriv; - if ( ! empty( $parent ) && 'admin.php' != $parent ) { + if ( ! empty( $parent ) && 'admin.php' !== $parent ) { if ( isset( $_wp_real_parent_file[ $parent ] ) ) { $parent = $_wp_real_parent_file[ $parent ]; } @@ -2018,7 +2024,7 @@ function get_plugin_page_hookname( $plugin_page, $parent_page ) { $parent = get_admin_page_parent( $parent_page ); $page_type = 'admin'; - if ( empty( $parent_page ) || 'admin.php' == $parent_page || isset( $admin_page_hooks[ $plugin_page ] ) ) { + if ( empty( $parent_page ) || 'admin.php' === $parent_page || isset( $admin_page_hooks[ $plugin_page ] ) ) { if ( isset( $admin_page_hooks[ $plugin_page ] ) ) { $page_type = 'toplevel'; } elseif ( isset( $admin_page_hooks[ $parent ] ) ) { @@ -2165,7 +2171,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; @@ -2200,7 +2206,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; diff --git a/src/wp-admin/includes/post.php b/src/wp-admin/includes/post.php index a554932951..c5bad99766 100644 --- a/src/wp-admin/includes/post.php +++ b/src/wp-admin/includes/post.php @@ -30,13 +30,13 @@ function _wp_translate_postdata( $update = false, $post_data = null ) { $ptype = get_post_type_object( $post_data['post_type'] ); if ( $update && ! current_user_can( 'edit_post', $post_data['ID'] ) ) { - if ( 'page' == $post_data['post_type'] ) { + if ( 'page' === $post_data['post_type'] ) { return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to edit pages as this user.' ) ); } else { return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to edit posts as this user.' ) ); } } elseif ( ! $update && ! current_user_can( $ptype->cap->create_posts ) ) { - if ( 'page' == $post_data['post_type'] ) { + if ( 'page' === $post_data['post_type'] ) { return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to create pages as this user.' ) ); } else { return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to create posts as this user.' ) ); @@ -75,13 +75,13 @@ function _wp_translate_postdata( $update = false, $post_data = null ) { && ! current_user_can( $ptype->cap->edit_others_posts ) ) { if ( $update ) { - if ( 'page' == $post_data['post_type'] ) { + if ( 'page' === $post_data['post_type'] ) { return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to edit pages as this user.' ) ); } else { return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to edit posts as this user.' ) ); } } else { - if ( 'page' == $post_data['post_type'] ) { + if ( 'page' === $post_data['post_type'] ) { return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to create pages as this user.' ) ); } else { return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to create posts as this user.' ) ); @@ -103,19 +103,21 @@ function _wp_translate_postdata( $update = false, $post_data = null ) { } // What to do based on which button they pressed. - if ( isset( $post_data['saveasdraft'] ) && '' != $post_data['saveasdraft'] ) { + if ( isset( $post_data['saveasdraft'] ) && '' !== $post_data['saveasdraft'] ) { $post_data['post_status'] = 'draft'; } - if ( isset( $post_data['saveasprivate'] ) && '' != $post_data['saveasprivate'] ) { + 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'] ) || 'private' !== $post_data['post_status'] ) ) { + 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'] ) { + if ( isset( $post_data['advanced'] ) && '' !== $post_data['advanced'] ) { $post_data['post_status'] = 'draft'; } - if ( isset( $post_data['pending'] ) && '' != $post_data['pending'] ) { + if ( isset( $post_data['pending'] ) && '' !== $post_data['pending'] ) { $post_data['post_status'] = 'pending'; } @@ -126,7 +128,7 @@ function _wp_translate_postdata( $update = false, $post_data = null ) { } $previous_status = $post_id ? get_post_field( 'post_status', $post_id ) : false; - if ( isset( $post_data['post_status'] ) && 'private' == $post_data['post_status'] && ! current_user_can( $ptype->cap->publish_posts ) ) { + if ( isset( $post_data['post_status'] ) && 'private' === $post_data['post_status'] && ! current_user_can( $ptype->cap->publish_posts ) ) { $post_data['post_status'] = $previous_status ? $previous_status : 'pending'; } @@ -247,14 +249,14 @@ function edit_post( $post_data = null ) { if ( ! empty( $post_data['post_status'] ) ) { $post_data['post_status'] = sanitize_key( $post_data['post_status'] ); - if ( 'inherit' == $post_data['post_status'] ) { + if ( 'inherit' === $post_data['post_status'] ) { unset( $post_data['post_status'] ); } } $ptype = get_post_type_object( $post_data['post_type'] ); if ( ! current_user_can( 'edit_post', $post_ID ) ) { - if ( 'page' == $post_data['post_type'] ) { + if ( 'page' === $post_data['post_type'] ) { wp_die( __( 'Sorry, you are not allowed to edit this page.' ) ); } else { wp_die( __( 'Sorry, you are not allowed to edit this post.' ) ); @@ -376,7 +378,7 @@ function edit_post( $post_data = null ) { } // Attachment stuff. - if ( 'attachment' == $post_data['post_type'] ) { + if ( 'attachment' === $post_data['post_type'] ) { if ( isset( $post_data['_wp_attachment_image_alt'] ) ) { $image_alt = wp_unslash( $post_data['_wp_attachment_image_alt'] ); @@ -467,7 +469,7 @@ function bulk_edit_posts( $post_data = null ) { } if ( ! current_user_can( $ptype->cap->edit_posts ) ) { - if ( 'page' == $ptype->name ) { + if ( 'page' === $ptype->name ) { wp_die( __( 'Sorry, you are not allowed to edit pages.' ) ); } else { wp_die( __( 'Sorry, you are not allowed to edit posts.' ) ); @@ -485,7 +487,7 @@ function bulk_edit_posts( $post_data = null ) { if ( ! empty( $post_data['post_status'] ) ) { $post_data['post_status'] = sanitize_key( $post_data['post_status'] ); - if ( 'inherit' == $post_data['post_status'] ) { + if ( 'inherit' === $post_data['post_status'] ) { unset( $post_data['post_status'] ); } } @@ -508,7 +510,7 @@ function bulk_edit_posts( $post_data = null ) { ); foreach ( $reset as $field ) { - if ( isset( $post_data[ $field ] ) && ( '' == $post_data[ $field ] || -1 == $post_data[ $field ] ) ) { + if ( isset( $post_data[ $field ] ) && ( '' === $post_data[ $field ] || -1 == $post_data[ $field ] ) ) { unset( $post_data[ $field ] ); } } @@ -632,7 +634,7 @@ function bulk_edit_posts( $post_data = null ) { $updated[] = wp_update_post( $post_data ); if ( isset( $post_data['sticky'] ) && current_user_can( $ptype->cap->edit_others_posts ) ) { - if ( 'sticky' == $post_data['sticky'] ) { + if ( 'sticky' === $post_data['sticky'] ) { stick_post( $post_ID ); } else { unstick_post( $post_ID ); @@ -813,7 +815,7 @@ function wp_write_post() { } if ( ! current_user_can( $ptype->cap->edit_posts ) ) { - if ( 'page' == $ptype->name ) { + if ( 'page' === $ptype->name ) { return new WP_Error( 'edit_pages', __( 'Sorry, you are not allowed to create pages on this site.' ) ); } else { return new WP_Error( 'edit_posts', __( 'Sorry, you are not allowed to create posts or drafts on this site.' ) ); @@ -912,12 +914,12 @@ function add_meta( $post_ID ) { $metavalue = trim( $metavalue ); } - if ( ( ( '#NONE#' != $metakeyselect ) && ! empty( $metakeyselect ) ) || ! empty( $metakeyinput ) ) { + if ( ( ( '#NONE#' !== $metakeyselect ) && ! empty( $metakeyselect ) ) || ! empty( $metakeyinput ) ) { /* * We have a key/value pair. If both the select and the input * for the key have data, the input takes precedence. */ - if ( '#NONE#' != $metakeyselect ) { + if ( '#NONE#' !== $metakeyselect ) { $metakey = $metakeyselect; } @@ -1143,7 +1145,7 @@ function wp_edit_posts_query( $q = false ) { if ( isset( $q['order'] ) ) { $order = $q['order']; - } elseif ( isset( $q['post_status'] ) && 'pending' == $q['post_status'] ) { + } elseif ( isset( $q['post_status'] ) && 'pending' === $q['post_status'] ) { $order = 'ASC'; } @@ -1220,8 +1222,8 @@ function wp_edit_attachments_query_vars( $q = false ) { $states .= ',private'; } - $q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : $states; - $q['post_status'] = isset( $q['attachment-filter'] ) && 'trash' == $q['attachment-filter'] ? 'trash' : $states; + $q['post_status'] = isset( $q['status'] ) && 'trash' === $q['status'] ? 'trash' : $states; + $q['post_status'] = isset( $q['attachment-filter'] ) && 'trash' === $q['attachment-filter'] ? 'trash' : $states; $media_per_page = (int) get_user_option( 'upload_per_page' ); if ( empty( $media_per_page ) || $media_per_page < 1 ) { @@ -1243,17 +1245,17 @@ function wp_edit_attachments_query_vars( $q = false ) { } foreach ( array_keys( $post_mime_types ) as $type ) { - if ( isset( $q['attachment-filter'] ) && "post_mime_type:$type" == $q['attachment-filter'] ) { + if ( isset( $q['attachment-filter'] ) && "post_mime_type:$type" === $q['attachment-filter'] ) { $q['post_mime_type'] = $type; break; } } - if ( isset( $q['detached'] ) || ( isset( $q['attachment-filter'] ) && 'detached' == $q['attachment-filter'] ) ) { + if ( isset( $q['detached'] ) || ( isset( $q['attachment-filter'] ) && 'detached' === $q['attachment-filter'] ) ) { $q['post_parent'] = 0; } - if ( isset( $q['mine'] ) || ( isset( $q['attachment-filter'] ) && 'mine' == $q['attachment-filter'] ) ) { + if ( isset( $q['mine'] ) || ( isset( $q['attachment-filter'] ) && 'mine' === $q['attachment-filter'] ) ) { $q['author'] = get_current_user_id(); } @@ -1458,7 +1460,9 @@ 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' ) && get_option( 'page_on_front' ) == $id ) ) { + 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 { @@ -1682,7 +1686,7 @@ function _admin_notice_post_locked() { } else { $sendback = admin_url( 'edit.php' ); - if ( 'post' != $post->post_type ) { + if ( 'post' !== $post->post_type ) { $sendback = add_query_arg( 'post_type', $post->post_type, $sendback ); } @@ -1700,7 +1704,7 @@ function _admin_notice_post_locked() { if ( $locked ) { $query_args = array(); if ( get_post_type_object( $post->post_type )->public ) { - if ( 'publish' == $post->post_status || $user->ID != $post->post_author ) { + if ( 'publish' === $post->post_status || $user->ID != $post->post_author ) { // Latest content is in autosave. $nonce = wp_create_nonce( 'post_preview_' . $post->ID ); $query_args['preview_id'] = $post->ID; @@ -1888,12 +1892,14 @@ function post_preview() { $is_autosave = false; - if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author && ( 'draft' == $post->post_status || 'auto-draft' == $post->post_status ) ) { + if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author + && ( 'draft' === $post->post_status || 'auto-draft' === $post->post_status ) + ) { $saved_post_id = edit_post(); } else { $is_autosave = true; - if ( isset( $_POST['post_status'] ) && 'auto-draft' == $_POST['post_status'] ) { + if ( isset( $_POST['post_status'] ) && 'auto-draft' === $_POST['post_status'] ) { $_POST['post_status'] = 'draft'; } @@ -1953,7 +1959,7 @@ function wp_autosave( $post_data ) { return new WP_Error( 'edit_posts', __( 'Sorry, you are not allowed to edit this item.' ) ); } - if ( 'auto-draft' == $post->post_status ) { + if ( 'auto-draft' === $post->post_status ) { $post_data['post_status'] = 'draft'; } @@ -1961,7 +1967,9 @@ function wp_autosave( $post_data ) { $post_data['post_category'] = explode( ',', $post_data['catslist'] ); } - if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author && ( 'auto-draft' == $post->post_status || 'draft' == $post->post_status ) ) { + if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author + && ( 'auto-draft' === $post->post_status || 'draft' === $post->post_status ) + ) { // Drafts and auto-drafts are just overwritten by autosave for the same user if the post is not locked. return edit_post( wp_slash( $post_data ) ); } else { @@ -1994,7 +2002,7 @@ function redirect_post( $post_id = '' ) { $message = 6; } } else { - $message = 'draft' == $status ? 10 : 1; + $message = 'draft' === $status ? 10 : 1; } $location = add_query_arg( 'message', $message, get_edit_post_link( $post_id, 'url' ) ); diff --git a/src/wp-admin/includes/schema.php b/src/wp-admin/includes/schema.php index 0df44d2456..616c63349c 100644 --- a/src/wp-admin/includes/schema.php +++ b/src/wp-admin/includes/schema.php @@ -958,10 +958,10 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam global $wpdb, $current_site, $wp_rewrite; $errors = new WP_Error(); - if ( '' == $domain ) { + if ( '' === $domain ) { $errors->add( 'empty_domain', __( 'You must provide a domain name.' ) ); } - if ( '' == $site_name ) { + if ( '' === $site_name ) { $errors->add( 'empty_sitename', __( 'You must provide a name for your network of sites.' ) ); } diff --git a/src/wp-admin/includes/screen.php b/src/wp-admin/includes/screen.php index 75cc14a573..345bc8b4f2 100644 --- a/src/wp-admin/includes/screen.php +++ b/src/wp-admin/includes/screen.php @@ -118,7 +118,7 @@ function meta_box_prefs( $screen ) { continue; } // Submit box cannot be hidden. - if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] ) { + if ( 'submitdiv' === $box['id'] || 'linksubmitdiv' === $box['id'] ) { continue; } @@ -161,8 +161,8 @@ function get_hidden_meta_boxes( $screen ) { // Hide slug boxes by default. if ( $use_defaults ) { $hidden = array(); - if ( 'post' == $screen->base ) { - if ( 'post' == $screen->post_type || 'page' == $screen->post_type || 'attachment' == $screen->post_type ) { + if ( 'post' === $screen->base ) { + if ( in_array( $screen->post_type, array( 'post', 'page', 'attachment' ), true ) ) { $hidden = array( 'slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv' ); } else { $hidden = array( 'slugdiv' ); diff --git a/src/wp-admin/includes/taxonomy.php b/src/wp-admin/includes/taxonomy.php index e2877ca565..e711c9658b 100644 --- a/src/wp-admin/includes/taxonomy.php +++ b/src/wp-admin/includes/taxonomy.php @@ -129,7 +129,7 @@ function wp_insert_category( $catarr, $wp_error = false ) { ); $catarr = wp_parse_args( $catarr, $cat_defaults ); - if ( trim( $catarr['cat_name'] ) == '' ) { + if ( '' === trim( $catarr['cat_name'] ) ) { if ( ! $wp_error ) { return 0; } else { diff --git a/src/wp-admin/includes/template.php b/src/wp-admin/includes/template.php index b0fb03cb18..5641f061a2 100644 --- a/src/wp-admin/includes/template.php +++ b/src/wp-admin/includes/template.php @@ -2330,7 +2330,7 @@ function compression_test() { } if ( 2 == test ) { - if ( '"wpCompressionTest' == r ) + if ( '"wpCompressionTest' === r ) this.get('yes'); else this.get('no'); diff --git a/src/wp-admin/includes/theme.php b/src/wp-admin/includes/theme.php index 4da4eafb7f..c622be3dfd 100644 --- a/src/wp-admin/includes/theme.php +++ b/src/wp-admin/includes/theme.php @@ -471,7 +471,7 @@ function themes_api( $action, $args = array() ) { $args = (object) $args; } - if ( 'query_themes' == $action ) { + if ( 'query_themes' === $action ) { if ( ! isset( $args->per_page ) ) { $args->per_page = 24; } @@ -583,13 +583,13 @@ function themes_api( $action, $args = array() ) { } // Back-compat for info/1.2 API, upgrade the theme objects in query_themes to objects. - if ( 'query_themes' == $action ) { + if ( 'query_themes' === $action ) { foreach ( $res->themes as $i => $theme ) { $res->themes[ $i ] = (object) $theme; } } // Back-compat for info/1.2 API, downgrade the feature_list result back to an array. - if ( 'feature_list' == $action ) { + if ( 'feature_list' === $action ) { $res = (array) $res; } } diff --git a/src/wp-admin/includes/update-core.php b/src/wp-admin/includes/update-core.php index 686c75fe45..ac7a734f7c 100644 --- a/src/wp-admin/includes/update-core.php +++ b/src/wp-admin/includes/update-core.php @@ -1041,7 +1041,7 @@ function update_core( $from, $to ) { } if ( is_array( $checksums ) ) { foreach ( $checksums as $file => $checksum ) { - if ( 'wp-content' == substr( $file, 0, 10 ) ) { + if ( 'wp-content' === substr( $file, 0, 10 ) ) { continue; } if ( ! file_exists( ABSPATH . $file ) ) { @@ -1114,7 +1114,7 @@ function update_core( $from, $to ) { $failed = array(); if ( isset( $checksums ) && is_array( $checksums ) ) { foreach ( $checksums as $file => $checksum ) { - if ( 'wp-content' == substr( $file, 0, 10 ) ) { + if ( 'wp-content' === substr( $file, 0, 10 ) ) { continue; } if ( ! file_exists( $working_dir_local . $file ) ) { @@ -1187,7 +1187,7 @@ function update_core( $from, $to ) { $wp_filesystem->delete( $maintenance_file ); // 3.5 -> 3.5+ - an empty twentytwelve directory was created upon upgrade to 3.5 for some users, preventing installation of Twenty Twelve. - if ( '3.5' == $old_wp_version ) { + if ( '3.5' === $old_wp_version ) { if ( is_dir( WP_CONTENT_DIR . '/themes/twentytwelve' ) && ! file_exists( WP_CONTENT_DIR . '/themes/twentytwelve/style.css' ) ) { $wp_filesystem->delete( $wp_filesystem->wp_themes_dir() . 'twentytwelve/' ); } @@ -1203,17 +1203,18 @@ function update_core( $from, $to ) { foreach ( (array) $_new_bundled_files as $file => $introduced_version ) { // If a $development_build or if $introduced version is greater than what the site was previously running. if ( $development_build || version_compare( $introduced_version, $old_wp_version, '>' ) ) { - $directory = ( '/' == $file[ strlen( $file ) - 1 ] ); - list($type, $filename) = explode( '/', $file, 2 ); + $directory = ( '/' === $file[ strlen( $file ) - 1 ] ); + + list( $type, $filename ) = explode( '/', $file, 2 ); // Check to see if the bundled items exist before attempting to copy them. if ( ! $wp_filesystem->exists( $from . $distro . 'wp-content/' . $file ) ) { continue; } - if ( 'plugins' == $type ) { + if ( 'plugins' === $type ) { $dest = $wp_filesystem->wp_plugins_dir(); - } elseif ( 'themes' == $type ) { + } elseif ( 'themes' === $type ) { // Back-compat, ::wp_themes_dir() did not return trailingslash'd pre-3.2. $dest = trailingslashit( $wp_filesystem->wp_themes_dir() ); } else { @@ -1343,7 +1344,7 @@ function _copy_dir( $from, $to, $skip_list = array() ) { continue; } - if ( 'f' == $fileinfo['type'] ) { + if ( 'f' === $fileinfo['type'] ) { if ( ! $wp_filesystem->copy( $from . $filename, $to . $filename, true, FS_CHMOD_FILE ) ) { // If copy failed, chmod file to 0644 and try again. $wp_filesystem->chmod( $to . $filename, FS_CHMOD_FILE ); @@ -1351,7 +1352,7 @@ function _copy_dir( $from, $to, $skip_list = array() ) { return new WP_Error( 'copy_failed__copy_dir', __( 'Could not copy file.' ), $to . $filename ); } } - } elseif ( 'd' == $fileinfo['type'] ) { + } elseif ( 'd' === $fileinfo['type'] ) { if ( ! $wp_filesystem->is_dir( $to . $filename ) ) { if ( ! $wp_filesystem->mkdir( $to . $filename, FS_CHMOD_DIR ) ) { return new WP_Error( 'mkdir_failed__copy_dir', __( 'Could not create directory.' ), $to . $filename ); @@ -1399,11 +1400,11 @@ function _redirect_to_about_wordpress( $new_version ) { } // Ensure we only run this on the update-core.php page. The Core_Upgrader may be used in other contexts. - if ( 'update-core.php' != $pagenow ) { + if ( 'update-core.php' !== $pagenow ) { return; } - if ( 'do-core-upgrade' != $action && 'do-core-reinstall' != $action ) { + if ( 'do-core-upgrade' !== $action && 'do-core-reinstall' !== $action ) { return; } diff --git a/src/wp-admin/includes/update.php b/src/wp-admin/includes/update.php index 464ae93d22..085aa00f9e 100644 --- a/src/wp-admin/includes/update.php +++ b/src/wp-admin/includes/update.php @@ -95,7 +95,7 @@ function find_core_auto_update() { $auto_update = false; $upgrader = new WP_Automatic_Updater; foreach ( $updates->updates as $update ) { - if ( 'autoupdate' != $update->response ) { + if ( 'autoupdate' !== $update->response ) { continue; } @@ -285,7 +285,7 @@ function update_nag() { global $pagenow; - if ( 'update-core.php' == $pagenow ) { + if ( 'update-core.php' === $pagenow ) { return; } diff --git a/src/wp-admin/includes/upgrade.php b/src/wp-admin/includes/upgrade.php index afc5abc171..be125f913e 100644 --- a/src/wp-admin/includes/upgrade.php +++ b/src/wp-admin/includes/upgrade.php @@ -862,7 +862,7 @@ function upgrade_100() { $posts = $wpdb->get_results( "SELECT ID, post_title, post_name FROM $wpdb->posts WHERE post_name = ''" ); if ( $posts ) { foreach ( $posts as $post ) { - if ( '' == $post->post_name ) { + if ( '' === $post->post_name ) { $newtitle = sanitize_title( $post->post_title ); $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_name = %s WHERE ID = %d", $newtitle, $post->ID ) ); } @@ -871,7 +871,7 @@ function upgrade_100() { $categories = $wpdb->get_results( "SELECT cat_ID, cat_name, category_nicename FROM $wpdb->categories" ); foreach ( $categories as $category ) { - if ( '' == $category->category_nicename ) { + if ( '' === $category->category_nicename ) { $newtitle = sanitize_title( $category->cat_name ); $wpdb->update( $wpdb->categories, array( 'category_nicename' => $newtitle ), array( 'cat_ID' => $category->cat_ID ) ); } @@ -947,7 +947,7 @@ function upgrade_110() { // Set user_nicename. $users = $wpdb->get_results( "SELECT ID, user_nickname, user_nicename FROM $wpdb->users" ); foreach ( $users as $user ) { - if ( '' == $user->user_nicename ) { + if ( '' === $user->user_nicename ) { $newname = sanitize_title( $user->user_nickname ); $wpdb->update( $wpdb->users, array( 'user_nicename' => $newname ), array( 'ID' => $user->ID ) ); } @@ -982,7 +982,7 @@ function upgrade_110() { * MAX(post_date_gmt) can't be '0000-00-00 00:00:00'. * <michel_v> I just slapped myself silly for not thinking about it earlier. */ - $got_gmt_fields = ! ( $wpdb->get_var( "SELECT MAX(post_date_gmt) FROM $wpdb->posts" ) == '0000-00-00 00:00:00' ); + $got_gmt_fields = ( '0000-00-00 00:00:00' !== $wpdb->get_var( "SELECT MAX(post_date_gmt) FROM $wpdb->posts" ) ); if ( ! $got_gmt_fields ) { @@ -1226,10 +1226,10 @@ function upgrade_210() { $status = $post->post_status; $type = 'post'; - if ( 'static' == $status ) { + if ( 'static' === $status ) { $status = 'publish'; $type = 'page'; - } elseif ( 'attachment' == $status ) { + } elseif ( 'attachment' === $status ) { $status = 'inherit'; $type = 'attachment'; } @@ -1357,7 +1357,7 @@ function upgrade_230() { $post_id = (int) $post->post_id; $term_id = (int) $post->category_id; $taxonomy = 'category'; - if ( ! empty( $post->rel_type ) && 'tag' == $post->rel_type ) { + if ( ! empty( $post->rel_type ) && 'tag' === $post->rel_type ) { $taxonomy = 'tag'; } $tt_id = $tt_ids[ $term_id ][ $taxonomy ]; @@ -1475,7 +1475,7 @@ function upgrade_230() { // Recalculate all counts. $terms = $wpdb->get_results( "SELECT term_taxonomy_id, taxonomy FROM $wpdb->term_taxonomy" ); foreach ( (array) $terms as $term ) { - if ( ( 'post_tag' == $term->taxonomy ) || ( 'category' == $term->taxonomy ) ) { + if ( 'post_tag' === $term->taxonomy || 'category' === $term->taxonomy ) { $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term->term_taxonomy_id ) ); } else { $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id ) ); @@ -1815,7 +1815,7 @@ function upgrade_340() { } if ( $wp_current_db_version < 20080 ) { - if ( 'yes' == $wpdb->get_var( "SELECT autoload FROM $wpdb->options WHERE option_name = 'uninstall_plugins'" ) ) { + if ( 'yes' === $wpdb->get_var( "SELECT autoload FROM $wpdb->options WHERE option_name = 'uninstall_plugins'" ) ) { $uninstall_plugins = get_option( 'uninstall_plugins' ); delete_option( 'uninstall_plugins' ); add_option( 'uninstall_plugins', $uninstall_plugins, null, 'no' ); @@ -2291,7 +2291,7 @@ function upgrade_network() { $upgrade = false; $indexes = $wpdb->get_results( "SHOW INDEXES FROM $wpdb->signups" ); foreach ( $indexes as $index ) { - if ( 'domain_path' == $index->Key_name && 'domain' == $index->Column_name && 140 != $index->Sub_part ) { + if ( 'domain_path' === $index->Key_name && 'domain' === $index->Column_name && 140 != $index->Sub_part ) { $upgrade = true; break; } @@ -2501,7 +2501,7 @@ function get_alloptions_110() { $options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ); if ( $options ) { foreach ( $options as $option ) { - if ( 'siteurl' == $option->option_name || 'home' == $option->option_name || 'category_base' == $option->option_name ) { + if ( 'siteurl' === $option->option_name || 'home' === $option->option_name || 'category_base' === $option->option_name ) { $option->option_value = untrailingslashit( $option->option_value ); } $all_options->{$option->option_name} = stripslashes( $option->option_value ); @@ -2535,11 +2535,11 @@ function __get_option( $setting ) { // phpcs:ignore WordPress.NamingConventions. $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 ( in_array( $setting, array( 'siteurl', 'home', 'category_base', 'tag_base' ), true ) ) { $option = untrailingslashit( $option ); } @@ -2915,7 +2915,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 .= ','; } @@ -3270,7 +3270,7 @@ function maybe_disable_automattic_widgets() { $plugins = __get_option( 'active_plugins' ); foreach ( (array) $plugins as $plugin ) { - if ( basename( $plugin ) == 'widgets.php' ) { + if ( 'widgets.php' === basename( $plugin ) ) { array_splice( $plugins, array_search( $plugin, $plugins, true ), 1 ); update_option( 'active_plugins', $plugins ); break; diff --git a/src/wp-admin/includes/user.php b/src/wp-admin/includes/user.php index fc1ca67dcb..2268f75e55 100644 --- a/src/wp-admin/includes/user.php +++ b/src/wp-admin/includes/user.php @@ -132,7 +132,7 @@ function edit_user( $user_id = 0 ) { $user->show_admin_bar_front = isset( $_POST['admin_bar_front'] ) ? 'true' : 'false'; } - $user->comment_shortcuts = isset( $_POST['comment_shortcuts'] ) && 'true' == $_POST['comment_shortcuts'] ? 'true' : ''; + $user->comment_shortcuts = isset( $_POST['comment_shortcuts'] ) && 'true' === $_POST['comment_shortcuts'] ? 'true' : ''; $user->use_ssl = 0; if ( ! empty( $_POST['use_ssl'] ) ) { @@ -142,7 +142,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.' ) ); } @@ -474,7 +474,9 @@ function default_password_nag_handler( $errors = false ) { } // get_user_setting() = JS-saved UI setting. Else no-js-fallback code. - if ( 'hide' == get_user_setting( 'default_password_nag' ) || isset( $_GET['default_password_nag'] ) && '0' == $_GET['default_password_nag'] ) { + if ( 'hide' === get_user_setting( 'default_password_nag' ) + || isset( $_GET['default_password_nag'] ) && '0' == $_GET['default_password_nag'] + ) { delete_user_setting( 'default_password_nag' ); update_user_option( $user_ID, 'default_password_nag', false, true ); } @@ -509,7 +511,7 @@ function default_password_nag_edit_user( $user_ID, $old_data ) { function default_password_nag() { global $pagenow; // Short-circuit it. - if ( 'profile.php' == $pagenow || ! get_user_option( 'default_password_nag' ) ) { + if ( 'profile.php' === $pagenow || ! get_user_option( 'default_password_nag' ) ) { return; } diff --git a/src/wp-admin/includes/widgets.php b/src/wp-admin/includes/widgets.php index f8f16ac79c..d3bdf2032c 100644 --- a/src/wp-admin/includes/widgets.php +++ b/src/wp-admin/includes/widgets.php @@ -225,7 +225,7 @@ function wp_widget_control( $sidebar_args ) { * We aren't showing a widget control, we're outputting a template * for a multi-widget control. */ - if ( isset( $sidebar_args['_display'] ) && 'template' == $sidebar_args['_display'] && $widget_number ) { + if ( isset( $sidebar_args['_display'] ) && 'template' === $sidebar_args['_display'] && $widget_number ) { // number == -1 implies a template where id numbers are replaced by a generic '__i__'. $control['params'][0]['number'] = -1; // With id_base widget id's are constructed like {$id_base}-{$id_number}. diff --git a/src/wp-admin/maint/repair.php b/src/wp-admin/maint/repair.php index e6bc2418da..64242ce6f6 100644 --- a/src/wp-admin/maint/repair.php +++ b/src/wp-admin/maint/repair.php @@ -96,7 +96,7 @@ if ( ! defined( 'WP_ALLOW_REPAIR' ) || ! WP_ALLOW_REPAIR ) { $check = $wpdb->get_row( "CHECK TABLE $table" ); echo '<p>'; - if ( 'OK' == $check->Msg_text ) { + if ( 'OK' === $check->Msg_text ) { /* translators: %s: Table name. */ printf( __( 'The %s table is okay.' ), "<code>$table</code>" ); } else { @@ -106,7 +106,7 @@ if ( ! defined( 'WP_ALLOW_REPAIR' ) || ! WP_ALLOW_REPAIR ) { $repair = $wpdb->get_row( "REPAIR TABLE $table" ); echo '<br /> '; - if ( 'OK' == $check->Msg_text ) { + if ( 'OK' === $check->Msg_text ) { /* translators: %s: Table name. */ printf( __( 'Successfully repaired the %s table.' ), "<code>$table</code>" ); } else { @@ -121,14 +121,14 @@ if ( ! defined( 'WP_ALLOW_REPAIR' ) || ! WP_ALLOW_REPAIR ) { $check = $wpdb->get_row( "ANALYZE TABLE $table" ); echo '<br /> '; - if ( 'Table is already up to date' == $check->Msg_text ) { + if ( 'Table is already up to date' === $check->Msg_text ) { /* translators: %s: Table name. */ printf( __( 'The %s table is already optimized.' ), "<code>$table</code>" ); } else { $check = $wpdb->get_row( "OPTIMIZE TABLE $table" ); echo '<br /> '; - if ( 'OK' == $check->Msg_text || 'Table is already up to date' == $check->Msg_text ) { + if ( 'OK' === $check->Msg_text || 'Table is already up to date' === $check->Msg_text ) { /* translators: %s: Table name. */ printf( __( 'Successfully optimized the %s table.' ), "<code>$table</code>" ); } else { @@ -158,7 +158,7 @@ if ( ! defined( 'WP_ALLOW_REPAIR' ) || ! WP_ALLOW_REPAIR ) { echo '<h1 class="screen-reader-text">' . __( 'WordPress database repair' ) . '</h1>'; - if ( isset( $_GET['referrer'] ) && 'is_blog_installed' == $_GET['referrer'] ) { + if ( isset( $_GET['referrer'] ) && 'is_blog_installed' === $_GET['referrer'] ) { echo '<p>' . __( 'One or more database tables are unavailable. To allow WordPress to attempt to repair these tables, press the “Repair Database” button. Repairing can take a while, so please be patient.' ) . '</p>'; } else { echo '<p>' . __( 'WordPress can automatically look for some common database problems and repair them. Repairing can take a while, so please be patient.' ) . '</p>'; diff --git a/src/wp-admin/nav-menus.php b/src/wp-admin/nav-menus.php index 6f33cd7321..f1a45022d5 100644 --- a/src/wp-admin/nav-menus.php +++ b/src/wp-admin/nav-menus.php @@ -421,7 +421,7 @@ $menu_count = count( $nav_menus ); // Are we on the add new screen? $add_new_screen = ( isset( $_GET['menu'] ) && 0 == $_GET['menu'] ) ? true : false; -$locations_screen = ( isset( $_GET['action'] ) && 'locations' == $_GET['action'] ) ? true : false; +$locations_screen = ( isset( $_GET['action'] ) && 'locations' === $_GET['action'] ) ? true : false; /* * If we have one theme location, and zero menus, we take them right @@ -470,7 +470,7 @@ if ( empty( $nav_menu_selected_id ) && ! isset( $_GET['menu'] ) && is_nav_menu( } // On deletion of menu, if another menu exists, show it. -if ( ! $add_new_screen && 0 < $menu_count && isset( $_GET['action'] ) && 'delete' == $_GET['action'] ) { +if ( ! $add_new_screen && 0 < $menu_count && isset( $_GET['action'] ) && 'delete' === $_GET['action'] ) { $nav_menu_selected_id = $nav_menus[0]->term_id; } diff --git a/src/wp-admin/network.php b/src/wp-admin/network.php index cc24b7f773..b52e03e97d 100644 --- a/src/wp-admin/network.php +++ b/src/wp-admin/network.php @@ -99,7 +99,7 @@ if ( $_POST ) { if ( ! network_domain_check() ) { $result = populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), wp_unslash( $_POST['sitename'] ), $base, $subdomain_install ); if ( is_wp_error( $result ) ) { - if ( 1 == count( $result->get_error_codes() ) && 'no_wildcard_dns' == $result->get_error_code() ) { + if ( 1 == count( $result->get_error_codes() ) && 'no_wildcard_dns' === $result->get_error_code() ) { network_step2( $result ); } else { network_step1( $result ); diff --git a/src/wp-admin/options-discussion.php b/src/wp-admin/options-discussion.php index 2eb571f995..d8e33c1adb 100644 --- a/src/wp-admin/options-discussion.php +++ b/src/wp-admin/options-discussion.php @@ -125,11 +125,11 @@ printf( __( 'Enable threaded (nested) comments %s levels deep' ), $thread_commen <input name="page_comments" type="checkbox" id="page_comments" value="1" <?php checked( '1', get_option( 'page_comments' ) ); ?> /> <?php $default_comments_page = '</label> <label for="default_comments_page"><select name="default_comments_page" id="default_comments_page"><option value="newest"'; -if ( 'newest' == get_option( 'default_comments_page' ) ) { +if ( 'newest' === get_option( 'default_comments_page' ) ) { $default_comments_page .= ' selected="selected"'; } $default_comments_page .= '>' . __( 'last' ) . '</option><option value="oldest"'; -if ( 'oldest' == get_option( 'default_comments_page' ) ) { +if ( 'oldest' === get_option( 'default_comments_page' ) ) { $default_comments_page .= ' selected="selected"'; } $default_comments_page .= '>' . __( 'first' ) . '</option></select>'; @@ -146,11 +146,11 @@ printf( <?php $comment_order = '<select name="comment_order" id="comment_order"><option value="asc"'; -if ( 'asc' == get_option( 'comment_order' ) ) { +if ( 'asc' === get_option( 'comment_order' ) ) { $comment_order .= ' selected="selected"'; } $comment_order .= '>' . __( 'older' ) . '</option><option value="desc"'; -if ( 'desc' == get_option( 'comment_order' ) ) { +if ( 'desc' === get_option( 'comment_order' ) ) { $comment_order .= ' selected="selected"'; } $comment_order .= '>' . __( 'newer' ) . '</option></select>'; diff --git a/src/wp-admin/options.php b/src/wp-admin/options.php index f5a5fb89a4..fcbb960209 100644 --- a/src/wp-admin/options.php +++ b/src/wp-admin/options.php @@ -64,7 +64,7 @@ if ( ! empty( $_GET['adminhash'] ) ) { } wp_redirect( admin_url( $redirect ) ); exit; -} elseif ( ! empty( $_GET['dismiss'] ) && 'new_admin_email' == $_GET['dismiss'] ) { +} elseif ( ! empty( $_GET['dismiss'] ) && 'new_admin_email' === $_GET['dismiss'] ) { check_admin_referer( 'dismiss-' . get_current_blog_id() . '-new_admin_email' ); delete_option( 'adminhash' ); delete_option( 'new_admin_email' ); @@ -204,8 +204,8 @@ if ( ! is_multisite() ) { */ $whitelist_options = apply_filters( 'whitelist_options', $whitelist_options ); -if ( 'update' == $action ) { // We are saving settings sent from a settings page. - if ( 'options' == $option_page && ! isset( $_POST['option_page'] ) ) { // This is for back compat and will eventually be removed. +if ( 'update' === $action ) { // We are saving settings sent from a settings page. + if ( 'options' === $option_page && ! isset( $_POST['option_page'] ) ) { // This is for back compat and will eventually be removed. $unregistered = true; check_admin_referer( 'update-options' ); } else { @@ -223,7 +223,7 @@ if ( 'update' == $action ) { // We are saving settings sent from a settings page ); } - if ( 'options' == $option_page ) { + if ( 'options' === $option_page ) { if ( is_multisite() && ! current_user_can( 'manage_network_options' ) ) { wp_die( __( 'Sorry, you are not allowed to modify unregistered settings for this site.' ) ); } @@ -232,14 +232,20 @@ if ( 'update' == $action ) { // We are saving settings sent from a settings page $options = $whitelist_options[ $option_page ]; } - if ( 'general' == $option_page ) { + if ( 'general' === $option_page ) { // Handle custom date/time formats. - if ( ! empty( $_POST['date_format'] ) && isset( $_POST['date_format_custom'] ) && '\c\u\s\t\o\m' == wp_unslash( $_POST['date_format'] ) ) { + if ( ! empty( $_POST['date_format'] ) && isset( $_POST['date_format_custom'] ) + && '\c\u\s\t\o\m' === wp_unslash( $_POST['date_format'] ) + ) { $_POST['date_format'] = $_POST['date_format_custom']; } - if ( ! empty( $_POST['time_format'] ) && isset( $_POST['time_format_custom'] ) && '\c\u\s\t\o\m' == wp_unslash( $_POST['time_format'] ) ) { + + if ( ! empty( $_POST['time_format'] ) && isset( $_POST['time_format_custom'] ) + && '\c\u\s\t\o\m' === wp_unslash( $_POST['time_format'] ) + ) { $_POST['time_format'] = $_POST['time_format_custom']; } + // Map UTC+- timezones to gmt_offsets and set timezone_string to empty. if ( ! empty( $_POST['timezone_string'] ) && preg_match( '/^UTC[+-]/', $_POST['timezone_string'] ) ) { $_POST['gmt_offset'] = $_POST['timezone_string']; @@ -335,9 +341,11 @@ $options = $wpdb->get_results( "SELECT * FROM $wpdb->options ORDER BY option_nam foreach ( (array) $options as $option ) : $disabled = false; - if ( '' == $option->option_name ) { + + if ( '' === $option->option_name ) { continue; } + if ( is_serialized( $option->option_value ) ) { if ( is_serialized_string( $option->option_value ) ) { // This is a serialized string, so we should display it. @@ -354,6 +362,7 @@ foreach ( (array) $options as $option ) : $options_to_update[] = $option->option_name; $class = 'all-options'; } + $name = esc_attr( $option->option_name ); ?> <tr> diff --git a/src/wp-admin/plugin-editor.php b/src/wp-admin/plugin-editor.php index 2cf6e7dcb1..d85d5dd702 100644 --- a/src/wp-admin/plugin-editor.php +++ b/src/wp-admin/plugin-editor.php @@ -161,7 +161,7 @@ if ( ! empty( $posted_content ) ) { $content = file_get_contents( $real_file ); } -if ( '.php' == substr( $real_file, strrpos( $real_file, '.' ) ) ) { +if ( '.php' === substr( $real_file, strrpos( $real_file, '.' ) ) ) { $functions = wp_doc_link_parse( $content ); if ( ! empty( $functions ) ) { diff --git a/src/wp-admin/plugin-install.php b/src/wp-admin/plugin-install.php index e45bf03a35..76e942a36d 100644 --- a/src/wp-admin/plugin-install.php +++ b/src/wp-admin/plugin-install.php @@ -6,7 +6,7 @@ * @subpackage Administration */ // TODO: Route this page via a specific iframe handler instead of the do_action below. -if ( ! defined( 'IFRAME_REQUEST' ) && isset( $_GET['tab'] ) && ( 'plugin-information' == $_GET['tab'] ) ) { +if ( ! defined( 'IFRAME_REQUEST' ) && isset( $_GET['tab'] ) && ( 'plugin-information' === $_GET['tab'] ) ) { define( 'IFRAME_REQUEST', true ); } diff --git a/src/wp-admin/plugins.php b/src/wp-admin/plugins.php index b7d1b2ddfc..8352e207ab 100644 --- a/src/wp-admin/plugins.php +++ b/src/wp-admin/plugins.php @@ -43,7 +43,7 @@ if ( $action ) { $result = activate_plugin( $plugin, self_admin_url( 'plugins.php?error=true&plugin=' . urlencode( $plugin ) ), is_network_admin() ); if ( is_wp_error( $result ) ) { - if ( 'unexpected_output' == $result->get_error_code() ) { + if ( 'unexpected_output' === $result->get_error_code() ) { $redirect = self_admin_url( 'plugins.php?error=true&charsout=' . strlen( $result->get_error_data() ) . '&plugin=' . urlencode( $plugin ) . "&plugin_status=$status&paged=$page&s=$s" ); wp_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-activation-error_' . $plugin ), $redirect ) ); exit; @@ -62,10 +62,10 @@ if ( $action ) { update_site_option( 'recently_activated', $recent ); } - if ( isset( $_GET['from'] ) && 'import' == $_GET['from'] ) { + if ( isset( $_GET['from'] ) && 'import' === $_GET['from'] ) { // Overrides the ?error=true one above and redirects to the Imports page, stripping the -importer suffix. wp_redirect( self_admin_url( 'import.php?import=' . str_replace( '-importer', '', dirname( $plugin ) ) ) ); - } elseif ( isset( $_GET['from'] ) && 'press-this' == $_GET['from'] ) { + } elseif ( isset( $_GET['from'] ) && 'press-this' === $_GET['from'] ) { wp_redirect( self_admin_url( 'press-this.php' ) ); } else { // Overrides the ?error=true one above. @@ -292,7 +292,7 @@ if ( $action ) { foreach ( (array) $plugins as $plugin ) { $plugin_slug = dirname( $plugin ); - if ( '.' == $plugin_slug ) { + if ( '.' === $plugin_slug ) { $data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); if ( $data ) { $plugin_info[ $plugin ] = $data; @@ -579,7 +579,7 @@ elseif ( isset( $_GET['deleted'] ) ) : <div id="message" class="updated notice is-dismissible"><p><?php _e( 'Plugin deactivated.' ); ?></p></div> <?php elseif ( isset( $_GET['deactivate-multi'] ) ) : ?> <div id="message" class="updated notice is-dismissible"><p><?php _e( 'Selected plugins deactivated.' ); ?></p></div> -<?php elseif ( 'update-selected' == $action ) : ?> +<?php elseif ( 'update-selected' === $action ) : ?> <div id="message" class="updated notice is-dismissible"><p><?php _e( 'All selected plugins are up to date.' ); ?></p></div> <?php elseif ( isset( $_GET['resume'] ) ) : ?> <div id="message" class="updated notice is-dismissible"><p><?php _e( 'Plugin resumed.' ); ?></p></div> diff --git a/src/wp-admin/post-new.php b/src/wp-admin/post-new.php index 9074bedb5f..521ef9ef7c 100644 --- a/src/wp-admin/post-new.php +++ b/src/wp-admin/post-new.php @@ -25,10 +25,10 @@ if ( ! isset( $_GET['post_type'] ) ) { } $post_type_object = get_post_type_object( $post_type ); -if ( 'post' == $post_type ) { +if ( 'post' === $post_type ) { $parent_file = 'edit.php'; $submenu_file = 'post-new.php'; -} elseif ( 'attachment' == $post_type ) { +} elseif ( 'attachment' === $post_type ) { if ( wp_redirect( admin_url( 'media-new.php' ) ) ) { exit; } diff --git a/src/wp-admin/post.php b/src/wp-admin/post.php index 355ce1aca9..b11dc15836 100644 --- a/src/wp-admin/post.php +++ b/src/wp-admin/post.php @@ -49,7 +49,7 @@ if ( isset( $_POST['post_type'] ) && $post && $post_type !== $_POST['post_type'] if ( isset( $_POST['deletepost'] ) ) { $action = 'delete'; -} elseif ( isset( $_POST['wp-preview'] ) && 'dopreview' == $_POST['wp-preview'] ) { +} elseif ( isset( $_POST['wp-preview'] ) && 'dopreview' === $_POST['wp-preview'] ) { $action = 'preview'; } @@ -57,7 +57,7 @@ $sendback = wp_get_referer(); if ( ! $sendback || false !== strpos( $sendback, 'post.php' ) || false !== strpos( $sendback, 'post-new.php' ) ) { - if ( 'attachment' == $post_type ) { + if ( 'attachment' === $post_type ) { $sendback = admin_url( 'upload.php' ); } else { $sendback = admin_url( 'edit.php' ); @@ -111,7 +111,7 @@ switch ( $action ) { case 'postajaxpost': case 'post': check_admin_referer( 'add-' . $post_type ); - $post_id = 'postajaxpost' == $action ? edit_post() : write_post(); + $post_id = 'postajaxpost' === $action ? edit_post() : write_post(); redirect_post( $post_id ); exit(); @@ -139,7 +139,7 @@ switch ( $action ) { wp_die( __( 'Sorry, you are not allowed to edit this item.' ) ); } - if ( 'trash' == $post->post_status ) { + if ( 'trash' === $post->post_status ) { wp_die( __( 'You can’t edit this item because it is in the Trash. Please restore it and try again.' ) ); } @@ -151,11 +151,11 @@ switch ( $action ) { } $post_type = $post->post_type; - if ( 'post' == $post_type ) { + if ( 'post' === $post_type ) { $parent_file = 'edit.php'; $submenu_file = 'edit.php'; $post_new_file = 'post-new.php'; - } elseif ( 'attachment' == $post_type ) { + } elseif ( 'attachment' === $post_type ) { $parent_file = 'upload.php'; $submenu_file = 'upload.php'; $post_new_file = 'media-new.php'; diff --git a/src/wp-admin/setup-config.php b/src/wp-admin/setup-config.php index 36eee67451..b721f8158d 100644 --- a/src/wp-admin/setup-config.php +++ b/src/wp-admin/setup-config.php @@ -354,7 +354,7 @@ switch ( $step ) { $key = 0; foreach ( $config_file as $line_num => $line ) { - if ( '$table_prefix =' == substr( $line, 0, 15 ) ) { + if ( '$table_prefix =' === substr( $line, 0, 15 ) ) { $config_file[ $line_num ] = '$table_prefix = \'' . addcslashes( $prefix, "\\'" ) . "';\r\n"; continue; } diff --git a/src/wp-admin/theme-editor.php b/src/wp-admin/theme-editor.php index cc0c1f4c0d..411003c929 100644 --- a/src/wp-admin/theme-editor.php +++ b/src/wp-admin/theme-editor.php @@ -69,7 +69,7 @@ if ( ! $theme->exists() ) { wp_die( __( 'The requested theme does not exist.' ) ); } -if ( $theme->errors() && 'theme_no_stylesheet' == $theme->errors()->get_error_code() ) { +if ( $theme->errors() && 'theme_no_stylesheet' === $theme->errors()->get_error_code() ) { wp_die( __( 'The requested theme does not exist.' ) . ' ' . $theme->errors()->get_error_message() ); } @@ -162,7 +162,7 @@ if ( ! empty( $posted_content ) ) { $f = fopen( $file, 'r' ); $content = fread( $f, filesize( $file ) ); - if ( '.php' == substr( $file, strrpos( $file, '.' ) ) ) { + if ( '.php' === substr( $file, strrpos( $file, '.' ) ) ) { $functions = wp_doc_link_parse( $content ); $docs_select = '<select name="docs-list" id="docs-list">'; @@ -228,7 +228,7 @@ if ( $file_description != $file_show ) { <select name="theme" id="theme"> <?php foreach ( wp_get_themes( array( 'errors' => null ) ) as $a_stylesheet => $a_theme ) { - if ( $a_theme->errors() && 'theme_no_stylesheet' == $a_theme->errors()->get_error_code() ) { + if ( $a_theme->errors() && 'theme_no_stylesheet' === $a_theme->errors()->get_error_code() ) { continue; } diff --git a/src/wp-admin/themes.php b/src/wp-admin/themes.php index 485c7674c3..d1c1197618 100644 --- a/src/wp-admin/themes.php +++ b/src/wp-admin/themes.php @@ -18,7 +18,7 @@ if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_op } if ( current_user_can( 'switch_themes' ) && isset( $_GET['action'] ) ) { - if ( 'activate' == $_GET['action'] ) { + if ( 'activate' === $_GET['action'] ) { check_admin_referer( 'switch-theme_' . $_GET['stylesheet'] ); $theme = wp_get_theme( $_GET['stylesheet'] ); @@ -53,7 +53,7 @@ if ( current_user_can( 'switch_themes' ) && isset( $_GET['action'] ) ) { wp_redirect( admin_url( 'themes.php?resumed=true' ) ); exit; - } elseif ( 'delete' == $_GET['action'] ) { + } elseif ( 'delete' === $_GET['action'] ) { check_admin_referer( 'delete-theme_' . $_GET['stylesheet'] ); $theme = wp_get_theme( $_GET['stylesheet'] ); @@ -247,7 +247,7 @@ if ( ! $ct->errors() || ( 1 == count( $ct->errors()->get_error_codes() ) if ( is_array( $submenu ) && isset( $submenu['themes.php'] ) ) { foreach ( (array) $submenu['themes.php'] as $item ) { $class = ''; - if ( 'themes.php' == $item[2] || 'theme-editor.php' == $item[2] || 0 === strpos( $item[2], 'customize.php' ) ) { + if ( 'themes.php' === $item[2] || 'theme-editor.php' === $item[2] || 0 === strpos( $item[2], 'customize.php' ) ) { continue; } // 0 = name, 1 = capability, 2 = file. diff --git a/src/wp-admin/update-core.php b/src/wp-admin/update-core.php index 9d21ac8c2c..c74e5c5546 100644 --- a/src/wp-admin/update-core.php +++ b/src/wp-admin/update-core.php @@ -690,9 +690,9 @@ function do_undismiss_core_update() { $action = isset( $_GET['action'] ) ? $_GET['action'] : 'upgrade-core'; $upgrade_error = false; -if ( ( 'do-theme-upgrade' == $action || ( 'do-plugin-upgrade' == $action && ! isset( $_GET['plugins'] ) ) ) +if ( ( 'do-theme-upgrade' === $action || ( 'do-plugin-upgrade' === $action && ! isset( $_GET['plugins'] ) ) ) && ! isset( $_POST['checked'] ) ) { - $upgrade_error = 'do-theme-upgrade' == $action ? 'themes' : 'plugins'; + $upgrade_error = ( 'do-theme-upgrade' === $action ) ? 'themes' : 'plugins'; $action = 'upgrade-core'; } @@ -731,7 +731,7 @@ get_current_screen()->set_help_sidebar( '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' ); -if ( 'upgrade-core' == $action ) { +if ( 'upgrade-core' === $action ) { // Force a update check when requested. $force_check = ! empty( $_GET['force-check'] ); wp_version_check( array(), $force_check ); @@ -795,7 +795,7 @@ if ( 'upgrade-core' == $action ) { require_once ABSPATH . 'wp-admin/admin-footer.php'; -} elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) { +} elseif ( 'do-core-upgrade' === $action || 'do-core-reinstall' === $action ) { if ( ! current_user_can( 'update_core' ) ) { wp_die( __( 'Sorry, you are not allowed to update this site.' ) ); @@ -811,7 +811,7 @@ if ( 'upgrade-core' == $action ) { } require_once ABSPATH . 'wp-admin/admin-header.php'; - if ( 'do-core-reinstall' == $action ) { + if ( 'do-core-reinstall' === $action ) { $reinstall = true; } else { $reinstall = false; @@ -831,7 +831,7 @@ if ( 'upgrade-core' == $action ) { require_once ABSPATH . 'wp-admin/admin-footer.php'; -} elseif ( 'do-plugin-upgrade' == $action ) { +} elseif ( 'do-plugin-upgrade' === $action ) { if ( ! current_user_can( 'update_plugins' ) ) { wp_die( __( 'Sorry, you are not allowed to update this site.' ) ); @@ -869,7 +869,7 @@ if ( 'upgrade-core' == $action ) { require_once ABSPATH . 'wp-admin/admin-footer.php'; -} elseif ( 'do-theme-upgrade' == $action ) { +} elseif ( 'do-theme-upgrade' === $action ) { if ( ! current_user_can( 'update_themes' ) ) { wp_die( __( 'Sorry, you are not allowed to update this site.' ) ); @@ -909,7 +909,7 @@ if ( 'upgrade-core' == $action ) { require_once ABSPATH . 'wp-admin/admin-footer.php'; -} elseif ( 'do-translation-upgrade' == $action ) { +} elseif ( 'do-translation-upgrade' === $action ) { if ( ! current_user_can( 'update_languages' ) ) { wp_die( __( 'Sorry, you are not allowed to update this site.' ) ); diff --git a/src/wp-admin/update.php b/src/wp-admin/update.php index 33d14e232e..8cb0cf44b8 100644 --- a/src/wp-admin/update.php +++ b/src/wp-admin/update.php @@ -22,7 +22,7 @@ if ( isset( $_GET['action'] ) ) { $theme = isset( $_REQUEST['theme'] ) ? urldecode( $_REQUEST['theme'] ) : ''; $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : ''; - if ( 'update-selected' == $action ) { + if ( 'update-selected' === $action ) { if ( ! current_user_can( 'update_plugins' ) ) { wp_die( __( 'Sorry, you are not allowed to update plugins for this site.' ) ); } @@ -50,7 +50,7 @@ if ( isset( $_GET['action'] ) ) { iframe_footer(); - } elseif ( 'upgrade-plugin' == $action ) { + } elseif ( 'upgrade-plugin' === $action ) { if ( ! current_user_can( 'update_plugins' ) ) { wp_die( __( 'Sorry, you are not allowed to update plugins for this site.' ) ); } @@ -72,7 +72,7 @@ if ( isset( $_GET['action'] ) ) { require_once ABSPATH . 'wp-admin/admin-footer.php'; - } elseif ( 'activate-plugin' == $action ) { + } elseif ( 'activate-plugin' === $action ) { if ( ! current_user_can( 'update_plugins' ) ) { wp_die( __( 'Sorry, you are not allowed to update plugins for this site.' ) ); } @@ -98,7 +98,7 @@ if ( isset( $_GET['action'] ) ) { include WP_PLUGIN_DIR . '/' . $plugin; } iframe_footer(); - } elseif ( 'install-plugin' == $action ) { + } elseif ( 'install-plugin' === $action ) { if ( ! current_user_can( 'install_plugins' ) ) { wp_die( __( 'Sorry, you are not allowed to install plugins on this site.' ) ); @@ -141,7 +141,7 @@ if ( isset( $_GET['action'] ) ) { require_once ABSPATH . 'wp-admin/admin-footer.php'; - } elseif ( 'upload-plugin' == $action ) { + } elseif ( 'upload-plugin' === $action ) { if ( ! current_user_can( 'upload_plugins' ) ) { wp_die( __( 'Sorry, you are not allowed to install plugins on this site.' ) ); @@ -171,7 +171,7 @@ if ( isset( $_GET['action'] ) ) { require_once ABSPATH . 'wp-admin/admin-footer.php'; - } elseif ( 'upgrade-theme' == $action ) { + } elseif ( 'upgrade-theme' === $action ) { if ( ! current_user_can( 'update_themes' ) ) { wp_die( __( 'Sorry, you are not allowed to update themes for this site.' ) ); @@ -193,7 +193,7 @@ if ( isset( $_GET['action'] ) ) { $upgrader->upgrade( $theme ); require_once ABSPATH . 'wp-admin/admin-footer.php'; - } elseif ( 'update-selected-themes' == $action ) { + } elseif ( 'update-selected-themes' === $action ) { if ( ! current_user_can( 'update_themes' ) ) { wp_die( __( 'Sorry, you are not allowed to update themes for this site.' ) ); } @@ -220,7 +220,7 @@ if ( isset( $_GET['action'] ) ) { $upgrader->bulk_upgrade( $themes ); iframe_footer(); - } elseif ( 'install-theme' == $action ) { + } elseif ( 'install-theme' === $action ) { if ( ! current_user_can( 'install_themes' ) ) { wp_die( __( 'Sorry, you are not allowed to install themes on this site.' ) ); @@ -260,7 +260,7 @@ if ( isset( $_GET['action'] ) ) { require_once ABSPATH . 'wp-admin/admin-footer.php'; - } elseif ( 'upload-theme' == $action ) { + } elseif ( 'upload-theme' === $action ) { if ( ! current_user_can( 'upload_themes' ) ) { wp_die( __( 'Sorry, you are not allowed to install themes on this site.' ) ); diff --git a/src/wp-admin/upload.php b/src/wp-admin/upload.php index 93eecc75e2..4e7c4893cc 100644 --- a/src/wp-admin/upload.php +++ b/src/wp-admin/upload.php @@ -120,7 +120,7 @@ $doaction = $wp_list_table->current_action(); if ( $doaction ) { check_admin_referer( 'bulk-media' ); - if ( 'delete_all' == $doaction ) { + if ( 'delete_all' === $doaction ) { $post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='attachment' AND post_status = 'trash'" ); $doaction = 'delete'; } elseif ( isset( $_REQUEST['media'] ) ) { diff --git a/src/wp-admin/user-edit.php b/src/wp-admin/user-edit.php index 49aff443a6..8c7088e96d 100644 --- a/src/wp-admin/user-edit.php +++ b/src/wp-admin/user-edit.php @@ -204,7 +204,7 @@ switch ( $action ) { <?php endif; ?> <?php if ( isset( $_GET['error'] ) ) : ?> <div class="notice notice-error"> - <?php if ( 'new-email' == $_GET['error'] ) : ?> + <?php if ( 'new-email' === $_GET['error'] ) : ?> <p><?php _e( 'Error while saving the new email address. Please try again.' ); ?></p> <?php endif; ?> </div> diff --git a/src/wp-admin/user-new.php b/src/wp-admin/user-new.php index 90c385c9ae..06ba7efd9a 100644 --- a/src/wp-admin/user-new.php +++ b/src/wp-admin/user-new.php @@ -29,7 +29,7 @@ if ( is_multisite() ) { add_filter( 'wpmu_signup_user_notification_email', 'admin_created_user_email' ); } -if ( isset( $_REQUEST['action'] ) && 'adduser' == $_REQUEST['action'] ) { +if ( isset( $_REQUEST['action'] ) && 'adduser' === $_REQUEST['action'] ) { check_admin_referer( 'add-user', '_wpnonce_add-user' ); $user_details = null; @@ -148,7 +148,7 @@ Please click the following link to confirm the invite: } wp_redirect( $redirect ); die(); -} elseif ( isset( $_REQUEST['action'] ) && 'createuser' == $_REQUEST['action'] ) { +} elseif ( isset( $_REQUEST['action'] ) && 'createuser' === $_REQUEST['action'] ) { check_admin_referer( 'create-user', '_wpnonce_create-user' ); if ( ! current_user_can( 'create_users' ) ) { @@ -331,7 +331,7 @@ if ( isset( $_GET['update'] ) ) { break; } } else { - if ( 'add' == $_GET['update'] ) { + if ( 'add' === $_GET['update'] ) { $messages[] = __( 'User added.' ); } } diff --git a/src/wp-content/themes/twentyeleven/content-featured.php b/src/wp-content/themes/twentyeleven/content-featured.php index adaadcbf0a..7e6e957d30 100644 --- a/src/wp-content/themes/twentyeleven/content-featured.php +++ b/src/wp-content/themes/twentyeleven/content-featured.php @@ -32,24 +32,26 @@ global $feature_class; <footer class="entry-meta"> <?php - /* translators: Used between list items, there is a space after the comma. */ - $tag_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) ); - if ( '' != $tag_list ) { + /* translators: Used between list items, there is a space after the comma. */ + $tag_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) ); + + if ( '' !== $tag_list ) { /* translators: 1: Category list, 2: Tag list, 3: Post permalink, 4: Post title. */ $utility_text = __( 'This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyeleven' ); } else { /* translators: 1: Category list, 3: Post permalink, 4: Post title. */ $utility_text = __( 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyeleven' ); } - printf( - $utility_text, - /* translators: Used between list items, there is a space after the comma. */ - get_the_category_list( __( ', ', 'twentyeleven' ) ), - $tag_list, - esc_url( get_permalink() ), - the_title_attribute( 'echo=0' ) - ); - ?> + + printf( + $utility_text, + /* translators: Used between list items, there is a space after the comma. */ + get_the_category_list( __( ', ', 'twentyeleven' ) ), + $tag_list, + esc_url( get_permalink() ), + the_title_attribute( 'echo=0' ) + ); + ?> <?php edit_post_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?> </footer><!-- .entry-meta --> diff --git a/src/wp-content/themes/twentyeleven/content-single.php b/src/wp-content/themes/twentyeleven/content-single.php index 207c5c1b56..7427ddc01e 100644 --- a/src/wp-content/themes/twentyeleven/content-single.php +++ b/src/wp-content/themes/twentyeleven/content-single.php @@ -12,7 +12,7 @@ <header class="entry-header"> <h1 class="entry-title"><?php the_title(); ?></h1> - <?php if ( 'post' == get_post_type() ) : ?> + <?php if ( 'post' === get_post_type() ) : ?> <div class="entry-meta"> <?php twentyeleven_posted_on(); ?> </div><!-- .entry-meta --> @@ -33,15 +33,16 @@ <footer class="entry-meta"> <?php - /* translators: Used between list items, there is a space after the comma. */ - $categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) ); + /* translators: Used between list items, there is a space after the comma. */ + $categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) ); - /* translators: Used between list items, there is a space after the comma. */ - $tag_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) ); - if ( '' != $tag_list ) { + /* translators: Used between list items, there is a space after the comma. */ + $tag_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) ); + + if ( '' !== $tag_list ) { /* translators: 1: Categories list, 2: Tag list, 3: Permalink, 4: Post title, 5: Author name, 6: Author URL. */ $utility_text = __( 'This entry was posted in %1$s and tagged %2$s by <a href="%6$s">%5$s</a>. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyeleven' ); - } elseif ( '' != $categories_list ) { + } elseif ( '' !== $categories_list ) { /* translators: 1: Categories list, 2: Tag list, 3: Permalink, 4: Post title, 5: Author name, 6: Author URL. */ $utility_text = __( 'This entry was posted in %1$s by <a href="%6$s">%5$s</a>. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyeleven' ); } else { @@ -49,16 +50,17 @@ $utility_text = __( 'This entry was posted by <a href="%6$s">%5$s</a>. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyeleven' ); } - printf( - $utility_text, - $categories_list, - $tag_list, - esc_url( get_permalink() ), - the_title_attribute( 'echo=0' ), - get_the_author(), - esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) - ); - ?> + printf( + $utility_text, + $categories_list, + $tag_list, + esc_url( get_permalink() ), + the_title_attribute( 'echo=0' ), + get_the_author(), + esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) + ); + ?> + <?php edit_post_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?> <?php diff --git a/src/wp-content/themes/twentyeleven/content.php b/src/wp-content/themes/twentyeleven/content.php index d05aa83020..0951b408c9 100644 --- a/src/wp-content/themes/twentyeleven/content.php +++ b/src/wp-content/themes/twentyeleven/content.php @@ -19,7 +19,7 @@ <h1 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h1> <?php endif; ?> - <?php if ( 'post' == get_post_type() ) : ?> + <?php if ( 'post' === get_post_type() ) : ?> <div class="entry-meta"> <?php twentyeleven_posted_on(); ?> </div><!-- .entry-meta --> diff --git a/src/wp-content/themes/twentyeleven/functions.php b/src/wp-content/themes/twentyeleven/functions.php index 6fdb4459fd..28cf5d7209 100644 --- a/src/wp-content/themes/twentyeleven/functions.php +++ b/src/wp-content/themes/twentyeleven/functions.php @@ -147,7 +147,7 @@ if ( ! function_exists( 'twentyeleven_setup' ) ) : add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote', 'image' ) ); $theme_options = twentyeleven_get_theme_options(); - if ( 'dark' == $theme_options['color_scheme'] ) { + if ( 'dark' === $theme_options['color_scheme'] ) { $default_background_color = '1d1d1d'; } else { $default_background_color = 'e2e2e2'; @@ -328,7 +328,7 @@ if ( ! function_exists( 'twentyeleven_header_style' ) ) : <style type="text/css" id="twentyeleven-header-css"> <?php // Has the text been hidden? - if ( 'blank' == $text_color ) : + if ( 'blank' === $text_color ) : ?> #site-title, #site-description { @@ -719,28 +719,29 @@ if ( ! function_exists( 'twentyeleven_comment' ) ) : <footer class="comment-meta"> <div class="comment-author vcard"> <?php - $avatar_size = 68; + $avatar_size = 68; + if ( '0' != $comment->comment_parent ) { $avatar_size = 39; } - echo get_avatar( $comment, $avatar_size ); - - printf( - /* translators: 1: Comment author, 2: Date and time. */ - __( '%1$s on %2$s <span class="says">said:</span>', 'twentyeleven' ), - sprintf( '<span class="fn">%s</span>', get_comment_author_link() ), - sprintf( - '<a href="%1$s"><time datetime="%2$s">%3$s</time></a>', - esc_url( get_comment_link( $comment->comment_ID ) ), - get_comment_time( 'c' ), - /* translators: 1: Date, 2: Time. */ - sprintf( __( '%1$s at %2$s', 'twentyeleven' ), get_comment_date(), get_comment_time() ) - ) - ); + echo get_avatar( $comment, $avatar_size ); + + printf( + /* translators: 1: Comment author, 2: Date and time. */ + __( '%1$s on %2$s <span class="says">said:</span>', 'twentyeleven' ), + sprintf( '<span class="fn">%s</span>', get_comment_author_link() ), + sprintf( + '<a href="%1$s"><time datetime="%2$s">%3$s</time></a>', + esc_url( get_comment_link( $comment->comment_ID ) ), + get_comment_time( 'c' ), + /* translators: 1: Date, 2: Time. */ + sprintf( __( '%1$s at %2$s', 'twentyeleven' ), get_comment_date(), get_comment_time() ) + ) + ); ?> - <?php edit_comment_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?> + <?php edit_comment_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?> </div><!-- .comment-author .vcard --> <?php diff --git a/src/wp-content/themes/twentyeleven/header.php b/src/wp-content/themes/twentyeleven/header.php index d8afc3b577..2d69a0bc8b 100644 --- a/src/wp-content/themes/twentyeleven/header.php +++ b/src/wp-content/themes/twentyeleven/header.php @@ -128,7 +128,7 @@ if ( is_singular() && get_option( 'thread_comments' ) ) { <?php // Has the text been hidden? - if ( 'blank' == get_header_textcolor() ) : + if ( 'blank' === get_header_textcolor() ) : $header_image_class = ''; if ( $header_image ) { $header_image_class = ' with-image'; diff --git a/src/wp-content/themes/twentyeleven/inc/theme-options.php b/src/wp-content/themes/twentyeleven/inc/theme-options.php index 23cf55f1dc..e0c73202bb 100644 --- a/src/wp-content/themes/twentyeleven/inc/theme-options.php +++ b/src/wp-content/themes/twentyeleven/inc/theme-options.php @@ -418,7 +418,7 @@ function twentyeleven_enqueue_color_scheme() { $options = twentyeleven_get_theme_options(); $color_scheme = $options['color_scheme']; - if ( 'dark' == $color_scheme ) { + if ( 'dark' === $color_scheme ) { wp_enqueue_style( 'dark', get_template_directory_uri() . '/colors/dark.css', array(), '20190404' ); } @@ -499,9 +499,9 @@ function twentyeleven_layout_classes( $existing_classes ) { $classes = array( 'one-column' ); } - if ( 'content-sidebar' == $current_layout ) { + if ( 'content-sidebar' === $current_layout ) { $classes[] = 'right-sidebar'; - } elseif ( 'sidebar-content' == $current_layout ) { + } elseif ( 'sidebar-content' === $current_layout ) { $classes[] = 'left-sidebar'; } else { $classes[] = $current_layout; diff --git a/src/wp-content/themes/twentyeleven/inc/widgets.php b/src/wp-content/themes/twentyeleven/inc/widgets.php index ec1ad74243..ae28fd41ae 100644 --- a/src/wp-content/themes/twentyeleven/inc/widgets.php +++ b/src/wp-content/themes/twentyeleven/inc/widgets.php @@ -111,7 +111,7 @@ class Twenty_Eleven_Ephemera_Widget extends WP_Widget { $ephemera->the_post(); ?> - <?php if ( 'link' != get_post_format() ) : ?> + <?php if ( 'link' !== get_post_format() ) : ?> <li class="widget-entry-title"> <a href="<?php echo esc_url( get_permalink() ); ?>" rel="bookmark"><?php the_title(); ?></a> diff --git a/src/wp-content/themes/twentyeleven/showcase.php b/src/wp-content/themes/twentyeleven/showcase.php index 2931b4073e..041054b8ae 100644 --- a/src/wp-content/themes/twentyeleven/showcase.php +++ b/src/wp-content/themes/twentyeleven/showcase.php @@ -33,7 +33,7 @@ get_header(); ?> * We are using a heading by rendering the_content * If we have content for this page, let's display it. */ - if ( '' != get_the_content() ) { + if ( '' !== get_the_content() ) { get_template_part( 'content', 'intro' ); } ?> diff --git a/src/wp-content/themes/twentyeleven/sidebar.php b/src/wp-content/themes/twentyeleven/sidebar.php index df543cf73a..6dbc7c5461 100644 --- a/src/wp-content/themes/twentyeleven/sidebar.php +++ b/src/wp-content/themes/twentyeleven/sidebar.php @@ -10,7 +10,7 @@ $options = twentyeleven_get_theme_options(); $current_layout = $options['theme_layout']; -if ( 'content' != $current_layout ) : +if ( 'content' !== $current_layout ) : ?> <div id="secondary" class="widget-area" role="complementary"> <?php if ( ! dynamic_sidebar( 'sidebar-1' ) ) : ?> diff --git a/src/wp-content/themes/twentyfifteen/content-search.php b/src/wp-content/themes/twentyfifteen/content-search.php index f8091ce6b2..59d8b32721 100644 --- a/src/wp-content/themes/twentyfifteen/content-search.php +++ b/src/wp-content/themes/twentyfifteen/content-search.php @@ -21,7 +21,7 @@ <?php the_excerpt(); ?> </div><!-- .entry-summary --> - <?php if ( 'post' == get_post_type() ) : ?> + <?php if ( 'post' === get_post_type() ) : ?> <footer class="entry-footer"> <?php twentyfifteen_entry_meta(); ?> diff --git a/src/wp-content/themes/twentyfifteen/functions.php b/src/wp-content/themes/twentyfifteen/functions.php index 55fc83ece7..206cf0b88d 100644 --- a/src/wp-content/themes/twentyfifteen/functions.php +++ b/src/wp-content/themes/twentyfifteen/functions.php @@ -320,13 +320,13 @@ if ( ! function_exists( 'twentyfifteen_fonts_url' ) ) : */ $subset = _x( 'no-subset', 'Add new subset (greek, cyrillic, devanagari, vietnamese)', 'twentyfifteen' ); - if ( 'cyrillic' == $subset ) { + if ( 'cyrillic' === $subset ) { $subsets .= ',cyrillic,cyrillic-ext'; - } elseif ( 'greek' == $subset ) { + } elseif ( 'greek' === $subset ) { $subsets .= ',greek,greek-ext'; - } elseif ( 'devanagari' == $subset ) { + } elseif ( 'devanagari' === $subset ) { $subsets .= ',devanagari'; - } elseif ( 'vietnamese' == $subset ) { + } elseif ( 'vietnamese' === $subset ) { $subsets .= ',vietnamese'; } @@ -460,7 +460,7 @@ function twentyfifteen_post_nav_background() { $next = get_adjacent_post( false, '', false ); $css = ''; - if ( is_attachment() && 'attachment' == $previous->post_type ) { + if ( is_attachment() && 'attachment' === $previous->post_type ) { return; } @@ -498,7 +498,7 @@ add_action( 'wp_enqueue_scripts', 'twentyfifteen_post_nav_background' ); * @return string Menu item with possible description. */ function twentyfifteen_nav_description( $item_output, $item, $depth, $args ) { - if ( 'primary' == $args->theme_location && $item->description ) { + if ( 'primary' === $args->theme_location && $item->description ) { $item_output = str_replace( $args->link_after . '</a>', '<div class="menu-item-description">' . $item->description . '</div>' . $args->link_after . '</a>', $item_output ); } diff --git a/src/wp-content/themes/twentyfifteen/inc/template-tags.php b/src/wp-content/themes/twentyfifteen/inc/template-tags.php index 93b436fe5d..b2b515f487 100644 --- a/src/wp-content/themes/twentyfifteen/inc/template-tags.php +++ b/src/wp-content/themes/twentyfifteen/inc/template-tags.php @@ -84,7 +84,7 @@ if ( ! function_exists( 'twentyfifteen_entry_meta' ) ) : ); } - if ( 'post' == get_post_type() ) { + if ( 'post' === get_post_type() ) { if ( is_singular() || is_multi_author() ) { printf( '<span class="byline"><span class="author vcard"><span class="screen-reader-text">%1$s </span><a class="url fn n" href="%2$s">%3$s</a></span></span>', diff --git a/src/wp-content/themes/twentyfourteen/content-featured-post.php b/src/wp-content/themes/twentyfourteen/content-featured-post.php index 1c9eeff828..803451fc08 100644 --- a/src/wp-content/themes/twentyfourteen/content-featured-post.php +++ b/src/wp-content/themes/twentyfourteen/content-featured-post.php @@ -13,7 +13,7 @@ <?php // Output the featured image. if ( has_post_thumbnail() ) : - if ( 'grid' == get_theme_mod( 'featured_content_layout' ) ) { + if ( 'grid' === get_theme_mod( 'featured_content_layout' ) ) { the_post_thumbnail(); } else { the_post_thumbnail( 'twentyfourteen-full-width' ); diff --git a/src/wp-content/themes/twentyfourteen/content.php b/src/wp-content/themes/twentyfourteen/content.php index a355f0143f..1c48043302 100644 --- a/src/wp-content/themes/twentyfourteen/content.php +++ b/src/wp-content/themes/twentyfourteen/content.php @@ -30,7 +30,7 @@ <div class="entry-meta"> <?php - if ( 'post' == get_post_type() ) { + if ( 'post' === get_post_type() ) { twentyfourteen_posted_on(); } diff --git a/src/wp-content/themes/twentyfourteen/functions.php b/src/wp-content/themes/twentyfourteen/functions.php index a8797f91a3..d0a139ebda 100644 --- a/src/wp-content/themes/twentyfourteen/functions.php +++ b/src/wp-content/themes/twentyfourteen/functions.php @@ -340,7 +340,7 @@ function twentyfourteen_scripts() { wp_enqueue_script( 'jquery-masonry' ); } - if ( is_front_page() && 'slider' == get_theme_mod( 'featured_content_layout' ) ) { + if ( is_front_page() && 'slider' === get_theme_mod( 'featured_content_layout' ) ) { wp_enqueue_script( 'twentyfourteen-slider', get_template_directory_uri() . '/js/slider.js', array( 'jquery' ), '20150120', true ); wp_localize_script( 'twentyfourteen-slider', @@ -567,7 +567,7 @@ function twentyfourteen_body_classes( $classes ) { $classes[] = 'singular'; } - if ( is_front_page() && 'slider' == get_theme_mod( 'featured_content_layout' ) ) { + if ( is_front_page() && 'slider' === get_theme_mod( 'featured_content_layout' ) ) { $classes[] = 'slider'; } elseif ( is_front_page() ) { $classes[] = 'grid'; diff --git a/src/wp-content/themes/twentyfourteen/inc/featured-content.php b/src/wp-content/themes/twentyfourteen/inc/featured-content.php index e794d4609b..f120b7fa39 100644 --- a/src/wp-content/themes/twentyfourteen/inc/featured-content.php +++ b/src/wp-content/themes/twentyfourteen/inc/featured-content.php @@ -302,7 +302,7 @@ class Featured_Content { } // Bail if term objects are unavailable. - if ( 'all' != $args['fields'] ) { + if ( 'all' !== $args['fields'] ) { return $terms; } @@ -339,7 +339,7 @@ class Featured_Content { } // Make sure we are in the correct taxonomy. - if ( 'post_tag' != $taxonomy ) { + if ( 'post_tag' !== $taxonomy ) { return $terms; } @@ -466,7 +466,7 @@ class Featured_Content { $options = wp_parse_args( $saved, $defaults ); $options = array_intersect_key( $options, $defaults ); - if ( 'all' != $key ) { + if ( 'all' !== $key ) { return isset( $options[ $key ] ) ? $options[ $key ] : false; } diff --git a/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-svg-icons.php b/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-svg-icons.php index 1546d0eb92..01a35c0309 100644 --- a/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-svg-icons.php +++ b/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-svg-icons.php @@ -25,9 +25,9 @@ class TwentyNineteen_SVG_Icons { * Gets the SVG code for a given icon. */ public static function get_svg( $group, $icon, $size ) { - if ( 'ui' == $group ) { + if ( 'ui' === $group ) { $arr = self::$ui_icons; - } elseif ( 'social' == $group ) { + } elseif ( 'social' === $group ) { $arr = self::$social_icons; } else { $arr = array(); diff --git a/src/wp-content/themes/twentyten/loop.php b/src/wp-content/themes/twentyten/loop.php index fbe541096e..6d88f4bc5b 100644 --- a/src/wp-content/themes/twentyten/loop.php +++ b/src/wp-content/themes/twentyten/loop.php @@ -62,7 +62,7 @@ while ( have_posts() ) : <?php /* How to display posts of the Gallery format. The gallery category is the old way. */ ?> - <?php if ( ( function_exists( 'get_post_format' ) && 'gallery' == get_post_format( $post->ID ) ) || in_category( _x( 'gallery', 'gallery category slug', 'twentyten' ) ) ) : ?> + <?php if ( ( function_exists( 'get_post_format' ) && 'gallery' === get_post_format( $post->ID ) ) || in_category( _x( 'gallery', 'gallery category slug', 'twentyten' ) ) ) : ?> <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <h2 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h2> @@ -102,7 +102,7 @@ while ( have_posts() ) : <div class="entry-utility"> <?php $gallery = get_term_by( 'slug', _x( 'gallery', 'gallery category slug', 'twentyten' ), 'category' ); - if ( function_exists( 'get_post_format' ) && 'gallery' == get_post_format( $post->ID ) ) : + if ( function_exists( 'get_post_format' ) && 'gallery' === get_post_format( $post->ID ) ) : ?> <a href="<?php echo esc_url( get_post_format_link( 'gallery' ) ); ?>" title="<?php esc_attr_e( 'View Galleries', 'twentyten' ); ?>"><?php _e( 'More Galleries', 'twentyten' ); ?></a> <span class="meta-sep">|</span> @@ -117,7 +117,7 @@ while ( have_posts() ) : <?php /* How to display posts of the Aside format. The asides category is the old way. */ ?> - <?php elseif ( ( function_exists( 'get_post_format' ) && 'aside' == get_post_format( $post->ID ) ) || in_category( _x( 'asides', 'asides category slug', 'twentyten' ) ) ) : ?> + <?php elseif ( ( function_exists( 'get_post_format' ) && 'aside' === get_post_format( $post->ID ) ) || in_category( _x( 'asides', 'asides category slug', 'twentyten' ) ) ) : ?> <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <?php if ( is_archive() || is_search() ) : // Display excerpts for archives and search. ?> diff --git a/src/wp-content/themes/twentythirteen/functions.php b/src/wp-content/themes/twentythirteen/functions.php index cf9718c76c..1b474d9307 100644 --- a/src/wp-content/themes/twentythirteen/functions.php +++ b/src/wp-content/themes/twentythirteen/functions.php @@ -478,7 +478,7 @@ if ( ! function_exists( 'twentythirteen_entry_meta' ) ) : echo '<span class="featured-post">' . esc_html__( 'Sticky', 'twentythirteen' ) . '</span>'; } - if ( ! has_post_format( 'link' ) && 'post' == get_post_type() ) { + if ( ! has_post_format( 'link' ) && 'post' === get_post_type() ) { twentythirteen_entry_date(); } @@ -495,7 +495,7 @@ if ( ! function_exists( 'twentythirteen_entry_meta' ) ) : } // Post author. - if ( 'post' == get_post_type() ) { + if ( 'post' === get_post_type() ) { printf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>', esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), diff --git a/src/wp-content/themes/twentythirteen/js/theme-customizer.js b/src/wp-content/themes/twentythirteen/js/theme-customizer.js index 60721045cd..7328f0d15b 100644 --- a/src/wp-content/themes/twentythirteen/js/theme-customizer.js +++ b/src/wp-content/themes/twentythirteen/js/theme-customizer.js @@ -20,8 +20,8 @@ // Header text color. wp.customize( 'header_textcolor', function( value ) { value.bind( function( to ) { - if ( 'blank' == to ) { - if ( 'remove-header' == wp.customize.instance( 'header_image' ).get() ) { + if ( 'blank' === to ) { + if ( 'remove-header' === wp.customize.instance( 'header_image' ).get() ) { $( '.home-link' ).css( 'min-height', '0' ); } $( '.site-title, .site-description' ).css( { diff --git a/src/wp-content/themes/twentytwelve/functions.php b/src/wp-content/themes/twentytwelve/functions.php index 366514bd76..9a333b47ed 100644 --- a/src/wp-content/themes/twentytwelve/functions.php +++ b/src/wp-content/themes/twentytwelve/functions.php @@ -158,11 +158,11 @@ function twentytwelve_get_font_url() { */ $subset = _x( 'no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)', 'twentytwelve' ); - if ( 'cyrillic' == $subset ) { + if ( 'cyrillic' === $subset ) { $subsets .= ',cyrillic,cyrillic-ext'; - } elseif ( 'greek' == $subset ) { + } elseif ( 'greek' === $subset ) { $subsets .= ',greek,greek-ext'; - } elseif ( 'vietnamese' == $subset ) { + } elseif ( 'vietnamese' === $subset ) { $subsets .= ',vietnamese'; } diff --git a/src/wp-content/themes/twentytwelve/js/theme-customizer.js b/src/wp-content/themes/twentytwelve/js/theme-customizer.js index c388997da9..46195fbcee 100644 --- a/src/wp-content/themes/twentytwelve/js/theme-customizer.js +++ b/src/wp-content/themes/twentytwelve/js/theme-customizer.js @@ -41,9 +41,9 @@ value.bind( function( to ) { var body = $( 'body' ); - if ( ( '#ffffff' == to || '#fff' == to ) && 'none' == body.css( 'background-image' ) ) + if ( ( '#ffffff' === to || '#fff' === to ) && 'none' === body.css( 'background-image' ) ) body.addClass( 'custom-background-white' ); - else if ( '' == to && 'none' == body.css( 'background-image' ) ) + else if ( '' === to && 'none' === body.css( 'background-image' ) ) body.addClass( 'custom-background-empty' ); else body.removeClass( 'custom-background-empty custom-background-white' ); diff --git a/src/wp-includes/admin-bar.php b/src/wp-includes/admin-bar.php index 00a0bcde8b..35d1d4c5b9 100644 --- a/src/wp-includes/admin-bar.php +++ b/src/wp-includes/admin-bar.php @@ -701,19 +701,20 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) { if ( is_admin() ) { $current_screen = get_current_screen(); $post = get_post(); - if ( 'post' == $current_screen->base ) { + + if ( 'post' === $current_screen->base ) { $post_type_object = get_post_type_object( $post->post_type ); - } elseif ( 'edit' == $current_screen->base ) { + } elseif ( 'edit' === $current_screen->base ) { $post_type_object = get_post_type_object( $current_screen->post_type ); } - if ( 'post' == $current_screen->base - && 'add' != $current_screen->action + if ( 'post' === $current_screen->base + && 'add' !== $current_screen->action && ( $post_type_object ) && current_user_can( 'read_post', $post->ID ) && ( $post_type_object->public ) && ( $post_type_object->show_in_admin_bar ) ) { - if ( 'draft' == $post->post_status ) { + if ( 'draft' === $post->post_status ) { $preview_link = get_preview_post_link( $post ); $wp_admin_bar->add_node( array( @@ -732,7 +733,7 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) { ) ); } - } elseif ( 'edit' == $current_screen->base + } elseif ( 'edit' === $current_screen->base && ( $post_type_object ) && ( $post_type_object->public ) && ( $post_type_object->show_in_admin_bar ) @@ -745,7 +746,7 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) { 'href' => get_post_type_archive_link( $current_screen->post_type ), ) ); - } elseif ( 'term' == $current_screen->base && isset( $tag ) && is_object( $tag ) && ! is_wp_error( $tag ) ) { + } elseif ( 'term' === $current_screen->base && isset( $tag ) && is_object( $tag ) && ! is_wp_error( $tag ) ) { $tax = get_taxonomy( $tag->taxonomy ); if ( is_taxonomy_viewable( $tax ) ) { $wp_admin_bar->add_node( @@ -756,7 +757,7 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) { ) ); } - } elseif ( 'user-edit' == $current_screen->base && isset( $user_id ) ) { + } elseif ( 'user-edit' === $current_screen->base && isset( $user_id ) ) { $user_object = get_userdata( $user_id ); $view_link = get_author_posts_url( $user_object->ID ); if ( $user_object->exists() && $view_link ) { @@ -1204,7 +1205,7 @@ function is_admin_bar_showing() { } if ( ! isset( $show_admin_bar ) ) { - if ( ! is_user_logged_in() || 'wp-login.php' == $pagenow ) { + if ( ! is_user_logged_in() || 'wp-login.php' === $pagenow ) { $show_admin_bar = false; } else { $show_admin_bar = _get_admin_bar_pref(); diff --git a/src/wp-includes/author-template.php b/src/wp-includes/author-template.php index e2c0356e15..c1dbf4d5c4 100644 --- a/src/wp-includes/author-template.php +++ b/src/wp-includes/author-template.php @@ -349,7 +349,7 @@ function get_author_posts_url( $author_id, $author_nicename = '' ) { $file = home_url( '/' ); $link = $file . '?author=' . $auth_ID; } else { - if ( '' == $author_nicename ) { + if ( '' === $author_nicename ) { $user = get_userdata( $author_id ); if ( ! empty( $user->user_nicename ) ) { $author_nicename = $user->user_nicename; @@ -467,7 +467,7 @@ function wp_list_authors( $args = '' ) { continue; // No need to go further to process HTML. } - if ( 'list' == $args['style'] ) { + if ( 'list' === $args['style'] ) { $return .= '<li>'; } @@ -513,7 +513,7 @@ function wp_list_authors( $args = '' ) { } $return .= $link; - $return .= ( 'list' == $args['style'] ) ? '</li>' : ', '; + $return .= ( 'list' === $args['style'] ) ? '</li>' : ', '; } $return = rtrim( $return, ', ' ); diff --git a/src/wp-includes/bookmark-template.php b/src/wp-includes/bookmark-template.php index 9385a36982..4bc52fcd4f 100644 --- a/src/wp-includes/bookmark-template.php +++ b/src/wp-includes/bookmark-template.php @@ -83,7 +83,7 @@ function _walk_bookmarks( $bookmarks, $args = '' ) { $title = $desc; if ( $parsed_args['show_updated'] ) { - if ( '00' != substr( $bookmark->link_updated_f, 0, 2 ) ) { + if ( '00' !== substr( $bookmark->link_updated_f, 0, 2 ) ) { $title .= ' ('; $title .= sprintf( /* translators: %s: Date and time of last update. */ @@ -98,15 +98,15 @@ function _walk_bookmarks( $bookmarks, $args = '' ) { } $alt = ' alt="' . $name . ( $parsed_args['show_description'] ? ' ' . $title : '' ) . '"'; - if ( '' != $title ) { + if ( '' !== $title ) { $title = ' title="' . $title . '"'; } $rel = $bookmark->link_rel; - if ( '' != $rel ) { + if ( '' !== $rel ) { $rel = ' rel="' . esc_attr( $rel ) . '"'; } $target = $bookmark->link_target; - if ( '' != $target ) { + if ( '' !== $target ) { $target = ' target="' . $target . '"'; } $output .= '<a href="' . $the_link . '"' . $rel . $title . $target . '>'; @@ -134,7 +134,7 @@ function _walk_bookmarks( $bookmarks, $args = '' ) { $output .= '</em>'; } - if ( $parsed_args['show_description'] && '' != $desc ) { + if ( $parsed_args['show_description'] && '' !== $desc ) { $output .= $parsed_args['between'] . $desc; } diff --git a/src/wp-includes/bookmark.php b/src/wp-includes/bookmark.php index 411c8f369b..39c257cedc 100644 --- a/src/wp-includes/bookmark.php +++ b/src/wp-includes/bookmark.php @@ -418,29 +418,29 @@ function sanitize_bookmark_field( $field, $value, $bookmark_id, $context ) { break; } - if ( 'raw' == $context ) { + if ( 'raw' === $context ) { return $value; } - if ( 'edit' == $context ) { + if ( 'edit' === $context ) { /** This filter is documented in wp-includes/post.php */ $value = apply_filters( "edit_{$field}", $value, $bookmark_id ); - if ( 'link_notes' == $field ) { + if ( 'link_notes' === $field ) { $value = esc_html( $value ); // textarea_escaped } else { $value = esc_attr( $value ); } - } elseif ( 'db' == $context ) { + } elseif ( 'db' === $context ) { /** This filter is documented in wp-includes/post.php */ $value = apply_filters( "pre_{$field}", $value ); } else { /** This filter is documented in wp-includes/post.php */ $value = apply_filters( "{$field}", $value, $bookmark_id, $context ); - if ( 'attribute' == $context ) { + if ( 'attribute' === $context ) { $value = esc_attr( $value ); - } elseif ( 'js' == $context ) { + } elseif ( 'js' === $context ) { $value = esc_js( $value ); } } diff --git a/src/wp-includes/capabilities.php b/src/wp-includes/capabilities.php index 3442ab63cb..24b0aa9e0a 100644 --- a/src/wp-includes/capabilities.php +++ b/src/wp-includes/capabilities.php @@ -54,7 +54,7 @@ function map_meta_cap( $cap, $user_id, ...$args ) { case 'edit_user': case 'edit_users': // Allow user to edit themselves. - if ( 'edit_user' == $cap && isset( $args[0] ) && $user_id == $args[0] ) { + if ( 'edit_user' === $cap && isset( $args[0] ) && $user_id == $args[0] ) { break; } @@ -73,7 +73,7 @@ function map_meta_cap( $cap, $user_id, ...$args ) { break; } - if ( 'revision' == $post->post_type ) { + if ( 'revision' === $post->post_type ) { $caps[] = 'do_not_allow'; break; } @@ -94,7 +94,7 @@ function map_meta_cap( $cap, $user_id, ...$args ) { if ( ! $post_type->map_meta_cap ) { $caps[] = $post_type->cap->$cap; // Prior to 3.1 we would re-call map_meta_cap here. - if ( 'delete_post' == $cap ) { + if ( 'delete_post' === $cap ) { $cap = $post_type->cap->$cap; } break; @@ -105,7 +105,7 @@ function map_meta_cap( $cap, $user_id, ...$args ) { // If the post is published or scheduled... if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) { $caps[] = $post_type->cap->delete_published_posts; - } elseif ( 'trash' == $post->post_status ) { + } elseif ( 'trash' === $post->post_status ) { $status = get_post_meta( $post->ID, '_wp_trash_meta_status', true ); if ( in_array( $status, array( 'publish', 'future' ), true ) ) { $caps[] = $post_type->cap->delete_published_posts; @@ -122,7 +122,7 @@ function map_meta_cap( $cap, $user_id, ...$args ) { // The post is published or scheduled, extra cap required. if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) { $caps[] = $post_type->cap->delete_published_posts; - } elseif ( 'private' == $post->post_status ) { + } elseif ( 'private' === $post->post_status ) { $caps[] = $post_type->cap->delete_private_posts; } } @@ -146,7 +146,7 @@ function map_meta_cap( $cap, $user_id, ...$args ) { break; } - if ( 'revision' == $post->post_type ) { + if ( 'revision' === $post->post_type ) { $post = get_post( $post->post_parent ); if ( ! $post ) { $caps[] = 'do_not_allow'; @@ -165,7 +165,7 @@ function map_meta_cap( $cap, $user_id, ...$args ) { if ( ! $post_type->map_meta_cap ) { $caps[] = $post_type->cap->$cap; // Prior to 3.1 we would re-call map_meta_cap here. - if ( 'edit_post' == $cap ) { + if ( 'edit_post' === $cap ) { $cap = $post_type->cap->$cap; } break; @@ -176,7 +176,7 @@ function map_meta_cap( $cap, $user_id, ...$args ) { // If the post is published or scheduled... if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) { $caps[] = $post_type->cap->edit_published_posts; - } elseif ( 'trash' == $post->post_status ) { + } elseif ( 'trash' === $post->post_status ) { $status = get_post_meta( $post->ID, '_wp_trash_meta_status', true ); if ( in_array( $status, array( 'publish', 'future' ), true ) ) { $caps[] = $post_type->cap->edit_published_posts; @@ -193,7 +193,7 @@ function map_meta_cap( $cap, $user_id, ...$args ) { // The post is published or scheduled, extra cap required. if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) { $caps[] = $post_type->cap->edit_published_posts; - } elseif ( 'private' == $post->post_status ) { + } elseif ( 'private' === $post->post_status ) { $caps[] = $post_type->cap->edit_private_posts; } } @@ -215,7 +215,7 @@ function map_meta_cap( $cap, $user_id, ...$args ) { break; } - if ( 'revision' == $post->post_type ) { + if ( 'revision' === $post->post_type ) { $post = get_post( $post->post_parent ); if ( ! $post ) { $caps[] = 'do_not_allow'; @@ -234,7 +234,7 @@ function map_meta_cap( $cap, $user_id, ...$args ) { if ( ! $post_type->map_meta_cap ) { $caps[] = $post_type->cap->$cap; // Prior to 3.1 we would re-call map_meta_cap here. - if ( 'read_post' == $cap ) { + if ( 'read_post' === $cap ) { $cap = $post_type->cap->$cap; } break; diff --git a/src/wp-includes/category-template.php b/src/wp-includes/category-template.php index 4b49c04f7a..aa090d11fe 100644 --- a/src/wp-includes/category-template.php +++ b/src/wp-includes/category-template.php @@ -155,7 +155,7 @@ function get_the_category_list( $separator = '', $parents = '', $post_id = false $rel = ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks() ) ? 'rel="category tag"' : 'rel="category"'; $thelist = ''; - if ( '' == $separator ) { + if ( '' === $separator ) { $thelist .= '<ul class="post-categories">'; foreach ( $categories as $category ) { $thelist .= "\n\t<li>"; @@ -351,7 +351,7 @@ function wp_dropdown_categories( $args = '' ) { $defaults['selected'] = ( is_category() ) ? get_query_var( 'cat' ) : 0; // Back compat. - if ( isset( $args['type'] ) && 'link' == $args['type'] ) { + if ( isset( $args['type'] ) && 'link' === $args['type'] ) { _deprecated_argument( __FUNCTION__, '3.0.0', @@ -559,7 +559,7 @@ function wp_list_categories( $args = '' ) { } if ( ! isset( $parsed_args['class'] ) ) { - $parsed_args['class'] = ( 'category' == $parsed_args['taxonomy'] ) ? 'categories' : $parsed_args['taxonomy']; + $parsed_args['class'] = ( 'category' === $parsed_args['taxonomy'] ) ? 'categories' : $parsed_args['taxonomy']; } if ( ! taxonomy_exists( $parsed_args['taxonomy'] ) ) { @@ -572,12 +572,16 @@ function wp_list_categories( $args = '' ) { $categories = get_categories( $parsed_args ); $output = ''; - if ( $parsed_args['title_li'] && 'list' == $parsed_args['style'] && ( ! empty( $categories ) || ! $parsed_args['hide_title_if_empty'] ) ) { + + if ( $parsed_args['title_li'] && 'list' === $parsed_args['style'] + && ( ! empty( $categories ) || ! $parsed_args['hide_title_if_empty'] ) + ) { $output = '<li class="' . esc_attr( $parsed_args['class'] ) . '">' . $parsed_args['title_li'] . '<ul>'; } + if ( empty( $categories ) ) { if ( ! empty( $show_option_none ) ) { - if ( 'list' == $parsed_args['style'] ) { + if ( 'list' === $parsed_args['style'] ) { $output .= '<li class="cat-item-none">' . $show_option_none . '</li>'; } else { $output .= $show_option_none; @@ -604,7 +608,7 @@ function wp_list_categories( $args = '' ) { // Fallback for the 'All' link is the posts page. if ( ! $posts_page ) { - if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) ) { + if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) ) { $posts_page = get_permalink( get_option( 'page_for_posts' ) ); } else { $posts_page = home_url( '/' ); @@ -612,7 +616,7 @@ function wp_list_categories( $args = '' ) { } $posts_page = esc_url( $posts_page ); - if ( 'list' == $parsed_args['style'] ) { + if ( 'list' === $parsed_args['style'] ) { $output .= "<li class='cat-item-all'><a href='$posts_page'>$show_option_all</a></li>"; } else { $output .= "<a href='$posts_page'>$show_option_all</a>"; @@ -634,7 +638,9 @@ function wp_list_categories( $args = '' ) { $output .= walk_category_tree( $categories, $depth, $parsed_args ); } - if ( $parsed_args['title_li'] && 'list' == $parsed_args['style'] && ( ! empty( $categories ) || ! $parsed_args['hide_title_if_empty'] ) ) { + if ( $parsed_args['title_li'] && 'list' === $parsed_args['style'] + && ( ! empty( $categories ) || ! $parsed_args['hide_title_if_empty'] ) + ) { $output .= '</ul></li>'; } @@ -713,7 +719,7 @@ function wp_tag_cloud( $args = '' ) { } foreach ( $tags as $key => $tag ) { - if ( 'edit' == $args['link'] ) { + if ( 'edit' === $args['link'] ) { $link = get_edit_term_link( $tag->term_id, $tag->taxonomy, $args['post_type'] ); } else { $link = get_term_link( intval( $tag->term_id ), $tag->taxonomy ); @@ -740,7 +746,7 @@ function wp_tag_cloud( $args = '' ) { */ $return = apply_filters( 'wp_tag_cloud', $return, $args ); - if ( 'array' == $args['format'] || empty( $args['echo'] ) ) { + if ( 'array' === $args['format'] || empty( $args['echo'] ) ) { return $return; } @@ -939,8 +945,8 @@ function wp_generate_tag_cloud( $tags, $args = '' ) { $tags_data[] = array( 'id' => $tag_id, - 'url' => '#' != $tag->link ? $tag->link : '#', - 'role' => '#' != $tag->link ? '' : ' role="button"', + 'url' => ( '#' !== $tag->link ) ? $tag->link : '#', + 'role' => ( '#' !== $tag->link ) ? '' : ' role="button"', 'name' => $tag->name, 'formatted_count' => $formatted_count, 'slug' => $tag->slug, diff --git a/src/wp-includes/category.php b/src/wp-includes/category.php index 3f5cb1929b..42ac6227f3 100644 --- a/src/wp-includes/category.php +++ b/src/wp-includes/category.php @@ -37,7 +37,7 @@ function get_categories( $args = '' ) { $args['taxonomy'] = apply_filters( 'get_categories_taxonomy', $args['taxonomy'], $args ); // Back compat. - if ( isset( $args['type'] ) && 'link' == $args['type'] ) { + if ( isset( $args['type'] ) && 'link' === $args['type'] ) { _deprecated_argument( __FUNCTION__, '3.0.0', @@ -126,9 +126,11 @@ function get_category_by_path( $category_path, $full_match = true, $output = OBJ $leaf_path = sanitize_title( basename( $category_paths ) ); $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( 'taxonomy' => 'category', diff --git a/src/wp-includes/class-http.php b/src/wp-includes/class-http.php index 51115bbf1a..963ed541e4 100644 --- a/src/wp-includes/class-http.php +++ b/src/wp-includes/class-http.php @@ -216,7 +216,7 @@ class WP_Http { $args = wp_parse_args( $args ); // By default, HEAD requests do not cause redirections. - if ( isset( $args['method'] ) && 'HEAD' == $args['method'] ) { + if ( isset( $args['method'] ) && 'HEAD' === $args['method'] ) { $defaults['redirection'] = 0; } @@ -739,7 +739,7 @@ class WP_Http { } else { $newheaders[ $key ] = $value; } - if ( 'set-cookie' == $key ) { + if ( 'set-cookie' === $key ) { $cookies[] = new WP_Http_Cookie( $value, $url ); } } @@ -870,7 +870,7 @@ class WP_Http { $home = parse_url( get_option( 'siteurl' ) ); // Don't block requests back to ourselves by default. - if ( 'localhost' == $check['host'] || ( isset( $home['host'] ) && $home['host'] == $check['host'] ) ) { + if ( 'localhost' === $check['host'] || ( isset( $home['host'] ) && $home['host'] == $check['host'] ) ) { /** * Filters whether to block local HTTP API requests. * @@ -975,7 +975,7 @@ class WP_Http { $path = ! empty( $url_parts['path'] ) ? $url_parts['path'] : '/'; // If it's a root-relative path, then great. - if ( ! empty( $relative_url_parts['path'] ) && '/' == $relative_url_parts['path'][0] ) { + if ( ! empty( $relative_url_parts['path'] ) && '/' === $relative_url_parts['path'][0] ) { $path = $relative_url_parts['path']; // Else it's a relative path. @@ -1040,7 +1040,7 @@ class WP_Http { $redirect_location = WP_Http::make_absolute_url( $redirect_location, $url ); // POST requests should not POST to a redirected location. - if ( 'POST' == $args['method'] ) { + if ( 'POST' === $args['method'] ) { if ( in_array( $response['response']['code'], array( 302, 303 ), true ) ) { $args['method'] = 'GET'; } diff --git a/src/wp-includes/class-walker-category.php b/src/wp-includes/class-walker-category.php index 16ad852e5b..c783cad3e9 100644 --- a/src/wp-includes/class-walker-category.php +++ b/src/wp-includes/class-walker-category.php @@ -53,7 +53,7 @@ class Walker_Category extends Walker { * value is 'list'. See wp_list_categories(). Default empty array. */ public function start_lvl( &$output, $depth = 0, $args = array() ) { - if ( 'list' != $args['style'] ) { + if ( 'list' !== $args['style'] ) { return; } @@ -74,7 +74,7 @@ class Walker_Category extends Walker { * value is 'list'. See wp_list_categories(). Default empty array. */ public function end_lvl( &$output, $depth = 0, $args = array() ) { - if ( 'list' != $args['style'] ) { + if ( 'list' !== $args['style'] ) { return; } @@ -186,7 +186,7 @@ class Walker_Category extends Walker { if ( ! empty( $args['show_count'] ) ) { $link .= ' (' . number_format_i18n( $category->count ) . ')'; } - if ( 'list' == $args['style'] ) { + if ( 'list' === $args['style'] ) { $output .= "\t<li"; $css_classes = array( 'cat-item', @@ -258,7 +258,7 @@ class Walker_Category extends Walker { * to output. See wp_list_categories(). Default empty array. */ public function end_el( &$output, $page, $depth = 0, $args = array() ) { - if ( 'list' != $args['style'] ) { + if ( 'list' !== $args['style'] ) { return; } diff --git a/src/wp-includes/class-walker-comment.php b/src/wp-includes/class-walker-comment.php index 7325fd0a6a..e7498b3dd6 100644 --- a/src/wp-includes/class-walker-comment.php +++ b/src/wp-includes/class-walker-comment.php @@ -181,7 +181,7 @@ class Walker_Comment extends Walker { return; } - if ( ( 'pingback' == $comment->comment_type || 'trackback' == $comment->comment_type ) && $args['short_ping'] ) { + if ( ( 'pingback' === $comment->comment_type || 'trackback' === $comment->comment_type ) && $args['short_ping'] ) { ob_start(); $this->ping( $comment, $depth, $args ); $output .= ob_get_clean(); @@ -216,7 +216,7 @@ class Walker_Comment extends Walker { $output .= ob_get_clean(); return; } - if ( 'div' == $args['style'] ) { + if ( 'div' === $args['style'] ) { $output .= "</div><!-- #comment-## -->\n"; } else { $output .= "</li><!-- #comment-## -->\n"; @@ -235,7 +235,7 @@ class Walker_Comment extends Walker { * @param array $args An array of arguments. */ protected function ping( $comment, $depth, $args ) { - $tag = ( 'div' == $args['style'] ) ? 'div' : 'li'; + $tag = ( 'div' === $args['style'] ) ? 'div' : 'li'; ?> <<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class( '', $comment ); ?>> <div class="comment-body"> @@ -256,7 +256,7 @@ class Walker_Comment extends Walker { * @param array $args An array of arguments. */ protected function comment( $comment, $depth, $args ) { - if ( 'div' == $args['style'] ) { + if ( 'div' === $args['style'] ) { $tag = 'div'; $add_below = 'comment'; } else { @@ -273,7 +273,7 @@ class Walker_Comment extends Walker { ?> <<?php echo $tag; ?> <?php comment_class( $this->has_children ? 'parent' : '', $comment ); ?> id="comment-<?php comment_ID(); ?>"> - <?php if ( 'div' != $args['style'] ) : ?> + <?php if ( 'div' !== $args['style'] ) : ?> <div id="div-comment-<?php comment_ID(); ?>" class="comment-body"> <?php endif; ?> <div class="comment-author vcard"> @@ -334,7 +334,7 @@ class Walker_Comment extends Walker { ); ?> - <?php if ( 'div' != $args['style'] ) : ?> + <?php if ( 'div' !== $args['style'] ) : ?> </div> <?php endif; ?> <?php diff --git a/src/wp-includes/class-walker-page.php b/src/wp-includes/class-walker-page.php index 557bf309b0..9589996721 100644 --- a/src/wp-includes/class-walker-page.php +++ b/src/wp-includes/class-walker-page.php @@ -201,7 +201,7 @@ class Walker_Page extends Walker { ); if ( ! empty( $args['show_date'] ) ) { - if ( 'modified' == $args['show_date'] ) { + if ( 'modified' === $args['show_date'] ) { $time = $page->post_modified; } else { $time = $page->post_date; diff --git a/src/wp-includes/class-wp-comment-query.php b/src/wp-includes/class-wp-comment-query.php index ae176bc510..020bce9378 100644 --- a/src/wp-includes/class-wp-comment-query.php +++ b/src/wp-includes/class-wp-comment-query.php @@ -388,7 +388,7 @@ class WP_Comment_Query { * * The expected return type from this filter depends on the value passed in the request query_vars. * When `$this->query_vars['count']` is set, the filter should return the comment count as an int. - * When `'ids' == $this->query_vars['fields']`, the filter should return an array of comment ids. + * When `'ids' === $this->query_vars['fields']`, the filter should return an array of comment ids. * Otherwise the filter should return an array of WP_Comment objects. * * @since 5.3.0 @@ -444,7 +444,7 @@ class WP_Comment_Query { $comment_ids = array_map( 'intval', $comment_ids ); - if ( 'ids' == $this->query_vars['fields'] ) { + if ( 'ids' === $this->query_vars['fields'] ) { $this->comments = $comment_ids; return $this->comments; } @@ -570,7 +570,7 @@ class WP_Comment_Query { } } - $order = ( 'ASC' == strtoupper( $this->query_vars['order'] ) ) ? 'ASC' : 'DESC'; + $order = ( 'ASC' === strtoupper( $this->query_vars['order'] ) ) ? 'ASC' : 'DESC'; // Disable ORDER BY with 'none', an empty array, or boolean false. if ( in_array( $this->query_vars['orderby'], array( 'none', array(), false ), true ) ) { diff --git a/src/wp-includes/class-wp-customize-nav-menus.php b/src/wp-includes/class-wp-customize-nav-menus.php index 7126955751..df374b9865 100644 --- a/src/wp-includes/class-wp-customize-nav-menus.php +++ b/src/wp-includes/class-wp-customize-nav-menus.php @@ -154,7 +154,7 @@ final class WP_Customize_Nav_Menus { $suppress_page_ids = array(); if ( 0 === $page && 'page' === $object ) { // Insert Front Page or custom "Home" link. - $front_page = 'page' == get_option( 'show_on_front' ) ? (int) get_option( 'page_on_front' ) : 0; + $front_page = 'page' === get_option( 'show_on_front' ) ? (int) get_option( 'page_on_front' ) : 0; if ( ! empty( $front_page ) ) { $front_page_obj = get_post( $front_page ); $important_pages[] = $front_page_obj; @@ -172,7 +172,7 @@ final class WP_Customize_Nav_Menus { } // Insert Posts Page. - $posts_page = 'page' == get_option( 'show_on_front' ) ? (int) get_option( 'page_for_posts' ) : 0; + $posts_page = 'page' === get_option( 'show_on_front' ) ? (int) get_option( 'page_for_posts' ) : 0; if ( ! empty( $posts_page ) ) { $posts_page_obj = get_post( $posts_page ); $important_pages[] = $posts_page_obj; @@ -445,7 +445,7 @@ final class WP_Customize_Nav_Menus { // Add "Home" link if search term matches. Treat as a page, but switch to custom on add. if ( isset( $args['s'] ) ) { // Only insert custom "Home" link if there's no Front Page - $front_page = 'page' == get_option( 'show_on_front' ) ? (int) get_option( 'page_on_front' ) : 0; + $front_page = 'page' === get_option( 'show_on_front' ) ? (int) get_option( 'page_on_front' ) : 0; if ( empty( $front_page ) ) { $title = _x( 'Home', 'nav menu home label' ); $matches = function_exists( 'mb_stripos' ) ? false !== mb_stripos( $title, $args['s'] ) : false !== stripos( $title, $args['s'] ); diff --git a/src/wp-includes/class-wp-editor.php b/src/wp-includes/class-wp-editor.php index 6af472469d..3ed8ffdcb0 100644 --- a/src/wp-includes/class-wp-editor.php +++ b/src/wp-includes/class-wp-editor.php @@ -524,7 +524,7 @@ final class _WP_Editors { $strings .= @file_get_contents( $path . $mce_locale . '_dlg.js' ) . "\n"; } - if ( 'en' != $mce_locale && empty( $strings ) ) { + if ( 'en' !== $mce_locale && empty( $strings ) ) { if ( @is_file( $path . 'en.js' ) ) { $str1 = @file_get_contents( $path . 'en.js' ); $strings .= preg_replace( '/([\'"])en\./', '$1' . $mce_locale . '.', $str1, 1 ) . "\n"; @@ -834,8 +834,8 @@ final class _WP_Editors { $options .= $key . ':' . $val . ','; continue; } elseif ( ! empty( $value ) && is_string( $value ) && ( - ( '{' == $value[0] && '}' == $value[ strlen( $value ) - 1 ] ) || - ( '[' == $value[0] && ']' == $value[ strlen( $value ) - 1 ] ) || + ( '{' === $value[0] && '}' === $value[ strlen( $value ) - 1 ] ) || + ( '[' === $value[0] && ']' === $value[ strlen( $value ) - 1 ] ) || preg_match( '/^\(?function ?\(/', $value ) ) ) { $options .= $key . ':' . $value . ','; @@ -1776,7 +1776,7 @@ final class _WP_Editors { // Build results. $results = array(); foreach ( $posts as $post ) { - if ( 'post' == $post->post_type ) { + if ( 'post' === $post->post_type ) { $info = mysql2date( __( 'Y/m/d' ), $post->post_date ); } else { $info = $pts[ $post->post_type ]->labels->singular_name; diff --git a/src/wp-includes/class-wp-embed.php b/src/wp-includes/class-wp-embed.php index eb77fe1431..10d36afcd0 100644 --- a/src/wp-includes/class-wp-embed.php +++ b/src/wp-includes/class-wp-embed.php @@ -355,7 +355,7 @@ class WP_Embed { } foreach ( $post_metas as $post_meta_key ) { - if ( '_oembed_' == substr( $post_meta_key, 0, 8 ) ) { + if ( '_oembed_' === substr( $post_meta_key, 0, 8 ) ) { delete_post_meta( $post_ID, $post_meta_key ); } } diff --git a/src/wp-includes/class-wp-http-cookie.php b/src/wp-includes/class-wp-http-cookie.php index 430bc47119..560af08c54 100644 --- a/src/wp-includes/class-wp-http-cookie.php +++ b/src/wp-includes/class-wp-http-cookie.php @@ -99,7 +99,7 @@ class WP_Http_Cookie { $this->domain = $arrURL['host']; } $this->path = isset( $arrURL['path'] ) ? $arrURL['path'] : '/'; - if ( '/' != substr( $this->path, -1 ) ) { + if ( '/' !== substr( $this->path, -1 ) ) { $this->path = dirname( $this->path ) . '/'; } @@ -127,7 +127,7 @@ class WP_Http_Cookie { list( $key, $val ) = strpos( $pair, '=' ) ? explode( '=', $pair ) : array( $pair, '' ); $key = strtolower( trim( $key ) ); - if ( 'expires' == $key ) { + if ( 'expires' === $key ) { $val = strtotime( $val ); } $this->$key = $val; @@ -174,7 +174,7 @@ class WP_Http_Cookie { // Get details on the URL we're thinking about sending to. $url = parse_url( $url ); - $url['port'] = isset( $url['port'] ) ? $url['port'] : ( 'https' == $url['scheme'] ? 443 : 80 ); + $url['port'] = isset( $url['port'] ) ? $url['port'] : ( 'https' === $url['scheme'] ? 443 : 80 ); $url['path'] = isset( $url['path'] ) ? $url['path'] : '/'; // Values to use for comparison against the URL. @@ -186,7 +186,7 @@ class WP_Http_Cookie { } // Host - very basic check that the request URL ends with the domain restriction (minus leading dot). - $domain = substr( $domain, 0, 1 ) == '.' ? substr( $domain, 1 ) : $domain; + $domain = ( '.' === substr( $domain, 0, 1 ) ) ? substr( $domain, 1 ) : $domain; if ( substr( $url['host'], -strlen( $domain ) ) != $domain ) { return false; } diff --git a/src/wp-includes/class-wp-http-encoding.php b/src/wp-includes/class-wp-http-encoding.php index ab92865c60..a64253123a 100644 --- a/src/wp-includes/class-wp-http-encoding.php +++ b/src/wp-includes/class-wp-http-encoding.php @@ -101,7 +101,7 @@ class WP_Http_Encoding { public static function compatible_gzinflate( $gzData ) { // Compressed data might contain a full header, if so strip it for gzinflate(). - if ( substr( $gzData, 0, 3 ) == "\x1f\x8b\x08" ) { + if ( "\x1f\x8b\x08" === substr( $gzData, 0, 3 ) ) { $i = 10; $flg = ord( substr( $gzData, 3, 1 ) ); if ( $flg > 0 ) { diff --git a/src/wp-includes/class-wp-http-streams.php b/src/wp-includes/class-wp-http-streams.php index e4e641ea84..1ecb0a6b53 100644 --- a/src/wp-includes/class-wp-http-streams.php +++ b/src/wp-includes/class-wp-http-streams.php @@ -84,7 +84,7 @@ class WP_Http_Streams { * to ::1, which fails when the server is not set up for it. For compatibility, always * connect to the IPv4 address. */ - if ( 'localhost' == strtolower( $connect_host ) ) { + if ( 'localhost' === strtolower( $connect_host ) ) { $connect_host = '127.0.0.1'; } @@ -186,8 +186,8 @@ class WP_Http_Streams { $include_port_in_host_header = ( ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) || - ( 'http' == $arrURL['scheme'] && 80 != $arrURL['port'] ) || - ( 'https' == $arrURL['scheme'] && 443 != $arrURL['port'] ) + ( 'http' === $arrURL['scheme'] && 80 != $arrURL['port'] ) || + ( 'https' === $arrURL['scheme'] && 443 != $arrURL['port'] ) ); if ( $include_port_in_host_header ) { @@ -334,7 +334,9 @@ class WP_Http_Streams { } // If the body was chunk encoded, then decode it. - if ( ! empty( $process['body'] ) && isset( $arrHeaders['headers']['transfer-encoding'] ) && 'chunked' == $arrHeaders['headers']['transfer-encoding'] ) { + if ( ! empty( $process['body'] ) && isset( $arrHeaders['headers']['transfer-encoding'] ) + && 'chunked' === $arrHeaders['headers']['transfer-encoding'] + ) { $process['body'] = WP_Http::chunkTransferDecode( $process['body'] ); } @@ -405,7 +407,7 @@ class WP_Http_Streams { } // IP's can't be wildcards, Stop processing. - if ( 'ip' == $host_type ) { + if ( 'ip' === $host_type ) { return false; } diff --git a/src/wp-includes/class-wp-image-editor.php b/src/wp-includes/class-wp-image-editor.php index 70af8cdc79..b052dec339 100644 --- a/src/wp-includes/class-wp-image-editor.php +++ b/src/wp-includes/class-wp-image-editor.php @@ -240,7 +240,7 @@ abstract class WP_Image_Editor { */ $quality = apply_filters( 'wp_editor_set_quality', $this->default_quality, $this->mime_type ); - if ( 'image/jpeg' == $this->mime_type ) { + if ( 'image/jpeg' === $this->mime_type ) { /** * Filters the JPEG compression quality for backward-compatibility. * diff --git a/src/wp-includes/class-wp-list-util.php b/src/wp-includes/class-wp-list-util.php index 3366af37ae..3b1d328447 100644 --- a/src/wp-includes/class-wp-list-util.php +++ b/src/wp-includes/class-wp-list-util.php @@ -112,9 +112,9 @@ class WP_List_Util { } if ( - ( 'AND' == $operator && $matched == $count ) || - ( 'OR' == $operator && $matched > 0 ) || - ( 'NOT' == $operator && 0 == $matched ) + ( 'AND' === $operator && $matched == $count ) || + ( 'OR' === $operator && $matched > 0 ) || + ( 'NOT' === $operator && 0 == $matched ) ) { $filtered[ $key ] = $obj; } diff --git a/src/wp-includes/class-wp-locale.php b/src/wp-includes/class-wp-locale.php index de3745702d..59ad290e08 100644 --- a/src/wp-includes/class-wp-locale.php +++ b/src/wp-includes/class-wp-locale.php @@ -214,7 +214,7 @@ class WP_Locale { $this->text_direction = $GLOBALS['text_direction']; /* translators: 'rtl' or 'ltr'. This sets the text direction for WordPress. */ - } elseif ( 'rtl' == _x( 'ltr', 'text direction' ) ) { + } elseif ( 'rtl' === _x( 'ltr', 'text direction' ) ) { $this->text_direction = 'rtl'; } } @@ -346,7 +346,7 @@ class WP_Locale { * @return bool Whether locale is RTL. */ public function is_rtl() { - return 'rtl' == $this->text_direction; + return 'rtl' === $this->text_direction; } /** diff --git a/src/wp-includes/class-wp-meta-query.php b/src/wp-includes/class-wp-meta-query.php index af446aef74..6bfcb89999 100644 --- a/src/wp-includes/class-wp-meta-query.php +++ b/src/wp-includes/class-wp-meta-query.php @@ -138,7 +138,7 @@ class WP_Meta_Query { return; } - if ( isset( $meta_query['relation'] ) && strtoupper( $meta_query['relation'] ) == 'OR' ) { + if ( isset( $meta_query['relation'] ) && 'OR' === strtoupper( $meta_query['relation'] ) ) { $this->relation = 'OR'; } else { $this->relation = 'AND'; @@ -295,7 +295,7 @@ class WP_Meta_Query { return 'CHAR'; } - if ( 'NUMERIC' == $meta_type ) { + if ( 'NUMERIC' === $meta_type ) { $meta_type = 'SIGNED'; } diff --git a/src/wp-includes/class-wp-network-query.php b/src/wp-includes/class-wp-network-query.php index c38a696380..61651cae40 100644 --- a/src/wp-includes/class-wp-network-query.php +++ b/src/wp-includes/class-wp-network-query.php @@ -262,7 +262,7 @@ class WP_Network_Query { $network_ids = array_map( 'intval', $network_ids ); - if ( 'ids' == $this->query_vars['fields'] ) { + if ( 'ids' === $this->query_vars['fields'] ) { $this->networks = $network_ids; return $this->networks; } diff --git a/src/wp-includes/class-wp-oembed.php b/src/wp-includes/class-wp-oembed.php index 5fbe1677d0..235faa6619 100644 --- a/src/wp-includes/class-wp-oembed.php +++ b/src/wp-includes/class-wp-oembed.php @@ -487,7 +487,7 @@ class WP_oEmbed { $providers[ $linktypes[ $atts['type'] ] ] = htmlspecialchars_decode( $atts['href'] ); // Stop here if it's JSON (that's all we need). - if ( 'json' == $linktypes[ $atts['type'] ] ) { + if ( 'json' === $linktypes[ $atts['type'] ] ) { break; } } @@ -537,7 +537,7 @@ class WP_oEmbed { foreach ( array( 'json', 'xml' ) as $format ) { $result = $this->_fetch_with_format( $provider, $format ); - if ( is_wp_error( $result ) && 'not-implemented' == $result->get_error_code() ) { + if ( is_wp_error( $result ) && 'not-implemented' === $result->get_error_code() ) { continue; } return ( $result && ! is_wp_error( $result ) ) ? $result : false; diff --git a/src/wp-includes/class-wp-post-type.php b/src/wp-includes/class-wp-post-type.php index 847bfef7cb..be156f5fd1 100644 --- a/src/wp-includes/class-wp-post-type.php +++ b/src/wp-includes/class-wp-post-type.php @@ -485,7 +485,7 @@ final class WP_Post_Type { } } - if ( false !== $args['rewrite'] && ( is_admin() || '' != get_option( 'permalink_structure' ) ) ) { + if ( false !== $args['rewrite'] && ( is_admin() || get_option( 'permalink_structure' ) ) ) { if ( ! is_array( $args['rewrite'] ) ) { $args['rewrite'] = array(); } @@ -554,7 +554,7 @@ final class WP_Post_Type { $wp->add_query_var( $this->query_var ); } - if ( false !== $this->rewrite && ( is_admin() || '' != get_option( 'permalink_structure' ) ) ) { + if ( false !== $this->rewrite && ( is_admin() || get_option( 'permalink_structure' ) ) ) { if ( $this->hierarchical ) { add_rewrite_tag( "%$this->name%", '(.+?)', $this->query_var ? "{$this->query_var}=" : "post_type=$this->name&pagename=" ); } else { diff --git a/src/wp-includes/class-wp-query.php b/src/wp-includes/class-wp-query.php index 50da8ed7d2..5027f21cf0 100644 --- a/src/wp-includes/class-wp-query.php +++ b/src/wp-includes/class-wp-query.php @@ -804,14 +804,14 @@ class WP_Query { $qv['attachment_id'] = absint( $qv['attachment_id'] ); - if ( ( '' != $qv['attachment'] ) || ! empty( $qv['attachment_id'] ) ) { + if ( ( '' !== $qv['attachment'] ) || ! empty( $qv['attachment_id'] ) ) { $this->is_single = true; $this->is_attachment = true; - } elseif ( '' != $qv['name'] ) { + } elseif ( '' !== $qv['name'] ) { $this->is_single = true; } elseif ( $qv['p'] ) { $this->is_single = true; - } elseif ( '' != $qv['pagename'] || ! empty( $qv['page_id'] ) ) { + } elseif ( '' !== $qv['pagename'] || ! empty( $qv['page_id'] ) ) { $this->is_page = true; $this->is_single = false; } else { @@ -879,7 +879,7 @@ class WP_Query { } } - if ( '' != $qv['w'] ) { + if ( $qv['w'] ) { $this->is_date = true; } @@ -891,7 +891,7 @@ class WP_Query { continue; } - if ( isset( $tax_query['operator'] ) && 'NOT IN' != $tax_query['operator'] ) { + if ( isset( $tax_query['operator'] ) && 'NOT IN' !== $tax_query['operator'] ) { switch ( $tax_query['taxonomy'] ) { case 'category': $this->is_category = true; @@ -912,7 +912,7 @@ class WP_Query { $this->is_author = true; } - if ( '' != $qv['author_name'] ) { + if ( '' !== $qv['author_name'] ) { $this->is_author = true; } @@ -971,10 +971,10 @@ class WP_Query { } // Correct `is_*` for 'page_on_front' and 'page_for_posts'. - if ( $this->is_home && 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) ) { + if ( $this->is_home && 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) ) { $_query = wp_parse_args( $this->query ); // 'pagename' can be set and empty depending on matched rewrite rules. Ignore an empty 'pagename'. - if ( isset( $_query['pagename'] ) && '' == $_query['pagename'] ) { + if ( isset( $_query['pagename'] ) && '' === $_query['pagename'] ) { unset( $_query['pagename'] ); } @@ -992,10 +992,10 @@ class WP_Query { } } - if ( '' != $qv['pagename'] ) { + if ( '' !== $qv['pagename'] ) { $this->queried_object = get_page_by_path( $qv['pagename'] ); - if ( $this->queried_object && 'attachment' == $this->queried_object->post_type ) { + if ( $this->queried_object && 'attachment' === $this->queried_object->post_type ) { if ( preg_match( '/^[^%]*%(?:postname)%/', get_option( 'permalink_structure' ) ) ) { // See if we also have a post with the same slug. $post = get_page_by_path( $qv['pagename'], OBJECT, 'post' ); @@ -1103,7 +1103,7 @@ class WP_Query { } foreach ( get_taxonomies( array(), 'objects' ) as $taxonomy => $t ) { - if ( 'post_tag' == $taxonomy ) { + if ( 'post_tag' === $taxonomy ) { continue; // Handled further down in the $q['tag'] block. } @@ -1235,7 +1235,7 @@ class WP_Query { // Tag stuff. - if ( '' != $q['tag'] && ! $this->is_singular && $this->query_vars_changed ) { + if ( '' !== $q['tag'] && ! $this->is_singular && $this->query_vars_changed ) { if ( strpos( $q['tag'], ',' ) !== false ) { $tags = preg_split( '/[,\r\n\t ]+/', $q['tag'] ); foreach ( (array) $tags as $tag ) { @@ -1993,7 +1993,7 @@ class WP_Query { } // If we've got a post_type AND it's not "any" post_type. - if ( ! empty( $q['post_type'] ) && 'any' != $q['post_type'] ) { + if ( ! empty( $q['post_type'] ) && 'any' !== $q['post_type'] ) { foreach ( (array) $q['post_type'] as $_post_type ) { $ptype_obj = get_post_type_object( $_post_type ); if ( ! $ptype_obj || ! $ptype_obj->query_var || empty( $q[ $ptype_obj->query_var ] ) ) { @@ -2020,14 +2020,14 @@ class WP_Query { } // Parameters related to 'post_name'. - if ( '' != $q['name'] ) { + if ( '' !== $q['name'] ) { $q['name'] = sanitize_title_for_query( $q['name'] ); $where .= " AND {$wpdb->posts}.post_name = '" . $q['name'] . "'"; - } elseif ( '' != $q['pagename'] ) { + } elseif ( '' !== $q['pagename'] ) { if ( isset( $this->queried_object_id ) ) { $reqpage = $this->queried_object_id; } else { - if ( 'page' != $q['post_type'] ) { + if ( 'page' !== $q['post_type'] ) { foreach ( (array) $q['post_type'] as $_post_type ) { $ptype_obj = get_post_type_object( $_post_type ); if ( ! $ptype_obj || ! $ptype_obj->hierarchical ) { @@ -2051,12 +2051,12 @@ class WP_Query { } $page_for_posts = get_option( 'page_for_posts' ); - if ( ( 'page' != get_option( 'show_on_front' ) ) || empty( $page_for_posts ) || ( $reqpage != $page_for_posts ) ) { + if ( ( 'page' !== get_option( 'show_on_front' ) ) || empty( $page_for_posts ) || ( $reqpage != $page_for_posts ) ) { $q['pagename'] = sanitize_title_for_query( wp_basename( $q['pagename'] ) ); $q['name'] = $q['pagename']; $where .= " AND ({$wpdb->posts}.ID = '$reqpage')"; $reqpage_obj = get_post( $reqpage ); - if ( is_object( $reqpage_obj ) && 'attachment' == $reqpage_obj->post_type ) { + if ( is_object( $reqpage_obj ) && 'attachment' === $reqpage_obj->post_type ) { $this->is_attachment = true; $post_type = 'attachment'; $q['post_type'] = 'attachment'; @@ -2064,7 +2064,7 @@ class WP_Query { $q['attachment_id'] = $reqpage; } } - } elseif ( '' != $q['attachment'] ) { + } elseif ( '' !== $q['attachment'] ) { $q['attachment'] = sanitize_title_for_query( wp_basename( $q['attachment'] ) ); $q['name'] = $q['attachment']; $where .= " AND {$wpdb->posts}.post_name = '" . $q['attachment'] . "'"; @@ -2239,7 +2239,7 @@ class WP_Query { // Author stuff for nice URLs. - if ( '' != $q['author_name'] ) { + if ( '' !== $q['author_name'] ) { if ( strpos( $q['author_name'], '/' ) !== false ) { $q['author_name'] = explode( '/', $q['author_name'] ); if ( $q['author_name'][ count( $q['author_name'] ) - 1 ] ) { @@ -2285,7 +2285,7 @@ class WP_Query { // MIME-Type stuff for attachment browsing. - if ( isset( $q['post_mime_type'] ) && '' != $q['post_mime_type'] ) { + if ( isset( $q['post_mime_type'] ) && '' !== $q['post_mime_type'] ) { $whichmimetype = wp_post_mime_type_where( $q['post_mime_type'], $wpdb->posts ); } $where .= $search . $whichauthor . $whichmimetype; @@ -2320,7 +2320,7 @@ class WP_Query { } else { $orderby = "{$wpdb->posts}.post_date " . $q['order']; } - } elseif ( 'none' == $q['orderby'] ) { + } elseif ( 'none' === $q['orderby'] ) { $orderby = ''; } else { $orderby_array = array(); @@ -2413,7 +2413,7 @@ class WP_Query { $where .= $wpdb->prepare( " AND {$wpdb->posts}.ping_status = %s ", $q['ping_status'] ); } - if ( 'any' == $post_type ) { + if ( 'any' === $post_type ) { $in_search_post_types = get_post_types( array( 'exclude_from_search' => false ) ); if ( empty( $in_search_post_types ) ) { $where .= ' AND 1=0 '; @@ -2468,7 +2468,7 @@ class WP_Query { } else { foreach ( get_post_stati() as $status ) { if ( in_array( $status, $q_status, true ) ) { - if ( 'private' == $status ) { + if ( 'private' === $status ) { $p_status[] = "{$wpdb->posts}.post_status = '$status'"; } else { $r_status[] = "{$wpdb->posts}.post_status = '$status'"; @@ -2477,7 +2477,7 @@ class WP_Query { } } - if ( empty( $q['perm'] ) || 'readable' != $q['perm'] ) { + if ( empty( $q['perm'] ) || 'readable' !== $q['perm'] ) { $r_status = array_merge( $r_status, $p_status ); unset( $p_status ); } @@ -2486,14 +2486,14 @@ class WP_Query { $statuswheres[] = '(' . join( ' AND ', $e_status ) . ')'; } if ( ! empty( $r_status ) ) { - if ( ! empty( $q['perm'] ) && 'editable' == $q['perm'] && ! current_user_can( $edit_others_cap ) ) { + if ( ! empty( $q['perm'] ) && 'editable' === $q['perm'] && ! current_user_can( $edit_others_cap ) ) { $statuswheres[] = "({$wpdb->posts}.post_author = $user_id " . 'AND (' . join( ' OR ', $r_status ) . '))'; } else { $statuswheres[] = '(' . join( ' OR ', $r_status ) . ')'; } } if ( ! empty( $p_status ) ) { - if ( ! empty( $q['perm'] ) && 'readable' == $q['perm'] && ! current_user_can( $read_private_cap ) ) { + if ( ! empty( $q['perm'] ) && 'readable' === $q['perm'] && ! current_user_can( $read_private_cap ) ) { $statuswheres[] = "({$wpdb->posts}.post_author = $user_id " . 'AND (' . join( ' OR ', $p_status ) . '))'; } else { $statuswheres[] = '(' . join( ' OR ', $p_status ) . ')'; @@ -2515,7 +2515,7 @@ class WP_Query { // Add public states. $public_states = get_post_stati( array( 'public' => true ) ); foreach ( (array) $public_states as $state ) { - if ( 'publish' == $state ) { // Publish is hard-coded above. + if ( 'publish' === $state ) { // Publish is hard-coded above. continue; } $where .= " OR {$wpdb->posts}.post_status = '$state'"; @@ -2948,7 +2948,7 @@ class WP_Query { */ $this->posts = apply_filters_ref_array( 'posts_pre_query', array( null, &$this ) ); - if ( 'ids' == $q['fields'] ) { + if ( 'ids' === $q['fields'] ) { if ( null === $this->posts ) { $this->posts = $wpdb->get_col( $this->request ); } @@ -2960,7 +2960,7 @@ class WP_Query { return $this->posts; } - if ( 'id=>parent' == $q['fields'] ) { + if ( 'id=>parent' === $q['fields'] ) { if ( null === $this->posts ) { $this->posts = $wpdb->get_results( $this->request ); } @@ -2980,7 +2980,7 @@ class WP_Query { } if ( null === $this->posts ) { - $split_the_query = ( $old_request == $this->request && "{$wpdb->posts}.*" == $fields && ! empty( $limits ) && $q['posts_per_page'] < 500 ); + $split_the_query = ( $old_request == $this->request && "{$wpdb->posts}.*" === $fields && ! empty( $limits ) && $q['posts_per_page'] < 500 ); /** * Filters whether to split the query. @@ -3093,7 +3093,7 @@ class WP_Query { $this->posts = array(); } else { $this->is_preview = true; - if ( 'future' != $status ) { + if ( 'future' !== $status ) { $this->posts[0]->post_date = current_time( 'mysql' ); } } @@ -3481,7 +3481,7 @@ class WP_Query { $query = $this->tax_query->queried_terms[ $matched_taxonomy ]; if ( ! empty( $query['terms'] ) ) { - if ( 'term_id' == $query['field'] ) { + if ( 'term_id' === $query['field'] ) { $term = get_term( reset( $query['terms'] ), $matched_taxonomy ); } else { $term = get_term_by( $query['field'], reset( $query['terms'] ), $matched_taxonomy ); @@ -3876,7 +3876,7 @@ class WP_Query { return (bool) $this->is_feed; } $qv = $this->get( 'feed' ); - if ( 'feed' == $qv ) { + if ( 'feed' === $qv ) { $qv = get_default_feed(); } return in_array( $qv, (array) $feeds, true ); @@ -3911,9 +3911,11 @@ class WP_Query { */ public function is_front_page() { // Most likely case. - if ( 'posts' == get_option( 'show_on_front' ) && $this->is_home() ) { + if ( 'posts' === get_option( 'show_on_front' ) && $this->is_home() ) { return true; - } elseif ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) && $this->is_page( get_option( 'page_on_front' ) ) ) { + } elseif ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) + && $this->is_page( get_option( 'page_on_front' ) ) + ) { return true; } else { return false; @@ -3954,7 +3956,9 @@ class WP_Query { * @return bool True, if Privacy Policy page. */ public function is_privacy_policy() { - if ( get_option( 'wp_page_for_privacy_policy' ) && $this->is_page( get_option( 'wp_page_for_privacy_policy' ) ) ) { + if ( get_option( 'wp_page_for_privacy_policy' ) + && $this->is_page( get_option( 'wp_page_for_privacy_policy' ) ) + ) { return true; } else { return false; diff --git a/src/wp-includes/class-wp-rewrite.php b/src/wp-includes/class-wp-rewrite.php index ca82342114..e23c483893 100644 --- a/src/wp-includes/class-wp-rewrite.php +++ b/src/wp-includes/class-wp-rewrite.php @@ -526,7 +526,7 @@ class WP_Rewrite { preg_match_all( '/%.+?%/', $this->permalink_structure, $tokens ); $tok_index = 1; foreach ( (array) $tokens[0] as $token ) { - if ( '%post_id%' == $token && ( $tok_index <= 3 ) ) { + if ( '%post_id%' === $token && ( $tok_index <= 3 ) ) { $front = $front . 'date/'; break; } @@ -1261,10 +1261,10 @@ class WP_Rewrite { // robots.txt -- only if installed at the root. $home_path = parse_url( home_url() ); - $robots_rewrite = ( empty( $home_path['path'] ) || '/' == $home_path['path'] ) ? array( 'robots\.txt$' => $this->index . '?robots=1' ) : array(); + $robots_rewrite = ( empty( $home_path['path'] ) || '/' === $home_path['path'] ) ? array( 'robots\.txt$' => $this->index . '?robots=1' ) : array(); // favicon.ico -- only if installed at the root. - $favicon_rewrite = ( empty( $home_path['path'] ) || '/' == $home_path['path'] ) ? array( 'favicon\.ico$' => $this->index . '?favicon=1' ) : array(); + $favicon_rewrite = ( empty( $home_path['path'] ) || '/' === $home_path['path'] ) ? array( 'favicon\.ico$' => $this->index . '?favicon=1' ) : array(); // Old feed and service files. $deprecated_files = array( @@ -1404,7 +1404,8 @@ class WP_Rewrite { * @param string[] $rules Array of rewrite rules generated for the current permastruct, keyed by their regex pattern. */ $rules = apply_filters( "{$permastructname}_rewrite_rules", $rules ); - if ( 'post_tag' == $permastructname ) { + + if ( 'post_tag' === $permastructname ) { /** * Filters rewrite rules used specifically for Tags. @@ -1647,7 +1648,7 @@ class WP_Rewrite { if ( $external ) { $this->add_external_rule( $regex, $query ); } else { - if ( 'bottom' == $after ) { + if ( 'bottom' === $after ) { $this->extra_rules = array_merge( $this->extra_rules, array( $regex => $query ) ); } else { $this->extra_rules_top = array_merge( $this->extra_rules_top, array( $regex => $query ) ); @@ -1854,7 +1855,8 @@ class WP_Rewrite { unset( $this->search_structure ); unset( $this->feed_structure ); unset( $this->comment_feed_structure ); - $this->use_trailing_slashes = ( '/' == substr( $this->permalink_structure, -1, 1 ) ); + + $this->use_trailing_slashes = ( '/' === substr( $this->permalink_structure, -1, 1 ) ); // Enable generic rules for pages if permalink structure doesn't begin with a wildcard. if ( preg_match( '/^[^%]*%(?:postname|category|tag|author)%/', $this->permalink_structure ) ) { diff --git a/src/wp-includes/class-wp-site-query.php b/src/wp-includes/class-wp-site-query.php index f2cc1b788a..a14c48c855 100644 --- a/src/wp-includes/class-wp-site-query.php +++ b/src/wp-includes/class-wp-site-query.php @@ -297,7 +297,7 @@ class WP_Site_Query { * * The expected return type from this filter depends on the value passed in the request query_vars: * When `$this->query_vars['count']` is set, the filter should return the site count as an int. - * When `'ids' == $this->query_vars['fields']`, the filter should return an array of site ids. + * When `'ids' === $this->query_vars['fields']`, the filter should return an array of site ids. * Otherwise the filter should return an array of WP_Site objects. * * @since 5.2.0 @@ -353,7 +353,7 @@ class WP_Site_Query { $site_ids = array_map( 'intval', $site_ids ); - if ( 'ids' == $this->query_vars['fields'] ) { + if ( 'ids' === $this->query_vars['fields'] ) { $this->sites = $site_ids; return $this->sites; diff --git a/src/wp-includes/class-wp-tax-query.php b/src/wp-includes/class-wp-tax-query.php index cf4427e7d3..15349b78a9 100644 --- a/src/wp-includes/class-wp-tax-query.php +++ b/src/wp-includes/class-wp-tax-query.php @@ -400,7 +400,7 @@ class WP_Tax_Query { $terms = $clause['terms']; $operator = strtoupper( $clause['operator'] ); - if ( 'IN' == $operator ) { + if ( 'IN' === $operator ) { if ( empty( $terms ) ) { return self::$no_results; @@ -430,7 +430,7 @@ class WP_Tax_Query { $where = "$alias.term_taxonomy_id $operator ($terms)"; - } elseif ( 'NOT IN' == $operator ) { + } elseif ( 'NOT IN' === $operator ) { if ( empty( $terms ) ) { return $sql; @@ -444,7 +444,7 @@ class WP_Tax_Query { WHERE term_taxonomy_id IN ($terms) )"; - } elseif ( 'AND' == $operator ) { + } elseif ( 'AND' === $operator ) { if ( empty( $terms ) ) { return $sql; @@ -641,7 +641,7 @@ class WP_Tax_Query { return; } - if ( 'AND' == $query['operator'] && count( $term_list ) < count( $query['terms'] ) ) { + if ( 'AND' === $query['operator'] && count( $term_list ) < count( $query['terms'] ) ) { $query = new WP_Error( 'inexistent_terms', __( 'Inexistent terms.' ) ); return; } diff --git a/src/wp-includes/class-wp-taxonomy.php b/src/wp-includes/class-wp-taxonomy.php index 7cb35e9044..0ff90fb53e 100644 --- a/src/wp-includes/class-wp-taxonomy.php +++ b/src/wp-includes/class-wp-taxonomy.php @@ -299,7 +299,7 @@ final class WP_Taxonomy { $args['query_var'] = false; } - if ( false !== $args['rewrite'] && ( is_admin() || '' != get_option( 'permalink_structure' ) ) ) { + if ( false !== $args['rewrite'] && ( is_admin() || get_option( 'permalink_structure' ) ) ) { $args['rewrite'] = wp_parse_args( $args['rewrite'], array( @@ -400,7 +400,7 @@ final class WP_Taxonomy { $wp->add_query_var( $this->query_var ); } - if ( false !== $this->rewrite && ( is_admin() || '' != get_option( 'permalink_structure' ) ) ) { + if ( false !== $this->rewrite && ( is_admin() || get_option( 'permalink_structure' ) ) ) { if ( $this->hierarchical && $this->rewrite['hierarchical'] ) { $tag = '(.+?)'; } else { diff --git a/src/wp-includes/class-wp-term-query.php b/src/wp-includes/class-wp-term-query.php index 1ef802ecbc..6d4844d173 100644 --- a/src/wp-includes/class-wp-term-query.php +++ b/src/wp-includes/class-wp-term-query.php @@ -253,7 +253,7 @@ class WP_Term_Query { $query['child_of'] = false; } - if ( 'all' == $query['get'] ) { + if ( 'all' === $query['get'] ) { $query['childless'] = false; $query['child_of'] = 0; $query['hide_empty'] = 0; @@ -341,7 +341,7 @@ class WP_Term_Query { $args['child_of'] = false; } - if ( 'all' == $args['get'] ) { + if ( 'all' === $args['get'] ) { $args['childless'] = false; $args['child_of'] = 0; $args['hide_empty'] = 0; @@ -382,7 +382,7 @@ class WP_Term_Query { } if ( ! $in_hierarchy ) { - if ( 'count' == $args['fields'] ) { + if ( 'count' === $args['fields'] ) { return 0; } else { $this->terms = array(); @@ -545,7 +545,7 @@ class WP_Term_Query { } $hierarchical = $args['hierarchical']; - if ( 'count' == $args['fields'] ) { + if ( 'count' === $args['fields'] ) { $hierarchical = false; } if ( $args['hide_empty'] && ! $hierarchical ) { @@ -709,14 +709,15 @@ class WP_Term_Query { return $this->terms; } - if ( 'count' == $_fields ) { + if ( 'count' === $_fields ) { $count = $wpdb->get_var( $this->request ); wp_cache_set( $cache_key, $count, 'terms' ); return $count; } $terms = $wpdb->get_results( $this->request ); - if ( 'all' == $_fields || 'all_with_object_id' === $_fields ) { + + if ( 'all' === $_fields || 'all_with_object_id' === $_fields ) { update_term_cache( $terms ); } @@ -741,7 +742,7 @@ class WP_Term_Query { } // Update term counts to include children. - if ( $args['pad_counts'] && 'all' == $_fields ) { + if ( $args['pad_counts'] && 'all' === $_fields ) { foreach ( $taxonomies as $_tax ) { _pad_term_counts( $terms, $_tax ); } @@ -773,7 +774,7 @@ class WP_Term_Query { * `$fields` is 'all_with_object_id', but should otherwise be * removed. */ - if ( ! empty( $args['object_ids'] ) && 'all_with_object_id' != $_fields ) { + if ( ! empty( $args['object_ids'] ) && 'all_with_object_id' !== $_fields ) { $_tt_ids = array(); $_terms = array(); foreach ( $terms as $term ) { @@ -789,31 +790,31 @@ class WP_Term_Query { } $_terms = array(); - if ( 'id=>parent' == $_fields ) { + if ( 'id=>parent' === $_fields ) { foreach ( $terms as $term ) { $_terms[ $term->term_id ] = $term->parent; } - } elseif ( 'ids' == $_fields ) { + } elseif ( 'ids' === $_fields ) { foreach ( $terms as $term ) { $_terms[] = (int) $term->term_id; } - } elseif ( 'tt_ids' == $_fields ) { + } elseif ( 'tt_ids' === $_fields ) { foreach ( $terms as $term ) { $_terms[] = (int) $term->term_taxonomy_id; } - } elseif ( 'names' == $_fields ) { + } elseif ( 'names' === $_fields ) { foreach ( $terms as $term ) { $_terms[] = $term->name; } - } elseif ( 'slugs' == $_fields ) { + } elseif ( 'slugs' === $_fields ) { foreach ( $terms as $term ) { $_terms[] = $term->slug; } - } elseif ( 'id=>name' == $_fields ) { + } elseif ( 'id=>name' === $_fields ) { foreach ( $terms as $term ) { $_terms[ $term->term_id ] = $term->name; } - } elseif ( 'id=>slug' == $_fields ) { + } elseif ( 'id=>slug' === $_fields ) { foreach ( $terms as $term ) { $_terms[ $term->term_id ] = $term->slug; } @@ -862,15 +863,15 @@ class WP_Term_Query { $orderby = "tt.$_orderby"; } elseif ( 'term_order' === $_orderby ) { $orderby = 'tr.term_order'; - } elseif ( 'include' == $_orderby && ! empty( $this->query_vars['include'] ) ) { + } elseif ( 'include' === $_orderby && ! empty( $this->query_vars['include'] ) ) { $include = implode( ',', wp_parse_id_list( $this->query_vars['include'] ) ); $orderby = "FIELD( t.term_id, $include )"; - } elseif ( 'slug__in' == $_orderby && ! empty( $this->query_vars['slug'] ) && is_array( $this->query_vars['slug'] ) ) { + } elseif ( 'slug__in' === $_orderby && ! empty( $this->query_vars['slug'] ) && is_array( $this->query_vars['slug'] ) ) { $slugs = implode( "', '", array_map( 'sanitize_title_for_query', $this->query_vars['slug'] ) ); $orderby = "FIELD( t.slug, '" . $slugs . "')"; - } elseif ( 'none' == $_orderby ) { + } elseif ( 'none' === $_orderby ) { $orderby = ''; - } elseif ( empty( $_orderby ) || 'id' == $_orderby || 'term_id' === $_orderby ) { + } elseif ( empty( $_orderby ) || 'id' === $_orderby || 'term_id' === $_orderby ) { $orderby = 't.term_id'; } else { $orderby = 't.name'; diff --git a/src/wp-includes/class-wp-theme.php b/src/wp-includes/class-wp-theme.php index c38262e623..ca6359ec7e 100644 --- a/src/wp-includes/class-wp-theme.php +++ b/src/wp-includes/class-wp-theme.php @@ -340,7 +340,8 @@ final class WP_Theme implements ArrayAccess { // wp-content/themes/directory-of-themes/* $parent_dir = dirname( $this->stylesheet ); $directories = search_theme_directories(); - if ( '.' != $parent_dir && file_exists( $this->theme_root . '/' . $parent_dir . '/' . $this->template . '/index.php' ) ) { + + if ( '.' !== $parent_dir && file_exists( $this->theme_root . '/' . $parent_dir . '/' . $this->template . '/index.php' ) ) { $this->template = $parent_dir . '/' . $this->template; } elseif ( $directories && isset( $directories[ $this->template ] ) ) { // Look for the template in the search_theme_directories() results, in case it is in another theme root. @@ -1142,7 +1143,7 @@ final class WP_Theme implements ArrayAccess { public function get_screenshot( $uri = 'uri' ) { $screenshot = $this->cache_get( 'screenshot' ); if ( $screenshot ) { - if ( 'relative' == $uri ) { + if ( 'relative' === $uri ) { return $screenshot; } return $this->get_stylesheet_directory_uri() . '/' . $screenshot; @@ -1153,7 +1154,7 @@ final class WP_Theme implements ArrayAccess { foreach ( array( 'png', 'gif', 'jpg', 'jpeg' ) as $ext ) { if ( file_exists( $this->get_stylesheet_directory() . "/screenshot.$ext" ) ) { $this->cache_add( 'screenshot', 'screenshot.' . $ext ); - if ( 'relative' == $uri ) { + if ( 'relative' === $uri ) { return 'screenshot.' . $ext; } return $this->get_stylesheet_directory_uri() . '/' . 'screenshot.' . $ext; @@ -1319,7 +1320,7 @@ final class WP_Theme implements ArrayAccess { } $relative_path = trailingslashit( $relative_path ); - if ( '/' == $relative_path ) { + if ( '/' === $relative_path ) { $relative_path = ''; } @@ -1336,7 +1337,7 @@ final class WP_Theme implements ArrayAccess { $exclusions = (array) apply_filters( 'theme_scandir_exclusions', array( 'CVS', 'node_modules', 'vendor', 'bower_components' ) ); foreach ( $results as $result ) { - if ( '.' == $result[0] || in_array( $result, $exclusions, true ) ) { + if ( '.' === $result[0] || in_array( $result, $exclusions, true ) ) { continue; } if ( is_dir( $path . '/' . $result ) ) { @@ -1407,14 +1408,14 @@ final class WP_Theme implements ArrayAccess { return true; } - if ( 'both' == $check || 'network' == $check ) { + if ( 'both' === $check || 'network' === $check ) { $allowed = self::get_allowed_on_network(); if ( ! empty( $allowed[ $this->get_stylesheet() ] ) ) { return true; } } - if ( 'both' == $check || 'site' == $check ) { + if ( 'both' === $check || 'site' === $check ) { $allowed = self::get_allowed_on_site( $blog_id ); if ( ! empty( $allowed[ $this->get_stylesheet() ] ) ) { return true; diff --git a/src/wp-includes/class-wp-user-query.php b/src/wp-includes/class-wp-user-query.php index 617773c3ae..02b0ff3814 100644 --- a/src/wp-includes/class-wp-user-query.php +++ b/src/wp-includes/class-wp-user-query.php @@ -242,7 +242,7 @@ class WP_User_Query { $this->query_fields[] = "$wpdb->users.$field"; } $this->query_fields = implode( ',', $this->query_fields ); - } elseif ( 'all' == $qv['fields'] ) { + } elseif ( 'all' === $qv['fields'] ) { $this->query_fields = "$wpdb->users.*"; } else { $this->query_fields = "$wpdb->users.ID"; @@ -320,7 +320,7 @@ class WP_User_Query { $this->meta_query = new WP_Meta_Query(); $this->meta_query->parse_query_vars( $qv ); - if ( isset( $qv['who'] ) && 'authors' == $qv['who'] && $blog_id ) { + if ( isset( $qv['who'] ) && 'authors' === $qv['who'] && $blog_id ) { $who_query = array( 'key' => $wpdb->get_blog_prefix( $blog_id ) . 'user_level', 'value' => 0, @@ -614,7 +614,7 @@ class WP_User_Query { if ( null === $this->results ) { $this->request = "SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit"; - if ( is_array( $qv['fields'] ) || 'all' == $qv['fields'] ) { + if ( is_array( $qv['fields'] ) || 'all' === $qv['fields'] ) { $this->results = $wpdb->get_results( $this->request ); } else { $this->results = $wpdb->get_col( $this->request ); @@ -642,7 +642,7 @@ class WP_User_Query { return; } - if ( 'all_with_meta' == $qv['fields'] ) { + if ( 'all_with_meta' === $qv['fields'] ) { cache_users( $this->results ); $r = array(); @@ -651,7 +651,7 @@ class WP_User_Query { } $this->results = $r; - } elseif ( 'all' == $qv['fields'] ) { + } elseif ( 'all' === $qv['fields'] ) { foreach ( $this->results as $key => $user ) { $this->results[ $key ] = new WP_User( $user, '', $qv['blog_id'] ); } @@ -703,12 +703,12 @@ class WP_User_Query { global $wpdb; $searches = array(); - $leading_wild = ( 'leading' == $wild || 'both' == $wild ) ? '%' : ''; - $trailing_wild = ( 'trailing' == $wild || 'both' == $wild ) ? '%' : ''; + $leading_wild = ( 'leading' === $wild || 'both' === $wild ) ? '%' : ''; + $trailing_wild = ( 'trailing' === $wild || 'both' === $wild ) ? '%' : ''; $like = $leading_wild . $wpdb->esc_like( $string ) . $trailing_wild; foreach ( $cols as $col ) { - if ( 'ID' == $col ) { + if ( 'ID' === $col ) { $searches[] = $wpdb->prepare( "$col = %s", $string ); } else { $searches[] = $wpdb->prepare( "$col LIKE %s", $like ); @@ -760,9 +760,9 @@ class WP_User_Query { $_orderby = 'user_' . $orderby; } elseif ( in_array( $orderby, array( 'user_login', 'user_nicename', 'user_email', 'user_url', 'user_registered' ), true ) ) { $_orderby = $orderby; - } elseif ( 'name' == $orderby || 'display_name' == $orderby ) { + } elseif ( 'name' === $orderby || 'display_name' === $orderby ) { $_orderby = 'display_name'; - } elseif ( 'post_count' == $orderby ) { + } elseif ( 'post_count' === $orderby ) { // @todo Avoid the JOIN. $where = get_posts_by_author_sql( 'post' ); $this->query_from .= " LEFT OUTER JOIN ( @@ -773,11 +773,11 @@ class WP_User_Query { ) p ON ({$wpdb->users}.ID = p.post_author) "; $_orderby = 'post_count'; - } elseif ( 'ID' == $orderby || 'id' == $orderby ) { + } elseif ( 'ID' === $orderby || 'id' === $orderby ) { $_orderby = 'ID'; - } elseif ( 'meta_value' == $orderby || $this->get( 'meta_key' ) == $orderby ) { + } elseif ( 'meta_value' === $orderby || $this->get( 'meta_key' ) == $orderby ) { $_orderby = "$wpdb->usermeta.meta_value"; - } elseif ( 'meta_value_num' == $orderby ) { + } elseif ( 'meta_value_num' === $orderby ) { $_orderby = "$wpdb->usermeta.meta_value+0"; } elseif ( 'include' === $orderby && ! empty( $this->query_vars['include'] ) ) { $include = wp_parse_id_list( $this->query_vars['include'] ); diff --git a/src/wp-includes/class-wp-user.php b/src/wp-includes/class-wp-user.php index a7ff4e6974..abb56b05a0 100644 --- a/src/wp-includes/class-wp-user.php +++ b/src/wp-includes/class-wp-user.php @@ -192,7 +192,7 @@ class WP_User { $field = 'id'; } - if ( 'id' == $field ) { + if ( 'id' === $field ) { // Make sure the value is numeric to avoid casting objects, for example, // to int 1. if ( ! is_numeric( $value ) ) { @@ -263,7 +263,7 @@ class WP_User { * @return bool Whether the given user meta key is set. */ public function __isset( $key ) { - if ( 'id' == $key ) { + if ( 'id' === $key ) { _deprecated_argument( 'WP_User->id', '2.1.0', @@ -296,7 +296,7 @@ class WP_User { * @return mixed Value of the given user meta key (if set). If `$key` is 'id', the user ID. */ public function __get( $key ) { - if ( 'id' == $key ) { + if ( 'id' === $key ) { _deprecated_argument( 'WP_User->id', '2.1.0', @@ -337,7 +337,7 @@ class WP_User { * @param mixed $value User meta value. */ public function __set( $key, $value ) { - if ( 'id' == $key ) { + if ( 'id' === $key ) { _deprecated_argument( 'WP_User->id', '2.1.0', @@ -362,7 +362,7 @@ class WP_User { * @param string $key User meta key to unset. */ public function __unset( $key ) { - if ( 'id' == $key ) { + if ( 'id' === $key ) { _deprecated_argument( 'WP_User->id', '2.1.0', diff --git a/src/wp-includes/class-wp-xmlrpc-server.php b/src/wp-includes/class-wp-xmlrpc-server.php index 5a32694129..6e74bf6ca5 100644 --- a/src/wp-includes/class-wp-xmlrpc-server.php +++ b/src/wp-includes/class-wp-xmlrpc-server.php @@ -1131,7 +1131,7 @@ class wp_xmlrpc_server extends IXR_Server { if ( '0' == $comment->comment_approved ) { $comment_status = 'hold'; - } elseif ( 'spam' == $comment->comment_approved ) { + } elseif ( 'spam' === $comment->comment_approved ) { $comment_status = 'spam'; } elseif ( '1' == $comment->comment_approved ) { $comment_status = 'approve'; @@ -3379,7 +3379,7 @@ class wp_xmlrpc_server extends IXR_Server { $cat_id = wp_insert_category( $new_category, true ); if ( is_wp_error( $cat_id ) ) { - if ( 'term_exists' == $cat_id->get_error_code() ) { + if ( 'term_exists' === $cat_id->get_error_code() ) { return (int) $cat_id->get_error_data(); } else { return new IXR_Error( 500, __( 'Sorry, the category could not be created.' ) ); @@ -3912,7 +3912,7 @@ class wp_xmlrpc_server extends IXR_Server { $comment['user_ID'] = 0; if ( get_option( 'require_name_email' ) ) { - if ( 6 > strlen( $comment['comment_author_email'] ) || '' == $comment['comment_author'] ) { + if ( strlen( $comment['comment_author_email'] < 6 ) || '' === $comment['comment_author'] ) { return new IXR_Error( 403, __( 'Comment author name and email are required.' ) ); } elseif ( ! is_email( $comment['comment_author_email'] ) ) { return new IXR_Error( 403, __( 'A valid email address is required.' ) ); @@ -5720,7 +5720,7 @@ class wp_xmlrpc_server extends IXR_Server { } $page_template = null; - if ( ! empty( $content_struct['wp_page_template'] ) && 'page' == $post_type ) { + if ( ! empty( $content_struct['wp_page_template'] ) && 'page' === $post_type ) { $page_template = $content_struct['wp_page_template']; } @@ -5847,7 +5847,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 ( 'page' == $post_type && ! current_user_can( 'publish_pages' ) ) { + 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' ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this 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'] ); @@ -6020,8 +6020,8 @@ class wp_xmlrpc_server extends IXR_Server { // Get the author info. $author = get_userdata( $postdata['post_author'] ); - $allow_comments = ( 'open' == $postdata['comment_status'] ) ? 1 : 0; - $allow_pings = ( 'open' == $postdata['ping_status'] ) ? 1 : 0; + $allow_comments = ( 'open' === $postdata['comment_status'] ) ? 1 : 0; + $allow_pings = ( 'open' === $postdata['ping_status'] ) ? 1 : 0; // Consider future posts as published. if ( 'future' === $postdata['post_status'] ) { @@ -6172,8 +6172,8 @@ class wp_xmlrpc_server extends IXR_Server { // Get the post author info. $author = get_userdata( $entry['post_author'] ); - $allow_comments = ( 'open' == $entry['comment_status'] ) ? 1 : 0; - $allow_pings = ( 'open' == $entry['ping_status'] ) ? 1 : 0; + $allow_comments = ( 'open' === $entry['comment_status'] ) ? 1 : 0; + $allow_pings = ( 'open' === $entry['ping_status'] ) ? 1 : 0; // Consider future posts as published. if ( 'future' === $entry['post_status'] ) { @@ -6681,7 +6681,7 @@ class wp_xmlrpc_server extends IXR_Server { $trackback_pings = array(); foreach ( $comments as $comment ) { - if ( 'trackback' == $comment->comment_type ) { + if ( 'trackback' === $comment->comment_type ) { $content = $comment->comment_content; $title = substr( $content, 8, ( strpos( $content, '</strong>' ) - 8 ) ); $trackback_pings[] = array( @@ -7028,7 +7028,7 @@ class wp_xmlrpc_server extends IXR_Server { $pingbacks = array(); foreach ( $comments as $comment ) { - if ( 'pingback' == $comment->comment_type ) { + if ( 'pingback' === $comment->comment_type ) { $pingbacks[] = $comment->comment_author_url; } } diff --git a/src/wp-includes/class-wp.php b/src/wp-includes/class-wp.php index ba1f15d033..0d6268fe08 100644 --- a/src/wp-includes/class-wp.php +++ b/src/wp-includes/class-wp.php @@ -420,7 +420,7 @@ class WP { } else { // Set the correct content type for feeds. $type = $this->query_vars['feed']; - if ( 'feed' == $this->query_vars['feed'] ) { + if ( 'feed' === $this->query_vars['feed'] ) { $type = get_default_feed(); } $headers['Content-Type'] = feed_content_type( $type ) . '; charset=' . get_option( 'blog_charset' ); diff --git a/src/wp-includes/comment-template.php b/src/wp-includes/comment-template.php index 2048dccdfa..d792bffd9c 100644 --- a/src/wp-includes/comment-template.php +++ b/src/wp-includes/comment-template.php @@ -193,7 +193,7 @@ 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; + $display = ( '' !== $linktext ) ? $linktext : $email; $return = $before; $return .= sprintf( '<a href="%1$s">%2$s</a>', esc_url( 'mailto:' . $email ), esc_html( $display ) ); $return .= $after; @@ -221,7 +221,7 @@ function get_comment_author_link( $comment_ID = 0 ) { $url = get_comment_author_url( $comment ); $author = get_comment_author( $comment ); - if ( empty( $url ) || 'http://' == $url ) { + if ( empty( $url ) || 'http://' === $url ) { $return = $author; } else { $return = "<a href='$url' rel='external nofollow ugc' class='url'>$author</a>"; @@ -308,7 +308,7 @@ function get_comment_author_url( $comment_ID = 0 ) { $url = ''; $id = 0; if ( ! empty( $comment ) ) { - $author_url = ( 'http://' == $comment->comment_author_url ) ? '' : $comment->comment_author_url; + $author_url = ( 'http://' === $comment->comment_author_url ) ? '' : $comment->comment_author_url; $url = esc_url( $author_url, array( 'http', 'https' ) ); $id = $comment->comment_ID; } @@ -376,11 +376,11 @@ 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 ); - if ( '/' == substr( $display, -1 ) ) { + if ( '/' === substr( $display, -1 ) ) { $display = substr( $display, 0, -1 ); } @@ -550,11 +550,13 @@ function get_comment_class( $class = '', $comment_id = null, $post_id = null ) { */ function get_comment_date( $format = '', $comment_ID = 0 ) { $comment = get_comment( $comment_ID ); - if ( '' == $format ) { + + if ( '' === $format ) { $date = mysql2date( get_option( 'date_format' ), $comment->comment_date ); } else { $date = mysql2date( $format, $comment->comment_date ); } + /** * Filters the returned comment date. * @@ -1037,7 +1039,8 @@ function get_comment_time( $format = '', $gmt = false, $translate = true ) { $comment = get_comment(); $comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date; - if ( '' == $format ) { + + if ( '' === $format ) { $date = mysql2date( get_option( 'time_format' ), $comment_date, $translate ); } else { $date = mysql2date( $format, $comment_date, $translate ); @@ -1080,7 +1083,8 @@ function comment_time( $format = '' ) { */ function get_comment_type( $comment_ID = 0 ) { $comment = get_comment( $comment_ID ); - if ( '' == $comment->comment_type ) { + + if ( '' === $comment->comment_type ) { $comment->comment_type = 'comment'; } @@ -1141,7 +1145,7 @@ function comment_type( $commenttxt = false, $trackbacktxt = false, $pingbacktxt * @return string The trackback URL after being filtered. */ function get_trackback_url() { - if ( '' != get_option( 'permalink_structure' ) ) { + if ( get_option( 'permalink_structure' ) ) { $tb_url = trailingslashit( get_permalink() ) . user_trailingslashit( 'trackback', 'single_trackback' ); } else { $tb_url = get_option( 'siteurl' ) . '/wp-trackback.php?p=' . get_the_ID(); @@ -1235,7 +1239,7 @@ function comments_open( $post_id = null ) { $_post = get_post( $post_id ); $post_id = $_post ? $_post->ID : 0; - $open = ( 'open' == $_post->comment_status ); + $open = ( 'open' === $_post->comment_status ); /** * Filters whether the current post is open for comments. @@ -1265,7 +1269,7 @@ function pings_open( $post_id = null ) { $_post = get_post( $post_id ); $post_id = $_post ? $_post->ID : 0; - $open = ( 'open' == $_post->ping_status ); + $open = ( 'open' === $_post->ping_status ); /** * Filters whether the current post is open for pings. @@ -1505,8 +1509,9 @@ function comments_template( $file = '/comments.php', $separate_comments = false } $overridden_cpage = false; + if ( '' == get_query_var( 'cpage' ) && $wp_query->max_num_comment_pages > 1 ) { - set_query_var( 'cpage', 'newest' == get_option( 'default_comments_page' ) ? get_comment_pages_count() : 1 ); + set_query_var( 'cpage', 'newest' === get_option( 'default_comments_page' ) ? get_comment_pages_count() : 1 ); $overridden_cpage = true; } @@ -1515,6 +1520,7 @@ function comments_template( $file = '/comments.php', $separate_comments = false } $theme_template = STYLESHEETPATH . $file; + /** * Filters the path to the theme template file used for the comments template. * @@ -1523,6 +1529,7 @@ function comments_template( $file = '/comments.php', $separate_comments = false * @param string $theme_template The path to the theme template file. */ $include = apply_filters( 'comments_template', $theme_template ); + if ( file_exists( $include ) ) { require $include; } elseif ( file_exists( TEMPLATEPATH . $file ) ) { @@ -2060,7 +2067,7 @@ function wp_list_comments( $args = array(), $comments = null ) { if ( empty( $comments ) ) { return; } - if ( 'all' != $parsed_args['type'] ) { + if ( 'all' !== $parsed_args['type'] ) { $comments_by_type = separate_comments( $comments ); if ( empty( $comments_by_type[ $parsed_args['type'] ] ) ) { return; @@ -2101,7 +2108,7 @@ function wp_list_comments( $args = array(), $comments = null ) { $comments = get_comments( $comment_args ); - if ( 'all' != $parsed_args['type'] ) { + if ( 'all' !== $parsed_args['type'] ) { $comments_by_type = separate_comments( $comments ); if ( empty( $comments_by_type[ $parsed_args['type'] ] ) ) { return; @@ -2118,7 +2125,7 @@ function wp_list_comments( $args = array(), $comments = null ) { if ( empty( $wp_query->comments ) ) { return; } - if ( 'all' != $parsed_args['type'] ) { + if ( 'all' !== $parsed_args['type'] ) { if ( empty( $wp_query->comments_by_type ) ) { $wp_query->comments_by_type = separate_comments( $wp_query->comments ); } @@ -2174,7 +2181,7 @@ function wp_list_comments( $args = array(), $comments = null ) { $parsed_args['page'] = get_query_var( 'cpage' ); } else { $threaded = ( -1 != $parsed_args['max_depth'] ); - $parsed_args['page'] = ( 'newest' == get_option( 'default_comments_page' ) ) ? get_comment_pages_count( $_comments, $parsed_args['per_page'], $threaded ) : 1; + $parsed_args['page'] = ( 'newest' === get_option( 'default_comments_page' ) ) ? get_comment_pages_count( $_comments, $parsed_args['per_page'], $threaded ) : 1; set_query_var( 'cpage', $parsed_args['page'] ); } } @@ -2185,7 +2192,7 @@ function wp_list_comments( $args = array(), $comments = null ) { } if ( null === $parsed_args['reverse_top_level'] ) { - $parsed_args['reverse_top_level'] = ( 'desc' == get_option( 'comment_order' ) ); + $parsed_args['reverse_top_level'] = ( 'desc' === get_option( 'comment_order' ) ); } wp_queue_comments_for_comment_meta_lazyload( $_comments ); diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index 8648a89a0f..a57cf275f8 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -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 ) ); @@ -963,14 +963,19 @@ function separate_comments( &$comments ) { 'pingback' => array(), 'pings' => array(), ); - $count = count( $comments ); + + $count = count( $comments ); + for ( $i = 0; $i < $count; $i++ ) { $type = $comments[ $i ]->comment_type; + if ( empty( $type ) ) { $type = 'comment'; } + $comments_by_type[ $type ][] = &$comments[ $i ]; - if ( 'trackback' == $type || 'pingback' == $type ) { + + if ( 'trackback' === $type || 'pingback' === $type ) { $comments_by_type['pings'][] = &$comments[ $i ]; } } @@ -1281,7 +1286,7 @@ function wp_blacklist_check( $author, $email, $url, $comment, $user_ip, $user_ag do_action( 'wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent ); $mod_keys = trim( get_option( 'blacklist_keys' ) ); - if ( '' == $mod_keys ) { + if ( '' === $mod_keys ) { return false; // If moderation keys are empty. } @@ -1671,9 +1676,9 @@ function wp_get_comment_status( $comment_id ) { return 'approved'; } elseif ( '0' == $approved ) { return 'unapproved'; - } elseif ( 'spam' == $approved ) { + } elseif ( 'spam' === $approved ) { return 'spam'; - } elseif ( 'trash' == $approved ) { + } elseif ( 'trash' === $approved ) { return 'trash'; } else { return false; @@ -2114,8 +2119,10 @@ function wp_new_comment( $commentdata, $avoid_die = false ) { } $commentdata['comment_parent'] = isset( $commentdata['comment_parent'] ) ? absint( $commentdata['comment_parent'] ) : 0; - $parent_status = ( 0 < $commentdata['comment_parent'] ) ? wp_get_comment_status( $commentdata['comment_parent'] ) : ''; - $commentdata['comment_parent'] = ( 'approved' == $parent_status || 'unapproved' == $parent_status ) ? $commentdata['comment_parent'] : 0; + + $parent_status = ( $commentdata['comment_parent'] > 0 ) ? wp_get_comment_status( $commentdata['comment_parent'] ) : ''; + + $commentdata['comment_parent'] = ( 'approved' === $parent_status || 'unapproved' === $parent_status ) ? $commentdata['comment_parent'] : 0; if ( ! isset( $commentdata['comment_author_IP'] ) ) { $commentdata['comment_author_IP'] = $_SERVER['REMOTE_ADDR']; @@ -2375,9 +2382,9 @@ function wp_update_comment( $commentarr ) { if ( ! isset( $data['comment_approved'] ) ) { $data['comment_approved'] = 1; - } elseif ( 'hold' == $data['comment_approved'] ) { + } elseif ( 'hold' === $data['comment_approved'] ) { $data['comment_approved'] = 0; - } elseif ( 'approve' == $data['comment_approved'] ) { + } elseif ( 'approve' === $data['comment_approved'] ) { $data['comment_approved'] = 1; } @@ -2800,7 +2807,7 @@ function generic_ping( $post_id = 0 ) { $services = explode( "\n", $services ); foreach ( (array) $services as $service ) { $service = trim( $service ); - if ( '' != $service ) { + if ( '' !== $service ) { weblog_ping( $service ); } } @@ -2985,7 +2992,7 @@ function weblog_ping( $server = '', $path = '' ) { include_once ABSPATH . WPINC . '/class-wp-http-ixr-client.php'; // Using a timeout of 3 seconds should be enough to cover slow servers. - $client = new WP_HTTP_IXR_Client( $server, ( ( ! strlen( trim( $path ) ) || ( '/' == $path ) ) ? false : $path ) ); + $client = new WP_HTTP_IXR_Client( $server, ( ( ! strlen( trim( $path ) ) || ( '/' === $path ) ) ? false : $path ) ); $client->timeout = 3; $client->useragent .= ' -- WordPress/' . get_bloginfo( 'version' ); @@ -3266,7 +3273,7 @@ function wp_handle_comment_submission( $comment_data ) { // get_post_status() will get the parent status for attachments. $status = get_post_status( $post ); - if ( ( 'private' == $status ) && ! current_user_can( 'read_post', $comment_post_ID ) ) { + if ( ( 'private' === $status ) && ! current_user_can( 'read_post', $comment_post_ID ) ) { return new WP_Error( 'comment_id_not_found' ); } @@ -3285,7 +3292,7 @@ function wp_handle_comment_submission( $comment_data ) { return new WP_Error( 'comment_closed', __( 'Sorry, comments are closed for this item.' ), 403 ); - } elseif ( 'trash' == $status ) { + } elseif ( 'trash' === $status ) { /** * Fires when a comment is attempted on a trashed post. diff --git a/src/wp-includes/feed.php b/src/wp-includes/feed.php index 41bb04c288..3ac76955e1 100644 --- a/src/wp-includes/feed.php +++ b/src/wp-includes/feed.php @@ -85,7 +85,8 @@ function get_default_feed() { * Default 'rss2'. */ $default_feed = apply_filters( 'default_feed', 'rss2' ); - return 'rss' == $default_feed ? 'rss2' : $default_feed; + + return ( 'rss' === $default_feed ) ? 'rss2' : $default_feed; } /** @@ -160,8 +161,7 @@ function get_the_title_rss() { * * @param string $title The current post title. */ - $title = apply_filters( 'the_title_rss', $title ); - return $title; + return apply_filters( 'the_title_rss', $title ); } /** @@ -190,6 +190,7 @@ function get_the_content_feed( $feed_type = null ) { /** This filter is documented in wp-includes/post-template.php */ $content = apply_filters( 'the_content', get_the_content() ); $content = str_replace( ']]>', ']]>', $content ); + /** * Filters the post content for use in feeds. * @@ -382,7 +383,7 @@ function get_the_category_rss( $type = null ) { $cat_names = array(); $filter = 'rss'; - if ( 'atom' == $type ) { + if ( 'atom' === $type ) { $filter = 'raw'; } @@ -401,9 +402,9 @@ function get_the_category_rss( $type = null ) { $cat_names = array_unique( $cat_names ); foreach ( $cat_names as $cat_name ) { - if ( 'rdf' == $type ) { + if ( 'rdf' === $type ) { $the_list .= "\t\t<dc:subject><![CDATA[$cat_name]]></dc:subject>\n"; - } elseif ( 'atom' == $type ) { + } elseif ( 'atom' === $type ) { $the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', esc_attr( get_bloginfo_rss( 'url' ) ), esc_attr( $cat_name ) ); } else { $the_list .= "\t\t<category><![CDATA[" . html_entity_decode( $cat_name, ENT_COMPAT, get_option( 'blog_charset' ) ) . "]]></category>\n"; diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index 8854d2f34e..f7f318f9c8 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -379,7 +379,7 @@ function wptexturize_primes( $haystack, $needle, $prime, $open_quote, $close_quo $sentence = preg_replace( $prime_pattern, $prime, $sentence ); $sentence = preg_replace( $quote_pattern, $close_quote, $sentence ); } - if ( '"' == $needle && false !== strpos( $sentence, '"' ) ) { + if ( '"' === $needle && false !== strpos( $sentence, '"' ) ) { $sentence = str_replace( '"', $close_quote, $sentence ); } } @@ -1938,7 +1938,7 @@ function remove_accents( $string ) { // Used for locale-specific rules. $locale = get_locale(); - if ( 'de_DE' == $locale || 'de_DE_formal' == $locale || 'de_CH' == $locale || 'de_CH_informal' == $locale ) { + if ( in_array( $locale, array( 'de_DE', 'de_DE_formal', 'de_CH', 'de_CH_informal' ), true ) ) { $chars['Ä'] = 'Ae'; $chars['ä'] = 'ae'; $chars['Ö'] = 'Oe'; @@ -2179,7 +2179,7 @@ function sanitize_key( $key ) { function sanitize_title( $title, $fallback_title = '', $context = 'save' ) { $raw_title = $title; - if ( 'save' == $context ) { + if ( 'save' === $context ) { $title = remove_accents( $title ); } @@ -2246,7 +2246,7 @@ function sanitize_title_with_dashes( $title, $raw_title = '', $context = 'displa $title = strtolower( $title ); - if ( 'save' == $context ) { + if ( 'save' === $context ) { // Convert  , &ndash, and &mdash to hyphens. $title = str_replace( array( '%c2%a0', '%e2%80%93', '%e2%80%94' ), '-', $title ); // Convert  , &ndash, and &mdash HTML entities to hyphens. @@ -2354,7 +2354,7 @@ function sanitize_html_class( $class, $fallback = '' ) { // Limit to A-Z, a-z, 0-9, '_', '-'. $sanitized = preg_replace( '/[^A-Za-z0-9_-]/', '', $sanitized ); - if ( '' == $sanitized && $fallback ) { + if ( '' === $sanitized && $fallback ) { return sanitize_html_class( $fallback ); } /** @@ -2836,7 +2836,7 @@ function antispambot( $email_address, $hex_encoding = 0 ) { function _make_url_clickable_cb( $matches ) { $url = $matches[2]; - if ( ')' == $matches[3] && strpos( $url, '(' ) ) { + if ( ')' === $matches[3] && strpos( $url, '(' ) ) { // If the trailing character is a closing parethesis, and the URL has an opening parenthesis in it, // add the closing parenthesis to the URL. Then we can let the parenthesis balancer do its thing below. $url .= $matches[3]; @@ -3370,17 +3370,17 @@ function convert_smilies( $text ) { $content = $textarr[ $i ]; // If we're in an ignore block, wait until we find its closing tag. - if ( '' == $ignore_block_element && preg_match( '/^<(' . $tags_to_ignore . ')[^>]*>/', $content, $matches ) ) { + if ( '' === $ignore_block_element && preg_match( '/^<(' . $tags_to_ignore . ')[^>]*>/', $content, $matches ) ) { $ignore_block_element = $matches[1]; } // If it's not a tag and not in ignore block. - if ( '' == $ignore_block_element && strlen( $content ) > 0 && '<' != $content[0] ) { + if ( '' === $ignore_block_element && strlen( $content ) > 0 && '<' !== $content[0] ) { $content = preg_replace_callback( $wp_smiliessearch, 'translate_smiley', $content ); } // Did we exit ignore block? - if ( '' != $ignore_block_element && '</' . $ignore_block_element . '>' == $content ) { + if ( '' !== $ignore_block_element && '</' . $ignore_block_element . '>' === $content ) { $ignore_block_element = ''; } @@ -3573,7 +3573,7 @@ function iso8601_timezone_to_offset( $timezone ) { if ( 'Z' === $timezone ) { $offset = 0; } else { - $sign = ( substr( $timezone, 0, 1 ) == '+' ) ? 1 : -1; + $sign = ( '+' === substr( $timezone, 0, 1 ) ) ? 1 : -1; $hours = intval( substr( $timezone, 1, 2 ) ); $minutes = intval( substr( $timezone, 3, 4 ) ) / 60; $offset = $sign * HOUR_IN_SECONDS * ( $hours + $minutes ); @@ -3813,7 +3813,8 @@ function human_time_diff( $from, $to = 0 ) { */ function wp_trim_excerpt( $text = '', $post = null ) { $raw_excerpt = $text; - if ( '' == $text ) { + + if ( '' === $text ) { $post = get_post( $post ); $text = get_the_content( '', false, $post ); @@ -4307,7 +4308,7 @@ function esc_sql( $data ) { function esc_url( $url, $protocols = null, $_context = 'display' ) { $original_url = $url; - if ( '' == $url ) { + if ( '' === $url ) { return $url; } @@ -4335,7 +4336,7 @@ function esc_url( $url, $protocols = null, $_context = 'display' ) { } // Replace ampersands and single quotes only when displaying. - if ( 'display' == $_context ) { + if ( 'display' === $_context ) { $url = wp_kses_normalize_entities( $url ); $url = str_replace( '&', '&', $url ); $url = str_replace( "'", ''', $url ); @@ -4645,7 +4646,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 ( '0' == $value || '' == $value ) { + if ( '0' == $value || '' === $value ) { $value = 'closed'; } break; @@ -4977,7 +4978,7 @@ function wp_sprintf( $pattern, ...$args ) { } // Literal %: append and continue. - if ( substr( $pattern, $start, 2 ) == '%%' ) { + if ( '%%' === substr( $pattern, $start, 2 ) ) { $start += 2; $result .= '%'; continue; @@ -5043,7 +5044,7 @@ function wp_sprintf( $pattern, ...$args ) { */ function wp_sprintf_l( $pattern, $args ) { // Not a match. - if ( substr( $pattern, 0, 2 ) != '%l' ) { + if ( '%l' !== substr( $pattern, 0, 2 ) ) { return $pattern; } @@ -5806,12 +5807,12 @@ function wp_staticize_emoji( $text ) { $content = $textarr[ $i ]; // If we're in an ignore block, wait until we find its closing tag. - if ( '' == $ignore_block_element && preg_match( '/^<(' . $tags_to_ignore . ')>/', $content, $matches ) ) { + if ( '' === $ignore_block_element && preg_match( '/^<(' . $tags_to_ignore . ')>/', $content, $matches ) ) { $ignore_block_element = $matches[1]; } // If it's not a tag and not in ignore block. - if ( '' == $ignore_block_element && strlen( $content ) > 0 && '<' != $content[0] && false !== strpos( $content, '&#x' ) ) { + if ( '' === $ignore_block_element && strlen( $content ) > 0 && '<' !== $content[0] && false !== strpos( $content, '&#x' ) ) { foreach ( $possible_emoji as $emojum => $emoji_char ) { if ( false === strpos( $content, $emojum ) ) { continue; @@ -5827,7 +5828,7 @@ function wp_staticize_emoji( $text ) { } // Did we exit ignore block? - if ( '' != $ignore_block_element && '</' . $ignore_block_element . '>' == $content ) { + if ( '' !== $ignore_block_element && '</' . $ignore_block_element . '>' === $content ) { $ignore_block_element = ''; } diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 1d3b2c74bc..4a92e3ed8a 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -640,7 +640,7 @@ function is_serialized( $data, $strict = true ) { return false; } $data = trim( $data ); - if ( 'N;' == $data ) { + if ( 'N;' === $data ) { return true; } if ( strlen( $data ) < 4 ) { @@ -1517,7 +1517,7 @@ function get_num_queries() { * @return bool True if yes, false on anything else. */ function bool_from_yn( $yn ) { - return ( strtolower( $yn ) == 'y' ); + return ( 'y' === strtolower( $yn ) ); } /** @@ -1540,7 +1540,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(); } @@ -1841,6 +1841,7 @@ function wp_referer_field( $echo = true ) { if ( $echo ) { echo $referer_field; } + return $referer_field; } @@ -1860,13 +1861,17 @@ function wp_referer_field( $echo = true ) { */ function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) { $ref = wp_get_original_referer(); + if ( ! $ref ) { - $ref = 'previous' == $jump_back_to ? wp_get_referer() : wp_unslash( $_SERVER['REQUEST_URI'] ); + $ref = ( 'previous' === $jump_back_to ) ? wp_get_referer() : wp_unslash( $_SERVER['REQUEST_URI'] ); } + $orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr( $ref ) . '" />'; + if ( $echo ) { echo $orig_referer_field; } + return $orig_referer_field; } @@ -1972,7 +1977,7 @@ function wp_mkdir_p( $target ) { // We need to find the permissions of the parent folder that exists and inherit that. $target_parent = dirname( $target ); - while ( '.' != $target_parent && ! is_dir( $target_parent ) && dirname( $target_parent ) !== $target_parent ) { + while ( '.' !== $target_parent && ! is_dir( $target_parent ) && dirname( $target_parent ) !== $target_parent ) { $target_parent = dirname( $target_parent ); } @@ -2334,7 +2339,7 @@ function _wp_upload_dir( $time = null ) { $siteurl = get_option( 'siteurl' ); $upload_path = trim( get_option( 'upload_path' ) ); - if ( empty( $upload_path ) || 'wp-content/uploads' == $upload_path ) { + if ( empty( $upload_path ) || 'wp-content/uploads' === $upload_path ) { $dir = WP_CONTENT_DIR . '/uploads'; } elseif ( 0 !== strpos( $upload_path, ABSPATH ) ) { // $dir is absolute, $upload_path is (maybe) relative to ABSPATH. @@ -2345,7 +2350,7 @@ function _wp_upload_dir( $time = null ) { $url = get_option( 'upload_url_path' ); if ( ! $url ) { - if ( empty( $upload_path ) || ( 'wp-content/uploads' == $upload_path ) || ( $upload_path == $dir ) ) { + if ( empty( $upload_path ) || ( 'wp-content/uploads' === $upload_path ) || ( $upload_path == $dir ) ) { $url = WP_CONTENT_URL . '/uploads'; } else { $url = trailingslashit( $siteurl ) . $upload_path; @@ -3211,7 +3216,7 @@ function get_allowed_mime_types( $user = null ) { * @param string $action The nonce action. */ function wp_nonce_ays( $action ) { - if ( 'log-out' == $action ) { + if ( 'log-out' === $action ) { $html = sprintf( /* translators: %s: Site title. */ __( 'You are attempting to log out of %s' ), @@ -3539,7 +3544,7 @@ function _default_wp_die_handler( $message, $title = '', $args = array() ) { } <?php - if ( 'rtl' == $text_direction ) { + if ( 'rtl' === $text_direction ) { echo 'body { font-family: Tahoma, Arial; }'; } ?> @@ -4333,7 +4338,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". } @@ -5214,7 +5219,8 @@ function _doing_it_wrong( $function, $message, $version ) { function is_lighttpd_before_150() { $server_parts = explode( '/', isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : '' ); $server_parts[1] = isset( $server_parts[1] ) ? $server_parts[1] : ''; - return 'lighttpd' == $server_parts[0] && -1 == version_compare( $server_parts[1], '1.5.0' ); + + return ( 'lighttpd' === $server_parts[0] && -1 == version_compare( $server_parts[1], '1.5.0' ) ); } /** @@ -5248,6 +5254,7 @@ function apache_mod_loaded( $mod, $default = false ) { return true; } } + return $default; } @@ -5274,7 +5281,7 @@ function iis7_supports_permalinks() { * Lastly we make sure that PHP is running via FastCGI. This is important because if it runs * via ISAPI then pretty permalinks will not work. */ - $supports_permalinks = class_exists( 'DOMDocument', false ) && isset( $_SERVER['IIS_UrlRewriteModule'] ) && ( PHP_SAPI == 'cgi-fcgi' ); + $supports_permalinks = class_exists( 'DOMDocument', false ) && isset( $_SERVER['IIS_UrlRewriteModule'] ) && ( 'cgi-fcgi' === PHP_SAPI ); } /** @@ -5324,7 +5331,7 @@ function validate_file( $file, $allowed_files = array() ) { } // Absolute Windows drive paths are not allowed: - if ( ':' == substr( $file, 1, 1 ) ) { + if ( ':' === substr( $file, 1, 1 ) ) { return 2; } @@ -5364,7 +5371,7 @@ function force_ssl_admin( $force = null ) { * @return string The guessed URL. */ function wp_guess_url() { - if ( defined( 'WP_SITEURL' ) && '' != WP_SITEURL ) { + if ( defined( 'WP_SITEURL' ) && '' !== WP_SITEURL ) { $url = WP_SITEURL; } else { $abspath_fix = str_replace( '\\', '/', ABSPATH ); @@ -5375,7 +5382,7 @@ function wp_guess_url() { $path = preg_replace( '#/(wp-admin/.*|wp-login.php)#i', '', $_SERVER['REQUEST_URI'] ); // The request is for a file in ABSPATH. - } elseif ( $script_filename_dir . '/' == $abspath_fix ) { + } elseif ( $script_filename_dir . '/' === $abspath_fix ) { // Strip off any file/query params in the path. $path = preg_replace( '#/[^/]*$#i', '', $_SERVER['PHP_SELF'] ); @@ -5935,7 +5942,7 @@ function wp_scheduled_delete() { $del_post = get_post( $post_id ); - if ( ! $del_post || 'trash' != $del_post->post_status ) { + if ( ! $del_post || 'trash' !== $del_post->post_status ) { delete_post_meta( $post_id, '_wp_trash_meta_status' ); delete_post_meta( $post_id, '_wp_trash_meta_time' ); } else { @@ -5953,7 +5960,7 @@ function wp_scheduled_delete() { $del_comment = get_comment( $comment_id ); - if ( ! $del_comment || 'trash' != $del_comment->comment_approved ) { + if ( ! $del_comment || 'trash' !== $del_comment->comment_approved ) { delete_comment_meta( $comment_id, '_wp_trash_meta_time' ); delete_comment_meta( $comment_id, '_wp_trash_meta_status' ); } else { diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php index 437dd4dc1c..82c138cef7 100644 --- a/src/wp-includes/general-template.php +++ b/src/wp-includes/general-template.php @@ -253,7 +253,8 @@ function get_search_form( $args = array() ) { $format = apply_filters( 'search_form_format', $format ); $search_form_template = locate_template( 'searchform.php' ); - if ( '' != $search_form_template ) { + + if ( '' !== $search_form_template ) { ob_start(); require $search_form_template; $form = ob_get_clean(); @@ -268,7 +269,7 @@ function get_search_form( $args = array() ) { */ $aria_label = ''; } - if ( 'html5' == $format ) { + if ( 'html5' === $format ) { $form = '<form role="search" ' . $aria_label . 'method="get" class="search-form" action="' . esc_url( home_url( '/' ) ) . '"> <label> <span class="screen-reader-text">' . _x( 'Search for:', 'label' ) . '</span> @@ -762,7 +763,7 @@ function get_bloginfo( $show = '', $filter = 'raw' ) { break; case 'charset': $output = get_option( 'blog_charset' ); - if ( '' == $output ) { + if ( '' === $output ) { $output = 'UTF-8'; } break; @@ -816,7 +817,7 @@ function get_bloginfo( $show = '', $filter = 'raw' ) { $url = false; } - if ( 'display' == $filter ) { + if ( 'display' === $filter ) { if ( $url ) { /** * Filters the URL returned by get_bloginfo(). @@ -1286,7 +1287,7 @@ function wp_title( $sep = '»', $display = true, $seplocation = '' ) { $title_array = apply_filters( 'wp_title_parts', explode( $t_sep, $title ) ); // Determines position of the separator and direction of the breadcrumb. - if ( 'right' == $seplocation ) { // Separator on right, so reverse the order. + if ( 'right' === $seplocation ) { // Separator on right, so reverse the order. $title_array = array_reverse( $title_array ); $title = implode( " $sep ", $title_array ) . $prefix; } else { @@ -1834,9 +1835,10 @@ function wp_get_archives( $args = '' ) { if ( ! is_post_type_viewable( $post_type_object ) ) { return; } + $parsed_args['post_type'] = $post_type_object->name; - if ( '' == $parsed_args['type'] ) { + if ( '' === $parsed_args['type'] ) { $parsed_args['type'] = 'monthly'; } @@ -1881,7 +1883,7 @@ function wp_get_archives( $args = '' ) { $limit = $parsed_args['limit']; - if ( 'monthly' == $parsed_args['type'] ) { + if ( 'monthly' === $parsed_args['type'] ) { $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date $order $limit"; $key = md5( $query ); $key = "wp_get_archives:$key:$last_changed"; @@ -1906,7 +1908,7 @@ function wp_get_archives( $args = '' ) { $output .= get_archives_link( $url, $text, $parsed_args['format'], $parsed_args['before'], $parsed_args['after'], $selected ); } } - } elseif ( 'yearly' == $parsed_args['type'] ) { + } elseif ( 'yearly' === $parsed_args['type'] ) { $query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date $order $limit"; $key = md5( $query ); $key = "wp_get_archives:$key:$last_changed"; @@ -1930,7 +1932,7 @@ function wp_get_archives( $args = '' ) { $output .= get_archives_link( $url, $text, $parsed_args['format'], $parsed_args['before'], $parsed_args['after'], $selected ); } } - } elseif ( 'daily' == $parsed_args['type'] ) { + } elseif ( 'daily' === $parsed_args['type'] ) { $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date $order $limit"; $key = md5( $query ); $key = "wp_get_archives:$key:$last_changed"; @@ -1955,7 +1957,7 @@ function wp_get_archives( $args = '' ) { $output .= get_archives_link( $url, $text, $parsed_args['format'], $parsed_args['before'], $parsed_args['after'], $selected ); } } - } elseif ( 'weekly' == $parsed_args['type'] ) { + } elseif ( 'weekly' === $parsed_args['type'] ) { $week = _wp_mysql_week( '`post_date`' ); $query = "SELECT DISTINCT $week AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_date`, '%Y-%m-%d' ) AS `yyyymmdd`, count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` $order $limit"; $key = md5( $query ); @@ -1994,8 +1996,8 @@ function wp_get_archives( $args = '' ) { } } } - } elseif ( ( 'postbypost' == $parsed_args['type'] ) || ( 'alpha' == $parsed_args['type'] ) ) { - $orderby = ( 'alpha' == $parsed_args['type'] ) ? 'post_title ASC ' : 'post_date DESC, ID DESC '; + } elseif ( ( 'postbypost' === $parsed_args['type'] ) || ( 'alpha' === $parsed_args['type'] ) ) { + $orderby = ( 'alpha' === $parsed_args['type'] ) ? 'post_title ASC ' : 'post_date DESC, ID DESC '; $query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit"; $key = md5( $query ); $key = "wp_get_archives:$key:$last_changed"; @@ -2402,7 +2404,7 @@ function get_the_date( $format = '', $post = null ) { return false; } - if ( '' == $format ) { + if ( '' === $format ) { $the_date = get_post_time( get_option( 'date_format' ), false, $post, true ); } else { $the_date = get_post_time( $format, false, $post, true ); @@ -2531,7 +2533,7 @@ function get_the_time( $format = '', $post = null ) { return false; } - if ( '' == $format ) { + if ( '' === $format ) { $the_time = get_post_time( get_option( 'time_format' ), false, $post, true ); } else { $the_time = get_post_time( $format, false, $post, true ); @@ -3342,7 +3344,7 @@ function user_can_richedit() { if ( ! isset( $wp_rich_edit ) ) { $wp_rich_edit = false; - if ( get_user_option( 'rich_editing' ) == 'true' || ! is_user_logged_in() ) { // Default to 'true' for logged out users. + if ( 'true' === get_user_option( 'rich_editing' ) || ! is_user_logged_in() ) { // Default to 'true' for logged out users. if ( $is_safari ) { $wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval( $match[1] ) >= 534 ); } elseif ( $is_IE ) { diff --git a/src/wp-includes/http.php b/src/wp-includes/http.php index c2678afae1..fc34c170f4 100644 --- a/src/wp-includes/http.php +++ b/src/wp-includes/http.php @@ -375,7 +375,7 @@ function wp_http_supports( $capabilities = array(), $url = null ) { if ( $url && ! isset( $capabilities['ssl'] ) ) { $scheme = parse_url( $url, PHP_URL_SCHEME ); - if ( 'https' == $scheme || 'ssl' == $scheme ) { + if ( 'https' === $scheme || 'ssl' === $scheme ) { $capabilities['ssl'] = true; } } diff --git a/src/wp-includes/kses.php b/src/wp-includes/kses.php index b445a429a3..ae7cc0f411 100644 --- a/src/wp-includes/kses.php +++ b/src/wp-includes/kses.php @@ -775,12 +775,12 @@ function wp_kses_one_attr( $string, $element ) { // Remove quotes surrounding $value. // Also guarantee correct quoting in $string for this one attribute. - if ( '' == $value ) { + if ( '' === $value ) { $quote = ''; } else { $quote = $value[0]; } - if ( '"' == $quote || "'" == $quote ) { + if ( '"' === $quote || "'" === $quote ) { if ( substr( $value, -1 ) != $quote ) { return ''; } @@ -1039,17 +1039,17 @@ function wp_kses_split2( $string, $allowed_html, $allowed_protocols ) { $string = wp_kses_stripslashes( $string ); // It matched a ">" character. - if ( substr( $string, 0, 1 ) != '<' ) { + if ( '<' !== substr( $string, 0, 1 ) ) { return '>'; } // Allow HTML comments. - if ( '<!--' == substr( $string, 0, 4 ) ) { + if ( '<!--' === substr( $string, 0, 4 ) ) { $string = str_replace( array( '<!--', '-->' ), '', $string ); 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>"; } @@ -1164,7 +1164,7 @@ function wp_kses_attr_check( &$name, &$value, &$whole, $vless, $element, $allowe $allowed_attr = $allowed_html[ $element_low ]; - if ( ! isset( $allowed_attr[ $name_low ] ) || '' == $allowed_attr[ $name_low ] ) { + if ( ! isset( $allowed_attr[ $name_low ] ) || '' === $allowed_attr[ $name_low ] ) { /* * Allow `data-*` attributes. * @@ -1189,7 +1189,7 @@ function wp_kses_attr_check( &$name, &$value, &$whole, $vless, $element, $allowe } } - if ( 'style' == $name_low ) { + if ( 'style' === $name_low ) { $new_value = safecss_filter_attr( $value ); if ( empty( $new_value ) ) { @@ -1609,7 +1609,7 @@ function wp_kses_no_null( $string, $options = null ) { } $string = preg_replace( '/[\x00-\x08\x0B\x0C\x0E-\x1F]/', '', $string ); - if ( 'remove' == $options['slash_zero'] ) { + if ( 'remove' === $options['slash_zero'] ) { $string = preg_replace( '/\\\\+0+/', '', $string ); } @@ -1688,7 +1688,7 @@ function wp_kses_bad_protocol_once( $string, $allowed_protocols, $count = 1 ) { if ( isset( $string2[1] ) && ! preg_match( '%/\?%', $string2[0] ) ) { $string = trim( $string2[1] ); $protocol = wp_kses_bad_protocol_once2( $string2[0], $allowed_protocols ); - if ( 'feed:' == $protocol ) { + if ( 'feed:' === $protocol ) { if ( $count > 2 ) { return ''; } @@ -2244,7 +2244,7 @@ function safecss_filter_attr( $css, $deprecated = '' ) { $css = ''; foreach ( $css_array as $css_item ) { - if ( '' == $css_item ) { + if ( '' === $css_item ) { continue; } @@ -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 .= ';'; } diff --git a/src/wp-includes/link-template.php b/src/wp-includes/link-template.php index 9dbbf4931f..cec437dd02 100644 --- a/src/wp-includes/link-template.php +++ b/src/wp-includes/link-template.php @@ -131,7 +131,7 @@ function get_permalink( $post = 0, $leavename = false ) { $leavename ? '' : '%pagename%', ); - if ( is_object( $post ) && isset( $post->filter ) && 'sample' == $post->filter ) { + if ( is_object( $post ) && isset( $post->filter ) && 'sample' === $post->filter ) { $sample = true; } else { $post = get_post( $post ); @@ -165,7 +165,7 @@ function get_permalink( $post = 0, $leavename = false ) { */ $permalink = apply_filters( 'pre_post_link', $permalink, $post, $leavename ); - if ( '' != $permalink && ! in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft', 'future' ), true ) ) { + if ( $permalink && ! in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft', 'future' ), true ) ) { $category = ''; if ( strpos( $permalink, '%category%' ) !== false ) { @@ -620,7 +620,8 @@ function get_feed_link( $feed = '' ) { global $wp_rewrite; $permalink = $wp_rewrite->get_feed_permastruct(); - if ( '' != $permalink ) { + + if ( '' !== $permalink ) { if ( false !== strpos( $feed, 'comments_' ) ) { $feed = str_replace( 'comments_', '', $feed ); $permalink = $wp_rewrite->get_comment_feed_permastruct(); @@ -681,7 +682,7 @@ function get_post_comments_feed_link( $post_id = 0, $feed = '' ) { $post = get_post( $post_id ); $unattached = 'attachment' === $post->post_type && 0 === (int) $post->post_parent; - if ( '' != get_option( 'permalink_structure' ) ) { + if ( get_option( 'permalink_structure' ) ) { if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $post_id ) { $url = _get_page_link( $post_id ); } else { @@ -794,7 +795,7 @@ function get_author_feed_link( $author_id, $feed = '' ) { $feed = get_default_feed(); } - if ( '' == $permalink_structure ) { + if ( ! $permalink_structure ) { $link = home_url( "?feed=$feed&author=" . $author_id ); } else { $link = get_author_posts_url( $author_id ); @@ -866,10 +867,10 @@ function get_term_feed_link( $term_id, $taxonomy = 'category', $feed = '' ) { $permalink_structure = get_option( 'permalink_structure' ); - if ( '' == $permalink_structure ) { - if ( 'category' == $taxonomy ) { + if ( ! $permalink_structure ) { + if ( 'category' === $taxonomy ) { $link = home_url( "?feed=$feed&cat=$term_id" ); - } elseif ( 'post_tag' == $taxonomy ) { + } elseif ( 'post_tag' === $taxonomy ) { $link = home_url( "?feed=$feed&tag=$term->slug" ); } else { $t = get_taxonomy( $taxonomy ); @@ -886,7 +887,7 @@ function get_term_feed_link( $term_id, $taxonomy = 'category', $feed = '' ) { $link = trailingslashit( $link ) . user_trailingslashit( $feed_link, 'feed' ); } - if ( 'category' == $taxonomy ) { + if ( 'category' === $taxonomy ) { /** * Filters the category feed link. * @@ -896,7 +897,7 @@ function get_term_feed_link( $term_id, $taxonomy = 'category', $feed = '' ) { * @param string $feed Feed type. Possible values include 'rss2', 'atom'. */ $link = apply_filters( 'category_feed_link', $link, $feed ); - } elseif ( 'post_tag' == $taxonomy ) { + } elseif ( 'post_tag' === $taxonomy ) { /** * Filters the post tag feed link. * @@ -1364,7 +1365,7 @@ function get_edit_post_link( $id = 0, $context = 'display' ) { if ( 'revision' === $post->post_type ) { $action = ''; - } elseif ( 'display' == $context ) { + } elseif ( 'display' === $context ) { $action = '&action=edit'; } else { $action = '&action=edit'; @@ -2268,7 +2269,7 @@ function get_pagenum_link( $pagenum = 1, $escape = true ) { $base = trailingslashit( get_bloginfo( 'url' ) ); - if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' != $request ) ) { + if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' !== $request ) ) { $base .= $wp_rewrite->index . '/'; } @@ -2728,7 +2729,7 @@ function get_the_posts_pagination( $args = array() ) { ); // Make sure we get a string back. Plain is the next best thing. - if ( isset( $args['type'] ) && 'array' == $args['type'] ) { + if ( isset( $args['type'] ) && 'array' === $args['type'] ) { $args['type'] = 'plain'; } @@ -2823,7 +2824,7 @@ function get_comments_pagenum_link( $pagenum = 1, $max_page = 0 ) { $result = get_permalink(); - if ( 'newest' == get_option( 'default_comments_page' ) ) { + if ( 'newest' === get_option( 'default_comments_page' ) ) { if ( $pagenum != $max_page ) { if ( $wp_rewrite->using_permalinks() ) { $result = user_trailingslashit( trailingslashit( $result ) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged' ); @@ -3110,7 +3111,7 @@ function get_the_comments_pagination( $args = array() ) { $args['echo'] = false; // Make sure we get a string back. Plain is the next best thing. - if ( isset( $args['type'] ) && 'array' == $args['type'] ) { + if ( isset( $args['type'] ) && 'array' === $args['type'] ) { $args['type'] = 'plain'; } @@ -3405,7 +3406,7 @@ function plugins_url( $path = '', $plugin = '' ) { if ( ! empty( $plugin ) && is_string( $plugin ) ) { $folder = dirname( plugin_basename( $plugin ) ); - if ( '.' != $folder ) { + if ( '.' !== $folder ) { $url .= '/' . ltrim( $folder, '/' ); } } @@ -3451,7 +3452,7 @@ function network_site_url( $path = '', $scheme = null ) { $current_network = get_network(); - if ( 'relative' == $scheme ) { + if ( 'relative' === $scheme ) { $url = $current_network->path; } else { $url = set_url_scheme( 'http://' . $current_network->domain . $current_network->path, $scheme ); @@ -3501,7 +3502,7 @@ function network_home_url( $path = '', $scheme = null ) { $scheme = is_ssl() && ! is_admin() ? 'https' : 'http'; } - if ( 'relative' == $scheme ) { + if ( 'relative' === $scheme ) { $url = $current_network->path; } else { $url = set_url_scheme( 'http://' . $current_network->domain . $current_network->path, $scheme ); @@ -3645,7 +3646,7 @@ function set_url_scheme( $url, $scheme = null ) { $url = 'http:' . $url; } - if ( 'relative' == $scheme ) { + if ( 'relative' === $scheme ) { $url = ltrim( preg_replace( '#^\w+://[^/]*#', '', $url ) ); if ( '' !== $url && '/' === $url[0] ) { $url = '/' . ltrim( $url, "/ \t\n\r\0\x0B" ); @@ -3784,7 +3785,7 @@ function wp_get_canonical_url( $post = null ) { if ( get_queried_object_id() === $post->ID ) { $page = get_query_var( 'page', 0 ); if ( $page >= 2 ) { - if ( '' == get_option( 'permalink_structure' ) ) { + if ( ! get_option( 'permalink_structure' ) ) { $canonical_url = add_query_arg( 'page', $page, $canonical_url ); } else { $canonical_url = trailingslashit( $canonical_url ) . user_trailingslashit( $page, 'single_paged' ); @@ -3873,10 +3874,10 @@ function wp_get_shortlink( $id = 0, $context = 'post', $allow_slugs = true ) { } $post_id = 0; - if ( 'query' == $context && is_singular() ) { + if ( 'query' === $context && is_singular() ) { $post_id = get_queried_object_id(); $post = get_post( $post_id ); - } elseif ( 'post' == $context ) { + } elseif ( 'post' === $context ) { $post = get_post( $id ); if ( ! empty( $post->ID ) ) { $post_id = $post->ID; diff --git a/src/wp-includes/load.php b/src/wp-includes/load.php index 72d92e58e7..51fe392a20 100644 --- a/src/wp-includes/load.php +++ b/src/wp-includes/load.php @@ -40,7 +40,7 @@ function wp_fix_server_vars() { $_SERVER = array_merge( $default_server_values, $_SERVER ); // Fix for IIS when running with PHP ISAPI. - if ( empty( $_SERVER['REQUEST_URI'] ) || ( PHP_SAPI != 'cgi-fcgi' && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) { + if ( empty( $_SERVER['REQUEST_URI'] ) || ( 'cgi-fcgi' !== PHP_SAPI && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) { if ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) ) { // IIS Mod-Rewrite. @@ -137,7 +137,7 @@ function wp_check_php_mysql_versions() { * @deprecated 5.4.0 Deprecated in favor of do_favicon(). */ function wp_favicon_request() { - if ( '/favicon.ico' == $_SERVER['REQUEST_URI'] ) { + if ( '/favicon.ico' === $_SERVER['REQUEST_URI'] ) { header( 'Content-Type: image/vnd.microsoft.icon' ); exit; } @@ -628,7 +628,7 @@ function wp_get_mu_plugins() { return $mu_plugins; } while ( ( $plugin = readdir( $dh ) ) !== false ) { - if ( substr( $plugin, -4 ) == '.php' ) { + if ( '.php' === substr( $plugin, -4 ) ) { $mu_plugins[] = WPMU_PLUGIN_DIR . '/' . $plugin; } } @@ -670,7 +670,7 @@ function wp_get_active_and_valid_plugins() { foreach ( $active_plugins as $plugin ) { if ( ! validate_file( $plugin ) // $plugin must validate as file. - && '.php' == substr( $plugin, -4 ) // $plugin must end with '.php'. + && '.php' === substr( $plugin, -4 ) // $plugin must end with '.php'. && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist. // Not already included as a network plugin. && ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins, true ) ) @@ -1168,7 +1168,7 @@ function wp_load_translations_early() { while ( true ) { if ( defined( 'WPLANG' ) ) { - if ( '' == WPLANG ) { + if ( '' === WPLANG ) { break; } $locales[] = WPLANG; @@ -1263,7 +1263,7 @@ function wp_installing( $is_installing = null ) { */ function is_ssl() { if ( isset( $_SERVER['HTTPS'] ) ) { - if ( 'on' == strtolower( $_SERVER['HTTPS'] ) ) { + if ( 'on' === strtolower( $_SERVER['HTTPS'] ) ) { return true; } diff --git a/src/wp-includes/media-template.php b/src/wp-includes/media-template.php index 1fdbf390d9..7742f73883 100644 --- a/src/wp-includes/media-template.php +++ b/src/wp-includes/media-template.php @@ -832,15 +832,15 @@ function wp_print_media_templates() { data-user-setting="urlbutton" <# } #>> - <option value="post" <# if ( ! wp.media.galleryDefaults.link || 'post' == wp.media.galleryDefaults.link ) { + <option value="post" <# if ( ! wp.media.galleryDefaults.link || 'post' === wp.media.galleryDefaults.link ) { #>selected="selected"<# } #>> <?php esc_html_e( 'Attachment Page' ); ?> </option> - <option value="file" <# if ( 'file' == wp.media.galleryDefaults.link ) { #>selected="selected"<# } #>> + <option value="file" <# if ( 'file' === wp.media.galleryDefaults.link ) { #>selected="selected"<# } #>> <?php esc_html_e( 'Media File' ); ?> </option> - <option value="none" <# if ( 'none' == wp.media.galleryDefaults.link ) { #>selected="selected"<# } #>> + <option value="none" <# if ( 'none' === wp.media.galleryDefaults.link ) { #>selected="selected"<# } #>> <?php esc_html_e( 'None' ); ?> </option> </select> diff --git a/src/wp-includes/meta.php b/src/wp-includes/meta.php index 7eee83a759..de00456c78 100644 --- a/src/wp-includes/meta.php +++ b/src/wp-includes/meta.php @@ -173,7 +173,7 @@ function update_metadata( $meta_type, $object_id, $meta_key, $meta_value, $prev_ $meta_subtype = get_object_subtype( $meta_type, $object_id ); $column = sanitize_key( $meta_type . '_id' ); - $id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id'; + $id_column = ( 'user' === $meta_type ) ? 'umeta_id' : 'meta_id'; // expected_slashed ($meta_key) $raw_meta_key = $meta_key; @@ -248,7 +248,7 @@ function update_metadata( $meta_type, $object_id, $meta_key, $meta_value, $prev_ */ do_action( "update_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value ); - if ( 'post' == $meta_type ) { + if ( 'post' === $meta_type ) { /** * Fires immediately before updating a post's metadata. * @@ -287,7 +287,7 @@ function update_metadata( $meta_type, $object_id, $meta_key, $meta_value, $prev_ */ do_action( "updated_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value ); - if ( 'post' == $meta_type ) { + if ( 'post' === $meta_type ) { /** * Fires immediately after updating a post's metadata. * @@ -346,7 +346,8 @@ function delete_metadata( $meta_type, $object_id, $meta_key, $meta_value = '', $ } $type_column = sanitize_key( $meta_type . '_id' ); - $id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id'; + $id_column = ( 'user' === $meta_type ) ? 'umeta_id' : 'meta_id'; + // expected_slashed ($meta_key) $meta_key = wp_unslash( $meta_key ); $meta_value = wp_unslash( $meta_value ); @@ -415,7 +416,7 @@ function delete_metadata( $meta_type, $object_id, $meta_key, $meta_value = '', $ do_action( "delete_{$meta_type}_meta", $meta_ids, $object_id, $meta_key, $_meta_value ); // Old-style action. - if ( 'post' == $meta_type ) { + if ( 'post' === $meta_type ) { /** * Fires immediately before deleting metadata for a post. * @@ -458,7 +459,7 @@ function delete_metadata( $meta_type, $object_id, $meta_key, $meta_value = '', $ do_action( "deleted_{$meta_type}_meta", $meta_ids, $object_id, $meta_key, $_meta_value ); // Old-style action. - if ( 'post' == $meta_type ) { + if ( 'post' === $meta_type ) { /** * Fires immediately after deleting metadata for a post. * @@ -620,7 +621,7 @@ function get_metadata_by_mid( $meta_type, $meta_id ) { return false; } - $id_column = ( 'user' == $meta_type ) ? 'umeta_id' : 'meta_id'; + $id_column = ( 'user' === $meta_type ) ? 'umeta_id' : 'meta_id'; /** * Filters whether to retrieve metadata of a specific type by meta ID. @@ -685,7 +686,7 @@ function update_metadata_by_mid( $meta_type, $meta_id, $meta_value, $meta_key = } $column = sanitize_key( $meta_type . '_id' ); - $id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id'; + $id_column = ( 'user' === $meta_type ) ? 'umeta_id' : 'meta_id'; /** * Filters whether to update metadata of a specific type by meta ID. @@ -740,7 +741,7 @@ function update_metadata_by_mid( $meta_type, $meta_id, $meta_value, $meta_key = /** This action is documented in wp-includes/meta.php */ do_action( "update_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value ); - if ( 'post' == $meta_type ) { + if ( 'post' === $meta_type ) { /** This action is documented in wp-includes/meta.php */ do_action( 'update_postmeta', $meta_id, $object_id, $meta_key, $meta_value ); } @@ -757,7 +758,7 @@ function update_metadata_by_mid( $meta_type, $meta_id, $meta_value, $meta_key = /** This action is documented in wp-includes/meta.php */ do_action( "updated_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value ); - if ( 'post' == $meta_type ) { + if ( 'post' === $meta_type ) { /** This action is documented in wp-includes/meta.php */ do_action( 'updated_postmeta', $meta_id, $object_id, $meta_key, $meta_value ); } @@ -801,7 +802,7 @@ function delete_metadata_by_mid( $meta_type, $meta_id ) { // Object and ID columns. $column = sanitize_key( $meta_type . '_id' ); - $id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id'; + $id_column = ( 'user' === $meta_type ) ? 'umeta_id' : 'meta_id'; /** * Filters whether to delete metadata of a specific type by meta ID. @@ -829,7 +830,7 @@ function delete_metadata_by_mid( $meta_type, $meta_id ) { do_action( "delete_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value ); // Old-style action. - if ( 'post' == $meta_type || 'comment' == $meta_type ) { + if ( 'post' === $meta_type || 'comment' === $meta_type ) { /** * Fires immediately before deleting post or comment metadata of a specific type. * @@ -853,7 +854,7 @@ function delete_metadata_by_mid( $meta_type, $meta_id ) { do_action( "deleted_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value ); // Old-style action. - if ( 'post' == $meta_type || 'comment' == $meta_type ) { + if ( 'post' === $meta_type || 'comment' === $meta_type ) { /** * Fires immediately after deleting post or comment metadata of a specific type. * @@ -943,7 +944,8 @@ function update_meta_cache( $meta_type, $object_ids ) { // Get meta info. $id_list = join( ',', $ids ); - $id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id'; + $id_column = ( 'user' === $meta_type ) ? 'umeta_id' : 'meta_id'; + $meta_list = $wpdb->get_results( "SELECT $column, meta_key, meta_value FROM $table WHERE $column IN ($id_list) ORDER BY $id_column ASC", ARRAY_A ); if ( ! empty( $meta_list ) ) { @@ -1045,7 +1047,7 @@ function _get_meta_table( $type ) { * @return bool Whether the meta key is considered protected. */ function is_protected_meta( $meta_key, $meta_type = '' ) { - $protected = ( '_' == $meta_key[0] ); + $protected = ( '_' === $meta_key[0] ); /** * Filters whether a meta key is considered protected. diff --git a/src/wp-includes/ms-blogs.php b/src/wp-includes/ms-blogs.php index e59dde5078..4adb674b8c 100644 --- a/src/wp-includes/ms-blogs.php +++ b/src/wp-includes/ms-blogs.php @@ -137,7 +137,7 @@ function get_blog_details( $fields = null, $get_all = true ) { if ( false !== $blog ) { return $blog; } - if ( substr( $fields['domain'], 0, 4 ) == 'www.' ) { + if ( 'www.' === substr( $fields['domain'], 0, 4 ) ) { $nowww = substr( $fields['domain'], 4 ); $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path'] ) ); } else { @@ -155,7 +155,7 @@ function get_blog_details( $fields = null, $get_all = true ) { if ( false !== $blog ) { return $blog; } - if ( substr( $fields['domain'], 0, 4 ) == 'www.' ) { + if ( 'www.' === substr( $fields['domain'], 0, 4 ) ) { $nowww = substr( $fields['domain'], 4 ); $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'] ) ); } else { @@ -784,7 +784,7 @@ function _update_blog_date_on_post_publish( $new_status, $old_status, $post ) { return; } - if ( 'publish' != $new_status && 'publish' != $old_status ) { + if ( 'publish' !== $new_status && 'publish' !== $old_status ) { return; } @@ -809,7 +809,7 @@ function _update_blog_date_on_post_delete( $post_id ) { return; } - if ( 'publish' != $post->post_status ) { + if ( 'publish' !== $post->post_status ) { return; } diff --git a/src/wp-includes/ms-default-constants.php b/src/wp-includes/ms-default-constants.php index 519d908b42..3164cf6e89 100644 --- a/src/wp-includes/ms-default-constants.php +++ b/src/wp-includes/ms-default-constants.php @@ -36,7 +36,7 @@ function ms_upload_constants() { define( 'UPLOADS', UPLOADBLOGSDIR . '/' . $site_id . '/files/' ); // Uploads dir relative to ABSPATH. - if ( 'wp-content/blogs.dir' == UPLOADBLOGSDIR && ! defined( 'BLOGUPLOADDIR' ) ) { + if ( 'wp-content/blogs.dir' === UPLOADBLOGSDIR && ! defined( 'BLOGUPLOADDIR' ) ) { define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . '/blogs.dir/' . $site_id . '/files/' ); } } @@ -155,7 +155,7 @@ function ms_subdomain_constants() { if ( defined( 'SUBDOMAIN_INSTALL' ) && defined( 'VHOST' ) ) { $subdomain_error = true; - if ( SUBDOMAIN_INSTALL !== ( 'yes' == VHOST ) ) { + if ( SUBDOMAIN_INSTALL !== ( 'yes' === VHOST ) ) { $subdomain_error_warn = true; } } elseif ( defined( 'SUBDOMAIN_INSTALL' ) ) { @@ -163,7 +163,7 @@ function ms_subdomain_constants() { define( 'VHOST', SUBDOMAIN_INSTALL ? 'yes' : 'no' ); } elseif ( defined( 'VHOST' ) ) { $subdomain_error = true; - define( 'SUBDOMAIN_INSTALL', 'yes' == VHOST ); + define( 'SUBDOMAIN_INSTALL', 'yes' === VHOST ); } else { $subdomain_error = false; define( 'SUBDOMAIN_INSTALL', false ); diff --git a/src/wp-includes/ms-deprecated.php b/src/wp-includes/ms-deprecated.php index cd30478811..3dff066c6b 100644 --- a/src/wp-includes/ms-deprecated.php +++ b/src/wp-includes/ms-deprecated.php @@ -199,7 +199,7 @@ function get_blog_list( $start = 0, $num = 10, $deprecated = '' ) { return array(); } - if ( $num == 'all' ) { + if ( 'all' === $num ) { return array_slice( $blog_list, $start, count( $blog_list ) ); } else { return array_slice( $blog_list, $start, $num ); @@ -293,7 +293,7 @@ function wpmu_admin_do_redirect( $url = '' ) { if ( isset( $_GET['redirect'] ) && isset( $_POST['redirect'] ) && $_GET['redirect'] !== $_POST['redirect'] ) { wp_die( __( 'A variable mismatch has been detected.' ), __( 'Sorry, you are not allowed to view this item.' ), 400 ); } elseif ( isset( $_GET['redirect'] ) ) { - if ( substr( $_GET['redirect'], 0, 2 ) == 's_' ) + if ( 's_' === substr( $_GET['redirect'], 0, 2 ) ) $url .= '&action=blogs&s='. esc_html( substr( $_GET['redirect'], 2 ) ); } elseif ( isset( $_POST['redirect'] ) ) { $url = wpmu_admin_redirect_add_updated_param( $_POST['redirect'] ); @@ -372,7 +372,7 @@ function get_blogaddress_by_domain( $domain, $path ) { $blogname = substr( $domain, 0, strpos( $domain, '.' ) ); $url = 'http://' . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path; // We're not installing the main blog. - if ( $blogname != 'www.' ) + if ( 'www.' !== $blogname ) $url .= $blogname . '/'; } else { // Main blog. $url = 'http://' . $domain . $path; @@ -718,7 +718,7 @@ function update_user_status( $id, $pref, $value, $deprecated = null ) { $user = new WP_User( $id ); clean_user_cache( $user ); - if ( $pref == 'spam' ) { + if ( 'spam' === $pref ) { if ( $value == 1 ) { /** This filter is documented in wp-includes/user.php */ do_action( 'make_spam_user', $id ); diff --git a/src/wp-includes/ms-functions.php b/src/wp-includes/ms-functions.php index dae8d4f742..bcdf5bcefc 100644 --- a/src/wp-includes/ms-functions.php +++ b/src/wp-includes/ms-functions.php @@ -944,11 +944,14 @@ function wpmu_signup_blog_notification( $domain, $path, $title, $user_login, $us } $activate_url = esc_url( $activate_url ); - $admin_email = get_site_option( 'admin_email' ); - if ( '' == $admin_email ) { + + $admin_email = get_site_option( 'admin_email' ); + + if ( '' === $admin_email ) { $admin_email = 'support@' . $_SERVER['SERVER_NAME']; } - $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) ); + + $from_name = ( '' !== get_site_option( 'site_name' ) ) ? esc_html( get_site_option( 'site_name' ) ) : 'WordPress'; $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . 'Content-Type: text/plain; charset="' . get_option( 'blog_charset' ) . "\"\n"; $user = get_user_by( 'login', $user_login ); @@ -1070,10 +1073,12 @@ function wpmu_signup_user_notification( $user_login, $user_email, $key, $meta = // Send email with activation link. $admin_email = get_site_option( 'admin_email' ); - if ( '' == $admin_email ) { + + if ( '' === $admin_email ) { $admin_email = 'support@' . $_SERVER['SERVER_NAME']; } - $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) ); + + $from_name = ( '' !== get_site_option( 'site_name' ) ) ? esc_html( get_site_option( 'site_name' ) ) : 'WordPress'; $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . 'Content-Type: text/plain; charset="' . get_option( 'blog_charset' ) . "\"\n"; $message = sprintf( /** @@ -1224,7 +1229,7 @@ function wpmu_activate_signup( $key ) { * failed in between creating the blog and setting the activation flag. * Let's just set the active flag and instruct the user to reset their password. */ - if ( 'blog_taken' == $blog_id->get_error_code() ) { + if ( 'blog_taken' === $blog_id->get_error_code() ) { $blog_id->add_data( $signup ); $wpdb->update( $wpdb->signups, @@ -1398,11 +1403,12 @@ function newblog_notify_siteadmin( $blog_id, $deprecated = '' ) { $blog_id = $blog_id->blog_id; } - if ( get_site_option( 'registrationnotification' ) != 'yes' ) { + if ( 'yes' !== get_site_option( 'registrationnotification' ) ) { return false; } $email = get_site_option( 'admin_email' ); + if ( is_email( $email ) == false ) { return false; } @@ -1458,7 +1464,7 @@ Disable these notifications: %4$s' * @return bool */ function newuser_notify_siteadmin( $user_id ) { - if ( get_site_option( 'registrationnotification' ) != 'yes' ) { + if ( 'yes' !== get_site_option( 'registrationnotification' ) ) { return false; } @@ -1632,13 +1638,14 @@ We hope you enjoy your new site. Thanks! * @param array $meta Signup meta data. By default, contains the requested privacy setting and lang_id. */ $welcome_email = apply_filters( 'update_welcome_email', $welcome_email, $blog_id, $user_id, $password, $title, $meta ); - $admin_email = get_site_option( 'admin_email' ); - if ( '' == $admin_email ) { + $admin_email = get_site_option( 'admin_email' ); + + if ( '' === $admin_email ) { $admin_email = 'support@' . $_SERVER['SERVER_NAME']; } - $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) ); + $from_name = ( '' !== get_site_option( 'site_name' ) ) ? esc_html( get_site_option( 'site_name' ) ) : 'WordPress'; $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . 'Content-Type: text/plain; charset="' . get_option( 'blog_charset' ) . "\"\n"; $message = $welcome_email; @@ -1726,11 +1733,11 @@ function wpmu_welcome_user_notification( $user_id, $password, $meta = array() ) $admin_email = get_site_option( 'admin_email' ); - if ( '' == $admin_email ) { + if ( '' === $admin_email ) { $admin_email = 'support@' . $_SERVER['SERVER_NAME']; } - $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) ); + $from_name = ( '' !== get_site_option( 'site_name' ) ) ? esc_html( get_site_option( 'site_name' ) ) : 'WordPress'; $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . 'Content-Type: text/plain; charset="' . get_option( 'blog_charset' ) . "\"\n"; $message = $welcome_email; @@ -1849,7 +1856,7 @@ function check_upload_mimes( $mimes ) { $site_mimes = array(); foreach ( $site_exts as $ext ) { foreach ( $mimes as $ext_pattern => $mime ) { - if ( '' != $ext && false !== strpos( $ext_pattern, $ext ) ) { + if ( '' !== $ext && false !== strpos( $ext_pattern, $ext ) ) { $site_mimes[ $ext_pattern ] = $mime; } } @@ -2119,7 +2126,7 @@ function maybe_add_existing_user_to_blog() { $parts = explode( '/', $_SERVER['REQUEST_URI'] ); $key = array_pop( $parts ); - if ( '' == $key ) { + if ( '' === $key ) { $key = array_pop( $parts ); } @@ -2309,7 +2316,7 @@ Thanks! function force_ssl_content( $force = '' ) { static $forced_content = false; - if ( '' != $force ) { + if ( ! $force ) { $old_forced = $forced_content; $forced_content = $force; return $old_forced; @@ -2594,7 +2601,7 @@ function wp_is_large_network( $using = 'sites', $network_id = null ) { $network_id = get_current_network_id(); } - if ( 'users' == $using ) { + if ( 'users' === $using ) { $count = get_user_count( $network_id ); /** * Filters whether the network is considered large. @@ -2611,6 +2618,7 @@ function wp_is_large_network( $using = 'sites', $network_id = null ) { } $count = get_blog_count( $network_id ); + /** This filter is documented in wp-includes/ms-functions.php */ return apply_filters( 'wp_is_large_network', $count > 10000, 'sites', $count, $network_id ); } diff --git a/src/wp-includes/ms-load.php b/src/wp-includes/ms-load.php index 0e369101ae..29bb41114a 100644 --- a/src/wp-includes/ms-load.php +++ b/src/wp-includes/ms-load.php @@ -20,7 +20,7 @@ function is_subdomain_install() { return SUBDOMAIN_INSTALL; } - return ( defined( 'VHOST' ) && VHOST == 'yes' ); + return ( defined( 'VHOST' ) && 'yes' === VHOST ); } /** @@ -46,7 +46,7 @@ function wp_get_active_network_plugins() { foreach ( $active_plugins as $plugin ) { if ( ! validate_file( $plugin ) // $plugin must validate as file. - && '.php' == substr( $plugin, -4 ) // $plugin must end with '.php'. + && '.php' === substr( $plugin, -4 ) // $plugin must end with '.php'. && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist. ) { $plugins[] = WP_PLUGIN_DIR . '/' . $plugin; @@ -499,7 +499,7 @@ function ms_not_installed( $domain, $path ) { ); $msg .= ' ' . __( 'If you’re still stuck with this message, then check that your database contains the following tables:' ) . '</p><ul>'; foreach ( $wpdb->tables( 'global' ) as $t => $table ) { - if ( 'sitecategories' == $t ) { + if ( 'sitecategories' === $t ) { continue; } $msg .= '<li>' . $table . '</li>'; diff --git a/src/wp-includes/ms-settings.php b/src/wp-includes/ms-settings.php index 1aff91ac66..6824895880 100644 --- a/src/wp-includes/ms-settings.php +++ b/src/wp-includes/ms-settings.php @@ -55,10 +55,10 @@ ms_subdomain_constants(); if ( ! isset( $current_site ) || ! isset( $current_blog ) ) { $domain = strtolower( stripslashes( $_SERVER['HTTP_HOST'] ) ); - if ( substr( $domain, -3 ) == ':80' ) { + if ( ':80' === substr( $domain, -3 ) ) { $domain = substr( $domain, 0, -3 ); $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -3 ); - } elseif ( substr( $domain, -4 ) == ':443' ) { + } elseif ( ':443' === substr( $domain, -4 ) ) { $domain = substr( $domain, 0, -4 ); $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -4 ); } diff --git a/src/wp-includes/nav-menu-template.php b/src/wp-includes/nav-menu-template.php index d49dbeed02..2f82bb9820 100644 --- a/src/wp-includes/nav-menu-template.php +++ b/src/wp-includes/nav-menu-template.php @@ -392,7 +392,7 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { } // If the menu item corresponds to a taxonomy term for the currently queried non-hierarchical post object. - if ( $wp_query->is_singular && 'taxonomy' == $menu_item->type + if ( $wp_query->is_singular && 'taxonomy' === $menu_item->type && in_array( (int) $menu_item->object_id, $possible_object_parents, true ) ) { $active_parent_object_ids[] = (int) $menu_item->object_id; @@ -403,9 +403,10 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { } elseif ( $menu_item->object_id == $queried_object_id && ( - ( ! empty( $home_page_id ) && 'post_type' == $menu_item->type && $wp_query->is_home && $home_page_id == $menu_item->object_id ) - || ( 'post_type' == $menu_item->type && $wp_query->is_singular ) - || ( 'taxonomy' == $menu_item->type + ( ! empty( $home_page_id ) && 'post_type' === $menu_item->type + && $wp_query->is_home && $home_page_id == $menu_item->object_id ) + || ( 'post_type' === $menu_item->type && $wp_query->is_singular ) + || ( 'taxonomy' === $menu_item->type && ( $wp_query->is_category || $wp_query->is_tag || $wp_query->is_tax ) && $queried_object->taxonomy == $menu_item->object ) ) @@ -421,7 +422,7 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { $active_ancestor_item_ids[] = $_anc_id; } - if ( 'post_type' == $menu_item->type && 'page' == $menu_item->object ) { + if ( 'post_type' === $menu_item->type && 'page' === $menu_item->object ) { // Back compat classes for pages to match wp_page_menu(). $classes[] = 'page_item'; $classes[] = 'page-item-' . $menu_item->object_id; @@ -434,7 +435,7 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { // If the menu item corresponds to the currently queried post type archive. } elseif ( - 'post_type_archive' == $menu_item->type + 'post_type_archive' === $menu_item->type && is_post_type_archive( array( $menu_item->object ) ) ) { $classes[] = 'current-menu-item'; @@ -451,7 +452,7 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { $active_parent_item_ids[] = (int) $menu_item->menu_item_parent; // If the menu item corresponds to the currently requested URL. - } elseif ( 'custom' == $menu_item->object && isset( $_SERVER['HTTP_HOST'] ) ) { + } elseif ( 'custom' === $menu_item->object && isset( $_SERVER['HTTP_HOST'] ) ) { $_root_relative_current = untrailingslashit( $_SERVER['REQUEST_URI'] ); // If it's the customize page then it will strip the query var off the URL before entering the comparison block. @@ -504,7 +505,9 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { } // Back-compat with wp_page_menu(): add "current_page_parent" to static home page link for any non-page query. - if ( ! empty( $home_page_id ) && 'post_type' == $menu_item->type && empty( $wp_query->is_page ) && $home_page_id == $menu_item->object_id ) { + if ( ! empty( $home_page_id ) && 'post_type' === $menu_item->type + && empty( $wp_query->is_page ) && $home_page_id == $menu_item->object_id + ) { $classes[] = 'current_page_parent'; } @@ -525,7 +528,7 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { && ( // Ancestral post object. ( - 'post_type' == $parent_item->type + 'post_type' === $parent_item->type && ! empty( $queried_object->post_type ) && is_post_type_hierarchical( $queried_object->post_type ) && in_array( (int) $parent_item->object_id, $queried_object->ancestors, true ) @@ -534,7 +537,7 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { // Ancestral term. ( - 'taxonomy' == $parent_item->type + 'taxonomy' === $parent_item->type && isset( $possible_taxonomy_ancestors[ $parent_item->object ] ) && in_array( (int) $parent_item->object_id, $possible_taxonomy_ancestors[ $parent_item->object ], true ) && ( @@ -565,7 +568,7 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { $classes[] = 'current-' . $active_object . '-parent'; } - if ( 'post_type' == $parent_item->type && 'page' == $parent_item->object ) { + if ( 'post_type' === $parent_item->type && 'page' === $parent_item->object ) { // Back compat classes for pages to match wp_page_menu(). if ( in_array( 'current-menu-parent', $classes, true ) ) { $classes[] = 'current_page_parent'; diff --git a/src/wp-includes/nav-menu.php b/src/wp-includes/nav-menu.php index 12d5c31ba2..e786d786db 100644 --- a/src/wp-includes/nav-menu.php +++ b/src/wp-includes/nav-menu.php @@ -70,7 +70,7 @@ function is_nav_menu( $menu ) { $menu_obj && ! is_wp_error( $menu_obj ) && ! empty( $menu_obj->taxonomy ) && - 'nav_menu' == $menu_obj->taxonomy + 'nav_menu' === $menu_obj->taxonomy ) { return true; } @@ -235,7 +235,7 @@ function wp_get_nav_menu_name( $location ) { * @return bool Whether the given ID is that of a nav menu item. */ function is_nav_menu_item( $menu_item_id = 0 ) { - return ( ! is_wp_error( $menu_item_id ) && ( 'nav_menu_item' == get_post_type( $menu_item_id ) ) ); + return ( ! is_wp_error( $menu_item_id ) && ( 'nav_menu_item' === get_post_type( $menu_item_id ) ) ); } /** @@ -476,15 +476,15 @@ function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item $args['menu-item-url'] = ''; $original_title = ''; - if ( 'taxonomy' == $args['menu-item-type'] ) { + if ( 'taxonomy' === $args['menu-item-type'] ) { $original_parent = get_term_field( 'parent', $args['menu-item-object-id'], $args['menu-item-object'], 'raw' ); $original_title = get_term_field( 'name', $args['menu-item-object-id'], $args['menu-item-object'], 'raw' ); - } elseif ( 'post_type' == $args['menu-item-type'] ) { + } elseif ( 'post_type' === $args['menu-item-type'] ) { $original_object = get_post( $args['menu-item-object-id'] ); $original_parent = (int) $original_object->post_parent; $original_title = $original_object->post_title; - } elseif ( 'post_type_archive' == $args['menu-item-type'] ) { + } elseif ( 'post_type_archive' === $args['menu-item-type'] ) { $original_object = get_post_type_object( $args['menu-item-object'] ); if ( $original_object ) { $original_title = $original_object->labels->archives; @@ -496,7 +496,7 @@ function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item } // Hack to get wp to create a post object when too many properties are empty. - if ( '' == $args['menu-item-title'] && '' == $args['menu-item-description'] ) { + if ( '' === $args['menu-item-title'] && '' === $args['menu-item-description'] ) { $args['menu-item-description'] = ' '; } } @@ -517,7 +517,7 @@ function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item // New menu item. Default is draft status. if ( ! $update ) { $post['ID'] = 0; - $post['post_status'] = 'publish' == $args['menu-item-status'] ? 'publish' : 'draft'; + $post['post_status'] = 'publish' === $args['menu-item-status'] ? 'publish' : 'draft'; $menu_item_db_id = wp_insert_post( $post ); if ( ! $menu_item_db_id || is_wp_error( $menu_item_db_id ) ) { return $menu_item_db_id; @@ -543,7 +543,7 @@ function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item wp_set_object_terms( $menu_item_db_id, array( $menu->term_id ), 'nav_menu' ); } - if ( 'custom' == $args['menu-item-type'] ) { + if ( 'custom' === $args['menu-item-type'] ) { $args['menu-item-object-id'] = $menu_item_db_id; $args['menu-item-object'] = 'custom'; } @@ -571,7 +571,7 @@ function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item // Update existing menu item. Default is publish status. if ( $update ) { $post['ID'] = $menu_item_db_id; - $post['post_status'] = 'draft' == $args['menu-item-status'] ? 'draft' : 'publish'; + $post['post_status'] = ( 'draft' === $args['menu-item-status'] ) ? 'draft' : 'publish'; wp_update_post( $post ); } @@ -711,9 +711,9 @@ function wp_get_nav_menu_items( $menu, $args = array() ) { $object = get_post_meta( $item->ID, '_menu_item_object', true ); $type = get_post_meta( $item->ID, '_menu_item_type', true ); - if ( 'post_type' == $type ) { + if ( 'post_type' === $type ) { $posts[ $object ][] = $object_id; - } elseif ( 'taxonomy' == $type ) { + } elseif ( 'taxonomy' === $type ) { $terms[ $object ][] = $object_id; } } @@ -806,14 +806,14 @@ function wp_get_nav_menu_items( $menu, $args = array() ) { */ function wp_setup_nav_menu_item( $menu_item ) { if ( isset( $menu_item->post_type ) ) { - if ( 'nav_menu_item' == $menu_item->post_type ) { + if ( 'nav_menu_item' === $menu_item->post_type ) { $menu_item->db_id = (int) $menu_item->ID; $menu_item->menu_item_parent = ! isset( $menu_item->menu_item_parent ) ? get_post_meta( $menu_item->ID, '_menu_item_menu_item_parent', true ) : $menu_item->menu_item_parent; $menu_item->object_id = ! isset( $menu_item->object_id ) ? get_post_meta( $menu_item->ID, '_menu_item_object_id', true ) : $menu_item->object_id; $menu_item->object = ! isset( $menu_item->object ) ? get_post_meta( $menu_item->ID, '_menu_item_object', true ) : $menu_item->object; $menu_item->type = ! isset( $menu_item->type ) ? get_post_meta( $menu_item->ID, '_menu_item_type', true ) : $menu_item->type; - if ( 'post_type' == $menu_item->type ) { + if ( 'post_type' === $menu_item->type ) { $object = get_post_type_object( $menu_item->object ); if ( $object ) { $menu_item->type_label = $object->labels->singular_name; @@ -853,7 +853,7 @@ function wp_setup_nav_menu_item( $menu_item ) { $menu_item->title = ( '' === $menu_item->post_title ) ? $original_title : $menu_item->post_title; - } elseif ( 'post_type_archive' == $menu_item->type ) { + } elseif ( 'post_type_archive' === $menu_item->type ) { $object = get_post_type_object( $menu_item->object ); if ( $object ) { $menu_item->title = ( '' === $menu_item->post_title ) ? $object->labels->archives : $menu_item->post_title; @@ -868,7 +868,7 @@ function wp_setup_nav_menu_item( $menu_item ) { $post_type_description = ( '' === $post_content ) ? $post_type_description : $post_content; $menu_item->url = get_post_type_archive_link( $menu_item->object ); - } elseif ( 'taxonomy' == $menu_item->type ) { + } elseif ( 'taxonomy' === $menu_item->type ) { $object = get_taxonomy( $menu_item->object ); if ( $object ) { $menu_item->type_label = $object->labels->singular_name; @@ -1013,13 +1013,13 @@ function wp_get_associated_nav_menu_items( $object_id = 0, $object_type = 'post_ if ( isset( $menu_item->ID ) && is_nav_menu_item( $menu_item->ID ) ) { $menu_item_type = get_post_meta( $menu_item->ID, '_menu_item_type', true ); if ( - 'post_type' == $object_type && - 'post_type' == $menu_item_type + 'post_type' === $object_type && + 'post_type' === $menu_item_type ) { $menu_item_ids[] = (int) $menu_item->ID; } elseif ( - 'taxonomy' == $object_type && - 'taxonomy' == $menu_item_type && + 'taxonomy' === $object_type && + 'taxonomy' === $menu_item_type && get_post_meta( $menu_item->ID, '_menu_item_object', true ) == $taxonomy ) { $menu_item_ids[] = (int) $menu_item->ID; @@ -1079,7 +1079,7 @@ function _wp_delete_tax_menu_item( $object_id = 0, $tt_id, $taxonomy ) { * @param WP_Post $post The post object being transitioned from one status to another. */ function _wp_auto_add_pages_to_menu( $new_status, $old_status, $post ) { - if ( 'publish' != $new_status || 'publish' == $old_status || 'page' != $post->post_type ) { + if ( 'publish' !== $new_status || 'publish' === $old_status || 'page' !== $post->post_type ) { return; } if ( ! empty( $post->post_parent ) ) { diff --git a/src/wp-includes/option.php b/src/wp-includes/option.php index b38ea66109..28ef635466 100644 --- a/src/wp-includes/option.php +++ b/src/wp-includes/option.php @@ -128,7 +128,7 @@ function get_option( $option, $default = false ) { } // If home is not set, use siteurl. - if ( 'home' == $option && '' == $value ) { + if ( 'home' === $option && '' === $value ) { return get_option( 'siteurl' ); } @@ -508,7 +508,7 @@ function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) } if ( ! wp_installing() ) { - if ( 'yes' == $autoload ) { + if ( 'yes' === $autoload ) { $alloptions = wp_load_alloptions( true ); $alloptions[ $option ] = $serialized_value; wp_cache_set( 'alloptions', $alloptions, 'options' ); @@ -586,7 +586,7 @@ function delete_option( $option ) { $result = $wpdb->delete( $wpdb->options, array( 'option_name' => $option ) ); if ( ! wp_installing() ) { - if ( 'yes' == $row->autoload ) { + if ( 'yes' === $row->autoload ) { $alloptions = wp_load_alloptions( true ); if ( is_array( $alloptions ) && isset( $alloptions[ $option ] ) ) { unset( $alloptions[ $option ] ); @@ -2154,7 +2154,7 @@ function register_setting( $option_group, $option_name, $args = array() ) { $wp_registered_settings = array(); } - if ( 'misc' == $option_group ) { + if ( 'misc' === $option_group ) { _deprecated_argument( __FUNCTION__, '3.0.0', @@ -2167,7 +2167,7 @@ function register_setting( $option_group, $option_name, $args = array() ) { $option_group = 'general'; } - if ( 'privacy' == $option_group ) { + if ( 'privacy' === $option_group ) { _deprecated_argument( __FUNCTION__, '3.5.0', @@ -2207,7 +2207,7 @@ function register_setting( $option_group, $option_name, $args = array() ) { function unregister_setting( $option_group, $option_name, $deprecated = '' ) { global $new_whitelist_options, $wp_registered_settings; - if ( 'misc' == $option_group ) { + if ( 'misc' === $option_group ) { _deprecated_argument( __FUNCTION__, '3.0.0', @@ -2220,7 +2220,7 @@ function unregister_setting( $option_group, $option_name, $deprecated = '' ) { $option_group = 'general'; } - if ( 'privacy' == $option_group ) { + if ( 'privacy' === $option_group ) { _deprecated_argument( __FUNCTION__, '3.5.0', diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php index e484923a42..f87763b16f 100644 --- a/src/wp-includes/pluggable.php +++ b/src/wp-includes/pluggable.php @@ -329,7 +329,7 @@ if ( ! function_exists( 'wp_mail' ) ) : if ( ! isset( $from_email ) ) { // Get the site domain and get rid of www. $sitename = strtolower( $_SERVER['SERVER_NAME'] ); - if ( substr( $sitename, 0, 4 ) == 'www.' ) { + if ( 'www.' === substr( $sitename, 0, 4 ) ) { $sitename = substr( $sitename, 4 ); } @@ -432,7 +432,7 @@ if ( ! function_exists( 'wp_mail' ) ) : $phpmailer->ContentType = $content_type; // Set whether it's plaintext, depending on $content_type. - if ( 'text/html' == $content_type ) { + if ( 'text/html' === $content_type ) { $phpmailer->isHTML( true ); } @@ -633,7 +633,7 @@ if ( ! function_exists( 'wp_validate_auth_cookie' ) ) : $expiration = $cookie_elements['expiration']; // Allow a grace period for POST and Ajax requests. - if ( wp_doing_ajax() || 'POST' == $_SERVER['REQUEST_METHOD'] ) { + if ( wp_doing_ajax() || 'POST' === $_SERVER['REQUEST_METHOD'] ) { $expired += HOUR_IN_SECONDS; } @@ -1266,7 +1266,7 @@ if ( ! function_exists( 'wp_redirect' ) ) : $location = wp_sanitize_redirect( $location ); - if ( ! $is_IIS && PHP_SAPI != 'cgi-fcgi' ) { + if ( ! $is_IIS && 'cgi-fcgi' !== PHP_SAPI ) { status_header( $status ); // This causes problems on IIS and some FastCGI setups. } @@ -1414,7 +1414,7 @@ if ( ! function_exists( 'wp_validate_redirect' ) ) : function wp_validate_redirect( $location, $default = '' ) { $location = trim( $location, " \t\n\r\0\x08\x0B" ); // Browsers will assume 'http' is your protocol, and will obey a redirect to a URL starting with '//'. - if ( substr( $location, 0, 2 ) == '//' ) { + if ( '//' === substr( $location, 0, 2 ) ) { $location = 'http:' . $location; } @@ -1431,7 +1431,7 @@ if ( ! function_exists( 'wp_validate_redirect' ) ) : } // Allow only 'http' and 'https' schemes. No 'data:', etc. - if ( isset( $lp['scheme'] ) && ! ( 'http' == $lp['scheme'] || 'https' == $lp['scheme'] ) ) { + if ( isset( $lp['scheme'] ) && ! ( 'http' === $lp['scheme'] || 'https' === $lp['scheme'] ) ) { return $default; } @@ -1646,14 +1646,14 @@ if ( ! function_exists( 'wp_notify_postauthor' ) ) : $wp_email = 'wordpress@' . preg_replace( '#^www\.#', '', strtolower( $_SERVER['SERVER_NAME'] ) ); - if ( '' == $comment->comment_author ) { + if ( '' === $comment->comment_author ) { $from = "From: \"$blogname\" <$wp_email>"; - if ( '' != $comment->comment_author_email ) { + if ( '' !== $comment->comment_author_email ) { $reply_to = "Reply-To: $comment->comment_author_email"; } } else { $from = "From: \"$comment->comment_author\" <$wp_email>"; - if ( '' != $comment->comment_author_email ) { + if ( '' !== $comment->comment_author_email ) { $reply_to = "Reply-To: \"$comment->comment_author_email\" <$comment->comment_author_email>"; } } @@ -2271,7 +2271,7 @@ if ( ! function_exists( 'wp_salt' ) ) : if ( defined( 'SECRET_KEY' ) && SECRET_KEY && empty( $duplicated_keys[ SECRET_KEY ] ) ) { $values['key'] = SECRET_KEY; } - if ( 'auth' == $scheme && defined( 'SECRET_SALT' ) && SECRET_SALT && empty( $duplicated_keys[ SECRET_SALT ] ) ) { + if ( 'auth' === $scheme && defined( 'SECRET_SALT' ) && SECRET_SALT && empty( $duplicated_keys[ SECRET_SALT ] ) ) { $values['salt'] = SECRET_SALT; } diff --git a/src/wp-includes/pomo/mo.php b/src/wp-includes/pomo/mo.php index b37c09b6af..b4f829fdef 100644 --- a/src/wp-includes/pomo/mo.php +++ b/src/wp-includes/pomo/mo.php @@ -221,7 +221,7 @@ if ( ! class_exists( 'MO', false ) ) : } $reader->setEndian( $endian_string ); - $endian = ( 'big' == $endian_string ) ? 'N' : 'V'; + $endian = ( 'big' === $endian_string ) ? 'N' : 'V'; $header = $reader->read( 24 ); if ( $reader->strlen( $header ) != 24 ) { diff --git a/src/wp-includes/pomo/po.php b/src/wp-includes/pomo/po.php index 238573d041..29f370841d 100644 --- a/src/wp-includes/pomo/po.php +++ b/src/wp-includes/pomo/po.php @@ -149,7 +149,7 @@ if ( ! class_exists( 'PO', false ) ) : $chars = $chars[0]; foreach ( $chars as $char ) { if ( ! $previous_is_backslash ) { - if ( '\\' == $char ) { + if ( '\\' === $char ) { $previous_is_backslash = true; } else { $unpoified .= $char; @@ -294,7 +294,7 @@ if ( ! class_exists( 'PO', false ) ) : if ( ! $res ) { break; } - if ( '' == $res['entry']->singular ) { + if ( '' === $res['entry']->singular ) { $this->set_headers( $this->make_headers( $res['entry']->translations[0] ) ); } else { $this->add_entry( $res['entry'] ); @@ -460,16 +460,16 @@ if ( ! class_exists( 'PO', false ) ) : function read_line( $f, $action = 'read' ) { static $last_line = ''; static $use_last_line = false; - if ( 'clear' == $action ) { + if ( 'clear' === $action ) { $last_line = ''; return true; } - if ( 'put-back' == $action ) { + if ( 'put-back' === $action ) { $use_last_line = true; return true; } $line = $use_last_line ? $last_line : fgets( $f ); - $line = ( "\r\n" == substr( $line, -2 ) ) ? rtrim( $line, "\r\n" ) . "\n" : $line; + $line = ( "\r\n" === substr( $line, -2 ) ) ? rtrim( $line, "\r\n" ) . "\n" : $line; $last_line = $line; $use_last_line = false; return $line; @@ -482,11 +482,11 @@ if ( ! class_exists( 'PO', false ) ) : function add_comment_to_entry( &$entry, $po_comment_line ) { $first_two = substr( $po_comment_line, 0, 2 ); $comment = trim( substr( $po_comment_line, 2 ) ); - if ( '#:' == $first_two ) { + if ( '#:' === $first_two ) { $entry->references = array_merge( $entry->references, preg_split( '/\s+/', $comment ) ); - } elseif ( '#.' == $first_two ) { + } elseif ( '#.' === $first_two ) { $entry->extracted_comments = trim( $entry->extracted_comments . "\n" . $comment ); - } elseif ( '#,' == $first_two ) { + } elseif ( '#,' === $first_two ) { $entry->flags = array_merge( $entry->flags, preg_split( '/,\s*/', $comment ) ); } else { $entry->translator_comments = trim( $entry->translator_comments . "\n" . $comment ); @@ -498,10 +498,10 @@ if ( ! class_exists( 'PO', false ) ) : * @return string */ public static function trim_quotes( $s ) { - if ( substr( $s, 0, 1 ) == '"' ) { + if ( '"' === substr( $s, 0, 1 ) ) { $s = substr( $s, 1 ); } - if ( substr( $s, -1, 1 ) == '"' ) { + if ( '"' === substr( $s, -1, 1 ) ) { $s = substr( $s, 0, -1 ); } return $s; diff --git a/src/wp-includes/pomo/streams.php b/src/wp-includes/pomo/streams.php index 07edcc2cd0..8d8a2edcc7 100644 --- a/src/wp-includes/pomo/streams.php +++ b/src/wp-includes/pomo/streams.php @@ -54,7 +54,7 @@ if ( ! class_exists( 'POMO_Reader', false ) ) : if ( 4 != $this->strlen( $bytes ) ) { return false; } - $endian_letter = ( 'big' == $this->endian ) ? 'N' : 'V'; + $endian_letter = ( 'big' === $this->endian ) ? 'N' : 'V'; $int = unpack( $endian_letter, $bytes ); return reset( $int ); } @@ -71,7 +71,7 @@ if ( ! class_exists( 'POMO_Reader', false ) ) : if ( 4 * $count != $this->strlen( $bytes ) ) { return false; } - $endian_letter = ( 'big' == $this->endian ) ? 'N' : 'V'; + $endian_letter = ( 'big' === $this->endian ) ? 'N' : 'V'; return unpack( $endian_letter . $count, $bytes ); } diff --git a/src/wp-includes/pomo/translations.php b/src/wp-includes/pomo/translations.php index 7211b52441..f4a125e32c 100644 --- a/src/wp-includes/pomo/translations.php +++ b/src/wp-includes/pomo/translations.php @@ -287,7 +287,7 @@ if ( ! class_exists( 'Translations', false ) ) : */ function set_header( $header, $value ) { parent::set_header( $header, $value ); - if ( 'Plural-Forms' == $header ) { + if ( 'Plural-Forms' === $header ) { list( $nplurals, $expression ) = $this->nplurals_and_expression_from_header( $this->get_header( 'Plural-Forms' ) ); $this->_nplurals = $nplurals; $this->_gettext_select_plural_form = $this->make_plural_form_function( $nplurals, $expression ); diff --git a/src/wp-includes/post-formats.php b/src/wp-includes/post-formats.php index 65fb9a4e97..d064334b73 100644 --- a/src/wp-includes/post-formats.php +++ b/src/wp-includes/post-formats.php @@ -192,7 +192,7 @@ function _post_format_request( $qvs ) { */ function _post_format_link( $link, $term, $taxonomy ) { global $wp_rewrite; - if ( 'post_format' != $taxonomy ) { + if ( 'post_format' !== $taxonomy ) { return $link; } if ( $wp_rewrite->get_extra_permastruct( $taxonomy ) ) { @@ -232,13 +232,13 @@ function _post_format_get_term( $term ) { */ function _post_format_get_terms( $terms, $taxonomies, $args ) { if ( in_array( 'post_format', (array) $taxonomies, true ) ) { - if ( isset( $args['fields'] ) && 'names' == $args['fields'] ) { + if ( isset( $args['fields'] ) && 'names' === $args['fields'] ) { foreach ( $terms as $order => $name ) { $terms[ $order ] = get_post_format_string( str_replace( 'post-format-', '', $name ) ); } } else { foreach ( (array) $terms as $order => $term ) { - if ( isset( $term->taxonomy ) && 'post_format' == $term->taxonomy ) { + if ( isset( $term->taxonomy ) && 'post_format' === $term->taxonomy ) { $terms[ $order ]->name = get_post_format_string( str_replace( 'post-format-', '', $term->slug ) ); } } @@ -258,7 +258,7 @@ function _post_format_get_terms( $terms, $taxonomies, $args ) { */ function _post_format_wp_get_object_terms( $terms ) { foreach ( (array) $terms as $order => $term ) { - if ( isset( $term->taxonomy ) && 'post_format' == $term->taxonomy ) { + if ( isset( $term->taxonomy ) && 'post_format' === $term->taxonomy ) { $terms[ $order ]->name = get_post_format_string( str_replace( 'post-format-', '', $term->slug ) ); } } diff --git a/src/wp-includes/post-template.php b/src/wp-includes/post-template.php index e4e945dad5..5f65b6c6f6 100644 --- a/src/wp-includes/post-template.php +++ b/src/wp-includes/post-template.php @@ -139,7 +139,7 @@ function get_the_title( $post = 0 ) { */ $protected_title_format = apply_filters( 'protected_title_format', $prepend, $post ); $title = sprintf( $protected_title_format, $title ); - } elseif ( isset( $post->post_status ) && 'private' == $post->post_status ) { + } elseif ( isset( $post->post_status ) && 'private' === $post->post_status ) { /* translators: %s: Private post title. */ $prepend = __( 'Private: %s' ); @@ -556,7 +556,7 @@ function get_post_class( $class = '', $post_id = null ) { } // 'post_tag' uses the 'tag' prefix for backward compatibility. - if ( 'post_tag' == $taxonomy ) { + if ( 'post_tag' === $taxonomy ) { $classes[] = 'tag-' . $term_class; } else { $classes[] = sanitize_html_class( $taxonomy . '-' . $term_class, $taxonomy . '-' . $term->term_id ); @@ -950,7 +950,7 @@ function wp_link_pages( $args = '' ) { $output = ''; if ( $multipage ) { - if ( 'number' == $parsed_args['next_or_number'] ) { + if ( 'number' === $parsed_args['next_or_number'] ) { $output .= $parsed_args['before']; for ( $i = 1; $i <= $numpages; $i++ ) { $link = $parsed_args['link_before'] . str_replace( '%', $i, $parsed_args['pagelink'] ) . $parsed_args['link_after']; @@ -1032,9 +1032,9 @@ function _wp_link_page( $i ) { if ( 1 == $i ) { $url = get_permalink(); } else { - if ( '' == get_option( 'permalink_structure' ) || in_array( $post->post_status, array( 'draft', 'pending' ), true ) ) { + if ( ! get_option( 'permalink_structure' ) || in_array( $post->post_status, array( 'draft', 'pending' ), true ) ) { $url = add_query_arg( 'page', $i, get_permalink() ); - } elseif ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $post->ID ) { + } elseif ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $post->ID ) { $url = trailingslashit( get_permalink() ) . user_trailingslashit( "$wp_rewrite->pagination_base/" . $i, 'single_paged' ); } else { $url = trailingslashit( get_permalink() ) . user_trailingslashit( $i, 'single_paged' ); @@ -1436,7 +1436,7 @@ function wp_page_menu( $args = array() ) { } $menu .= '<li ' . $class . '><a href="' . home_url( '/' ) . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>'; // If the front page is a page, add it to the exclude list. - if ( get_option( 'show_on_front' ) == 'page' ) { + if ( 'page' === get_option( 'show_on_front' ) ) { if ( ! empty( $list_args['exclude'] ) ) { $list_args['exclude'] .= ','; } else { @@ -1612,7 +1612,7 @@ function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = fals if ( $text ) { $link_text = $text; - } elseif ( $size && 'none' != $size ) { + } elseif ( $size && 'none' !== $size ) { $link_text = wp_get_attachment_image( $_post->ID, $size, $icon, $attr ); } else { $link_text = ''; @@ -1789,7 +1789,7 @@ function get_page_template_slug( $post = null ) { $template = get_post_meta( $post->ID, '_wp_page_template', true ); - if ( ! $template || 'default' == $template ) { + if ( ! $template || 'default' === $template ) { return ''; } diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index dd549bfcda..a1eefc2e33 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -769,7 +769,7 @@ function get_post( $post = null, $output = OBJECT, $filter = 'raw' ) { if ( empty( $post->filter ) ) { $_post = sanitize_post( $post, 'raw' ); $_post = new WP_Post( $_post ); - } elseif ( 'raw' == $post->filter ) { + } elseif ( 'raw' === $post->filter ) { $_post = new WP_Post( $post ); } else { $_post = WP_Post::get_instance( $post->ID ); @@ -899,20 +899,20 @@ function get_post_status( $post = null ) { return false; } - if ( 'attachment' == $post->post_type ) { - if ( 'private' == $post->post_status ) { + if ( 'attachment' === $post->post_type ) { + if ( 'private' === $post->post_status ) { return 'private'; } // Unattached attachments are assumed to be published. - if ( ( 'inherit' == $post->post_status ) && ( 0 == $post->post_parent ) ) { + if ( ( 'inherit' === $post->post_status ) && ( 0 == $post->post_parent ) ) { return 'publish'; } // Inherit status from the parent. if ( $post->post_parent && ( $post->ID != $post->post_parent ) ) { $parent_post_status = get_post_status( $post->post_parent ); - if ( 'trash' == $parent_post_status ) { + if ( 'trash' === $parent_post_status ) { return get_post_meta( $post->post_parent, '_wp_trash_meta_status', true ); } else { return $parent_post_status; @@ -1160,7 +1160,7 @@ function get_post_status_object( $post_status ) { function get_post_stati( $args = array(), $output = 'names', $operator = 'and' ) { global $wp_post_statuses; - $field = ( 'names' == $output ) ? 'name' : false; + $field = ( 'names' === $output ) ? 'name' : false; return wp_filter_object_list( $wp_post_statuses, $args, $operator, $field ); } @@ -1265,7 +1265,7 @@ function get_post_type_object( $post_type ) { function get_post_types( $args = array(), $output = 'names', $operator = 'and' ) { global $wp_post_types; - $field = ( 'names' == $output ) ? 'name' : false; + $field = ( 'names' === $output ) ? 'name' : false; return wp_filter_object_list( $wp_post_types, $args, $operator, $field ); } @@ -2027,7 +2027,7 @@ function get_posts( $args = null ) { $parsed_args = wp_parse_args( $args, $defaults ); if ( empty( $parsed_args['post_status'] ) ) { - $parsed_args['post_status'] = ( 'attachment' == $parsed_args['post_type'] ) ? 'inherit' : 'publish'; + $parsed_args['post_status'] = ( 'attachment' === $parsed_args['post_type'] ) ? 'inherit' : 'publish'; } if ( ! empty( $parsed_args['numberposts'] ) && empty( $parsed_args['posts_per_page'] ) ) { $parsed_args['posts_per_page'] = $parsed_args['numberposts']; @@ -2381,7 +2381,7 @@ function sanitize_post_field( $field, $value, $post_id, $context = 'display' ) { return $value; } - if ( 'raw' == $context ) { + if ( 'raw' === $context ) { return $value; } @@ -2391,7 +2391,7 @@ function sanitize_post_field( $field, $value, $post_id, $context = 'display' ) { $field_no_prefix = str_replace( 'post_', '', $field ); } - if ( 'edit' == $context ) { + if ( 'edit' === $context ) { $format_to_edit = array( 'post_content', 'post_excerpt', 'post_title', 'post_password' ); if ( $prefixed ) { @@ -2426,7 +2426,7 @@ function sanitize_post_field( $field, $value, $post_id, $context = 'display' ) { } if ( in_array( $field, $format_to_edit, true ) ) { - if ( 'post_content' == $field ) { + if ( 'post_content' === $field ) { $value = format_to_edit( $value, user_can_richedit() ); } else { $value = format_to_edit( $value ); @@ -2434,7 +2434,7 @@ function sanitize_post_field( $field, $value, $post_id, $context = 'display' ) { } else { $value = esc_attr( $value ); } - } elseif ( 'db' == $context ) { + } elseif ( 'db' === $context ) { if ( $prefixed ) { /** @@ -2499,9 +2499,9 @@ function sanitize_post_field( $field, $value, $post_id, $context = 'display' ) { $value = apply_filters( "post_{$field}", $value, $post_id, $context ); } - if ( 'attribute' == $context ) { + if ( 'attribute' === $context ) { $value = esc_attr( $value ); - } elseif ( 'js' == $context ) { + } elseif ( 'js' === $context ) { $value = esc_js( $value ); } } @@ -2602,12 +2602,15 @@ function unstick_post( $post_id ) { */ function _count_posts_cache_key( $type = 'post', $perm = '' ) { $cache_key = 'posts-' . $type; - if ( 'readable' == $perm && is_user_logged_in() ) { + + if ( 'readable' === $perm && is_user_logged_in() ) { $post_type_object = get_post_type_object( $type ); + if ( $post_type_object && ! current_user_can( $post_type_object->cap->read_private_posts ) ) { $cache_key .= '_' . $perm . '_' . get_current_user_id(); } } + return $cache_key; } @@ -2646,7 +2649,8 @@ function wp_count_posts( $type = 'post', $perm = '' ) { } $query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s"; - if ( 'readable' == $perm && is_user_logged_in() ) { + + if ( 'readable' === $perm && is_user_logged_in() ) { $post_type_object = get_post_type_object( $type ); if ( ! current_user_can( $post_type_object->cap->read_private_posts ) ) { $query .= $wpdb->prepare( @@ -2655,6 +2659,7 @@ function wp_count_posts( $type = 'post', $perm = '' ) { ); } } + $query .= ' GROUP BY post_status'; $results = (array) $wpdb->get_results( $wpdb->prepare( $query, $type ), ARRAY_A ); @@ -3114,7 +3119,8 @@ function wp_delete_post( $postid = 0, $force_delete = false ) { */ function _reset_front_page_settings_for_post( $post_id ) { $post = get_post( $post_id ); - if ( 'page' == $post->post_type ) { + + if ( 'page' === $post->post_type ) { /* * If the page is defined in option page_on_front or post_for_posts, * adjust the corresponding options. @@ -3127,6 +3133,7 @@ function _reset_front_page_settings_for_post( $post_id ) { update_option( 'page_for_posts', 0 ); } } + unstick_post( $post->ID ); } @@ -3381,7 +3388,7 @@ function wp_untrash_post_comments( $post = null ) { foreach ( $group_by_status as $status => $comments ) { // Sanity check. This shouldn't happen. - if ( 'post-trashed' == $status ) { + if ( 'post-trashed' === $status ) { $status = '0'; } $comments_in = implode( ', ', array_map( 'intval', $comments ) ); @@ -3704,7 +3711,7 @@ function wp_insert_post( $postarr, $wp_error = false ) { // Make sure we set a valid category. if ( empty( $post_category ) || 0 == count( $post_category ) || ! is_array( $post_category ) ) { // 'post' requires at least one category. - if ( 'post' == $post_type && 'auto-draft' != $post_status ) { + if ( 'post' === $post_type && 'auto-draft' !== $post_status ) { $post_category = array( get_option( 'default_category' ) ); } else { $post_category = array(); @@ -3748,8 +3755,8 @@ function wp_insert_post( $postarr, $wp_error = false ) { * If the post date is empty (due to having been new or a draft) and status * is not 'draft' or 'pending', set date to now. */ - if ( empty( $postarr['post_date'] ) || '0000-00-00 00:00:00' == $postarr['post_date'] ) { - if ( empty( $postarr['post_date_gmt'] ) || '0000-00-00 00:00:00' == $postarr['post_date_gmt'] ) { + if ( empty( $postarr['post_date'] ) || '0000-00-00 00:00:00' === $postarr['post_date'] ) { + if ( empty( $postarr['post_date_gmt'] ) || '0000-00-00 00:00:00' === $postarr['post_date_gmt'] ) { $post_date = current_time( 'mysql' ); } else { $post_date = get_date_from_gmt( $postarr['post_date_gmt'] ); @@ -3771,7 +3778,7 @@ function wp_insert_post( $postarr, $wp_error = false ) { } } - if ( empty( $postarr['post_date_gmt'] ) || '0000-00-00 00:00:00' == $postarr['post_date_gmt'] ) { + if ( empty( $postarr['post_date_gmt'] ) || '0000-00-00 00:00:00' === $postarr['post_date_gmt'] ) { if ( ! in_array( $post_status, get_post_stati( array( 'date_floating' => true ) ), true ) ) { $post_date_gmt = get_gmt_from_date( $post_date ); } else { @@ -3781,7 +3788,7 @@ function wp_insert_post( $postarr, $wp_error = false ) { $post_date_gmt = $postarr['post_date_gmt']; } - if ( $update || '0000-00-00 00:00:00' == $post_date ) { + if ( $update || '0000-00-00 00:00:00' === $post_date ) { $post_modified = current_time( 'mysql' ); $post_modified_gmt = current_time( 'mysql', 1 ); } else { @@ -3833,7 +3840,7 @@ function wp_insert_post( $postarr, $wp_error = false ) { } $post_password = isset( $postarr['post_password'] ) ? $postarr['post_password'] : ''; - if ( 'private' == $post_status ) { + if ( 'private' === $post_status ) { $post_password = ''; } @@ -4027,7 +4034,7 @@ function wp_insert_post( $postarr, $wp_error = false ) { $current_guid = get_post_field( 'guid', $post_ID ); // Set GUID. - if ( ! $update && '' == $current_guid ) { + if ( ! $update && '' === $current_guid ) { $wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post_ID ) ), $where ); } @@ -4069,7 +4076,7 @@ function wp_insert_post( $postarr, $wp_error = false ) { if ( ! empty( $postarr['page_template'] ) ) { $post->page_template = $postarr['page_template']; $page_templates = wp_get_theme()->get_page_templates( $post ); - if ( 'default' != $postarr['page_template'] && ! isset( $page_templates[ $postarr['page_template'] ] ) ) { + if ( 'default' !== $postarr['page_template'] && ! isset( $page_templates[ $postarr['page_template'] ] ) ) { if ( $wp_error ) { return new WP_Error( 'invalid_page_template', __( 'Invalid page template.' ) ); } @@ -4239,7 +4246,7 @@ function wp_update_post( $postarr = array(), $wp_error = false ) { // Drafts shouldn't be assigned a date unless explicitly done so by the user. if ( isset( $post['post_status'] ) && in_array( $post['post_status'], array( 'draft', 'pending', 'auto-draft' ), true ) - && empty( $postarr['edit_date'] ) && ( '0000-00-00 00:00:00' == $post['post_date_gmt'] ) + && empty( $postarr['edit_date'] ) && ( '0000-00-00 00:00:00' === $post['post_date_gmt'] ) ) { $clear_date = true; } else { @@ -4292,7 +4299,7 @@ function wp_publish_post( $post ) { return; } - if ( 'publish' == $post->post_status ) { + if ( 'publish' === $post->post_status ) { return; } @@ -4337,7 +4344,7 @@ function check_and_publish_future_post( $post_id ) { return; } - if ( 'future' != $post->post_status ) { + if ( 'future' !== $post->post_status ) { return; } @@ -4371,7 +4378,7 @@ function check_and_publish_future_post( $post_id ) { */ function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_parent ) { if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ), true ) - || ( 'inherit' == $post_status && 'revision' == $post_type ) || 'user_request' === $post_type + || ( 'inherit' === $post_status && 'revision' === $post_type ) || 'user_request' === $post_type ) { return $slug; } @@ -4405,7 +4412,7 @@ function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p $feeds = array(); } - if ( 'attachment' == $post_type ) { + if ( 'attachment' === $post_type ) { // Attachment slugs must be unique across all types. $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND ID != %d LIMIT 1"; $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID ) ); @@ -4433,7 +4440,7 @@ function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p $slug = $alt_post_name; } } elseif ( is_post_type_hierarchical( $post_type ) ) { - if ( 'nav_menu_item' == $post_type ) { + if ( 'nav_menu_item' === $post_type ) { return $slug; } @@ -4671,13 +4678,13 @@ function wp_set_post_categories( $post_ID = 0, $post_categories = array(), $appe // If $post_categories isn't already an array, make it one: $post_categories = (array) $post_categories; if ( empty( $post_categories ) ) { - if ( 'post' == $post_type && 'auto-draft' != $post_status ) { + if ( 'post' === $post_type && 'auto-draft' !== $post_status ) { $post_categories = array( get_option( 'default_category' ) ); $append = false; } else { $post_categories = array(); } - } elseif ( 1 == count( $post_categories ) && '' == reset( $post_categories ) ) { + } elseif ( 1 == count( $post_categories ) && '' === reset( $post_categories ) ) { return true; } @@ -4816,7 +4823,7 @@ function get_enclosed( $post_id ) { } foreach ( $custom_fields as $key => $val ) { - if ( 'enclosure' != $key || ! is_array( $val ) ) { + if ( 'enclosure' !== $key || ! is_array( $val ) ) { continue; } foreach ( $val as $enc ) { @@ -5395,13 +5402,13 @@ function get_pages( $args = array() ) { $post_author = $post_author->ID; } - if ( '' == $author_query ) { + if ( '' === $author_query ) { $author_query = $wpdb->prepare( ' post_author = %d ', $post_author ); } else { $author_query .= $wpdb->prepare( ' OR post_author = %d ', $post_author ); } } - if ( '' != $author_query ) { + if ( '' !== $author_query ) { $author_query = " AND ($author_query)"; } } @@ -5593,7 +5600,7 @@ function is_local_attachment( $url ) { $id = url_to_postid( $url ); if ( $id ) { $post = get_post( $id ); - if ( 'attachment' == $post->post_type ) { + if ( 'attachment' === $post->post_type ) { return true; } } @@ -5925,7 +5932,7 @@ function wp_get_attachment_url( $attachment_id = 0 ) { return false; } - if ( 'attachment' != $post->post_type ) { + if ( 'attachment' !== $post->post_type ) { return false; } @@ -6239,7 +6246,7 @@ function wp_mime_type_icon( $mime = 0 ) { if ( $dh ) { while ( false !== $file = readdir( $dh ) ) { $file = wp_basename( $file ); - if ( substr( $file, 0, 1 ) == '.' ) { + if ( '.' === substr( $file, 0, 1 ) ) { continue; } @@ -6701,7 +6708,7 @@ function clean_post_cache( $post ) { */ do_action( 'clean_post_cache', $post->ID, $post ); - if ( 'page' == $post->post_type ) { + if ( 'page' === $post->post_type ) { wp_cache_delete( 'all_page_ids', 'posts' ); /** @@ -6747,7 +6754,7 @@ function update_post_caches( &$posts, $post_type = 'post', $update_term_cache = if ( $update_term_cache ) { if ( is_array( $post_type ) ) { $ptypes = $post_type; - } elseif ( 'any' == $post_type ) { + } elseif ( 'any' === $post_type ) { $ptypes = array(); // Just use the post_types in the supplied posts. foreach ( $posts as $post ) { @@ -6847,7 +6854,7 @@ function _transition_post_status( $new_status, $old_status, $post ) { if ( 'publish' !== $old_status && 'publish' === $new_status ) { // Reset GUID if transitioning to publish and it is empty. - if ( '' == get_the_guid( $post->ID ) ) { + if ( '' === get_the_guid( $post->ID ) ) { $wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post->ID ) ), array( 'ID' => $post->ID ) ); } @@ -6863,7 +6870,7 @@ function _transition_post_status( $new_status, $old_status, $post ) { } // If published posts changed clear the lastpostmodified cache. - if ( 'publish' == $new_status || 'publish' == $old_status ) { + if ( 'publish' === $new_status || 'publish' === $old_status ) { foreach ( array( 'server', 'gmt', 'blog' ) as $timezone ) { wp_cache_delete( "lastpostmodified:$timezone", 'timeinfo' ); wp_cache_delete( "lastpostdate:$timezone", 'timeinfo' ); diff --git a/src/wp-includes/revision.php b/src/wp-includes/revision.php index eec6c29700..49c8253cbe 100644 --- a/src/wp-includes/revision.php +++ b/src/wp-includes/revision.php @@ -122,7 +122,7 @@ function wp_save_post_revision( $post_id ) { return; } - if ( 'auto-draft' == $post->post_status ) { + if ( 'auto-draft' === $post->post_status ) { return; } @@ -308,7 +308,7 @@ function _wp_put_post_revision( $post = null, $autosave = false ) { return new WP_Error( 'invalid_post', __( 'Invalid post ID.' ) ); } - if ( isset( $post['post_type'] ) && 'revision' == $post['post_type'] ) { + if ( isset( $post['post_type'] ) && 'revision' === $post['post_type'] ) { return new WP_Error( 'post_type', __( 'Cannot create a revision of a revision' ) ); } @@ -616,11 +616,13 @@ function _wp_preview_terms_filter( $terms, $post_id, $taxonomy ) { return $terms; } - if ( empty( $_REQUEST['post_format'] ) || $post->ID != $post_id || 'post_format' != $taxonomy || 'revision' == $post->post_type ) { + if ( empty( $_REQUEST['post_format'] ) || $post->ID != $post_id + || 'post_format' !== $taxonomy || 'revision' === $post->post_type + ) { return $terms; } - if ( 'standard' == $_REQUEST['post_format'] ) { + if ( 'standard' === $_REQUEST['post_format'] ) { $terms = array(); } else { $term = get_term_by( 'slug', 'post-format-' . sanitize_key( $_REQUEST['post_format'] ), 'post_format' ); @@ -652,8 +654,8 @@ function _wp_preview_post_thumbnail_filter( $value, $post_id, $meta_key ) { if ( empty( $_REQUEST['_thumbnail_id'] ) || empty( $_REQUEST['preview_id'] ) || $post->ID != $post_id || - '_thumbnail_id' != $meta_key || - 'revision' == $post->post_type || + '_thumbnail_id' !== $meta_key || + 'revision' === $post->post_type || $post_id != $_REQUEST['preview_id'] ) { return $value; diff --git a/src/wp-includes/rewrite.php b/src/wp-includes/rewrite.php index c704bdd317..da999719ea 100644 --- a/src/wp-includes/rewrite.php +++ b/src/wp-includes/rewrite.php @@ -515,7 +515,7 @@ function url_to_postid( $url ) { $url = str_replace( '://www.', '://', $url ); } - if ( trim( $url, '/' ) === home_url() && 'page' == get_option( 'show_on_front' ) ) { + if ( trim( $url, '/' ) === home_url() && 'page' === get_option( 'show_on_front' ) ) { $page_on_front = get_option( 'page_on_front' ); if ( $page_on_front && get_post( $page_on_front ) instanceof WP_Post ) { diff --git a/src/wp-includes/shortcodes.php b/src/wp-includes/shortcodes.php index 6d784f701a..1d85fa4775 100644 --- a/src/wp-includes/shortcodes.php +++ b/src/wp-includes/shortcodes.php @@ -63,7 +63,7 @@ $shortcode_tags = array(); function add_shortcode( $tag, $callback ) { global $shortcode_tags; - if ( '' == trim( $tag ) ) { + if ( '' === trim( $tag ) ) { $message = __( 'Invalid shortcode name: Empty name given.' ); _doing_it_wrong( __FUNCTION__, $message, '4.4.0' ); return; @@ -386,7 +386,7 @@ function do_shortcodes_in_html_tags( $content, $ignore_html, $tagnames ) { $textarr = wp_html_split( $content ); foreach ( $textarr as &$element ) { - if ( '' == $element || '<' !== $element[0] ) { + if ( '' === $element || '<' !== $element[0] ) { continue; } @@ -511,8 +511,8 @@ function get_shortcode_atts_regex() { * * @param string $text * @return array|string List of attribute values. - * Returns empty array if trim( $text ) == '""'. - * Returns empty string if trim( $text ) == ''. + * Returns empty array if '""' === trim( $text ). + * Returns empty string if '' === trim( $text ). * All other matches are checked for not empty(). */ function shortcode_parse_atts( $text ) { diff --git a/src/wp-includes/template.php b/src/wp-includes/template.php index 447e76bc7a..51a4c86358 100644 --- a/src/wp-includes/template.php +++ b/src/wp-includes/template.php @@ -668,7 +668,7 @@ function locate_template( $template_names, $load = false, $require_once = true ) } } - if ( $load && '' != $located ) { + if ( $load && '' !== $located ) { load_template( $located, $require_once ); } diff --git a/src/wp-includes/theme-compat/comments.php b/src/wp-includes/theme-compat/comments.php index d5aa5c928d..2002f8679f 100644 --- a/src/wp-includes/theme-compat/comments.php +++ b/src/wp-includes/theme-compat/comments.php @@ -16,7 +16,7 @@ _deprecated_file( ); // Do not delete these lines. -if ( ! empty( $_SERVER['SCRIPT_FILENAME'] ) && 'comments.php' == basename( $_SERVER['SCRIPT_FILENAME'] ) ) { +if ( ! empty( $_SERVER['SCRIPT_FILENAME'] ) && 'comments.php' === basename( $_SERVER['SCRIPT_FILENAME'] ) ) { die( 'Please do not load this page directly. Thanks!' ); } diff --git a/src/wp-includes/theme.php b/src/wp-includes/theme.php index 3a827d27fe..48ccd29013 100644 --- a/src/wp-includes/theme.php +++ b/src/wp-includes/theme.php @@ -1156,7 +1156,7 @@ function has_header_image() { function get_header_image() { $url = get_theme_mod( 'header_image', get_theme_support( 'custom-header', 'default-image' ) ); - if ( 'remove-header' == $url ) { + if ( 'remove-header' === $url ) { return false; } @@ -1265,10 +1265,10 @@ function _get_random_header_data() { $header_image_mod = get_theme_mod( 'header_image', '' ); $headers = array(); - if ( 'random-uploaded-image' == $header_image_mod ) { + if ( 'random-uploaded-image' === $header_image_mod ) { $headers = get_uploaded_header_images(); } elseif ( ! empty( $_wp_default_headers ) ) { - if ( 'random-default-image' == $header_image_mod ) { + if ( 'random-default-image' === $header_image_mod ) { $headers = $_wp_default_headers; } else { if ( current_theme_supports( 'custom-header', 'random-default' ) ) { @@ -1286,6 +1286,7 @@ function _get_random_header_data() { $_wp_random_header->url = sprintf( $_wp_random_header->url, get_template_directory_uri(), get_stylesheet_directory_uri() ); $_wp_random_header->thumbnail_url = sprintf( $_wp_random_header->thumbnail_url, get_template_directory_uri(), get_stylesheet_directory_uri() ); } + return $_wp_random_header; } @@ -1298,9 +1299,11 @@ function _get_random_header_data() { */ function get_random_header_image() { $random_image = _get_random_header_data(); + if ( empty( $random_image->url ) ) { return ''; } + return $random_image->url; } @@ -1319,14 +1322,17 @@ function get_random_header_image() { function is_random_header_image( $type = 'any' ) { $header_image_mod = get_theme_mod( 'header_image', get_theme_support( 'custom-header', 'default-image' ) ); - if ( 'any' == $type ) { - if ( 'random-default-image' == $header_image_mod || 'random-uploaded-image' == $header_image_mod || ( '' != get_random_header_image() && empty( $header_image_mod ) ) ) { + if ( 'any' === $type ) { + if ( 'random-default-image' === $header_image_mod + || 'random-uploaded-image' === $header_image_mod + || ( '' !== get_random_header_image() && empty( $header_image_mod ) ) + ) { return true; } } else { - if ( "random-$type-image" == $header_image_mod ) { + if ( "random-$type-image" === $header_image_mod ) { return true; - } elseif ( 'default' == $type && empty( $header_image_mod ) && '' != get_random_header_image() ) { + } elseif ( 'default' === $type && empty( $header_image_mod ) && '' !== get_random_header_image() ) { return true; } } @@ -1341,6 +1347,7 @@ function is_random_header_image( $type = 'any' ) { */ function header_image() { $image = get_header_image(); + if ( $image ) { echo esc_url( $image ); } @@ -1536,6 +1543,7 @@ function get_header_video_url() { */ function the_header_video_url() { $video = get_header_video_url(); + if ( $video ) { echo esc_url( $video ); } @@ -2903,7 +2911,7 @@ function _remove_theme_support( $feature ) { function current_theme_supports( $feature, ...$args ) { global $_wp_theme_features; - if ( 'custom-header-uploads' == $feature ) { + if ( 'custom-header-uploads' === $feature ) { return current_theme_supports( 'custom-header', 'uploads' ); } @@ -3074,11 +3082,11 @@ function check_theme_switched() { */ function _wp_customize_include() { - $is_customize_admin_page = ( is_admin() && 'customize.php' == basename( $_SERVER['PHP_SELF'] ) ); + $is_customize_admin_page = ( is_admin() && 'customize.php' === basename( $_SERVER['PHP_SELF'] ) ); $should_include = ( $is_customize_admin_page || - ( isset( $_REQUEST['wp_customize'] ) && 'on' == $_REQUEST['wp_customize'] ) + ( isset( $_REQUEST['wp_customize'] ) && 'on' === $_REQUEST['wp_customize'] ) || ( ! empty( $_GET['customize_changeset_uuid'] ) || ! empty( $_POST['customize_changeset_uuid'] ) ) ); diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php index bf9472d8cf..a1e88f2e5a 100644 --- a/src/wp-includes/user.php +++ b/src/wp-includes/user.php @@ -910,7 +910,7 @@ function count_users( $strategy = 'time', $site_id = null ) { $blog_prefix = $wpdb->get_blog_prefix( $site_id ); $result = array(); - if ( 'time' == $strategy ) { + if ( 'time' === $strategy ) { if ( is_multisite() && get_current_blog_id() != $site_id ) { switch_to_blog( $site_id ); $avail_roles = wp_roles()->get_names(); @@ -1251,7 +1251,7 @@ function sanitize_user_field( $field, $value, $user_id, $context ) { $value = (int) $value; } - if ( 'raw' == $context ) { + if ( 'raw' === $context ) { return $value; } @@ -1261,7 +1261,7 @@ function sanitize_user_field( $field, $value, $user_id, $context ) { $prefixed = false !== strpos( $field, 'user_' ); - if ( 'edit' == $context ) { + if ( 'edit' === $context ) { if ( $prefixed ) { /** This filter is documented in wp-includes/post.php */ @@ -1282,12 +1282,12 @@ function sanitize_user_field( $field, $value, $user_id, $context ) { $value = apply_filters( "edit_user_{$field}", $value, $user_id ); } - if ( 'description' == $field ) { + if ( 'description' === $field ) { $value = esc_html( $value ); // textarea_escaped? } else { $value = esc_attr( $value ); } - } elseif ( 'db' == $context ) { + } elseif ( 'db' === $context ) { if ( $prefixed ) { /** This filter is documented in wp-includes/post.php */ $value = apply_filters( "pre_{$field}", $value ); @@ -1329,13 +1329,13 @@ function sanitize_user_field( $field, $value, $user_id, $context ) { } } - if ( 'user_url' == $field ) { + if ( 'user_url' === $field ) { $value = esc_url( $value ); } - if ( 'attribute' == $context ) { + if ( 'attribute' === $context ) { $value = esc_attr( $value ); - } elseif ( 'js' == $context ) { + } elseif ( 'js' === $context ) { $value = esc_js( $value ); } return $value; @@ -2506,7 +2506,7 @@ function register_new_user( $user_login, $user_email ) { $user_email = apply_filters( 'user_registration_email', $user_email ); // Check the username. - if ( '' == $sanitized_user_login ) { + if ( '' === $sanitized_user_login ) { $errors->add( 'empty_username', __( '<strong>Error</strong>: Please enter a username.' ) ); } elseif ( ! validate_username( $user_login ) ) { $errors->add( 'invalid_username', __( '<strong>Error</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.' ) ); @@ -2523,7 +2523,7 @@ function register_new_user( $user_login, $user_email ) { } // Check the email address. - if ( '' == $user_email ) { + if ( '' === $user_email ) { $errors->add( 'empty_email', __( '<strong>Error</strong>: Please type your email address.' ) ); } elseif ( ! is_email( $user_email ) ) { $errors->add( 'invalid_email', __( '<strong>Error</strong>: The email address isn’t correct.' ) ); |