Make WordPress Core

Ticket #45424: 45424.1.patch

File 45424.1.patch, 13.0 KB (added by allancole, 6 years ago)

General code quality and code documentation improvements. Original issue can be found on GitHub: https://github.com/WordPress/twentynineteen/pull/546

  • src/wp-content/themes/twentynineteen/archive.php

     
    2020                        <header class="page-header">
    2121                                <?php
    2222                                        the_archive_title( '<h1 class="page-title">', '</h1>' );
    23                                         // Remove for now @TODO
    24                                         // the_archive_description( '<div class="page-description">', '</div>' );
    2523                                ?>
    2624                        </header><!-- .page-header -->
    2725
  • src/wp-content/themes/twentynineteen/classes/class-twentynineteen-svg-icons.php

     
    205205                        'facebook.com',
    206206                        'fb.me',
    207207                ),
    208                 'feed'    => array(
     208                'feed'        => array(
    209209                        'feed',
    210210                ),
    211211                'google-plus' => array(
    212212                        'plus.google.com',
    213213                ),
    214                 'lastfm'   => array(
     214                'lastfm'      => array(
    215215                        'last.fm',
    216216                ),
    217                 'mail'   => array(
     217                'mail'        => array(
    218218                        'mailto:',
    219219                ),
    220220                'slideshare'  => array(
  • src/wp-content/themes/twentynineteen/functions.php

     
    263263
    264264        require_once get_parent_theme_file_path( '/inc/color-patterns.php' );
    265265
    266         if ( 'default' === get_theme_mod( 'primary_color', 'default' ) ) {
    267                 $primary_color = 199;
    268         } else {
    269                 $primary_color = absint( get_theme_mod( 'primary_color_hue', 199 ) );
     266        $primary_color = 199;
     267        if ( 'default' !== get_theme_mod( 'primary_color', 'default' ) ) {
     268                $primary_color = get_theme_mod( 'primary_color_hue', 199 );
    270269        }
    271270        ?>
    272271
    273         <style type="text/css" id="custom-theme-colors" <?php echo is_customize_preview() ? 'data-hue="' . $primary_color . '"' : ''; ?>>
     272        <style type="text/css" id="custom-theme-colors" <?php echo is_customize_preview() ? 'data-hue="' . absint( $primary_color ) . '"' : ''; ?>>
    274273                <?php echo twentynineteen_custom_colors_css(); ?>
    275274        </style>
    276275        <?php
  • src/wp-content/themes/twentynineteen/header.php

     
    3131
    3232                        <?php if ( is_singular() && twentynineteen_can_show_post_thumbnail() ) : ?>
    3333                                <div class="site-featured-image">
    34                                         <?php twentynineteen_post_thumbnail(); ?>
    35                                         <?php the_post(); ?>
    36                                         <?php $discussion = ! is_page() && twentynineteen_can_show_post_thumbnail() ? twentynineteen_get_discussion_data() : null; ?>
    37                                         <div class="<?php echo ( ! empty( $discussion ) && count( $discussion->responses ) > 0 ) ? 'entry-header has-discussion' : 'entry-header'; ?>">
     34                                        <?php
     35                                                twentynineteen_post_thumbnail();
     36                                                the_post();
     37                                                $discussion = ! is_page() && twentynineteen_can_show_post_thumbnail() ? twentynineteen_get_discussion_data() : null;
     38
     39                                                $classes = 'entry-header';
     40                                                if ( ! empty( $discussion ) && count( $discussion->responses ) > 0 ) {
     41                                                        $classes = 'entry-header has-discussion';
     42                                                }
     43                                        ?>
     44                                        <div class="<?php echo $classes; ?>">
    3845                                                <?php get_template_part( 'template-parts/header/entry', 'header' ); ?>
    3946                                        </div><!-- .entry-header -->
    4047                                        <?php rewind_posts(); ?>
  • src/wp-content/themes/twentynineteen/image.php

     
    4141                                                                echo wp_get_attachment_image( get_the_ID(), $image_size );
    4242                                                        ?>
    4343
    44                                                         <figcaption class="wp-caption-text"><?php echo get_the_excerpt(); ?></figcaption>
     44                                                        <figcaption class="wp-caption-text"><?php the_excerpt(); ?></figcaption>
    4545
    4646                                                </figure><!-- .entry-attachment -->
    4747
  • src/wp-content/themes/twentynineteen/inc/color-patterns.php

     
    1212 */
    1313function twentynineteen_custom_colors_css() {
    1414
    15         if ( 'default' === get_theme_mod( 'primary_color', 'default' ) ) {
    16                 $primary_color = 199;
    17         } else {
    18                 $primary_color = absint( get_theme_mod( 'primary_color_hue', 199 ) );
     15        $primary_color = 199;
     16        if ( 'default' !== get_theme_mod( 'primary_color', 'default' ) ) {
     17                $primary_color = absint( get_theme_mod( 'primary_color', 199 ) );
    1918        }
    2019
    2120        /**
     
    2524         *
    2625         * @param int $saturation Color saturation level.
    2726         */
     27        $saturation = apply_filters( 'twentynineteen_custom_colors_saturation', 100 );
     28        $saturation = absint( $saturation ) . '%';
    2829
    29         $saturation           = absint( apply_filters( 'twentynineteen_custom_colors_saturation', 100 ) );
    30         $saturation           = $saturation . '%';
    31 
     30        /**
     31         * Filter Twenty Nineteen default selection saturation level.
     32         *
     33         * @since Twenty Nineteen 1.0
     34         *
     35         * @param int $saturation_selection Selection color saturation level.
     36         */
    3237        $saturation_selection = absint( apply_filters( 'twentynineteen_custom_colors_saturation_selection', 50 ) );
    3338        $saturation_selection = $saturation_selection . '%';
    3439
    35         $lightness            = absint( apply_filters( 'twentynineteen_custom_colors_lightness', 33 ) );
    36         $lightness            = $lightness . '%';
     40        /**
     41         * Filter Twenty Nineteen default lightness level.
     42         *
     43         * @since Twenty Nineteen 1.0
     44         *
     45         * @param int $lightness Color lightness level.
     46         */
     47        $lightness = apply_filters( 'twentynineteen_custom_colors_lightness', 33 );
     48        $lightness = absint( $lightness ) . '%';
    3749
    38         $lightness_hover      = absint( apply_filters( 'twentynineteen_custom_colors_lightness_hover', 23 ) );
    39         $lightness_hover      = $lightness_hover . '%';
     50        /**
     51         * Filter Twenty Nineteen default hover lightness level.
     52         *
     53         * @since Twenty Nineteen 1.0
     54         *
     55         * @param int $lightness_hover Hover color lightness level.
     56         */
     57        $lightness_hover = apply_filters( 'twentynineteen_custom_colors_lightness_hover', 23 );
     58        $lightness_hover = absint( $lightness_hover ) . '%';
    4059
    41         $lightness_selection  = absint( apply_filters( 'twentynineteen_custom_colors_lightness_selection', 90 ) );
    42         $lightness_selection  = $lightness_selection . '%';
     60        /**
     61         * Filter Twenty Nineteen default selection lightness level.
     62         *
     63         * @since Twenty Nineteen 1.0
     64         *
     65         * @param int $lightness_selection Selection color lightness level.
     66         */
     67        $lightness_selection = apply_filters( 'twentynineteen_custom_colors_lightness_selection', 90 );
     68        $lightness_selection = absint( $lightness_selection ) . '%';
    4369
    4470        $theme_css = '
    4571                /*
     
    233259                        color: inherit;
    234260                }
    235261                ';
    236         $css = '';
     262
    237263        if ( function_exists( 'register_block_type' ) && is_admin() ) {
    238                 $css .= $editor_css;
    239         } else if ( ! is_admin() ) {
    240                 $css = $theme_css;
     264                $theme_css = $editor_css;
    241265        }
    242266
    243267        /**
     
    249273         * @param int    $primary_color The user's selected color hue.
    250274         * @param string $saturation    Filtered theme color saturation level.
    251275         */
    252         return apply_filters( 'twentynineteen_custom_colors_css', $css, $primary_color, $saturation );
     276        return apply_filters( 'twentynineteen_custom_colors_css', $theme_css, $primary_color, $saturation );
    253277}
  • src/wp-content/themes/twentynineteen/inc/customizer.php

     
    125125 * Bind JS handlers to instantly live-preview changes.
    126126 */
    127127function twentynineteen_customize_preview_js() {
    128         wp_enqueue_script( 'twentynineteen-customize-preview', get_theme_file_uri( '/js/customize-preview.js' ), array( 'customize-preview' ), '20151215', true );
     128        wp_enqueue_script( 'twentynineteen-customize-preview', get_theme_file_uri( '/js/customize-preview.js' ), array( 'customize-preview' ), '20181108', true );
    129129}
    130130add_action( 'customize_preview_init', 'twentynineteen_customize_preview_js' );
    131131
     
    133133 * Load dynamic logic for the customizer controls area.
    134134 */
    135135function twentynineteen_panels_js() {
    136         wp_enqueue_script( 'twentynineteen-customize-controls', get_theme_file_uri( '/js/customize-controls.js' ), array(), '1.0', true );
     136        wp_enqueue_script( 'twentynineteen-customize-controls', get_theme_file_uri( '/js/customize-controls.js' ), array(), '20181031', true );
    137137}
    138138add_action( 'customize_controls_enqueue_scripts', 'twentynineteen_panels_js' );
    139139
  • src/wp-content/themes/twentynineteen/inc/template-functions.php

     
    106106 * Returns true if image filters are enabled on the theme options.
    107107 */
    108108function twentynineteen_image_filters_enabled() {
    109         if ( get_theme_mod( 'image_filter', 1 ) ) {
    110                 return true;
    111         }
    112         return false;
     109        return 'inactive' !== get_theme_mod( 'image_filter', 1 );
    113110}
    114111
    115112/**
     
    418415
    419416                return "#$r$g$b";
    420417
    421         } else {
     418        }
    422419
    423                 return "rgb($r, $g, $b)";
    424         }
     420        return "rgb($r, $g, $b)";
    425421}
  • src/wp-content/themes/twentynineteen/inc/template-tags.php

     
    157157
    158158                <figure class="post-thumbnail">
    159159                        <a class="post-thumbnail-inner" href="<?php the_permalink(); ?>" aria-hidden="true" tabindex="-1">
    160                                 <?php
    161                                 the_post_thumbnail( 'post-thumbnail' );
    162                                 ?>
     160                                <?php the_post_thumbnail( 'post-thumbnail' ); ?>
    163161                        </a>
    164162                </figure>
    165163
     
    210208
    211209                        comment_form(
    212210                                array(
    213                                         'logged_in_as'       => null,
    214                                         'title_reply'        => null,
     211                                        'logged_in_as' => null,
     212                                        'title_reply'  => null,
    215213                                )
    216214                        );
    217215                }
     
    223221         * Documentation for function.
    224222         */
    225223        function twentynineteen_the_posts_navigation() {
    226                 $prev_icon = twentynineteen_get_icon_svg( 'chevron_left', 22 );
    227                 $next_icon = twentynineteen_get_icon_svg( 'chevron_right', 22 );
    228224                the_posts_pagination(
    229225                        array(
    230226                                'mid_size'  => 2,
    231                                 'prev_text' => sprintf( '%s <span class="nav-prev-text">%s</span>', $prev_icon, __( 'Newer posts', 'twentynineteen' ) ),
    232                                 'next_text' => sprintf( '<span class="nav-next-text">%s</span> %s', __( 'Older posts', 'twentynineteen' ), $next_icon ),
     227                                'prev_text' => sprintf(
     228                                        '%s <span class="nav-prev-text">%s</span>',
     229                                        twentynineteen_get_icon_svg( 'chevron_left', 22 ),
     230                                        __( 'Newer posts', 'twentynineteen' )
     231                                ),
     232                                'next_text' => sprintf(
     233                                        '<span class="nav-next-text">%s</span> %s',
     234                                        __( 'Older posts', 'twentynineteen' ),
     235                                        twentynineteen_get_icon_svg( 'chevron_right', 22 )
     236                                ),
    233237                        )
    234238                );
    235239        }
  • src/wp-content/themes/twentynineteen/index.php

     
    3939
    4040                }
    4141                ?>
    42                
     42
    4343                </main><!-- .site-main -->
    4444        </section><!-- .content-area -->
    4545
  • src/wp-content/themes/twentynineteen/sass/navigation/_menu-social-navigation.scss

     
    4545                                        width: 32px;
    4646                                        height: 32px;
    4747
     48                                        // Prevent icons from jumping in Safari using hardware acceleration.
     49                                        transform: translateZ(0);
     50
    4851                                        &#ui-icon-link {
    4952                                                transform: rotate(-45deg);
    5053                                        }
  • src/wp-content/themes/twentynineteen/style-rtl.css

     
    15921592  display: block;
    15931593  width: 32px;
    15941594  height: 32px;
     1595  transform: translateZ(0);
    15951596}
    15961597
    15971598.social-navigation ul.social-links-menu li a svg#ui-icon-link {
  • src/wp-content/themes/twentynineteen/style.css

     
    15921592  display: block;
    15931593  width: 32px;
    15941594  height: 32px;
     1595  transform: translateZ(0);
    15951596}
    15961597
    15971598.social-navigation ul.social-links-menu li a svg#ui-icon-link {