structure & pluggability

This commit is contained in:
James Koster 2014-08-18 12:44:54 +01:00
parent f3324ce9af
commit e607c79af2
10 changed files with 546 additions and 474 deletions

View file

@ -5,51 +5,14 @@
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> itemscope="" itemtype="http://schema.org/BlogPosting">
<header class="entry-header">
<?php storefront_posted_on(); ?>
<?php the_title( '<h1 class="entry-title" itemprop="name headline">', '</h1>' ); ?>
</header><!-- .entry-header -->
<aside class="entry-meta">
<?php if ( 'post' == get_post_type() ) : // Hide category and tag text for pages on Search ?>
<?php
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list( __( ', ', 'storefront' ) );
if ( $categories_list && storefront_categorized_blog() ) :
?>
<span class="cat-links">
<?php echo $categories_list; ?>
</span>
<?php endif; // End if categories ?>
<?php
/* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list( '', __( ', ', 'storefront' ) );
if ( $tags_list ) :
/**
* @hooked storefront_post_header - 10
* @hooked storefront_post_meta - 20
* @hooked storefront_post_content - 30
*/
do_action( 'storefront_single_post' );
?>
<span class="tags-links">
<?php echo $tags_list; ?>
</span>
<?php endif; // End if $tags_list ?>
<?php endif; // End if 'post' == get_post_type() ?>
<?php if ( ! post_password_required() && ( comments_open() || '0' != get_comments_number() ) ) : ?>
<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'storefront' ), __( '1 Comment', 'storefront' ), __( '% Comments', 'storefront' ) ); ?></span>
<?php endif; ?>
</aside>
<div class="entry-content" itemprop="articleBody">
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail( 'full', array( 'itemprop' => 'image' ) );
}
?>
<?php the_content(); ?>
<?php
wp_link_pages( array(
'before' => '<div class="page-links">' . __( 'Pages:', 'storefront' ),
'after' => '</div>',
) );
?>
</div><!-- .entry-content -->
</article><!-- #post-## -->

View file

@ -5,53 +5,14 @@
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> itemscope="" itemtype="http://schema.org/BlogPosting">
<header class="entry-header">
<?php if ( 'post' == get_post_type() ) : ?>
<?php storefront_posted_on(); ?>
<?php endif; ?>
<?php the_title( sprintf( '<h1 class="entry-title" itemprop="name headline"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h1>' ); ?>
</header><!-- .entry-header -->
<aside class="entry-meta">
<?php if ( 'post' == get_post_type() ) : // Hide category and tag text for pages on Search ?>
<?php
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list( __( ', ', 'storefront' ) );
if ( $categories_list && storefront_categorized_blog() ) :
?>
<span class="cat-links">
<?php echo $categories_list; ?>
</span>
<?php endif; // End if categories ?>
<?php
/* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list( '', __( ', ', 'storefront' ) );
if ( $tags_list ) :
/**
* @hooked storefront_post_header() - 10
* @hooked storefront_post_meta() - 20
* @hooked storefront_post_content() - 30
*/
do_action( 'storefront_loop_post' );
?>
<span class="tags-links">
<?php echo $tags_list; ?>
</span>
<?php endif; // End if $tags_list ?>
<?php endif; // End if 'post' == get_post_type() ?>
<?php if ( ! post_password_required() && ( comments_open() || '0' != get_comments_number() ) ) : ?>
<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'storefront' ), __( '1 Comment', 'storefront' ), __( '% Comments', 'storefront' ) ); ?></span>
<?php endif; ?>
</aside>
<div class="entry-content" itemprop="articleBody">
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail( 'full', array( 'itemprop' => 'image' ) );
}
?>
<?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'storefront' ) ); ?>
<?php
wp_link_pages( array(
'before' => '<div class="page-links">' . __( 'Pages:', 'storefront' ),
'after' => '</div>',
) );
?>
</div><!-- .entry-content -->
</article><!-- #post-## -->

View file

