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.

Built from https://develop.svn.wordpress.org/trunk@39618


git-svn-id: http://core.svn.wordpress.org/trunk@39558 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
David A. Kennedy 2016-12-16 22:08:47 +00:00
parent efb191c2ed
commit 7ad554f955
17 changed files with 184 additions and 148 deletions

View File

@ -310,6 +310,7 @@ add_action( 'widgets_init', 'twentyseventeen_widgets_init' );
*
* @since Twenty Seventeen 1.0
*
* @param string $link Link to single post/page.
* @return string 'Continue reading' link prepended with an ellipsis.
*/
function twentyseventeen_excerpt_more( $link ) {

View File

@ -201,7 +201,7 @@ function twentyseventeen_custom_colors_css() {
.colors-custom .widget ul li a:focus,
.colors-custom .widget ul li a:hover {
-webkit-box-shadow: inset 0 0 0 hsl( ' . $hue . ', ' . $saturation . ', 13% ), 0 3px 0 hsl( ' . $hue . ', ' . $saturation . ', 13% );
box-shadow: inset 0 0 0 hsl( ' . $hue . ', ' . $saturation. ' , 13% ), 0 3px 0 hsl( ' . $hue . ', ' . $saturation . ', 13% );
box-shadow: inset 0 0 0 hsl( ' . $hue . ', ' . $saturation . ' , 13% ), 0 3px 0 hsl( ' . $hue . ', ' . $saturation . ', 13% );
}
body.colors-custom,
@ -560,7 +560,6 @@ body.colors-custom,
}
}';
/**
* Filters Twenty Seventeen custom colors CSS.
*

View File

@ -111,6 +111,8 @@ endif; // End of twentyseventeen_header_style.
/**
* Customize video play/pause button in the custom header.
*
* @param array $settings Video settings.
*/
function twentyseventeen_video_controls( $settings ) {
$settings['l10n']['play'] = '<span class="screen-reader-text">' . __( 'Play background video', 'twentyseventeen' ) . '</span>' . twentyseventeen_get_svg( array( 'icon' => 'play' ) );

View File

@ -123,6 +123,8 @@ add_action( 'customize_register', 'twentyseventeen_customize_register' );
/**
* Sanitize the page layout options.
*
* @param string $input Page layout.
*/
function twentyseventeen_sanitize_page_layout( $input ) {
$valid = array(
@ -139,11 +141,13 @@ function twentyseventeen_sanitize_page_layout( $input ) {
/**
* Sanitize the colorscheme.
*
* @param string $input Color scheme.
*/
function twentyseventeen_sanitize_colorscheme( $input ) {
$valid = array( 'light', 'dark', 'custom' );
if ( in_array( $input, $valid ) ) {
if ( in_array( $input, $valid, true ) ) {
return $input;
}

View File

@ -128,8 +128,8 @@ endif;
/**
* Display a front page section.
*
* @param $partial WP_Customize_Partial Partial associated with a selective refresh request.
* @param $id integer Front page section to display.
* @param WP_Customize_Partial $partial Partial associated with a selective refresh request.
* @param integer $id Front page section to display.
*/
function twentyseventeen_front_page_section( $partial = null, $id = 0 ) {
if ( is_a( $partial, 'WP_Customize_Partial' ) ) {

View File

@ -7,6 +7,7 @@
* @since 1.0
* @version 1.0
*/
?>
<?php $unique_id = esc_attr( uniqid( 'search-form-' ) ); ?>

View File

@ -21,8 +21,11 @@
<p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
<?php endif; ?>
<?php $description = get_bloginfo( 'description', 'display' );
if ( $description || is_customize_preview() ) : ?>
<?php
$description = get_bloginfo( 'description', 'display' );
if ( $description || is_customize_preview() ) :
?>
<p class="site-description"><?php echo $description; ?></p>
<?php endif; ?>
</div><!-- .site-branding-text -->

View File

@ -10,7 +10,14 @@
?>
<nav id="site-navigation" class="main-navigation" role="navigation" aria-label="<?php _e( 'Top Menu', 'twentyseventeen' ); ?>">
<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>
<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>
<?php wp_nav_menu( array(
'theme_location' => 'top',
'menu_id' => 'top-menu',

View File

@ -14,22 +14,22 @@
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php
if ( is_sticky() && is_home() ) :
if ( is_sticky() && is_home() ) {
echo twentyseventeen_get_svg( array( 'icon' => 'thumb-tack' ) );
endif;
}
?>
<header class="entry-header">
<?php
if ( 'post' === get_post_type() ) :
if ( 'post' === get_post_type() ) {
echo '<div class="entry-meta">';
if ( is_single() ) :
if ( is_single() ) {
twentyseventeen_posted_on();
else :
} else {
echo twentyseventeen_time_link();
twentyseventeen_edit_link();
endif;
};
echo '</div><!-- .entry-meta -->';
endif;
};
if ( is_single() ) {
the_title( '<h1 class="entry-title">', '</h1>' );
@ -60,20 +60,21 @@
<div class="entry-content">
<?php if ( ! is_single() ) :
<?php
if ( ! is_single() ) {
// If not a single post, highlight the audio file.
if ( ! empty( $audio ) ) :
if ( ! empty( $audio ) ) {
foreach ( $audio as $audio_html ) {
echo '<div class="entry-audio">';
echo $audio_html;
echo '</div><!-- .entry-audio -->';
}
endif;
};
endif;
};
if ( is_single() || empty( $audio ) ) :
if ( is_single() || empty( $audio ) ) {
/* translators: %s: Name of current post */
the_content( sprintf(
@ -88,12 +89,15 @@
'link_after' => '</span>',
) );
endif; ?>
};
?>
</div><!-- .entry-content -->
<?php if ( is_single() ) : ?>
<?php twentyseventeen_entry_footer(); ?>
<?php endif; ?>
<?php
if ( is_single() ) {
twentyseventeen_entry_footer();
}
?>
</article><!-- #post-## -->

View File

@ -9,26 +9,27 @@
* @since 1.0
* @version 1.0
*/
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php
if ( is_sticky() && is_home() ) :
if ( is_sticky() && is_home() ) {
echo twentyseventeen_get_svg( array( 'icon' => 'thumb-tack' ) );
endif;
}
?>
<header class="entry-header">
<?php
if ( 'post' === get_post_type() ) :
if ( 'post' === get_post_type() ) {
echo '<div class="entry-meta">';
if ( is_single() ) :
if ( is_single() ) {
twentyseventeen_posted_on();
else :
} else {
echo twentyseventeen_time_link();
twentyseventeen_edit_link();
endif;
};
echo '</div><!-- .entry-meta -->';
endif;
};
if ( is_single() ) {
the_title( '<h1 class="entry-title">', '</h1>' );
@ -48,18 +49,19 @@
<div class="entry-content">
<?php if ( ! is_single() ) :
<?php
if ( ! is_single() ) {
// If not a single post, highlight the gallery.
if ( get_post_gallery() ) :
if ( get_post_gallery() ) {
echo '<div class="entry-gallery">';
echo get_post_gallery();
echo '</div>';
endif;
};
endif;
};
if ( is_single() || ! get_post_gallery() ) :
if ( is_single() || ! get_post_gallery() ) {
/* translators: %s: Name of current post */
the_content( sprintf(
@ -74,12 +76,15 @@
'link_after' => '</span>',
) );
endif; ?>
};
?>
</div><!-- .entry-content -->
<?php if ( is_single() ) : ?>
<?php twentyseventeen_entry_footer(); ?>
<?php endif; ?>
<?php
if ( is_single() ) {
twentyseventeen_entry_footer();
}
?>
</article><!-- #post-## -->

View File

@ -9,26 +9,27 @@
* @since 1.0
* @version 1.0
*/
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php
if ( is_sticky() && is_home() ) :
if ( is_sticky() && is_home() ) {
echo twentyseventeen_get_svg( array( 'icon' => 'thumb-tack' ) );
endif;
}
?>
<header class="entry-header">
<?php
if ( 'post' === get_post_type() ) :
if ( 'post' === get_post_type() ) {
echo '<div class="entry-meta">';
if ( is_single() ) :
if ( is_single() ) {
twentyseventeen_posted_on();
else :
} else {
echo twentyseventeen_time_link();
twentyseventeen_edit_link();
endif;
};
echo '</div><!-- .entry-meta -->';
endif;
};
if ( is_single() ) {
the_title( '<h1 class="entry-title">', '</h1>' );
@ -48,7 +49,7 @@
<div class="entry-content">
<?php if ( is_single() || '' === get_the_post_thumbnail() ) :
<?php if ( is_single() || '' === get_the_post_thumbnail() ) {
// Only show content if is a single post, or if there's no featured image.
/* translators: %s: Name of current post */
@ -64,12 +65,15 @@
'link_after' => '</span>',
) );
endif; ?>
};
?>
</div><!-- .entry-content -->
<?php if ( is_single() ) : ?>
<?php twentyseventeen_entry_footer(); ?>
<?php endif; ?>
<?php
if ( is_single() ) {
twentyseventeen_entry_footer();
}
?>
</article><!-- #post-## -->

View File

@ -9,26 +9,27 @@
* @since 1.0
* @version 1.0
*/
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php
if ( is_sticky() && is_home() ) :
if ( is_sticky() && is_home() ) {
echo twentyseventeen_get_svg( array( 'icon' => 'thumb-tack' ) );
endif;
}
?>
<header class="entry-header">
<?php
if ( 'post' === get_post_type() ) :
if ( 'post' === get_post_type() ) {
echo '<div class="entry-meta">';
if ( is_single() ) :
if ( is_single() ) {
twentyseventeen_posted_on();
else :
} else {
echo twentyseventeen_time_link();
twentyseventeen_edit_link();
endif;
}
echo '</div><!-- .entry-meta -->';
endif;
};
if ( is_single() ) {
the_title( '<h1 class="entry-title">', '</h1>' );
@ -58,20 +59,21 @@
<div class="entry-content">
<?php if ( ! is_single() ) :
<?php
if ( ! is_single() ) {
// If not a single post, highlight the video file.
if ( ! empty( $video ) ) :
if ( ! empty( $video ) ) {
foreach ( $video as $video_html ) {
echo '<div class="entry-video">';
echo $video_html;
echo '</div>';
}
endif;
};
endif;
};
if ( is_single() || empty( $video ) ) :
if ( is_single() || empty( $video ) ) {
/* translators: %s: Name of current post */
the_content( sprintf(
@ -85,13 +87,15 @@
'link_before' => '<span class="page-number">',
'link_after' => '</span>',
) );
endif; ?>
};
?>
</div><!-- .entry-content -->
<?php if ( is_single() ) : ?>
<?php twentyseventeen_entry_footer(); ?>
<?php endif; ?>
<?php
if ( is_single() ) {
twentyseventeen_entry_footer();
}
?>
</article><!-- #post-## -->

View File

@ -20,16 +20,16 @@
?>
<header class="entry-header">
<?php
if ( 'post' === get_post_type() ) :
if ( 'post' === get_post_type() ) {
echo '<div class="entry-meta">';
if ( is_single() ) :
if ( is_single() ) {
twentyseventeen_posted_on();
else :
} else {
echo twentyseventeen_time_link();
twentyseventeen_edit_link();
endif;
};
echo '</div><!-- .entry-meta -->';
endif;
};
if ( is_single() ) {
the_title( '<h1 class="entry-title">', '</h1>' );
@ -64,8 +64,10 @@
?>
</div><!-- .entry-content -->
<?php if ( is_single() ) : ?>
<?php twentyseventeen_entry_footer(); ?>
<?php endif; ?>
<?php
if ( is_single() ) {
twentyseventeen_entry_footer();
}
?>
</article><!-- #post-## -->

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.8-alpha-39617';
$wp_version = '4.8-alpha-39618';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.