Make WordPress Core

Changeset 39618


Ignore:
Timestamp:
12/16/2016 10:07:41 PM (8 years ago)
Author:
davidakennedy
Message:

Twenty Seventeen: Improves code readability and code standards in files

Adds better DocBlock comments and fixes some spacing issues based on PHP_CodeSniffer WordPress coding standards.

Props sstoqnov.

Fixes #39152.

Location:
trunk/src/wp-content/themes/twentyseventeen
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyseventeen/comments.php

    r39072 r39618  
    3131        <h2 class="comments-title">
    3232            <?php
    33                 $comments_number = get_comments_number();
    34                 if ( '1' === $comments_number ) {
    35                     /* translators: %s: post title */
    36                     printf( _x( 'One Reply to &ldquo;%s&rdquo;', 'comments title', 'twentyseventeen' ), get_the_title() );
    37                 } else {
    38                     printf(
    39                         /* translators: 1: number of comments, 2: post title */
    40                         _nx(
    41                             '%1$s Reply to &ldquo;%2$s&rdquo;',
    42                             '%1$s Replies to &ldquo;%2$s&rdquo;',
    43                             $comments_number,
    44                             'comments title',
    45                             'twentyseventeen'
    46                         ),
    47                         number_format_i18n( $comments_number ),
    48                         get_the_title()
    49                     );
    50                 }
     33            $comments_number = get_comments_number();
     34            if ( '1' === $comments_number ) {
     35                /* translators: %s: post title */
     36                printf( _x( 'One Reply to &ldquo;%s&rdquo;', 'comments title', 'twentyseventeen' ), get_the_title() );
     37            } else {
     38                printf(
     39                    /* translators: 1: number of comments, 2: post title */
     40                    _nx(
     41                        '%1$s Reply to &ldquo;%2$s&rdquo;',
     42                        '%1$s Replies to &ldquo;%2$s&rdquo;',
     43                        $comments_number,
     44                        'comments title',
     45                        'twentyseventeen'
     46                    ),
     47                    number_format_i18n( $comments_number ),
     48                    get_the_title()
     49                );
     50            }
    5151            ?>
    5252        </h2>
  • trunk/src/wp-content/themes/twentyseventeen/functions.php

    r39561 r39618  
    311311 * @since Twenty Seventeen 1.0
    312312 *
     313 * @param string $link Link to single post/page.
    313314 * @return string 'Continue reading' link prepended with an ellipsis.
    314315 */
  • trunk/src/wp-content/themes/twentyseventeen/inc/color-patterns.php

    r39413 r39618  
    9696.colors-custom .posts-navigation a,
    9797.colors-custom .widget_authors a strong {
    98     -webkit-box-shadow: inset 0 -1px 0 hsl( ' . $hue . ', ' . $saturation  . ', 6% ); /* base: rgba(15, 15, 15, 1); */
     98    -webkit-box-shadow: inset 0 -1px 0 hsl( ' . $hue . ', ' . $saturation . ', 6% ); /* base: rgba(15, 15, 15, 1); */
    9999    box-shadow: inset 0 -1px 0 hsl( ' . $hue . ', ' . $saturation . ', 6% ); /* base: rgba(15, 15, 15, 1); */
    100100}
     
    202202.colors-custom .widget ul li a:hover {
    203203    -webkit-box-shadow: inset 0 0 0 hsl( ' . $hue . ', ' . $saturation . ', 13% ), 0 3px 0 hsl( ' . $hue . ', ' . $saturation . ', 13% );
    204     box-shadow: inset 0 0 0 hsl( ' . $hue . ', ' . $saturation. ' , 13% ), 0 3px 0 hsl( ' . $hue . ', ' . $saturation . ', 13% );
     204    box-shadow: inset 0 0 0 hsl( ' . $hue . ', ' . $saturation . ' , 13% ), 0 3px 0 hsl( ' . $hue . ', ' . $saturation . ', 13% );
    205205}
    206206
     
    561561}';
    562562
    563 
    564563    /**
    565564     * Filters Twenty Seventeen custom colors CSS.
  • trunk/src/wp-content/themes/twentyseventeen/inc/custom-header.php

    r39447 r39618  
    112112/**
    113113 * Customize video play/pause button in the custom header.
     114 *
     115 * @param array $settings Video settings.
    114116 */
    115117function twentyseventeen_video_controls( $settings ) {
  • trunk/src/wp-content/themes/twentyseventeen/inc/customizer.php

    r39227 r39618  
    124124/**
    125125 * Sanitize the page layout options.
     126 *
     127 * @param string $input Page layout.
    126128 */
    127129function twentyseventeen_sanitize_page_layout( $input ) {
     
    140142/**
    141143 * Sanitize the colorscheme.
     144 *
     145 * @param string $input Color scheme.
    142146 */
    143147function twentyseventeen_sanitize_colorscheme( $input ) {
    144148    $valid = array( 'light', 'dark', 'custom' );
    145149
    146     if ( in_array( $input, $valid ) ) {
     150    if ( in_array( $input, $valid, true ) ) {
    147151        return $input;
    148152    }
  • trunk/src/wp-content/themes/twentyseventeen/inc/template-tags.php

    r39094 r39618  
    129129 * Display a front page section.
    130130 *
    131  * @param $partial WP_Customize_Partial Partial associated with a selective refresh request.
    132  * @param $id integer Front page section to display.
     131 * @param WP_Customize_Partial $partial Partial associated with a selective refresh request.
     132 * @param integer              $id Front page section to display.
    133133 */
    134134function twentyseventeen_front_page_section( $partial = null, $id = 0 ) {
  • trunk/src/wp-content/themes/twentyseventeen/searchform.php

    r38833 r39618  
    88 * @version 1.0
    99 */
     10
    1011?>
    1112
  • trunk/src/wp-content/themes/twentyseventeen/single.php

    r39072 r39618  
    1818
    1919            <?php
    20                 /* Start the Loop */
    21                 while ( have_posts() ) : the_post();
     20            /* Start the Loop */
     21            while ( have_posts() ) : the_post();
    2222
    23                     get_template_part( 'template-parts/post/content', get_post_format() );
     23                get_template_part( 'template-parts/post/content', get_post_format() );
    2424
    25                     // If comments are open or we have at least one comment, load up the comment template.
    26                     if ( comments_open() || get_comments_number() ) :
    27                         comments_template();
    28                     endif;
     25                // If comments are open or we have at least one comment, load up the comment template.
     26                if ( comments_open() || get_comments_number() ) :
     27                    comments_template();
     28                endif;
    2929
    30                     the_post_navigation( array(
    31                         'prev_text' => '<span class="screen-reader-text">' . __( 'Previous Post', 'twentyseventeen' ) . '</span><span aria-hidden="true" class="nav-subtitle">' . __( 'Previous', 'twentyseventeen' ) . '</span> <span class="nav-title"><span class="nav-title-icon-wrapper">' . twentyseventeen_get_svg( array( 'icon' => 'arrow-left' ) ) . '</span>%title</span>',
    32                         'next_text' => '<span class="screen-reader-text">' . __( 'Next Post', 'twentyseventeen' ) . '</span><span aria-hidden="true" class="nav-subtitle">' . __( 'Next', 'twentyseventeen' ) . '</span> <span class="nav-title">%title<span class="nav-title-icon-wrapper">' . twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ) . '</span></span>',
    33                     ) );
     30                the_post_navigation( array(
     31                    'prev_text' => '<span class="screen-reader-text">' . __( 'Previous Post', 'twentyseventeen' ) . '</span><span aria-hidden="true" class="nav-subtitle">' . __( 'Previous', 'twentyseventeen' ) . '</span> <span class="nav-title"><span class="nav-title-icon-wrapper">' . twentyseventeen_get_svg( array( 'icon' => 'arrow-left' ) ) . '</span>%title</span>',
     32                    'next_text' => '<span class="screen-reader-text">' . __( 'Next Post', 'twentyseventeen' ) . '</span><span aria-hidden="true" class="nav-subtitle">' . __( 'Next', 'twentyseventeen' ) . '</span> <span class="nav-title">%title<span class="nav-title-icon-wrapper">' . twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ) . '</span></span>',
     33                ) );
    3434
    35                 endwhile; // End of the loop.
     35            endwhile; // End of the loop.
    3636            ?>
    3737
  • trunk/src/wp-content/themes/twentyseventeen/template-parts/header/site-branding.php

    r39384 r39618  
    2222            <?php endif; ?>
    2323
    24             <?php $description = get_bloginfo( 'description', 'display' );
    25                 if ( $description || is_customize_preview() ) : ?>
    26                     <p class="site-description"><?php echo $description; ?></p>
    27                 <?php endif; ?>
     24            <?php
     25            $description = get_bloginfo( 'description', 'display' );
     26
     27            if ( $description || is_customize_preview() ) :
     28            ?>
     29                <p class="site-description"><?php echo $description; ?></p>
     30            <?php endif; ?>
    2831        </div><!-- .site-branding-text -->
    2932
  • trunk/src/wp-content/themes/twentyseventeen/template-parts/navigation/navigation-top.php

    r39384 r39618  
    1111?>
    1212<nav id="site-navigation" class="main-navigation" role="navigation" aria-label="<?php _e( 'Top Menu', 'twentyseventeen' ); ?>">
    13     <button class="menu-toggle" aria-controls="top-menu" aria-expanded="false"><?php echo twentyseventeen_get_svg( array( 'icon' => 'bars' ) ); echo twentyseventeen_get_svg( array( 'icon' => 'close' ) ); _e( 'Menu', 'twentyseventeen' ); ?></button>
     13    <button class="menu-toggle" aria-controls="top-menu" aria-expanded="false">
     14        <?php
     15        echo twentyseventeen_get_svg( array( 'icon' => 'bars' ) );
     16        echo twentyseventeen_get_svg( array( 'icon' => 'close' ) );
     17        _e( 'Menu', 'twentyseventeen' );
     18        ?>
     19    </button>
     20
    1421    <?php wp_nav_menu( array(
    1522        'theme_location' => 'top',
  • trunk/src/wp-content/themes/twentyseventeen/template-parts/post/content-audio.php

    r39146 r39618  
    1515<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    1616    <?php
    17         if ( is_sticky() && is_home() ) :
     17        if ( is_sticky() && is_home() ) {
    1818            echo twentyseventeen_get_svg( array( 'icon' => 'thumb-tack' ) );
    19         endif;
     19        }
    2020    ?>
    2121    <header class="entry-header">
    2222        <?php
    23             if ( 'post' === get_post_type() ) :
     23            if ( 'post' === get_post_type() ) {
    2424                echo '<div class="entry-meta">';
    25                     if ( is_single() ) :
     25                    if ( is_single() ) {
    2626                        twentyseventeen_posted_on();
    27                     else :
     27                    } else {
    2828                        echo twentyseventeen_time_link();
    2929                        twentyseventeen_edit_link();
    30                     endif;
     30                    };
    3131                echo '</div><!-- .entry-meta -->';
    32             endif;
     32            };
    3333
    3434            if ( is_single() ) {
     
    6161    <div class="entry-content">
    6262
    63         <?php if ( ! is_single() ) :
     63        <?php
     64        if ( ! is_single() ) {
    6465
    6566            // If not a single post, highlight the audio file.
    66             if ( ! empty( $audio ) ) :
     67            if ( ! empty( $audio ) ) {
    6768                foreach ( $audio as $audio_html ) {
    6869                    echo '<div class="entry-audio">';
     
    7071                    echo '</div><!-- .entry-audio -->';
    7172                }
    72             endif;
     73            };
    7374
    74         endif;
     75        };
    7576
    76         if ( is_single() || empty( $audio ) ) :
     77        if ( is_single() || empty( $audio ) ) {
    7778
    7879            /* translators: %s: Name of current post */
     
    8990            ) );
    9091
    91         endif; ?>
     92        };
     93        ?>
    9294
    9395    </div><!-- .entry-content -->
    9496
    95     <?php if ( is_single() ) : ?>
    96         <?php twentyseventeen_entry_footer(); ?>
    97     <?php endif; ?>
     97    <?php
     98    if ( is_single() ) {
     99        twentyseventeen_entry_footer();
     100    }
     101    ?>
    98102
    99103</article><!-- #post-## -->
  • trunk/src/wp-content/themes/twentyseventeen/template-parts/post/content-excerpt.php

    r38833 r39618  
    2121            <div class="entry-meta">
    2222                <?php
    23                     echo twentyseventeen_time_link();
    24                     twentyseventeen_edit_link();
     23                echo twentyseventeen_time_link();
     24                twentyseventeen_edit_link();
    2525                ?>
    2626            </div><!-- .entry-meta -->
  • trunk/src/wp-content/themes/twentyseventeen/template-parts/post/content-gallery.php

    r39072 r39618  
    1010 * @version 1.0
    1111 */
     12
    1213?>
    1314
    1415<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    1516    <?php
    16         if ( is_sticky() && is_home() ) :
    17             echo twentyseventeen_get_svg( array( 'icon' => 'thumb-tack' ) );
    18         endif;
     17    if ( is_sticky() && is_home() ) {
     18        echo twentyseventeen_get_svg( array( 'icon' => 'thumb-tack' ) );
     19    }
    1920    ?>
    2021    <header class="entry-header">
    2122        <?php
    22             if ( 'post' === get_post_type() ) :
    23                 echo '<div class="entry-meta">';
    24                     if ( is_single() ) :
    25                         twentyseventeen_posted_on();
    26                     else :
    27                         echo twentyseventeen_time_link();
    28                         twentyseventeen_edit_link();
    29                     endif;
    30                 echo '</div><!-- .entry-meta -->';
    31             endif;
     23        if ( 'post' === get_post_type() ) {
     24            echo '<div class="entry-meta">';
     25                if ( is_single() ) {
     26                    twentyseventeen_posted_on();
     27                } else {
     28                    echo twentyseventeen_time_link();
     29                    twentyseventeen_edit_link();
     30                };
     31            echo '</div><!-- .entry-meta -->';
     32        };
    3233
    33             if ( is_single() ) {
    34                 the_title( '<h1 class="entry-title">', '</h1>' );
    35             } else {
    36                 the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
    37             }
     34        if ( is_single() ) {
     35            the_title( '<h1 class="entry-title">', '</h1>' );
     36        } else {
     37            the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
     38        }
    3839        ?>
    3940    </header><!-- .entry-header -->
     
    4950    <div class="entry-content">
    5051
    51         <?php if ( ! is_single() ) :
     52        <?php
     53        if ( ! is_single() ) {
    5254
    5355            // If not a single post, highlight the gallery.
    54             if ( get_post_gallery() ) :
     56            if ( get_post_gallery() ) {
    5557                echo '<div class="entry-gallery">';
    5658                    echo get_post_gallery();
    5759                echo '</div>';
    58             endif;
     60            };
    5961
    60         endif;
     62        };
    6163
    62         if ( is_single() || ! get_post_gallery() ) :
     64        if ( is_single() || ! get_post_gallery() ) {
    6365
    6466            /* translators: %s: Name of current post */
     
    7577            ) );
    7678
    77         endif; ?>
     79        };
     80        ?>
    7881
    7982    </div><!-- .entry-content -->
    8083
    81     <?php if ( is_single() ) : ?>
    82         <?php twentyseventeen_entry_footer(); ?>
    83     <?php endif; ?>
     84    <?php
     85    if ( is_single() ) {
     86        twentyseventeen_entry_footer();
     87    }
     88    ?>
    8489
    8590</article><!-- #post-## -->
  • trunk/src/wp-content/themes/twentyseventeen/template-parts/post/content-image.php

    r39072 r39618  
    1010 * @version 1.0
    1111 */
     12
    1213?>
    1314
    1415<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    1516    <?php
    16         if ( is_sticky() && is_home() ) :
     17        if ( is_sticky() && is_home() ) {
    1718            echo twentyseventeen_get_svg( array( 'icon' => 'thumb-tack' ) );
    18         endif;
     19        }
    1920    ?>
    2021    <header class="entry-header">
    2122        <?php
    22             if ( 'post' === get_post_type() ) :
     23            if ( 'post' === get_post_type() ) {
    2324                echo '<div class="entry-meta">';
    24                     if ( is_single() ) :
     25                    if ( is_single() ) {
    2526                        twentyseventeen_posted_on();
    26                     else :
     27                    } else {
    2728                        echo twentyseventeen_time_link();
    2829                        twentyseventeen_edit_link();
    29                     endif;
     30                    };
    3031                echo '</div><!-- .entry-meta -->';
    31             endif;
     32            };
    3233
    3334            if ( is_single() ) {
     
    4950    <div class="entry-content">
    5051
    51         <?php if ( is_single() || '' === get_the_post_thumbnail() ) :
     52        <?php if ( is_single() || '' === get_the_post_thumbnail() ) {
    5253
    5354            // Only show content if is a single post, or if there's no featured image.
     
    6566            ) );
    6667
    67         endif; ?>
     68        };
     69        ?>
    6870
    6971    </div><!-- .entry-content -->
    7072
    71     <?php if ( is_single() ) : ?>
    72         <?php twentyseventeen_entry_footer(); ?>
    73     <?php endif; ?>
     73    <?php
     74    if ( is_single() ) {
     75        twentyseventeen_entry_footer();
     76    }
     77    ?>
    7478
    7579</article><!-- #post-## -->
  • trunk/src/wp-content/themes/twentyseventeen/template-parts/post/content-video.php

    r39146 r39618  
    1010 * @version 1.0
    1111 */
     12
    1213?>
    1314
    1415<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    1516    <?php
    16         if ( is_sticky() && is_home() ) :
     17        if ( is_sticky() && is_home() ) {
    1718            echo twentyseventeen_get_svg( array( 'icon' => 'thumb-tack' ) );
    18         endif;
     19        }
    1920    ?>
    2021    <header class="entry-header">
    2122        <?php
    22             if ( 'post' === get_post_type() ) :
     23            if ( 'post' === get_post_type() ) {
    2324                echo '<div class="entry-meta">';
    24                     if ( is_single() ) :
     25                    if ( is_single() ) {
    2526                        twentyseventeen_posted_on();
    26                     else :
     27                    } else {
    2728                        echo twentyseventeen_time_link();
    2829                        twentyseventeen_edit_link();
    29                     endif;
     30                    }
    3031                echo '</div><!-- .entry-meta -->';
    31             endif;
     32            };
    3233
    3334            if ( is_single() ) {
     
    5960    <div class="entry-content">
    6061
    61         <?php if ( ! is_single() ) :
     62        <?php
     63        if ( ! is_single() ) {
    6264
    6365            // If not a single post, highlight the video file.
    64             if ( ! empty( $video ) ) :
     66            if ( ! empty( $video ) ) {
    6567                foreach ( $video as $video_html ) {
    6668                    echo '<div class="entry-video">';
     
    6870                    echo '</div>';
    6971                }
    70             endif;
     72            };
    7173
    72         endif;
     74        };
    7375
    74         if ( is_single() || empty( $video ) ) :
     76        if ( is_single() || empty( $video ) ) {
    7577
    7678            /* translators: %s: Name of current post */
     
    8688                'link_after'  => '</span>',
    8789            ) );
    88 
    89         endif; ?>
     90        };
     91        ?>
    9092
    9193    </div><!-- .entry-content -->
    9294
    93     <?php if ( is_single() ) : ?>
    94         <?php twentyseventeen_entry_footer(); ?>
    95     <?php endif; ?>
     95    <?php
     96    if ( is_single() ) {
     97        twentyseventeen_entry_footer();
     98    }
     99    ?>
    96100
    97101</article><!-- #post-## -->
  • trunk/src/wp-content/themes/twentyseventeen/template-parts/post/content.php

    r39072 r39618  
    1515<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    1616    <?php
    17         if ( is_sticky() && is_home() ) :
    18             echo twentyseventeen_get_svg( array( 'icon' => 'thumb-tack' ) );
    19         endif;
     17    if ( is_sticky() && is_home() ) :
     18        echo twentyseventeen_get_svg( array( 'icon' => 'thumb-tack' ) );
     19    endif;
    2020    ?>
    2121    <header class="entry-header">
    2222        <?php
    23             if ( 'post' === get_post_type() ) :
    24                 echo '<div class="entry-meta">';
    25                     if ( is_single() ) :
    26                         twentyseventeen_posted_on();
    27                     else :
    28                         echo twentyseventeen_time_link();
    29                         twentyseventeen_edit_link();
    30                     endif;
    31                 echo '</div><!-- .entry-meta -->';
    32             endif;
     23        if ( 'post' === get_post_type() ) {
     24            echo '<div class="entry-meta">';
     25                if ( is_single() ) {
     26                    twentyseventeen_posted_on();
     27                } else {
     28                    echo twentyseventeen_time_link();
     29                    twentyseventeen_edit_link();
     30                };
     31            echo '</div><!-- .entry-meta -->';
     32        };
    3333
    34             if ( is_single() ) {
    35                 the_title( '<h1 class="entry-title">', '</h1>' );
    36             } else {
    37                 the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
    38             }
     34        if ( is_single() ) {
     35            the_title( '<h1 class="entry-title">', '</h1>' );
     36        } else {
     37            the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
     38        }
    3939        ?>
    4040    </header><!-- .entry-header -->
     
    5050    <div class="entry-content">
    5151        <?php
    52             /* translators: %s: Name of current post */
    53             the_content( sprintf(
    54                 __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ),
    55                 get_the_title()
    56             ) );
     52        /* translators: %s: Name of current post */
     53        the_content( sprintf(
     54            __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ),
     55            get_the_title()
     56        ) );
    5757
    58             wp_link_pages( array(
    59                 'before'      => '<div class="page-links">' . __( 'Pages:', 'twentyseventeen' ),
    60                 'after'       => '</div>',
    61                 'link_before' => '<span class="page-number">',
    62                 'link_after'  => '</span>',
    63             ) );
     58        wp_link_pages( array(
     59            'before'      => '<div class="page-links">' . __( 'Pages:', 'twentyseventeen' ),
     60            'after'       => '</div>',
     61            'link_before' => '<span class="page-number">',
     62            'link_after'  => '</span>',
     63        ) );
    6464        ?>
    6565    </div><!-- .entry-content -->
    6666
    67     <?php if ( is_single() ) : ?>
    68         <?php twentyseventeen_entry_footer(); ?>
    69     <?php endif; ?>
     67    <?php
     68    if ( is_single() ) {
     69        twentyseventeen_entry_footer();
     70    }
     71    ?>
    7072
    7173</article><!-- #post-## -->
Note: See TracChangeset for help on using the changeset viewer.