Make WordPress Core


Ignore:
Timestamp:
07/02/2019 11:41:16 PM (6 years ago)
Author:
pento
Message:

Coding Standards: Fix the Squiz.PHP.DisallowMultipleAssignments violations in wp-includes.

See #47632.

File:
1 edited

Legend:

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

    r44966 r45590  
    2929
    3030// Process feeds and trackbacks even if not using themes.
    31 if ( is_robots() ) :
     31if ( is_robots() ) {
    3232    /**
    3333     * Fired when the template loader determines a robots.txt request.
     
    3737    do_action( 'do_robots' );
    3838    return;
    39 elseif ( is_feed() ) :
     39} elseif ( is_feed() ) {
    4040    do_feed();
    4141    return;
    42 elseif ( is_trackback() ) :
     42} elseif ( is_trackback() ) {
    4343    include( ABSPATH . 'wp-trackback.php' );
    4444    return;
    45 endif;
     45}
    4646
    47 if ( wp_using_themes() ) :
    48     $template = false;
    49     if ( is_embed() && $template = get_embed_template() ) :
    50     elseif ( is_404() && $template = get_404_template() ) :
    51     elseif ( is_search() && $template = get_search_template() ) :
    52     elseif ( is_front_page() && $template = get_front_page_template() ) :
    53     elseif ( is_home() && $template = get_home_template() ) :
    54     elseif ( is_privacy_policy() && $template = get_privacy_policy_template() ) :
    55     elseif ( is_post_type_archive() && $template = get_post_type_archive_template() ) :
    56     elseif ( is_tax() && $template = get_taxonomy_template() ) :
    57     elseif ( is_attachment() && $template = get_attachment_template() ) :
    58         remove_filter( 'the_content', 'prepend_attachment' );
    59     elseif ( is_single() && $template = get_single_template() ) :
    60     elseif ( is_page() && $template = get_page_template() ) :
    61     elseif ( is_singular() && $template = get_singular_template() ) :
    62     elseif ( is_category() && $template = get_category_template() ) :
    63     elseif ( is_tag() && $template = get_tag_template() ) :
    64     elseif ( is_author() && $template = get_author_template() ) :
    65     elseif ( is_date() && $template = get_date_template() ) :
    66     elseif ( is_archive() && $template = get_archive_template() ) :
    67     else :
     47if ( wp_using_themes() ) {
     48
     49    $tag_templates = array(
     50        'is_embed'             => 'get_embed_template',
     51        'is_404'               => 'get_404_template',
     52        'is_search'            => 'get_search_template',
     53        'is_front_page'        => 'get_front_page_template',
     54        'is_home'              => 'get_home_template',
     55        'is_privacy_policy'    => 'get_privacy_policy_template',
     56        'is_post_type_archive' => 'get_post_type_archive_template',
     57        'is_tax'               => 'get_taxonomy_template',
     58        'is_attachment'        => 'get_attachment_template',
     59        'is_single'            => 'get_single_template',
     60        'is_page'              => 'get_page_template',
     61        'is_singular'          => 'get_singular_template',
     62        'is_category'          => 'get_category_template',
     63        'is_tag'               => 'get_tag_template',
     64        'is_author'            => 'get_author_template',
     65        'is_date'              => 'get_date_template',
     66        'is_archive'           => 'get_archive_template',
     67    );
     68    $template      = false;
     69
     70    // Loop through each of the template conditionals, and find the appropriate template file.
     71    foreach ( $tag_templates as $tag => $template_getter ) {
     72        if ( call_user_func( $tag ) ) {
     73            $template = call_user_func( $template_getter );
     74        }
     75
     76        if ( $template ) {
     77            if ( 'is_attachment' === $tag ) {
     78                remove_filter( 'the_content', 'prepend_attachment' );
     79            }
     80
     81            break;
     82        }
     83    }
     84
     85    if ( ! $template ) {
    6886        $template = get_index_template();
    69     endif;
     87    }
     88
    7089    /**
    7190     * Filters the path of the current template before including it.
     
    7594     * @param string $template The path of the template to include.
    7695     */
    77     if ( $template = apply_filters( 'template_include', $template ) ) {
     96    $template = apply_filters( 'template_include', $template );
     97    if ( $template ) {
    7898        include( $template );
    7999    } elseif ( current_user_can( 'switch_themes' ) ) {
     
    84104    }
    85105    return;
    86 endif;
     106}
Note: See TracChangeset for help on using the changeset viewer.