2016-01-20 16:02:53 +00:00
< ? php
/**
* Storefront template functions .
*
* @ package storefront
*/
if ( ! function_exists ( 'storefront_display_comments' ) ) {
/**
* Storefront display comments
2016-02-19 16:57:56 +00:00
*
2016-01-20 16:02:53 +00:00
* @ since 1.0 . 0
*/
function storefront_display_comments () {
2016-02-19 16:57:56 +00:00
// If comments are open or we have at least one comment, load up the comment template.
2016-01-20 16:02:53 +00:00
if ( comments_open () || '0' != get_comments_number () ) :
comments_template ();
endif ;
}
}
if ( ! function_exists ( 'storefront_comment' ) ) {
/**
* Storefront comment template
2016-02-19 16:57:56 +00:00
*
* @ param array $comment the comment array .
2016-02-25 14:46:06 +00:00
* @ param array $args the comment args .
* @ param int $depth the comment depth .
2016-01-20 16:02:53 +00:00
* @ since 1.0 . 0
*/
function storefront_comment ( $comment , $args , $depth ) {
if ( 'div' == $args [ 'style' ] ) {
$tag = 'div' ;
$add_below = 'comment' ;
} else {
$tag = 'li' ;
$add_below = 'div-comment' ;
}
?>
<< ? php echo esc_attr ( $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 ); ?>
2016-03-15 13:18:22 +00:00
< ? php printf ( wp_kses_post ( '<cite class="fn">%s</cite>' , 'storefront' ), get_comment_author_link () ); ?>
2016-01-20 16:02:53 +00:00
</ div >
< ? php if ( '0' == $comment -> comment_approved ) : ?>
2016-02-19 16:57:56 +00:00
< em class = " comment-awaiting-moderation " >< ? php esc_attr_e ( 'Your comment is awaiting moderation.' , 'storefront' ); ?> </em>
2016-01-20 16:02:53 +00:00
< br />
< ? php endif ; ?>
< a href = " <?php echo esc_url( htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ); ?> " class = " comment-date " >
2016-07-27 19:40:14 +02:00
< ? php echo '<time datetime="' . get_comment_date ( 'c' ) . '">' . get_comment_date () . '</time>' ; ?>
2016-01-20 16:02:53 +00:00
</ a >
</ div >
< ? php if ( 'div' != $args [ 'style' ] ) : ?>
< div id = " div-comment-<?php comment_ID() ?> " class = " comment-content " >
< ? php endif ; ?>
2016-04-25 13:49:21 +01:00
< div class = " comment-text " >
2016-01-20 16:02:53 +00:00
< ? php comment_text (); ?>
2016-04-25 13:49:21 +01:00
</ div >
2016-01-20 16:02:53 +00:00
< 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
}
}
if ( ! function_exists ( 'storefront_footer_widgets' ) ) {
/**
* Display the footer widget regions
2016-02-19 16:57:56 +00:00
*
2016-01-20 16:02:53 +00:00
* @ 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 ) : ?>
2016-07-26 08:20:51 +02:00
< div class = " footer-widgets col-<?php echo intval( $widget_columns ); ?> fix " >
2016-01-20 16:02:53 +00:00
2016-02-25 14:46:06 +00:00
< ? php
$i = 0 ;
while ( $i < $widget_columns ) : $i ++ ;
if ( is_active_sidebar ( 'footer-' . $i ) ) : ?>
2016-01-20 16:02:53 +00:00
2016-07-26 08:20:51 +02:00
< div class = " block footer-widget-<?php echo intval( $i ); ?> " >
2016-02-25 14:46:06 +00:00
< ? php dynamic_sidebar ( 'footer-' . intval ( $i ) ); ?>
2016-07-26 08:20:51 +02:00
</ div >
2016-01-20 16:02:53 +00:00
2016-02-25 14:46:06 +00:00
< ? php endif ;
endwhile ; ?>
2016-01-20 16:02:53 +00:00
2016-07-26 08:20:51 +02:00
</ div ><!-- /. footer - widgets -->
2016-01-20 16:02:53 +00:00
< ? php endif ;
}
}
if ( ! function_exists ( 'storefront_credit' ) ) {
/**
* Display the theme credit
2016-02-19 16:57:56 +00:00
*
2016-01-20 16:02:53 +00:00
* @ since 1.0 . 0
* @ return void
*/
function storefront_credit () {
?>
< div class = " site-info " >
< ? php echo esc_html ( apply_filters ( 'storefront_copyright_text' , $content = '© ' . get_bloginfo ( 'name' ) . ' ' . date ( 'Y' ) ) ); ?>
< ? php if ( apply_filters ( 'storefront_credit_link' , true ) ) { ?>
2016-07-26 08:20:51 +02:00
< br /> < ? php printf ( esc_attr__ ( '%1$s designed by %2$s.' , 'storefront' ), 'Storefront' , '<a href="http://www.woothemes.com" title="Premium WordPress Themes & Plugins by WooThemes" rel="author">WooThemes</a>' ); ?>
2016-01-20 16:02:53 +00:00
< ? php } ?>
</ div ><!-- . site - info -->
< ? php
}
}
if ( ! function_exists ( 'storefront_header_widget_region' ) ) {
/**
* Display header widget region
2016-02-19 16:57:56 +00:00
*
2016-01-20 16:02:53 +00:00
* @ since 1.0 . 0
*/
function storefront_header_widget_region () {
if ( is_active_sidebar ( 'header-1' ) ) {
?>
< div class = " header-widget-region " role = " complementary " >
< div class = " col-full " >
< ? php dynamic_sidebar ( 'header-1' ); ?>
</ div >
</ div >
< ? php
}
}
}
if ( ! function_exists ( 'storefront_site_branding' ) ) {
/**
* Display Site Branding
2016-02-19 16:57:56 +00:00
*
2016-01-20 16:02:53 +00:00
* @ since 1.0 . 0
* @ return void
*/
2016-08-01 11:17:10 +01:00
function storefront_site_branding () {
?>
< div class = " site-branding " >
< ? php
if ( function_exists ( 'the_custom_logo' ) && has_custom_logo () ) {
$logo = get_custom_logo ();
echo $logo = is_front_page () ? '<h1>' . $logo . '</h1>' : $logo ;
} elseif ( function_exists ( 'jetpack_has_site_logo' ) && jetpack_has_site_logo () ) {
jetpack_the_site_logo ();
} else {
$tag = is_front_page () ? 'h1' : 'div' ;
echo '<' . esc_attr ( $tag ) . ' class="beta site-title"><a href="' . esc_url ( home_url ( '/' ) ) . '" rel="home">' . esc_attr ( get_bloginfo ( 'name' ) ) . '</a></' . esc_attr ( $tag ) . '>' ;
if ( '' != get_bloginfo ( 'description' ) ) { ?>
2016-01-20 16:02:53 +00:00
< p class = " site-description " >< ? php echo bloginfo ( 'description' ); ?> </p>
2016-08-01 11:17:10 +01:00
< ? php
}
} ?>
</ div >
< ? php
2016-01-20 16:02:53 +00:00
}
}
if ( ! function_exists ( 'storefront_primary_navigation' ) ) {
/**
* Display Primary Navigation
2016-02-19 16:57:56 +00:00
*
2016-01-20 16:02:53 +00:00
* @ since 1.0 . 0
* @ return void
*/
function storefront_primary_navigation () {
?>
2016-07-27 15:50:32 +02:00
< nav id = " site-navigation " class = " main-navigation " role = " navigation " aria - label = " <?php esc_html_e( 'Primary Navigation', 'storefront' ); ?> " >
2016-07-26 08:20:51 +02:00
< button class = " menu-toggle " aria - controls = " site-navigation " aria - expanded = " false " >< span >< ? php echo esc_attr ( apply_filters ( 'storefront_menu_toggle_text' , __ ( 'Menu' , 'storefront' ) ) ); ?> </span></button>
2016-01-20 16:02:53 +00:00
< ? php
wp_nav_menu (
array (
'theme_location' => 'primary' ,
'container_class' => 'primary-navigation' ,
)
);
wp_nav_menu (
array (
'theme_location' => 'handheld' ,
'container_class' => 'handheld-navigation' ,
)
);
?>
2016-07-27 15:50:32 +02:00
</ nav ><!-- #site-navigation -->
2016-01-20 16:02:53 +00:00
< ? php
}
}
if ( ! function_exists ( 'storefront_secondary_navigation' ) ) {
/**
* Display Secondary Navigation
2016-02-19 16:57:56 +00:00
*
2016-01-20 16:02:53 +00:00
* @ since 1.0 . 0
* @ return void
*/
function storefront_secondary_navigation () {
2016-06-23 05:46:21 -06:00
if ( has_nav_menu ( 'secondary' ) ) {
?>
2016-07-27 15:50:32 +02:00
< nav class = " secondary-navigation " role = " navigation " aria - label = " <?php esc_html_e( 'Secondary Navigation', 'storefront' ); ?> " >
2016-06-23 05:46:21 -06:00
< ? php
wp_nav_menu (
array (
'theme_location' => 'secondary' ,
'fallback_cb' => '' ,
)
);
?>
2016-07-27 15:50:32 +02:00
</ nav ><!-- #site-navigation -->
2016-06-23 05:46:21 -06:00
< ? php
}
2016-01-20 16:02:53 +00:00
}
}
if ( ! function_exists ( 'storefront_skip_links' ) ) {
/**
* Skip links
2016-02-19 16:57:56 +00:00
*
2016-01-20 16:02:53 +00:00
* @ since 1.4 . 1
* @ return void
*/
function storefront_skip_links () {
?>
2016-02-19 16:57:56 +00:00
< a class = " skip-link screen-reader-text " href = " #site-navigation " >< ? php esc_attr_e ( 'Skip to navigation' , 'storefront' ); ?> </a>
< a class = " skip-link screen-reader-text " href = " #content " >< ? php esc_attr_e ( 'Skip to content' , 'storefront' ); ?> </a>
2016-01-20 16:02:53 +00:00
< ? php
}
}
if ( ! function_exists ( 'storefront_page_header' ) ) {
/**
* Display the post header with a link to the single post
2016-02-19 16:57:56 +00:00
*
2016-01-20 16:02:53 +00:00
* @ since 1.0 . 0
*/
function storefront_page_header () {
?>
< header class = " entry-header " >
< ? php
storefront_post_thumbnail ( 'full' );
2016-05-26 07:57:50 +02:00
the_title ( '<h1 class="entry-title">' , '</h1>' );
2016-01-20 16:02:53 +00:00
?>
</ header ><!-- . entry - header -->
< ? php
}
}
if ( ! function_exists ( 'storefront_page_content' ) ) {
/**
* Display the post content with a link to the single post
2016-02-19 16:57:56 +00:00
*
2016-01-20 16:02:53 +00:00
* @ since 1.0 . 0
*/
function storefront_page_content () {
?>
2016-05-26 07:57:50 +02:00
< div class = " entry-content " >
2016-01-20 16:02:53 +00:00
< ? php the_content (); ?>
< ? php
wp_link_pages ( array (
'before' => '<div class="page-links">' . __ ( 'Pages:' , 'storefront' ),
'after' => '</div>' ,
) );
?>
</ div ><!-- . entry - content -->
< ? php
}
}
if ( ! function_exists ( 'storefront_post_header' ) ) {
/**
* Display the post header with a link to the single post
2016-02-19 16:57:56 +00:00
*
2016-01-20 16:02:53 +00:00
* @ since 1.0 . 0
*/
2016-02-25 14:46:06 +00:00
function storefront_post_header () {
?>
2016-01-20 16:02:53 +00:00
< header class = " entry-header " >
< ? php
if ( is_single () ) {
storefront_posted_on ();
2016-05-26 07:57:50 +02:00
the_title ( '<h1 class="entry-title">' , '</h1>' );
2016-01-20 16:02:53 +00:00
} else {
if ( 'post' == get_post_type () ) {
storefront_posted_on ();
}
2016-07-28 14:27:12 +02:00
the_title ( sprintf ( '<h2 class="alpha entry-title"><a href="%s" rel="bookmark">' , esc_url ( get_permalink () ) ), '</a></h2>' );
2016-01-20 16:02:53 +00:00
}
?>
</ header ><!-- . entry - header -->
< ? php
}
}
if ( ! function_exists ( 'storefront_post_content' ) ) {
/**
* Display the post content with a link to the single post
2016-02-19 16:57:56 +00:00
*
2016-01-20 16:02:53 +00:00
* @ since 1.0 . 0
*/
function storefront_post_content () {
?>
2016-05-26 07:57:50 +02:00
< div class = " entry-content " >
2016-01-20 16:02:53 +00:00
< ? php
storefront_post_thumbnail ( 'full' );
the_content (
sprintf (
__ ( 'Continue reading %s' , 'storefront' ),
'<span class="screen-reader-text">' . get_the_title () . '</span>'
)
);
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
2016-02-19 16:57:56 +00:00
*
2016-01-20 16:02:53 +00:00
* @ since 1.0 . 0
*/
function storefront_post_meta () {
?>
< aside class = " entry-meta " >
2016-02-19 16:57:56 +00:00
< ? php if ( 'post' == get_post_type () ) : // Hide category and tag text for pages on Search.
2016-01-20 16:02:53 +00:00
2016-02-05 09:55:25 +00:00
?>
< div class = " author " >
< ? php
echo get_avatar ( get_the_author_meta ( 'ID' ), 128 );
echo '<div class="label">' . esc_attr ( __ ( 'Written by' , 'storefront' ) ) . '</div>' ;
the_author_posts_link ();
?>
</ div >
2016-01-20 16:02:53 +00:00
< ? php
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list ( __ ( ', ' , 'storefront' ) );
2016-01-21 10:50:49 +00:00
if ( $categories_list ) : ?>
2016-02-05 09:55:25 +00:00
< div class = " cat-links " >
2016-01-20 16:02:53 +00:00
< ? php
2016-02-05 09:55:25 +00:00
echo '<div class="label">' . esc_attr ( __ ( 'Posted in' , 'storefront' ) ) . '</div>' ;
2016-01-20 16:02:53 +00:00
echo wp_kses_post ( $categories_list );
?>
2016-02-05 09:55:25 +00:00
</ div >
2016-02-19 16:57:56 +00:00
< ? php endif ; // End if categories. ?>
2016-01-20 16:02:53 +00:00
< ? php
/* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list ( '' , __ ( ', ' , 'storefront' ) );
if ( $tags_list ) : ?>
2016-02-05 09:55:25 +00:00
< div class = " tags-links " >
2016-01-20 16:02:53 +00:00
< ? php
2016-02-05 09:55:25 +00:00
echo '<div class="label">' . esc_attr ( __ ( 'Tagged' , 'storefront' ) ) . '</div>' ;
2016-01-20 16:02:53 +00:00
echo wp_kses_post ( $tags_list );
?>
2016-02-05 09:55:25 +00:00
</ div >
2016-02-19 16:57:56 +00:00
< ? php endif ; // End if $tags_list. ?>
2016-01-20 16:02:53 +00:00
2016-02-19 16:57:56 +00:00
< ? php endif ; // End if 'post' == get_post_type(). ?>
2016-01-20 16:02:53 +00:00
< ? php if ( ! post_password_required () && ( comments_open () || '0' != get_comments_number () ) ) : ?>
2016-03-01 20:32:55 +00:00
< div class = " comments-link " >
< ? php echo '<div class="label">' . esc_attr ( __ ( 'Comments' , 'storefront' ) ) . '</div>' ; ?>
< span class = " comments-link " >< ? php comments_popup_link ( __ ( 'Leave a comment' , 'storefront' ), __ ( '1 Comment' , 'storefront' ), __ ( '% Comments' , 'storefront' ) ); ?> </span>
</ div >
2016-01-20 16:02:53 +00:00
< ? php endif ; ?>
</ aside >
< ? php
}
}
if ( ! function_exists ( 'storefront_paging_nav' ) ) {
/**
* Display navigation to next / previous set of posts when applicable .
*/
function storefront_paging_nav () {
global $wp_query ;
$args = array (
'type' => 'list' ,
2016-04-11 15:16:11 -05:00
'next_text' => _x ( 'Next' , 'Next post' , 'storefront' ),
'prev_text' => _x ( 'Previous' , 'Previous post' , 'storefront' ),
2016-01-20 16:02:53 +00:00
);
the_posts_pagination ( $args );
}
}
if ( ! function_exists ( 'storefront_post_nav' ) ) {
/**
* Display navigation to next / previous post when applicable .
*/
function storefront_post_nav () {
$args = array (
2016-04-11 15:16:11 -05:00
'next_text' => '%title' ,
'prev_text' => '%title' ,
2016-01-20 16:02:53 +00:00
);
the_post_navigation ( $args );
}
}
if ( ! function_exists ( 'storefront_posted_on' ) ) {
/**
* Prints HTML with meta information for the current post - date / time and author .
*/
function storefront_posted_on () {
2016-05-26 07:57:50 +02:00
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>' ;
2016-01-20 16:02:53 +00:00
if ( get_the_time ( 'U' ) !== get_the_modified_time ( 'U' ) ) {
2016-05-26 07:57:50 +02:00
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time> <time class="updated" datetime="%3$s">%4$s</time>' ;
2016-01-20 16:02:53 +00:00
}
$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>'
);
2016-02-22 15:22:16 +00:00
echo wp_kses ( apply_filters ( 'storefront_single_post_posted_on_html' , '<span class="posted-on">' . $posted_on . '</span>' , $posted_on ), array (
2016-02-23 16:21:49 +05:30
'span' => array (
'class' => array (),
),
2016-02-22 15:22:16 +00:00
'a' => array (
'href' => array (),
'title' => array (),
'rel' => array (),
),
'time' => array (
'datetime' => array (),
'class' => array (),
),
2016-02-25 14:46:06 +00:00
) );
2016-01-20 16:02:53 +00:00
}
}
if ( ! function_exists ( 'storefront_product_categories' ) ) {
/**
* Display Product Categories
* Hooked into the `homepage` action in the homepage template
2016-02-19 16:57:56 +00:00
*
2016-01-20 16:02:53 +00:00
* @ since 1.0 . 0
2016-02-25 14:46:06 +00:00
* @ param array $args the product section args .
2016-01-20 16:02:53 +00:00
* @ return void
*/
function storefront_product_categories ( $args ) {
if ( is_woocommerce_activated () ) {
$args = apply_filters ( 'storefront_product_categories_args' , array (
'limit' => 3 ,
'columns' => 3 ,
'child_categories' => 0 ,
'orderby' => 'name' ,
2016-02-09 17:26:28 +00:00
'title' => __ ( 'Shop by Category' , 'storefront' ),
2016-02-19 16:57:56 +00:00
) );
2016-01-20 16:02:53 +00:00
2016-07-28 18:17:31 +02:00
echo '<section class="storefront-product-section storefront-product-categories" aria-label="Product Categories">' ;
2016-01-20 16:02:53 +00:00
2016-02-25 14:46:06 +00:00
do_action ( 'storefront_homepage_before_product_categories' );
2016-01-20 16:02:53 +00:00
2016-02-25 14:46:06 +00:00
echo '<h2 class="section-title">' . wp_kses_post ( $args [ 'title' ] ) . '</h2>' ;
2016-01-20 16:02:53 +00:00
2016-02-25 14:46:06 +00:00
do_action ( 'storefront_homepage_after_product_categories_title' );
2016-01-20 16:02:53 +00:00
2016-02-25 14:46:06 +00:00
echo storefront_do_shortcode ( 'product_categories' , array (
'number' => intval ( $args [ 'limit' ] ),
'columns' => intval ( $args [ 'columns' ] ),
'orderby' => esc_attr ( $args [ 'orderby' ] ),
'parent' => esc_attr ( $args [ 'child_categories' ] ),
) );
2016-01-20 16:02:53 +00:00
2016-02-25 14:46:06 +00:00
do_action ( 'storefront_homepage_after_product_categories' );
2016-01-20 16:02:53 +00:00
echo '</section>' ;
}
}
}
if ( ! function_exists ( 'storefront_recent_products' ) ) {
/**
* Display Recent Products
* Hooked into the `homepage` action in the homepage template
2016-02-19 16:57:56 +00:00
*
2016-01-20 16:02:53 +00:00
* @ since 1.0 . 0
2016-02-25 14:46:06 +00:00
* @ param array $args the product section args .
2016-01-20 16:02:53 +00:00
* @ return void
*/
function storefront_recent_products ( $args ) {
if ( is_woocommerce_activated () ) {
$args = apply_filters ( 'storefront_recent_products_args' , array (
'limit' => 4 ,
'columns' => 4 ,
2016-02-09 17:26:28 +00:00
'title' => __ ( 'New In' , 'storefront' ),
2016-02-19 16:57:56 +00:00
) );
2016-01-20 16:02:53 +00:00
2016-07-28 18:17:31 +02:00
echo '<section class="storefront-product-section storefront-recent-products" aria-label="Recent Products">' ;
2016-01-20 16:02:53 +00:00
2016-02-25 14:46:06 +00:00
do_action ( 'storefront_homepage_before_recent_products' );
2016-01-20 16:02:53 +00:00
2016-02-25 14:46:06 +00:00
echo '<h2 class="section-title">' . wp_kses_post ( $args [ 'title' ] ) . '</h2>' ;
2016-01-20 16:02:53 +00:00
2016-02-25 14:46:06 +00:00
do_action ( 'storefront_homepage_after_recent_products_title' );
2016-01-20 16:02:53 +00:00
2016-02-25 14:46:06 +00:00
echo storefront_do_shortcode ( 'recent_products' , array (
'per_page' => intval ( $args [ 'limit' ] ),
'columns' => intval ( $args [ 'columns' ] ),
) );
2016-01-20 16:02:53 +00:00
2016-02-25 14:46:06 +00:00
do_action ( 'storefront_homepage_after_recent_products' );
2016-01-20 16:02:53 +00:00
echo '</section>' ;
}
}
}
if ( ! function_exists ( 'storefront_featured_products' ) ) {
/**
* Display Featured Products
* Hooked into the `homepage` action in the homepage template
2016-02-19 16:57:56 +00:00
*
2016-01-20 16:02:53 +00:00
* @ since 1.0 . 0
2016-02-25 14:46:06 +00:00
* @ param array $args the product section args .
2016-01-20 16:02:53 +00:00
* @ return void
*/
function storefront_featured_products ( $args ) {
if ( is_woocommerce_activated () ) {
$args = apply_filters ( 'storefront_featured_products_args' , array (
2016-02-19 16:57:56 +00:00
'limit' => 4 ,
'columns' => 4 ,
'orderby' => 'date' ,
'order' => 'desc' ,
'title' => __ ( 'We Recommend' , 'storefront' ),
) );
2016-01-20 16:02:53 +00:00
2016-07-28 18:17:31 +02:00
echo '<section class="storefront-product-section storefront-featured-products" aria-label="Featured Products">' ;
2016-01-20 16:02:53 +00:00
2016-02-25 14:46:06 +00:00
do_action ( 'storefront_homepage_before_featured_products' );
2016-01-20 16:02:53 +00:00
2016-02-25 14:46:06 +00:00
echo '<h2 class="section-title">' . wp_kses_post ( $args [ 'title' ] ) . '</h2>' ;
2016-01-20 16:02:53 +00:00
2016-02-25 14:46:06 +00:00
do_action ( 'storefront_homepage_after_featured_products_title' );
2016-01-20 16:02:53 +00:00
2016-02-25 14:46:06 +00:00
echo storefront_do_shortcode ( 'featured_products' , array (
'per_page' => intval ( $args [ 'limit' ] ),
'columns' => intval ( $args [ 'columns' ] ),
'orderby' => esc_attr ( $args [ 'orderby' ] ),
'order' => esc_attr ( $args [ 'order' ] ),
) );
2016-01-20 16:02:53 +00:00
2016-02-25 14:46:06 +00:00
do_action ( 'storefront_homepage_after_featured_products' );
2016-01-20 16:02:53 +00:00
echo '</section>' ;
}
}
}
if ( ! function_exists ( 'storefront_popular_products' ) ) {
/**
* Display Popular Products
* Hooked into the `homepage` action in the homepage template
2016-02-19 16:57:56 +00:00
*
2016-01-20 16:02:53 +00:00
* @ since 1.0 . 0
2016-02-25 14:46:06 +00:00
* @ param array $args the product section args .
2016-01-20 16:02:53 +00:00
* @ return void
*/
function storefront_popular_products ( $args ) {
if ( is_woocommerce_activated () ) {
$args = apply_filters ( 'storefront_popular_products_args' , array (
2016-02-19 16:57:56 +00:00
'limit' => 4 ,
'columns' => 4 ,
'title' => __ ( 'Fan Favorites' , 'storefront' ),
) );
2016-01-20 16:02:53 +00:00
2016-07-28 18:17:31 +02:00
echo '<section class="storefront-product-section storefront-popular-products" aria-label="Popular Products">' ;
2016-01-20 16:02:53 +00:00
2016-02-25 14:46:06 +00:00
do_action ( 'storefront_homepage_before_popular_products' );
2016-01-20 16:02:53 +00:00
2016-02-25 14:46:06 +00:00
echo '<h2 class="section-title">' . wp_kses_post ( $args [ 'title' ] ) . '</h2>' ;
2016-01-20 16:02:53 +00:00
2016-02-25 14:46:06 +00:00
do_action ( 'storefront_homepage_after_popular_products_title' );
2016-01-20 16:02:53 +00:00
2016-02-25 14:46:06 +00:00
echo storefront_do_shortcode ( 'top_rated_products' , array (
'per_page' => intval ( $args [ 'limit' ] ),
'columns' => intval ( $args [ 'columns' ] ),
) );
2016-01-20 16:02:53 +00:00
2016-02-25 14:46:06 +00:00
do_action ( 'storefront_homepage_after_popular_products' );
2016-01-20 16:02:53 +00:00
echo '</section>' ;
}
}
}
if ( ! function_exists ( 'storefront_on_sale_products' ) ) {
/**
* Display On Sale Products
* Hooked into the `homepage` action in the homepage template
2016-02-25 14:46:06 +00:00
*
* @ param array $args the product section args .
2016-01-20 16:02:53 +00:00
* @ since 1.0 . 0
* @ return void
*/
function storefront_on_sale_products ( $args ) {
if ( is_woocommerce_activated () ) {
$args = apply_filters ( 'storefront_on_sale_products_args' , array (
2016-02-19 16:57:56 +00:00
'limit' => 4 ,
'columns' => 4 ,
'title' => __ ( 'On Sale' , 'storefront' ),
) );
2016-01-20 16:02:53 +00:00
2016-07-28 18:17:31 +02:00
echo '<section class="storefront-product-section storefront-on-sale-products" aria-label="On Sale Products">' ;
2016-01-20 16:02:53 +00:00
2016-02-25 14:46:06 +00:00
do_action ( 'storefront_homepage_before_on_sale_products' );
2016-01-20 16:02:53 +00:00
2016-02-25 14:46:06 +00:00
echo '<h2 class="section-title">' . wp_kses_post ( $args [ 'title' ] ) . '</h2>' ;
2016-01-20 16:02:53 +00:00
2016-02-25 14:46:06 +00:00
do_action ( 'storefront_homepage_after_on_sale_products_title' );
2016-01-20 16:02:53 +00:00
2016-02-25 14:46:06 +00:00
echo storefront_do_shortcode ( 'sale_products' , array (
'per_page' => intval ( $args [ 'limit' ] ),
'columns' => intval ( $args [ 'columns' ] ),
) );
2016-01-20 16:02:53 +00:00
2016-02-25 14:46:06 +00:00
do_action ( 'storefront_homepage_after_on_sale_products' );
2016-01-20 16:02:53 +00:00
echo '</section>' ;
}
}
}
2016-03-13 15:47:15 -05:00
if ( ! function_exists ( 'storefront_best_selling_products' ) ) {
/**
* Display Best Selling Products
* Hooked into the `homepage` action in the homepage template
*
2016-03-15 13:23:59 +00:00
* @ since 2.0 . 0
2016-03-13 15:47:15 -05:00
* @ param array $args the product section args .
* @ return void
*/
function storefront_best_selling_products ( $args ) {
if ( is_woocommerce_activated () ) {
$args = apply_filters ( 'storefront_best_selling_products_args' , array (
2016-03-15 13:23:59 +00:00
'limit' => 4 ,
'columns' => 4 ,
'title' => esc_attr__ ( 'Best Sellers' , 'storefront' ),
2016-03-13 15:47:15 -05:00
) );
2016-07-28 18:17:31 +02:00
echo '<section class="storefront-product-section storefront-best-selling-products" aria-label="Best Selling Products">' ;
2016-03-13 15:47:15 -05:00
do_action ( 'storefront_homepage_before_best_selling_products' );
echo '<h2 class="section-title">' . wp_kses_post ( $args [ 'title' ] ) . '</h2>' ;
do_action ( 'storefront_homepage_after_best_selling_products_title' );
echo storefront_do_shortcode ( 'best_selling_products' , array (
'per_page' => intval ( $args [ 'limit' ] ),
'columns' => intval ( $args [ 'columns' ] ),
) );
2016-05-11 14:39:29 +01:00
do_action ( 'storefront_homepage_after_best_selling_products' );
2016-03-13 15:47:15 -05:00
echo '</section>' ;
}
}
}
2016-01-20 16:02:53 +00:00
if ( ! function_exists ( 'storefront_homepage_content' ) ) {
/**
* Display homepage content
* Hooked into the `homepage` action in the homepage template
2016-02-19 16:57:56 +00:00
*
2016-01-20 16:02:53 +00:00
* @ since 1.0 . 0
* @ return void
*/
function storefront_homepage_content () {
2016-02-04 13:16:31 +00:00
while ( have_posts () ) {
the_post ();
2016-01-20 16:02:53 +00:00
get_template_part ( 'content' , 'page' );
2016-02-04 13:16:31 +00:00
} // end of the loop.
2016-01-20 16:02:53 +00:00
}
}
if ( ! function_exists ( 'storefront_social_icons' ) ) {
/**
* Display social icons
* If the subscribe and connect plugin is active , display the icons .
2016-02-19 16:57:56 +00:00
*
2016-01-20 16:02:53 +00:00
* @ link http :// wordpress . org / plugins / subscribe - and - connect /
* @ since 1.0 . 0
*/
function storefront_social_icons () {
if ( class_exists ( 'Subscribe_And_Connect' ) ) {
echo '<div class="subscribe-and-connect-connect">' ;
subscribe_and_connect_connect ();
echo '</div>' ;
}
}
}
if ( ! function_exists ( 'storefront_get_sidebar' ) ) {
/**
* Display storefront sidebar
2016-02-19 16:57:56 +00:00
*
2016-01-20 16:02:53 +00:00
* @ uses get_sidebar ()
* @ since 1.0 . 0
*/
function storefront_get_sidebar () {
get_sidebar ();
}
}
if ( ! function_exists ( 'storefront_post_thumbnail' ) ) {
/**
* Display post thumbnail
2016-02-19 16:57:56 +00:00
*
2016-01-20 16:02:53 +00:00
* @ var $size thumbnail size . thumbnail | medium | large | full | $custom
* @ uses has_post_thumbnail ()
* @ uses the_post_thumbnail
2016-02-19 16:57:56 +00:00
* @ param string $size the post thumbnail size .
2016-01-20 16:02:53 +00:00
* @ since 1.5 . 0
*/
function storefront_post_thumbnail ( $size ) {
if ( has_post_thumbnail () ) {
2016-05-26 07:57:50 +02:00
the_post_thumbnail ( $size );
2016-01-20 16:02:53 +00:00
}
}
2016-02-19 16:57:56 +00:00
}
2016-03-18 12:10:14 +00:00
2016-07-12 08:37:41 +02:00
if ( ! function_exists ( 'storefront_primary_navigation_wrapper' ) ) {
/**
* The primary navigation wrapper
*/
function storefront_primary_navigation_wrapper () {
2016-07-26 08:20:51 +02:00
echo '<div class="storefront-primary-navigation">' ;
2016-07-12 08:37:41 +02:00
}
2016-03-18 12:10:14 +00:00
}
2016-07-12 08:37:41 +02:00
if ( ! function_exists ( 'storefront_primary_navigation_wrapper_close' ) ) {
/**
* The primary navigation wrapper close
*/
function storefront_primary_navigation_wrapper_close () {
2016-07-26 08:20:51 +02:00
echo '</div>' ;
2016-07-12 08:37:41 +02:00
}
2016-03-18 12:10:14 +00:00
}
2016-05-26 07:57:50 +02:00
if ( ! function_exists ( 'storefront_init_structured_data' ) ) {
2016-06-01 12:26:01 +01:00
/**
* Generate the structured data ...
* Initialize Storefront :: $structured_data via Storefront :: set_structured_data () ...
* Hooked into :
* `storefront_loop_post`
* `storefront_single_post`
* `storefront_page`
* Apply `storefront_structured_data` filter hook for structured data customization : )
*/
function storefront_init_structured_data () {
2016-06-02 12:18:59 +02:00
if ( is_home () || is_category () || is_date () || is_search () || is_single () && ( is_woocommerce_activated () && ! is_woocommerce () ) ) {
2016-06-01 12:26:01 +01:00
$image = wp_get_attachment_image_src ( get_post_thumbnail_id ( get_the_ID () ), 'normal' );
$logo = wp_get_attachment_image_src ( get_theme_mod ( 'custom_logo' ), 'full' );
$json [ '@type' ] = 'BlogPosting' ;
$json [ 'mainEntityOfPage' ] = array (
'@type' => 'webpage' ,
'@id' => get_the_permalink (),
);
$json [ 'image' ] = array (
'@type' => 'ImageObject' ,
'url' => $image [ 0 ],
'width' => $image [ 1 ],
'height' => $image [ 2 ],
);
$json [ 'publisher' ] = array (
'@type' => 'organization' ,
'name' => get_bloginfo ( 'name' ),
'logo' => array (
'@type' => 'ImageObject' ,
'url' => $logo [ 0 ],
'width' => $logo [ 1 ],
'height' => $logo [ 2 ],
),
);
$json [ 'author' ] = array (
'@type' => 'person' ,
'name' => get_the_author (),
);
$json [ 'datePublished' ] = get_post_time ( 'c' );
$json [ 'dateModified' ] = get_the_modified_date ( 'c' );
$json [ 'name' ] = get_the_title ();
$json [ 'headline' ] = get_the_title ();
$json [ 'description' ] = get_the_excerpt ();
} elseif ( is_page () ) {
$json [ '@type' ] = 'WebPage' ;
$json [ 'url' ] = get_the_permalink ();
$json [ 'name' ] = get_the_title ();
$json [ 'description' ] = get_the_excerpt ();
}
if ( isset ( $json ) ) {
Storefront :: set_structured_data ( apply_filters ( 'storefront_structured_data' , $json ) );
}
}
2016-05-26 07:57:50 +02:00
}