Move PHP tags on it’s own line & correct indention

This fixes a few of the errors from the news sniffs in WPCS 0.12.0 and also standardizes the indention between the PHP and HTML
This commit is contained in:
Ulrich Pogson 2017-08-01 22:27:46 +02:00 committed by jrfnl
parent 54ad32a598
commit b26b6ebfa4
13 changed files with 148 additions and 127 deletions

16
404.php
View File

@ -7,7 +7,8 @@
* @package _s * @package _s
*/ */
get_header(); ?> get_header();
?>
<div id="primary" class="content-area"> <div id="primary" class="content-area">
<main id="main" class="site-main"> <main id="main" class="site-main">
@ -29,7 +30,7 @@ get_header(); ?>
<div class="widget widget_categories"> <div class="widget widget_categories">
<h2 class="widget-title"><?php esc_html_e( 'Most Used Categories', '_s' ); ?></h2> <h2 class="widget-title"><?php esc_html_e( 'Most Used Categories', '_s' ); ?></h2>
<ul> <ul>
<?php <?php
wp_list_categories( array( wp_list_categories( array(
'orderby' => 'count', 'orderby' => 'count',
'order' => 'DESC', 'order' => 'DESC',
@ -37,17 +38,16 @@ get_header(); ?>
'title_li' => '', 'title_li' => '',
'number' => 10, 'number' => 10,
) ); ) );
?> ?>
</ul> </ul>
</div><!-- .widget --> </div><!-- .widget -->
<?php <?php
/* translators: %1$s: smiley */
$archive_content = '<p>' . sprintf( esc_html__( 'Try looking in the monthly archives. %1$s', '_s' ), convert_smilies( ':)' ) ) . '</p>';
the_widget( 'WP_Widget_Archives', 'dropdown=1', "after_title=</h2>$archive_content" );
/* translators: %1$s: smiley */ the_widget( 'WP_Widget_Tag_Cloud' );
$archive_content = '<p>' . sprintf( esc_html__( 'Try looking in the monthly archives. %1$s', '_s' ), convert_smilies( ':)' ) ) . '</p>';
the_widget( 'WP_Widget_Archives', 'dropdown=1', "after_title=</h2>$archive_content" );
the_widget( 'WP_Widget_Tag_Cloud' );
?> ?>
</div><!-- .page-content --> </div><!-- .page-content -->

View File

@ -7,24 +7,25 @@
* @package _s * @package _s
*/ */
get_header(); ?> get_header();
?>
<div id="primary" class="content-area"> <div id="primary" class="content-area">
<main id="main" class="site-main"> <main id="main" class="site-main">
<?php <?php if ( have_posts() ) : ?>
if ( have_posts() ) : ?>
<header class="page-header"> <header class="page-header">
<?php <?php
the_archive_title( '<h1 class="page-title">', '</h1>' ); the_archive_title( '<h1 class="page-title">', '</h1>' );
the_archive_description( '<div class="archive-description">', '</div>' ); the_archive_description( '<div class="archive-description">', '</div>' );
?> ?>
</header><!-- .page-header --> </header><!-- .page-header -->
<?php <?php
/* Start the Loop */ /* Start the Loop */
while ( have_posts() ) : the_post(); while ( have_posts() ) :
the_post();
/* /*
* Include the Post-Format-specific template for the content. * Include the Post-Format-specific template for the content.
@ -41,7 +42,8 @@ get_header(); ?>
get_template_part( 'template-parts/content', 'none' ); get_template_part( 'template-parts/content', 'none' );
endif; ?> endif;
?>
</main><!-- #main --> </main><!-- #main -->
</div><!-- #primary --> </div><!-- #primary -->

View File

@ -24,7 +24,8 @@ if ( post_password_required() ) {
<?php <?php
// You can start editing here -- including this comment! // You can start editing here -- including this comment!
if ( have_comments() ) : ?> if ( have_comments() ) :
?>
<h2 class="comments-title"> <h2 class="comments-title">
<?php <?php
$comment_count = get_comments_number(); $comment_count = get_comments_number();
@ -49,19 +50,21 @@ if ( post_password_required() ) {
<ol class="comment-list"> <ol class="comment-list">
<?php <?php
wp_list_comments( array( wp_list_comments( array(
'style' => 'ol', 'style' => 'ol',
'short_ping' => true, 'short_ping' => true,
) ); ) );
?> ?>
</ol><!-- .comment-list --> </ol><!-- .comment-list -->
<?php the_comments_navigation(); <?php
the_comments_navigation();
// If comments are closed and there are comments, let's leave a little note, shall we? // If comments are closed and there are comments, let's leave a little note, shall we?
if ( ! comments_open() ) : ?> if ( ! comments_open() ) :
?>
<p class="no-comments"><?php esc_html_e( 'Comments are closed.', '_s' ); ?></p> <p class="no-comments"><?php esc_html_e( 'Comments are closed.', '_s' ); ?></p>
<?php <?php
endif; endif;
endif; // Check for have_comments(). endif; // Check for have_comments().

View File

@ -15,15 +15,17 @@
<footer id="colophon" class="site-footer"> <footer id="colophon" class="site-footer">
<div class="site-info"> <div class="site-info">
<a href="<?php echo esc_url( __( 'https://wordpress.org/', '_s' ) ); ?>"><?php <a href="<?php echo esc_url( __( 'https://wordpress.org/', '_s' ) ); ?>">
<?php
/* translators: %s: CMS name, i.e. WordPress. */ /* translators: %s: CMS name, i.e. WordPress. */
printf( esc_html__( 'Proudly powered by %s', '_s' ), 'WordPress' ); printf( esc_html__( 'Proudly powered by %s', '_s' ), 'WordPress' );
?></a> ?>
</a>
<span class="sep"> | </span> <span class="sep"> | </span>
<?php <?php
/* translators: 1: Theme name, 2: Theme author. */ /* translators: 1: Theme name, 2: Theme author. */
printf( esc_html__( 'Theme: %1$s by %2$s.', '_s' ), '_s', '<a href="https://automattic.com/">Automattic</a>' ); printf( esc_html__( 'Theme: %1$s by %2$s.', '_s' ), '_s', '<a href="https://automattic.com/">Automattic</a>' );
?> ?>
</div><!-- .site-info --> </div><!-- .site-info -->
</footer><!-- #colophon --> </footer><!-- #colophon -->
</div><!-- #page --> </div><!-- #page -->

