mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@47808 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
+21
-14
@@ -127,7 +127,7 @@ function check_comment( $author, $email, $url, $comment, $user_ip, $user_agent,
|
||||
* email address. If both checks pass, return true. Otherwise, return false.
|
||||
*/
|
||||
if ( 1 == get_option( 'comment_whitelist' ) ) {
|
||||
if ( 'trackback' !== $comment_type && 'pingback' !== $comment_type && '' != $author && '' != $email ) {
|
||||
if ( 'trackback' !== $comment_type && 'pingback' !== $comment_type && '' !== $author && '' !== $email ) {
|
||||
$comment_user = get_user_by( 'email', wp_unslash( $email ) );
|
||||
if ( ! empty( $comment_user->ID ) ) {
|
||||
$ok_to_comment = $wpdb->get_var( $wpdb->prepare( "SELECT comment_approved FROM $wpdb->comments WHERE user_id = %d AND comment_approved = '1' LIMIT 1", $comment_user->ID ) );
|
||||
@@ -963,14 +963,19 @@ function separate_comments( &$comments ) {
|
||||
'pingback' => array(),
|
||||
'pings' => array(),
|
||||
);
|
||||
$count = count( $comments );
|
||||
|
||||
$count = count( $comments );
|
||||
|
||||
for ( $i = 0; $i < $count; $i++ ) {
|
||||
$type = $comments[ $i ]->comment_type;
|
||||
|
||||
if ( empty( $type ) ) {
|
||||
$type = 'comment';
|
||||
}
|
||||
|
||||
$comments_by_type[ $type ][] = &$comments[ $i ];
|
||||
if ( 'trackback' == $type || 'pingback' == $type ) {
|
||||
|
||||
if ( 'trackback' === $type || 'pingback' === $type ) {
|
||||
$comments_by_type['pings'][] = &$comments[ $i ];
|
||||
}
|
||||
}
|
||||
@@ -1281,7 +1286,7 @@ function wp_blacklist_check( $author, $email, $url, $comment, $user_ip, $user_ag
|
||||
do_action( 'wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent );
|
||||
|
||||
$mod_keys = trim( get_option( 'blacklist_keys' ) );
|
||||
if ( '' == $mod_keys ) {
|
||||
if ( '' === $mod_keys ) {
|
||||
return false; // If moderation keys are empty.
|
||||
}
|
||||
|
||||
@@ -1671,9 +1676,9 @@ function wp_get_comment_status( $comment_id ) {
|
||||
return 'approved';
|
||||
} elseif ( '0' == $approved ) {
|
||||
return 'unapproved';
|
||||
} elseif ( 'spam' == $approved ) {
|
||||
} elseif ( 'spam' === $approved ) {
|
||||
return 'spam';
|
||||
} elseif ( 'trash' == $approved ) {
|
||||
} elseif ( 'trash' === $approved ) {
|
||||
return 'trash';
|
||||
} else {
|
||||
return false;
|
||||
@@ -2114,8 +2119,10 @@ function wp_new_comment( $commentdata, $avoid_die = false ) {
|
||||
}
|
||||
|
||||
$commentdata['comment_parent'] = isset( $commentdata['comment_parent'] ) ? absint( $commentdata['comment_parent'] ) : 0;
|
||||
$parent_status = ( 0 < $commentdata['comment_parent'] ) ? wp_get_comment_status( $commentdata['comment_parent'] ) : '';
|
||||
$commentdata['comment_parent'] = ( 'approved' == $parent_status || 'unapproved' == $parent_status ) ? $commentdata['comment_parent'] : 0;
|
||||
|
||||
$parent_status = ( $commentdata['comment_parent'] > 0 ) ? wp_get_comment_status( $commentdata['comment_parent'] ) : '';
|
||||
|
||||
$commentdata['comment_parent'] = ( 'approved' === $parent_status || 'unapproved' === $parent_status ) ? $commentdata['comment_parent'] : 0;
|
||||
|
||||
if ( ! isset( $commentdata['comment_author_IP'] ) ) {
|
||||
$commentdata['comment_author_IP'] = $_SERVER['REMOTE_ADDR'];
|
||||
@@ -2375,9 +2382,9 @@ function wp_update_comment( $commentarr ) {
|
||||
|
||||
if ( ! isset( $data['comment_approved'] ) ) {
|
||||
$data['comment_approved'] = 1;
|
||||
} elseif ( 'hold' == $data['comment_approved'] ) {
|
||||
} elseif ( 'hold' === $data['comment_approved'] ) {
|
||||
$data['comment_approved'] = 0;
|
||||
} elseif ( 'approve' == $data['comment_approved'] ) {
|
||||
} elseif ( 'approve' === $data['comment_approved'] ) {
|
||||
$data['comment_approved'] = 1;
|
||||
}
|
||||
|
||||
@@ -2800,7 +2807,7 @@ function generic_ping( $post_id = 0 ) {
|
||||
$services = explode( "\n", $services );
|
||||
foreach ( (array) $services as $service ) {
|
||||
$service = trim( $service );
|
||||
if ( '' != $service ) {
|
||||
if ( '' !== $service ) {
|
||||
weblog_ping( $service );
|
||||
}
|
||||
}
|
||||
@@ -2985,7 +2992,7 @@ function weblog_ping( $server = '', $path = '' ) {
|
||||
include_once ABSPATH . WPINC . '/class-wp-http-ixr-client.php';
|
||||
|
||||
// Using a timeout of 3 seconds should be enough to cover slow servers.
|
||||
$client = new WP_HTTP_IXR_Client( $server, ( ( ! strlen( trim( $path ) ) || ( '/' == $path ) ) ? false : $path ) );
|
||||
$client = new WP_HTTP_IXR_Client( $server, ( ( ! strlen( trim( $path ) ) || ( '/' === $path ) ) ? false : $path ) );
|
||||
$client->timeout = 3;
|
||||
$client->useragent .= ' -- WordPress/' . get_bloginfo( 'version' );
|
||||
|
||||
@@ -3266,7 +3273,7 @@ function wp_handle_comment_submission( $comment_data ) {
|
||||
// get_post_status() will get the parent status for attachments.
|
||||
$status = get_post_status( $post );
|
||||
|
||||
if ( ( 'private' == $status ) && ! current_user_can( 'read_post', $comment_post_ID ) ) {
|
||||
if ( ( 'private' === $status ) && ! current_user_can( 'read_post', $comment_post_ID ) ) {
|
||||
return new WP_Error( 'comment_id_not_found' );
|
||||
}
|
||||
|
||||
@@ -3285,7 +3292,7 @@ function wp_handle_comment_submission( $comment_data ) {
|
||||
|
||||
return new WP_Error( 'comment_closed', __( 'Sorry, comments are closed for this item.' ), 403 );
|
||||
|
||||
} elseif ( 'trash' == $status ) {
|
||||
} elseif ( 'trash' === $status ) {
|
||||
|
||||
/**
|
||||
* Fires when a comment is attempted on a trashed post.
|
||||
|
||||
Reference in New Issue
Block a user