Merge pull request #859 from jrfnl/feature/854-no-unncessary-php-tags

Avoid going in and out of PHP unnecessarily.
This commit is contained in:
sarah ✈ semark 2015-12-03 20:13:49 +00:00
commit 193d073b84
12 changed files with 127 additions and 107 deletions

19
404.php
View File

@ -20,11 +20,14 @@ get_header(); ?>
<div class="page-content"> <div class="page-content">
<p><?php esc_html_e( 'It looks like nothing was found at this location. Maybe try one of the links below or a search?', '_s' ); ?></p> <p><?php esc_html_e( 'It looks like nothing was found at this location. Maybe try one of the links below or a search?', '_s' ); ?></p>
<?php get_search_form(); ?> <?php
get_search_form();
<?php the_widget( 'WP_Widget_Recent_Posts' ); ?> the_widget( 'WP_Widget_Recent_Posts' );
if ( _s_categorized_blog() ) : // Only show the widget if site has multiple categories.
?>
<?php if ( _s_categorized_blog() ) : // Only show the widget if site has multiple categories. ?>
<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>
@ -39,15 +42,16 @@ get_header(); ?>
?> ?>
</ul> </ul>
</div><!-- .widget --> </div><!-- .widget -->
<?php endif; ?>
<?php <?php
endif;
/* translators: %1$s: smiley */ /* translators: %1$s: smiley */
$archive_content = '<p>' . sprintf( esc_html__( 'Try looking in the monthly archives. %1$s', '_s' ), convert_smilies( ':)' ) ) . '</p>'; $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_Archives', 'dropdown=1', "after_title=</h2>$archive_content" );
?>
<?php the_widget( 'WP_Widget_Tag_Cloud' ); ?> the_widget( 'WP_Widget_Tag_Cloud' );
?>
</div><!-- .page-content --> </div><!-- .page-content -->
</section><!-- .error-404 --> </section><!-- .error-404 -->
@ -55,4 +59,5 @@ get_header(); ?>
</main><!-- #main --> </main><!-- #main -->
</div><!-- #primary --> </div><!-- #primary -->
<?php get_footer(); ?> <?php
get_footer();

View File

@ -12,7 +12,8 @@ get_header(); ?>
<div id="primary" class="content-area"> <div id="primary" class="content-area">
<main id="main" class="site-main" role="main"> <main id="main" class="site-main" role="main">
<?php if ( have_posts() ) : ?> <?php
if ( have_posts() ) : ?>
<header class="page-header"> <header class="page-header">
<?php <?php
@ -21,10 +22,9 @@ get_header(); ?>
?> ?>
</header><!-- .page-header --> </header><!-- .page-header -->
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php <?php
/* Start the Loop */
while ( have_posts() ) : the_post();
/* /*
* Include the Post-Format-specific template for the content. * Include the Post-Format-specific template for the content.
@ -32,20 +32,20 @@ get_header(); ?>
* called content-___.php (where ___ is the Post Format name) and that will be used instead. * called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/ */
get_template_part( 'template-parts/content', get_post_format() ); get_template_part( 'template-parts/content', get_post_format() );
?>
<?php endwhile; ?> endwhile;
<?php the_posts_navigation(); ?> the_posts_navigation();
<?php else : ?> else :
<?php get_template_part( 'template-parts/content', 'none' ); ?> get_template_part( 'template-parts/content', 'none' );
<?php endif; ?> endif; ?>
</main><!-- #main --> </main><!-- #main -->
</div><!-- #primary --> </div><!-- #primary -->
<?php get_sidebar(); ?> <?php
<?php get_footer(); ?> get_sidebar();
get_footer();

View File