View File

@ -28,27 +28,29 @@
<div class="site-branding"> <div class="site-branding">
<?php <?php
the_custom_logo(); the_custom_logo();
if ( is_front_page() && is_home() ) : ?> if ( is_front_page() && is_home() ) :
?>
<h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1> <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
<?php else : ?> <?php
else :
?>
<p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p> <p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
<?php <?php
endif; endif;
$description = get_bloginfo( 'description', 'display' ); $description = get_bloginfo( 'description', 'display' );
if ( $description || is_customize_preview() ) : ?> if ( $description || is_customize_preview() ) :
?>
<p class="site-description"><?php echo $description; /* WPCS: xss ok. */ ?></p> <p class="site-description"><?php echo $description; /* WPCS: xss ok. */ ?></p>
<?php <?php endif; ?>
endif; ?>
</div><!-- .site-branding --> </div><!-- .site-branding -->
<nav id="site-navigation" class="main-navigation"> <nav id="site-navigation" class="main-navigation">
<button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false"><?php esc_html_e( 'Primary Menu', '_s' ); ?></button> <button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false"><?php esc_html_e( 'Primary Menu', '_s' ); ?></button>
<?php <?php
wp_nav_menu( array( wp_nav_menu( array(
'theme_location' => 'menu-1', 'theme_location' => 'menu-1',
'menu_id' => 'primary-menu', 'menu_id' => 'primary-menu',
) ); ) );
?> ?>
</nav><!-- #site-navigation --> </nav><!-- #site-navigation -->
</header><!-- #masthead --> </header><!-- #masthead -->

View File

