Skip to content
Permalink
Browse files

Updating Twenty Nineteen, the new default theme for 2019.

This change adds general code quality and documentation improvements. 

- More info here: WordPress/twentynineteen#546

Props grapplerulrich, iCaleb.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@44187 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information...
allancole
allancole committed Dec 14, 2018
1 parent 5ddf67a commit 49d906cc9646d88b3396f88549e7225dff75e000
@@ -20,8 +20,6 @@
<header class="page-header">
<?php
the_archive_title( '<h1 class="page-title">', '</h1>' );
// Remove for now @TODO
// the_archive_description( '<div class="page-description">', '</div>' );
?>
</header><!-- .page-header -->

@@ -205,16 +205,16 @@ public static function get_social_link_svg( $uri, $size ) {
'facebook.com',
'fb.me',
),
'feed' => array(
'feed' => array(
'feed',
),
'google-plus' => array(
'plus.google.com',
),
'lastfm' => array(
'lastfm' => array(
'last.fm',
),
'mail' => array(
'mail' => array(
'mailto:',
),
'slideshare' => array(
@@ -263,14 +263,13 @@ function twentynineteen_colors_css_wrap() {
require_once get_parent_theme_file_path( '/inc/color-patterns.php' );
if ( 'default' === get_theme_mod( 'primary_color', 'default' ) ) {
$primary_color = 199;
} else {
$primary_color = absint( get_theme_mod( 'primary_color_hue', 199 ) );
$primary_color = 199;
if ( 'default' !== get_theme_mod( 'primary_color', 'default' ) ) {
$primary_color = get_theme_mod( 'primary_color_hue', 199 );
}
?>

<style type="text/css" id="custom-theme-colors" <?php echo is_customize_preview() ? 'data-hue="' . $primary_color . '"' : ''; ?>>
<style type="text/css" id="custom-theme-colors" <?php echo is_customize_preview() ? 'data-hue="' . absint( $primary_color ) . '"' : ''; ?>>
<?php echo twentynineteen_custom_colors_css(); ?>
</style>
<?php
@@ -31,10 +31,17 @@

<?php if ( is_singular() && twentynineteen_can_show_post_thumbnail() ) : ?>
<div class="site-featured-image">
<?php twentynineteen_post_thumbnail(); ?>
<?php the_post(); ?>
<?php $discussion = ! is_page() && twentynineteen_can_show_post_thumbnail() ? twentynineteen_get_discussion_data() : null; ?>
<div class="<?php echo ( ! empty( $discussion ) && count( $discussion->responses ) > 0 ) ? 'entry-header has-discussion' : 'entry-header'; ?>">
<?php
twentynineteen_post_thumbnail();
the_post();
$discussion = ! is_page() && twentynineteen_can_show_post_thumbnail() ? twentynineteen_get_discussion_data() : null;
$classes = 'entry-header';
if ( ! empty( $discussion ) && count( $discussion->responses ) > 0 ) {
$classes = 'entry-header has-discussion';
}
?>
<div class="<?php echo $classes; ?>">
<?php get_template_part( 'template-parts/header/entry', 'header' ); ?>
</div><!-- .entry-header -->
<?php rewind_posts(); ?>
@@ -41,7 +41,7 @@
echo wp_get_attachment_image( get_the_ID(), $image_size );
?>

<figcaption class="wp-caption-text"><?php echo get_the_excerpt(); ?></figcaption>
<figcaption class="wp-caption-text"><?php the_excerpt(); ?></figcaption>

</figure><!-- .entry-attachment -->

@@ -12,10 +12,9 @@
*/
function twentynineteen_custom_colors_css() {
if ( 'default' === get_theme_mod( 'primary_color', 'default' ) ) {
$primary_color = 199;
} else {
$primary_color = absint( get_theme_mod( 'primary_color_hue', 199 ) );
$primary_color = 199;
if ( 'default' !== get_theme_mod( 'primary_color', 'default' ) ) {
$primary_color = absint( get_theme_mod( 'primary_color', 199 ) );
}
/**
@@ -25,21 +24,48 @@ function twentynineteen_custom_colors_css() {
*
* @param int $saturation Color saturation level.
*/
$saturation = apply_filters( 'twentynineteen_custom_colors_saturation', 100 );
$saturation = absint( $saturation ) . '%';
$saturation = absint( apply_filters( 'twentynineteen_custom_colors_saturation', 100 ) );
$saturation = $saturation . '%';
/**
* Filter Twenty Nineteen default selection saturation level.
*
* @since Twenty Nineteen 1.0
*
* @param int $saturation_selection Selection color saturation level.
*/
$saturation_selection = absint( apply_filters( 'twentynineteen_custom_colors_saturation_selection', 50 ) );
$saturation_selection = $saturation_selection . '%';
$lightness = absint( apply_filters( 'twentynineteen_custom_colors_lightness', 33 ) );
$lightness = $lightness . '%';
/**
* Filter Twenty Nineteen default lightness level.
*
* @since Twenty Nineteen 1.0
*
* @param int $lightness Color lightness level.
*/
$lightness = apply_filters( 'twentynineteen_custom_colors_lightness', 33 );
$lightness = absint( $lightness ) . '%';
$lightness_hover = absint( apply_filters( 'twentynineteen_custom_colors_lightness_hover', 23 ) );
$lightness_hover = $lightness_hover . '%';
/**
* Filter Twenty Nineteen default hover lightness level.
*
* @since Twenty Nineteen 1.0
*
* @param int $lightness_hover Hover color lightness level.
*/
$lightness_hover = apply_filters( 'twentynineteen_custom_colors_lightness_hover', 23 );
$lightness_hover = absint( $lightness_hover ) . '%';
$lightness_selection = absint( apply_filters( 'twentynineteen_custom_colors_lightness_selection', 90 ) );
$lightness_selection = $lightness_selection . '%';
/**
* Filter Twenty Nineteen default selection lightness level.
*
* @since Twenty Nineteen 1.0
*
* @param int $lightness_selection Selection color lightness level.
*/
$lightness_selection = apply_filters( 'twentynineteen_custom_colors_lightness_selection', 90 );
$lightness_selection = absint( $lightness_selection ) . '%';
$theme_css = '
/*
@@ -233,11 +259,9 @@ function twentynineteen_custom_colors_css() {
color: inherit;
}
';
$css = '';
if ( function_exists( 'register_block_type' ) && is_admin() ) {
$css .= $editor_css;
} else if ( ! is_admin() ) {
$css = $theme_css;
$theme_css = $editor_css;
}
/**
@@ -249,5 +273,5 @@ function twentynineteen_custom_colors_css() {
* @param int $primary_color The user's selected color hue.
* @param string $saturation Filtered theme color saturation level.
*/
return apply_filters( 'twentynineteen_custom_colors_css', $css, $primary_color, $saturation );
return apply_filters( 'twentynineteen_custom_colors_css', $theme_css, $primary_color, $saturation );
}
@@ -125,15 +125,15 @@ function twentynineteen_customize_partial_blogdescription() {
* Bind JS handlers to instantly live-preview changes.
*/
function twentynineteen_customize_preview_js() {
wp_enqueue_script( 'twentynineteen-customize-preview', get_theme_file_uri( '/js/customize-preview.js' ), array( 'customize-preview' ), '20151215', true );
wp_enqueue_script( 'twentynineteen-customize-preview', get_theme_file_uri( '/js/customize-preview.js' ), array( 'customize-preview' ), '20181108', true );
}
add_action( 'customize_preview_init', 'twentynineteen_customize_preview_js' );
/**
* Load dynamic logic for the customizer controls area.
*/
function twentynineteen_panels_js() {
wp_enqueue_script( 'twentynineteen-customize-controls', get_theme_file_uri( '/js/customize-controls.js' ), array(), '1.0', true );
wp_enqueue_script( 'twentynineteen-customize-controls', get_theme_file_uri( '/js/customize-controls.js' ), array(), '20181031', true );
}
add_action( 'customize_controls_enqueue_scripts', 'twentynineteen_panels_js' );
@@ -106,10 +106,7 @@ function twentynineteen_can_show_post_thumbnail() {
* Returns true if image filters are enabled on the theme options.
*/
function twentynineteen_image_filters_enabled() {
if ( get_theme_mod( 'image_filter', 1 ) ) {
return true;
}
return false;
return 'inactive' !== get_theme_mod( 'image_filter', 1 );
}
/**
@@ -418,8 +415,7 @@ function twentynineteen_hsl_hex( $h, $s, $l, $to_hex = true ) {
return "#$r$g$b";
} else {
return "rgb($r, $g, $b)";
}
return "rgb($r, $g, $b)";
}
@@ -157,9 +157,7 @@ function twentynineteen_post_thumbnail() {

<figure class="post-thumbnail">
<a class="post-thumbnail-inner" href="<?php the_permalink(); ?>" aria-hidden="true" tabindex="-1">
<?php
the_post_thumbnail( 'post-thumbnail' );
?>
<?php the_post_thumbnail( 'post-thumbnail' ); ?>
</a>
</figure>

@@ -210,8 +208,8 @@ function twentynineteen_comment_form( $order ) {
comment_form(
array(
'logged_in_as' => null,
'title_reply' => null,
'logged_in_as' => null,
'title_reply' => null,
)
);
}
@@ -223,13 +221,19 @@ function twentynineteen_comment_form( $order ) {
* Documentation for function.
*/
function twentynineteen_the_posts_navigation() {
$prev_icon = twentynineteen_get_icon_svg( 'chevron_left', 22 );
$next_icon = twentynineteen_get_icon_svg( 'chevron_right', 22 );
the_posts_pagination(
array(
'mid_size' => 2,
'prev_text' => sprintf( '%s <span class="nav-prev-text">%s</span>', $prev_icon, __( 'Newer posts', 'twentynineteen' ) ),
'next_text' => sprintf( '<span class="nav-next-text">%s</span> %s', __( 'Older posts', 'twentynineteen' ), $next_icon ),
'prev_text' => sprintf(
'%s <span class="nav-prev-text">%s</span>',
twentynineteen_get_icon_svg( 'chevron_left', 22 ),
__( 'Newer posts', 'twentynineteen' )
),
'next_text' => sprintf(
'<span class="nav-next-text">%s</span> %s',
__( 'Older posts', 'twentynineteen' ),
twentynineteen_get_icon_svg( 'chevron_right', 22 )
),
)
);
}
@@ -39,7 +39,7 @@
}
?>

</main><!-- .site-main -->
</section><!-- .content-area -->

@@ -45,6 +45,9 @@
width: 32px;
height: 32px;

// Prevent icons from jumping in Safari using hardware acceleration.
transform: translateZ(0);

&#ui-icon-link {
transform: rotate(-45deg);
}
@@ -1604,6 +1604,7 @@ body.page .main-navigation {
display: block;
width: 32px;
height: 32px;
transform: translateZ(0);
}

.social-navigation ul.social-links-menu li a svg#ui-icon-link {
@@ -1604,6 +1604,7 @@ body.page .main-navigation {
display: block;
width: 32px;
height: 32px;
transform: translateZ(0);
}

.social-navigation ul.social-links-menu li a svg#ui-icon-link {

0 comments on commit 49d906c

Please sign in to comment.
You can’t perform that action at this time.