@ -22,9 +22,9 @@ if ( post_password_required() ) {
<div id="comments" class="comments-area"> <div id="comments" class="comments-area">
<?php // You can start editing here -- including this comment! ?> <?php
// You can start editing here -- including this comment!
<?php if ( have_comments() ) : ?> if ( have_comments() ) : ?>
<h2 class="comments-title"> <h2 class="comments-title">
<?php <?php
printf( // WPCS: XSS OK. printf( // WPCS: XSS OK.
@ -66,17 +66,20 @@ if ( post_password_required() ) {
</div><!-- .nav-links --> </div><!-- .nav-links -->
</nav><!-- #comment-nav-below --> </nav><!-- #comment-nav-below -->
<?php endif; // Check for comment navigation. ?>
<?php endif; // Check for have_comments(). ?>
<?php <?php
// If comments are closed and there are comments, let's leave a little note, shall we? endif; // Check for comment navigation.
if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) :
?>
<p class="no-comments"><?php esc_html_e( 'Comments are closed.', '_s' ); ?></p>
<?php endif; ?>
<?php comment_form(); ?> endif; // Check for have_comments().
// If comments are closed and there are comments, let's leave a little note, shall we?
if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) : ?>
<p class="no-comments"><?php esc_html_e( 'Comments are closed.', '_s' ); ?></p>
<?php
endif;
comment_form();
?>
</div><!-- #comments --> </div><!-- #comments -->

View File

@ -26,16 +26,19 @@
<header id="masthead" class="site-header" role="banner"> <header id="masthead" class="site-header" role="banner">
<div class="site-branding"> <div class="site-branding">
<?php if ( is_front_page() && is_home() ) : ?> <?php
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 endif; <?php
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 endif; ?> <?php
endif; ?>
</div><!-- .site-branding --> </div><!-- .site-branding -->
<nav id="site-navigation" class="main-navigation" role="navigation"> <nav id="site-navigation" class="main-navigation" role="navigation">

View File

@ -17,18 +17,19 @@ get_header(); ?>
<div id="primary" class="content-area"> <div id="primary" class="content-area">
<main id="main" class="site-main" role="main"> <main id="main" class="site-main" role="main">
<?php if ( have_posts() ) : ?> <?php
if ( have_posts() ) :
<?php 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 endif; ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php <?php
endif;
/* Start the Loop */
while ( have_posts() ) : the_post();
/* /*
* Include the Post-Format-specific template for the content. * Include the Post-Format-specific template for the content.
@ -36,20 +37,20 @@ get_header(); ?>
* called content-___.php (where ___ is the Post Format name) and that will be used instead. * called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/ */
get_template_part( 'template-parts/content', get_post_format() ); get_template_part( 'template-parts/content', get_post_format() );
?>
<?php endwhile; ?> endwhile;
<?php the_posts_navigation(); ?> the_posts_navigation();
<?php else : ?> else :
<?php get_template_part( 'template-parts/content', 'none' ); ?> get_template_part( 'template-parts/content', 'none' );
<?php endif; ?> endif; ?>
</main><!-- #main --> </main><!-- #main -->
</div><!-- #primary --> </div><!-- #primary -->
<?php get_sidebar(); ?> <?php
<?php get_footer(); ?> get_sidebar();
get_footer();

View File

@ -17,21 +17,22 @@ get_header(); ?>
<div id="primary" class="content-area"> <div id="primary" class="content-area">
<main id="main" class="site-main" role="main"> <main id="main" class="site-main" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'template-parts/content', 'page' ); ?>
<?php <?php
while ( have_posts() ) : the_post();
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;
?>
<?php endwhile; // End of the loop. ?> endwhile; // End of the loop.
?>
</main><!-- #main --> </main><!-- #main -->
</div><!-- #primary --> </div><!-- #primary -->
<?php get_sidebar(); ?> <?php
<?php get_footer(); ?> get_sidebar();
get_footer();

View File