@ -51,16 +51,16 @@ if ( ! function_exists( '_s_header_style' ) ) :
<?php <?php
// Has the text been hidden? // Has the text been hidden?
if ( ! display_header_text() ) : if ( ! display_header_text() ) :
?> ?>
.site-title, .site-title,
.site-description { .site-description {
position: absolute; position: absolute;
clip: rect(1px, 1px, 1px, 1px); clip: rect(1px, 1px, 1px, 1px);
} }
<?php <?php
// If the user has set a custom color for the text use that. // If the user has set a custom color for the text use that.
else : else :
?> ?>
.site-title a, .site-title a,
.site-description { .site-description {
color: #<?php echo esc_attr( $header_text_color ); ?>; color: #<?php echo esc_attr( $header_text_color ); ?>;

View File

@ -12,7 +12,8 @@
* @package _s * @package _s
*/ */
get_header(); ?> get_header();
?>
<div id="primary" class="content-area"> <div id="primary" class="content-area">
<main id="main" class="site-main"> <main id="main" class="site-main">
@ -20,16 +21,17 @@ get_header(); ?>
<?php <?php
if ( have_posts() ) : if ( have_posts() ) :
if ( is_home() && ! is_front_page() ) : ?> if ( is_home() && ! is_front_page() ) :
?>
<header> <header>
<h1 class="page-title screen-reader-text"><?php single_post_title(); ?></h1> <h1 class="page-title screen-reader-text"><?php single_post_title(); ?></h1>
</header> </header>
<?php
<?php
endif; endif;
/* Start the Loop */ /* Start the Loop */
while ( have_posts() ) : the_post(); while ( have_posts() ) :
the_post();
/* /*
* Include the Post-Format-specific template for the content. * Include the Post-Format-specific template for the content.
@ -46,7 +48,8 @@ get_header(); ?>
get_template_part( 'template-parts/content', 'none' ); get_template_part( 'template-parts/content', 'none' );
endif; ?> endif;
?>
</main><!-- #main --> </main><!-- #main -->
</div><!-- #primary --> </div><!-- #primary -->

View File

@ -12,23 +12,25 @@
* @package _s * @package _s
*/ */
get_header(); ?> get_header();
?>
<div id="primary" class="content-area"> <div id="primary" class="content-area">
<main id="main" class="site-main"> <main id="main" class="site-main">
<?php <?php
while ( have_posts() ) : the_post(); while ( have_posts() ) :
the_post();
get_template_part( 'template-parts/content', 'page' ); get_template_part( 'template-parts/content', 'page' );
// If comments are open or we have at least one comment, load up the comment template. // If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) : if ( comments_open() || get_comments_number() ) :
comments_template(); comments_template();
endif; endif;
endwhile; // End of the loop. endwhile; // End of the loop.
?> ?>
</main><!-- #main --> </main><!-- #main -->
</div><!-- #primary --> </div><!-- #primary -->

View File

@ -7,24 +7,27 @@
* @package _s * @package _s
*/ */
get_header(); ?> get_header();
?>
<section id="primary" class="content-area"> <section id="primary" class="content-area">
<main id="main" class="site-main"> <main id="main" class="site-main">
<?php <?php if ( have_posts() ) : ?>
if ( have_posts() ) : ?>
<header class="page-header"> <header class="page-header">
<h1 class="page-title"><?php <h1 class="page-title">
<?php
/* translators: %s: search query. */ /* translators: %s: search query. */
printf( esc_html__( 'Search Results for: %s', '_s' ), '<span>' . get_search_query() . '</span>' ); printf( esc_html__( 'Search Results for: %s', '_s' ), '<span>' . get_search_query() . '</span>' );
?></h1> ?>
</h1>
</header><!-- .page-header --> </header><!-- .page-header -->
<?php <?php
/* Start the Loop */ /* Start the Loop */
while ( have_posts() ) : the_post(); while ( have_posts() ) :
the_post();
/** /**
* Run the loop for the search to output the results. * Run the loop for the search to output the results.
@ -41,7 +44,8 @@ get_header(); ?>
get_template_part( 'template-parts/content', 'none' ); get_template_part( 'template-parts/content', 'none' );
endif; ?> endif;
?>
</main><!-- #main --> </main><!-- #main -->
</section><!-- #primary --> </section><!-- #primary -->

View File

@ -7,13 +7,15 @@
* @package _s * @package _s
*/ */
get_header(); ?> get_header();
?>
<div id="primary" class="content-area"> <div id="primary" class="content-area">
<main id="main" class="site-main"> <main id="main" class="site-main">
<?php <?php
while ( have_posts() ) : the_post(); while ( have_posts() ) :
the_post();
get_template_part( 'template-parts/content', get_post_type() ); get_template_part( 'template-parts/content', get_post_type() );

View File

@ -16,35 +16,36 @@
<div class="page-content"> <div class="page-content">
<?php <?php
if ( is_home() && current_user_can( 'publish_posts' ) ) : ?> if ( is_home() && current_user_can( 'publish_posts' ) ) :
<p><?php printf(
printf( '<p>' . wp_kses(
wp_kses( /* translators: 1: link to WP admin new post page. */
/* translators: 1: link to WP admin new post page. */ __( 'Ready to publish your first post? <a href="%1$s">Get started here</a>.', '_s' ),
__( 'Ready to publish your first post? <a href="%1$s">Get started here</a>.', '_s' ), array(
array( 'a' => array(
'a' => array( 'href' => array(),
'href' => array(), ),
), )
) ) . '</p>',
), esc_url( admin_url( 'post-new.php' ) )
esc_url( admin_url( 'post-new.php' ) ) );
);
?></p>
<?php elseif ( is_search() ) : ?> elseif ( is_search() ) :
?>
<p><?php esc_html_e( 'Sorry, but nothing matched your search terms. Please try again with some different keywords.', '_s' ); ?></p> <p><?php esc_html_e( 'Sorry, but nothing matched your search terms. Please try again with some different keywords.', '_s' ); ?></p>
<?php <?php
get_search_form(); get_search_form();
else : ?> else :
?>
<p><?php esc_html_e( 'It seems we can&rsquo;t find what you&rsquo;re looking for. Perhaps searching can help.', '_s' ); ?></p> <p><?php esc_html_e( 'It seems we can&rsquo;t find what you&rsquo;re looking for. Perhaps searching can help.', '_s' ); ?></p>
<?php <?php
get_search_form(); get_search_form();
endif; ?> endif;
?>
</div><!-- .page-content --> </div><!-- .page-content -->
</section><!-- .no-results --> </section><!-- .no-results -->

View File

@ -18,34 +18,34 @@
<div class="entry-content"> <div class="entry-content">
<?php <?php
the_content(); the_content();
wp_link_pages( array( wp_link_pages( array(
'before' => '<div class="page-links">' . esc_html__( 'Pages:', '_s' ), 'before' => '<div class="page-links">' . esc_html__( 'Pages:', '_s' ),
'after' => '</div>', 'after' => '</div>',
) ); ) );
?> ?>
</div><!-- .entry-content --> </div><!-- .entry-content -->
<?php if ( get_edit_post_link() ) : ?> <?php if ( get_edit_post_link() ) : ?>
<footer class="entry-footer"> <footer class="entry-footer">
<?php <?php
edit_post_link( edit_post_link(
sprintf( sprintf(
wp_kses( wp_kses(
/* translators: %s: Name of current post. Only visible to screen readers */ /* translators: %s: Name of current post. Only visible to screen readers */
__( 'Edit <span class="screen-reader-text">%s</span>', '_s' ), __( 'Edit <span class="screen-reader-text">%s</span>', '_s' ),
array( array(
'span' => array( 'span' => array(
'class' => array(), 'class' => array(),
), ),
) )
),
get_the_title()
), ),
'<span class="edit-link">', get_the_title()
'</span>' ),
); '<span class="edit-link">',
'</span>'
);
?> ?>
</footer><!-- .entry-footer --> </footer><!-- .entry-footer -->
<?php endif; ?> <?php endif; ?>

View File

@ -18,38 +18,38 @@
the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' ); the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
endif; endif;
if ( 'post' === get_post_type() ) : ?> if ( 'post' === get_post_type() ) :
<div class="entry-meta"> ?>
<div class="entry-meta">
<?php <?php
_s_posted_on(); _s_posted_on();
_s_posted_by(); _s_posted_by();
?> ?>
</div><!-- .entry-meta --> </div><!-- .entry-meta -->
<?php <?php endif; ?>
endif; ?>
</header><!-- .entry-header --> </header><!-- .entry-header -->
<?php _s_post_thumbnail(); ?> <?php _s_post_thumbnail(); ?>
<div class="entry-content"> <div class="entry-content">
<?php <?php
the_content( sprintf( the_content( sprintf(
wp_kses( wp_kses(
/* translators: %s: Name of current post. Only visible to screen readers */ /* translators: %s: Name of current post. Only visible to screen readers */
__( 'Continue reading<span class="screen-reader-text"> "%s"</span>', '_s' ), __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', '_s' ),
array( array(
'span' => array( 'span' => array(
'class' => array(), 'class' => array(),
), ),
) )
), ),
get_the_title() get_the_title()
) ); ) );
wp_link_pages( array( wp_link_pages( array(
'before' => '<div class="page-links">' . esc_html__( 'Pages:', '_s' ), 'before' => '<div class="page-links">' . esc_html__( 'Pages:', '_s' ),
'after' => '</div>', 'after' => '</div>',
) ); ) );
?> ?>
</div><!-- .entry-content --> </div><!-- .entry-content -->