Make WordPress Core


Ignore:
Timestamp:
05/16/2020 06:40:52 PM (5 years 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/link-template.php

    r47557 r47808  
    132132    );
    133133
    134     if ( is_object( $post ) && isset( $post->filter ) && 'sample' == $post->filter ) {
     134    if ( is_object( $post ) && isset( $post->filter ) && 'sample' === $post->filter ) {
    135135        $sample = true;
    136136    } else {
     
    166166    $permalink = apply_filters( 'pre_post_link', $permalink, $post, $leavename );
    167167
    168     if ( '' != $permalink && ! in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft', 'future' ), true ) ) {
     168    if ( $permalink && ! in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft', 'future' ), true ) ) {
    169169
    170170        $category = '';
     
    621621
    622622    $permalink = $wp_rewrite->get_feed_permastruct();
    623     if ( '' != $permalink ) {
     623
     624    if ( '' !== $permalink ) {
    624625        if ( false !== strpos( $feed, 'comments_' ) ) {
    625626            $feed      = str_replace( 'comments_', '', $feed );
     
    682683    $unattached = 'attachment' === $post->post_type && 0 === (int) $post->post_parent;
    683684
    684     if ( '' != get_option( 'permalink_structure' ) ) {
     685    if ( get_option( 'permalink_structure' ) ) {
    685686        if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $post_id ) {
    686687            $url = _get_page_link( $post_id );
     
    795796    }
    796797
    797     if ( '' == $permalink_structure ) {
     798    if ( ! $permalink_structure ) {
    798799        $link = home_url( "?feed=$feed&author=" . $author_id );
    799800    } else {
     
    867868    $permalink_structure = get_option( 'permalink_structure' );
    868869
    869     if ( '' == $permalink_structure ) {
    870         if ( 'category' == $taxonomy ) {
     870    if ( ! $permalink_structure ) {
     871        if ( 'category' === $taxonomy ) {
    871872            $link = home_url( "?feed=$feed&cat=$term_id" );
    872         } elseif ( 'post_tag' == $taxonomy ) {
     873        } elseif ( 'post_tag' === $taxonomy ) {
    873874            $link = home_url( "?feed=$feed&tag=$term->slug" );
    874875        } else {
     
    887888    }
    888889
    889     if ( 'category' == $taxonomy ) {
     890    if ( 'category' === $taxonomy ) {
    890891        /**
    891892         * Filters the category feed link.
     
    897898         */
    898899        $link = apply_filters( 'category_feed_link', $link, $feed );
    899     } elseif ( 'post_tag' == $taxonomy ) {
     900    } elseif ( 'post_tag' === $taxonomy ) {
    900901        /**
    901902         * Filters the post tag feed link.
     
    13651366    if ( 'revision' === $post->post_type ) {
    13661367        $action = '';
    1367     } elseif ( 'display' == $context ) {
     1368    } elseif ( 'display' === $context ) {
    13681369        $action = '&action=edit';
    13691370    } else {
     
    22692270        $base = trailingslashit( get_bloginfo( 'url' ) );
    22702271
    2271         if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' != $request ) ) {
     2272        if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' !== $request ) ) {
    22722273            $base .= $wp_rewrite->index . '/';
    22732274        }
     
    27292730
    27302731        // Make sure we get a string back. Plain is the next best thing.
    2731         if ( isset( $args['type'] ) && 'array' == $args['type'] ) {
     2732        if ( isset( $args['type'] ) && 'array' === $args['type'] ) {
    27322733            $args['type'] = 'plain';
    27332734        }
     
    28242825    $result = get_permalink();
    28252826
    2826     if ( 'newest' == get_option( 'default_comments_page' ) ) {
     2827    if ( 'newest' === get_option( 'default_comments_page' ) ) {
    28272828        if ( $pagenum != $max_page ) {
    28282829            if ( $wp_rewrite->using_permalinks() ) {
     
    31113112
    31123113    // Make sure we get a string back. Plain is the next best thing.
    3113     if ( isset( $args['type'] ) && 'array' == $args['type'] ) {
     3114    if ( isset( $args['type'] ) && 'array' === $args['type'] ) {
    31143115        $args['type'] = 'plain';
    31153116    }
     
    34063407    if ( ! empty( $plugin ) && is_string( $plugin ) ) {
    34073408        $folder = dirname( plugin_basename( $plugin ) );
    3408         if ( '.' != $folder ) {
     3409        if ( '.' !== $folder ) {
    34093410            $url .= '/' . ltrim( $folder, '/' );
    34103411        }
     
    34523453    $current_network = get_network();
    34533454
    3454     if ( 'relative' == $scheme ) {
     3455    if ( 'relative' === $scheme ) {
    34553456        $url = $current_network->path;
    34563457    } else {
     
    35023503    }
    35033504
    3504     if ( 'relative' == $scheme ) {
     3505    if ( 'relative' === $scheme ) {
    35053506        $url = $current_network->path;
    35063507    } else {
     
    36463647    }
    36473648
    3648     if ( 'relative' == $scheme ) {
     3649    if ( 'relative' === $scheme ) {
    36493650        $url = ltrim( preg_replace( '#^\w+://[^/]*#', '', $url ) );
    36503651        if ( '' !== $url && '/' === $url[0] ) {
     
    37853786        $page = get_query_var( 'page', 0 );
    37863787        if ( $page >= 2 ) {
    3787             if ( '' == get_option( 'permalink_structure' ) ) {
     3788            if ( ! get_option( 'permalink_structure' ) ) {
    37883789                $canonical_url = add_query_arg( 'page', $page, $canonical_url );
    37893790            } else {
     
    38743875
    38753876    $post_id = 0;
    3876     if ( 'query' == $context && is_singular() ) {
     3877    if ( 'query' === $context && is_singular() ) {
    38773878        $post_id = get_queried_object_id();
    38783879        $post    = get_post( $post_id );
    3879     } elseif ( 'post' == $context ) {
     3880    } elseif ( 'post' === $context ) {
    38803881        $post = get_post( $id );
    38813882        if ( ! empty( $post->ID ) ) {
Note: See TracChangeset for help on using the changeset viewer.