@ -118,3 +118,44 @@ function storefront_html_tag_schema() {
echo 'itemscope="itemscope" itemtype="' . $schema . $type . '"';
}
/**
* Returns true if a blog has more than 1 category.
*
* @return bool
*/
function storefront_categorized_blog() {
if ( false === ( $all_the_cool_cats = get_transient( 'storefront_categories' ) ) ) {
// Create an array of all the categories that are attached to posts.
$all_the_cool_cats = get_categories( array(
'fields' => 'ids',
'hide_empty' => 1,
// We only need to know if there is more than one category.
'number' => 2,
) );
// Count the number of categories that are attached to the posts.
$all_the_cool_cats = count( $all_the_cool_cats );
set_transient( 'storefront_categories', $all_the_cool_cats );
}
if ( $all_the_cool_cats > 1 ) {
// This blog has more than 1 category so storefront_categorized_blog should return true.
return true;
} else {
// This blog has only 1 category so storefront_categorized_blog should return false.
return false;
}
}
/**
* Flush out the transients used in storefront_categorized_blog.
*/
function storefront_category_transient_flusher() {
// Like, beat it. Dig?
delete_transient( 'storefront_categories' );
}
add_action( 'edit_category', 'storefront_category_transient_flusher' );
add_action( 'save_post', 'storefront_category_transient_flusher' );

View file

@ -23,8 +23,13 @@ require get_template_directory() . '/inc/functions/setup.php';
require get_template_directory() . '/inc/structure/hooks.php';
/**
* Custom template tags for this theme.
* Structure.
* Template functions used throughout the theme.
*/
require get_template_directory() . '/inc/structure/post.php';
require get_template_directory() . '/inc/structure/header.php';
require get_template_directory() . '/inc/structure/footer.php';
require get_template_directory() . '/inc/structure/comments.php';
require get_template_directory() . '/inc/structure/template-tags.php';
/**
@ -50,7 +55,7 @@ require get_template_directory() . '/inc/jetpack/jetpack.php';
require get_template_directory() . '/inc/admin/welcome-screen.php';
/**
* Load Jetpack WooCommerce file.
* Load WooCommerce compatibility files.
*/
if ( is_woocommerce_activated() ) {
require get_template_directory() . '/inc/woocommerce/hooks.php';

View file

@ -0,0 +1,55 @@
<?php
/**
* Template functions used for the site comments.
*
* @package storefront
*/
/**
* Storefront comment template
* @since 1.0.0
*/
function storefront_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
extract( $args, EXTR_SKIP );
if ( 'div' == $args['style'] ) {
$tag = 'div';
$add_below = 'comment';
} else {
$tag = 'li';
$add_below = 'div-comment';
}
?>
<<?php echo $tag ?> <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ) ?> id="comment-<?php comment_ID() ?>">
<div class="comment-body">
<div class="comment-meta commentmetadata">
<div class="comment-author vcard">
<?php echo get_avatar( $comment, 128 ); ?>
<?php printf( __( '<cite class="fn">%s</cite>', 'storefront' ), get_comment_author_link() ); ?>
</div>
<?php if ( $comment->comment_approved == '0' ) : ?>
<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ); ?></em>
<br />
<?php endif; ?>
<a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>" class="comment-date">
<?php echo '<time>' . get_comment_date() . '</time>'; ?>
</a>
</div>
<?php if ( 'div' != $args['style'] ) : ?>
<div id="div-comment-<?php comment_ID() ?>" class="comment-content">
<?php endif; ?>
<?php comment_text(); ?>
<div class="reply">
<?php comment_reply_link( array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
<?php edit_comment_link( __( 'Edit', 'storefront' ), ' ', '' ); ?>
</div>
</div>
<?php if ( 'div' != $args['style'] ) : ?>
</div>
<?php endif; ?>
<?php
}

60
inc/structure/footer.php Normal file
View file

