Coding Standards: Use strict comparison where static strings are involved.

This reduces the number of `WordPress.PHP.StrictComparisons.LooseComparison` issues in half, from 1897 to 890.

Includes minor code layout fixes for better readability.

See #49542.
Built from https://develop.svn.wordpress.org/trunk@47808


git-svn-id: http://core.svn.wordpress.org/trunk@47584 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-05-16 18:42:12 +00:00
parent 45f7e68d54
commit 7932193708
161 changed files with 1144 additions and 1008 deletions

View File

@ -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';
}

View File

@ -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() ) {

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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 ) {

View File

@ -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 {

View File

@ -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;
}
}

View File

@ -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&amp;from=import&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ),
__( 'Activate Plugin &amp; 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&amp;from=press-this&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ),

View File

@ -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 ) : '';

View File

@ -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 />

View File

@ -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";
}

View File

@ -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>',

View File

@ -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;
}

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 ) {

View File

@ -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'] : '&nbsp;' ) . '</p>';
$plugin_name = $plugin_data['Name'];
}

View File

@ -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 ),

View File

@ -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 ) ) {

View File

@ -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;
}

View File

@ -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() );

View File

@ -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' );
}
}

View File

@ -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>

View File

@ -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();}
?>

View File

@ -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;

View File

@ -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 {

View File

@ -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, '&hellip;' ) . '</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 {

View File

@ -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 );

View File

@ -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&amp;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 ) );
}

View File

@ -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] )

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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 ); } );
}

View File

@ -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 ) ) {

View File

@ -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;

View File

@ -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' ) );

View File

@ -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.' ) );
}

View File

@ -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' );

View File

@ -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 {

View File

@ -2330,7 +2330,7 @@ function compression_test() {
}
if ( 2 == test ) {
if ( '"wpCompressionTest' == r )
if ( '"wpCompressionTest' === r )
this.get('yes');
else
this.get('no');

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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}.

View File

@ -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 />&nbsp;&nbsp;&nbsp;&nbsp;';
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 />&nbsp;&nbsp;&nbsp;&nbsp;';
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 />&nbsp;&nbsp;&nbsp;&nbsp;';
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 &#8220;Repair Database&#8221; 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>';

View File

@ -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;
}

View File

@ -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 );

View File

@ -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>';

View File

@ -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>

View File

@ -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 ) ) {

View File

@ -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 );
}

View File

@ -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>

View File

@ -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;
}

View File

@ -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&#8217;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';

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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.

View File

@ -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.' ) );

View File

@ -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.' ) );

View File

@ -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'] ) ) {

View File

@ -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>

View File

@ -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.' );
}
}

View File

@ -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 -->

View File

@ -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

View File

@ -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 -->

View File

@ -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 );
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() )
)
);
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

View File

@ -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';

View File

@ -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;

View File

@ -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>

View File

@ -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' );
}
?>

View File

@ -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' ) ) : ?>

View File

@ -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(); ?>

View File

@ -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 );
}

View File

@ -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>',

View File

@ -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' );

View File

@ -30,7 +30,7 @@
<div class="entry-meta">
<?php
if ( 'post' == get_post_type() ) {
if ( 'post' === get_post_type() ) {
twentyfourteen_posted_on();
}

View File

@ -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';

View File

@ -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;
}

View File

@ -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();

View File

@ -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. ?>

View File

@ -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' ) ) ),

View File

@ -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( {

View File

@ -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';
}

View File

@ -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' );

View File

@ -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();

View File

@ -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, ', ' );

View File

@ -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;
}

View File

@ -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 );
}
}

View File

@ -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;

View File

@ -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,

View File

@ -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',

View File

@ -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';
}

View File

@ -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;
}

View File

@ -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

View File

@ -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;

View File

@ -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 ) ) {

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