lots of coding standards tweaks. #326

This commit is contained in:
James Koster 2016-02-19 16:57:56 +00:00
parent c4920aad86
commit 1409ee5c66
34 changed files with 1746 additions and 1603 deletions

16
404.php
View file

@ -40,11 +40,11 @@ get_header(); ?>
echo '<div class="col-2">';
echo '<h2>' . esc_html__( 'Product Categories', 'storefront' ) . '</h2>';
echo '<h2>' . esc_html__( 'Product Categories', 'storefront' ) . '</h2>';
the_widget( 'WC_Widget_Product_Categories', array(
'count' => 1,
) );
the_widget( 'WC_Widget_Product_Categories', array(
'count' => 1,
) );
echo '</div>';
echo '</div>';
@ -52,9 +52,9 @@ get_header(); ?>
echo '<h2>' . esc_html__( 'Popular Products', 'storefront' ) . '</h2>';
echo storefront_do_shortcode( 'best_selling_products', array(
'per_page' => 4,
'columns' => 4,
) );
'per_page' => 4,
'columns' => 4,
) );
}
?>
@ -64,4 +64,4 @@ get_header(); ?>
</main><!-- #main -->
</div><!-- #primary -->
<?php get_footer(); ?>
<?php get_footer();

View file

@ -35,4 +35,4 @@ get_header(); ?>
<?php
do_action( 'storefront_sidebar' );
get_footer();
get_footer();

View file