@ -0,0 +1,60 @@
<?php
/**
* Template functions used for the site footer.
*
* @package storefront
*/
/**
* Display the footer widget regions
* @since 1.0.0
* @return void
*/
function storefront_footer_widgets() {
if ( is_active_sidebar( 'footer-4' ) ) {
$widget_columns = apply_filters( 'storefront_footer_widget_regions', 4 );
} elseif ( is_active_sidebar( 'footer-3' ) ) {
$widget_columns = apply_filters( 'storefront_footer_widget_regions', 3 );
} elseif ( is_active_sidebar( 'footer-2' ) ) {
$widget_columns = apply_filters( 'storefront_footer_widget_regions', 2 );
} elseif ( is_active_sidebar( 'footer-1' ) ) {
$widget_columns = apply_filters( 'storefront_footer_widget_regions', 1 );
} else {
$widget_columns = apply_filters( 'storefront_footer_widget_regions', 0 );
}
if ( $widget_columns > 0 ) : ?>
<section class="footer-widgets col-full col-<?php echo $widget_columns; ?> fix">
<?php $i = 0; while ( $i < $widget_columns ) : $i++; ?>
<?php if ( is_active_sidebar( 'footer-' . $i ) ) : ?>
<section class="block footer-widget-<?php echo $i; ?>">
<?php dynamic_sidebar( 'footer-' . $i ); ?>
</section>
<?php endif; ?>
<?php endwhile; ?>
</section><!-- /.footer-widgets -->
<?php endif;
}
/**
* Display the theme credit
* @since 1.0.0
* @return void
*/
function storefront_credit() {
?>
<div class="site-info">
<a href="<?php echo esc_url( __( 'http://wordpress.org/', 'storefront' ) ); ?>"><?php printf( __( 'Proudly powered by %s', 'storefront' ), 'WordPress' ); ?></a>
<span class="sep"> | </span>
<?php printf( __( 'Theme: %1$s by %2$s.', 'storefront' ), 'storefront', '<a href="http://woothemes.com" rel="designer">woothemes</a>' ); ?>
</div><!-- .site-info -->
<?php
}

64
inc/structure/header.php Normal file
View file

@ -0,0 +1,64 @@
<?php
/**
* Template functions used for the site header.
*
* @package storefront
*/
/**
* Display header widget region
* @since 1.0.0
*/
function storefront_header_widget_region() {
?>
<div class="header-widget-region">
<div class="col-full">
<?php dynamic_sidebar( 'header-1' ); ?>
</div>
</div>
<?php
}
/**
* Display Site Branding
* @since 1.0.0
* @return void
*/
function storefront_site_branding() {
if ( function_exists( 'has_site_logo' ) && has_site_logo() ) {
the_site_logo();
} else {
?>
<div class="site-branding">
<h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
<p class="site-description"><?php bloginfo( 'description' ); ?></p>
</div>
<?php }
}
/**
* Display Primary Navigation
* @since 1.0.0
* @return void
*/
function storefront_primary_navigation() {
?>
<nav id="site-navigation" class="main-navigation" role="navigation">
<button class="menu-toggle"><?php _e( 'Primary Menu', 'storefront' ); ?></button>
<?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>
</nav><!-- #site-navigation -->
<?php
}
/**
* Display Secondary Navigation
* @since 1.0.0
* @return void
*/
function storefront_secondary_navigation() {
?>
<nav class="secondary-navigation" role="navigation">
<?php wp_nav_menu( array( 'theme_location' => 'secondary', 'fallback_cb' => '' ) ); ?>
</nav><!-- #site-navigation -->
<?php
}

View file