@ -12,36 +12,37 @@ get_header(); ?>
<section id="primary" class="content-area"> <section id="primary" class="content-area">
<main id="main" class="site-main" role="main"> <main id="main" class="site-main" role="main">
<?php if ( have_posts() ) : ?> <?php
if ( have_posts() ) : ?>
<header class="page-header"> <header class="page-header">
<h1 class="page-title"><?php printf( esc_html__( 'Search Results for: %s', '_s' ), '<span>' . get_search_query() . '</span>' ); ?></h1> <h1 class="page-title"><?php printf( esc_html__( 'Search Results for: %s', '_s' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
</header><!-- .page-header --> </header><!-- .page-header -->
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php <?php
/* Start the Loop */
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.
* If you want to overload this in a child theme then include a file * If you want to overload this in a child theme then include a file
* called content-search.php and that will be used instead. * called content-search.php and that will be used instead.
*/ */
get_template_part( 'template-parts/content', 'search' ); get_template_part( 'template-parts/content', 'search' );
?>
<?php endwhile; ?> endwhile;
<?php the_posts_navigation(); ?> the_posts_navigation();
<?php else : ?> else :
<?php get_template_part( 'template-parts/content', 'none' ); ?> get_template_part( 'template-parts/content', 'none' );
<?php endif; ?> endif; ?>
</main><!-- #main --> </main><!-- #main -->
</section><!-- #primary --> </section><!-- #primary -->
<?php get_sidebar(); ?> <?php
<?php get_footer(); ?> get_sidebar();
get_footer();

View File

@ -12,23 +12,24 @@ get_header(); ?>
<div id="primary" class="content-area"> <div id="primary" class="content-area">
<main id="main" class="site-main" role="main"> <main id="main" class="site-main" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'template-parts/content', 'single' ); ?>
<?php the_post_navigation(); ?>
<?php <?php
while ( have_posts() ) : the_post();
get_template_part( 'template-parts/content', 'single' );
the_post_navigation();
// 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;
?>
<?php endwhile; // End of the loop. ?> endwhile; // End of the loop.
?>
</main><!-- #main --> </main><!-- #main -->
</div><!-- #primary --> </div><!-- #primary -->
<?php get_sidebar(); ?> <?php
<?php get_footer(); ?> get_sidebar();
get_footer();

View File

@ -15,20 +15,23 @@
</header><!-- .page-header --> </header><!-- .page-header -->
<div class="page-content"> <div class="page-content">
<?php if ( is_home() && current_user_can( 'publish_posts' ) ) : ?> <?php
if ( is_home() && current_user_can( 'publish_posts' ) ) : ?>
<p><?php printf( wp_kses( __( 'Ready to publish your first post? <a href="%1$s">Get started here</a>.', '_s' ), array( 'a' => array( 'href' => array() ) ) ), esc_url( admin_url( 'post-new.php' ) ) ); ?></p> <p><?php printf( wp_kses( __( 'Ready to publish your first post? <a href="%1$s">Get started here</a>.', '_s' ), array( 'a' => array( 'href' => array() ) ) ), esc_url( admin_url( 'post-new.php' ) ) ); ?></p>
<?php elseif ( is_search() ) : ?> <?php 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 get_search_form(); ?> <?php
get_search_form();
<?php 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 get_search_form(); ?> <?php
get_search_form();
<?php endif; ?> endif; ?>
</div><!-- .page-content --> </div><!-- .page-content -->
</section><!-- .no-results --> </section><!-- .no-results -->

View File

@ -15,8 +15,9 @@
</header><!-- .entry-header --> </header><!-- .entry-header -->
<div class="entry-content"> <div class="entry-content">
<?php the_content(); ?>
<?php <?php
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>',

View File

@ -19,8 +19,9 @@
</header><!-- .entry-header --> </header><!-- .entry-header -->
<div class="entry-content"> <div class="entry-content">
<?php the_content(); ?>
<?php <?php
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>',

View File

@ -11,13 +11,15 @@
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header"> <header class="entry-header">
<?php the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' ); ?> <?php
the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' );
<?php if ( 'post' === get_post_type() ) : ?> if ( 'post' === get_post_type() ) : ?>
<div class="entry-meta"> <div class="entry-meta">
<?php _s_posted_on(); ?> <?php _s_posted_on(); ?>
</div><!-- .entry-meta --> </div><!-- .entry-meta -->
<?php endif; ?> <?php
endif; ?>
</header><!-- .entry-header --> </header><!-- .entry-header -->
<div class="entry-content"> <div class="entry-content">
@ -27,9 +29,7 @@
wp_kses( __( 'Continue reading %s <span class="meta-nav">&rarr;</span>', '_s' ), array( 'span' => array( 'class' => array() ) ) ), wp_kses( __( 'Continue reading %s <span class="meta-nav">&rarr;</span>', '_s' ), array( 'span' => array( 'class' => array() ) ) ),
the_title( '<span class="screen-reader-text">"', '"</span>', false ) the_title( '<span class="screen-reader-text">"', '"</span>', false )
) ); ) );
?>
<?php
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>',