@ -20,7 +20,8 @@ if ( post_password_required() ) {
<div id="comments" class="comments-area">
<?php if ( have_comments() ) : ?>
<?php
if ( have_comments() ) : ?>
<h2 class="comments-title">
<?php
printf( _nx( 'One thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', get_comments_number(), 'comments title', 'storefront' ),
@ -62,4 +63,4 @@ if ( post_password_required() ) {
comment_form(); ?>
</div><!-- #comments -->
</div><!-- #comments -->

View file

@ -30,4 +30,4 @@
<?php endif; ?>
</div><!-- .page-content -->
</section><!-- .no-results -->
</section><!-- .no-results -->

View file

@ -4,14 +4,17 @@
*
* @package storefront
*/
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php
/**
* @hooked storefront_page_header - 10
* Functions hooked in to storefront_page add_action
*
* @hooked storefront_page_header - 10
* @hooked storefront_page_content - 20
*/
do_action( 'storefront_page' );
?>
</article><!-- #post-## -->
</article><!-- #post-## -->

View file

@ -1,18 +1,23 @@
<?php
/**
* Template used to display post content on single pages.
*
* @package storefront
*/
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> itemscope="" itemtype="http://schema.org/BlogPosting">
<?php
/**
* @hooked storefront_post_header - 10
* @hooked storefront_post_meta - 20
* Functions hooked into storefront_single_post add_action
*
* @hooked storefront_post_header - 10
* @hooked storefront_post_meta - 20
* @hooked storefront_post_content - 30
*/
do_action( 'storefront_single_post' );
?>
</article><!-- #post-## -->
</article><!-- #post-## -->

View file

@ -1,18 +1,23 @@
<?php
/**
* Template used to display post content.
*
* @package storefront
*/
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> itemscope="" itemtype="http://schema.org/BlogPosting">
<?php
/**
* @hooked storefront_post_header() - 10
* @hooked storefront_post_meta() - 20
* @hooked storefront_post_content() - 30
* Functions hooked in to storefront_loop_post action.
*
* @hooked storefront_post_header - 10
* @hooked storefront_post_meta - 20
* @hooked storefront_post_content - 30
*/
do_action( 'storefront_loop_post' );
?>
</article><!-- #post-## -->
</article><!-- #post-## -->

View file

@ -6,6 +6,7 @@
*
* @package storefront
*/
?>
</div><!-- .col-full -->
@ -18,8 +19,10 @@
<?php
/**
* Functions hooked in to storefront_footer action
*
* @hooked storefront_footer_widgets - 10
* @hooked storefront_credit - 20
* @hooked storefront_credit - 20
*/
do_action( 'storefront_footer' ); ?>
@ -33,4 +36,4 @@
<?php wp_footer(); ?>
</body>
</html>
</html>

View file

@ -1,6 +1,6 @@
<?php
/**
* storefront engine room
* Storefront engine room
*
* @package storefront
*/
@ -8,8 +8,8 @@
/**
* Assign the Storefront version to a var
*/
$theme = wp_get_theme( 'storefront' );
$storefront_version = $theme['Version'];
$theme = wp_get_theme( 'storefront' );
$storefront_version = $theme['Version'];
/**
* Initialize all the things.
@ -35,4 +35,4 @@ if ( is_admin() ) {
/**
* Note: Do not add any custom code here. Please use a custom plugin so that your customizations aren't lost during updates.
* https://github.com/woothemes/theme-customisations
*/
*/

View file

@ -6,6 +6,7 @@
*
* @package storefront
*/
?><!DOCTYPE html>
<html <?php language_attributes(); ?> <?php storefront_html_tag_schema(); ?>>
<head>
@ -27,13 +28,15 @@
<?php
/**
* @hooked storefront_skip_links - 0
* @hooked storefront_social_icons - 10
* @hooked storefront_site_branding - 20
* Functions hooked into storefront_header action
*
* @hooked storefront_skip_links - 0
* @hooked storefront_social_icons - 10
* @hooked storefront_site_branding - 20
* @hooked storefront_secondary_navigation - 30
* @hooked storefront_product_search - 40
* @hooked storefront_primary_navigation - 50
* @hooked storefront_header_cart - 60
* @hooked storefront_product_search - 40
* @hooked storefront_primary_navigation - 50
* @hooked storefront_header_cart - 60
*/
do_action( 'storefront_header' ); ?>
@ -42,6 +45,8 @@
<?php
/**
* Functions hooked in to storefront_before_content
*
* @hooked storefront_header_widget_region - 10
*/
do_action( 'storefront_before_content' ); ?>
@ -51,6 +56,8 @@
<?php
/**
* Functions hooked in to storefront_content_top
*
* @hooked woocommerce_breadcrumb - 10
*/
do_action( 'storefront_content_top' ); ?>
do_action( 'storefront_content_top' );

View file

@ -12,141 +12,153 @@ if ( ! defined( 'ABSPATH' ) ) {
if ( ! class_exists( 'Storefront_Admin' ) ) :
class Storefront_Admin {
class Storefront_Admin {
/**
* Setup class.
*
* @since 1.0
*/
public function __construct() {
add_action( 'admin_menu', array( $this, 'welcome_register_menu' ) );
add_action( 'load-themes.php', array( $this, 'activation_admin_notice' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'welcome_style' ) );
/**
* Setup class.
*
* @since 1.0
*/
public function __construct() {
add_action( 'admin_menu', array( $this, 'welcome_register_menu' ) );
add_action( 'load-themes.php', array( $this, 'activation_admin_notice' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'welcome_style' ) );
add_action( 'storefront_welcome', array( $this, 'welcome_intro' ), 10 );
add_action( 'storefront_welcome', array( $this, 'welcome_enhance' ), 20 );
add_action( 'storefront_welcome', array( $this, 'welcome_contribute' ), 30 );
}
/**
* Adds an admin notice upon successful activation.
* @since 1.0.3
*/
public function activation_admin_notice() {
global $pagenow;
if ( is_admin() && 'themes.php' == $pagenow && isset( $_GET['activated'] ) ) { // input var okay
add_action( 'admin_notices', array( $this, 'storefront_welcome_admin_notice' ), 99 );
add_action( 'storefront_welcome', array( $this, 'welcome_intro' ), 10 );
add_action( 'storefront_welcome', array( $this, 'welcome_enhance' ), 20 );
add_action( 'storefront_welcome', array( $this, 'welcome_contribute' ), 30 );
}
}
/**
* Display an admin notice linking to the welcome screen
* @since 1.0.3
*/
public function storefront_welcome_admin_notice() {
?>
<div class="updated notice is-dismissible">
<p><?php echo sprintf( esc_html__( 'Thanks for choosing Storefront! You can read hints and tips on how get the most out of your new theme on the %swelcome screen%s.', 'storefront' ), '<a href="' . esc_url( admin_url( 'themes.php?page=storefront-welcome' ) ) . '">', '</a>' ); ?></p>
<p><a href="<?php echo esc_url( admin_url( 'themes.php?page=storefront-welcome' ) ); ?>" class="button" style="text-decoration: none;"><?php _e( 'Get started with Storefront', 'storefront' ); ?></a></p>
</div>
<?php
}
/**
* Adds an admin notice upon successful activation.
*
* @since 1.0.3
*/
public function activation_admin_notice() {
global $pagenow;
/**
* Load welcome screen css
* @return void
* @since 1.4.4
*/
public function welcome_style( $hook_suffix ) {
global $storefront_version;
if ( 'appearance_page_storefront-welcome' == $hook_suffix ) {
wp_enqueue_style( 'storefront-welcome-screen', get_template_directory_uri() . '/assets/sass/admin/welcome-screen/welcome.css', $storefront_version );
wp_style_add_data( 'storefront-welcome-screen', 'rtl', 'replace' );
wp_enqueue_style( 'thickbox' );
wp_enqueue_script( 'thickbox' );
wp_enqueue_script( 'masonry' );
wp_enqueue_script( 'storefront-welcome-screen-script', get_template_directory_uri() . '/assets/js/admin/welcome-screen/welcome.min.js', array( 'masonry'), $storefront_version );
if ( is_admin() && 'themes.php' == $pagenow && isset( $_GET['activated'] ) ) { // input var okay.
add_action( 'admin_notices', array( $this, 'storefront_welcome_admin_notice' ), 99 );
}
}
}
/**
* Creates the dashboard page
* @see add_theme_page()
* @since 1.0.0
*/
public function welcome_register_menu() {
add_theme_page( 'Storefront', 'Storefront', 'activate_plugins', 'storefront-welcome', array( $this, 'storefront_welcome_screen' ) );
}
/**
* The welcome screen
* @since 1.0.0
*/
public function storefront_welcome_screen() {
require_once( ABSPATH . 'wp-load.php' );
require_once( ABSPATH . 'wp-admin/admin.php' );
require_once( ABSPATH . 'wp-admin/admin-header.php' );
?>
<div class="wrap about-wrap">
/**
* Display an admin notice linking to the welcome screen
*
* @since 1.0.3
*/
public function storefront_welcome_admin_notice() {
?>
<div class="updated notice is-dismissible">
<p><?php echo sprintf( esc_html__( 'Thanks for choosing Storefront! You can read hints and tips on how get the most out of your new theme on the %swelcome screen%s.', 'storefront' ), '<a href="' . esc_url( admin_url( 'themes.php?page=storefront-welcome' ) ) . '">', '</a>' ); ?></p>
<p><a href="<?php echo esc_url( admin_url( 'themes.php?page=storefront-welcome' ) ); ?>" class="button" style="text-decoration: none;"><?php esc_attr_e( 'Get started with Storefront', 'storefront' ); ?></a></p>
</div>
<?php
/**
* @hooked welcome_intro - 10
* @hooked welcome_enhance - 20
* @hooked welcome_contribute - 30
*/
do_action( 'storefront_welcome' ); ?>
</div>
<?php
}
/**
* Welcome screen intro
* @since 1.0.0
*/
public function welcome_intro() {
require_once( get_template_directory() . '/inc/admin/welcome-screen/component-intro.php' );
}
/**
* Welcome screen enhance section
* @since 1.5.2
*/
public function welcome_enhance() {
require_once( get_template_directory() . '/inc/admin/welcome-screen/component-enhance.php' );
}
/**
* Welcome screen contribute section
* @since 1.5.2
*/
public function welcome_contribute() {
require_once( get_template_directory() . '/inc/admin/welcome-screen/component-contribute.php' );
}
/**
* Get product data from json
* @param string $url URL to the json file
* @param string $transient Name the transient
* @return [type] [description]
*/
public function get_storefront_product_data( $url, $transient ) {
$raw_products = wp_safe_remote_get( $url );
$products = json_decode( wp_remote_retrieve_body( $raw_products ) );
if ( ! empty( $products ) ) {
set_transient( $transient, $products, DAY_IN_SECONDS );
}
return $products;
/**
* Load welcome screen css
*
* @param string $hook_suffix the current page hook suffix.
* @return void
* @since 1.4.4
*/
public function welcome_style( $hook_suffix ) {
global $storefront_version;
if ( 'appearance_page_storefront-welcome' == $hook_suffix ) {
wp_enqueue_style( 'storefront-welcome-screen', get_template_directory_uri() . '/assets/sass/admin/welcome-screen/welcome.css', $storefront_version );
wp_style_add_data( 'storefront-welcome-screen', 'rtl', 'replace' );
wp_enqueue_style( 'thickbox' );
wp_enqueue_script( 'thickbox' );
wp_enqueue_script( 'masonry' );
wp_enqueue_script( 'storefront-welcome-screen-script', get_template_directory_uri() . '/assets/js/admin/welcome-screen/welcome.min.js', array( 'masonry' ), $storefront_version );
}
}
/**
* Creates the dashboard page
*
* @see add_theme_page()
* @since 1.0.0
*/
public function welcome_register_menu() {
add_theme_page( 'Storefront', 'Storefront', 'activate_plugins', 'storefront-welcome', array( $this, 'storefront_welcome_screen' ) );
}
/**
* The welcome screen
*
* @since 1.0.0
*/
public function storefront_welcome_screen() {
require_once( ABSPATH . 'wp-load.php' );
require_once( ABSPATH . 'wp-admin/admin.php' );
require_once( ABSPATH . 'wp-admin/admin-header.php' );
?>
<div class="wrap about-wrap">
<?php
/**
* Functions hooked into storefront_welcome action
*
* @hooked welcome_intro - 10
* @hooked welcome_enhance - 20
* @hooked welcome_contribute - 30
*/
do_action( 'storefront_welcome' ); ?>
</div>
<?php
}
/**
* Welcome screen intro
*
* @since 1.0.0
*/
public function welcome_intro() {
require_once( get_template_directory() . '/inc/admin/welcome-screen/component-intro.php' );
}
/**
* Welcome screen enhance section
*
* @since 1.5.2
*/
public function welcome_enhance() {
require_once( get_template_directory() . '/inc/admin/welcome-screen/component-enhance.php' );
}
/**
* Welcome screen contribute section
*
* @since 1.5.2
*/
public function welcome_contribute() {
require_once( get_template_directory() . '/inc/admin/welcome-screen/component-contribute.php' );
}
/**
* Get product data from json
*
* @param string $url URL to the json file
* @param string $transient Name the transient.
* @return [type] [description]
*/
public function get_storefront_product_data( $url, $transient ) {
$raw_products = wp_safe_remote_get( $url );
$products = json_decode( wp_remote_retrieve_body( $raw_products ) );
if ( ! empty( $products ) ) {
set_transient( $transient, $products, DAY_IN_SECONDS );
}
return $products;
}
}
}
endif;
return new Storefront_Admin();
return new Storefront_Admin();

View file

@ -1,7 +1,10 @@
<?php
/**
* Welcome screen contribute template
*
* @package storefront
*/
?>
<div class="boxed contribute">
<h2><?php esc_html_e( 'Contribute to Storefront', 'storefront' ); ?></h2>
@ -16,6 +19,6 @@
<div class="automattic">
<p>
<?php printf( esc_html__( 'An %s project', 'storefront' ), '<a href="https://automattic.com/"><img src="' . esc_url( get_template_directory_uri() ) . '/assets/images/admin/welcome-screen/automattic.png' . '" alt="Automattic" /></a>' ); ?>
<?php printf( esc_html__( 'An %s project', 'storefront' ), '<a href="https://automattic.com/"><img src="' . esc_url( get_template_directory_uri() ) . '/assets/images/admin/welcome-screen/automattic.png" alt="Automattic" /></a>' ); ?>
</p>
</div>
</div>

View file

@ -1,7 +1,10 @@
<?php
/**
* Welcome screen enhance template
*
* @package storefront
*/
?>
<?php
@ -27,8 +30,8 @@ $child_themes = $storefront_admin::get_storefront_product_data( 'http://d3t0oe
$price = $product->price;
$title = str_replace( 'Storefront', '', $product->title );
if ( $price != '&#36;0.00' ) {
echo '<li><a href="' . esc_url( $product->link ) . '">' . $title . ' - <span class="price">' . esc_attr( $product->price ) . '</span></a><p>' . wp_kses_post( $product->excerpt ) . '</p></li>';
if ( '&#36;0.00' != $price ) {
echo '<li><a href="' . esc_url( $product->link ) . '">' . esc_attr( $title ) . ' - <span class="price">' . esc_attr( $product->price ) . '</span></a><p>' . wp_kses_post( $product->excerpt ) . '</p></li>';
}
}
}
@ -95,18 +98,18 @@ $child_themes = $storefront_admin::get_storefront_product_data( 'http://d3t0oe
if ( $extensions ) {
foreach ( $extensions as $extension ) {
foreach ( $extension as $product ) {
$price = $product->price;
$lower_case_title = strtolower( str_replace( ' ', '-', $product->title ) );
$title = str_replace( 'Storefront', '', $product->title );
$price = $product->price;
$lower_case_title = strtolower( str_replace( ' ', '-', $product->title ) );
$title = str_replace( 'Storefront', '', $product->title );
if ( $price == '&#36;0.00' ) {
echo '<li><a class="thickbox" href="' . esc_url( wp_nonce_url( self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . esc_attr( $lower_case_title ) . '&TB_iframe=true&width=744&height=800' ), 'install-plugin_' . esc_attr( $lower_case_title ) ) ) . '">' . esc_attr( $title ) . ' - <span class="price">' . __( 'Free!', 'storefront' ) . '</span></a><p>' . wp_kses_post( $product->excerpt ) . '</p></li>';
if ( '&#36;0.00' == $price ) {
echo '<li><a class="thickbox" href="' . esc_url( wp_nonce_url( self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . esc_attr( $lower_case_title ) . '&TB_iframe=true&width=744&height=800' ), 'install-plugin_' . esc_attr( $lower_case_title ) ) ) . '">' . esc_attr( $title ) . ' - <span class="price">' . esc_attr__( 'Free!', 'storefront' ) . '</span></a><p>' . wp_kses_post( $product->excerpt ) . '</p></li>';
}
}
}
} else {
echo '<div class="storefront-notice">' . __( 'We\'re currently unable to retrieve these products. Please double check your internet connection or try back later.', 'storefront' ) . '</div>';
echo '<div class="storefront-notice">' . esc_attr__( 'We\'re currently unable to retrieve these products. Please double check your internet connection or try back later.', 'storefront' ) . '</div>';
}
?>
</ul>
</div>
</div>

View file

@ -2,12 +2,13 @@
/**
* Welcome screen intro template
*/
?>
<?php
global $storefront_version;
?>
<h1 class="sf-title"><?php echo '<img src="' . esc_url( get_template_directory_uri() ) . '/assets/images/admin/welcome-screen/storefront.png' . '" alt="Storefront" width="250" /> <sup class="version">' . esc_attr( $storefront_version ) . '</sup>'; ?></h1>
<h1 class="sf-title"><?php echo '<img src="' . esc_url( get_template_directory_uri() ) . '/assets/images/admin/welcome-screen/storefront.png" alt="Storefront" width="250" /> <sup class="version">' . esc_attr( $storefront_version ) . '</sup>'; ?></h1>
<section class="sf-review">
<p><?php echo sprintf( esc_html__( '%sEnjoying %s?%s Why not %sleave a review%s on WordPress.org? We\'d really appreciate it!', 'storefront' ), '<strong>', 'Storefront', '</strong>', '<a href="https://wordpress.org/themes/storefront">', '</a>' ); ?></p>
@ -64,4 +65,4 @@ global $storefront_version;
<p>
<span class="dashicons dashicons-hammer"></span> <?php printf( esc_html__( 'Stay up to date with Storefront developments on the %sdev blog%s.', 'storefront' ), '<a href="https://storefront.wordpress.com/">', '</a>' ); ?>
</p>
</div>
</div>

View file

@ -4,6 +4,7 @@
*
* @author WooThemes
* @since 2.0.0
* @package storefront
*/
if ( ! defined( 'ABSPATH' ) ) {
@ -12,224 +13,231 @@ if ( ! defined( 'ABSPATH' ) ) {
if ( ! class_exists( 'Storefront' ) ) :
class Storefront {
/**
* Setup class.
*
* @since 1.0
* The main Storefront class
*/
public function __construct() {
add_action( 'after_setup_theme', array( $this, 'setup' ) );
add_action( 'widgets_init', array( $this, 'widgets_init' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'scripts' ), 10 );
add_action( 'wp_enqueue_scripts', array( $this, 'child_scripts' ), 30 ); // After WooCommerce
add_filter( 'body_class', array( $this, 'body_classes' ) );
add_filter( 'wp_page_menu_args', array( $this, 'page_menu_args' ) );
}
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which
* runs before the init hook. The init hook is too late for some features, such
* as indicating support for post thumbnails.
*/
public function setup() {
class Storefront {
/**
* Set the content width based on the theme's design and stylesheet.
* Setup class.
*
* @since 1.0
*/
if ( ! isset( $content_width ) ) {
$content_width = 980; /* pixels */
public function __construct() {
add_action( 'after_setup_theme', array( $this, 'setup' ) );
add_action( 'widgets_init', array( $this, 'widgets_init' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'scripts' ), 10 );
add_action( 'wp_enqueue_scripts', array( $this, 'child_scripts' ), 30 ); // After WooCommerce.
add_filter( 'body_class', array( $this, 'body_classes' ) );
add_filter( 'wp_page_menu_args', array( $this, 'page_menu_args' ) );
}
/*
* Load Localisation files.
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note: the first-loaded translation file overrides any following ones if the same translation is present.
* Note that this function is hooked into the after_setup_theme hook, which
* runs before the init hook. The init hook is too late for some features, such
* as indicating support for post thumbnails.
*/
public function setup() {
// wp-content/languages/themes/storefront-it_IT.mo
load_theme_textdomain( 'storefront', trailingslashit( WP_LANG_DIR ) . 'themes/' );
/**
* Set the content width based on the theme's design and stylesheet.
*/
if ( ! isset( $content_width ) ) {
$content_width = 980; /* pixels */
}
// wp-content/themes/child-theme-name/languages/it_IT.mo
load_theme_textdomain( 'storefront', get_stylesheet_directory() . '/languages' );
/*
* Load Localisation files.
*
* Note: the first-loaded translation file overrides any following ones if the same translation is present.
*/
// wp-content/themes/storefront/languages/it_IT.mo
load_theme_textdomain( 'storefront', get_template_directory() . '/languages' );
// Loads wp-content/languages/themes/storefront-it_IT.mo.
load_theme_textdomain( 'storefront', trailingslashit( WP_LANG_DIR ) . 'themes/' );
// Loads wp-content/themes/child-theme-name/languages/it_IT.mo.
load_theme_textdomain( 'storefront', get_stylesheet_directory() . '/languages' );
// Loads wp-content/themes/storefront/languages/it_IT.mo.
load_theme_textdomain( 'storefront', get_template_directory() . '/languages' );
/**
* Add default posts and comments RSS feed links to head.
*/
add_theme_support( 'automatic-feed-links' );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
*/
add_theme_support( 'post-thumbnails' );
// This theme uses wp_nav_menu() in two locations.
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'storefront' ),
'secondary' => __( 'Secondary Menu', 'storefront' ),
'handheld' => __( 'Handheld Menu', 'storefront' ),
) );
/*
* Switch default core markup for search form, comment form, comments, galleries, captions and widgets
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
'widgets',
) );
// Setup the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'storefront_custom_background_args', array(
'default-color' => apply_filters( 'storefront_default_background_color', 'f5f5f5' ),
'default-image' => '',
) ) );
/**
* Add support for the Site Logo plugin and the site logo functionality in JetPack
* https://github.com/automattic/site-logo
* http://jetpack.me/
*/
add_theme_support( 'site-logo', array( 'size' => 'full' ) );
// Declare WooCommerce support.
add_theme_support( 'woocommerce' );
// Declare support for title theme feature.
add_theme_support( 'title-tag' );
}
/**
* Add default posts and comments RSS feed links to head.
*/
add_theme_support( 'automatic-feed-links' );
/*
* Enable support for Post Thumbnails on posts and pages.
* Register widget area.
*
* @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
* @link http://codex.wordpress.org/Function_Reference/register_sidebar
*/
add_theme_support( 'post-thumbnails' );
// This theme uses wp_nav_menu() in two locations.
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'storefront' ),
'secondary' => __( 'Secondary Menu', 'storefront' ),
'handheld' => __( 'Handheld Menu', 'storefront' ),
) );
/*
* Switch default core markup for search form, comment form, comments, galleries, captions and widgets
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
'widgets',
) );
// Setup the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'storefront_custom_background_args', array(
'default-color' => apply_filters( 'storefront_default_background_color', 'f5f5f5' ),
'default-image' => '',
) ) );
// Add support for the Site Logo plugin and the site logo functionality in JetPack
// https://github.com/automattic/site-logo
// http://jetpack.me/
add_theme_support( 'site-logo', array( 'size' => 'full' ) );
// Declare WooCommerce support
add_theme_support( 'woocommerce' );
// Declare support for title theme feature
add_theme_support( 'title-tag' );
}
/**
* Register widget area.
*
* @link http://codex.wordpress.org/Function_Reference/register_sidebar
*/
public function widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar', 'storefront' ),
'id' => 'sidebar-1',
'description' => '',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => __( 'Below Header', 'storefront' ),
'id' => 'header-1',
'description' => 'Widgets added to this region will appear beneath the header and above the main content.',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
$footer_widget_regions = apply_filters( 'storefront_footer_widget_regions', 4 );
for ( $i = 1; $i <= intval( $footer_widget_regions ); $i++ ) {
public function widgets_init() {
register_sidebar( array(
'name' => sprintf( __( 'Footer %d', 'storefront' ), $i ),
'id' => sprintf( 'footer-%d', $i ),
'description' => sprintf( __( 'Widgetized Footer Region %d.', 'storefront' ), $i ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3>',
'after_title' => '</h3>',
)
);
}
}
'name' => __( 'Sidebar', 'storefront' ),
'id' => 'sidebar-1',
'description' => '',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
/**
* Enqueue scripts and styles.
* @since 1.0.0
*/
public function scripts() {
global $storefront_version;
register_sidebar( array(
'name' => __( 'Below Header', 'storefront' ),
'id' => 'header-1',
'description' => 'Widgets added to this region will appear beneath the header and above the main content.',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
wp_enqueue_style( 'storefront-style', get_template_directory_uri() . '/style.css', '', $storefront_version );
$footer_widget_regions = apply_filters( 'storefront_footer_widget_regions', 4 );
wp_style_add_data( 'storefront-style', 'rtl', 'replace' );
wp_enqueue_script( 'storefront-navigation', get_template_directory_uri() . '/assets/js/navigation.min.js', array( 'jquery' ), '20120206', true );
wp_enqueue_script( 'storefront-skip-link-focus-fix', get_template_directory_uri() . '/assets/js/skip-link-focus-fix.min.js', array(), '20130115', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
/**
* Enqueue child theme stylesheet.
* A separate function is required as the child theme css needs to be enqueued _after_ the parent theme
* primary css and the separate WooCommerce css.
* @since 1.5.3
*/
public function child_scripts() {
if ( is_child_theme() ) {
wp_enqueue_style( 'storefront-child-style', get_stylesheet_uri(), '' );
}
}
/**
* Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
*
* @param array $args Configuration arguments.
* @return array
*/
public function page_menu_args( $args ) {
$args['show_home'] = true;
return $args;
}
/**
* Adds custom classes to the array of body classes.
*
* @param array $classes Classes for the body element.
* @return array
*/
public function body_classes( $classes ) {
// Adds a class of group-blog to blogs with more than 1 published author.
if ( is_multi_author() ) {
$classes[] = 'group-blog';
}
if ( ! function_exists( 'woocommerce_breadcrumb' ) ) {
$classes[] = 'no-wc-breadcrumb';
for ( $i = 1; $i <= intval( $footer_widget_regions ); $i++ ) {
register_sidebar( array(
'name' => sprintf( __( 'Footer %d', 'storefront' ), $i ),
'id' => sprintf( 'footer-%d', $i ),
'description' => sprintf( __( 'Widgetized Footer Region %d.', 'storefront' ), $i ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3>',
'after_title' => '</h3>',
)
);
}
}
/**
* What is this?!
* Take the blue pill, close this file and forget you saw the following code.
* Or take the red pill, filter storefront_make_me_cute and see how deep the rabbit hole goes...
* Enqueue scripts and styles.
*
* @since 1.0.0
*/
$cute = apply_filters( 'storefront_make_me_cute', false );
public function scripts() {
global $storefront_version;
if ( true === $cute ) {
$classes[] = 'storefront-cute';
wp_enqueue_style( 'storefront-style', get_template_directory_uri() . '/style.css', '', $storefront_version );
wp_style_add_data( 'storefront-style', 'rtl', 'replace' );
wp_enqueue_script( 'storefront-navigation', get_template_directory_uri() . '/assets/js/navigation.min.js', array( 'jquery' ), '20120206', true );
wp_enqueue_script( 'storefront-skip-link-focus-fix', get_template_directory_uri() . '/assets/js/skip-link-focus-fix.min.js', array(), '20130115', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
// If our main sidebar doesn't contain widgets, adjust the layout to be full-width.
if ( ! is_active_sidebar( 'sidebar-1' ) ) {
$classes[] = 'storefront-full-width-content';
/**
* Enqueue child theme stylesheet.
* A separate function is required as the child theme css needs to be enqueued _after_ the parent theme
* primary css and the separate WooCommerce css.
*
* @since 1.5.3
*/
public function child_scripts() {
if ( is_child_theme() ) {
wp_enqueue_style( 'storefront-child-style', get_stylesheet_uri(), '' );
}
}
return $classes;
/**
* Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
*
* @param array $args Configuration arguments.
* @return array
*/
public function page_menu_args( $args ) {
$args['show_home'] = true;
return $args;
}
/**
* Adds custom classes to the array of body classes.
*
* @param array $classes Classes for the body element.
* @return array
*/
public function body_classes( $classes ) {
// Adds a class of group-blog to blogs with more than 1 published author.
if ( is_multi_author() ) {
$classes[] = 'group-blog';
}
if ( ! function_exists( 'woocommerce_breadcrumb' ) ) {
$classes[] = 'no-wc-breadcrumb';
}
/**
* What is this?!
* Take the blue pill, close this file and forget you saw the following code.
* Or take the red pill, filter storefront_make_me_cute and see how deep the rabbit hole goes...
*/
$cute = apply_filters( 'storefront_make_me_cute', false );
if ( true === $cute ) {
$classes[] = 'storefront-cute';
}
// If our main sidebar doesn't contain widgets, adjust the layout to be full-width.
if ( ! is_active_sidebar( 'sidebar-1' ) ) {
$classes[] = 'storefront-full-width-content';
}
return $classes;
}
}
}
endif;
return new Storefront();
return new Storefront();

View file

@ -6,6 +6,11 @@ class Arbitrary_Storefront_Control extends WP_Customize_Control {
public $settings = 'blogname';
public $description = '';
/**
* Renter the control
*
* @return void
*/
public function render_content() {
switch ( $this->type ) {
default:

View file

@ -7,7 +7,8 @@ class More_Storefront_Control extends WP_Customize_Control {
/**
* Render the content on the theme customizer page
*/
public function render_content() { ?>
public function render_content() {
?>
<label style="overflow: hidden; zoom: 1;">
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
@ -21,8 +22,8 @@ class More_Storefront_Control extends WP_Customize_Control {
<p>
<?php printf( esc_html__( 'Why not leave us a review on %sWordPress.org%s? We\'d really appreciate it!', 'storefront' ), '<a href="https://wordpress.org/themes/storefront">', '</a>' ); ?>
</p>
</label>
<?php
}
}
}

View file

@ -55,7 +55,7 @@ class Storefront_Custom_Radio_Image_Control extends WP_Customize_Control {
<div id="input_<?php echo esc_attr( $this->id ); ?>" class="image">
<?php foreach ( $this->choices as $value => $label ) : ?>
<input class="image-select" type="radio" value="<?php echo esc_attr( $value ); ?>" id="<?php echo $this->id . $value; ?>" name="<?php echo esc_attr( $name ); ?>" <?php $this->link(); checked( $this->value(), $value ); ?>>
<input class="image-select" type="radio" value="<?php echo esc_attr( $value ); ?>" id="<?php echo esc_attr( $this->id . $value ); ?>" name="<?php echo esc_attr( $name ); ?>" <?php $this->link(); checked( $this->value(), $value ); ?>>
<label for="<?php echo esc_attr( $this->id ) . esc_attr( $value ); ?>">
<img src="<?php echo esc_html( $label ); ?>" alt="<?php echo esc_attr( $value ); ?>" title="<?php echo esc_attr( $value ); ?>">
</label>
@ -66,4 +66,4 @@ class Storefront_Custom_Radio_Image_Control extends WP_Customize_Control {
<script>jQuery(document).ready(function($) { $( '[id="input_<?php echo esc_attr( $this->id ); ?>"]' ).buttonset(); });</script>
<?php
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -2,6 +2,7 @@
/**
* Storefront Jetpack Class
*
* @package storefront
* @author WooThemes
* @since 2.0.0
*/
@ -12,43 +13,47 @@ if ( ! defined( 'ABSPATH' ) ) {
if ( ! class_exists( 'Storefront_Jetpack' ) ) :
class Storefront_Jetpack {
/**
* Setup class.
*
* @since 1.0
* The Storefront Jetpack integration class
*/
public function __construct() {
add_action( 'after_setup_theme', array( $this, 'jetpack_setup' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'jetpack_scripts' ), 10 );
}
class Storefront_Jetpack {
/**
* Add theme support for Infinite Scroll.
* See: http://jetpack.me/support/infinite-scroll/
*/
public function jetpack_setup() {
add_theme_support( 'infinite-scroll', array(
'container' => 'main',
'footer' => 'page',
) );
}
/**
* Setup class.
*
* @since 1.0
*/
public function __construct() {
add_action( 'after_setup_theme', array( $this, 'jetpack_setup' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'jetpack_scripts' ), 10 );
}
/**
* Enqueue jetpack styles.
* @since 1.6.1
*/
public function jetpack_scripts() {
global $storefront_version;
/**
* Add theme support for Infinite Scroll.
* See: http://jetpack.me/support/infinite-scroll/
*/
public function jetpack_setup() {
add_theme_support( 'infinite-scroll', array(
'container' => 'main',
'footer' => 'page',
) );
}
if ( class_exists( 'Jetpack' ) ) {
wp_enqueue_style( 'storefront-jetpack-style', get_template_directory_uri() . '/inc/jetpack/css/jetpack.css', '', $storefront_version );
wp_style_add_data( 'storefront-jetpack-style', 'rtl', 'replace' );
/**
* Enqueue jetpack styles.
*
* @since 1.6.1
*/
public function jetpack_scripts() {
global $storefront_version;
if ( class_exists( 'Jetpack' ) ) {
wp_enqueue_style( 'storefront-jetpack-style', get_template_directory_uri() . '/inc/jetpack/css/jetpack.css', '', $storefront_version );
wp_style_add_data( 'storefront-jetpack-style', 'rtl', 'replace' );
}
}
}
}
endif;
return new Storefront_Jetpack();
return new Storefront_Jetpack();

View file

@ -36,6 +36,7 @@ function storefront_do_shortcode( $tag, array $atts = array(), $content = null )
/**
* Get the content background color
* Accounts for the Storefront Designer's content background option.
*
* @since 1.6.0
* @return string the background color
*/
@ -44,10 +45,10 @@ function storefront_get_content_background_color() {
$content_bg_color = get_theme_mod( 'sd_content_background_color' );
$content_frame = get_theme_mod( 'sd_fixed_width' );
// Set the bg color based on the default theme option
// Set the bg color based on the default theme option.
$bg_color = str_replace( '#', '', get_theme_mod( 'background_color' ) );
// But if the Storefront Designer extension is active, and the content frame option is enabled we need that bg color instead
// But if the Storefront Designer extension is active, and the content frame option is enabled we need that bg color instead.
if ( $content_bg_color && 'true' == $content_frame && class_exists( 'Storefront_Designer' ) ) {
$bg_color = str_replace( '#', '', $content_bg_color );
}
@ -57,6 +58,7 @@ function storefront_get_content_background_color() {
/**
* Apply inline style to the Storefront header.
*
* @uses get_header_image()
* @since 2.0.0
*/
@ -65,7 +67,7 @@ function storefront_header_styles() {
'background-image' => 'url(' . esc_url( get_header_image() ) . ')',
) );
foreach( $styles as $style => $value ) {
foreach ( $styles as $style => $value ) {
echo $style . ': ' . $value . '; ';
}
}
@ -73,28 +75,29 @@ function storefront_header_styles() {
/**
* Adjust a hex color brightness
* Allows us to create hover styles for custom link colors
* @param strong $hex hex color e.g. #111111
* @param integer $steps factor by which to brighten/darken ranging from -255 (darken) to 255 (brighten)
*
* @param strong $hex hex color e.g. #111111.
* @param integer $steps factor by which to brighten/darken ranging from -255 (darken) to 255 (brighten).
* @return string brightened/darkened hex color
* @since 1.0.0
*/
function storefront_adjust_color_brightness( $hex, $steps ) {
// Steps should be between -255 and 255. Negative = darker, positive = lighter
// Steps should be between -255 and 255. Negative = darker, positive = lighter.
$steps = max( -255, min( 255, $steps ) );
// Format the hex color string
// Format the hex color string.
$hex = str_replace( '#', '', $hex );
if ( 3 == strlen( $hex ) ) {
$hex = str_repeat( substr( $hex, 0, 1 ), 2 ) . str_repeat( substr( $hex, 1, 1 ), 2 ) . str_repeat( substr( $hex, 2, 1 ), 2 );
}
// Get decimal values
// Get decimal values.
$r = hexdec( substr( $hex, 0, 2 ) );
$g = hexdec( substr( $hex, 2, 2 ) );
$b = hexdec( substr( $hex, 4, 2 ) );
// Adjust number of steps and keep it inside 0 to 255
// Adjust number of steps and keep it inside 0 to 255.
$r = max( 0, min( 255, $r + $steps ) );
$g = max( 0, min( 255, $g + $steps ) );
$b = max( 0, min( 255, $b + $steps ) );
@ -110,6 +113,7 @@ function storefront_adjust_color_brightness( $hex, $steps ) {
* Sanitizes choices (selects / radios)
* Checks that the input matches one of the available choices
*
* @param array $input the available choices.
* @since 1.3.0
*/
function storefront_sanitize_choices( $input, $setting ) {
@ -134,7 +138,7 @@ function storefront_sanitize_choices( $input, $setting ) {
* @since 1.5.0
*/
function storefront_sanitize_checkbox( $checked ) {
return (bool) $checked;
return (bool) $checked;
}
/**
@ -142,6 +146,7 @@ function storefront_sanitize_checkbox( $checked ) {
*
* Ensures only array keys matching the original settings specified in add_control() are valid
*
* @param array $input the layout options.
* @since 1.0.3
*/
function storefront_sanitize_layout( $input ) {
@ -162,6 +167,7 @@ function storefront_sanitize_layout( $input ) {
/**
* Storefront Sanitize Hex Color
*
* @param string $color The color as a hex.
* @todo remove in 2.1.
*/
function storefront_sanitize_hex_color( $color ) {
@ -209,4 +215,4 @@ function storefront_categorized_blog() {
// This blog has only 1 category so storefront_categorized_blog should return false.
return false;
}
}
}

View file

@ -8,10 +8,11 @@
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 are open or we have at least one comment, load up the comment template.
if ( comments_open() || '0' != get_comments_number() ) :
comments_template();
endif;
@ -21,23 +22,21 @@ if ( ! function_exists( 'storefront_display_comments' ) ) {
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';
$schema = 'http://schema.org/';
$type = 'WebPage';
// Is single post
if ( is_singular( 'post' ) ) {
$type = 'Article';
$type = 'Article';
}
// Is author page
elseif ( is_author() ) {
$type = 'ProfilePage';
$type = 'ProfilePage';
}
// Is search results page
elseif ( is_search() ) {
$type = 'SearchResultsPage';
}
@ -49,6 +48,8 @@ if ( ! function_exists( 'storefront_html_tag_schema' ) ) {
if ( ! function_exists( 'storefront_comment' ) ) {
/**
* Storefront comment template
*
* @param array $comment the comment array.
* @since 1.0.0
*/
function storefront_comment( $comment, $args, $depth ) {
@ -65,10 +66,10 @@ if ( ! function_exists( 'storefront_comment' ) ) {
<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() ); ?>
<?php printf( esc_attr__( '<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>
<em class="comment-awaiting-moderation"><?php esc_attr_e( 'Your comment is awaiting moderation.', 'storefront' ); ?></em>
<br />
<?php endif; ?>
@ -97,6 +98,7 @@ if ( ! function_exists( 'storefront_comment' ) ) {
if ( ! function_exists( 'storefront_footer_widgets' ) ) {
/**
* Display the footer widget regions
*
* @since 1.0.0
* @return void
*/
@ -138,6 +140,7 @@ if ( ! function_exists( 'storefront_footer_widgets' ) ) {
if ( ! function_exists( 'storefront_credit' ) ) {
/**
* Display the theme credit
*
* @since 1.0.0
* @return void
*/
@ -146,7 +149,7 @@ if ( ! function_exists( 'storefront_credit' ) ) {
<div class="site-info">
<?php echo esc_html( apply_filters( 'storefront_copyright_text', $content = '&copy; ' . 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>' ); ?>
<br /> <?php printf( esc_attr__( '%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
@ -156,6 +159,7 @@ if ( ! function_exists( 'storefront_credit' ) ) {
if ( ! function_exists( 'storefront_footer_widgets' ) ) {
/**
* Display the footer widget regions
*
* @since 1.0.0
* @return void
*/
@ -197,6 +201,7 @@ if ( ! function_exists( 'storefront_footer_widgets' ) ) {
if ( ! function_exists( 'storefront_credit' ) ) {
/**
* Display the theme credit
*
* @since 1.0.0
* @return void
*/
@ -205,7 +210,7 @@ if ( ! function_exists( 'storefront_credit' ) ) {
<div class="site-info">
<?php echo esc_html( apply_filters( 'storefront_copyright_text', $content = '&copy; ' . 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>' ); ?>
<br /> <?php printf( esc_attr__( '%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
@ -215,6 +220,7 @@ if ( ! function_exists( 'storefront_credit' ) ) {
if ( ! function_exists( 'storefront_header_widget_region' ) ) {
/**
* Display header widget region
*
* @since 1.0.0
*/
function storefront_header_widget_region() {
@ -233,6 +239,7 @@ if ( ! function_exists( 'storefront_header_widget_region' ) ) {
if ( ! function_exists( 'storefront_site_branding' ) ) {
/**
* Display Site Branding
*
* @since 1.0.0
* @return void
*/
@ -253,6 +260,7 @@ if ( ! function_exists( 'storefront_site_branding' ) ) {
if ( ! function_exists( 'storefront_primary_navigation' ) ) {
/**
* Display Primary Navigation
*
* @since 1.0.0
* @return void
*/
@ -283,6 +291,7 @@ if ( ! function_exists( 'storefront_primary_navigation' ) ) {
if ( ! function_exists( 'storefront_secondary_navigation' ) ) {
/**
* Display Secondary Navigation
*
* @since 1.0.0
* @return void
*/
@ -305,13 +314,14 @@ if ( ! function_exists( 'storefront_secondary_navigation' ) ) {
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>
<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>
<?php
}
}
@ -319,6 +329,7 @@ if ( ! function_exists( 'storefront_skip_links' ) ) {
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() {
@ -336,6 +347,7 @@ if ( ! function_exists( 'storefront_page_header' ) ) {
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() {
@ -356,6 +368,7 @@ if ( ! function_exists( 'storefront_page_content' ) ) {
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() { ?>
@ -380,6 +393,7 @@ if ( ! function_exists( 'storefront_post_header' ) ) {
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() {
@ -408,12 +422,13 @@ if ( ! function_exists( 'storefront_post_content' ) ) {
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 if ( 'post' == get_post_type() ) : // Hide category and tag text for pages on Search.
?>
<div class="author">
@ -434,7 +449,7 @@ if ( ! function_exists( 'storefront_post_meta' ) ) {
echo wp_kses_post( $categories_list );
?>
</div>
<?php endif; // End if categories ?>
<?php endif; // End if categories. ?>
<?php
/* translators: used between list items, there is a space after the comma */
@ -447,9 +462,9 @@ if ( ! function_exists( 'storefront_post_meta' ) ) {
echo wp_kses_post( $tags_list );
?>
</div>
<?php endif; // End if $tags_list ?>
<?php endif; // End if $tags_list. ?>
<?php endif; // End if 'post' == get_post_type() ?>
<?php endif; // End if 'post' == get_post_type(). ?>
<?php if ( ! post_password_required() && ( comments_open() || '0' != get_comments_number() ) ) : ?>
<?php echo '<div class="label">' . esc_attr( __( 'Comments', 'storefront' ) ) . '</div>'; ?>
@ -512,7 +527,7 @@ if ( ! function_exists( 'storefront_posted_on' ) ) {
'<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'
);
echo apply_filters( 'storefront_single_post_posted_on_html', '<span class="posted-on">' . $posted_on . '</span>', $posted_on );
echo esc_attr( apply_filters( 'storefront_single_post_posted_on_html', '<span class="posted-on">' . $posted_on . '</span>', $posted_on ) );
}
}
@ -520,6 +535,7 @@ if ( ! function_exists( 'storefront_product_categories' ) ) {
/**
* Display Product Categories
* Hooked into the `homepage` action in the homepage template
*
* @since 1.0.0
* @return void
*/
@ -533,7 +549,7 @@ if ( ! function_exists( 'storefront_product_categories' ) ) {
'child_categories' => 0,
'orderby' => 'name',
'title' => __( 'Shop by Category', 'storefront' ),
) );
) );
echo '<section class="storefront-product-section storefront-product-categories">';
@ -543,13 +559,12 @@ if ( ! function_exists( 'storefront_product_categories' ) ) {
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'] ),
) );
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' );
@ -562,6 +577,7 @@ if ( ! function_exists( 'storefront_recent_products' ) ) {
/**
* Display Recent Products
* Hooked into the `homepage` action in the homepage template
*
* @since 1.0.0
* @return void
*/
@ -573,7 +589,7 @@ if ( ! function_exists( 'storefront_recent_products' ) ) {
'limit' => 4,
'columns' => 4,
'title' => __( 'New In', 'storefront' ),
) );
) );
echo '<section class="storefront-product-section storefront-recent-products">';
@ -583,11 +599,10 @@ if ( ! function_exists( 'storefront_recent_products' ) ) {
do_action( 'storefront_homepage_after_recent_products_title' );
echo storefront_do_shortcode( 'recent_products',
array(
'per_page' => intval( $args['limit'] ),
'columns' => intval( $args['columns'] ),
) );
echo storefront_do_shortcode( 'recent_products', array(
'per_page' => intval( $args['limit'] ),
'columns' => intval( $args['columns'] ),
) );
do_action( 'storefront_homepage_after_recent_products' );
@ -600,6 +615,7 @@ if ( ! function_exists( 'storefront_featured_products' ) ) {
/**
* Display Featured Products
* Hooked into the `homepage` action in the homepage template
*
* @since 1.0.0
* @return void
*/
@ -608,12 +624,12 @@ if ( ! function_exists( 'storefront_featured_products' ) ) {
if ( is_woocommerce_activated() ) {
$args = apply_filters( 'storefront_featured_products_args', array(
'limit' => 4,
'columns' => 4,
'orderby' => 'date',
'order' => 'desc',
'title' => __( 'We Recommend', 'storefront' ),
) );
'limit' => 4,
'columns' => 4,
'orderby' => 'date',
'order' => 'desc',
'title' => __( 'We Recommend', 'storefront' ),
) );
echo '<section class="storefront-product-section storefront-featured-products">';
@ -623,13 +639,12 @@ if ( ! function_exists( 'storefront_featured_products' ) ) {
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'] ),
) );
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' );
@ -642,6 +657,7 @@ if ( ! function_exists( 'storefront_popular_products' ) ) {
/**
* Display Popular Products
* Hooked into the `homepage` action in the homepage template
*
* @since 1.0.0
* @return void
*/
@ -650,10 +666,10 @@ if ( ! function_exists( 'storefront_popular_products' ) ) {
if ( is_woocommerce_activated() ) {
$args = apply_filters( 'storefront_popular_products_args', array(
'limit' => 4,
'columns' => 4,
'title' => __( 'Fan Favorites', 'storefront' ),
) );
'limit' => 4,
'columns' => 4,
'title' => __( 'Fan Favorites', 'storefront' ),
) );
echo '<section class="storefront-product-section storefront-popular-products">';
@ -663,11 +679,10 @@ if ( ! function_exists( 'storefront_popular_products' ) ) {
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'] ),
) );
echo storefront_do_shortcode( 'top_rated_products', array(
'per_page' => intval( $args['limit'] ),
'columns' => intval( $args['columns'] ),
) );
do_action( 'storefront_homepage_after_popular_products' );
@ -688,10 +703,10 @@ if ( ! function_exists( 'storefront_on_sale_products' ) ) {
if ( is_woocommerce_activated() ) {
$args = apply_filters( 'storefront_on_sale_products_args', array(
'limit' => 4,
'columns' => 4,
'title' => __( 'On Sale', 'storefront' ),
) );
'limit' => 4,
'columns' => 4,
'title' => __( 'On Sale', 'storefront' ),
) );
echo '<section class="storefront-product-section storefront-on-sale-products">';
@ -701,11 +716,10 @@ if ( ! function_exists( 'storefront_on_sale_products' ) ) {
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'] ),
) );
echo storefront_do_shortcode( 'sale_products', array(
'per_page' => intval( $args['limit'] ),
'columns' => intval( $args['columns'] ),
) );
do_action( 'storefront_homepage_after_on_sale_products' );
@ -718,6 +732,7 @@ if ( ! function_exists( 'storefront_homepage_content' ) ) {
/**
* Display homepage content
* Hooked into the `homepage` action in the homepage template
*
* @since 1.0.0
* @return void
*/
@ -735,6 +750,7 @@ 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
*/
@ -750,6 +766,7 @@ if ( ! function_exists( 'storefront_social_icons' ) ) {
if ( ! function_exists( 'storefront_get_sidebar' ) ) {
/**
* Display storefront sidebar
*
* @uses get_sidebar()
* @since 1.0.0
*/
@ -761,10 +778,11 @@ if ( ! function_exists( 'storefront_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
* @param string $size the post thumbnail size.
* @since 1.5.0
*/
function storefront_post_thumbnail( $size ) {
@ -772,4 +790,4 @@ if ( ! function_exists( 'storefront_post_thumbnail' ) ) {
the_post_thumbnail( $size, array( 'itemprop' => 'image' ) );
}
}
}
}

View file

@ -7,34 +7,38 @@
/**
* General
*
* @see storefront_header_widget_region()
* @see storefront_get_sidebar()
*/
add_action( 'storefront_before_content', 'storefront_header_widget_region', 10 );
add_action( 'storefront_sidebar', 'storefront_get_sidebar', 10 );
add_action( 'storefront_before_content', 'storefront_header_widget_region', 10 );
add_action( 'storefront_sidebar', 'storefront_get_sidebar', 10 );
/**
* Header
*
* @see storefront_skip_links()
* @see storefront_secondary_navigation()
* @see storefront_site_branding()
* @see storefront_primary_navigation()
*/
add_action( 'storefront_header', 'storefront_skip_links', 0 );
add_action( 'storefront_header', 'storefront_site_branding', 20 );
add_action( 'storefront_header', 'storefront_secondary_navigation', 30 );
add_action( 'storefront_header', 'storefront_primary_navigation', 50 );
add_action( 'storefront_header', 'storefront_skip_links', 0 );
add_action( 'storefront_header', 'storefront_site_branding', 20 );
add_action( 'storefront_header', 'storefront_secondary_navigation', 30 );
add_action( 'storefront_header', 'storefront_primary_navigation', 50 );
/**
* Footer
*
* @see storefront_footer_widgets()
* @see storefront_credit()
*/
add_action( 'storefront_footer', 'storefront_footer_widgets', 10 );
add_action( 'storefront_footer', 'storefront_credit', 20 );
add_action( 'storefront_footer', 'storefront_footer_widgets', 10 );
add_action( 'storefront_footer', 'storefront_credit', 20 );
/**
* Homepage
*
* @see storefront_homepage_content()
* @see storefront_product_categories()
* @see storefront_recent_products()
@ -42,15 +46,16 @@ add_action( 'storefront_footer', 'storefront_credit', 20 );
* @see storefront_popular_products()
* @see storefront_on_sale_products()
*/
add_action( 'homepage', 'storefront_homepage_content', 10 );
add_action( 'homepage', 'storefront_product_categories', 20 );
add_action( 'homepage', 'storefront_recent_products', 30 );
add_action( 'homepage', 'storefront_featured_products', 40 );
add_action( 'homepage', 'storefront_popular_products', 50 );
add_action( 'homepage', 'storefront_on_sale_products', 60 );
add_action( 'homepage', 'storefront_homepage_content', 10 );
add_action( 'homepage', 'storefront_product_categories', 20 );
add_action( 'homepage', 'storefront_recent_products', 30 );
add_action( 'homepage', 'storefront_featured_products', 40 );
add_action( 'homepage', 'storefront_popular_products', 50 );
add_action( 'homepage', 'storefront_on_sale_products', 60 );
/**
* Posts
*
* @see storefront_post_header()
* @see storefront_post_meta()
* @see storefront_post_content()
@ -59,22 +64,23 @@ add_action( 'homepage', 'storefront_on_sale_products', 60 );
* @see storefront_post_nav()
* @see storefront_display_comments()
*/
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 );
add_action( 'storefront_single_post_after', 'storefront_post_nav', 10 );
add_action( 'storefront_single_post_after', 'storefront_display_comments', 20 );
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 );
add_action( 'storefront_single_post_after', 'storefront_post_nav', 10 );
add_action( 'storefront_single_post_after', 'storefront_display_comments', 20 );
/**
* Pages
*
* @see storefront_page_header()
* @see storefront_page_content()
* @see storefront_display_comments()
*/
add_action( 'storefront_page', 'storefront_page_header', 10 );
add_action( 'storefront_page', 'storefront_page_content', 20 );
add_action( 'storefront_page_after', 'storefront_display_comments', 10 );
add_action( 'storefront_page', 'storefront_page_header', 10 );
add_action( 'storefront_page', 'storefront_page_content', 20 );
add_action( 'storefront_page_after', 'storefront_display_comments', 10 );

View file

@ -2,6 +2,7 @@
/**
* Storefront WooCommerce Class
*
* @package storefront
* @author WooThemes
* @since 2.0.0
*/
@ -12,315 +13,327 @@ if ( ! defined( 'ABSPATH' ) ) {
if ( ! class_exists( 'Storefront_WooCommerce' ) ) :
class Storefront_WooCommerce {
/**
* Setup class.
*
* @since 1.0
* The Storefront WooCommerce Integration class
*/
public function __construct() {
add_filter( 'loop_shop_columns', array( $this, 'loop_columns' ) );
add_filter( 'body_class', array( $this, 'woocommerce_body_class' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'woocommerce_scripts' ), 20 );
add_filter( 'woocommerce_enqueue_styles', '__return_empty_array' );
add_filter( 'woocommerce_output_related_products_args', array( $this, 'related_products_args' ) );
add_filter( 'woocommerce_product_thumbnails_columns', array( $this, 'thumbnail_columns' ) );
add_filter( 'loop_shop_per_page', array( $this, 'products_per_page' ) );
class Storefront_WooCommerce {
if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '2.5', '<' ) ) {
add_action( 'wp_footer', array( $this, 'star_rating_script' ) );
/**
* Setup class.
*
* @since 1.0
*/
public function __construct() {
add_filter( 'loop_shop_columns', array( $this, 'loop_columns' ) );
add_filter( 'body_class', array( $this, 'woocommerce_body_class' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'woocommerce_scripts' ), 20 );
add_filter( 'woocommerce_enqueue_styles', '__return_empty_array' );
add_filter( 'woocommerce_output_related_products_args', array( $this, 'related_products_args' ) );
add_filter( 'woocommerce_product_thumbnails_columns', array( $this, 'thumbnail_columns' ) );
add_filter( 'loop_shop_per_page', array( $this, 'products_per_page' ) );
if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '2.5', '<' ) ) {
add_action( 'wp_footer', array( $this, 'star_rating_script' ) );
}
// Integrations.
add_action( 'wp_enqueue_scripts', array( $this, 'woocommerce_integrations_scripts' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'add_integrations_customizer_css' ) );
}
// Integrations
add_action( 'wp_enqueue_scripts', array( $this, 'woocommerce_integrations_scripts' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'add_integrations_customizer_css' ) );
}
/**
* Default loop columns on product archives
* @return integer products per row
* @since 1.0.0
*/
public function loop_columns() {
return apply_filters( 'storefront_loop_columns', 3 ); // 3 products per row
}
/**
* Add 'woocommerce-active' class to the body tag
* @param array $classes
* @return array $classes modified to include 'woocommerce-active' class
*/
public function woocommerce_body_class( $classes ) {
if ( is_woocommerce_activated() ) {
$classes[] = 'woocommerce-active';
/**
* Default loop columns on product archives
*
* @return integer products per row
* @since 1.0.0
*/
public function loop_columns() {
return apply_filters( 'storefront_loop_columns', 3 ); // 3 products per row
}
return $classes;
}
/**
* Add 'woocommerce-active' class to the body tag
*
* @param array $classes css classes applied to the body tag.
* @return array $classes modified to include 'woocommerce-active' class
*/
public function woocommerce_body_class( $classes ) {
if ( is_woocommerce_activated() ) {
$classes[] = 'woocommerce-active';
}
/**
* WooCommerce specific scripts & stylesheets
* @since 1.0.0
*/
public function woocommerce_scripts() {
global $storefront_version;
wp_enqueue_style( 'storefront-woocommerce-style', get_template_directory_uri() . '/assets/sass/woocommerce/woocommerce.css', $storefront_version );
wp_style_add_data( 'storefront-woocommerce-style', 'rtl', 'replace' );
wp_register_script( 'storefront-sticky-payment', get_template_directory_uri() . '/assets/js/woocommerce/checkout.min.js', 'jquery', $storefront_version, true );
if ( is_checkout() ) {
wp_enqueue_script( 'storefront-sticky-payment' );
return $classes;
}
}
/**
* Star rating backwards compatibility script (WooCommerce <2.5).
* @since 1.6.0
*/
public function star_rating_script() {
if ( wp_script_is( 'jquery', 'done' ) && is_product() ) {
?>
<script type="text/javascript">
jQuery( function( $ ) {
$( 'body' ).on( 'click', '#respond p.stars a', function() {
var $container = $( this ).closest( '.stars' );
$container.addClass( 'selected' );
/**
* WooCommerce specific scripts & stylesheets
*
* @since 1.0.0
*/
public function woocommerce_scripts() {
global $storefront_version;
wp_enqueue_style( 'storefront-woocommerce-style', get_template_directory_uri() . '/assets/sass/woocommerce/woocommerce.css', $storefront_version );
wp_style_add_data( 'storefront-woocommerce-style', 'rtl', 'replace' );
wp_register_script( 'storefront-sticky-payment', get_template_directory_uri() . '/assets/js/woocommerce/checkout.min.js', 'jquery', $storefront_version, true );
if ( is_checkout() ) {
wp_enqueue_script( 'storefront-sticky-payment' );
}
}
/**
* Star rating backwards compatibility script (WooCommerce <2.5).
*
* @since 1.6.0
*/
public function star_rating_script() {
if ( wp_script_is( 'jquery', 'done' ) && is_product() ) {
?>
<script type="text/javascript">
jQuery( function( $ ) {
$( 'body' ).on( 'click', '#respond p.stars a', function() {
var $container = $( this ).closest( '.stars' );
$container.addClass( 'selected' );
});
});
});
</script>
<?php
}
}
/**
* Related Products Args
* @param array $args related products args
* @since 1.0.0
* @return array $args related products args
*/
public function related_products_args( $args ) {
$args = apply_filters( 'storefront_related_products_args', array(
'posts_per_page' => 3,
'columns' => 3,
) );
return $args;
}
/**
* Product gallery thumnail columns
* @return integer number of columns
* @since 1.0.0
*/
public function thumbnail_columns() {
return intval( apply_filters( 'storefront_product_thumbnail_columns', 4 ) );
}
/**
* Products per page
* @return integer number of products
* @since 1.0.0
*/
public function products_per_page() {
return intval( apply_filters( 'storefront_products_per_page', 12 ) );
}
/**
* Query WooCommerce Extension Activation.
* @var $extension main extension class name
* @return boolean
*/
public function is_woocommerce_extension_activated( $extension = 'WC_Bookings' ) {
return class_exists( $extension ) ? true : false;
}
/**
* Integration Styles & Scripts
* @return void
*/
public function woocommerce_integrations_scripts() {
/**
* Bookings
*/
if ( $this->is_woocommerce_extension_activated( 'WC_Bookings' ) ) {
wp_enqueue_style( 'storefront-woocommerce-bookings-style', get_template_directory_uri() . '/assets/sass/woocommerce/bookings.css', 'storefront-woocommerce-style' );
wp_style_add_data( 'storefront-woocommerce-bookings-style', 'rtl', 'replace' );
</script>
<?php
}
}
/**
* Brands
* Related Products Args
*
* @param array $args related products args.
* @since 1.0.0
* @return array $args related products args
*/
if ( $this->is_woocommerce_extension_activated( 'WC_Brands' ) ) {
wp_enqueue_style( 'storefront-woocommerce-brands-style', get_template_directory_uri() . '/assets/sass/woocommerce/brands.css', 'storefront-woocommerce-style' );
wp_style_add_data( 'storefront-woocommerce-brands-style', 'rtl', 'replace' );
public function related_products_args( $args ) {
$args = apply_filters( 'storefront_related_products_args', array(
'posts_per_page' => 3,
'columns' => 3,
) );
return $args;
}
/**
* Wishlists
* Product gallery thumnail columns
*
* @return integer number of columns
* @since 1.0.0
*/
if ( $this->is_woocommerce_extension_activated( 'WC_Wishlists_Wishlist' ) ) {
wp_enqueue_style( 'storefront-woocommerce-wishlists-style', get_template_directory_uri() . '/assets/sass/woocommerce/wishlists.css', 'storefront-woocommerce-style' );
wp_style_add_data( 'storefront-woocommerce-wishlists-style', 'rtl', 'replace' );
public function thumbnail_columns() {
return intval( apply_filters( 'storefront_product_thumbnail_columns', 4 ) );
}
/**
* AJAX Layered Nav
* Products per page
*
* @return integer number of products
* @since 1.0.0
*/
if ( $this->is_woocommerce_extension_activated( 'SOD_Widget_Ajax_Layered_Nav' ) ) {
wp_enqueue_style( 'storefront-woocommerce-ajax-layered-nav-style', get_template_directory_uri() . '/assets/sass/woocommerce/ajax-layered-nav.css', 'storefront-woocommerce-style' );
wp_style_add_data( 'storefront-woocommerce-ajax-layered-nav-style', 'rtl', 'replace' );
public function products_per_page() {
return intval( apply_filters( 'storefront_products_per_page', 12 ) );
}
/**
* Variation Swatches
* Query WooCommerce Extension Activation.
*
* @param string $extension Extension class name.
* @return boolean
*/
if ( $this->is_woocommerce_extension_activated( 'WC_SwatchesPlugin' ) ) {
wp_enqueue_style( 'storefront-woocommerce-variation-swatches-style', get_template_directory_uri() . '/assets/sass/woocommerce/variation-swatches.css', 'storefront-woocommerce-style' );
wp_style_add_data( 'storefront-woocommerce-variation-swatches-style', 'rtl', 'replace' );
public function is_woocommerce_extension_activated( $extension = 'WC_Bookings' ) {
return class_exists( $extension ) ? true : false;
}
/**
* Composite Products
* Integration Styles & Scripts
*
* @return void
*/
if ( $this->is_woocommerce_extension_activated( 'WC_Composite_Products' ) ) {
wp_enqueue_style( 'storefront-woocommerce-composite-products-style', get_template_directory_uri() . '/assets/sass/woocommerce/composite-products.css', 'storefront-woocommerce-style' );
wp_style_add_data( 'storefront-woocommerce-composite-products-style', 'rtl', 'replace' );
}
/**
* WooCommerce Photography
*/
if ( $this->is_woocommerce_extension_activated( 'WC_Photography' ) ) {
wp_enqueue_style( 'storefront-woocommerce-photography-style', get_template_directory_uri() . '/assets/sass/woocommerce/photography.css', 'storefront-woocommerce-style' );
wp_style_add_data( 'storefront-woocommerce-photography-style', 'rtl', 'replace' );
}
/**
* Product Reviews Pro
*/
if ( $this->is_woocommerce_extension_activated( 'WC_Product_Reviews_Pro' ) ) {
wp_enqueue_style( 'storefront-woocommerce-product-reviews-pro-style', get_template_directory_uri() . '/assets/sass/woocommerce/product-reviews-pro.css', 'storefront-woocommerce-style' );
wp_style_add_data( 'storefront-woocommerce-product-reviews-pro-style', 'rtl', 'replace' );
}
/**
* WooCommerce Smart Coupons
*/
if ( $this->is_woocommerce_extension_activated( 'WC_Smart_Coupons' ) ) {
wp_enqueue_style( 'storefront-woocommerce-smart-coupons-style', get_template_directory_uri() . '/assets/sass/woocommerce/smart-coupons.css', 'storefront-woocommerce-style' );
wp_style_add_data( 'storefront-woocommerce-smart-coupons-style', 'rtl', 'replace' );
}
/**
* WooCommerce Deposits
*/
if ( $this->is_woocommerce_extension_activated( 'WC_Deposits' ) ) {
wp_enqueue_style( 'storefront-woocommerce-deposits-style', get_template_directory_uri() . '/assets/sass/woocommerce/deposits.css', 'storefront-woocommerce-style' );
wp_style_add_data( 'storefront-woocommerce-deposits-style', 'rtl', 'replace' );
}
/**
* WooCommerce Product Bundles
*/
if ( $this->is_woocommerce_extension_activated( 'WC_Bundles' ) ) {
wp_enqueue_style( 'storefront-woocommerce-bundles-style', get_template_directory_uri() . '/assets/sass/woocommerce/bundles.css', 'storefront-woocommerce-style' );
wp_style_add_data( 'storefront-woocommerce-bundles-style', 'rtl', 'replace' );
}
/**
* WooCommerce Multiple Shipping Addresses
*/
if ( $this->is_woocommerce_extension_activated( 'WC_Ship_Multiple' ) ) {
wp_enqueue_style( 'storefront-woocommerce-sma-style', get_template_directory_uri() . '/assets/sass/woocommerce/ship-multiple-addresses.css', 'storefront-woocommerce-style' );
wp_style_add_data( 'storefront-woocommerce-sma-style', 'rtl', 'replace' );
}
}
/**
* Add CSS in <head> for integration styles handled by the theme customizer
*
* @since 1.0
*/
public function add_integrations_customizer_css() {
$accent_color = get_theme_mod( 'storefront_accent_color', apply_filters( 'storefront_default_accent_color', '#FFA107' ) );
$header_text_color = get_theme_mod( 'storefront_header_text_color', apply_filters( 'storefront_default_header_text_color', '#9aa0a7' ) );
$header_background_color = get_theme_mod( 'storefront_header_background_color', apply_filters( 'storefront_default_header_background_color', '#2c2d33' ) );
$text_color = get_theme_mod( 'storefront_text_color', apply_filters( 'storefront_default_text_color', '#60646c' ) );
$button_background_color = get_theme_mod( 'storefront_button_background_color', apply_filters( 'storefront_default_button_background_color', '#60646c' ) );
$button_text_color = get_theme_mod( 'storefront_button_text_color', apply_filters( 'storefront_default_button_text_color', '#ffffff' ) );
$woocommerce_style = '';
if ( $this->is_woocommerce_extension_activated( 'WC_Bookings' ) ) {
$woocommerce_style .= '
#wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker td.bookable a,
#wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker td.bookable a:hover,
#wc-bookings-booking-form .block-picker li a:hover,
#wc-bookings-booking-form .block-picker li a.selected {
background-color: ' . $accent_color . ' !important;
public function woocommerce_integrations_scripts() {
/**
* Bookings
*/
if ( $this->is_woocommerce_extension_activated( 'WC_Bookings' ) ) {
wp_enqueue_style( 'storefront-woocommerce-bookings-style', get_template_directory_uri() . '/assets/sass/woocommerce/bookings.css', 'storefront-woocommerce-style' );
wp_style_add_data( 'storefront-woocommerce-bookings-style', 'rtl', 'replace' );
}
#wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker td.ui-state-disabled .ui-state-default,
#wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker th {
color:' . $text_color . ';
/**
* Brands
*/
if ( $this->is_woocommerce_extension_activated( 'WC_Brands' ) ) {
wp_enqueue_style( 'storefront-woocommerce-brands-style', get_template_directory_uri() . '/assets/sass/woocommerce/brands.css', 'storefront-woocommerce-style' );
wp_style_add_data( 'storefront-woocommerce-brands-style', 'rtl', 'replace' );
}
#wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker-header {
background-color: ' . $header_background_color . ';
color: ' . $header_text_color . ';
}';
/**
* Wishlists
*/
if ( $this->is_woocommerce_extension_activated( 'WC_Wishlists_Wishlist' ) ) {
wp_enqueue_style( 'storefront-woocommerce-wishlists-style', get_template_directory_uri() . '/assets/sass/woocommerce/wishlists.css', 'storefront-woocommerce-style' );
wp_style_add_data( 'storefront-woocommerce-wishlists-style', 'rtl', 'replace' );
}
/**
* AJAX Layered Nav
*/
if ( $this->is_woocommerce_extension_activated( 'SOD_Widget_Ajax_Layered_Nav' ) ) {
wp_enqueue_style( 'storefront-woocommerce-ajax-layered-nav-style', get_template_directory_uri() . '/assets/sass/woocommerce/ajax-layered-nav.css', 'storefront-woocommerce-style' );
wp_style_add_data( 'storefront-woocommerce-ajax-layered-nav-style', 'rtl', 'replace' );
}
/**
* Variation Swatches
*/
if ( $this->is_woocommerce_extension_activated( 'WC_SwatchesPlugin' ) ) {
wp_enqueue_style( 'storefront-woocommerce-variation-swatches-style', get_template_directory_uri() . '/assets/sass/woocommerce/variation-swatches.css', 'storefront-woocommerce-style' );
wp_style_add_data( 'storefront-woocommerce-variation-swatches-style', 'rtl', 'replace' );
}
/**
* Composite Products
*/
if ( $this->is_woocommerce_extension_activated( 'WC_Composite_Products' ) ) {
wp_enqueue_style( 'storefront-woocommerce-composite-products-style', get_template_directory_uri() . '/assets/sass/woocommerce/composite-products.css', 'storefront-woocommerce-style' );
wp_style_add_data( 'storefront-woocommerce-composite-products-style', 'rtl', 'replace' );
}
/**
* WooCommerce Photography
*/
if ( $this->is_woocommerce_extension_activated( 'WC_Photography' ) ) {
wp_enqueue_style( 'storefront-woocommerce-photography-style', get_template_directory_uri() . '/assets/sass/woocommerce/photography.css', 'storefront-woocommerce-style' );
wp_style_add_data( 'storefront-woocommerce-photography-style', 'rtl', 'replace' );
}
/**
* Product Reviews Pro
*/
if ( $this->is_woocommerce_extension_activated( 'WC_Product_Reviews_Pro' ) ) {
wp_enqueue_style( 'storefront-woocommerce-product-reviews-pro-style', get_template_directory_uri() . '/assets/sass/woocommerce/product-reviews-pro.css', 'storefront-woocommerce-style' );
wp_style_add_data( 'storefront-woocommerce-product-reviews-pro-style', 'rtl', 'replace' );
}
/**
* WooCommerce Smart Coupons
*/
if ( $this->is_woocommerce_extension_activated( 'WC_Smart_Coupons' ) ) {
wp_enqueue_style( 'storefront-woocommerce-smart-coupons-style', get_template_directory_uri() . '/assets/sass/woocommerce/smart-coupons.css', 'storefront-woocommerce-style' );
wp_style_add_data( 'storefront-woocommerce-smart-coupons-style', 'rtl', 'replace' );
}
/**
* WooCommerce Deposits
*/
if ( $this->is_woocommerce_extension_activated( 'WC_Deposits' ) ) {
wp_enqueue_style( 'storefront-woocommerce-deposits-style', get_template_directory_uri() . '/assets/sass/woocommerce/deposits.css', 'storefront-woocommerce-style' );
wp_style_add_data( 'storefront-woocommerce-deposits-style', 'rtl', 'replace' );
}
/**
* WooCommerce Product Bundles
*/
if ( $this->is_woocommerce_extension_activated( 'WC_Bundles' ) ) {
wp_enqueue_style( 'storefront-woocommerce-bundles-style', get_template_directory_uri() . '/assets/sass/woocommerce/bundles.css', 'storefront-woocommerce-style' );
wp_style_add_data( 'storefront-woocommerce-bundles-style', 'rtl', 'replace' );
}
/**
* WooCommerce Multiple Shipping Addresses
*/
if ( $this->is_woocommerce_extension_activated( 'WC_Ship_Multiple' ) ) {
wp_enqueue_style( 'storefront-woocommerce-sma-style', get_template_directory_uri() . '/assets/sass/woocommerce/ship-multiple-addresses.css', 'storefront-woocommerce-style' );
wp_style_add_data( 'storefront-woocommerce-sma-style', 'rtl', 'replace' );
}
}
if ( $this->is_woocommerce_extension_activated( 'WC_Product_Reviews_Pro' ) ) {
$woocommerce_style .= '
.woocommerce #reviews .product-rating .product-rating-details table td.rating-graph .bar,
.woocommerce-page #reviews .product-rating .product-rating-details table td.rating-graph .bar {
background-color: ' . $text_color . ' !important;
/**
* Add CSS in <head> for integration styles handled by the theme customizer
*
* @since 1.0
*/
public function add_integrations_customizer_css() {
$accent_color = get_theme_mod( 'storefront_accent_color', apply_filters( 'storefront_default_accent_color', '#FFA107' ) );
$header_text_color = get_theme_mod( 'storefront_header_text_color', apply_filters( 'storefront_default_header_text_color', '#9aa0a7' ) );
$header_background_color = get_theme_mod( 'storefront_header_background_color', apply_filters( 'storefront_default_header_background_color', '#2c2d33' ) );
$text_color = get_theme_mod( 'storefront_text_color', apply_filters( 'storefront_default_text_color', '#60646c' ) );
$button_background_color = get_theme_mod( 'storefront_button_background_color', apply_filters( 'storefront_default_button_background_color', '#60646c' ) );
$button_text_color = get_theme_mod( 'storefront_button_text_color', apply_filters( 'storefront_default_button_text_color', '#ffffff' ) );
$woocommerce_style = '';
if ( $this->is_woocommerce_extension_activated( 'WC_Bookings' ) ) {
$woocommerce_style .= '
#wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker td.bookable a,
#wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker td.bookable a:hover,
#wc-bookings-booking-form .block-picker li a:hover,
#wc-bookings-booking-form .block-picker li a.selected {
background-color: ' . $accent_color . ' !important;
}
#wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker td.ui-state-disabled .ui-state-default,
#wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker th {
color:' . $text_color . ';
}
#wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker-header {
background-color: ' . $header_background_color . ';
color: ' . $header_text_color . ';
}';
}
.woocommerce #reviews .contribution-actions .feedback,
.woocommerce-page #reviews .contribution-actions .feedback,
.star-rating-selector:not(:checked) label.checkbox {
color: ' . $text_color . ';
if ( $this->is_woocommerce_extension_activated( 'WC_Product_Reviews_Pro' ) ) {
$woocommerce_style .= '
.woocommerce #reviews .product-rating .product-rating-details table td.rating-graph .bar,
.woocommerce-page #reviews .product-rating .product-rating-details table td.rating-graph .bar {
background-color: ' . $text_color . ' !important;
}
.woocommerce #reviews .contribution-actions .feedback,
.woocommerce-page #reviews .contribution-actions .feedback,
.star-rating-selector:not(:checked) label.checkbox {
color: ' . $text_color . ';
}
.woocommerce #reviews #comments ol.commentlist li .contribution-actions a,
.woocommerce-page #reviews #comments ol.commentlist li .contribution-actions a,
.star-rating-selector:not(:checked) input:checked ~ label.checkbox,
.star-rating-selector:not(:checked) label.checkbox:hover ~ label.checkbox,
.star-rating-selector:not(:checked) label.checkbox:hover,
.woocommerce #reviews #comments ol.commentlist li .contribution-actions a,
.woocommerce-page #reviews #comments ol.commentlist li .contribution-actions a,
.woocommerce #reviews .form-contribution .attachment-type:not(:checked) label.checkbox:before,
.woocommerce-page #reviews .form-contribution .attachment-type:not(:checked) label.checkbox:before {
color: ' . $accent_color . ' !important;
}';
}
.woocommerce #reviews #comments ol.commentlist li .contribution-actions a,
.woocommerce-page #reviews #comments ol.commentlist li .contribution-actions a,
.star-rating-selector:not(:checked) input:checked ~ label.checkbox,
.star-rating-selector:not(:checked) label.checkbox:hover ~ label.checkbox,
.star-rating-selector:not(:checked) label.checkbox:hover,
.woocommerce #reviews #comments ol.commentlist li .contribution-actions a,
.woocommerce-page #reviews #comments ol.commentlist li .contribution-actions a,
.woocommerce #reviews .form-contribution .attachment-type:not(:checked) label.checkbox:before,
.woocommerce-page #reviews .form-contribution .attachment-type:not(:checked) label.checkbox:before {
color: ' . $accent_color . ' !important;
}';
if ( $this->is_woocommerce_extension_activated( 'WC_Smart_Coupons' ) ) {
$woocommerce_style .= '
.coupon-container {
background-color: ' . $button_background_color . ' !important;
}
.coupon-content {
border-color: ' . $button_text_color . ' !important;
color: ' . $button_text_color . ';
}
.sd-buttons-transparent.woocommerce .coupon-content,
.sd-buttons-transparent.woocommerce-page .coupon-content {
border-color: ' . $button_background_color . ' !important;
}';
}
wp_add_inline_style( 'storefront-style', $woocommerce_style );
}
if ( $this->is_woocommerce_extension_activated( 'WC_Smart_Coupons' ) ) {
$woocommerce_style .= '
.coupon-container {
background-color: ' . $button_background_color . ' !important;
}
.coupon-content {
border-color: ' . $button_text_color . ' !important;
color: ' . $button_text_color . ';
}
.sd-buttons-transparent.woocommerce .coupon-content,
.sd-buttons-transparent.woocommerce-page .coupon-content {
border-color: ' . $button_background_color . ' !important;
}';
}
wp_add_inline_style( 'storefront-style', $woocommerce_style );
}
}
endif;
return new Storefront_WooCommerce();
return new Storefront_WooCommerce();

View file

@ -5,13 +5,14 @@
* @package storefront
*/
/**
* Before Content
* Wraps all WooCommerce content in wrappers which match the theme markup
* @since 1.0.0
* @return void
*/
if ( ! function_exists( 'storefront_before_content' ) ) {
/**
* Before Content
* Wraps all WooCommerce content in wrappers which match the theme markup
*
* @since 1.0.0
* @return void
*/
function storefront_before_content() {
?>
<div id="primary" class="content-area">
@ -20,13 +21,14 @@ if ( ! function_exists( 'storefront_before_content' ) ) {
}
}
/**
* After Content
* Closes the wrapping divs
* @since 1.0.0
* @return void
*/
if ( ! function_exists( 'storefront_after_content' ) ) {
/**
* After Content
* Closes the wrapping divs
*
* @since 1.0.0
* @return void
*/
function storefront_after_content() {
?>
</main><!-- #main -->
@ -36,13 +38,14 @@ if ( ! function_exists( 'storefront_after_content' ) ) {
}
}
/**
* Cart Fragments
* Ensure cart contents update when products are added to the cart via AJAX
* @param array $fragments Fragments to refresh via AJAX
* @return array Fragments to refresh via AJAX
*/
if ( ! function_exists( 'storefront_cart_link_fragment' ) ) {
/**
* Cart Fragments
* Ensure cart contents update when products are added to the cart via AJAX
*
* @param array $fragments Fragments to refresh via AJAX.
* @return array Fragments to refresh via AJAX
*/
function storefront_cart_link_fragment( $fragments ) {
global $woocommerce;
@ -58,30 +61,31 @@ if ( ! function_exists( 'storefront_cart_link_fragment' ) ) {
}
}
/**
* Cart Link
* Displayed a link to the cart including the number of items present and the cart total
* @param array $settings Settings
* @return array Settings
* @since 1.0.0
*/
if ( ! function_exists( 'storefront_cart_link' ) ) {
/**
* Cart Link
* Displayed a link to the cart including the number of items present and the cart total
*
* @return void
* @since 1.0.0
*/
function storefront_cart_link() {
?>
<a class="cart-contents" href="<?php echo esc_url( WC()->cart->get_cart_url() ); ?>" title="<?php _e( 'View your shopping cart', 'storefront' ); ?>">
<a class="cart-contents" href="<?php echo esc_url( WC()->cart->get_cart_url() ); ?>" title="<?php esc_attr_e( 'View your shopping cart', 'storefront' ); ?>">
<span class="amount"><?php echo wp_kses_data( WC()->cart->get_cart_subtotal() ); ?></span> <span class="count"><?php echo wp_kses_data( sprintf( _n( '%d item', '%d items', WC()->cart->get_cart_contents_count(), 'storefront' ), WC()->cart->get_cart_contents_count() ) );?></span>
</a>
<?php
}
}
/**
* Display Product Search
* @since 1.0.0
* @uses is_woocommerce_activated() check if WooCommerce is activated
* @return void
*/
if ( ! function_exists( 'storefront_product_search' ) ) {
/**
* Display Product Search
*
* @since 1.0.0
* @uses is_woocommerce_activated() check if WooCommerce is activated
* @return void
*/
function storefront_product_search() {
if ( is_woocommerce_activated() ) { ?>
<div class="site-search">
@ -92,13 +96,14 @@ if ( ! function_exists( 'storefront_product_search' ) ) {
}
}
/**
* Display Header Cart
* @since 1.0.0
* @uses is_woocommerce_activated() check if WooCommerce is activated
* @return void
*/
if ( ! function_exists( 'storefront_header_cart' ) ) {
/**
* Display Header Cart
*
* @since 1.0.0
* @uses is_woocommerce_activated() check if WooCommerce is activated
* @return void
*/
function storefront_header_cart() {
if ( is_woocommerce_activated() ) {
if ( is_cart() ) {
@ -120,14 +125,15 @@ if ( ! function_exists( 'storefront_header_cart' ) ) {
}
}
/**
* Upsells
* Replace the default upsell function with our own which displays the correct number product columns
* @since 1.0.0
* @return void
* @uses woocommerce_upsell_display()
*/
if ( ! function_exists( 'storefront_upsell_display' ) ) {
/**
* Upsells
* Replace the default upsell function with our own which displays the correct number product columns
*
* @since 1.0.0
* @return void
* @uses woocommerce_upsell_display()
*/
function storefront_upsell_display() {
woocommerce_upsell_display( -1, 3 );
}
@ -135,6 +141,7 @@ if ( ! function_exists( 'storefront_upsell_display' ) ) {
/**
* Sorting wrapper
*
* @since 1.4.3
* @return void
*/
@ -144,6 +151,7 @@ function storefront_sorting_wrapper() {
/**
* Sorting wrapper close
*
* @since 1.4.3
* @return void
*/
@ -153,6 +161,7 @@ function storefront_sorting_wrapper_close() {
/**
* Storefront shop messages
*
* @since 1.4.4
* @uses do_shortcode
*/
@ -162,14 +171,15 @@ function storefront_shop_messages() {
}
}
/**
* Storefront WooCommerce Pagination
* WooCommerce disables the product pagination inside the woocommerce_product_subcategories() function
* but since Storefront adds pagination before that function is excuted we need a separate function to
* determine whether or not to display the pagination.
* @since 1.4.4
*/
if ( ! function_exists( 'storefront_woocommerce_pagination' ) ) {
/**
* Storefront WooCommerce Pagination
* WooCommerce disables the product pagination inside the woocommerce_product_subcategories() function
* but since Storefront adds pagination before that function is excuted we need a separate function to
* determine whether or not to display the pagination.
*
* @since 1.4.4
*/
function storefront_woocommerce_pagination() {
if ( woocommerce_products_will_display() ) {
woocommerce_pagination();
@ -177,18 +187,22 @@ if ( ! function_exists( 'storefront_woocommerce_pagination' ) ) {
}
}
/**
* Featured and On-Sale Products
* Check for featured products then on-sale products and use the appropiate shortcode.
* If neither exist, it can fallback to show recently added products.
* @since 1.5.1
* @uses is_woocommerce_activated()
* @uses wc_get_featured_product_ids()
* @uses wc_get_product_ids_on_sale()
* @uses storefront_do_shortcode()
* @return void
*/
if ( ! function_exists( 'storefront_promoted_products' ) ) {
/**
* Featured and On-Sale Products
* Check for featured products then on-sale products and use the appropiate shortcode.
* If neither exist, it can fallback to show recently added products.
*
* @since 1.5.1
* @param integer $per_page total products to display.
* @param integer $columns columns to arrange products in to.
* @param boolean $recent_fallback Should the function display recent products as a fallback when there are no featured or on-sale products?.
* @uses is_woocommerce_activated()
* @uses wc_get_featured_product_ids()
* @uses wc_get_product_ids_on_sale()
* @uses storefront_do_shortcode()
* @return void
*/
function storefront_promoted_products( $per_page = '2', $columns = '2', $recent_fallback = true ) {
if ( is_woocommerce_activated() ) {
@ -197,25 +211,25 @@ if ( ! function_exists( 'storefront_promoted_products' ) ) {
echo '<h2>' . esc_html__( 'Featured Products', 'storefront' ) . '</h2>';
echo storefront_do_shortcode( 'featured_products', array(
'per_page' => $per_page,
'columns' => $columns,
) );
'per_page' => $per_page,
'columns' => $columns,
) );
} elseif ( wc_get_product_ids_on_sale() ) {
echo '<h2>' . esc_html__( 'On Sale Now', 'storefront' ) . '</h2>';
echo storefront_do_shortcode( 'sale_products', array(
'per_page' => $per_page,
'columns' => $columns,
) );
'per_page' => $per_page,
'columns' => $columns,
) );
} elseif ( $recent_fallback ) {
echo '<h2>' . esc_html__( 'New In Store', 'storefront' ) . '</h2>';
echo storefront_do_shortcode( 'recent_products', array(
'per_page' => $per_page,
'columns' => $columns,
) );
'per_page' => $per_page,
'columns' => $columns,
) );
}
}
}
@ -223,21 +237,22 @@ if ( ! function_exists( 'storefront_promoted_products' ) ) {
/**
* Display a menu intended for use on handheld devices
*
* @since 2.0.0
*/
function storefront_handheld_footer_bar() {
$links = apply_filters( 'storefront_handheld_footer_bar_links', array(
'my-account' => array(
'priority' => 10,
'callback' => 'storefront_handheld_footer_bar_account_link'
'my-account' => array(
'priority' => 10,
'callback' => 'storefront_handheld_footer_bar_account_link',
),
'search' => array(
'priority' => 20,
'callback' => 'storefront_handheld_footer_bar_search'
'search' => array(
'priority' => 20,
'callback' => 'storefront_handheld_footer_bar_search',
),
'cart' => array(
'priority' => 30,
'callback' => 'storefront_handheld_footer_bar_cart_link'
'cart' => array(
'priority' => 30,
'callback' => 'storefront_handheld_footer_bar_cart_link',
),
) );
?>
@ -246,9 +261,9 @@ function storefront_handheld_footer_bar() {
<?php foreach ( $links as $key => $link ) : ?>
<li class="<?php echo esc_attr( $key ); ?>">
<?php
if ( $link['callback'] ) {
call_user_func( $link['callback'], $key, $link );
}
if ( $link['callback'] ) {
call_user_func( $link['callback'], $key, $link );
}
?>
</li>
<?php endforeach; ?>
@ -259,6 +274,7 @@ function storefront_handheld_footer_bar() {
/**
* The search callback function for the handheld footer bar
*
* @since 2.0.0
*/
function storefront_handheld_footer_bar_search() {
@ -268,11 +284,12 @@ function storefront_handheld_footer_bar_search() {
/**
* The cart callback function for the handheld footer bar
*
* @since 2.0.0
*/
function storefront_handheld_footer_bar_cart_link() {
?>
<a class="footer-cart-contents" href="<?php echo esc_url( WC()->cart->get_cart_url() ); ?>" title="<?php _e( 'View your shopping cart', 'storefront' ); ?>">
<a class="footer-cart-contents" href="<?php echo esc_url( WC()->cart->get_cart_url() ); ?>" title="<?php esc_attr_e( 'View your shopping cart', 'storefront' ); ?>">
<span class="count"><?php echo wp_kses_data( WC()->cart->get_cart_contents_count() );?></span>
</a>
<?php
@ -280,8 +297,9 @@ function storefront_handheld_footer_bar_cart_link() {
/**
* The account callback function for the handheld footer bar
*
* @since 2.0.0
*/
function storefront_handheld_footer_bar_account_link() {
echo '<a href="' . get_permalink( get_option('woocommerce_myaccount_page_id') ) . '">' . esc_attr__( 'My Account', 'storefront' ) . '</a>';
}
echo '<a href="' . esc_url( get_permalink( get_option( 'woocommerce_myaccount_page_id' ) ) ) . '">' . esc_attr__( 'My Account', 'storefront' ) . '</a>';
}

View file

@ -1,68 +1,71 @@
<?php
/**
* storefront WooCommerce hooks
* Storefront WooCommerce hooks
*
* @package storefront
*/
/**
* Styles
*
* @see storefront_woocommerce_scripts()
*/
/**
* Layout
*
* @see storefront_before_content()
* @see storefront_after_content()
* @see woocommerce_breadcrumb()
* @see storefront_shop_messages()
*/
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 10 );
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
add_action( 'woocommerce_before_main_content', 'storefront_before_content', 10 );
add_action( 'woocommerce_after_main_content', 'storefront_after_content', 10 );
add_action( 'storefront_content_top', 'storefront_shop_messages', 15 );
add_action( 'storefront_content_top', 'woocommerce_breadcrumb', 10 );
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 10 );
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
add_action( 'woocommerce_before_main_content', 'storefront_before_content', 10 );
add_action( 'woocommerce_after_main_content', 'storefront_after_content', 10 );
add_action( 'storefront_content_top', 'storefront_shop_messages', 15 );
add_action( 'storefront_content_top', 'woocommerce_breadcrumb', 10 );
add_action( 'woocommerce_after_shop_loop', 'storefront_sorting_wrapper', 9 );
add_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10 );
add_action( 'woocommerce_after_shop_loop', 'woocommerce_result_count', 20 );
add_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 30 );
add_action( 'woocommerce_after_shop_loop', 'storefront_sorting_wrapper_close', 31 );
add_action( 'woocommerce_after_shop_loop', 'storefront_sorting_wrapper', 9 );
add_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10 );
add_action( 'woocommerce_after_shop_loop', 'woocommerce_result_count', 20 );
add_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 30 );
add_action( 'woocommerce_after_shop_loop', 'storefront_sorting_wrapper_close', 31 );
add_action( 'woocommerce_before_shop_loop', 'storefront_sorting_wrapper', 9 );
add_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10 );
add_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
add_action( 'woocommerce_before_shop_loop', 'storefront_woocommerce_pagination', 30 );
add_action( 'woocommerce_before_shop_loop', 'storefront_sorting_wrapper_close', 31 );
add_action( 'woocommerce_before_shop_loop', 'storefront_sorting_wrapper', 9 );
add_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10 );
add_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
add_action( 'woocommerce_before_shop_loop', 'storefront_woocommerce_pagination', 30 );
add_action( 'woocommerce_before_shop_loop', 'storefront_sorting_wrapper_close', 31 );
add_action( 'storefront_footer', 'storefront_handheld_footer_bar', 999 );
add_action( 'storefront_footer', 'storefront_handheld_footer_bar', 999 );
/**
* Products
*
* @see storefront_upsell_display()
*/
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
add_action( 'woocommerce_after_single_product_summary', 'storefront_upsell_display', 15 );
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 );
add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 6 );
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
add_action( 'woocommerce_after_single_product_summary', 'storefront_upsell_display', 15 );
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 );
add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 6 );
/**
* Header
*
* @see storefront_product_search()
* @see storefront_header_cart()
*/
add_action( 'storefront_header', 'storefront_product_search', 40 );
add_action( 'storefront_header', 'storefront_header_cart', 60 );
add_action( 'storefront_header', 'storefront_product_search', 40 );
add_action( 'storefront_header', 'storefront_header_cart', 60 );
if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '2.3', '>=' ) ) {
add_filter( 'woocommerce_add_to_cart_fragments', 'storefront_cart_link_fragment' );
} else {
add_filter( 'add_to_cart_fragments', 'storefront_cart_link_fragment' );
}
}

View file

@ -30,5 +30,5 @@ get_header(); ?>
</div><!-- #primary -->
<?php
do_action( 'storefront_sidebar' );
get_footer();
do_action( 'storefront_sidebar' );
get_footer();

View file

@ -12,7 +12,8 @@ do_action( 'storefront_loop_before' );
while ( have_posts() ) : the_post();
/* Include the Post-Format-specific template for the content.
/**
* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
@ -21,6 +22,8 @@ while ( have_posts() ) : the_post();
endwhile;
/**
* Functions hooked in to storefront_paging_nav action
*
* @hooked storefront_paging_nav - 10
*/
do_action( 'storefront_loop_after' );
do_action( 'storefront_loop_after' );

View file

@ -22,15 +22,17 @@ get_header(); ?>
get_template_part( 'content', 'page' );
/**
* Functions hooked in to storefront_page_after action
*
* @hooked storefront_display_comments - 10
*/
do_action( 'storefront_page_after' );
endwhile; // end of the loop. ?>
endwhile; // End of the loop. ?>
</main><!-- #main -->
</div><!-- #primary -->
<?php
do_action( 'storefront_sidebar' );
get_footer();
get_footer();

View file

@ -13,7 +13,7 @@ get_header(); ?>
<?php if ( have_posts() ) : ?>
<header class="page-header">
<h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'storefront' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
<h1 class="page-title"><?php printf( esc_attr__( 'Search Results for: %s', 'storefront' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
</header><!-- .page-header -->
<?php get_template_part( 'loop' );
@ -29,4 +29,4 @@ get_header(); ?>
<?php
do_action( 'storefront_sidebar' );
get_footer();
get_footer();

View file

@ -12,4 +12,4 @@ if ( ! is_active_sidebar( 'sidebar-1' ) ) {
<div id="secondary" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'sidebar-1' ); ?>
</div><!-- #secondary -->
</div><!-- #secondary -->

View file

@ -17,16 +17,18 @@ get_header(); ?>
get_template_part( 'content', 'single' );
/**
* @hooked storefront_post_nav - 10
* Functions hooked in to storefront_single_post_after action
*
* @hooked storefront_post_nav - 10
* @hooked storefront_display_comments - 20
*/
do_action( 'storefront_single_post_after' );
endwhile; // end of the loop. ?>
endwhile; // End of the loop. ?>
</main><!-- #main -->
</div><!-- #primary -->
<?php
do_action( 'storefront_sidebar' );
get_footer();
get_footer();

View file

@ -19,14 +19,16 @@ get_header(); ?>
get_template_part( 'content', 'page' );
/**
* Functions hooked in to storefront_page_after action
*
* @hooked storefront_display_comments - 10
*/
do_action( 'storefront_page_after' );
endwhile; // end of the loop. ?>
endwhile; // End of the loop. ?>
</main><!-- #main -->
</div><!-- #primary -->
<?php
get_footer();
get_footer();

View file

@ -19,16 +19,18 @@ get_header(); ?>
<?php
/**
* @hooked storefront_homepage_content - 10
* Functions hooked in to homepage action
*
* @hooked storefront_homepage_content - 10
* @hooked storefront_product_categories - 20
* @hooked storefront_recent_products - 30
* @hooked storefront_featured_products - 40
* @hooked storefront_popular_products - 50
* @hooked storefront_on_sale_products - 60
* @hooked storefront_recent_products - 30
* @hooked storefront_featured_products - 40
* @hooked storefront_popular_products - 50
* @hooked storefront_on_sale_products - 60
*/
do_action( 'homepage' ); ?>
</main><!-- #main -->
</div><!-- #primary -->
<?php
get_footer();
get_footer();