Make WordPress Core


Ignore:
Timestamp:
02/09/2020 04:52:28 PM (7 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use Yoda conditions where appropriate.

See #49222.

File:
1 edited

Legend:

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

    r47122 r47219  
    143143        }
    144144
    145         if ( $post->post_type == 'page' ) {
     145        if ( 'page' === $post->post_type ) {
    146146                return get_page_link( $post, $leavename, $sample );
    147         } elseif ( $post->post_type == 'attachment' ) {
     147        } elseif ( 'attachment' === $post->post_type ) {
    148148                return get_attachment_link( $post, $leavename );
    149149        } elseif ( in_array( $post->post_type, get_post_types( array( '_builtin' => false ) ) ) ) {
    … …  
    333333        $post = get_post( $post );
    334334
    335         if ( 'page' == get_option( 'show_on_front' ) && $post->ID == get_option( 'page_on_front' ) ) {
     335        if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $post->ID ) {
    336336                $link = home_url( '/' );
    337337        } else {
    … …  
    423423
    424424        if ( $wp_rewrite->using_permalinks() && $parent ) {
    425                 if ( 'page' == $parent->post_type ) {
     425                if ( 'page' === $parent->post_type ) {
    426426                        $parentlink = _get_page_link( $post->post_parent ); // Ignores page_on_front.
    427427                } else {
    … …  
    683683
    684684        if ( '' != get_option( 'permalink_structure' ) ) {
    685                 if ( 'page' == get_option( 'show_on_front' ) && $post_id == get_option( 'page_on_front' ) ) {
     685                if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $post_id ) {
    686686                        $url = _get_page_link( $post_id );
    687687                } else {
    … …  
    691691                if ( $unattached ) {
    692692                        $url = home_url( '/feed/' );
    693                         if ( $feed !== get_default_feed() ) {
     693                        if ( get_default_feed() !== $feed ) {
    694694                                $url .= "$feed/";
    695695                        }
    … …  
    697697                } else {
    698698                        $url = trailingslashit( $url ) . 'feed';
    699                         if ( $feed != get_default_feed() ) {
     699                        if ( get_default_feed() != $feed ) {
    700700                                $url .= "/$feed";
    701701                        }
    … …  
    711711                                home_url( '/' )
    712712                        );
    713                 } elseif ( 'page' == $post->post_type ) {
     713                } elseif ( 'page' === $post->post_type ) {
    714714                        $url = add_query_arg(
    715715                                array(
    … …  
    799799        } else {
    800800                $link = get_author_posts_url( $author_id );
    801                 if ( $feed == get_default_feed() ) {
     801                if ( get_default_feed() == $feed ) {
    802802                        $feed_link = 'feed';
    803803                } else {
    … …  
    878878        } else {
    879879                $link = get_term_link( $term_id, $term->taxonomy );
    880                 if ( $feed == get_default_feed() ) {
     880                if ( get_default_feed() == $feed ) {
    881881                        $feed_link = 'feed';
    882882                } else {
    … …  
    12231223                $page_for_posts = get_option( 'page_for_posts' );
    12241224
    1225                 if ( 'page' == $show_on_front && $page_for_posts ) {
     1225                if ( 'page' === $show_on_front && $page_for_posts ) {
    12261226                        $link = get_permalink( $page_for_posts );
    12271227                } else {
    … …  
    36353635        if ( ! $scheme ) {
    36363636                $scheme = is_ssl() ? 'https' : 'http';
    3637         } elseif ( $scheme === 'admin' || $scheme === 'login' || $scheme === 'login_post' || $scheme === 'rpc' ) {
     3637        } elseif ( 'admin' === $scheme || 'login' === $scheme || 'login_post' === $scheme || 'rpc' === $scheme ) {
    36383638                $scheme = is_ssl() || force_ssl_admin() ? 'https' : 'http';
    3639         } elseif ( $scheme !== 'http' && $scheme !== 'https' && $scheme !== 'relative' ) {
     3639        } elseif ( 'http' !== $scheme && 'https' !== $scheme && 'relative' !== $scheme ) {
    36403640                $scheme = is_ssl() ? 'https' : 'http';
    36413641        }
    … …  
    36483648        if ( 'relative' == $scheme ) {
    36493649                $url = ltrim( preg_replace( '#^\w+://[^/]*#', '', $url ) );
    3650                 if ( $url !== '' && $url[0] === '/' ) {
     3650                if ( '' !== $url && '/' === $url[0] ) {
    36513651                        $url = '/' . ltrim( $url, "/ \t\n\r\0\x0B" );
    36523652                }
    … …  
    37803780
    37813781        // If a canonical is being generated for the current page, make sure it has pagination if needed.
    3782         if ( $post->ID === get_queried_object_id() ) {
     3782        if ( get_queried_object_id() === $post->ID ) {
    37833783                $page = get_query_var( 'page', 0 );
    37843784                if ( $page >= 2 ) {
    … …  
    38883888                $post_type = get_post_type_object( $post->post_type );
    38893889
    3890                 if ( 'page' === $post->post_type && $post->ID == get_option( 'page_on_front' ) && 'page' == get_option( 'show_on_front' ) ) {
     3890                if ( 'page' === $post->post_type && get_option( 'page_on_front' ) == $post->ID && 'page' === get_option( 'show_on_front' ) ) {
    38913891                        $shortlink = home_url( '/' );
    38923892                } elseif ( $post_type->public ) {
Note: See TracChangeset for help on using the changeset viewer.