Make WordPress Core


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

    r47550 r47808  
    156156
    157157        $thelist = '';
    158         if ( '' == $separator ) {
     158        if ( '' === $separator ) {
    159159                $thelist .= '<ul class="post-categories">';
    160160                foreach ( $categories as $category ) {
    … …  
    352352
    353353        // Back compat.
    354         if ( isset( $args['type'] ) && 'link' == $args['type'] ) {
     354        if ( isset( $args['type'] ) && 'link' === $args['type'] ) {
    355355                _deprecated_argument(
    356356                        __FUNCTION__,
    … …  
    560560
    561561        if ( ! isset( $parsed_args['class'] ) ) {
    562                 $parsed_args['class'] = ( 'category' == $parsed_args['taxonomy'] ) ? 'categories' : $parsed_args['taxonomy'];
     562                $parsed_args['class'] = ( 'category' === $parsed_args['taxonomy'] ) ? 'categories' : $parsed_args['taxonomy'];
    563563        }
    564564
    … …  
    573573
    574574        $output = '';
    575         if ( $parsed_args['title_li'] && 'list' == $parsed_args['style'] && ( ! empty( $categories ) || ! $parsed_args['hide_title_if_empty'] ) ) {
     575
     576        if ( $parsed_args['title_li'] && 'list' === $parsed_args['style']
     577                && ( ! empty( $categories ) || ! $parsed_args['hide_title_if_empty'] )
     578        ) {
    576579                $output = '<li class="' . esc_attr( $parsed_args['class'] ) . '">' . $parsed_args['title_li'] . '<ul>';
    577580        }
     581
    578582        if ( empty( $categories ) ) {
    579583                if ( ! empty( $show_option_none ) ) {
    580                         if ( 'list' == $parsed_args['style'] ) {
     584                        if ( 'list' === $parsed_args['style'] ) {
    581585                                $output .= '<li class="cat-item-none">' . $show_option_none . '</li>';
    582586                        } else {
    … …  
    605609                        // Fallback for the 'All' link is the posts page.
    606610                        if ( ! $posts_page ) {
    607                                 if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) ) {
     611                                if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) ) {
    608612                                        $posts_page = get_permalink( get_option( 'page_for_posts' ) );
    609613                                } else {
    … …  
    613617
    614618                        $posts_page = esc_url( $posts_page );
    615                         if ( 'list' == $parsed_args['style'] ) {
     619                        if ( 'list' === $parsed_args['style'] ) {
    616620                                $output .= "<li class='cat-item-all'><a href='$posts_page'>$show_option_all</a></li>";
    617621                        } else {
    … …  
    635639        }
    636640
    637         if ( $parsed_args['title_li'] && 'list' == $parsed_args['style'] && ( ! empty( $categories ) || ! $parsed_args['hide_title_if_empty'] ) ) {
     641        if ( $parsed_args['title_li'] && 'list' === $parsed_args['style']
     642                && ( ! empty( $categories ) || ! $parsed_args['hide_title_if_empty'] )
     643        ) {
    638644                $output .= '</ul></li>';
    639645        }
    … …  
    714720
    715721        foreach ( $tags as $key => $tag ) {
    716                 if ( 'edit' == $args['link'] ) {
     722                if ( 'edit' === $args['link'] ) {
    717723                        $link = get_edit_term_link( $tag->term_id, $tag->taxonomy, $args['post_type'] );
    718724                } else {
    … …  
    741747        $return = apply_filters( 'wp_tag_cloud', $return, $args );
    742748
    743         if ( 'array' == $args['format'] || empty( $args['echo'] ) ) {
     749        if ( 'array' === $args['format'] || empty( $args['echo'] ) ) {
    744750                return $return;
    745751        }
    … …  
    940946                $tags_data[] = array(
    941947                        'id'              => $tag_id,
    942                         'url'             => '#' != $tag->link ? $tag->link : '#',
    943                         'role'            => '#' != $tag->link ? '' : ' role="button"',
     948                        'url'             => ( '#' !== $tag->link ) ? $tag->link : '#',
     949                        'role'            => ( '#' !== $tag->link ) ? '' : ' role="button"',
    944950                        'name'            => $tag->name,
    945951                        'formatted_count' => $formatted_count,
Note: See TracChangeset for help on using the changeset viewer.