WordPress.org

Make WordPress Core


Ignore:
Timestamp:
05/16/2020 06:40:52 PM (11 months ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment-template.php

    r47506 r47808  
    194194
    195195    if ( ( ! empty( $email ) ) && ( '@' !== $email ) ) {
    196         $display = ( '' != $linktext ) ? $linktext : $email;
     196        $display = ( '' !== $linktext ) ? $linktext : $email;
    197197        $return  = $before;
    198198        $return .= sprintf( '<a href="%1$s">%2$s</a>', esc_url( 'mailto:' . $email ), esc_html( $display ) );
     
    222222    $author  = get_comment_author( $comment );
    223223
    224     if ( empty( $url ) || 'http://' == $url ) {
     224    if ( empty( $url ) || 'http://' === $url ) {
    225225        $return = $author;
    226226    } else {
     
    309309    $id      = 0;
    310310    if ( ! empty( $comment ) ) {
    311         $author_url = ( 'http://' == $comment->comment_author_url ) ? '' : $comment->comment_author_url;
     311        $author_url = ( 'http://' === $comment->comment_author_url ) ? '' : $comment->comment_author_url;
    312312        $url        = esc_url( $author_url, array( 'http', 'https' ) );
    313313        $id         = $comment->comment_ID;
     
    377377function get_comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 ) {
    378378    $url     = get_comment_author_url( $comment );
    379     $display = ( '' != $linktext ) ? $linktext : $url;
     379    $display = ( '' !== $linktext ) ? $linktext : $url;
    380380    $display = str_replace( 'http://www.', '', $display );
    381381    $display = str_replace( 'http://', '', $display );
    382382
    383     if ( '/' == substr( $display, -1 ) ) {
     383    if ( '/' === substr( $display, -1 ) ) {
    384384        $display = substr( $display, 0, -1 );
    385385    }
     
    551551function get_comment_date( $format = '', $comment_ID = 0 ) {
    552552    $comment = get_comment( $comment_ID );
    553     if ( '' == $format ) {
     553
     554    if ( '' === $format ) {
    554555        $date = mysql2date( get_option( 'date_format' ), $comment->comment_date );
    555556    } else {
    556557        $date = mysql2date( $format, $comment->comment_date );
    557558    }
     559
    558560    /**
    559561     * Filters the returned comment date.
     
    10381040
    10391041    $comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;
    1040     if ( '' == $format ) {
     1042
     1043    if ( '' === $format ) {
    10411044        $date = mysql2date( get_option( 'time_format' ), $comment_date, $translate );
    10421045    } else {
     
    10811084function get_comment_type( $comment_ID = 0 ) {
    10821085    $comment = get_comment( $comment_ID );
    1083     if ( '' == $comment->comment_type ) {
     1086
     1087    if ( '' === $comment->comment_type ) {
    10841088        $comment->comment_type = 'comment';
    10851089    }
     
    11421146 */
    11431147function get_trackback_url() {
    1144     if ( '' != get_option( 'permalink_structure' ) ) {
     1148    if ( get_option( 'permalink_structure' ) ) {
    11451149        $tb_url = trailingslashit( get_permalink() ) . user_trailingslashit( 'trackback', 'single_trackback' );
    11461150    } else {
     
    12361240
    12371241    $post_id = $_post ? $_post->ID : 0;
    1238     $open    = ( 'open' == $_post->comment_status );
     1242    $open    = ( 'open' === $_post->comment_status );
    12391243
    12401244    /**
     
    12661270
    12671271    $post_id = $_post ? $_post->ID : 0;
    1268     $open    = ( 'open' == $_post->ping_status );
     1272    $open    = ( 'open' === $_post->ping_status );
    12691273
    12701274    /**
     
    15061510
    15071511    $overridden_cpage = false;
     1512
    15081513    if ( '' == get_query_var( 'cpage' ) && $wp_query->max_num_comment_pages > 1 ) {
    1509         set_query_var( 'cpage', 'newest' == get_option( 'default_comments_page' ) ? get_comment_pages_count() : 1 );
     1514        set_query_var( 'cpage', 'newest' === get_option( 'default_comments_page' ) ? get_comment_pages_count() : 1 );
    15101515        $overridden_cpage = true;
    15111516    }
     
    15161521
    15171522    $theme_template = STYLESHEETPATH . $file;
     1523
    15181524    /**
    15191525     * Filters the path to the theme template file used for the comments template.
     
    15241530     */
    15251531    $include = apply_filters( 'comments_template', $theme_template );
     1532
    15261533    if ( file_exists( $include ) ) {
    15271534        require $include;
     
    20612068            return;
    20622069        }
    2063         if ( 'all' != $parsed_args['type'] ) {
     2070        if ( 'all' !== $parsed_args['type'] ) {
    20642071            $comments_by_type = separate_comments( $comments );
    20652072            if ( empty( $comments_by_type[ $parsed_args['type'] ] ) ) {
     
    21022109                $comments = get_comments( $comment_args );
    21032110
    2104                 if ( 'all' != $parsed_args['type'] ) {
     2111                if ( 'all' !== $parsed_args['type'] ) {
    21052112                    $comments_by_type = separate_comments( $comments );
    21062113                    if ( empty( $comments_by_type[ $parsed_args['type'] ] ) ) {
     
    21192126                return;
    21202127            }
    2121             if ( 'all' != $parsed_args['type'] ) {
     2128            if ( 'all' !== $parsed_args['type'] ) {
    21222129                if ( empty( $wp_query->comments_by_type ) ) {
    21232130                    $wp_query->comments_by_type = separate_comments( $wp_query->comments );
     
    21752182        } else {
    21762183            $threaded            = ( -1 != $parsed_args['max_depth'] );
    2177             $parsed_args['page'] = ( 'newest' == get_option( 'default_comments_page' ) ) ? get_comment_pages_count( $_comments, $parsed_args['per_page'], $threaded ) : 1;
     2184            $parsed_args['page'] = ( 'newest' === get_option( 'default_comments_page' ) ) ? get_comment_pages_count( $_comments, $parsed_args['per_page'], $threaded ) : 1;
    21782185            set_query_var( 'cpage', $parsed_args['page'] );
    21792186        }
     
    21862193
    21872194    if ( null === $parsed_args['reverse_top_level'] ) {
    2188         $parsed_args['reverse_top_level'] = ( 'desc' == get_option( 'comment_order' ) );
     2195        $parsed_args['reverse_top_level'] = ( 'desc' === get_option( 'comment_order' ) );
    21892196    }
    21902197
Note: See TracChangeset for help on using the changeset viewer.