@ -53,11 +53,22 @@ add_action( 'homepage', 'storefront_popular_products', 50 );
add_action( 'homepage', 'storefront_on_sale_products', 60 );
/**
* Loop
* Posts
* @see storefront_post_header()
* @see storefront_post_meta()
* @see storefront_post_content()
* @see storefront_paging_nav()
* @see storefront_single_post_header()
*/
add_action( 'storefront_loop_post', 'storefront_post_header', 10 );
add_action( 'storefront_loop_post', 'storefront_post_meta', 20 );
add_action( 'storefront_loop_post', 'storefront_post_content', 30 );
add_action( 'storefront_loop_after', 'storefront_paging_nav', 10 );
add_action( 'storefront_single_post', 'storefront_post_header', 10 );
add_action( 'storefront_single_post', 'storefront_post_meta', 20 );
add_action( 'storefront_single_post', 'storefront_post_content', 30 );
/**
* Extras
* @see storefront_setup_author()

178
inc/structure/post.php Normal file
View file

@ -0,0 +1,178 @@
<?php
/**
* Template functions used for post posts.
*
* @package storefront
*/
if ( ! function_exists( 'storefront_post_header' ) ) {
/**
* Display the post header with a link to the single post
* @since 1.0.0
*/
function storefront_post_header() {
?>
<header class="entry-header">
<?php if ( is_single() ) {
storefront_posted_on();
the_title( '<h1 class="entry-title" itemprop="name headline">', '</h1>' );
} else {
if ( 'post' == get_post_type() ) {
storefront_posted_on();
}
the_title( sprintf( '<h1 class="entry-title" itemprop="name headline"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h1>' );
} ?>
</header><!-- .entry-header -->
<?php
}
}
if ( ! function_exists( 'storefront_post_content' ) ) {
/**
* Display the post content with a link to the single post
* @since 1.0.0
*/
function storefront_post_content() {
?>
<div class="entry-content" itemprop="articleBody">
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail( 'full', array( 'itemprop' => 'image' ) );
}
?>
<?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'storefront' ) ); ?>
<?php
wp_link_pages( array(
'before' => '<div class="page-links">' . __( 'Pages:', 'storefront' ),
'after' => '</div>',
) );
?>
</div><!-- .entry-content -->
<?php
}
}
if ( ! function_exists( 'storefront_post_meta' ) ) {
/**
* Display the post meta
* @since 1.0.0
*/
function storefront_post_meta() {
?>
<aside class="entry-meta">
<?php if ( 'post' == get_post_type() ) : // Hide category and tag text for pages on Search ?>
<?php
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list( __( ', ', 'storefront' ) );
if ( $categories_list && storefront_categorized_blog() ) :
?>
<span class="cat-links">
<?php echo $categories_list; ?>
</span>
<?php endif; // End if categories ?>
<?php
/* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list( '', __( ', ', 'storefront' ) );
if ( $tags_list ) :
?>
<span class="tags-links">
<?php echo $tags_list; ?>
</span>
<?php endif; // End if $tags_list ?>
<?php endif; // End if 'post' == get_post_type() ?>
<?php if ( ! post_password_required() && ( comments_open() || '0' != get_comments_number() ) ) : ?>
<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'storefront' ), __( '1 Comment', 'storefront' ), __( '% Comments', 'storefront' ) ); ?></span>
<?php endif; ?>
</aside>
<?php
}
}
if ( ! function_exists( 'storefront_paging_nav' ) ) {
/**
* Display navigation to next/previous set of posts when applicable.
*/
function storefront_paging_nav() {
// Don't print empty markup if there's only one page.
if ( $GLOBALS['wp_query']->max_num_pages < 2 ) {
return;
}
?>
<nav class="navigation paging-navigation" role="navigation">
<h1 class="screen-reader-text"><?php _e( 'Posts navigation', 'storefront' ); ?></h1>
<div class="nav-links">
<?php if ( get_next_posts_link() ) : ?>
<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'storefront' ) ); ?></div>
<?php endif; ?>
<?php if ( get_previous_posts_link() ) : ?>
<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'storefront' ) ); ?></div>
<?php endif; ?>
</div><!-- .nav-links -->
</nav><!-- .navigation -->
<?php
}
}
if ( ! function_exists( 'storefront_post_nav' ) ) {
/**
* Display navigation to next/previous post when applicable.
*/
function storefront_post_nav() {
// Don't print empty markup if there's nowhere to navigate.
$previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true );
$next = get_adjacent_post( false, '', false );
if ( ! $next && ! $previous ) {
return;
}
?>
<nav class="navigation post-navigation" role="navigation">
<h1 class="screen-reader-text"><?php _e( 'Post navigation', 'storefront' ); ?></h1>
<div class="nav-links">
<?php
previous_post_link( '<div class="nav-previous">%link</div>', _x( '<span class="meta-nav">&larr;</span>&nbsp;%title', 'Previous post link', 'storefront' ) );
next_post_link( '<div class="nav-next">%link</div>', _x( '%title&nbsp;<span class="meta-nav">&rarr;</span>', 'Next post link', 'storefront' ) );
?>
</div><!-- .nav-links -->
</nav><!-- .navigation -->
<?php
}
}
if ( ! function_exists( 'storefront_posted_on' ) ) {
/**
* Prints HTML with meta information for the current post-date/time and author.
*/
function storefront_posted_on() {
$time_string = '<time class="entry-date published updated" datetime="%1$s" itemprop="datePublished">%2$s</time>';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s" itemprop="datePublished">%4$s</time>';
}
$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date() )
);
$posted_on = sprintf(
_x( 'Posted on %s', 'post date', 'storefront' ),
'<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'
);
$byline = sprintf(
_x( 'by %s', 'post author', 'storefront' ),
'<span class="author vcard" itemprop="author" itemscope="" itemtype="http://schema.org/Person"><a class="url fn n" itemprop="name" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>'
);
echo '<span class="posted-on">' . $posted_on . '</span><span class="byline"> ' . $byline . '</span>';
}
}

