mirror of
https://github.com/woocommerce/storefront.git
synced 2025-08-20 04:00:29 +08:00
775 lines
22 KiB
PHP
775 lines
22 KiB
PHP
|
<?php
|
||
|
/**
|
||
|
* Storefront template functions.
|
||
|
*
|
||
|
* @package storefront
|
||
|
*/
|
||
|
|
||
|
if ( ! function_exists( 'storefront_display_comments' ) ) {
|
||
|
/**
|
||
|
* Storefront display comments
|
||
|
* @since 1.0.0
|
||
|
*/
|
||
|
function storefront_display_comments() {
|
||
|
// If comments are open or we have at least one comment, load up the comment template
|
||
|
if ( comments_open() || '0' != get_comments_number() ) :
|
||
|
comments_template();
|
||
|
endif;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( ! function_exists( 'storefront_html_tag_schema' ) ) {
|
||
|
/**
|
||
|
* Schema type
|
||
|
* @return string schema itemprop type
|
||
|
*/
|
||
|
function storefront_html_tag_schema() {
|
||
|
$schema = 'http://schema.org/';
|
||
|
$type = 'WebPage';
|
||
|
|
||
|
// Is single post
|
||
|
if ( is_singular( 'post' ) ) {
|
||
|
$type = 'Article';
|
||
|
}
|
||
|
|
||
|
// Is author page
|
||
|
elseif ( is_author() ) {
|
||
|
$type = 'ProfilePage';
|
||
|
}
|
||
|
|
||
|
// Is search results page
|
||
|
elseif ( is_search() ) {
|
||
|
$type = 'SearchResultsPage';
|
||
|
}
|
||
|
|
||
|
echo 'itemscope="itemscope" itemtype="' . esc_attr( $schema ) . esc_attr( $type ) . '"';
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( ! function_exists( 'storefront_comment' ) ) {
|
||
|
/**
|
||
|
* Storefront comment template
|
||
|
* @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 ); ?>
|
||
|
<?php printf( __( '<cite class="fn">%s</cite>', 'storefront' ), get_comment_author_link() ); ?>
|
||
|
</div>
|
||
|
<?php if ( '0' == $comment->comment_approved ) : ?>
|
||
|
<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'storefront' ); ?></em>
|
||
|
<br />
|
||
|
<?php endif; ?>
|
||
|
|
||
|
<a href="<?php echo esc_url( 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
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( ! function_exists( 'storefront_footer_widgets' ) ) {
|
||
|
/**
|
||
|
* 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-<?php echo intval( $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 intval( $i ); ?>">
|
||
|
<?php dynamic_sidebar( 'footer-' . intval( $i ) ); ?>
|
||
|
</section>
|
||
|
|
||
|
<?php endif; ?>
|
||
|
|
||
|
<?php endwhile; ?>
|
||
|
|
||
|
</section><!-- /.footer-widgets -->
|
||
|
|
||
|
<?php endif;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( ! function_exists( 'storefront_credit' ) ) {
|
||
|
/**
|
||
|
* Display the theme credit
|
||
|
* @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 ) ) { ?>
|
||
|
<br /> <?php printf( __( '%1$s designed by %2$s.', 'storefront' ), 'Storefront', '<a href="http://www.woothemes.com" alt="Premium WordPress Themes & Plugins by WooThemes" title="Premium WordPress Themes & Plugins by WooThemes" rel="designer">WooThemes</a>' ); ?>
|
||
|
<?php } ?>
|
||
|
</div><!-- .site-info -->
|
||
|
<?php
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( ! function_exists( 'storefront_footer_widgets' ) ) {
|
||
|
/**
|
||
|
* 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-<?php echo intval( $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 intval( $i ); ?>">
|
||
|
<?php dynamic_sidebar( 'footer-' . intval( $i ) ); ?>
|
||
|
</section>
|
||
|
|
||
|
<?php endif; ?>
|
||
|
|
||
|
<?php endwhile; ?>
|
||
|
|
||
|
</section><!-- /.footer-widgets -->
|
||
|
|
||
|
<?php endif;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( ! function_exists( 'storefront_credit' ) ) {
|
||
|
/**
|
||
|
* Display the theme credit
|
||
|
* @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 ) ) { ?>
|
||
|
<br /> <?php printf( __( '%1$s designed by %2$s.', 'storefront' ), 'Storefront', '<a href="http://www.woothemes.com" alt="Premium WordPress Themes & Plugins by WooThemes" title="Premium WordPress Themes & Plugins by WooThemes" rel="designer">WooThemes</a>' ); ?>
|
||
|
<?php } ?>
|
||
|
</div><!-- .site-info -->
|
||
|
<?php
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( ! function_exists( 'storefront_header_widget_region' ) ) {
|
||
|
/**
|
||
|
* Display header widget region
|
||
|
* @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
|
||
|
* @since 1.0.0
|
||
|
* @return void
|
||
|
*/
|
||
|
function storefront_site_branding() {
|
||
|
if ( function_exists( 'jetpack_has_site_logo' ) && jetpack_has_site_logo() ) {
|
||
|
jetpack_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>
|
||
|
<?php if ( '' != get_bloginfo( 'description' ) ) { ?>
|
||
|
<p class="site-description"><?php echo bloginfo( 'description' ); ?></p>
|
||
|
<?php } ?>
|
||
|
</div>
|
||
|
<?php }
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( ! function_exists( 'storefront_primary_navigation' ) ) {
|
||
|
/**
|
||
|
* Display Primary Navigation
|
||
|
* @since 1.0.0
|
||
|
* @return void
|
||
|
*/
|
||
|
function storefront_primary_navigation() {
|
||
|
?>
|
||
|
<nav id="site-navigation" class="main-navigation" role="navigation" aria-label="<?php esc_html_e( 'Primary Navigation', 'storefront' ); ?>">
|
||
|
<button class="menu-toggle" aria-controls="primary-navigation" aria-expanded="false"><?php echo esc_attr( apply_filters( 'storefront_menu_toggle_text', __( 'Navigation', 'storefront' ) ) ); ?></button>
|
||
|
<?php
|
||
|
wp_nav_menu(
|
||
|
array(
|
||
|
'theme_location' => 'primary',
|
||
|
'container_class' => 'primary-navigation',
|
||
|
)
|
||
|
);
|
||
|
|
||
|
wp_nav_menu(
|
||
|
array(
|
||
|
'theme_location' => 'handheld',
|
||
|
'container_class' => 'handheld-navigation',
|
||
|
)
|
||
|
);
|
||
|
?>
|
||
|
</nav><!-- #site-navigation -->
|
||
|
<?php
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( ! function_exists( 'storefront_secondary_navigation' ) ) {
|
||
|
/**
|
||
|
* Display Secondary Navigation
|
||
|
* @since 1.0.0
|
||
|
* @return void
|
||
|
*/
|
||
|
function storefront_secondary_navigation() {
|
||
|
?>
|
||
|
<nav class="secondary-navigation" role="navigation" aria-label="<?php _e( 'Secondary Navigation', 'storefront' ); ?>">
|
||
|
<?php
|
||
|
wp_nav_menu(
|
||
|
array(
|
||
|
'theme_location' => 'secondary',
|
||
|
'fallback_cb' => '',
|
||
|
)
|
||
|
);
|
||
|
?>
|
||
|
</nav><!-- #site-navigation -->
|
||
|
<?php
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( ! function_exists( 'storefront_skip_links' ) ) {
|
||
|
/**
|
||
|
* Skip links
|
||
|
* @since 1.4.1
|
||
|
* @return void
|
||
|
*/
|
||
|
function storefront_skip_links() {
|
||
|
?>
|
||
|
<a class="skip-link screen-reader-text" href="#site-navigation"><?php _e( 'Skip to navigation', 'storefront' ); ?></a>
|
||
|
<a class="skip-link screen-reader-text" href="#content"><?php _e( 'Skip to content', 'storefront' ); ?></a>
|
||
|
<?php
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( ! function_exists( 'storefront_page_header' ) ) {
|
||
|
/**
|
||
|
* Display the post header with a link to the single post
|
||
|
* @since 1.0.0
|
||
|
*/
|
||
|
function storefront_page_header() {
|
||
|
?>
|
||
|
<header class="entry-header">
|
||
|
<?php
|
||
|
storefront_post_thumbnail( 'full' );
|
||
|
the_title( '<h1 class="entry-title" itemprop="name">', '</h1>' );
|
||
|
?>
|
||
|
</header><!-- .entry-header -->
|
||
|
<?php
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( ! function_exists( 'storefront_page_content' ) ) {
|
||
|
/**
|
||
|
* Display the post content with a link to the single post
|
||
|
* @since 1.0.0
|
||
|
*/
|
||
|
function storefront_page_content() {
|
||
|
?>
|
||
|
<div class="entry-content" itemprop="mainContentOfPage">
|
||
|
<?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
|
||
|
* @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
|
||
|
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
|
||
|
* @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 '<span class="screen-reader-text">' . esc_attr( __( 'Categories: ', 'storefront' ) ) . '</span>';
|
||
|
echo wp_kses_post( $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 '<span class="screen-reader-text">' . esc_attr( __( 'Tags: ', 'storefront' ) ) . '</span>';
|
||
|
echo wp_kses_post( $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() {
|
||
|
global $wp_query;
|
||
|
|
||
|
$args = array(
|
||
|
'type' => 'list',
|
||
|
'next_text' => _x( 'Next', 'Next post', 'storefront' ) . ' <span class="meta-nav">→</span>',
|
||
|
'prev_text' => '<span class="meta-nav">←</span> ' . _x( 'Previous', 'Previous post', 'storefront' ),
|
||
|
);
|
||
|
|
||
|
the_posts_pagination( $args );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( ! function_exists( 'storefront_post_nav' ) ) {
|
||
|
/**
|
||
|
* Display navigation to next/previous post when applicable.
|
||
|
*/
|
||
|
function storefront_post_nav() {
|
||
|
$args = array(
|
||
|
'next_text' => '%title <span class="meta-nav">→</span>',
|
||
|
'prev_text' => '<span class="meta-nav">←</span> %title',
|
||
|
);
|
||
|
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() {
|
||
|
$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="vcard author"><span class="fn" itemprop="author"><a class="url fn n" rel="author" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span></span>'
|
||
|
);
|
||
|
|
||
|
echo apply_filters( 'storefront_single_post_posted_on_html', '<span class="posted-on">' . $posted_on . '</span><span class="byline"> ' . $byline . '</span>', $posted_on, $byline );
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
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( $args ) {
|
||
|
|
||
|
if ( is_woocommerce_activated() ) {
|
||
|
|
||
|
$args = apply_filters( 'storefront_product_categories_args', array(
|
||
|
'limit' => 3,
|
||
|
'columns' => 3,
|
||
|
'child_categories' => 0,
|
||
|
'orderby' => 'name',
|
||
|
'title' => __( 'Product Categories', 'storefront' ),
|
||
|
) );
|
||
|
|
||
|
echo '<section class="storefront-product-section storefront-product-categories">';
|
||
|
|
||
|
do_action( 'storefront_homepage_before_product_categories' );
|
||
|
|
||
|
echo '<h2 class="section-title">' . wp_kses_post( $args['title'] ) . '</h2>';
|
||
|
|
||
|
do_action( 'storefront_homepage_after_product_categories_title' );
|
||
|
|
||
|
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'] ),
|
||
|
) );
|
||
|
|
||
|
do_action( 'storefront_homepage_after_product_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( $args ) {
|
||
|
|
||
|
if ( is_woocommerce_activated() ) {
|
||
|
|
||
|
$args = apply_filters( 'storefront_recent_products_args', array(
|
||
|
'limit' => 4,
|
||
|
'columns' => 4,
|
||
|
'title' => __( 'Recent Products', 'storefront' ),
|
||
|
) );
|
||
|
|
||
|
echo '<section class="storefront-product-section storefront-recent-products">';
|
||
|
|
||
|
do_action( 'storefront_homepage_before_recent_products' );
|
||
|
|
||
|
echo '<h2 class="section-title">' . wp_kses_post( $args['title'] ) . '</h2>';
|
||
|
|
||
|
do_action( 'storefront_homepage_after_recent_products_title' );
|
||
|
|
||
|
echo storefront_do_shortcode( 'recent_products',
|
||
|
array(
|
||
|
'per_page' => intval( $args['limit'] ),
|
||
|
'columns' => intval( $args['columns'] ),
|
||
|
) );
|
||
|
|
||
|
do_action( 'storefront_homepage_after_recent_products' );
|
||
|
|
||
|
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( $args ) {
|
||
|
|
||
|
if ( is_woocommerce_activated() ) {
|
||
|
|
||
|
$args = apply_filters( 'storefront_featured_products_args', array(
|
||
|
'limit' => 4,
|
||
|
'columns' => 4,
|
||
|
'orderby' => 'date',
|
||
|
'order' => 'desc',
|
||
|
'title' => __( 'Featured Products', 'storefront' ),
|
||
|
) );
|
||
|
|
||
|
echo '<section class="storefront-product-section storefront-featured-products">';
|
||
|
|
||
|
do_action( 'storefront_homepage_before_featured_products' );
|
||
|
|
||
|
echo '<h2 class="section-title">' . wp_kses_post( $args['title'] ) . '</h2>';
|
||
|
|
||
|
do_action( 'storefront_homepage_after_featured_products_title' );
|
||
|
|
||
|
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'] ),
|
||
|
) );
|
||
|
|
||
|
do_action( 'storefront_homepage_after_featured_products' );
|
||
|
|
||
|
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( $args ) {
|
||
|
|
||
|
if ( is_woocommerce_activated() ) {
|
||
|
|
||
|
$args = apply_filters( 'storefront_popular_products_args', array(
|
||
|
'limit' => 4,
|
||
|
'columns' => 4,
|
||
|
'title' => __( 'Top Rated Products', 'storefront' ),
|
||
|
) );
|
||
|
|
||
|
echo '<section class="storefront-product-section storefront-popular-products">';
|
||
|
|
||
|
do_action( 'storefront_homepage_before_popular_products' );
|
||
|
|
||
|
echo '<h2 class="section-title">' . wp_kses_post( $args['title'] ) . '</h2>';
|
||
|
|
||
|
do_action( 'storefront_homepage_after_popular_products_title' );
|
||
|
|
||
|
echo storefront_do_shortcode( 'top_rated_products',
|
||
|
array(
|
||
|
'per_page' => intval( $args['limit'] ),
|
||
|
'columns' => intval( $args['columns'] ),
|
||
|
) );
|
||
|
|
||
|
do_action( 'storefront_homepage_after_popular_products' );
|
||
|
|
||
|
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( $args ) {
|
||
|
|
||
|
if ( is_woocommerce_activated() ) {
|
||
|
|
||
|
$args = apply_filters( 'storefront_on_sale_products_args', array(
|
||
|
'limit' => 4,
|
||
|
'columns' => 4,
|
||
|
'title' => __( 'On Sale', 'storefront' ),
|
||
|
) );
|
||
|
|
||
|
echo '<section class="storefront-product-section storefront-on-sale-products">';
|
||
|
|
||
|
do_action( 'storefront_homepage_before_on_sale_products' );
|
||
|
|
||
|
echo '<h2 class="section-title">' . wp_kses_post( $args['title'] ) . '</h2>';
|
||
|
|
||
|
do_action( 'storefront_homepage_after_on_sale_products_title' );
|
||
|
|
||
|
echo storefront_do_shortcode( 'sale_products',
|
||
|
array(
|
||
|
'per_page' => intval( $args['limit'] ),
|
||
|
'columns' => intval( $args['columns'] ),
|
||
|
) );
|
||
|
|
||
|
do_action( 'storefront_homepage_after_on_sale_products' );
|
||
|
|
||
|
echo '</section>';
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( ! function_exists( 'storefront_homepage_content' ) ) {
|
||
|
/**
|
||
|
* Display homepage content
|
||
|
* Hooked into the `homepage` action in the homepage template
|
||
|
* @since 1.0.0
|
||
|
* @return void
|
||
|
*/
|
||
|
function storefront_homepage_content() {
|
||
|
while ( have_posts() ) : the_post();
|
||
|
|
||
|
get_template_part( 'content', 'page' );
|
||
|
|
||
|
endwhile; // end of the loop.
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( ! function_exists( 'storefront_social_icons' ) ) {
|
||
|
/**
|
||
|
* Display social icons
|
||
|
* If the subscribe and connect plugin is active, display the icons.
|
||
|
* @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
|
||
|
* @uses get_sidebar()
|
||
|
* @since 1.0.0
|
||
|
*/
|
||
|
function storefront_get_sidebar() {
|
||
|
get_sidebar();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( ! function_exists( 'storefront_post_thumbnail' ) ) {
|
||
|
/**
|
||
|
* Display post thumbnail
|
||
|
* @var $size thumbnail size. thumbnail|medium|large|full|$custom
|
||
|
* @uses has_post_thumbnail()
|
||
|
* @uses the_post_thumbnail
|
||
|
* @param string $size
|
||
|
* @since 1.5.0
|
||
|
*/
|
||
|
function storefront_post_thumbnail( $size ) {
|
||
|
if ( has_post_thumbnail() ) {
|
||
|
the_post_thumbnail( $size, array( 'itemprop' => 'image' ) );
|
||
|
}
|
||
|
}
|
||
|
}
|