View file

@ -7,197 +7,14 @@
* @package storefront
*/
if ( ! function_exists( 'storefront_paging_nav' ) ) :
/**
* Display navigation to next/previous set of posts when applicable.
*/
function storefront_paging_nav() {
// Don't print empty markup if there's only one page.
if ( $GLOBALS['wp_query']->max_num_pages < 2 ) {
return;
}
?>
<nav class="navigation paging-navigation" role="navigation">
<h1 class="screen-reader-text"><?php _e( 'Posts navigation', 'storefront' ); ?></h1>
<div class="nav-links">
<?php if ( get_next_posts_link() ) : ?>
<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'storefront' ) ); ?></div>
<?php endif; ?>
<?php if ( get_previous_posts_link() ) : ?>
<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'storefront' ) ); ?></div>
<?php endif; ?>
</div><!-- .nav-links -->
</nav><!-- .navigation -->
<?php
}
endif;
if ( ! function_exists( 'storefront_post_nav' ) ) :
/**
* Display navigation to next/previous post when applicable.
*/
function storefront_post_nav() {
// Don't print empty markup if there's nowhere to navigate.
$previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true );
$next = get_adjacent_post( false, '', false );
if ( ! $next && ! $previous ) {
return;
}
?>
<nav class="navigation post-navigation" role="navigation">
<h1 class="screen-reader-text"><?php _e( 'Post navigation', 'storefront' ); ?></h1>
<div class="nav-links">
<?php
previous_post_link( '<div class="nav-previous">%link</div>', _x( '<span class="meta-nav">&larr;</span>&nbsp;%title', 'Previous post link', 'storefront' ) );
next_post_link( '<div class="nav-next">%link</div>', _x( '%title&nbsp;<span class="meta-nav">&rarr;</span>', 'Next post link', 'storefront' ) );
?>
</div><!-- .nav-links -->
</nav><!-- .navigation -->
<?php
}
endif;
if ( ! function_exists( 'storefront_posted_on' ) ) :
/**
* Prints HTML with meta information for the current post-date/time and author.
*/
function storefront_posted_on() {
$time_string = '<time class="entry-date published updated" datetime="%1$s" itemprop="datePublished">%2$s</time>';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s" itemprop="datePublished">%4$s</time>';
}
$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date() )
);
$posted_on = sprintf(
_x( 'Posted on %s', 'post date', 'storefront' ),
'<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'
);
$byline = sprintf(
_x( 'by %s', 'post author', 'storefront' ),
'<span class="author vcard" itemprop="author" itemscope="" itemtype="http://schema.org/Person"><a class="url fn n" itemprop="name" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>'
);
echo '<span class="posted-on">' . $posted_on . '</span><span class="byline"> ' . $byline . '</span>';
}
endif;
/**
* Returns true if a blog has more than 1 category.
*
* @return bool
*/
function storefront_categorized_blog() {
if ( false === ( $all_the_cool_cats = get_transient( 'storefront_categories' ) ) ) {
// Create an array of all the categories that are attached to posts.
$all_the_cool_cats = get_categories( array(
'fields' => 'ids',
'hide_empty' => 1,
// We only need to know if there is more than one category.
'number' => 2,
) );
// Count the number of categories that are attached to the posts.
$all_the_cool_cats = count( $all_the_cool_cats );
set_transient( 'storefront_categories', $all_the_cool_cats );
}
if ( $all_the_cool_cats > 1 ) {
// This blog has more than 1 category so storefront_categorized_blog should return true.
return true;
} else {
// This blog has only 1 category so storefront_categorized_blog should return false.
return false;
}
}
/**
* Flush out the transients used in storefront_categorized_blog.
*/
function storefront_category_transient_flusher() {
// Like, beat it. Dig?
delete_transient( 'storefront_categories' );
}
add_action( 'edit_category', 'storefront_category_transient_flusher' );
add_action( 'save_post', 'storefront_category_transient_flusher' );
/**
* Display header widget region
* @since 1.0.0
*/
function storefront_header_widget_region() {
?>
<div class="header-widget-region">
<div class="col-full">
<?php dynamic_sidebar( 'header-1' ); ?>
</div>
</div>
<?php
}
/**
* Display Site Branding
* @since 1.0.0
* @return void
*/
function storefront_site_branding() {
if ( function_exists( 'has_site_logo' ) && has_site_logo() ) {
the_site_logo();
} else {
?>
<div class="site-branding">
<h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
<p class="site-description"><?php bloginfo( 'description' ); ?></p>
</div>
<?php }
}
/**
* Display Primary Navigation
* @since 1.0.0
* @return void
*/
function storefront_primary_navigation() {
?>
<nav id="site-navigation" class="main-navigation" role="navigation">
<button class="menu-toggle"><?php _e( 'Primary Menu', 'storefront' ); ?></button>
<?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>
</nav><!-- #site-navigation -->
<?php
}
/**
* Display Secondary Navigation
* @since 1.0.0
* @return void
*/
function storefront_secondary_navigation() {
?>
<nav class="secondary-navigation" role="navigation">
<?php wp_nav_menu( array( 'theme_location' => 'secondary', 'fallback_cb' => '' ) ); ?>
</nav><!-- #site-navigation -->
<?php
}
/**
if ( ! function_exists( 'storefront_product_categories' ) ) {
/**
* Display Product Categories
* Hooked into the `homepage` action in the homepage template
* @since 1.0.0
* @return void
*/
function storefront_product_categories( $defaults ) {
function storefront_product_categories( $defaults ) {
$defaults = apply_filters( 'storefront_product_categories_args', array(
'limit' => 3,
@ -213,14 +30,17 @@ function storefront_product_categories( $defaults ) {
echo do_shortcode( '[product_categories number="' . $defaults['limit'] . '" columns="' . $defaults['columns'] . '" orderby="' . $defaults['orderby'] . '" parent="' . $defaults['child_categories'] . '"]' );
echo '</section>';
}
}
/**
if ( ! function_exists( 'storefront_recent_products' ) ) {
/**
* Display Recent Products
* Hooked into the `homepage` action in the homepage template
* @since 1.0.0
* @return void
*/
function storefront_recent_products( $defaults ) {
function storefront_recent_products( $defaults ) {
$defaults = apply_filters( 'storefront_recent_products_args', array(
'limit' => 4,
'columns' => 4,
@ -233,14 +53,17 @@ function storefront_recent_products( $defaults ) {
echo do_shortcode( '[recent_products per_page="' . $defaults['limit'] . '" columns="' . $defaults['columns'] . '"]' );
echo '</section>';
}
}
/**
if ( ! function_exists( 'storefront_featured_products' ) ) {
/**
* Display Featured Products
* Hooked into the `homepage` action in the homepage template
* @since 1.0.0
* @return void
*/
function storefront_featured_products( $defaults ) {
function storefront_featured_products( $defaults ) {
$defaults = apply_filters( 'storefront_featured_products_args', array(
'limit' => 4,
'columns' => 4,
@ -253,14 +76,17 @@ function storefront_featured_products( $defaults ) {
echo do_shortcode( '[featured_products per_page="' . $defaults['limit'] . '" columns="' . $defaults['columns'] . '"]' );
echo '</section>';
}
}
/**
if ( ! function_exists( 'storefront_popular_products' ) ) {
/**
* Display Popular Products
* Hooked into the `homepage` action in the homepage template
* @since 1.0.0
* @return void
*/
function storefront_popular_products( $defaults ) {
function storefront_popular_products( $defaults ) {
$defaults = apply_filters( 'storefront_popular_products_args', array(
'limit' => 4,
'columns' => 4,
@ -273,14 +99,17 @@ function storefront_popular_products( $defaults ) {
echo do_shortcode( '[top_rated_products per_page="' . $defaults['limit'] . '" columns="' . $defaults['columns'] . '"]' );
echo '</section>';
}
}
/**
if ( ! function_exists( 'storefront_on_sale_products' ) ) {
/**
* Display On Sale Products
* Hooked into the `homepage` action in the homepage template
* @since 1.0.0
* @return void
*/
function storefront_on_sale_products( $defaults ) {
function storefront_on_sale_products( $defaults ) {
$defaults = apply_filters( 'storefront_on_sale_products_args', array(
'limit' => 4,
'columns' => 4,
@ -293,116 +122,21 @@ function storefront_on_sale_products( $defaults ) {
echo do_shortcode( '[sale_products per_page="' . $defaults['limit'] . '" columns="' . $defaults['columns'] . '"]' );
echo '</section>';
}
}
/**
if ( ! function_exists( 'storefront_page_content' ) ) {
/**
* Display page content
* Hooked into the `homepage` action in the homepage template
* @since 1.0.0
* @return void
*/
function storefront_page_content() {
function storefront_page_content() {
while ( have_posts() ) : the_post();
get_template_part( 'content', 'page' );
endwhile; // end of the loop.
}
/**
* Display the footer widget regions
* @since 1.0.0
* @return void
*/
function storefront_footer_widgets() {
if ( is_active_sidebar( 'footer-4' ) ) {
$widget_columns = apply_filters( 'storefront_footer_widget_regions', 4 );
} elseif ( is_active_sidebar( 'footer-3' ) ) {
$widget_columns = apply_filters( 'storefront_footer_widget_regions', 3 );
} elseif ( is_active_sidebar( 'footer-2' ) ) {
$widget_columns = apply_filters( 'storefront_footer_widget_regions', 2 );
} elseif ( is_active_sidebar( 'footer-1' ) ) {
$widget_columns = apply_filters( 'storefront_footer_widget_regions', 1 );
} else {
$widget_columns = apply_filters( 'storefront_footer_widget_regions', 0 );
}
if ( $widget_columns > 0 ) : ?>
<section class="footer-widgets col-full col-<?php echo $widget_columns; ?> fix">
<?php $i = 0; while ( $i < $widget_columns ) : $i++; ?>
<?php if ( is_active_sidebar( 'footer-' . $i ) ) : ?>
<section class="block footer-widget-<?php echo $i; ?>">
<?php dynamic_sidebar( 'footer-' . $i ); ?>
</section>
<?php endif; ?>
<?php endwhile; ?>
</section><!-- /.footer-widgets -->
<?php endif;
}
/**
* Display the theme credit
* @since 1.0.0
* @return void
*/
function storefront_credit() {
?>
<div class="site-info">
<a href="<?php echo esc_url( __( 'http://wordpress.org/', 'storefront' ) ); ?>"><?php printf( __( 'Proudly powered by %s', 'storefront' ), 'WordPress' ); ?></a>
<span class="sep"> | </span>
<?php printf( __( 'Theme: %1$s by %2$s.', 'storefront' ), 'storefront', '<a href="http://woothemes.com" rel="designer">woothemes</a>' ); ?>
</div><!-- .site-info -->
<?php
}
function storefront_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
extract( $args, EXTR_SKIP );
if ( 'div' == $args['style'] ) {
$tag = 'div';
$add_below = 'comment';
} else {
$tag = 'li';
$add_below = 'div-comment';
}
?>
<<?php echo $tag ?> <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ) ?> id="comment-<?php comment_ID() ?>">
<div class="comment-body">
<div class="comment-meta commentmetadata">
<div class="comment-author vcard">
<?php echo get_avatar( $comment, 128 ); ?>
<?php printf( __( '<cite class="fn">%s</cite>', 'storefront' ), get_comment_author_link() ); ?>
</div>
<?php if ( $comment->comment_approved == '0' ) : ?>
<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ); ?></em>
<br />
<?php endif; ?>
<a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>" class="comment-date">
<?php echo '<time>' . get_comment_date() . '</time>'; ?>
</a>
</div>
<?php if ( 'div' != $args['style'] ) : ?>
<div id="div-comment-<?php comment_ID() ?>" class="comment-content">
<?php endif; ?>
<?php comment_text(); ?>
<div class="reply">
<?php comment_reply_link( array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
<?php edit_comment_link( __( 'Edit', 'storefront' ), ' ', '' ); ?>
</div>
</div>
<?php if ( 'div' != $args['style'] ) : ?>
</div>
<?php endif; ?>
<?php
}