Version Description
- Added php codesniffer via composer package for WordPress code standards.
- Fixed spacing and syntax issues for WordPress code standards.
- Renamed Gencwooc_Featured_Products file to adhere to WordPress code standards.
Download this release
Release Info
| Developer | nathanrice |
| Plugin | |
| Version | 1.1.0 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.0 to 1.1.0
- .circleci/config.yml +28 -0
- admin/notices.php +20 -3
- admin/views/html-notice-needs-genesis.php +10 -3
- admin/views/html-notice-needs-woocommerce.php +10 -3
- genesis-connect-woocommerce.php +53 -43
- languages/genesis-connect-woocommerce.pot +202 -0
- lib/breadcrumb.php +94 -107
- lib/posts-per-page.php +37 -32
- lib/template-loader.php +108 -102
- lib/widgets.php +27 -0
- readme.txt +9 -4
- sp-plugins-integration/genesis-simple-menus.php +22 -26
- sp-plugins-integration/genesis-simple-sidebars.php +37 -59
- templates/archive-product.php +23 -28
- templates/single-product.php +30 -38
- templates/taxonomy.php +26 -30
- widgets/class-gencwooc-featured-products.php +519 -0
- widgets/woocommerce-featured-widgets.php +0 -506
.circleci/config.yml
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: 2
|
| 2 |
+
|
| 3 |
+
jobs:
|
| 4 |
+
test:
|
| 5 |
+
docker:
|
| 6 |
+
- image: circleci/php:7.3-stretch
|
| 7 |
+
steps:
|
| 8 |
+
- checkout
|
| 9 |
+
- restore_cache:
|
| 10 |
+
keys:
|
| 11 |
+
- v1-dependencies-{{ checksum "composer.json" }}
|
| 12 |
+
- v1-dependencies-
|
| 13 |
+
- run:
|
| 14 |
+
name: "Install composer dependencies."
|
| 15 |
+
command: composer install --no-interaction --prefer-dist --no-suggest
|
| 16 |
+
- save_cache:
|
| 17 |
+
key: composer-v1-{{ checksum "composer.lock" }}
|
| 18 |
+
paths:
|
| 19 |
+
- vendor
|
| 20 |
+
- run:
|
| 21 |
+
name: "Run PHPCS"
|
| 22 |
+
command: composer sniff
|
| 23 |
+
|
| 24 |
+
workflows:
|
| 25 |
+
version: 2
|
| 26 |
+
check-wp-cs:
|
| 27 |
+
jobs:
|
| 28 |
+
- test
|
admin/notices.php
CHANGED
|
@@ -2,15 +2,32 @@
|
|
| 2 |
/**
|
| 3 |
* Callbacks for `admin_notices` action to load HTML notices.
|
| 4 |
*
|
| 5 |
-
* @package
|
| 6 |
-
* @
|
| 7 |
*/
|
| 8 |
-
defined( 'ABSPATH' ) || exit;
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
function gencwooc_woocommerce_notice() {
|
| 11 |
include GCW_ADMIN_DIR . '/views/html-notice-needs-woocommerce.php';
|
| 12 |
}
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
function gencwooc_genesis_notice() {
|
| 15 |
include GCW_ADMIN_DIR . '/views/html-notice-needs-genesis.php';
|
| 16 |
}
|
| 2 |
/**
|
| 3 |
* Callbacks for `admin_notices` action to load HTML notices.
|
| 4 |
*
|
| 5 |
+
* @package Genesis_Connect_WooCommerce
|
| 6 |
+
* @since 1.0
|
| 7 |
*/
|
|
|
|
| 8 |
|
| 9 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
| 10 |
+
exit;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
/**
|
| 14 |
+
* Display notice message if WooCommerce is not active.
|
| 15 |
+
*
|
| 16 |
+
* Callback for WordPress 'admin_notices' action.
|
| 17 |
+
*
|
| 18 |
+
* @since 1.0
|
| 19 |
+
*/
|
| 20 |
function gencwooc_woocommerce_notice() {
|
| 21 |
include GCW_ADMIN_DIR . '/views/html-notice-needs-woocommerce.php';
|
| 22 |
}
|
| 23 |
|
| 24 |
+
/**
|
| 25 |
+
* Display notice message if Genesis is not active.
|
| 26 |
+
*
|
| 27 |
+
* Callback for WordPress 'admin_notices' action.
|
| 28 |
+
*
|
| 29 |
+
* @since 1.0
|
| 30 |
+
*/
|
| 31 |
function gencwooc_genesis_notice() {
|
| 32 |
include GCW_ADMIN_DIR . '/views/html-notice-needs-genesis.php';
|
| 33 |
}
|
admin/views/html-notice-needs-genesis.php
CHANGED
|
@@ -1,11 +1,18 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
-
*
|
|
|
|
|
|
|
|
|
|
| 4 |
*/
|
| 5 |
|
| 6 |
-
defined( 'ABSPATH' )
|
|
|
|
|
|
|
| 7 |
|
| 8 |
?>
|
| 9 |
<div id="message" class="error notice">
|
| 10 |
-
<p
|
|
|
|
|
|
|
| 11 |
</div>
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
+
* View for WordPress `admin_notice` if Genesis is not active.
|
| 4 |
+
*
|
| 5 |
+
* @package Genesis_Connect_WooCommerce
|
| 6 |
+
* @since 1.0.0
|
| 7 |
*/
|
| 8 |
|
| 9 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
| 10 |
+
exit;
|
| 11 |
+
}
|
| 12 |
|
| 13 |
?>
|
| 14 |
<div id="message" class="error notice">
|
| 15 |
+
<p>
|
| 16 |
+
<?php esc_html_e( 'Genesis Connect for WooCommerce requires a Genesis child theme. Please activate a Genesis theme or disable Genesis Connect.', 'gencwooc' ); ?>
|
| 17 |
+
</p>
|
| 18 |
</div>
|
admin/views/html-notice-needs-woocommerce.php
CHANGED
|
@@ -1,11 +1,18 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
-
*
|
|
|
|
|
|
|
|
|
|
| 4 |
*/
|
| 5 |
|
| 6 |
-
defined( 'ABSPATH' )
|
|
|
|
|
|
|
| 7 |
|
| 8 |
?>
|
| 9 |
<div id="message" class="error notice">
|
| 10 |
-
<p
|
|
|
|
|
|
|
| 11 |
</div>
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
+
* View for WordPress `admin_notice` if WooCommerce is not active.
|
| 4 |
+
*
|
| 5 |
+
* @package Genesis_Connect_WooCommerce
|
| 6 |
+
* @since 1.0.0
|
| 7 |
*/
|
| 8 |
|
| 9 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
| 10 |
+
exit;
|
| 11 |
+
}
|
| 12 |
|
| 13 |
?>
|
| 14 |
<div id="message" class="error notice">
|
| 15 |
+
<p>
|
| 16 |
+
<?php esc_html_e( 'Genesis Connect for WooCommerce requires WooCommerce. Please activate WooCommerce or disable Genesis Connect.', 'gencwooc' ); ?>
|
| 17 |
+
</p>
|
| 18 |
</div>
|
genesis-connect-woocommerce.php
CHANGED
|
@@ -1,48 +1,53 @@
|
|
| 1 |
<?php
|
| 2 |
-
|
| 3 |
-
Plugin Name: Genesis Connect for WooCommerce
|
| 4 |
-
Plugin URI: https://wordpress.org/plugins/genesis-connect-woocommerce/
|
| 5 |
-
Version: 1.0
|
| 6 |
-
Author: StudioPress
|
| 7 |
-
Author URI: https://www.studiopress.com/
|
| 8 |
-
Description: Allows you to seamlessly integrate WooCommerce with the Genesis Framework and Genesis child themes.
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
| 19 |
define( 'GCW_TEMPLATE_DIR', dirname( __FILE__ ) . '/templates' );
|
| 20 |
-
define( 'GCW_LIB_DIR', dirname( __FILE__ ) . '/lib');
|
| 21 |
-
define( 'GCW_ADMIN_DIR', dirname( __FILE__ ) . '/admin');
|
| 22 |
define( 'GCW_WIDGETS_DIR', dirname( __FILE__ ) . '/widgets' );
|
| 23 |
define( 'GCW_SP_DIR', dirname( __FILE__ ) . '/sp-plugins-integration' );
|
| 24 |
|
| 25 |
add_action( 'after_setup_theme', 'gencwooc_setup' );
|
| 26 |
/**
|
| 27 |
-
* Setup
|
| 28 |
*
|
| 29 |
-
* Checks whether WooCommerce is active
|
| 30 |
-
*
|
| 31 |
-
*
|
| 32 |
*
|
| 33 |
* @since 0.9.0
|
| 34 |
*/
|
| 35 |
function gencwooc_setup() {
|
| 36 |
|
| 37 |
require_once GCW_ADMIN_DIR . '/notices.php';
|
|
|
|
| 38 |
$ready = true;
|
| 39 |
|
| 40 |
if ( ! function_exists( 'is_plugin_active' ) ) {
|
| 41 |
-
require_once
|
| 42 |
}
|
| 43 |
|
| 44 |
if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
|
| 45 |
add_action( 'admin_notices', 'gencwooc_woocommerce_notice' );
|
|
|
|
| 46 |
$ready = false;
|
| 47 |
}
|
| 48 |
|
|
@@ -60,42 +65,47 @@ function gencwooc_setup() {
|
|
| 60 |
|
| 61 |
global $woocommerce;
|
| 62 |
|
| 63 |
-
|
| 64 |
-
require_once
|
| 65 |
-
|
| 66 |
-
// Load posts per page option
|
| 67 |
-
require_once( GCW_LIB_DIR . '/posts-per-page.php' );
|
| 68 |
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
|
| 73 |
-
/** Ensure WooCommerce 2.0+ compatibility */
|
| 74 |
add_theme_support( 'woocommerce' );
|
| 75 |
|
| 76 |
-
/** Add Genesis Layout, Genesis Scripts and SEO options to Product edit screen */
|
| 77 |
add_post_type_support( 'product', array( 'genesis-layouts', 'genesis-scripts', 'genesis-seo' ) );
|
| 78 |
-
|
| 79 |
-
/** Add Studiopress plugins support */
|
| 80 |
add_post_type_support( 'product', array( 'genesis-simple-sidebars', 'genesis-simple-menus' ) );
|
| 81 |
|
| 82 |
-
/** Add Widgets */
|
| 83 |
if ( current_theme_supports( 'gencwooc-featured-products-widget' ) ) {
|
| 84 |
-
require_once
|
| 85 |
}
|
| 86 |
|
| 87 |
-
/** Take control of shop template loading */
|
| 88 |
remove_filter( 'template_include', array( &$woocommerce, 'template_loader' ) );
|
| 89 |
add_filter( 'template_include', 'gencwooc_template_loader', 20 );
|
| 90 |
|
| 91 |
-
/** Integration - Genesis Simple Sidebars */
|
| 92 |
if ( is_plugin_active( 'genesis-simple-sidebars/plugin.php' ) ) {
|
| 93 |
-
require_once
|
| 94 |
}
|
| 95 |
|
| 96 |
-
/** Integration - Genesis Simple Menus */
|
| 97 |
if ( is_plugin_active( 'genesis-simple-menus/simple-menu.php' ) ) {
|
| 98 |
-
require_once
|
| 99 |
}
|
| 100 |
|
| 101 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Plugin Name: Genesis Connect for WooCommerce
|
| 4 |
+
* Plugin URI: https://wordpress.org/plugins/genesis-connect-woocommerce/
|
| 5 |
+
* Version: 1.1.0
|
| 6 |
+
* Author: StudioPress
|
| 7 |
+
* Author URI: https://www.studiopress.com/
|
| 8 |
+
* Description: Allows you to seamlessly integrate WooCommerce with the Genesis Framework and Genesis child themes.
|
| 9 |
+
* Text Domain: gencwooc
|
| 10 |
+
* License: GNU General Public License v2.0 (or later)
|
| 11 |
+
* License URI: http://www.opensource.org/licenses/gpl-license.php
|
| 12 |
+
*
|
| 13 |
+
* WC requires at least: 3.3.0
|
| 14 |
+
* WC tested up to: 3.6.4
|
| 15 |
+
*
|
| 16 |
+
* @package Genesis_Connect_WooCommerce
|
| 17 |
+
*
|
| 18 |
+
* Special thanks to Ade Walker (http://www.studiograsshopper.ch/) for his contributions to this plugin.
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
define( 'GCW_DIR', dirname( __FILE__ ) );
|
| 22 |
define( 'GCW_TEMPLATE_DIR', dirname( __FILE__ ) . '/templates' );
|
| 23 |
+
define( 'GCW_LIB_DIR', dirname( __FILE__ ) . '/lib' );
|
| 24 |
+
define( 'GCW_ADMIN_DIR', dirname( __FILE__ ) . '/admin' );
|
| 25 |
define( 'GCW_WIDGETS_DIR', dirname( __FILE__ ) . '/widgets' );
|
| 26 |
define( 'GCW_SP_DIR', dirname( __FILE__ ) . '/sp-plugins-integration' );
|
| 27 |
|
| 28 |
add_action( 'after_setup_theme', 'gencwooc_setup' );
|
| 29 |
/**
|
| 30 |
+
* Setup Genesis Connect for WooCommerce.
|
| 31 |
*
|
| 32 |
+
* Checks whether WooCommerce is active.
|
| 33 |
+
* Once past these checks, loads the necessary files, actions and filters for the plugin
|
| 34 |
+
* to do its thing.
|
| 35 |
*
|
| 36 |
* @since 0.9.0
|
| 37 |
*/
|
| 38 |
function gencwooc_setup() {
|
| 39 |
|
| 40 |
require_once GCW_ADMIN_DIR . '/notices.php';
|
| 41 |
+
|
| 42 |
$ready = true;
|
| 43 |
|
| 44 |
if ( ! function_exists( 'is_plugin_active' ) ) {
|
| 45 |
+
require_once ABSPATH . '/wp-admin/includes/plugin.php';
|
| 46 |
}
|
| 47 |
|
| 48 |
if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
|
| 49 |
add_action( 'admin_notices', 'gencwooc_woocommerce_notice' );
|
| 50 |
+
|
| 51 |
$ready = false;
|
| 52 |
}
|
| 53 |
|
| 65 |
|
| 66 |
global $woocommerce;
|
| 67 |
|
| 68 |
+
require_once GCW_LIB_DIR . '/template-loader.php';
|
| 69 |
+
require_once GCW_LIB_DIR . '/posts-per-page.php';
|
| 70 |
+
require_once GCW_LIB_DIR . '/widgets.php';
|
|
|
|
|
|
|
| 71 |
|
| 72 |
+
if ( ! current_theme_supports( 'gencwooc-woo-breadcrumbs' ) ) {
|
| 73 |
+
require_once GCW_LIB_DIR . '/breadcrumb.php';
|
| 74 |
+
}
|
| 75 |
|
|
|
|
| 76 |
add_theme_support( 'woocommerce' );
|
| 77 |
|
|
|
|
| 78 |
add_post_type_support( 'product', array( 'genesis-layouts', 'genesis-scripts', 'genesis-seo' ) );
|
|
|
|
|
|
|
| 79 |
add_post_type_support( 'product', array( 'genesis-simple-sidebars', 'genesis-simple-menus' ) );
|
| 80 |
|
|
|
|
| 81 |
if ( current_theme_supports( 'gencwooc-featured-products-widget' ) ) {
|
| 82 |
+
require_once GCW_WIDGETS_DIR . '/class-gencwooc-featured-products.php';
|
| 83 |
}
|
| 84 |
|
|
|
|
| 85 |
remove_filter( 'template_include', array( &$woocommerce, 'template_loader' ) );
|
| 86 |
add_filter( 'template_include', 'gencwooc_template_loader', 20 );
|
| 87 |
|
|
|
|
| 88 |
if ( is_plugin_active( 'genesis-simple-sidebars/plugin.php' ) ) {
|
| 89 |
+
require_once GCW_SP_DIR . '/genesis-simple-sidebars.php';
|
| 90 |
}
|
| 91 |
|
|
|
|
| 92 |
if ( is_plugin_active( 'genesis-simple-menus/simple-menu.php' ) ) {
|
| 93 |
+
require_once GCW_SP_DIR . '/genesis-simple-menus.php';
|
| 94 |
}
|
| 95 |
|
| 96 |
}
|
| 97 |
+
|
| 98 |
+
add_action( 'plugins_loaded', 'gencwooc_load_plugin_textdomain' );
|
| 99 |
+
/**
|
| 100 |
+
* Load plugin translated strings.
|
| 101 |
+
*
|
| 102 |
+
* Callback for WordPress 'plugins_loaded' action.
|
| 103 |
+
*
|
| 104 |
+
* @uses load_plugin_textdomain()
|
| 105 |
+
* @link https://codex.wordpress.org/Function_Reference/load_plugin_textdomain
|
| 106 |
+
*
|
| 107 |
+
* @since 1.1.0
|
| 108 |
+
*/
|
| 109 |
+
function gencwooc_load_plugin_textdomain() {
|
| 110 |
+
load_plugin_textdomain( 'gencwooc', false, GCW_DIR . '/languages' );
|
| 111 |
+
}
|
languages/genesis-connect-woocommerce.pot
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (C) 2019 StudioPress
|
| 2 |
+
# This file is distributed under the same license as the Genesis Connect for WooCommerce plugin.
|
| 3 |
+
msgid ""
|
| 4 |
+
msgstr ""
|
| 5 |
+
"Project-Id-Version: Genesis Connect for WooCommerce 1.1.0\n"
|
| 6 |
+
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/genesis-connect-woocommerce\n"
|
| 7 |
+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
| 8 |
+
"Language-Team: LANGUAGE <LL@li.org>\n"
|
| 9 |
+
"MIME-Version: 1.0\n"
|
| 10 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
| 11 |
+
"Content-Transfer-Encoding: 8bit\n"
|
| 12 |
+
"POT-Creation-Date: 2019-07-10T15:02:37+00:00\n"
|
| 13 |
+
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
| 14 |
+
"X-Generator: WP-CLI 2.1.0\n"
|
| 15 |
+
"X-Domain: gencwooc\n"
|
| 16 |
+
|
| 17 |
+
#. Plugin Name of the plugin
|
| 18 |
+
msgid "Genesis Connect for WooCommerce"
|
| 19 |
+
msgstr ""
|
| 20 |
+
|
| 21 |
+
#. Plugin URI of the plugin
|
| 22 |
+
msgid "https://wordpress.org/plugins/genesis-connect-woocommerce/"
|
| 23 |
+
msgstr ""
|
| 24 |
+
|
| 25 |
+
#. Description of the plugin
|
| 26 |
+
msgid "Allows you to seamlessly integrate WooCommerce with the Genesis Framework and Genesis child themes."
|
| 27 |
+
msgstr ""
|
| 28 |
+
|
| 29 |
+
#. Author of the plugin
|
| 30 |
+
msgid "StudioPress"
|
| 31 |
+
msgstr ""
|
| 32 |
+
|
| 33 |
+
#. Author URI of the plugin
|
| 34 |
+
msgid "https://www.studiopress.com/"
|
| 35 |
+
msgstr ""
|
| 36 |
+
|
| 37 |
+
#: admin/views/html-notice-needs-genesis.php:16
|
| 38 |
+
msgid "Genesis Connect for WooCommerce requires a Genesis child theme. Please activate a Genesis theme or disable Genesis Connect."
|
| 39 |
+
msgstr ""
|
| 40 |
+
|
| 41 |
+
#: admin/views/html-notice-needs-woocommerce.php:16
|
| 42 |
+
msgid "Genesis Connect for WooCommerce requires WooCommerce. Please activate WooCommerce or disable Genesis Connect."
|
| 43 |
+
msgstr ""
|
| 44 |
+
|
| 45 |
+
#: lib/template-loader.php:178
|
| 46 |
+
msgid "Search Results:"
|
| 47 |
+
msgstr ""
|
| 48 |
+
|
| 49 |
+
#: lib/template-loader.php:181
|
| 50 |
+
msgid "Page"
|
| 51 |
+
msgstr ""
|
| 52 |
+
|
| 53 |
+
#: lib/breadcrumb.php:67
|
| 54 |
+
msgid "Search results for “"
|
| 55 |
+
msgstr ""
|
| 56 |
+
|
| 57 |
+
#: lib/breadcrumb.php:114
|
| 58 |
+
msgid "Products tagged “"
|
| 59 |
+
msgstr ""
|
| 60 |
+
|
| 61 |
+
#: lib/breadcrumb.php:114
|
| 62 |
+
msgctxt "endquote"
|
| 63 |
+
msgid "”"
|
| 64 |
+
msgstr ""
|
| 65 |
+
|
| 66 |
+
#: lib/posts-per-page.php:25
|
| 67 |
+
#: lib/posts-per-page.php:62
|
| 68 |
+
msgid "Genesis Connect Addons"
|
| 69 |
+
msgstr ""
|
| 70 |
+
|
| 71 |
+
#: lib/posts-per-page.php:68
|
| 72 |
+
msgid "Products Per Page"
|
| 73 |
+
msgstr ""
|
| 74 |
+
|
| 75 |
+
#: lib/posts-per-page.php:70
|
| 76 |
+
msgid "This setting determines how many products show up on archive pages and may be overridden by filters used in themes and plugins."
|
| 77 |
+
msgstr ""
|
| 78 |
+
|
| 79 |
+
#: widgets/class-gencwooc-featured-products.php:54
|
| 80 |
+
msgid "More Products from this Category"
|
| 81 |
+
msgstr ""
|
| 82 |
+
|
| 83 |
+
#: widgets/class-gencwooc-featured-products.php:59
|
| 84 |
+
msgid "Genesis - Featured Products"
|
| 85 |
+
msgstr ""
|
| 86 |
+
|
| 87 |
+
#: widgets/class-gencwooc-featured-products.php:60
|
| 88 |
+
msgid "Displays featured products with thumbnails"
|
| 89 |
+
msgstr ""
|
| 90 |
+
|
| 91 |
+
#: widgets/class-gencwooc-featured-products.php:66
|
| 92 |
+
msgid "Title"
|
| 93 |
+
msgstr ""
|
| 94 |
+
|
| 95 |
+
#: widgets/class-gencwooc-featured-products.php:71
|
| 96 |
+
msgid "Product Category"
|
| 97 |
+
msgstr ""
|
| 98 |
+
|
| 99 |
+
#: widgets/class-gencwooc-featured-products.php:80
|
| 100 |
+
msgid "Products to Show"
|
| 101 |
+
msgstr ""
|
| 102 |
+
|
| 103 |
+
#: widgets/class-gencwooc-featured-products.php:88
|
| 104 |
+
msgid "Product Offset"
|
| 105 |
+
msgstr ""
|
| 106 |
+
|
| 107 |
+
#: widgets/class-gencwooc-featured-products.php:93
|
| 108 |
+
msgid "Show"
|
| 109 |
+
msgstr ""
|
| 110 |
+
|
| 111 |
+
#: widgets/class-gencwooc-featured-products.php:95
|
| 112 |
+
msgid "All products"
|
| 113 |
+
msgstr ""
|
| 114 |
+
|
| 115 |
+
#: widgets/class-gencwooc-featured-products.php:96
|
| 116 |
+
msgid "Featured products"
|
| 117 |
+
msgstr ""
|
| 118 |
+
|
| 119 |
+
#: widgets/class-gencwooc-featured-products.php:97
|
| 120 |
+
msgid "On-sale products"
|
| 121 |
+
msgstr ""
|
| 122 |
+
|
| 123 |
+
#: widgets/class-gencwooc-featured-products.php:103
|
| 124 |
+
msgid "Order by"
|
| 125 |
+
msgstr ""
|
| 126 |
+
|
| 127 |
+
#: widgets/class-gencwooc-featured-products.php:105
|
| 128 |
+
msgid "Date"
|
| 129 |
+
msgstr ""
|
| 130 |
+
|
| 131 |
+
#: widgets/class-gencwooc-featured-products.php:106
|
| 132 |
+
msgid "Price"
|
| 133 |
+
msgstr ""
|
| 134 |
+
|
| 135 |
+
#: widgets/class-gencwooc-featured-products.php:107
|
| 136 |
+
msgid "Random"
|
| 137 |
+
msgstr ""
|
| 138 |
+
|
| 139 |
+
#: widgets/class-gencwooc-featured-products.php:108
|
| 140 |
+
msgid "Sales"
|
| 141 |
+
msgstr ""
|
| 142 |
+
|
| 143 |
+
#: widgets/class-gencwooc-featured-products.php:114
|
| 144 |
+
msgctxt "Sorting Order"
|
| 145 |
+
msgid "Order"
|
| 146 |
+
msgstr ""
|
| 147 |
+
|
| 148 |
+
#: widgets/class-gencwooc-featured-products.php:116
|
| 149 |
+
msgid "ASC"
|
| 150 |
+
msgstr ""
|
| 151 |
+
|
| 152 |
+
#: widgets/class-gencwooc-featured-products.php:117
|
| 153 |
+
msgid "DESC"
|
| 154 |
+
msgstr ""
|
| 155 |
+
|
| 156 |
+
#: widgets/class-gencwooc-featured-products.php:123
|
| 157 |
+
msgid "Hide Free Products"
|
| 158 |
+
msgstr ""
|
| 159 |
+
|
| 160 |
+
#: widgets/class-gencwooc-featured-products.php:128
|
| 161 |
+
msgid "Show Hidden Products"
|
| 162 |
+
msgstr ""
|
| 163 |
+
|
| 164 |
+
#: widgets/class-gencwooc-featured-products.php:133
|
| 165 |
+
msgid "Show Featured Image?"
|
| 166 |
+
msgstr ""
|
| 167 |
+
|
| 168 |
+
#: widgets/class-gencwooc-featured-products.php:138
|
| 169 |
+
msgid "Image Size"
|
| 170 |
+
msgstr ""
|
| 171 |
+
|
| 172 |
+
#: widgets/class-gencwooc-featured-products.php:144
|
| 173 |
+
msgid "Link Product Image?"
|
| 174 |
+
msgstr ""
|
| 175 |
+
|
| 176 |
+
#: widgets/class-gencwooc-featured-products.php:149
|
| 177 |
+
msgid "Show Title?"
|
| 178 |
+
msgstr ""
|
| 179 |
+
|
| 180 |
+
#: widgets/class-gencwooc-featured-products.php:154
|
| 181 |
+
msgid "Show Add to Cart Button?"
|
| 182 |
+
msgstr ""
|
| 183 |
+
|
| 184 |
+
#: widgets/class-gencwooc-featured-products.php:159
|
| 185 |
+
msgid "Show Price?"
|
| 186 |
+
msgstr ""
|
| 187 |
+
|
| 188 |
+
#: widgets/class-gencwooc-featured-products.php:164
|
| 189 |
+
msgid "Show Category Archive Link?"
|
| 190 |
+
msgstr ""
|
| 191 |
+
|
| 192 |
+
#: widgets/class-gencwooc-featured-products.php:169
|
| 193 |
+
msgid "Link Text:"
|
| 194 |
+
msgstr ""
|
| 195 |
+
|
| 196 |
+
#: widgets/class-gencwooc-featured-products.php:197
|
| 197 |
+
msgid "All Categories"
|
| 198 |
+
msgstr ""
|
| 199 |
+
|
| 200 |
+
#: widgets/class-gencwooc-featured-products.php:408
|
| 201 |
+
msgid "(no title)"
|
| 202 |
+
msgstr ""
|
lib/breadcrumb.php
CHANGED
|
@@ -1,28 +1,25 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
-
* This file contains functions related modifying Genesis Breadcrumb output
|
| 4 |
-
*
|
| 5 |
-
* @package genesis_connect_woocommerce
|
| 6 |
-
* @version 0.9.8
|
| 7 |
*
|
|
|
|
| 8 |
* @since 0.9.0
|
| 9 |
*
|
| 10 |
*
|
| 11 |
-
* By default, the Genesis Breadcrumb class does not handle Shop pages and taxonomy
|
| 12 |
-
*
|
| 13 |
-
*
|
| 14 |
-
* trail mimics that of WooC's breadcrumbs, for:
|
| 15 |
* - Shop page (archive page)
|
| 16 |
* - Single product
|
| 17 |
* - Taxonomy archive
|
| 18 |
*
|
| 19 |
-
* Users who prefer to use
|
| 20 |
* theme's functions.php:
|
| 21 |
* - add_theme_support( 'gencwooc-woo-breadcrumbs' );
|
| 22 |
* And this to the relevant templates:
|
| 23 |
* - remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' );
|
| 24 |
*
|
| 25 |
-
* @see readme.txt
|
| 26 |
*
|
| 27 |
* As this modification code uses existing Genesis Breadcrumb filters there is a risk that
|
| 28 |
* it will cause compatibility issues with any existing uses of Genesis Breadcrumb filters.
|
|
@@ -31,24 +28,17 @@
|
|
| 31 |
*
|
| 32 |
* @see genesis/lib/classes/breadcrumb.php v1.8
|
| 33 |
* @see woocommerce/templates/shop/breadcrumb.php v1.4.4
|
| 34 |
-
*
|
| 35 |
-
* @TODO Replace with subclass of Genesis_Breadcrumb?
|
| 36 |
-
*/
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
/**
|
| 40 |
-
* Prevent direct access to this file
|
| 41 |
*/
|
| 42 |
-
if ( ! defined( 'ABSPATH' ) )
|
| 43 |
-
exit( __( 'Sorry, you are not allowed to access this file directly.' ) );
|
| 44 |
-
|
| 45 |
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
add_filter( 'genesis_archive_crumb', 'gencwooc_get_archive_crumb_filter', 10, 2 );
|
| 48 |
/**
|
| 49 |
-
* Filter the Genesis Breadcrumbs archive crumb
|
| 50 |
*
|
| 51 |
-
* Needed for Product Archive (Shop page) and Taxonomy archives
|
| 52 |
*
|
| 53 |
* Note: relevant WooCommerce settings (WooCommerce > Settings > Pages tab):
|
| 54 |
* - woocommerce_prepend_shop_page_to_urls (breadcrumbs and permalinks)
|
|
@@ -56,74 +46,64 @@ add_filter( 'genesis_archive_crumb', 'gencwooc_get_archive_crumb_filter', 10, 2
|
|
| 56 |
* - woocommerce_prepend_category_to_products (permalinks only)
|
| 57 |
*
|
| 58 |
* @since 0.9.0
|
| 59 |
-
* @updated 0.9.7
|
| 60 |
*
|
| 61 |
-
* @param
|
| 62 |
-
* @param array
|
| 63 |
-
*
|
|
|
|
| 64 |
*/
|
| 65 |
function gencwooc_get_archive_crumb_filter( $crumb, $args ) {
|
| 66 |
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
$
|
| 71 |
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
$crumb = $shop_name;
|
| 81 |
-
|
| 82 |
-
endif;
|
| 83 |
|
| 84 |
return apply_filters( 'gencwooc_product_archive_crumb', $crumb, $args );
|
| 85 |
}
|
| 86 |
|
| 87 |
-
|
| 88 |
-
/** Are we on a shop taxonomy archive page? */
|
| 89 |
if ( is_tax( 'product_cat' ) || is_tax( 'product_tag' ) ) {
|
| 90 |
-
|
| 91 |
-
$
|
| 92 |
-
|
| 93 |
-
$
|
| 94 |
-
|
| 95 |
-
/** Should we prepend crumb with 'shop' page link? */
|
| 96 |
-
/** See Dashboard > WooC Settings > Pages tab */
|
| 97 |
-
$shop_url = get_option( 'woocommerce_prepend_shop_page_to_urls' );
|
| 98 |
-
$shop_id = wc_get_page_id( 'shop' );
|
| 99 |
$shop_title = get_the_title( $shop_id );
|
| 100 |
|
| 101 |
-
if ( 'yes'
|
| 102 |
$prepend = gencwooc_get_crumb_link( get_permalink( $shop_id ), $shop_title, $shop_title, $args['sep'] );
|
| 103 |
-
|
| 104 |
}
|
| 105 |
|
| 106 |
if ( is_tax( 'product_cat' ) ) {
|
| 107 |
-
|
| 108 |
-
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
|
| 109 |
-
|
| 110 |
$parents = array();
|
| 111 |
-
$parent
|
| 112 |
-
|
| 113 |
-
|
|
|
|
| 114 |
$new_parent = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ) );
|
| 115 |
-
$parent
|
| 116 |
-
|
| 117 |
|
| 118 |
$crumb .= $prepend;
|
| 119 |
|
| 120 |
-
if ( ! empty( $parents ) )
|
| 121 |
$parents = array_reverse( $parents );
|
| 122 |
-
|
| 123 |
-
|
|
|
|
| 124 |
$crumb .= gencwooc_get_crumb_link( get_term_link( $item->slug, 'product_cat' ), $item->name, $item->name, $args['sep'] );
|
| 125 |
-
|
| 126 |
-
|
| 127 |
|
| 128 |
$crumb .= single_term_title( '', false );
|
| 129 |
|
|
@@ -131,99 +111,106 @@ function gencwooc_get_archive_crumb_filter( $crumb, $args ) {
|
|
| 131 |
}
|
| 132 |
|
| 133 |
if ( is_tax( 'product_tag' ) ) {
|
| 134 |
-
|
| 135 |
$crumb .= $prepend . __( 'Products tagged “', 'gencwooc' ) . single_term_title( '', false ) . _x( '”', 'endquote', 'gencwooc' );
|
| 136 |
|
| 137 |
return $crumb;
|
| 138 |
}
|
| 139 |
|
| 140 |
-
/** Original unmodified */
|
| 141 |
return $crumb;
|
| 142 |
-
}
|
| 143 |
|
|
|
|
| 144 |
|
| 145 |
add_filter( 'genesis_single_crumb', 'gencwooc_get_single_crumb', 10, 2 );
|
| 146 |
/**
|
| 147 |
-
* Filter the Genesis Breadcrumbs singular crumb
|
| 148 |
*
|
| 149 |
-
* Needed for single Product pages
|
| 150 |
*
|
| 151 |
* @since 0.9.0
|
| 152 |
*
|
| 153 |
-
* @
|
| 154 |
-
*
|
| 155 |
-
* @
|
|
|
|
|
|
|
|
|
|
| 156 |
*/
|
| 157 |
function gencwooc_get_single_crumb( $crumb, $args ) {
|
| 158 |
|
| 159 |
-
/** Are we on a single product page? */
|
| 160 |
if ( is_singular( 'product' ) ) {
|
| 161 |
-
|
| 162 |
global $post;
|
| 163 |
|
| 164 |
-
$crumb
|
| 165 |
-
$prepend
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
/** See Dashboard > WooC Settings > Pages tab */
|
| 169 |
-
$shop_url = get_option( 'woocommerce_prepend_shop_page_to_urls' );
|
| 170 |
-
$shop_id = wc_get_page_id( 'shop' );
|
| 171 |
$shop_title = get_the_title( $shop_id );
|
| 172 |
|
| 173 |
-
if ( 'yes'
|
| 174 |
$prepend = gencwooc_get_crumb_link( get_permalink( $shop_id ), $shop_title, $shop_title, $args['sep'] );
|
|
|
|
| 175 |
|
| 176 |
$crumb .= $prepend;
|
|
|
|
| 177 |
|
| 178 |
-
if ( $terms
|
| 179 |
-
$term
|
| 180 |
$parents = array();
|
| 181 |
-
$parent
|
| 182 |
-
|
| 183 |
-
|
|
|
|
| 184 |
$new_parent = get_term_by( 'id', $parent, 'product_cat' );
|
| 185 |
-
$parent
|
| 186 |
-
|
| 187 |
|
| 188 |
-
if( ! empty( $parents ) )
|
| 189 |
$parents = array_reverse( $parents );
|
| 190 |
-
|
| 191 |
-
|
|
|
|
| 192 |
$crumb .= gencwooc_get_crumb_link( get_term_link( $item->slug, 'product_cat' ), $item->name, $item->name, $args['sep'] );
|
| 193 |
-
|
| 194 |
-
|
|
|
|
| 195 |
$crumb .= gencwooc_get_crumb_link( get_term_link( $term->slug, 'product_cat' ), $term->name, $term->name, $args['sep'] );
|
| 196 |
-
|
| 197 |
|
| 198 |
$crumb .= get_the_title();
|
| 199 |
|
| 200 |
return apply_filters( 'gencwooc_single_product_crumb', $crumb, $args );
|
| 201 |
}
|
| 202 |
|
| 203 |
-
/** Fallback - original unmodified */
|
| 204 |
return $crumb;
|
| 205 |
-
}
|
| 206 |
|
|
|
|
| 207 |
|
| 208 |
/**
|
| 209 |
* Helper function to create anchor link for a single crumb.
|
| 210 |
*
|
| 211 |
-
* This is a copy of Genesis_Breadcrumb::get_breadcrumb_link() (G1.8)
|
| 212 |
*
|
| 213 |
* @since 0.9.0
|
| 214 |
*
|
| 215 |
-
* @param string $url
|
| 216 |
-
* @param string $title title attribute
|
| 217 |
-
* @param string $content
|
| 218 |
-
* @param string $sep
|
|
|
|
| 219 |
* @return string HTML markup for anchor link and optional separator.
|
| 220 |
*/
|
| 221 |
function gencwooc_get_crumb_link( $url, $title, $content, $sep = false ) {
|
| 222 |
|
| 223 |
-
$link = sprintf(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
|
| 225 |
-
if ( $sep )
|
| 226 |
$link .= $sep;
|
|
|
|
| 227 |
|
| 228 |
return $link;
|
| 229 |
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
+
* This file contains functions related modifying Genesis Breadcrumb output.
|
|
|
|
|
|
|
|
|
|
| 4 |
*
|
| 5 |
+
* @package Genesis_Connect_WooCommerce
|
| 6 |
* @since 0.9.0
|
| 7 |
*
|
| 8 |
*
|
| 9 |
+
* By default, the Genesis Breadcrumb class does not handle Shop pages and taxonomy archives in the
|
| 10 |
+
* same way as WooCommerce breadcrumbs. These filters and callback functions modify the default Genesis
|
| 11 |
+
* breadcrumb output so that the breadcrumb trail mimics that of WooCommerce breadcrumbs for:
|
|
|
|
| 12 |
* - Shop page (archive page)
|
| 13 |
* - Single product
|
| 14 |
* - Taxonomy archive
|
| 15 |
*
|
| 16 |
+
* Users who prefer to use WooCommerce breadcrumbs can do so by adding this to their child
|
| 17 |
* theme's functions.php:
|
| 18 |
* - add_theme_support( 'gencwooc-woo-breadcrumbs' );
|
| 19 |
* And this to the relevant templates:
|
| 20 |
* - remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' );
|
| 21 |
*
|
| 22 |
+
* @see readme.txt For more details.
|
| 23 |
*
|
| 24 |
* As this modification code uses existing Genesis Breadcrumb filters there is a risk that
|
| 25 |
* it will cause compatibility issues with any existing uses of Genesis Breadcrumb filters.
|
| 28 |
*
|
| 29 |
* @see genesis/lib/classes/breadcrumb.php v1.8
|
| 30 |
* @see woocommerce/templates/shop/breadcrumb.php v1.4.4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
*/
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
| 34 |
+
exit;
|
| 35 |
+
}
|
| 36 |
|
| 37 |
add_filter( 'genesis_archive_crumb', 'gencwooc_get_archive_crumb_filter', 10, 2 );
|
| 38 |
/**
|
| 39 |
+
* Filter the Genesis Breadcrumbs archive crumb.
|
| 40 |
*
|
| 41 |
+
* Needed for Product Archive (Shop page) and Taxonomy archives.
|
| 42 |
*
|
| 43 |
* Note: relevant WooCommerce settings (WooCommerce > Settings > Pages tab):
|
| 44 |
* - woocommerce_prepend_shop_page_to_urls (breadcrumbs and permalinks)
|
| 46 |
* - woocommerce_prepend_category_to_products (permalinks only)
|
| 47 |
*
|
| 48 |
* @since 0.9.0
|
|
|
|
| 49 |
*
|
| 50 |
+
* @param string $crumb Breadcrumb 'crumb' for archives.
|
| 51 |
+
* @param array $args Genesis Breadcrumb args.
|
| 52 |
+
*
|
| 53 |
+
* @return string $crumb Breadcrumb 'crumb' for archives.
|
| 54 |
*/
|
| 55 |
function gencwooc_get_archive_crumb_filter( $crumb, $args ) {
|
| 56 |
|
| 57 |
+
if ( is_post_type_archive( 'product' ) && get_option( 'page_on_front' ) !== wc_get_page_id( 'shop' ) ) {
|
| 58 |
+
$shop_id = wc_get_page_id( 'shop' );
|
| 59 |
+
$shop_name = $shop_id ? get_the_title( $shop_id ) : ucwords( get_option( 'woocommerce_shop_slug' ) );
|
| 60 |
+
$crumb = $shop_name;
|
| 61 |
|
| 62 |
+
if ( is_search() ) {
|
| 63 |
+
$crumb = gencwooc_get_crumb_link(
|
| 64 |
+
get_post_type_archive_link( 'product' ),
|
| 65 |
+
$shop_name,
|
| 66 |
+
$shop_name,
|
| 67 |
+
$args['sep'] . __( 'Search results for “', 'gencwooc' ) . get_search_query() . '”'
|
| 68 |
+
);
|
| 69 |
+
}
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
return apply_filters( 'gencwooc_product_archive_crumb', $crumb, $args );
|
| 72 |
}
|
| 73 |
|
|
|
|
|
|
|
| 74 |
if ( is_tax( 'product_cat' ) || is_tax( 'product_tag' ) ) {
|
| 75 |
+
$crumb = '';
|
| 76 |
+
$prepend = '';
|
| 77 |
+
$shop_url = get_option( 'woocommerce_prepend_shop_page_to_urls' );
|
| 78 |
+
$shop_id = wc_get_page_id( 'shop' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
$shop_title = get_the_title( $shop_id );
|
| 80 |
|
| 81 |
+
if ( 'yes' === $shop_url && $shop_id && get_option( 'page_on_front' ) !== $shop_id ) {
|
| 82 |
$prepend = gencwooc_get_crumb_link( get_permalink( $shop_id ), $shop_title, $shop_title, $args['sep'] );
|
| 83 |
+
}
|
| 84 |
}
|
| 85 |
|
| 86 |
if ( is_tax( 'product_cat' ) ) {
|
| 87 |
+
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
|
|
|
|
|
|
|
| 88 |
$parents = array();
|
| 89 |
+
$parent = $term->parent;
|
| 90 |
+
|
| 91 |
+
while ( $parent ) {
|
| 92 |
+
$parents[] = $parent;
|
| 93 |
$new_parent = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ) );
|
| 94 |
+
$parent = $new_parent->parent;
|
| 95 |
+
}
|
| 96 |
|
| 97 |
$crumb .= $prepend;
|
| 98 |
|
| 99 |
+
if ( ! empty( $parents ) ) {
|
| 100 |
$parents = array_reverse( $parents );
|
| 101 |
+
|
| 102 |
+
foreach ( $parents as $parent ) {
|
| 103 |
+
$item = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ) );
|
| 104 |
$crumb .= gencwooc_get_crumb_link( get_term_link( $item->slug, 'product_cat' ), $item->name, $item->name, $args['sep'] );
|
| 105 |
+
}
|
| 106 |
+
}
|
| 107 |
|
| 108 |
$crumb .= single_term_title( '', false );
|
| 109 |
|
| 111 |
}
|
| 112 |
|
| 113 |
if ( is_tax( 'product_tag' ) ) {
|
|
|
|
| 114 |
$crumb .= $prepend . __( 'Products tagged “', 'gencwooc' ) . single_term_title( '', false ) . _x( '”', 'endquote', 'gencwooc' );
|
| 115 |
|
| 116 |
return $crumb;
|
| 117 |
}
|
| 118 |
|
|
|
|
| 119 |
return $crumb;
|
|
|
|
| 120 |
|
| 121 |
+
}
|
| 122 |
|
| 123 |
add_filter( 'genesis_single_crumb', 'gencwooc_get_single_crumb', 10, 2 );
|
| 124 |
/**
|
| 125 |
+
* Filter the Genesis Breadcrumbs singular crumb.
|
| 126 |
*
|
| 127 |
+
* Needed for single Product pages.
|
| 128 |
*
|
| 129 |
* @since 0.9.0
|
| 130 |
*
|
| 131 |
+
* @global WP_Post $post The current WP_Post.
|
| 132 |
+
*
|
| 133 |
+
* @param string $crumb Breadcrumb 'crumb' for single posts.
|
| 134 |
+
* @param array $args Genesis Breadcrumb args.
|
| 135 |
+
*
|
| 136 |
+
* @return string $crumb Breadcrumb 'crumb' for single posts.
|
| 137 |
*/
|
| 138 |
function gencwooc_get_single_crumb( $crumb, $args ) {
|
| 139 |
|
|
|
|
| 140 |
if ( is_singular( 'product' ) ) {
|
|
|
|
| 141 |
global $post;
|
| 142 |
|
| 143 |
+
$crumb = '';
|
| 144 |
+
$prepend = '';
|
| 145 |
+
$shop_url = get_option( 'woocommerce_prepend_shop_page_to_urls' );
|
| 146 |
+
$shop_id = wc_get_page_id( 'shop' );
|
|
|
|
|
|
|
|
|
|
| 147 |
$shop_title = get_the_title( $shop_id );
|
| 148 |
|
| 149 |
+
if ( 'yes' === $shop_url && $shop_id && get_option( 'page_on_front' ) !== $shop_id ) {
|
| 150 |
$prepend = gencwooc_get_crumb_link( get_permalink( $shop_id ), $shop_title, $shop_title, $args['sep'] );
|
| 151 |
+
}
|
| 152 |
|
| 153 |
$crumb .= $prepend;
|
| 154 |
+
$terms = wp_get_object_terms( $post->ID, 'product_cat' );
|
| 155 |
|
| 156 |
+
if ( $terms ) {
|
| 157 |
+
$term = current( $terms );
|
| 158 |
$parents = array();
|
| 159 |
+
$parent = $term->parent;
|
| 160 |
+
|
| 161 |
+
while ( $parent ) {
|
| 162 |
+
$parents[] = $parent;
|
| 163 |
$new_parent = get_term_by( 'id', $parent, 'product_cat' );
|
| 164 |
+
$parent = $new_parent->parent;
|
| 165 |
+
}
|
| 166 |
|
| 167 |
+
if ( ! empty( $parents ) ) {
|
| 168 |
$parents = array_reverse( $parents );
|
| 169 |
+
|
| 170 |
+
foreach ( $parents as $parent ) {
|
| 171 |
+
$item = get_term_by( 'id', $parent, 'product_cat' );
|
| 172 |
$crumb .= gencwooc_get_crumb_link( get_term_link( $item->slug, 'product_cat' ), $item->name, $item->name, $args['sep'] );
|
| 173 |
+
}
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
$crumb .= gencwooc_get_crumb_link( get_term_link( $term->slug, 'product_cat' ), $term->name, $term->name, $args['sep'] );
|
| 177 |
+
}
|
| 178 |
|
| 179 |
$crumb .= get_the_title();
|
| 180 |
|
| 181 |
return apply_filters( 'gencwooc_single_product_crumb', $crumb, $args );
|
| 182 |
}
|
| 183 |
|
|
|
|
| 184 |
return $crumb;
|
|
|
|
| 185 |
|
| 186 |
+
}
|
| 187 |
|
| 188 |
/**
|
| 189 |
* Helper function to create anchor link for a single crumb.
|
| 190 |
*
|
| 191 |
+
* This is a copy of Genesis_Breadcrumb::get_breadcrumb_link() (G1.8).
|
| 192 |
*
|
| 193 |
* @since 0.9.0
|
| 194 |
*
|
| 195 |
+
* @param string $url URL for href attribute.
|
| 196 |
+
* @param string $title The title attribute.
|
| 197 |
+
* @param string $content The link content.
|
| 198 |
+
* @param string $sep Separator. Default false.
|
| 199 |
+
*
|
| 200 |
* @return string HTML markup for anchor link and optional separator.
|
| 201 |
*/
|
| 202 |
function gencwooc_get_crumb_link( $url, $title, $content, $sep = false ) {
|
| 203 |
|
| 204 |
+
$link = sprintf(
|
| 205 |
+
'<a href="%s" title="%s">%s</a>',
|
| 206 |
+
esc_attr( $url ),
|
| 207 |
+
esc_attr( $title ),
|
| 208 |
+
esc_html( $content )
|
| 209 |
+
);
|
| 210 |
|
| 211 |
+
if ( $sep ) {
|
| 212 |
$link .= $sep;
|
| 213 |
+
}
|
| 214 |
|
| 215 |
return $link;
|
| 216 |
|
lib/posts-per-page.php
CHANGED
|
@@ -1,31 +1,29 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
-
* These functions manage loading of plugin-specific addons to the WooCommerce
|
| 4 |
-
* settings page.
|
| 5 |
-
*
|
| 6 |
-
* @package genesis_connect_woocommerce
|
| 7 |
-
* @version 0.9.8
|
| 8 |
*
|
|
|
|
| 9 |
* @since 0.9.0
|
| 10 |
*/
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
if ( ! defined( 'ABSPATH' ) )
|
| 16 |
-
exit( _( 'Sorry, you are not allowed to access this file directly.' ) );
|
| 17 |
|
| 18 |
add_filter( 'woocommerce_settings_tabs_array', 'genesis_connect_addon_tab', 50 );
|
| 19 |
-
|
| 20 |
* Add a custom tab in the WooCommerce settings for Genesis Connect.
|
| 21 |
*
|
| 22 |
* @since 1.0.0
|
|
|
|
|
|
|
|
|
|
| 23 |
* @return array $tabs Used to add a tab to the WooCommerce settings page.
|
| 24 |
*/
|
| 25 |
function genesis_connect_addon_tab( $tabs ) {
|
| 26 |
|
| 27 |
-
// Add our own section.
|
| 28 |
$tabs['gencwooc'] = __( 'Genesis Connect Addons', 'gencwooc' );
|
|
|
|
| 29 |
return $tabs;
|
| 30 |
|
| 31 |
}
|
|
@@ -35,11 +33,9 @@ add_action( 'woocommerce_settings_tabs_gencwooc', 'genesis_connect_settings_tab'
|
|
| 35 |
* Function to add our settings to the new tab.
|
| 36 |
*
|
| 37 |
* @since 1.0.0
|
| 38 |
-
* @return array Multiple arrays holding our section information
|
| 39 |
*/
|
| 40 |
-
|
| 41 |
function genesis_connect_settings_tab() {
|
| 42 |
-
|
| 43 |
}
|
| 44 |
|
| 45 |
add_action( 'woocommerce_update_options_gencwooc', 'genesis_connect_update_settings' );
|
|
@@ -47,52 +43,61 @@ add_action( 'woocommerce_update_options_gencwooc', 'genesis_connect_update_setti
|
|
| 47 |
* Update settings.
|
| 48 |
*
|
| 49 |
* @since 1.0.0
|
| 50 |
-
* @return array Settings to update.
|
| 51 |
*/
|
| 52 |
function genesis_connect_update_settings() {
|
| 53 |
-
|
| 54 |
}
|
| 55 |
|
| 56 |
/**
|
| 57 |
* Helper function to hold an array of our settings.
|
| 58 |
*
|
| 59 |
* @since 1.0.0
|
|
|
|
| 60 |
* @return array $settings Array of our settings.
|
| 61 |
*/
|
| 62 |
function genesis_connect_get_settings() {
|
| 63 |
-
|
|
|
|
| 64 |
'gencwooc_section_title' => array(
|
| 65 |
'name' => __( 'Genesis Connect Addons', 'gencwooc' ),
|
| 66 |
'type' => 'title',
|
| 67 |
'desc' => 'Set and save additional WooCommerce settings here.',
|
| 68 |
-
'id' => 'gencwooc_section_title'
|
| 69 |
),
|
| 70 |
-
'products_per_page'
|
| 71 |
'name' => __( 'Products Per Page', 'gencwooc' ),
|
| 72 |
'type' => 'number',
|
| 73 |
'desc' => __( 'This setting determines how many products show up on archive pages and may be overridden by filters used in themes and plugins.', 'gencwooc' ),
|
| 74 |
'id' => 'gencwooc_products_per_page',
|
| 75 |
'default' => apply_filters( 'genesiswooc_default_products_per_page', get_option( 'posts_per_page' ) ),
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
|
|
|
|
|
|
| 83 |
}
|
| 84 |
|
|
|
|
| 85 |
/**
|
| 86 |
-
* Execute settings on the frontend (this should probably
|
| 87 |
-
* go somewhere else other than this file).
|
| 88 |
*
|
| 89 |
* @since 1.0.0
|
| 90 |
-
*
|
|
|
|
|
|
|
|
|
|
| 91 |
*/
|
| 92 |
-
add_filter( 'loop_shop_per_page', 'genesiswooc_products_per_page' );
|
| 93 |
function genesiswooc_products_per_page( $count ) {
|
| 94 |
|
| 95 |
-
$count = get_option( 'gencwooc_products_per_page' )
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
return $count;
|
| 98 |
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
+
* These functions manage loading of plugin-specific addons to the WooCommerce settings page.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
*
|
| 5 |
+
* @package Genesis_Connect_WooCommerce
|
| 6 |
* @since 0.9.0
|
| 7 |
*/
|
| 8 |
|
| 9 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
| 10 |
+
exit;
|
| 11 |
+
}
|
|
|
|
|
|
|
| 12 |
|
| 13 |
add_filter( 'woocommerce_settings_tabs_array', 'genesis_connect_addon_tab', 50 );
|
| 14 |
+
/**
|
| 15 |
* Add a custom tab in the WooCommerce settings for Genesis Connect.
|
| 16 |
*
|
| 17 |
* @since 1.0.0
|
| 18 |
+
*
|
| 19 |
+
* @param array $tabs Used to add a tab to the WooCommerce settings page.
|
| 20 |
+
*
|
| 21 |
* @return array $tabs Used to add a tab to the WooCommerce settings page.
|
| 22 |
*/
|
| 23 |
function genesis_connect_addon_tab( $tabs ) {
|
| 24 |
|
|
|
|
| 25 |
$tabs['gencwooc'] = __( 'Genesis Connect Addons', 'gencwooc' );
|
| 26 |
+
|
| 27 |
return $tabs;
|
| 28 |
|
| 29 |
}
|
| 33 |
* Function to add our settings to the new tab.
|
| 34 |
*
|
| 35 |
* @since 1.0.0
|
|
|
|
| 36 |
*/
|
|
|
|
| 37 |
function genesis_connect_settings_tab() {
|
| 38 |
+
woocommerce_admin_fields( genesis_connect_get_settings() );
|
| 39 |
}
|
| 40 |
|
| 41 |
add_action( 'woocommerce_update_options_gencwooc', 'genesis_connect_update_settings' );
|
| 43 |
* Update settings.
|
| 44 |
*
|
| 45 |
* @since 1.0.0
|
|
|
|
| 46 |
*/
|
| 47 |
function genesis_connect_update_settings() {
|
| 48 |
+
woocommerce_update_options( genesis_connect_get_settings() );
|
| 49 |
}
|
| 50 |
|
| 51 |
/**
|
| 52 |
* Helper function to hold an array of our settings.
|
| 53 |
*
|
| 54 |
* @since 1.0.0
|
| 55 |
+
*
|
| 56 |
* @return array $settings Array of our settings.
|
| 57 |
*/
|
| 58 |
function genesis_connect_get_settings() {
|
| 59 |
+
|
| 60 |
+
$settings = array(
|
| 61 |
'gencwooc_section_title' => array(
|
| 62 |
'name' => __( 'Genesis Connect Addons', 'gencwooc' ),
|
| 63 |
'type' => 'title',
|
| 64 |
'desc' => 'Set and save additional WooCommerce settings here.',
|
| 65 |
+
'id' => 'gencwooc_section_title',
|
| 66 |
),
|
| 67 |
+
'products_per_page' => array(
|
| 68 |
'name' => __( 'Products Per Page', 'gencwooc' ),
|
| 69 |
'type' => 'number',
|
| 70 |
'desc' => __( 'This setting determines how many products show up on archive pages and may be overridden by filters used in themes and plugins.', 'gencwooc' ),
|
| 71 |
'id' => 'gencwooc_products_per_page',
|
| 72 |
'default' => apply_filters( 'genesiswooc_default_products_per_page', get_option( 'posts_per_page' ) ),
|
| 73 |
+
),
|
| 74 |
+
'section_end' => array(
|
| 75 |
+
'type' => 'sectionend',
|
| 76 |
+
'id' => 'gencwooc_section_end',
|
| 77 |
+
),
|
| 78 |
+
);
|
| 79 |
+
|
| 80 |
+
return $settings;
|
| 81 |
+
|
| 82 |
}
|
| 83 |
|
| 84 |
+
add_filter( 'loop_shop_per_page', 'genesiswooc_products_per_page' );
|
| 85 |
/**
|
| 86 |
+
* Execute settings on the frontend (this should probably go somewhere else other than this file).
|
|
|
|
| 87 |
*
|
| 88 |
* @since 1.0.0
|
| 89 |
+
*
|
| 90 |
+
* @param integer $count Products per page to display.
|
| 91 |
+
*
|
| 92 |
+
* @return integer $count Products per page to display.
|
| 93 |
*/
|
|
|
|
| 94 |
function genesiswooc_products_per_page( $count ) {
|
| 95 |
|
| 96 |
+
$count = get_option( 'gencwooc_products_per_page' );
|
| 97 |
+
|
| 98 |
+
if ( ! $count ) {
|
| 99 |
+
$count = apply_filters( 'genesiswooc_default_products_per_page', get_option( 'posts_per_page' ) );
|
| 100 |
+
}
|
| 101 |
|
| 102 |
return $count;
|
| 103 |
|
lib/template-loader.php
CHANGED
|
@@ -1,41 +1,38 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
-
* These functions manage loading of templates for WooCommerce
|
| 4 |
-
*
|
| 5 |
-
* @package genesis_connect_woocommerce
|
| 6 |
-
* @version 0.9.8
|
| 7 |
*
|
|
|
|
| 8 |
* @since 0.9.0
|
| 9 |
*/
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
if ( ! defined( 'ABSPATH' ) )
|
| 15 |
-
exit( _( 'Sorry, you are not allowed to access this file directly.' ) );
|
| 16 |
-
|
| 17 |
-
|
| 18 |
|
| 19 |
/**
|
| 20 |
* Load the Genesis-fied templates, instead of the WooCommerce defaults.
|
| 21 |
*
|
| 22 |
-
* Hooked to 'template_include' filter
|
| 23 |
*
|
| 24 |
-
* This template loader determines which template file will be used for the requested page,
|
| 25 |
-
* following hierarchy to find the template:
|
| 26 |
* 1. First looks in the child theme's 'woocommerce' folder.
|
| 27 |
* 2. If no template found, falls back to GCW's templates.
|
| 28 |
*
|
| 29 |
-
* For taxonomy templates, first looks in child theme's 'woocommerce' folder and searches for term
|
| 30 |
-
* then taxonomy specific template, then taxonomy.php. If no template found,
|
|
|
|
| 31 |
*
|
| 32 |
* GCW provides three templates in the plugin's 'templates' directory:
|
| 33 |
* - single-product.php
|
| 34 |
* - archive-product.php
|
| 35 |
* - taxonomy.php
|
| 36 |
*
|
| 37 |
-
* Users can override GCW templates by placing their own templates in their child theme's
|
| 38 |
-
* The 'woocommerce' folder must be a folder in the child theme's root
|
|
|
|
|
|
|
| 39 |
* Permitted user templates (as per WP Template Hierarchy) are:
|
| 40 |
* - single-product.php
|
| 41 |
* - archive-product.php
|
|
@@ -43,14 +40,15 @@ if ( ! defined( 'ABSPATH' ) )
|
|
| 43 |
* - taxonomy-{taxonomy-name}.php
|
| 44 |
* - taxonomy.php
|
| 45 |
*
|
| 46 |
-
* Note that in the case of taxonomy templates, this function accommodates ALL taxonomies
|
| 47 |
-
* 'product' custom post type. This means that it will cater for users' own
|
|
|
|
| 48 |
*
|
| 49 |
* @since 0.9.0
|
| 50 |
*
|
| 51 |
-
* @param string $template Template file as per template hierarchy
|
| 52 |
-
*
|
| 53 |
-
*
|
| 54 |
*/
|
| 55 |
function gencwooc_template_loader( $template ) {
|
| 56 |
|
|
@@ -58,47 +56,38 @@ function gencwooc_template_loader( $template ) {
|
|
| 58 |
return $template;
|
| 59 |
}
|
| 60 |
|
| 61 |
-
if ( is_single() && 'product'
|
| 62 |
-
|
| 63 |
$template = locate_template( array( 'woocommerce/single-product.php' ) );
|
| 64 |
|
| 65 |
-
if ( ! $template )
|
| 66 |
$template = GCW_TEMPLATE_DIR . '/single-product.php';
|
| 67 |
-
|
| 68 |
-
}
|
| 69 |
-
elseif ( is_post_type_archive( 'product' ) || is_page( wc_get_page_id( 'shop' ) ) ) {
|
| 70 |
-
|
| 71 |
$template = locate_template( array( 'woocommerce/archive-product.php' ) );
|
| 72 |
|
| 73 |
-
if ( ! $template )
|
| 74 |
$template = GCW_TEMPLATE_DIR . '/archive-product.php';
|
| 75 |
-
|
| 76 |
-
}
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
$term = get_query_var( 'term' );
|
| 80 |
-
|
| 81 |
-
$tax = get_query_var( 'taxonomy' );
|
| 82 |
-
|
| 83 |
-
/** Get an array of all relevant taxonomies */
|
| 84 |
$taxonomies = get_object_taxonomies( 'product', 'names' );
|
| 85 |
|
| 86 |
-
if ( in_array( $tax, $taxonomies ) ) {
|
| 87 |
-
|
| 88 |
-
$tax = sanitize_title( $tax );
|
| 89 |
$term = sanitize_title( $term );
|
| 90 |
|
| 91 |
$templates = array(
|
| 92 |
-
|
| 93 |
-
|
| 94 |
'woocommerce/taxonomy.php',
|
| 95 |
);
|
| 96 |
|
| 97 |
$template = locate_template( $templates );
|
| 98 |
|
| 99 |
-
|
| 100 |
-
if ( ! $template )
|
| 101 |
$template = GCW_TEMPLATE_DIR . '/taxonomy.php';
|
|
|
|
| 102 |
}
|
| 103 |
}
|
| 104 |
|
|
@@ -106,10 +95,8 @@ function gencwooc_template_loader( $template ) {
|
|
| 106 |
|
| 107 |
}
|
| 108 |
|
| 109 |
-
|
| 110 |
-
|
| 111 |
/**
|
| 112 |
-
* Shop Loop 'template part' loader
|
| 113 |
*
|
| 114 |
* ONLY RETAINED FOR BACKWARDS COMPATIBILITY for GCW pre-0.9.2 custom templates which
|
| 115 |
* may use this function.
|
|
@@ -117,100 +104,113 @@ function gencwooc_template_loader( $template ) {
|
|
| 117 |
* Function looks for loop-shop.php in child theme's 'woocommerce' folder. If it doesn't exist,
|
| 118 |
* loads the default WooCommerce loop-shop.php file.
|
| 119 |
*
|
| 120 |
-
* Note: loop-shop.php is used to display products on the archive and taxonomy pages
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
*
|
| 122 |
-
* Users can override the default WooCommerce loop-shop.php by placing their own template (named loop-shop.php) in
|
| 123 |
-
* their child theme's 'woocommerce' folder. The'woocommerce' folder must be a folder in the
|
| 124 |
-
* child theme's root directory, eg themes/my-child-theme/woocommerce.
|
| 125 |
* It is recommended to use woocommerce/templates/loop-shop.php as the starting point of
|
| 126 |
* any custom loop template.
|
| 127 |
*
|
| 128 |
* Based on woocommerce_get_template_part()
|
| 129 |
*
|
| 130 |
* Note: updated v0.9.3 to reflect changes to woocommerce_get_template_part() introduced in
|
| 131 |
-
*
|
| 132 |
*
|
| 133 |
-
* @since 0.9.0
|
| 134 |
-
* @updated 0.9.8
|
| 135 |
* @global object $woocommerce WooCommerce instance
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
*/
|
| 137 |
-
|
| 138 |
|
| 139 |
global $woocommerce;
|
|
|
|
| 140 |
$template = '';
|
| 141 |
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
|
| 146 |
-
|
| 147 |
-
if ( !$template && $name && file_exists( $woocommerce->plugin_path() . "/templates/{$slug}-{$name}.php" ) )
|
| 148 |
$template = $woocommerce->plugin_path() . "/templates/{$slug}-{$name}.php";
|
|
|
|
| 149 |
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
|
| 154 |
-
if ( $template )
|
| 155 |
load_template( $template, false );
|
| 156 |
-
}
|
| 157 |
|
|
|
|
| 158 |
|
| 159 |
/**
|
| 160 |
-
* Display shop items
|
| 161 |
*
|
| 162 |
-
*
|
| 163 |
*
|
| 164 |
-
* Uses WooCommerce structure and contains all existing WooCommerce hooks
|
| 165 |
-
* Note that this will also display any content created in the Shop Page itself
|
| 166 |
*
|
| 167 |
-
*
|
| 168 |
-
* @see woocommerce/woocommerce-template.php
|
| 169 |
*
|
|
|
|
|
|
|
|
|
|
| 170 |
*
|
| 171 |
* @since 0.9.4
|
| 172 |
-
*
|
| 173 |
-
* @global string|int $shop_page_id The ID of the Shop WP Page
|
| 174 |
*/
|
| 175 |
function genesiswooc_product_archive() {
|
| 176 |
|
| 177 |
global $shop_page_id;
|
| 178 |
|
| 179 |
-
if ( !is_search() )
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
|
| 189 |
do_action( 'woocommerce_before_main_content' );
|
| 190 |
-
?>
|
|
|
|
|
|
|
| 191 |
|
| 192 |
-
|
| 193 |
|
| 194 |
-
|
| 195 |
|
| 196 |
woocommerce_get_template_part( 'loop', 'shop' );
|
| 197 |
|
| 198 |
do_action( 'woocommerce_pagination' );
|
| 199 |
|
| 200 |
do_action( 'woocommerce_after_main_content' );
|
| 201 |
-
}
|
| 202 |
|
|
|
|
| 203 |
|
| 204 |
/**
|
| 205 |
-
* Displays shop items for the queried taxonomy term
|
| 206 |
*
|
| 207 |
-
*
|
| 208 |
*
|
| 209 |
-
* Uses WooCommerce structure and contains all existing WooCommerce hooks
|
| 210 |
*
|
| 211 |
-
* Code based on WooCommerce 1.5.5 woocommerce_product_taxonomy_content()
|
| 212 |
-
* @see woocommerce/woocommerce-template.php
|
| 213 |
*
|
|
|
|
| 214 |
*
|
| 215 |
* @since 0.9.4
|
| 216 |
*/
|
|
@@ -226,24 +226,21 @@ function genesiswooc_product_taxonomy() {
|
|
| 226 |
|
| 227 |
}
|
| 228 |
|
| 229 |
-
|
| 230 |
/**
|
| 231 |
-
* Displays shop items for archives (taxonomy and main shop page)
|
| 232 |
-
*
|
| 233 |
-
* Only loaded if WooC 1.6.0+ is in use.
|
| 234 |
*
|
| 235 |
-
*
|
| 236 |
*
|
| 237 |
-
*
|
| 238 |
*
|
|
|
|
| 239 |
*
|
| 240 |
* @since 0.9.4
|
| 241 |
-
* @updated 0.9.8
|
| 242 |
*/
|
| 243 |
function genesiswooc_content_product() {
|
| 244 |
|
| 245 |
/**
|
| 246 |
-
* woocommerce_before_main_content hook
|
| 247 |
*
|
| 248 |
* @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
|
| 249 |
* @hooked woocommerce_breadcrumb - 20
|
|
@@ -252,7 +249,9 @@ function genesiswooc_content_product() {
|
|
| 252 |
|
| 253 |
if ( apply_filters( 'woocommerce_show_page_title', true ) ) {
|
| 254 |
echo '<h1 class="woocommerce-products-header__title page-title">';
|
|
|
|
| 255 |
woocommerce_page_title();
|
|
|
|
| 256 |
echo '</h1>';
|
| 257 |
}
|
| 258 |
|
|
@@ -267,20 +266,26 @@ function genesiswooc_content_product() {
|
|
| 267 |
* @hooked woocommerce_catalog_ordering - 30
|
| 268 |
*/
|
| 269 |
do_action( 'woocommerce_before_shop_loop' );
|
|
|
|
| 270 |
woocommerce_product_loop_start();
|
|
|
|
| 271 |
if ( wc_get_loop_prop( 'total' ) ) {
|
| 272 |
while ( have_posts() ) {
|
| 273 |
the_post();
|
|
|
|
| 274 |
/**
|
| 275 |
* Hook: woocommerce_shop_loop.
|
| 276 |
*
|
| 277 |
* @hooked WC_Structured_Data::generate_product_data() - 10
|
| 278 |
*/
|
| 279 |
do_action( 'woocommerce_shop_loop' );
|
|
|
|
| 280 |
wc_get_template_part( 'content', 'product' );
|
| 281 |
}
|
| 282 |
}
|
|
|
|
| 283 |
woocommerce_product_loop_end();
|
|
|
|
| 284 |
/**
|
| 285 |
* Hook: woocommerce_after_shop_loop.
|
| 286 |
*
|
|
@@ -295,6 +300,7 @@ function genesiswooc_content_product() {
|
|
| 295 |
*/
|
| 296 |
do_action( 'woocommerce_no_products_found' );
|
| 297 |
}
|
|
|
|
| 298 |
/**
|
| 299 |
* Hook: woocommerce_after_main_content.
|
| 300 |
*
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
+
* These functions manage loading of templates for WooCommerce.
|
|
|
|
|
|
|
|
|
|
| 4 |
*
|
| 5 |
+
* @package Genesis_Connect_WooCommerce
|
| 6 |
* @since 0.9.0
|
| 7 |
*/
|
| 8 |
|
| 9 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
| 10 |
+
exit;
|
| 11 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
/**
|
| 14 |
* Load the Genesis-fied templates, instead of the WooCommerce defaults.
|
| 15 |
*
|
| 16 |
+
* Hooked to 'template_include' filter.
|
| 17 |
*
|
| 18 |
+
* This template loader determines which template file will be used for the requested page,
|
| 19 |
+
* and uses the following hierarchy to find the template:
|
| 20 |
* 1. First looks in the child theme's 'woocommerce' folder.
|
| 21 |
* 2. If no template found, falls back to GCW's templates.
|
| 22 |
*
|
| 23 |
+
* For taxonomy templates, first looks in child theme's 'woocommerce' folder and searches for term
|
| 24 |
+
* specific template, then taxonomy specific template, then taxonomy.php. If no template found,
|
| 25 |
+
* falls back to GCW's taxonomy.php.
|
| 26 |
*
|
| 27 |
* GCW provides three templates in the plugin's 'templates' directory:
|
| 28 |
* - single-product.php
|
| 29 |
* - archive-product.php
|
| 30 |
* - taxonomy.php
|
| 31 |
*
|
| 32 |
+
* Users can override GCW templates by placing their own templates in their child theme's
|
| 33 |
+
* 'woocommerce' folder. The 'woocommerce' folder must be a folder in the child theme's root
|
| 34 |
+
* directory, eg themes/my-child-theme/woocommerce.
|
| 35 |
+
*
|
| 36 |
* Permitted user templates (as per WP Template Hierarchy) are:
|
| 37 |
* - single-product.php
|
| 38 |
* - archive-product.php
|
| 40 |
* - taxonomy-{taxonomy-name}.php
|
| 41 |
* - taxonomy.php
|
| 42 |
*
|
| 43 |
+
* Note that in the case of taxonomy templates, this function accommodates ALL taxonomies
|
| 44 |
+
* registered to the 'product' custom post type. This means that it will cater for users' own
|
| 45 |
+
* custom taxonomies as well as WooCommerce taxonomies.
|
| 46 |
*
|
| 47 |
* @since 0.9.0
|
| 48 |
*
|
| 49 |
+
* @param string $template Template file as per template hierarchy.
|
| 50 |
+
*
|
| 51 |
+
* @return string $template Template file as per template hierarchy.
|
| 52 |
*/
|
| 53 |
function gencwooc_template_loader( $template ) {
|
| 54 |
|
| 56 |
return $template;
|
| 57 |
}
|
| 58 |
|
| 59 |
+
if ( is_single() && 'product' === get_post_type() ) {
|
|
|
|
| 60 |
$template = locate_template( array( 'woocommerce/single-product.php' ) );
|
| 61 |
|
| 62 |
+
if ( ! $template ) {
|
| 63 |
$template = GCW_TEMPLATE_DIR . '/single-product.php';
|
| 64 |
+
}
|
| 65 |
+
} elseif ( is_post_type_archive( 'product' ) || is_page( wc_get_page_id( 'shop' ) ) ) {
|
|
|
|
|
|
|
| 66 |
$template = locate_template( array( 'woocommerce/archive-product.php' ) );
|
| 67 |
|
| 68 |
+
if ( ! $template ) {
|
| 69 |
$template = GCW_TEMPLATE_DIR . '/archive-product.php';
|
| 70 |
+
}
|
| 71 |
+
} elseif ( is_tax() ) {
|
| 72 |
+
$term = get_query_var( 'term' );
|
| 73 |
+
$tax = get_query_var( 'taxonomy' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
$taxonomies = get_object_taxonomies( 'product', 'names' );
|
| 75 |
|
| 76 |
+
if ( in_array( $tax, $taxonomies, true ) ) {
|
| 77 |
+
$tax = sanitize_title( $tax );
|
|
|
|
| 78 |
$term = sanitize_title( $term );
|
| 79 |
|
| 80 |
$templates = array(
|
| 81 |
+
"woocommerce/taxonomy-{$tax}-{$term}.php",
|
| 82 |
+
"woocommerce/taxonomy-{$tax}.php",
|
| 83 |
'woocommerce/taxonomy.php',
|
| 84 |
);
|
| 85 |
|
| 86 |
$template = locate_template( $templates );
|
| 87 |
|
| 88 |
+
if ( ! $template ) {
|
|
|
|
| 89 |
$template = GCW_TEMPLATE_DIR . '/taxonomy.php';
|
| 90 |
+
}
|
| 91 |
}
|
| 92 |
}
|
| 93 |
|
| 95 |
|
| 96 |
}
|
| 97 |
|
|
|
|
|
|
|
| 98 |
/**
|
| 99 |
+
* Shop Loop 'template part' loader.
|
| 100 |
*
|
| 101 |
* ONLY RETAINED FOR BACKWARDS COMPATIBILITY for GCW pre-0.9.2 custom templates which
|
| 102 |
* may use this function.
|
| 104 |
* Function looks for loop-shop.php in child theme's 'woocommerce' folder. If it doesn't exist,
|
| 105 |
* loads the default WooCommerce loop-shop.php file.
|
| 106 |
*
|
| 107 |
+
* Note: loop-shop.php is used to display products on the archive and taxonomy pages.
|
| 108 |
+
*
|
| 109 |
+
* Users can override the default WooCommerce loop-shop.php by placing their own template
|
| 110 |
+
* (named loop-shop.php) in their child theme's 'woocommerce' folder. The'woocommerce' folder
|
| 111 |
+
* must be a folder in the child theme root directory, eg themes/my-child-theme/woocommerce.
|
| 112 |
*
|
|
|
|
|
|
|
|
|
|
| 113 |
* It is recommended to use woocommerce/templates/loop-shop.php as the starting point of
|
| 114 |
* any custom loop template.
|
| 115 |
*
|
| 116 |
* Based on woocommerce_get_template_part()
|
| 117 |
*
|
| 118 |
* Note: updated v0.9.3 to reflect changes to woocommerce_get_template_part() introduced in
|
| 119 |
+
* WooCommerce v1.4+ and, effectively, this function is a clone of woocommerce_get_template_part()
|
| 120 |
*
|
|
|
|
|
|
|
| 121 |
* @global object $woocommerce WooCommerce instance
|
| 122 |
+
*
|
| 123 |
+
* @since 0.9.0
|
| 124 |
+
*
|
| 125 |
+
* @param string $slug The template slug.
|
| 126 |
+
* @param string $name The template name.
|
| 127 |
*/
|
| 128 |
+
function gencwooc_get_template_part( $slug, $name = '' ) {
|
| 129 |
|
| 130 |
global $woocommerce;
|
| 131 |
+
|
| 132 |
$template = '';
|
| 133 |
|
| 134 |
+
if ( $name ) {
|
| 135 |
+
$template = locate_template( array( "{$slug}-{$name}.php", "{$woocommerce->template_url}{$slug}-{$name}.php" ) );
|
| 136 |
+
}
|
| 137 |
|
| 138 |
+
if ( ! $template && $name && file_exists( $woocommerce->plugin_path() . "/templates/{$slug}-{$name}.php" ) ) {
|
|
|
|
| 139 |
$template = $woocommerce->plugin_path() . "/templates/{$slug}-{$name}.php";
|
| 140 |
+
}
|
| 141 |
|
| 142 |
+
if ( ! $template ) {
|
| 143 |
+
$template = locate_template( array( "{$slug}.php", "{$woocommerce->template_url}{$slug}.php" ) );
|
| 144 |
+
}
|
| 145 |
|
| 146 |
+
if ( $template ) {
|
| 147 |
load_template( $template, false );
|
| 148 |
+
}
|
| 149 |
|
| 150 |
+
}
|
| 151 |
|
| 152 |
/**
|
| 153 |
+
* Display shop items.
|
| 154 |
*
|
| 155 |
+
* For backwards compatibility with WooCommerce versions pre-1.6.0.
|
| 156 |
*
|
| 157 |
+
* Uses WooCommerce structure and contains all existing WooCommerce hooks.
|
|
|
|
| 158 |
*
|
| 159 |
+
* Note that this will also display any content created in the Shop Page itself.
|
|
|
|
| 160 |
*
|
| 161 |
+
* Code based on WooCommerce 1.5.5 woocommerce_archive_product_content().
|
| 162 |
+
*
|
| 163 |
+
* @see woocommerce/woocommerce-template.php
|
| 164 |
*
|
| 165 |
* @since 0.9.4
|
| 166 |
+
*
|
| 167 |
+
* @global string|int $shop_page_id The ID of the Shop WP Page.
|
| 168 |
*/
|
| 169 |
function genesiswooc_product_archive() {
|
| 170 |
|
| 171 |
global $shop_page_id;
|
| 172 |
|
| 173 |
+
if ( ! is_search() ) {
|
| 174 |
+
$shop_page = get_post( $shop_page_id );
|
| 175 |
+
$shop_page_title = apply_filters( 'the_title', ( get_option( 'woocommerce_shop_page_title' ) ) ? get_option( 'woocommerce_shop_page_title' ) : $shop_page->post_title, $shop_page->ID );
|
| 176 |
+
$shop_page_content = $shop_page->post_content;
|
| 177 |
+
} else {
|
| 178 |
+
$shop_page_title = __( 'Search Results:', 'gencwooc' ) . ' “' . get_search_query() . '”';
|
| 179 |
+
|
| 180 |
+
if ( get_query_var( 'paged' ) ) {
|
| 181 |
+
$shop_page_title .= ' — ' . __( 'Page', 'gencwooc' ) . ' ' . get_query_var( 'paged' );
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
$shop_page_content = '';
|
| 185 |
+
}
|
| 186 |
|
| 187 |
do_action( 'woocommerce_before_main_content' );
|
| 188 |
+
?>
|
| 189 |
+
|
| 190 |
+
<h1 class="page-title"><?php echo $shop_page_title; // phpcs:ignore WordPress.Security.EscapeOutput ?></h1>
|
| 191 |
|
| 192 |
+
<?php
|
| 193 |
|
| 194 |
+
echo apply_filters( 'the_content', $shop_page_content ); // phpcs:ignore WordPress.Security.EscapeOutput
|
| 195 |
|
| 196 |
woocommerce_get_template_part( 'loop', 'shop' );
|
| 197 |
|
| 198 |
do_action( 'woocommerce_pagination' );
|
| 199 |
|
| 200 |
do_action( 'woocommerce_after_main_content' );
|
|
|
|
| 201 |
|
| 202 |
+
}
|
| 203 |
|
| 204 |
/**
|
| 205 |
+
* Displays shop items for the queried taxonomy term.
|
| 206 |
*
|
| 207 |
+
* For backwards compatibility with WooCommerce versions pre-1.6.0.
|
| 208 |
*
|
| 209 |
+
* Uses WooCommerce structure and contains all existing WooCommerce hooks.
|
| 210 |
*
|
| 211 |
+
* Code based on WooCommerce 1.5.5 woocommerce_product_taxonomy_content().
|
|
|
|
| 212 |
*
|
| 213 |
+
* @see woocommerce/woocommerce-template.php
|
| 214 |
*
|
| 215 |
* @since 0.9.4
|
| 216 |
*/
|
| 226 |
|
| 227 |
}
|
| 228 |
|
|
|
|
| 229 |
/**
|
| 230 |
+
* Displays shop items for archives (taxonomy and main shop page).
|
|
|
|
|
|
|
| 231 |
*
|
| 232 |
+
* Only loaded if WooCommerce 1.6.0+ is in use.
|
| 233 |
*
|
| 234 |
+
* Uses WooCommerce structure and contains all existing WooCommerce hooks.
|
| 235 |
*
|
| 236 |
+
* Code based on WooCommerce 2.1.12 templates/archive-product.php.
|
| 237 |
*
|
| 238 |
* @since 0.9.4
|
|
|
|
| 239 |
*/
|
| 240 |
function genesiswooc_content_product() {
|
| 241 |
|
| 242 |
/**
|
| 243 |
+
* For woocommerce_before_main_content hook.
|
| 244 |
*
|
| 245 |
* @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
|
| 246 |
* @hooked woocommerce_breadcrumb - 20
|
| 249 |
|
| 250 |
if ( apply_filters( 'woocommerce_show_page_title', true ) ) {
|
| 251 |
echo '<h1 class="woocommerce-products-header__title page-title">';
|
| 252 |
+
|
| 253 |
woocommerce_page_title();
|
| 254 |
+
|
| 255 |
echo '</h1>';
|
| 256 |
}
|
| 257 |
|
| 266 |
* @hooked woocommerce_catalog_ordering - 30
|
| 267 |
*/
|
| 268 |
do_action( 'woocommerce_before_shop_loop' );
|
| 269 |
+
|
| 270 |
woocommerce_product_loop_start();
|
| 271 |
+
|
| 272 |
if ( wc_get_loop_prop( 'total' ) ) {
|
| 273 |
while ( have_posts() ) {
|
| 274 |
the_post();
|
| 275 |
+
|
| 276 |
/**
|
| 277 |
* Hook: woocommerce_shop_loop.
|
| 278 |
*
|
| 279 |
* @hooked WC_Structured_Data::generate_product_data() - 10
|
| 280 |
*/
|
| 281 |
do_action( 'woocommerce_shop_loop' );
|
| 282 |
+
|
| 283 |
wc_get_template_part( 'content', 'product' );
|
| 284 |
}
|
| 285 |
}
|
| 286 |
+
|
| 287 |
woocommerce_product_loop_end();
|
| 288 |
+
|
| 289 |
/**
|
| 290 |
* Hook: woocommerce_after_shop_loop.
|
| 291 |
*
|
| 300 |
*/
|
| 301 |
do_action( 'woocommerce_no_products_found' );
|
| 302 |
}
|
| 303 |
+
|
| 304 |
/**
|
| 305 |
* Hook: woocommerce_after_main_content.
|
| 306 |
*
|
lib/widgets.php
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Widget callback functions.
|
| 4 |
+
*
|
| 5 |
+
* @package Genesis_Connect_WooCommerce
|
| 6 |
+
* @since 1.1.0
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
| 10 |
+
exit;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
add_action( 'widgets_init', 'gencwooc_register_featured_products_widget' );
|
| 14 |
+
/**
|
| 15 |
+
* Register Gencwooc_Featured_Products widget.
|
| 16 |
+
*
|
| 17 |
+
* Callback for WordPress 'widgets_init' action.
|
| 18 |
+
*
|
| 19 |
+
* @since 1.0.0
|
| 20 |
+
*/
|
| 21 |
+
function gencwooc_register_featured_products_widget() {
|
| 22 |
+
|
| 23 |
+
if ( class_exists( 'Gencwooc_Featured_Products' ) ) {
|
| 24 |
+
register_widget( 'Gencwooc_Featured_Products' );
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
}
|
readme.txt
CHANGED
|
@@ -2,8 +2,8 @@
|
|
| 2 |
Contributors: nathanrice, studiopress, studiograsshopper, modernnerd, marksabbath, calvinkoepke, curtismchale
|
| 3 |
Tags: genesis, genesiswp, studiopress, woocommerce
|
| 4 |
Requires at least: 3.3
|
| 5 |
-
Tested up to:
|
| 6 |
-
Stable tag: 1.0
|
| 7 |
|
| 8 |
This plugin allows you to seamlessly integrate WooCommerce with the Genesis Framework and Genesis child themes.
|
| 9 |
|
|
@@ -131,6 +131,11 @@ For the benefit of theme developers and customizers, here is a summary of possib
|
|
| 131 |
|
| 132 |
== Changelog ==
|
| 133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
= 1.0 =
|
| 135 |
* Released 7 August 2018.
|
| 136 |
* Add WooCommerce version check support.
|
|
@@ -162,7 +167,7 @@ For the benefit of theme developers and customizers, here is a summary of possib
|
|
| 162 |
|
| 163 |
= 0.9.8 =
|
| 164 |
* Released 9 July 2014
|
| 165 |
-
* Updates genesiswooc_content_product() to reflect
|
| 166 |
|
| 167 |
= 0.9.7 =
|
| 168 |
* Released 22 December 2013
|
|
@@ -187,7 +192,7 @@ For the benefit of theme developers and customizers, here is a summary of possib
|
|
| 187 |
|
| 188 |
= 0.9.2 =
|
| 189 |
* Released 15 March 2012
|
| 190 |
-
* single-product.php - Single product title template file now hooked in as per
|
| 191 |
|
| 192 |
= 0.9.1 =
|
| 193 |
* Released 6 March 2012
|
| 2 |
Contributors: nathanrice, studiopress, studiograsshopper, modernnerd, marksabbath, calvinkoepke, curtismchale
|
| 3 |
Tags: genesis, genesiswp, studiopress, woocommerce
|
| 4 |
Requires at least: 3.3
|
| 5 |
+
Tested up to: 5.2.2
|
| 6 |
+
Stable tag: 1.1.0
|
| 7 |
|
| 8 |
This plugin allows you to seamlessly integrate WooCommerce with the Genesis Framework and Genesis child themes.
|
| 9 |
|
| 131 |
|
| 132 |
== Changelog ==
|
| 133 |
|
| 134 |
+
= 1.1.0 =
|
| 135 |
+
* Added php codesniffer via composer package for WordPress code standards.
|
| 136 |
+
* Fixed spacing and syntax issues for WordPress code standards.
|
| 137 |
+
* Renamed Gencwooc_Featured_Products file to adhere to WordPress code standards.
|
| 138 |
+
|
| 139 |
= 1.0 =
|
| 140 |
* Released 7 August 2018.
|
| 141 |
* Add WooCommerce version check support.
|
| 167 |
|
| 168 |
= 0.9.8 =
|
| 169 |
* Released 9 July 2014
|
| 170 |
+
* Updates genesiswooc_content_product() to reflect WooCommerce 2.1+ templates and correct handling of WooCommerce page title filter function
|
| 171 |
|
| 172 |
= 0.9.7 =
|
| 173 |
* Released 22 December 2013
|
| 192 |
|
| 193 |
= 0.9.2 =
|
| 194 |
* Released 15 March 2012
|
| 195 |
+
* single-product.php - Single product title template file now hooked in as per WooCommerce 1.5.2
|
| 196 |
|
| 197 |
= 0.9.1 =
|
| 198 |
* Released 6 March 2012
|
sp-plugins-integration/genesis-simple-menus.php
CHANGED
|
@@ -1,45 +1,40 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
-
*
|
| 4 |
-
*
|
| 5 |
-
* @package genesis_connect_woocommerce
|
| 6 |
-
* @version 0.9.8
|
| 7 |
-
|
| 8 |
*
|
|
|
|
| 9 |
* @since 0.9.0
|
| 10 |
*
|
| 11 |
* Genesis Simple Menus (GSM) version 0.1.4
|
| 12 |
*
|
| 13 |
* What GCW integration needs to do:
|
| 14 |
-
*
|
| 15 |
-
*
|
| 16 |
*
|
| 17 |
* What GCW does:
|
| 18 |
-
*
|
| 19 |
-
*
|
| 20 |
*
|
| 21 |
* Note: this file is loaded on the 'after_theme_setup' hook only if GSM
|
| 22 |
* is activated.
|
| 23 |
* @see gencwooc_setup() in genesis-connect-woocommerce.php
|
| 24 |
-
*
|
| 25 |
-
*/
|
| 26 |
-
|
| 27 |
-
/**
|
| 28 |
-
* Prevent direct access to this file
|
| 29 |
*/
|
| 30 |
-
if ( ! defined( 'ABSPATH' ) )
|
| 31 |
-
exit( __( 'Sorry, you are not allowed to access this file directly.', 'genwooc' ) );
|
| 32 |
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
add_filter( 'genesis_pre_get_option_subnav_type', 'gencwooc_gsm_subnav_type', 9 );
|
| 35 |
/**
|
| 36 |
-
* Tells Genesis to load a custom menu
|
| 37 |
*
|
| 38 |
* @since 0.9.0
|
| 39 |
*
|
| 40 |
* @see Genesis_Simple_Menus::wp_head()
|
| 41 |
-
*
|
| 42 |
-
* @
|
|
|
|
|
|
|
| 43 |
*/
|
| 44 |
function gencwooc_gsm_subnav_type( $nav ) {
|
| 45 |
return 'nav-menu';
|
|
@@ -48,23 +43,24 @@ function gencwooc_gsm_subnav_type( $nav ) {
|
|
| 48 |
|
| 49 |
add_filter( 'theme_mod_nav_menu_locations', 'gencwooc_gsm_theme_mod' );
|
| 50 |
/**
|
| 51 |
-
* Replace the menu selected in the WordPress Menu settings with the custom one for this request
|
| 52 |
*
|
| 53 |
* @since 0.9.0
|
| 54 |
*
|
| 55 |
* @see Genesis_Simple_Menus::wp_head()
|
| 56 |
-
*
|
| 57 |
-
* @
|
|
|
|
|
|
|
| 58 |
*/
|
| 59 |
function gencwooc_gsm_theme_mod( $mods ) {
|
| 60 |
|
| 61 |
-
/** Post meta key as per GSM 0.1.4 */
|
| 62 |
-
$field_name = '_gsm_menu';
|
| 63 |
-
|
| 64 |
$shop_id = function_exists( 'wc_get_page_id' ) ? wc_get_page_id( 'shop' ) : woocommerce_get_page_id( 'shop' );
|
|
|
|
| 65 |
|
| 66 |
-
if ( is_post_type_archive( 'product' ) && $_menu
|
| 67 |
$mods['secondary'] = (int) $_menu;
|
|
|
|
| 68 |
|
| 69 |
return $mods;
|
| 70 |
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
+
* Genesis Simple Menus integration.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
*
|
| 5 |
+
* @package Genesis_Connect_WooCommerce
|
| 6 |
* @since 0.9.0
|
| 7 |
*
|
| 8 |
* Genesis Simple Menus (GSM) version 0.1.4
|
| 9 |
*
|
| 10 |
* What GCW integration needs to do:
|
| 11 |
+
* 1. add_post_type_support for 'genesis-simple-menus'
|
| 12 |
+
* 2. deal with serving correct GSM menu for Shop page (product archive)
|
| 13 |
*
|
| 14 |
* What GCW does:
|
| 15 |
+
* 1. GCW adds post_type_support for GSM - see gencwooc_setup()
|
| 16 |
+
* 2. uses Genesis filters to intercept request and serve correct GSM menu on Shop Page
|
| 17 |
*
|
| 18 |
* Note: this file is loaded on the 'after_theme_setup' hook only if GSM
|
| 19 |
* is activated.
|
| 20 |
* @see gencwooc_setup() in genesis-connect-woocommerce.php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
*/
|
|
|
|
|
|
|
| 22 |
|
| 23 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
| 24 |
+
exit;
|
| 25 |
+
}
|
| 26 |
|
| 27 |
add_filter( 'genesis_pre_get_option_subnav_type', 'gencwooc_gsm_subnav_type', 9 );
|
| 28 |
/**
|
| 29 |
+
* Tells Genesis to load a custom menu.
|
| 30 |
*
|
| 31 |
* @since 0.9.0
|
| 32 |
*
|
| 33 |
* @see Genesis_Simple_Menus::wp_head()
|
| 34 |
+
*
|
| 35 |
+
* @param string $nav The sub nav type.
|
| 36 |
+
*
|
| 37 |
+
* @return string The sub nav type.
|
| 38 |
*/
|
| 39 |
function gencwooc_gsm_subnav_type( $nav ) {
|
| 40 |
return 'nav-menu';
|
| 43 |
|
| 44 |
add_filter( 'theme_mod_nav_menu_locations', 'gencwooc_gsm_theme_mod' );
|
| 45 |
/**
|
| 46 |
+
* Replace the menu selected in the WordPress Menu settings with the custom one for this request.
|
| 47 |
*
|
| 48 |
* @since 0.9.0
|
| 49 |
*
|
| 50 |
* @see Genesis_Simple_Menus::wp_head()
|
| 51 |
+
*
|
| 52 |
+
* @param array $mods Array of theme mods.
|
| 53 |
+
*
|
| 54 |
+
* @return array $mods Array of theme mods.
|
| 55 |
*/
|
| 56 |
function gencwooc_gsm_theme_mod( $mods ) {
|
| 57 |
|
|
|
|
|
|
|
|
|
|
| 58 |
$shop_id = function_exists( 'wc_get_page_id' ) ? wc_get_page_id( 'shop' ) : woocommerce_get_page_id( 'shop' );
|
| 59 |
+
$_menu = get_post_meta( $shop_id, '_gsm_menu', true );
|
| 60 |
|
| 61 |
+
if ( is_post_type_archive( 'product' ) && $_menu ) {
|
| 62 |
$mods['secondary'] = (int) $_menu;
|
| 63 |
+
}
|
| 64 |
|
| 65 |
return $mods;
|
| 66 |
|
sp-plugins-integration/genesis-simple-sidebars.php
CHANGED
|
@@ -1,65 +1,55 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
-
*
|
| 4 |
-
*
|
| 5 |
-
* @package genesis_connect_woocommerce
|
| 6 |
-
* @version 0.9.8
|
| 7 |
*
|
|
|
|
| 8 |
* @since 0.9.0
|
| 9 |
*
|
| 10 |
-
* Based on Genesis Simple Sidebars (GSS) version 0.9.2
|
| 11 |
*
|
| 12 |
* What GCW integration needs to do:
|
| 13 |
-
*
|
| 14 |
-
*
|
| 15 |
*
|
| 16 |
* What GCW does:
|
| 17 |
-
*
|
| 18 |
-
*
|
| 19 |
-
* then hands back control of sidebar loading in all other cases to GSS
|
| 20 |
*
|
| 21 |
-
* Note: this file is loaded on the 'after_theme_setup' hook only if GSS
|
| 22 |
-
* is activated.
|
| 23 |
* @see gencwooc_setup() in genesis-connect-woocommerce.php
|
| 24 |
-
*
|
| 25 |
-
* @TODO simply these functions
|
| 26 |
*/
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
if ( ! defined( 'ABSPATH' ) )
|
| 32 |
-
exit( __( 'Sorry, you are not allowed to access this file directly.', 'genwooc' ) );
|
| 33 |
|
| 34 |
|
| 35 |
add_action( 'get_header', 'gencwooc_ss_handler', 11 );
|
| 36 |
/**
|
| 37 |
-
* Take control of GSS sidebar loading
|
| 38 |
*
|
| 39 |
-
* Hooked to 'get_header' with priority of 11 to ensure that GSS's
|
| 40 |
-
*
|
| 41 |
-
*
|
|
|
|
|
|
|
| 42 |
*
|
| 43 |
-
* Unhooks GSS ss_do_sidebar() and ss_do_sidebar_alt() functions and
|
| 44 |
-
* hooks GCW versions of these functions to the same hooks instead.
|
| 45 |
* @see GSS ss_sidebars_init() in genesis-simple-sidebars/plugin.php
|
| 46 |
*
|
| 47 |
* Note for developers:
|
| 48 |
* ====================
|
| 49 |
-
* If you want to do more complex manipulations of sidebars, eg load another one
|
| 50 |
-
*
|
| 51 |
-
*
|
| 52 |
*
|
| 53 |
* @since 0.9.0
|
| 54 |
-
*
|
| 55 |
*/
|
| 56 |
function gencwooc_ss_handler() {
|
| 57 |
|
| 58 |
-
/** Unhook GSS functions */
|
| 59 |
remove_action( 'genesis_sidebar', 'ss_do_sidebar' );
|
| 60 |
remove_action( 'genesis_sidebar_alt', 'ss_do_sidebar_alt' );
|
| 61 |
|
| 62 |
-
/** Hook replacement functions */
|
| 63 |
add_action( 'genesis_sidebar', 'gencwooc_ss_do_sidebar' );
|
| 64 |
add_action( 'genesis_sidebar_alt', 'gencwooc_ss_do_sidebar_alt' );
|
| 65 |
|
|
@@ -67,72 +57,60 @@ function gencwooc_ss_handler() {
|
|
| 67 |
|
| 68 |
|
| 69 |
/**
|
| 70 |
-
* Callback for dealing with Primary Sidebar loading
|
| 71 |
*
|
| 72 |
-
* Intercepts GSS code flow, so that Shop page can be dealt with, then
|
| 73 |
-
*
|
| 74 |
-
*
|
| 75 |
*
|
| 76 |
-
* Checks if we're on the product archive and a GSS sidebar has been
|
| 77 |
-
*
|
| 78 |
-
* GSS sidebar on the Shop Page.
|
| 79 |
*
|
| 80 |
* If either of the above conditions return false, we load the regular sidebar.
|
| 81 |
*
|
| 82 |
* @since 0.9.0
|
| 83 |
*
|
| 84 |
* @uses woocommerce_get_page_id()
|
| 85 |
-
*
|
| 86 |
*/
|
| 87 |
function gencwooc_ss_do_sidebar() {
|
| 88 |
|
| 89 |
-
$bar = '_ss_sidebar';
|
| 90 |
$shop_id = function_exists( 'wc_get_page_id' ) ? wc_get_page_id( 'shop' ) : woocommerce_get_page_id( 'shop' );
|
|
|
|
| 91 |
|
| 92 |
-
if ( is_post_type_archive( 'product' ) && $_bar
|
| 93 |
-
|
| 94 |
dynamic_sidebar( $_bar );
|
| 95 |
-
|
| 96 |
} else {
|
| 97 |
-
|
| 98 |
genesis_do_sidebar();
|
| 99 |
-
|
| 100 |
}
|
| 101 |
|
| 102 |
}
|
| 103 |
|
| 104 |
|
| 105 |
/**
|
| 106 |
-
* Callback for dealing with Sidebar Alt loading
|
| 107 |
*
|
| 108 |
-
* Intercepts GSS code flow, so that Shop page can be dealt with, then
|
| 109 |
-
*
|
| 110 |
-
*
|
| 111 |
*
|
| 112 |
-
* Checks if we're on the product archive and a GSS sidebar has been
|
| 113 |
-
*
|
| 114 |
-
* GSS sidebar on the Shop Page.
|
| 115 |
*
|
| 116 |
* If either of the above conditions return false, we load the regular alt sidebar.
|
| 117 |
*
|
| 118 |
* @since 0.9.0
|
| 119 |
*
|
| 120 |
* @uses woocommerce_get_page_id()
|
| 121 |
-
*
|
| 122 |
*/
|
| 123 |
function gencwooc_ss_do_sidebar_alt() {
|
| 124 |
|
| 125 |
-
$bar = '_ss_sidebar_alt';
|
| 126 |
$shop_id = function_exists( 'wc_get_page_id' ) ? wc_get_page_id( 'shop' ) : woocommerce_get_page_id( 'shop' );
|
|
|
|
| 127 |
|
| 128 |
-
if ( is_post_type_archive( 'product' ) && $_bar
|
| 129 |
-
|
| 130 |
dynamic_sidebar( $_bar );
|
| 131 |
-
|
| 132 |
} else {
|
| 133 |
-
|
| 134 |
genesis_do_sidebar_alt();
|
| 135 |
-
|
| 136 |
}
|
| 137 |
|
| 138 |
}
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
+
* Genesis Simple Sidebars integration.
|
|
|
|
|
|
|
|
|
|
| 4 |
*
|
| 5 |
+
* @package Genesis_Connect_WooCommerce
|
| 6 |
* @since 0.9.0
|
| 7 |
*
|
| 8 |
+
* Based on Genesis Simple Sidebars (GSS) version 0.9.2.
|
| 9 |
*
|
| 10 |
* What GCW integration needs to do:
|
| 11 |
+
* 1. Add_post_type_support for 'genesis-simple-sidebars'.
|
| 12 |
+
* 2. Deal with serving correct GSS sidebar(s) for Shop page (product archive).
|
| 13 |
*
|
| 14 |
* What GCW does:
|
| 15 |
+
* 1. GCW adds post_type_support for GSS - see gencwooc_setup().
|
| 16 |
+
* 2. Intercepts GSS sidebar loading functions, deals with Shop Page,
|
| 17 |
+
* then hands back control of sidebar loading in all other cases to GSS.
|
| 18 |
*
|
| 19 |
+
* Note: this file is loaded on the 'after_theme_setup' hook only if GSS is activated.
|
|
|
|
| 20 |
* @see gencwooc_setup() in genesis-connect-woocommerce.php
|
|
|
|
|
|
|
| 21 |
*/
|
| 22 |
|
| 23 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
| 24 |
+
exit;
|
| 25 |
+
}
|
|
|
|
|
|
|
| 26 |
|
| 27 |
|
| 28 |
add_action( 'get_header', 'gencwooc_ss_handler', 11 );
|
| 29 |
/**
|
| 30 |
+
* Take control of GSS sidebar loading.
|
| 31 |
*
|
| 32 |
+
* Hooked to 'get_header' with priority of 11 to ensure that GSS's actions, which are unhooked
|
| 33 |
+
* here in this function, have been added and therefore can be removed.
|
| 34 |
+
*
|
| 35 |
+
* Unhooks GSS ss_do_sidebar() and ss_do_sidebar_alt() functions and hooks GCW versions of
|
| 36 |
+
* these functions to the same hooks instead.
|
| 37 |
*
|
|
|
|
|
|
|
| 38 |
* @see GSS ss_sidebars_init() in genesis-simple-sidebars/plugin.php
|
| 39 |
*
|
| 40 |
* Note for developers:
|
| 41 |
* ====================
|
| 42 |
+
* If you want to do more complex manipulations of sidebars, eg load another one altogether
|
| 43 |
+
* (ie not a GSS sidebar, G Sidebar or G Sidebar Alt), unhook this function and replace it with
|
| 44 |
+
* your own version.
|
| 45 |
*
|
| 46 |
* @since 0.9.0
|
|
|
|
| 47 |
*/
|
| 48 |
function gencwooc_ss_handler() {
|
| 49 |
|
|
|
|
| 50 |
remove_action( 'genesis_sidebar', 'ss_do_sidebar' );
|
| 51 |
remove_action( 'genesis_sidebar_alt', 'ss_do_sidebar_alt' );
|
| 52 |
|
|
|
|
| 53 |
add_action( 'genesis_sidebar', 'gencwooc_ss_do_sidebar' );
|
| 54 |
add_action( 'genesis_sidebar_alt', 'gencwooc_ss_do_sidebar_alt' );
|
| 55 |
|
| 57 |
|
| 58 |
|
| 59 |
/**
|
| 60 |
+
* Callback for dealing with Primary Sidebar loading.
|
| 61 |
*
|
| 62 |
+
* Intercepts GSS code flow, so that Shop page can be dealt with, then hands back control to the
|
| 63 |
+
* GSS function for loading primary sidebars. Effectively, it's just a more complex version
|
| 64 |
+
* of ss_do_sidebar().
|
| 65 |
*
|
| 66 |
+
* Checks if we're on the product archive and a GSS sidebar has been assigned in the
|
| 67 |
+
* Shop WP Page editor, then, if both true, loads the relevant GSS sidebar on the Shop Page.
|
|
|
|
| 68 |
*
|
| 69 |
* If either of the above conditions return false, we load the regular sidebar.
|
| 70 |
*
|
| 71 |
* @since 0.9.0
|
| 72 |
*
|
| 73 |
* @uses woocommerce_get_page_id()
|
|
|
|
| 74 |
*/
|
| 75 |
function gencwooc_ss_do_sidebar() {
|
| 76 |
|
|
|
|
| 77 |
$shop_id = function_exists( 'wc_get_page_id' ) ? wc_get_page_id( 'shop' ) : woocommerce_get_page_id( 'shop' );
|
| 78 |
+
$_bar = get_post_meta( $shop_id, '_ss_sidebar', true );
|
| 79 |
|
| 80 |
+
if ( is_post_type_archive( 'product' ) && $_bar ) {
|
|
|
|
| 81 |
dynamic_sidebar( $_bar );
|
|
|
|
| 82 |
} else {
|
|
|
|
| 83 |
genesis_do_sidebar();
|
|
|
|
| 84 |
}
|
| 85 |
|
| 86 |
}
|
| 87 |
|
| 88 |
|
| 89 |
/**
|
| 90 |
+
* Callback for dealing with Sidebar Alt loading.
|
| 91 |
*
|
| 92 |
+
* Intercepts GSS code flow, so that Shop page can be dealt with, then hands back control to the
|
| 93 |
+
* GSS function for loading secondary sidebars. Effectively, it's just a more complex version
|
| 94 |
+
* of ss_do_sidebar_alt().
|
| 95 |
*
|
| 96 |
+
* Checks if we're on the product archive and a GSS sidebar has been assigned in the
|
| 97 |
+
* Shop WP Page editor, then, if both true, loads the relevant GSS sidebar on the Shop Page.
|
|
|
|
| 98 |
*
|
| 99 |
* If either of the above conditions return false, we load the regular alt sidebar.
|
| 100 |
*
|
| 101 |
* @since 0.9.0
|
| 102 |
*
|
| 103 |
* @uses woocommerce_get_page_id()
|
|
|
|
| 104 |
*/
|
| 105 |
function gencwooc_ss_do_sidebar_alt() {
|
| 106 |
|
|
|
|
| 107 |
$shop_id = function_exists( 'wc_get_page_id' ) ? wc_get_page_id( 'shop' ) : woocommerce_get_page_id( 'shop' );
|
| 108 |
+
$_bar = get_post_meta( $shop_id, '_ss_sidebar_alt', true );
|
| 109 |
|
| 110 |
+
if ( is_post_type_archive( 'product' ) && $_bar ) {
|
|
|
|
| 111 |
dynamic_sidebar( $_bar );
|
|
|
|
| 112 |
} else {
|
|
|
|
| 113 |
genesis_do_sidebar_alt();
|
|
|
|
| 114 |
}
|
| 115 |
|
| 116 |
}
|
templates/archive-product.php
CHANGED
|
@@ -1,9 +1,10 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
-
* This template displays the archive for Products
|
| 4 |
*
|
| 5 |
-
* @package
|
| 6 |
* @version 0.9.8
|
|
|
|
| 7 |
*
|
| 8 |
* Note for customisers/users: Do not edit this file!
|
| 9 |
* ==================================================
|
|
@@ -12,24 +13,15 @@
|
|
| 12 |
* (Your theme may not have a 'woocommerce' folder, in which case create one.)
|
| 13 |
* The version in the child theme's woocommerce folder will override this template, and
|
| 14 |
* any future updates to this plugin won't wipe out your customisations.
|
| 15 |
-
*
|
| 16 |
-
* @since 0.9.0
|
| 17 |
-
*
|
| 18 |
*/
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
remove_action( 'genesis_before_loop', 'genesis_do_taxonomy_title_description', 15 );
|
| 25 |
-
|
| 26 |
-
/** Remove WooCommerce breadcrumbs */
|
| 27 |
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
|
| 28 |
-
|
| 29 |
-
/** Uncomment the below line of code to add back WooCommerce breadcrumbs */
|
| 30 |
-
//add_action( 'genesis_before_loop', 'woocommerce_breadcrumb', 10, 0 );
|
| 31 |
-
|
| 32 |
-
/** Remove Woo #container and #content divs */
|
| 33 |
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
|
| 34 |
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
|
| 35 |
|
|
@@ -41,8 +33,9 @@ add_filter( 'genesis_pre_get_option_site_layout', 'genesiswooc_archive_layout' )
|
|
| 41 |
*
|
| 42 |
* @since 0.9.0
|
| 43 |
*
|
| 44 |
-
* @param
|
| 45 |
-
*
|
|
|
|
| 46 |
*/
|
| 47 |
function genesiswooc_archive_layout( $layout ) {
|
| 48 |
|
|
@@ -60,17 +53,18 @@ add_action( 'genesis_before_loop', 'genesiswooc_archive_product_loop' );
|
|
| 60 |
/**
|
| 61 |
* Display shop items (product custom post archive)
|
| 62 |
*
|
| 63 |
-
* This function has been refactored in 0.9.4 to provide compatibility with
|
| 64 |
-
*
|
| 65 |
-
*
|
| 66 |
-
* introduced in
|
|
|
|
| 67 |
*
|
| 68 |
-
* @uses genesiswooc_content_product() if
|
| 69 |
-
* @uses genesiswooc_product_archive() for earlier
|
| 70 |
*
|
| 71 |
* @since 0.9.0
|
| 72 |
-
*
|
| 73 |
-
* @global
|
| 74 |
*/
|
| 75 |
function genesiswooc_archive_product_loop() {
|
| 76 |
|
|
@@ -78,11 +72,12 @@ function genesiswooc_archive_product_loop() {
|
|
| 78 |
|
| 79 |
$new = version_compare( $woocommerce->version, '1.6.0', '>=' );
|
| 80 |
|
| 81 |
-
if ( $new )
|
| 82 |
genesiswooc_content_product();
|
| 83 |
-
|
| 84 |
-
else
|
| 85 |
genesiswooc_product_archive();
|
|
|
|
|
|
|
| 86 |
}
|
| 87 |
|
| 88 |
genesis();
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
+
* This template displays the archive for Products.
|
| 4 |
*
|
| 5 |
+
* @package Genesis_Connect_WooCommerce
|
| 6 |
* @version 0.9.8
|
| 7 |
+
* @since 0.9.0
|
| 8 |
*
|
| 9 |
* Note for customisers/users: Do not edit this file!
|
| 10 |
* ==================================================
|
| 13 |
* (Your theme may not have a 'woocommerce' folder, in which case create one.)
|
| 14 |
* The version in the child theme's woocommerce folder will override this template, and
|
| 15 |
* any future updates to this plugin won't wipe out your customisations.
|
|
|
|
|
|
|
|
|
|
| 16 |
*/
|
| 17 |
|
| 18 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
| 19 |
+
exit;
|
| 20 |
+
}
|
| 21 |
|
| 22 |
+
remove_action( 'genesis_loop', 'genesis_do_loop' );
|
| 23 |
remove_action( 'genesis_before_loop', 'genesis_do_taxonomy_title_description', 15 );
|
|
|
|
|
|
|
| 24 |
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
|
| 26 |
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
|
| 27 |
|
| 33 |
*
|
| 34 |
* @since 0.9.0
|
| 35 |
*
|
| 36 |
+
* @param string $layout Current Genesis page layout, such as 'content-sidebar'.
|
| 37 |
+
*
|
| 38 |
+
* @return string Page layout if set for the shop page, otherwise the default site layout.
|
| 39 |
*/
|
| 40 |
function genesiswooc_archive_layout( $layout ) {
|
| 41 |
|
| 53 |
/**
|
| 54 |
* Display shop items (product custom post archive)
|
| 55 |
*
|
| 56 |
+
* This function has been refactored in 0.9.4 to provide compatibility with both WooCommerce 1.6.0
|
| 57 |
+
* and backwards compatibility with older versions.
|
| 58 |
+
*
|
| 59 |
+
* This is needed thanks to substantial changes to WooCommerce template contents introduced in
|
| 60 |
+
* WooCommerce 1.6.0.
|
| 61 |
*
|
| 62 |
+
* @uses genesiswooc_content_product() if WooCommerce is version 1.6.0+
|
| 63 |
+
* @uses genesiswooc_product_archive() for earlier WooCommerce versions
|
| 64 |
*
|
| 65 |
* @since 0.9.0
|
| 66 |
+
*
|
| 67 |
+
* @global WooCommerce $woocommerce Current WooCommerce instance.
|
| 68 |
*/
|
| 69 |
function genesiswooc_archive_product_loop() {
|
| 70 |
|
| 72 |
|
| 73 |
$new = version_compare( $woocommerce->version, '1.6.0', '>=' );
|
| 74 |
|
| 75 |
+
if ( $new ) {
|
| 76 |
genesiswooc_content_product();
|
| 77 |
+
} else {
|
|
|
|
| 78 |
genesiswooc_product_archive();
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
}
|
| 82 |
|
| 83 |
genesis();
|
templates/single-product.php
CHANGED
|
@@ -1,9 +1,10 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
-
* This template displays the single Product
|
| 4 |
*
|
| 5 |
-
* @package
|
| 6 |
* @version 0.9.8
|
|
|
|
| 7 |
*
|
| 8 |
* Note for customisers/users: Do not edit this file!
|
| 9 |
* ==================================================
|
|
@@ -12,30 +13,25 @@
|
|
| 12 |
* (Your theme may not have a 'woocommerce' folder, in which case create one.)
|
| 13 |
* The version in the child theme's woocommerce folder will override this template, and
|
| 14 |
* any future updates to this plugin won't wipe out your customisations.
|
| 15 |
-
*
|
| 16 |
*/
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
|
|
|
| 20 |
|
| 21 |
-
|
| 22 |
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
|
| 23 |
-
|
| 24 |
-
/** Uncomment the below line of code to add back WooCommerce breadcrumbs */
|
| 25 |
-
//add_action( 'genesis_before_loop', 'woocommerce_breadcrumb', 10, 0 );
|
| 26 |
-
|
| 27 |
-
/** Remove Woo #container and #content divs */
|
| 28 |
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
|
| 29 |
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
|
| 30 |
|
| 31 |
-
|
| 32 |
add_action( 'genesis_loop', 'gencwooc_single_product_loop' );
|
| 33 |
/**
|
| 34 |
-
* Displays single product loop
|
|
|
|
|
|
|
| 35 |
*
|
| 36 |
-
*
|
| 37 |
*
|
| 38 |
-
* Code based on WooCommerce 1.5.5 woocommerce_single_product_content()
|
| 39 |
* @see woocommerce/woocommerce-template.php
|
| 40 |
*
|
| 41 |
* @since 0.9.0
|
|
@@ -44,42 +40,38 @@ function gencwooc_single_product_loop() {
|
|
| 44 |
|
| 45 |
do_action( 'woocommerce_before_main_content' );
|
| 46 |
|
| 47 |
-
|
| 48 |
-
$wc_query = false;
|
| 49 |
-
|
| 50 |
-
// Added a hook for developers in case they need to modify the query
|
| 51 |
-
$wc_query = apply_filters( 'gencwooc_custom_query', $wc_query );
|
| 52 |
-
|
| 53 |
-
if ( ! $wc_query) {
|
| 54 |
|
|
|
|
| 55 |
global $wp_query;
|
| 56 |
|
| 57 |
$wc_query = $wp_query;
|
| 58 |
}
|
| 59 |
|
| 60 |
-
if ( $wc_query->have_posts() )
|
| 61 |
-
|
| 62 |
-
|
| 63 |
|
| 64 |
-
|
|
|
|
| 65 |
|
| 66 |
-
|
|
|
|
| 67 |
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
|
|
|
|
| 72 |
</div>
|
| 73 |
|
| 74 |
-
<?php
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
<?php do_action( 'woocommerce_after_single_product' );
|
| 79 |
-
|
| 80 |
-
endwhile;
|
| 81 |
|
| 82 |
do_action( 'woocommerce_after_main_content' );
|
|
|
|
| 83 |
}
|
| 84 |
|
| 85 |
-
genesis();
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
+
* This template displays the single Product.
|
| 4 |
*
|
| 5 |
+
* @package Genesis_Connect_WooCommerce
|
| 6 |
* @version 0.9.8
|
| 7 |
+
* @since 0.9.0
|
| 8 |
*
|
| 9 |
* Note for customisers/users: Do not edit this file!
|
| 10 |
* ==================================================
|
| 13 |
* (Your theme may not have a 'woocommerce' folder, in which case create one.)
|
| 14 |
* The version in the child theme's woocommerce folder will override this template, and
|
| 15 |
* any future updates to this plugin won't wipe out your customisations.
|
|
|
|
| 16 |
*/
|
| 17 |
|
| 18 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
| 19 |
+
exit;
|
| 20 |
+
}
|
| 21 |
|
| 22 |
+
remove_action( 'genesis_loop', 'genesis_do_loop' );
|
| 23 |
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
|
| 25 |
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
|
| 26 |
|
|
|
|
| 27 |
add_action( 'genesis_loop', 'gencwooc_single_product_loop' );
|
| 28 |
/**
|
| 29 |
+
* Displays single product loop.
|
| 30 |
+
*
|
| 31 |
+
* Uses WooCommerce structure and contains all existing WooCommerce hooks.
|
| 32 |
*
|
| 33 |
+
* Code based on WooCommerce 1.5.5 woocommerce_single_product_content().
|
| 34 |
*
|
|
|
|
| 35 |
* @see woocommerce/woocommerce-template.php
|
| 36 |
*
|
| 37 |
* @since 0.9.0
|
| 40 |
|
| 41 |
do_action( 'woocommerce_before_main_content' );
|
| 42 |
|
| 43 |
+
$wc_query = apply_filters( 'gencwooc_custom_query', false );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
+
if ( ! $wc_query ) {
|
| 46 |
global $wp_query;
|
| 47 |
|
| 48 |
$wc_query = $wp_query;
|
| 49 |
}
|
| 50 |
|
| 51 |
+
if ( $wc_query->have_posts() ) {
|
| 52 |
+
while ( $wc_query->have_posts() ) {
|
| 53 |
+
$wc_query->the_post();
|
| 54 |
|
| 55 |
+
do_action( 'woocommerce_before_single_product' );
|
| 56 |
+
?>
|
| 57 |
|
| 58 |
+
<div id="product-<?php the_ID(); ?>" <?php post_class(); ?>>
|
| 59 |
+
<?php do_action( 'woocommerce_before_single_product_summary' ); ?>
|
| 60 |
|
| 61 |
+
<div class="summary">
|
| 62 |
+
<?php do_action( 'woocommerce_single_product_summary' ); ?>
|
| 63 |
+
</div>
|
| 64 |
|
| 65 |
+
<?php do_action( 'woocommerce_after_single_product_summary' ); ?>
|
| 66 |
</div>
|
| 67 |
|
| 68 |
+
<?php
|
| 69 |
+
do_action( 'woocommerce_after_single_product' );
|
| 70 |
+
}
|
| 71 |
+
}
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
do_action( 'woocommerce_after_main_content' );
|
| 74 |
+
|
| 75 |
}
|
| 76 |
|
| 77 |
+
genesis();
|
templates/taxonomy.php
CHANGED
|
@@ -1,9 +1,10 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
-
* This template displays the Product Category and Tag taxonomy term archives
|
| 4 |
*
|
| 5 |
-
* @package
|
| 6 |
* @version 0.9.8
|
|
|
|
| 7 |
*
|
| 8 |
* Note for customisers/users: Do not edit this file!
|
| 9 |
* ==================================================
|
|
@@ -12,27 +13,32 @@
|
|
| 12 |
* (Your theme may not have a 'woocommerce' folder, in which case create one.)
|
| 13 |
* The version in the child theme's woocommerce folder will override this template, and
|
| 14 |
* any future updates to this plugin won't wipe out your customisations.
|
| 15 |
-
*
|
| 16 |
*/
|
| 17 |
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
/** Remove default Genesis loop */
|
| 20 |
remove_action( 'genesis_loop', 'genesis_do_loop' );
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
// Remove the WooCommerce archive title and description.
|
| 23 |
add_filter( 'woocommerce_show_page_title', '__return_false' );
|
| 24 |
-
remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description' );
|
| 25 |
|
| 26 |
add_filter( 'genesis_term_intro_text_output', 'genesiswooc_term_intro_text_output' );
|
| 27 |
/**
|
| 28 |
* Fall back to the archive description if no intro text is set.
|
| 29 |
*
|
|
|
|
|
|
|
| 30 |
* @param string $intro_text The default Genesis archive intro text.
|
| 31 |
-
* @return string Archive intro text, or archive description if no intro text set.
|
| 32 |
*
|
| 33 |
-
* @
|
| 34 |
*/
|
| 35 |
function genesiswooc_term_intro_text_output( $intro_text ) {
|
|
|
|
| 36 |
$wp_archive_description = get_the_archive_description();
|
| 37 |
|
| 38 |
if ( ! $intro_text && $wp_archive_description ) {
|
|
@@ -40,34 +46,24 @@ function genesiswooc_term_intro_text_output( $intro_text ) {
|
|
| 40 |
}
|
| 41 |
|
| 42 |
return $intro_text;
|
| 43 |
-
}
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
/** Remove WooCommerce breadcrumbs */
|
| 47 |
-
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
|
| 48 |
-
|
| 49 |
-
/** Uncomment the below line of code to add back WooCommerce breadcrumbs */
|
| 50 |
-
//add_action( 'genesis_before_loop', 'woocommerce_breadcrumb', 10, 0 );
|
| 51 |
-
|
| 52 |
-
/** Remove Woo #container and #content divs */
|
| 53 |
-
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
|
| 54 |
-
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
|
| 55 |
|
|
|
|
| 56 |
|
| 57 |
add_action( 'genesis_loop', 'genesiswooc_product_taxonomy_loop' );
|
| 58 |
/**
|
| 59 |
-
* Displays shop items for the queried taxonomy term
|
| 60 |
*
|
| 61 |
* This function has been refactored in 0.9.4 to provide compatibility with
|
| 62 |
-
* both
|
| 63 |
-
* This is needed thanks to substantial changes to
|
| 64 |
-
* introduced in
|
| 65 |
*
|
| 66 |
-
* @
|
| 67 |
-
*
|
|
|
|
|
|
|
| 68 |
*
|
| 69 |
* @since 0.9.0
|
| 70 |
-
* @updated 0.9.4
|
| 71 |
*/
|
| 72 |
function genesiswooc_product_taxonomy_loop() {
|
| 73 |
|
|
@@ -75,11 +71,11 @@ function genesiswooc_product_taxonomy_loop() {
|
|
| 75 |
|
| 76 |
$new = version_compare( $woocommerce->version, '1.6.0', '>=' );
|
| 77 |
|
| 78 |
-
if ( $new )
|
| 79 |
genesiswooc_content_product();
|
| 80 |
-
|
| 81 |
-
else
|
| 82 |
genesiswooc_product_taxonomy();
|
|
|
|
| 83 |
|
| 84 |
}
|
| 85 |
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
+
* This template displays the Product Category and Tag taxonomy term archives.
|
| 4 |
*
|
| 5 |
+
* @package Genesis_Connect_WooCommerce
|
| 6 |
* @version 0.9.8
|
| 7 |
+
* @since 0.9.0
|
| 8 |
*
|
| 9 |
* Note for customisers/users: Do not edit this file!
|
| 10 |
* ==================================================
|
| 13 |
* (Your theme may not have a 'woocommerce' folder, in which case create one.)
|
| 14 |
* The version in the child theme's woocommerce folder will override this template, and
|
| 15 |
* any future updates to this plugin won't wipe out your customisations.
|
|
|
|
| 16 |
*/
|
| 17 |
|
| 18 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
| 19 |
+
exit;
|
| 20 |
+
}
|
| 21 |
|
|
|
|
| 22 |
remove_action( 'genesis_loop', 'genesis_do_loop' );
|
| 23 |
+
remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description' );
|
| 24 |
+
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
|
| 25 |
+
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
|
| 26 |
+
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
|
| 27 |
|
|
|
|
| 28 |
add_filter( 'woocommerce_show_page_title', '__return_false' );
|
|
|
|
| 29 |
|
| 30 |
add_filter( 'genesis_term_intro_text_output', 'genesiswooc_term_intro_text_output' );
|
| 31 |
/**
|
| 32 |
* Fall back to the archive description if no intro text is set.
|
| 33 |
*
|
| 34 |
+
* @since 1.0.0
|
| 35 |
+
*
|
| 36 |
* @param string $intro_text The default Genesis archive intro text.
|
|
|
|
| 37 |
*
|
| 38 |
+
* @return string Archive intro text, or archive description if no intro text set.
|
| 39 |
*/
|
| 40 |
function genesiswooc_term_intro_text_output( $intro_text ) {
|
| 41 |
+
|
| 42 |
$wp_archive_description = get_the_archive_description();
|
| 43 |
|
| 44 |
if ( ! $intro_text && $wp_archive_description ) {
|
| 46 |
}
|
| 47 |
|
| 48 |
return $intro_text;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
+
}
|
| 51 |
|
| 52 |
add_action( 'genesis_loop', 'genesiswooc_product_taxonomy_loop' );
|
| 53 |
/**
|
| 54 |
+
* Displays shop items for the queried taxonomy term.
|
| 55 |
*
|
| 56 |
* This function has been refactored in 0.9.4 to provide compatibility with
|
| 57 |
+
* both WooCommerce 1.6.0 and backwards compatibility with older versions.
|
| 58 |
+
* This is needed thanks to substantial changes to WooCommerce template contents
|
| 59 |
+
* introduced in WooCommerce 1.6.0.
|
| 60 |
*
|
| 61 |
+
* @global $woocommerce $woocommerce The WooCommerce instance.
|
| 62 |
+
*
|
| 63 |
+
* @uses genesiswooc_content_product() if WooCommerce is version 1.6.0+
|
| 64 |
+
* @uses genesiswooc_product_taxonomy() for earlier WooCommerce versions
|
| 65 |
*
|
| 66 |
* @since 0.9.0
|
|
|
|
| 67 |
*/
|
| 68 |
function genesiswooc_product_taxonomy_loop() {
|
| 69 |
|
| 71 |
|
| 72 |
$new = version_compare( $woocommerce->version, '1.6.0', '>=' );
|
| 73 |
|
| 74 |
+
if ( $new ) {
|
| 75 |
genesiswooc_content_product();
|
| 76 |
+
} else {
|
|
|
|
| 77 |
genesiswooc_product_taxonomy();
|
| 78 |
+
}
|
| 79 |
|
| 80 |
}
|
| 81 |
|
widgets/class-gencwooc-featured-products.php
ADDED
|
@@ -0,0 +1,519 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* This file contains a widget to display WooCommerce products in a Genesis - Featured Post format.
|
| 4 |
+
*
|
| 5 |
+
* @package Genesis_Connect_WooCommerce
|
| 6 |
+
* @since 0.9.9
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
| 10 |
+
exit;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
/**
|
| 14 |
+
* Genesis Featured Products widget for the Genesis Connect plugin.
|
| 15 |
+
*
|
| 16 |
+
* @since 1.0.0
|
| 17 |
+
*/
|
| 18 |
+
class Gencwooc_Featured_Products extends WC_Widget {
|
| 19 |
+
|
| 20 |
+
/**
|
| 21 |
+
* Holds widget settings defaults, populated in constructor.
|
| 22 |
+
*
|
| 23 |
+
* @var array
|
| 24 |
+
*/
|
| 25 |
+
protected $defaults;
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Constructor. Set the default widget options and create widget.
|
| 29 |
+
*
|
| 30 |
+
* @since 0.1.8
|
| 31 |
+
*/
|
| 32 |
+
public function __construct() {
|
| 33 |
+
|
| 34 |
+
add_action( 'admin_init', array( $this, 'set_featured_products' ) );
|
| 35 |
+
|
| 36 |
+
$this->defaults = apply_filters(
|
| 37 |
+
'gencwooc_featured_products_defaults',
|
| 38 |
+
array(
|
| 39 |
+
'category' => '',
|
| 40 |
+
'count' => 8,
|
| 41 |
+
'offset' => 0,
|
| 42 |
+
'show_type' => '',
|
| 43 |
+
'orderby' => 'date',
|
| 44 |
+
'order' => 'desc',
|
| 45 |
+
'hide_free' => 0,
|
| 46 |
+
'show_hidden' => 0,
|
| 47 |
+
'show_image' => 1,
|
| 48 |
+
'image_size' => 'thumbnail',
|
| 49 |
+
'link_image' => 1,
|
| 50 |
+
'show_title' => 1,
|
| 51 |
+
'show_add_to_cart' => 1,
|
| 52 |
+
'show_price' => 1,
|
| 53 |
+
'more_from_category' => 0,
|
| 54 |
+
'more_from_category_text' => __( 'More Products from this Category', 'gencwooc' ),
|
| 55 |
+
)
|
| 56 |
+
);
|
| 57 |
+
|
| 58 |
+
$this->widget_cssclass = 'featured-content featuredproducts';
|
| 59 |
+
$this->widget_name = __( 'Genesis - Featured Products', 'gencwooc' );
|
| 60 |
+
$this->widget_description = __( 'Displays featured products with thumbnails', 'gencwooc' );
|
| 61 |
+
$this->widget_id = 'featured-products';
|
| 62 |
+
$this->settings = array(
|
| 63 |
+
'title' => array(
|
| 64 |
+
'type' => 'text',
|
| 65 |
+
'std' => '',
|
| 66 |
+
'label' => __( 'Title', 'gencwooc' ),
|
| 67 |
+
),
|
| 68 |
+
'product_cat' => array(
|
| 69 |
+
'type' => 'select',
|
| 70 |
+
'std' => esc_html( $this->defaults['category'] ),
|
| 71 |
+
'label' => __( 'Product Category', 'gencwooc' ),
|
| 72 |
+
'options' => array(),
|
| 73 |
+
),
|
| 74 |
+
'product_num' => array(
|
| 75 |
+
'type' => 'number',
|
| 76 |
+
'step' => 1,
|
| 77 |
+
'min' => 1,
|
| 78 |
+
'max' => '',
|
| 79 |
+
'std' => absint( $this->defaults['count'] ),
|
| 80 |
+
'label' => __( 'Products to Show', 'gencwooc' ),
|
| 81 |
+
),
|
| 82 |
+
'product_offset' => array(
|
| 83 |
+
'type' => 'number',
|
| 84 |
+
'step' => 1,
|
| 85 |
+
'min' => 0,
|
| 86 |
+
'max' => '',
|
| 87 |
+
'std' => absint( $this->defaults['offset'] ),
|
| 88 |
+
'label' => __( 'Product Offset', 'gencwooc' ),
|
| 89 |
+
),
|
| 90 |
+
'product_show' => array(
|
| 91 |
+
'type' => 'select',
|
| 92 |
+
'std' => esc_html( $this->defaults['show_type'] ),
|
| 93 |
+
'label' => __( 'Show', 'gencwooc' ),
|
| 94 |
+
'options' => array(
|
| 95 |
+
'' => __( 'All products', 'gencwooc' ),
|
| 96 |
+
'featured' => __( 'Featured products', 'gencwooc' ),
|
| 97 |
+
'onsale' => __( 'On-sale products', 'gencwooc' ),
|
| 98 |
+
),
|
| 99 |
+
),
|
| 100 |
+
'orderby' => array(
|
| 101 |
+
'type' => 'select',
|
| 102 |
+
'std' => esc_html( $this->defaults['orderby'] ),
|
| 103 |
+
'label' => __( 'Order by', 'gencwooc' ),
|
| 104 |
+
'options' => array(
|
| 105 |
+
'date' => __( 'Date', 'gencwooc' ),
|
| 106 |
+
'price' => __( 'Price', 'gencwooc' ),
|
| 107 |
+
'rand' => __( 'Random', 'gencwooc' ),
|
| 108 |
+
'sales' => __( 'Sales', 'gencwooc' ),
|
| 109 |
+
),
|
| 110 |
+
),
|
| 111 |
+
'order' => array(
|
| 112 |
+
'type' => 'select',
|
| 113 |
+
'std' => esc_html( $this->defaults['order'] ),
|
| 114 |
+
'label' => _x( 'Order', 'Sorting Order', 'gencwooc' ),
|
| 115 |
+
'options' => array(
|
| 116 |
+
'asc' => __( 'ASC', 'gencwooc' ),
|
| 117 |
+
'desc' => __( 'DESC', 'gencwooc' ),
|
| 118 |
+
),
|
| 119 |
+
),
|
| 120 |
+
'hide_free' => array(
|
| 121 |
+
'type' => 'checkbox',
|
| 122 |
+
'std' => absint( $this->defaults['hide_free'] ),
|
| 123 |
+
'label' => __( 'Hide Free Products', 'gencwooc' ),
|
| 124 |
+
),
|
| 125 |
+
'show_hidden' => array(
|
| 126 |
+
'type' => 'checkbox',
|
| 127 |
+
'std' => absint( $this->defaults['show_hidden'] ),
|
| 128 |
+
'label' => __( 'Show Hidden Products', 'gencwooc' ),
|
| 129 |
+
),
|
| 130 |
+
'show_image' => array(
|
| 131 |
+
'type' => 'checkbox',
|
| 132 |
+
'std' => absint( $this->defaults['show_image'] ),
|
| 133 |
+
'label' => __( 'Show Featured Image?', 'gencwooc' ),
|
| 134 |
+
),
|
| 135 |
+
'image_size' => array(
|
| 136 |
+
'type' => 'select',
|
| 137 |
+
'std' => esc_html( $this->defaults['image_size'] ),
|
| 138 |
+
'label' => __( 'Image Size', 'gencwooc' ),
|
| 139 |
+
'options' => $this->get_featured_image_sizes(),
|
| 140 |
+
),
|
| 141 |
+
'link_image' => array(
|
| 142 |
+
'type' => 'checkbox',
|
| 143 |
+
'std' => absint( $this->defaults['link_image'] ),
|
| 144 |
+
'label' => __( 'Link Product Image?', 'gencwooc' ),
|
| 145 |
+
),
|
| 146 |
+
'show_title' => array(
|
| 147 |
+
'type' => 'checkbox',
|
| 148 |
+
'std' => absint( $this->defaults['show_title'] ),
|
| 149 |
+
'label' => __( 'Show Title?', 'gencwooc' ),
|
| 150 |
+
),
|
| 151 |
+
'show_add_to_cart' => array(
|
| 152 |
+
'type' => 'checkbox',
|
| 153 |
+
'std' => absint( $this->defaults['show_add_to_cart'] ),
|
| 154 |
+
'label' => __( 'Show Add to Cart Button?', 'gencwooc' ),
|
| 155 |
+
),
|
| 156 |
+
'show_price' => array(
|
| 157 |
+
'type' => 'checkbox',
|
| 158 |
+
'std' => absint( $this->defaults['show_price'] ),
|
| 159 |
+
'label' => __( 'Show Price?', 'gencwooc' ),
|
| 160 |
+
),
|
| 161 |
+
'more_from_category' => array(
|
| 162 |
+
'type' => 'checkbox',
|
| 163 |
+
'std' => absint( $this->defaults['more_from_category'] ),
|
| 164 |
+
'label' => __( 'Show Category Archive Link?', 'gencwooc' ),
|
| 165 |
+
),
|
| 166 |
+
'more_from_category_text' => array(
|
| 167 |
+
'type' => 'text',
|
| 168 |
+
'std' => esc_html( $this->defaults['more_from_category_text'] ),
|
| 169 |
+
'label' => __( 'Link Text:', 'gencwooc' ),
|
| 170 |
+
),
|
| 171 |
+
);
|
| 172 |
+
|
| 173 |
+
parent::__construct();
|
| 174 |
+
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
/**
|
| 178 |
+
* Callback for WordPress `admin_init` action.
|
| 179 |
+
*
|
| 180 |
+
* Sets the product_cat options using get_featured_product_categories() after the product_cat
|
| 181 |
+
* taxonomy has been registered.
|
| 182 |
+
*/
|
| 183 |
+
public function set_featured_products() {
|
| 184 |
+
$this->settings['product_cat']['options'] = $this->get_featured_product_categories();
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
/**
|
| 188 |
+
* Function to retrieve the actual product categories as an assosiative array. Used to output
|
| 189 |
+
* a dropdown in the widget settings.
|
| 190 |
+
*
|
| 191 |
+
* @return array Associative array of product categories.
|
| 192 |
+
*/
|
| 193 |
+
public function get_featured_product_categories() {
|
| 194 |
+
|
| 195 |
+
$cats = get_terms( 'product_cat' );
|
| 196 |
+
$options = array(
|
| 197 |
+
'' => __( 'All Categories', 'gencwooc' ),
|
| 198 |
+
);
|
| 199 |
+
|
| 200 |
+
if ( ! empty( $cats ) && ! is_wp_error( $cats ) ) {
|
| 201 |
+
foreach ( $cats as $cat ) {
|
| 202 |
+
$options[ $cat->slug ] = $cat->name;
|
| 203 |
+
}
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
return $options;
|
| 207 |
+
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
/**
|
| 211 |
+
* Function to retrieve an associative array containing all possible featured image sizes to
|
| 212 |
+
* be used.
|
| 213 |
+
*
|
| 214 |
+
* @return array Associative array containg possible image sizes and dimensions.
|
| 215 |
+
*/
|
| 216 |
+
public function get_featured_image_sizes() {
|
| 217 |
+
|
| 218 |
+
$options = [];
|
| 219 |
+
$images = genesis_get_image_sizes();
|
| 220 |
+
|
| 221 |
+
foreach ( $images as $size => $data ) {
|
| 222 |
+
$name = sprintf( '%s: %s x %s', $size, $data['width'], $data['height'] );
|
| 223 |
+
$options[ $size ] = $name;
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
return $options;
|
| 227 |
+
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
/**
|
| 231 |
+
* Main function to retrieve a WP_Query object with appropriate arguments passed in from
|
| 232 |
+
* the instance.
|
| 233 |
+
*
|
| 234 |
+
* @param array $args Widgdet instance arguments.
|
| 235 |
+
* @param array $instance Instance arguments to be used in the query.
|
| 236 |
+
*
|
| 237 |
+
* @return object New WP_Query object to be looped through.
|
| 238 |
+
*/
|
| 239 |
+
public function get_featured_products( $args, $instance ) {
|
| 240 |
+
|
| 241 |
+
$cat = ! empty( $instance['product_cat'] ) ? sanitize_title( $instance['product_cat'] ) : $this->settings['product_cat']['std'];
|
| 242 |
+
$count = ! empty( $instance['product_num'] ) ? absint( $instance['product_num'] ) : $this->settings['product_num']['std'];
|
| 243 |
+
$offset = ! empty( $instance['product_offset'] ) ? absint( $instance['product_offset'] ) : $this->settings['product_offset']['std'];
|
| 244 |
+
$orderby = ! empty( $instance['orderby'] ) ? sanitize_title( $instance['orderby'] ) : $this->settings['orderby']['std'];
|
| 245 |
+
$order = ! empty( $instance['order'] ) ? sanitize_title( $instance['order'] ) : $this->settings['order']['std'];
|
| 246 |
+
$product_show = ! empty( $instance['product_show'] ) ? sanitize_title( $instance['product_show'] ) : $this->settings['product_show']['std'];
|
| 247 |
+
$product_visibility_term_ids = wc_get_product_visibility_term_ids();
|
| 248 |
+
|
| 249 |
+
$query_args = array(
|
| 250 |
+
'post_type' => 'product',
|
| 251 |
+
'cat' => $cat,
|
| 252 |
+
'showposts' => $count,
|
| 253 |
+
'offset' => $offset,
|
| 254 |
+
'order' => $order,
|
| 255 |
+
'tax_query' => array( // phpcs:ignore WordPress.DB.SlowDBQuery
|
| 256 |
+
'relation' => 'AND',
|
| 257 |
+
),
|
| 258 |
+
);
|
| 259 |
+
|
| 260 |
+
switch ( $product_show ) {
|
| 261 |
+
case 'featured':
|
| 262 |
+
$query_args['tax_query'][] = array(
|
| 263 |
+
'taxonomy' => 'product_visibility',
|
| 264 |
+
'field' => 'term_taxonomy_id',
|
| 265 |
+
'terms' => $product_visibility_term_ids['featured'],
|
| 266 |
+
);
|
| 267 |
+
break;
|
| 268 |
+
case 'onsale':
|
| 269 |
+
$product_ids_on_sale = wc_get_product_ids_on_sale();
|
| 270 |
+
$product_ids_on_sale[] = 0;
|
| 271 |
+
$query_args['post__in'] = $product_ids_on_sale;
|
| 272 |
+
break;
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
if ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) ) {
|
| 276 |
+
$query_args['tax_query'] = array( // phpcs:ignore WordPress.DB.SlowDBQuery
|
| 277 |
+
array(
|
| 278 |
+
'taxonomy' => 'product_visibility',
|
| 279 |
+
'field' => 'term_taxonomy_id',
|
| 280 |
+
'terms' => $product_visibility_term_ids['outofstock'],
|
| 281 |
+
'operator' => 'NOT IN',
|
| 282 |
+
),
|
| 283 |
+
);
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
if ( empty( $instance['show_hidden'] ) ) {
|
| 287 |
+
$query_args['tax_query'][] = array(
|
| 288 |
+
'taxonomy' => 'product_visibility',
|
| 289 |
+
'field' => 'term_taxonomy_id',
|
| 290 |
+
'terms' => is_search() ? $product_visibility_term_ids['exclude-from-search'] : $product_visibility_term_ids['exclude-from-catalog'],
|
| 291 |
+
'operator' => 'NOT IN',
|
| 292 |
+
);
|
| 293 |
+
|
| 294 |
+
$query_args['post_parent'] = 0;
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
if ( ! empty( $instance['hide_free'] ) ) {
|
| 298 |
+
// Meta query ensures price and sale price are not explicitly set
|
| 299 |
+
// to a zero-like string. Empty pricing fields do not count as
|
| 300 |
+
// a free product. WooCommerce shows no purchase buttons for those.
|
| 301 |
+
$query_args['meta_query'][] = array(
|
| 302 |
+
'relation' => 'AND',
|
| 303 |
+
array(
|
| 304 |
+
'key' => '_price',
|
| 305 |
+
'value' => array( '0', '00', '000', '0000', '0.00', '0,00' ),
|
| 306 |
+
'compare' => 'NOT IN',
|
| 307 |
+
),
|
| 308 |
+
array(
|
| 309 |
+
'key' => '_sale_price',
|
| 310 |
+
'value' => array( '0', '00', '000', '0000', '0.00', '0,00' ),
|
| 311 |
+
'compare' => 'NOT IN',
|
| 312 |
+
),
|
| 313 |
+
);
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
switch ( $orderby ) {
|
| 317 |
+
case 'price':
|
| 318 |
+
$query_args['meta_key'] = '_price'; // phpcs:ignore WordPress.DB.SlowDBQuery
|
| 319 |
+
$query_args['orderby'] = 'meta_value_num';
|
| 320 |
+
break;
|
| 321 |
+
case 'rand':
|
| 322 |
+
$query_args['orderby'] = 'rand';
|
| 323 |
+
break;
|
| 324 |
+
case 'sales':
|
| 325 |
+
$query_args['meta_key'] = 'total_sales'; // phpcs:ignore WordPress.DB.SlowDBQuery
|
| 326 |
+
$query_args['orderby'] = 'meta_value_num';
|
| 327 |
+
break;
|
| 328 |
+
default:
|
| 329 |
+
$query_args['orderby'] = 'date';
|
| 330 |
+
}
|
| 331 |
+
|
| 332 |
+
return new WP_Query( apply_filters( 'genwoo_featured_products_widget_query_args', $query_args ) );
|
| 333 |
+
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
/**
|
| 337 |
+
* Echo the widget content.
|
| 338 |
+
*
|
| 339 |
+
* @since 0.9.9
|
| 340 |
+
*
|
| 341 |
+
* @global WP_Query $product Product (post) object.
|
| 342 |
+
*
|
| 343 |
+
* @param array $args Display arguments including `before_title`, `after_title`,
|
| 344 |
+
* `before_widget`, and `after_widget`.
|
| 345 |
+
* @param array $instance The settings for the particular instance of the widget.
|
| 346 |
+
*/
|
| 347 |
+
public function widget( $args, $instance ) {
|
| 348 |
+
|
| 349 |
+
if ( $this->get_cached_widget( $args ) ) {
|
| 350 |
+
return;
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
+
ob_start();
|
| 354 |
+
|
| 355 |
+
$instance = wp_parse_args( $instance, $this->defaults );
|
| 356 |
+
$products = $this->get_featured_products( $args, $instance );
|
| 357 |
+
|
| 358 |
+
if ( $products && $products->have_posts() ) {
|
| 359 |
+
$this->widget_start( $args, $instance );
|
| 360 |
+
|
| 361 |
+
genesis_markup(
|
| 362 |
+
array(
|
| 363 |
+
'open' => '<ul %s>',
|
| 364 |
+
'context' => 'featured-products-list',
|
| 365 |
+
)
|
| 366 |
+
);
|
| 367 |
+
|
| 368 |
+
while ( $products->have_posts() ) {
|
| 369 |
+
$products->the_post();
|
| 370 |
+
|
| 371 |
+
global $product;
|
| 372 |
+
|
| 373 |
+
genesis_markup(
|
| 374 |
+
array(
|
| 375 |
+
'open' => '<li %s>',
|
| 376 |
+
'context' => 'entry-product',
|
| 377 |
+
)
|
| 378 |
+
);
|
| 379 |
+
|
| 380 |
+
$image = genesis_get_image(
|
| 381 |
+
array(
|
| 382 |
+
'format' => 'html',
|
| 383 |
+
'size' => $instance['image_size'],
|
| 384 |
+
'context' => 'featured-product-image',
|
| 385 |
+
'attr' => genesis_parse_attr( 'featured-product-image', array( 'alt' => get_the_title() ) ),
|
| 386 |
+
)
|
| 387 |
+
);
|
| 388 |
+
|
| 389 |
+
if ( $image && $instance['show_image'] ) {
|
| 390 |
+
if ( $instance['link_image'] ) {
|
| 391 |
+
printf(
|
| 392 |
+
'<a href="%s" class="entry-image-wrap">%s</a>',
|
| 393 |
+
esc_url( get_permalink() ),
|
| 394 |
+
wp_make_content_images_responsive( $image ) // phpcs:ignore WordPress.Security.EscapeOutput
|
| 395 |
+
);
|
| 396 |
+
} else {
|
| 397 |
+
printf(
|
| 398 |
+
'<div class="entry-image-wrap">%s</div>',
|
| 399 |
+
wp_make_content_images_responsive( $image ) // phpcs:ignore WordPress.Security.EscapeOutput
|
| 400 |
+
);
|
| 401 |
+
}
|
| 402 |
+
}
|
| 403 |
+
|
| 404 |
+
if ( $instance['show_title'] ) {
|
| 405 |
+
$header = '';
|
| 406 |
+
|
| 407 |
+
if ( ! empty( $instance['show_title'] ) ) {
|
| 408 |
+
$title = get_the_title() ? get_the_title() : __( '(no title)', 'gencwooc' );
|
| 409 |
+
|
| 410 |
+
/**
|
| 411 |
+
* Filter the featured post widget title.
|
| 412 |
+
*
|
| 413 |
+
* @since 2.2.0
|
| 414 |
+
*
|
| 415 |
+
* @param string $title Featured post title.
|
| 416 |
+
* @param array $instance {
|
| 417 |
+
* Widget settings for this instance.
|
| 418 |
+
*
|
| 419 |
+
* @type string $title Widget title.
|
| 420 |
+
* @type int $product_cat ID of the post category.
|
| 421 |
+
* @type int $product_num Number of posts to show.
|
| 422 |
+
* @type int $product_offset Number of posts to skip when
|
| 423 |
+
* retrieving.
|
| 424 |
+
* @type string $orderby Field to order posts by.
|
| 425 |
+
* @type string $order ASC fr ascending order, DESC for
|
| 426 |
+
* descending order of posts.
|
| 427 |
+
* @type bool $show_image True if featured image should be
|
| 428 |
+
* shown, false otherwise.
|
| 429 |
+
* @type bool $show_hidden True if hidden products should be
|
| 430 |
+
* shown, false otherwise.
|
| 431 |
+
* @type string $image_size Name of the image size.
|
| 432 |
+
* @type bool $show_title True if featured page title should
|
| 433 |
+
* be shown, false otherwise.
|
| 434 |
+
* @type int $extra_num Number of extra post titles to show.
|
| 435 |
+
* @type string $extra_title Heading for extra posts.
|
| 436 |
+
* @type bool $more_from_category True if showing category archive
|
| 437 |
+
* link, false otherwise.
|
| 438 |
+
* @type string $more_from_category_text Category archive link text.
|
| 439 |
+
* }
|
| 440 |
+
* @param array $args {
|
| 441 |
+
* Widget display arguments.
|
| 442 |
+
*
|
| 443 |
+
* @type string $before_widget Markup or content to display before the widget.
|
| 444 |
+
* @type string $before_title Markup or content to display before the widget title.
|
| 445 |
+
* @type string $after_title Markup or content to display after the widget title.
|
| 446 |
+
* @type string $after_widget Markup or content to display after the widget.
|
| 447 |
+
* }
|
| 448 |
+
*/
|
| 449 |
+
$title = apply_filters( 'genesis_featured_product_title', $title, $instance, $args );
|
| 450 |
+
$heading = genesis_a11y( 'headings' ) ? 'h4' : 'h2';
|
| 451 |
+
|
| 452 |
+
$header .= genesis_markup(
|
| 453 |
+
array(
|
| 454 |
+
'open' => "<{$heading} %s>",
|
| 455 |
+
'close' => "</{$heading}>",
|
| 456 |
+
'context' => 'entry-product-title',
|
| 457 |
+
'content' => sprintf( '<a href="%s">%s</a>', get_permalink(), $title ),
|
| 458 |
+
'echo' => false,
|
| 459 |
+
)
|
| 460 |
+
);
|
| 461 |
+
|
| 462 |
+
}
|
| 463 |
+
|
| 464 |
+
genesis_markup(
|
| 465 |
+
array(
|
| 466 |
+
'open' => '<header %s>',
|
| 467 |
+
'close' => '</header>',
|
| 468 |
+
'context' => 'entry-product-header',
|
| 469 |
+
'content' => $header,
|
| 470 |
+
)
|
| 471 |
+
);
|
| 472 |
+
|
| 473 |
+
}
|
| 474 |
+
|
| 475 |
+
if ( $instance['show_price'] && $product->get_price_html() ) {
|
| 476 |
+
printf( '<span class="price">%s</span>', $product->get_price_html() ); // phpcs:ignore WordPress.Security.EscapeOutput
|
| 477 |
+
}
|
| 478 |
+
|
| 479 |
+
if ( $instance['show_add_to_cart'] ) {
|
| 480 |
+
woocommerce_template_loop_add_to_cart( $product->get_id() );
|
| 481 |
+
}
|
| 482 |
+
|
| 483 |
+
genesis_markup(
|
| 484 |
+
array(
|
| 485 |
+
'close' => '</li>',
|
| 486 |
+
'context' => 'entry-product',
|
| 487 |
+
)
|
| 488 |
+
);
|
| 489 |
+
}
|
| 490 |
+
|
| 491 |
+
genesis_markup(
|
| 492 |
+
array(
|
| 493 |
+
'close' => '</ul>',
|
| 494 |
+
'context' => 'featured-products-list',
|
| 495 |
+
)
|
| 496 |
+
);
|
| 497 |
+
|
| 498 |
+
if ( ! empty( $instance['more_from_category'] ) ) {
|
| 499 |
+
$cat = get_term_by( 'name', $instance['product_cat'], 'product_cat' );
|
| 500 |
+
|
| 501 |
+
printf(
|
| 502 |
+
'<p class="more-from-category"><a href="%1$s" title="%2$s">%3$s</a></p>',
|
| 503 |
+
esc_url( get_term_link( $cat->term_taxonomy_id ) ),
|
| 504 |
+
esc_attr( $cat->name ),
|
| 505 |
+
esc_html( $instance['more_from_category_text'] )
|
| 506 |
+
);
|
| 507 |
+
}
|
| 508 |
+
|
| 509 |
+
$this->widget_end( $args );
|
| 510 |
+
|
| 511 |
+
}
|
| 512 |
+
|
| 513 |
+
wp_reset_postdata();
|
| 514 |
+
|
| 515 |
+
echo $this->cache_widget( $args, ob_get_clean() ); // phpcs:ignore WordPress.Security.EscapeOutput
|
| 516 |
+
|
| 517 |
+
}
|
| 518 |
+
|
| 519 |
+
}
|
widgets/woocommerce-featured-widgets.php
DELETED
|
@@ -1,506 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* This file contains a widget to display WooCommerce products in a Genesis - Featured Post format.
|
| 4 |
-
*
|
| 5 |
-
* @package genesis_connect_woocommerce
|
| 6 |
-
* @version 0.9.9
|
| 7 |
-
*
|
| 8 |
-
* @since 0.9.9
|
| 9 |
-
*/
|
| 10 |
-
|
| 11 |
-
/**
|
| 12 |
-
* Genesis Featured Products widget for the Genesis Connect plugin.
|
| 13 |
-
*
|
| 14 |
-
* @since 1.0.0
|
| 15 |
-
*
|
| 16 |
-
* @package Canvas
|
| 17 |
-
*/
|
| 18 |
-
class Gencwooc_Featured_Products extends WC_Widget {
|
| 19 |
-
|
| 20 |
-
/**
|
| 21 |
-
* Holds widget settings defaults, populated in constructor.
|
| 22 |
-
*
|
| 23 |
-
* @var array
|
| 24 |
-
*/
|
| 25 |
-
protected $defaults;
|
| 26 |
-
|
| 27 |
-
/**
|
| 28 |
-
* Constructor. Set the default widget options and create widget.
|
| 29 |
-
*
|
| 30 |
-
* @since 0.1.8
|
| 31 |
-
*/
|
| 32 |
-
public function __construct() {
|
| 33 |
-
|
| 34 |
-
// Retrieve a list of product categories.
|
| 35 |
-
add_action( 'admin_init', array( $this, 'set_featured_products' ) );
|
| 36 |
-
|
| 37 |
-
// Set the widget default settings.
|
| 38 |
-
$this->defaults = apply_filters( 'gencwooc_featured_products_defaults', array(
|
| 39 |
-
'category' => '',
|
| 40 |
-
'count' => 8,
|
| 41 |
-
'offset' => 0,
|
| 42 |
-
'show_type' => '',
|
| 43 |
-
'orderby' => 'date',
|
| 44 |
-
'order' => 'desc',
|
| 45 |
-
'hide_free' => 0,
|
| 46 |
-
'show_hidden' => 0,
|
| 47 |
-
'show_image' => 1,
|
| 48 |
-
'image_size' => 'thumbnail',
|
| 49 |
-
'link_image' => 1,
|
| 50 |
-
'show_title' => 1,
|
| 51 |
-
'show_add_to_cart' => 1,
|
| 52 |
-
'show_price' => 1,
|
| 53 |
-
'more_from_category' => 0,
|
| 54 |
-
'more_from_category_text' => __( 'More Products from this Category', 'gencwooc' ),
|
| 55 |
-
));
|
| 56 |
-
|
| 57 |
-
$this->widget_cssclass = 'featured-content featuredproducts';
|
| 58 |
-
$this->widget_name = __( 'Genesis - Featured Products', 'gencwooc' );
|
| 59 |
-
$this->widget_description = __( 'Displays featured products with thumbnails', 'gencwooc' );
|
| 60 |
-
$this->widget_id = 'featured-products';
|
| 61 |
-
$this->settings = array(
|
| 62 |
-
'title' => array(
|
| 63 |
-
'type' => 'text',
|
| 64 |
-
'std' => '',
|
| 65 |
-
'label' => __( 'Title', 'gencwooc' ),
|
| 66 |
-
),
|
| 67 |
-
'product_cat' => array(
|
| 68 |
-
'type' => 'select',
|
| 69 |
-
'std' => esc_html( $this->defaults['category'] ),
|
| 70 |
-
'label' => __( 'Product Category', 'gencwooc' ),
|
| 71 |
-
'options' => array(),
|
| 72 |
-
),
|
| 73 |
-
'product_num' => array(
|
| 74 |
-
'type' => 'number',
|
| 75 |
-
'step' => 1,
|
| 76 |
-
'min' => 1,
|
| 77 |
-
'max' => '',
|
| 78 |
-
'std' => absint( $this->defaults['count'] ),
|
| 79 |
-
'label' => __( 'Products to Show', 'gencwooc' ),
|
| 80 |
-
),
|
| 81 |
-
'product_offset' => array(
|
| 82 |
-
'type' => 'number',
|
| 83 |
-
'step' => 1,
|
| 84 |
-
'min' => 0,
|
| 85 |
-
'max' => '',
|
| 86 |
-
'std' => absint( $this->defaults['offset'] ),
|
| 87 |
-
'label' => __( 'Product Offset', 'gencwooc' ),
|
| 88 |
-
),
|
| 89 |
-
'product_show' => array(
|
| 90 |
-
'type' => 'select',
|
| 91 |
-
'std' => esc_html( $this->defaults['show_type'] ),
|
| 92 |
-
'label' => __( 'Show', 'gencwooc' ),
|
| 93 |
-
'options' => array(
|
| 94 |
-
'' => __( 'All products', 'gencwooc' ),
|
| 95 |
-
'featured' => __( 'Featured products', 'gencwooc' ),
|
| 96 |
-
'onsale' => __( 'On-sale products', 'gencwooc' ),
|
| 97 |
-
),
|
| 98 |
-
),
|
| 99 |
-
'orderby' => array(
|
| 100 |
-
'type' => 'select',
|
| 101 |
-
'std' => esc_html( $this->defaults['orderby'] ),
|
| 102 |
-
'label' => __( 'Order by', 'gencwooc' ),
|
| 103 |
-
'options' => array(
|
| 104 |
-
'date' => __( 'Date', 'gencwooc' ),
|
| 105 |
-
'price' => __( 'Price', 'gencwooc' ),
|
| 106 |
-
'rand' => __( 'Random', 'gencwooc' ),
|
| 107 |
-
'sales' => __( 'Sales', 'gencwooc' ),
|
| 108 |
-
),
|
| 109 |
-
),
|
| 110 |
-
'order' => array(
|
| 111 |
-
'type' => 'select',
|
| 112 |
-
'std' => esc_html( $this->defaults['order'] ),
|
| 113 |
-
'label' => _x( 'Order', 'Sorting Order', 'gencwooc' ),
|
| 114 |
-
'options' => array(
|
| 115 |
-
'asc' => __( 'ASC', 'gencwooc' ),
|
| 116 |
-
'desc' => __( 'DESC', 'gencwooc' ),
|
| 117 |
-
),
|
| 118 |
-
),
|
| 119 |
-
'hide_free' => array(
|
| 120 |
-
'type' => 'checkbox',
|
| 121 |
-
'std' => absint( $this->defaults['hide_free'] ),
|
| 122 |
-
'label' => __( 'Hide Free Products', 'gencwooc' ),
|
| 123 |
-
),
|
| 124 |
-
'show_hidden' => array(
|
| 125 |
-
'type' => 'checkbox',
|
| 126 |
-
'std' => absint( $this->defaults['show_hidden'] ),
|
| 127 |
-
'label' => __( 'Show Hidden Products', 'gensis' ),
|
| 128 |
-
),
|
| 129 |
-
'show_image' => array(
|
| 130 |
-
'type' => 'checkbox',
|
| 131 |
-
'std' => absint( $this->defaults['show_image'] ),
|
| 132 |
-
'label' => __( 'Show Featured Image?', 'gencwooc' ),
|
| 133 |
-
),
|
| 134 |
-
'image_size' => array(
|
| 135 |
-
'type' => 'select',
|
| 136 |
-
'std' => esc_html( $this->defaults['image_size'] ),
|
| 137 |
-
'label' => __( 'Image Size', 'gencwooc' ),
|
| 138 |
-
'options' => $this->get_featured_image_sizes(),
|
| 139 |
-
),
|
| 140 |
-
'link_image' => array(
|
| 141 |
-
'type' => 'checkbox',
|
| 142 |
-
'std' => absint( $this->defaults['link_image'] ),
|
| 143 |
-
'label' => __( 'Link Product Image?', 'gencwooc' ),
|
| 144 |
-
),
|
| 145 |
-
'show_title' => array(
|
| 146 |
-
'type' => 'checkbox',
|
| 147 |
-
'std' => absint( $this->defaults['show_title'] ),
|
| 148 |
-
'label' => __( 'Show Title?', 'gencwooc' ),
|
| 149 |
-
),
|
| 150 |
-
'show_add_to_cart' => array(
|
| 151 |
-
'type' => 'checkbox',
|
| 152 |
-
'std' => absint( $this->defaults['show_add_to_cart'] ),
|
| 153 |
-
'label' => __( 'Show Add to Cart Button?', 'gencwooc' ),
|
| 154 |
-
),
|
| 155 |
-
'show_price' => array(
|
| 156 |
-
'type' => 'checkbox',
|
| 157 |
-
'std' => absint( $this->defaults['show_price'] ),
|
| 158 |
-
'label' => __( 'Show Price?', 'gencwooc' ),
|
| 159 |
-
),
|
| 160 |
-
'more_from_category' => array(
|
| 161 |
-
'type' => 'checkbox',
|
| 162 |
-
'std' => absint( $this->defaults['more_from_category'] ),
|
| 163 |
-
'label' => __( 'Show Category Archive Link?', 'gencwooc' ),
|
| 164 |
-
),
|
| 165 |
-
'more_from_category_text' => array(
|
| 166 |
-
'type' => 'text',
|
| 167 |
-
'std' => esc_html( $this->defaults['more_from_category_text'] ),
|
| 168 |
-
'label' => __( 'Link Text:', 'gencwooc' ),
|
| 169 |
-
),
|
| 170 |
-
);
|
| 171 |
-
|
| 172 |
-
parent::__construct();
|
| 173 |
-
|
| 174 |
-
}
|
| 175 |
-
|
| 176 |
-
/**
|
| 177 |
-
* Callback on the `admin_init` action.
|
| 178 |
-
* Sets the product_cat options using get_featured_product_categories()
|
| 179 |
-
* after the product_cat taxonomy has been registered.
|
| 180 |
-
*
|
| 181 |
-
* @return void
|
| 182 |
-
*/
|
| 183 |
-
public function set_featured_products() {
|
| 184 |
-
|
| 185 |
-
$this->settings['product_cat']['options'] = $this->get_featured_product_categories();
|
| 186 |
-
|
| 187 |
-
}
|
| 188 |
-
|
| 189 |
-
/**
|
| 190 |
-
* Function to retrieve the actual product categories as an assosiative
|
| 191 |
-
* array. Used to output a dropdown in the widget settings.
|
| 192 |
-
*
|
| 193 |
-
* @return array Associative array of product categories.
|
| 194 |
-
*/
|
| 195 |
-
public function get_featured_product_categories() {
|
| 196 |
-
|
| 197 |
-
$cats = get_terms( 'product_cat' );
|
| 198 |
-
$options = array(
|
| 199 |
-
'' => __( 'All Categories', 'gencwooc' ),
|
| 200 |
-
);
|
| 201 |
-
|
| 202 |
-
if ( ! empty( $cats ) && ! is_wp_error( $cats ) ) {
|
| 203 |
-
foreach( $cats as $cat ) {
|
| 204 |
-
$options[$cat->slug] = $cat->name;
|
| 205 |
-
}
|
| 206 |
-
}
|
| 207 |
-
|
| 208 |
-
return $options;
|
| 209 |
-
|
| 210 |
-
}
|
| 211 |
-
|
| 212 |
-
/**
|
| 213 |
-
* Function to retrieve an associative array containing all possible
|
| 214 |
-
* featured image sizes to be used.
|
| 215 |
-
*
|
| 216 |
-
* @return array Associative array containg possible image sizes and dimensions.
|
| 217 |
-
*/
|
| 218 |
-
public function get_featured_image_sizes() {
|
| 219 |
-
|
| 220 |
-
$options = [];
|
| 221 |
-
$images = genesis_get_image_sizes();
|
| 222 |
-
|
| 223 |
-
foreach( $images as $size => $data ) {
|
| 224 |
-
|
| 225 |
-
$name = sprintf( '%s: %s x %s', $size, $data['width'], $data['height'] );
|
| 226 |
-
$options[ $size ] = $name;
|
| 227 |
-
|
| 228 |
-
}
|
| 229 |
-
|
| 230 |
-
return $options;
|
| 231 |
-
|
| 232 |
-
}
|
| 233 |
-
|
| 234 |
-
/**
|
| 235 |
-
* Main function to retrieve a WP_Query object with appropriate arguments passed in from the instance.
|
| 236 |
-
*
|
| 237 |
-
* @param array $instance Instance arguments to be used in the query.
|
| 238 |
-
* @return object New WP_Query object to be looped through.
|
| 239 |
-
*/
|
| 240 |
-
public function get_featured_products( $args, $instance ) {
|
| 241 |
-
$cat = ! empty( $instance['product_cat'] ) ? sanitize_title( $instance['product_cat'] ) : $this->settings['product_cat']['std'];
|
| 242 |
-
$count = ! empty( $instance['product_num'] ) ? absint( $instance['product_num'] ) : $this->settings['product_num']['std'];
|
| 243 |
-
$offset = ! empty( $instance['product_offset'] ) ? absint( $instance['product_offset'] ) : $this->settings['product_offset']['std'];
|
| 244 |
-
|
| 245 |
-
$orderby = ! empty( $instance['orderby'] ) ? sanitize_title( $instance['orderby'] ) : $this->settings['orderby']['std'];
|
| 246 |
-
$order = ! empty( $instance['order'] ) ? sanitize_title( $instance['order'] ) : $this->settings['order']['std'];
|
| 247 |
-
$product_show = ! empty( $instance['product_show'] ) ? sanitize_title( $instance['product_show'] ) : $this->settings['product_show']['std'];
|
| 248 |
-
$product_visibility_term_ids = wc_get_product_visibility_term_ids();
|
| 249 |
-
|
| 250 |
-
$query_args = array(
|
| 251 |
-
'post_type' => 'product',
|
| 252 |
-
'cat' => $cat,
|
| 253 |
-
'showposts' => $count,
|
| 254 |
-
'offset' => $offset,
|
| 255 |
-
'order' => $order,
|
| 256 |
-
'tax_query' => array(
|
| 257 |
-
'relation' => 'AND',
|
| 258 |
-
),
|
| 259 |
-
);
|
| 260 |
-
|
| 261 |
-
switch ( $product_show ) {
|
| 262 |
-
case 'featured':
|
| 263 |
-
$query_args['tax_query'][] = array(
|
| 264 |
-
'taxonomy' => 'product_visibility',
|
| 265 |
-
'field' => 'term_taxonomy_id',
|
| 266 |
-
'terms' => $product_visibility_term_ids['featured'],
|
| 267 |
-
);
|
| 268 |
-
break;
|
| 269 |
-
case 'onsale':
|
| 270 |
-
$product_ids_on_sale = wc_get_product_ids_on_sale();
|
| 271 |
-
$product_ids_on_sale[] = 0;
|
| 272 |
-
$query_args['post__in'] = $product_ids_on_sale;
|
| 273 |
-
break;
|
| 274 |
-
}
|
| 275 |
-
|
| 276 |
-
if ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) ) {
|
| 277 |
-
$query_args['tax_query'] = array(
|
| 278 |
-
array(
|
| 279 |
-
'taxonomy' => 'product_visibility',
|
| 280 |
-
'field' => 'term_taxonomy_id',
|
| 281 |
-
'terms' => $product_visibility_term_ids['outofstock'],
|
| 282 |
-
'operator' => 'NOT IN',
|
| 283 |
-
),
|
| 284 |
-
);
|
| 285 |
-
}
|
| 286 |
-
|
| 287 |
-
if ( empty( $instance['show_hidden'] ) ) {
|
| 288 |
-
$query_args['tax_query'][] = array(
|
| 289 |
-
'taxonomy' => 'product_visibility',
|
| 290 |
-
'field' => 'term_taxonomy_id',
|
| 291 |
-
'terms' => is_search() ? $product_visibility_term_ids['exclude-from-search'] : $product_visibility_term_ids['exclude-from-catalog'],
|
| 292 |
-
'operator' => 'NOT IN',
|
| 293 |
-
);
|
| 294 |
-
$query_args['post_parent'] = 0;
|
| 295 |
-
}
|
| 296 |
-
|
| 297 |
-
if ( ! empty( $instance['hide_free'] ) ) {
|
| 298 |
-
// Meta query ensures price and sale price are not explicitly set
|
| 299 |
-
// to a zero-like string. Empty pricing fields do not count as
|
| 300 |
-
// a free product. WooCommerce shows no purchase buttons for those.
|
| 301 |
-
$query_args['meta_query'][] = array(
|
| 302 |
-
'relation' => 'AND',
|
| 303 |
-
array(
|
| 304 |
-
'key' => '_price',
|
| 305 |
-
'value' => array( '0', '00', '000', '0000', '0.00', '0,00' ),
|
| 306 |
-
'compare' => 'NOT IN',
|
| 307 |
-
),
|
| 308 |
-
array(
|
| 309 |
-
'key' => '_sale_price',
|
| 310 |
-
'value' => array( '0', '00', '000', '0000', '0.00', '0,00' ),
|
| 311 |
-
'compare' => 'NOT IN',
|
| 312 |
-
),
|
| 313 |
-
);
|
| 314 |
-
}
|
| 315 |
-
|
| 316 |
-
switch ( $orderby ) {
|
| 317 |
-
case 'price':
|
| 318 |
-
$query_args['meta_key'] = '_price';
|
| 319 |
-
$query_args['orderby'] = 'meta_value_num';
|
| 320 |
-
break;
|
| 321 |
-
case 'rand':
|
| 322 |
-
$query_args['orderby'] = 'rand';
|
| 323 |
-
break;
|
| 324 |
-
case 'sales':
|
| 325 |
-
$query_args['meta_key'] = 'total_sales';
|
| 326 |
-
$query_args['orderby'] = 'meta_value_num';
|
| 327 |
-
break;
|
| 328 |
-
default:
|
| 329 |
-
$query_args['orderby'] = 'date';
|
| 330 |
-
}
|
| 331 |
-
|
| 332 |
-
return new WP_Query( apply_filters( 'genwoo_featured_products_widget_query_args', $query_args ) );
|
| 333 |
-
}
|
| 334 |
-
|
| 335 |
-
/**
|
| 336 |
-
* Echo the widget content.
|
| 337 |
-
*
|
| 338 |
-
* @since 0.9.9
|
| 339 |
-
*
|
| 340 |
-
* @global WP_Query $product Product (post) object.
|
| 341 |
-
*
|
| 342 |
-
* @param array $args Display arguments including `before_title`, `after_title`,
|
| 343 |
-
* `before_widget`, and `after_widget`.
|
| 344 |
-
* @param array $instance The settings for the particular instance of the widget.
|
| 345 |
-
*/
|
| 346 |
-
public function widget( $args, $instance ) {
|
| 347 |
-
|
| 348 |
-
if ( $this->get_cached_widget( $args ) ) {
|
| 349 |
-
return;
|
| 350 |
-
}
|
| 351 |
-
|
| 352 |
-
ob_start();
|
| 353 |
-
|
| 354 |
-
$instance = wp_parse_args( $instance, $this->defaults );
|
| 355 |
-
|
| 356 |
-
if ( ( $products = $this->get_featured_products( $args, $instance ) ) && $products->have_posts() ) {
|
| 357 |
-
$this->widget_start( $args, $instance );
|
| 358 |
-
|
| 359 |
-
genesis_markup( array(
|
| 360 |
-
'open' => '<ul %s>',
|
| 361 |
-
'context' => 'featured-products-list',
|
| 362 |
-
));
|
| 363 |
-
|
| 364 |
-
while ( $products->have_posts() ) {
|
| 365 |
-
$products->the_post();
|
| 366 |
-
|
| 367 |
-
global $product;
|
| 368 |
-
|
| 369 |
-
genesis_markup(array(
|
| 370 |
-
'open' => '<li %s>',
|
| 371 |
-
'context' => 'entry-product',
|
| 372 |
-
));
|
| 373 |
-
|
| 374 |
-
$image = genesis_get_image( array(
|
| 375 |
-
'format' => 'html',
|
| 376 |
-
'size' => $instance['image_size'],
|
| 377 |
-
'context' => 'featured-product-image',
|
| 378 |
-
'attr' => genesis_parse_attr( 'featured-product-image', array ( 'alt' => get_the_title() ) ),
|
| 379 |
-
) );
|
| 380 |
-
|
| 381 |
-
if ( $image && $instance['show_image'] ) {
|
| 382 |
-
if ( $instance['link_image'] ) {
|
| 383 |
-
printf( '<a href="%s" class="entry-image-wrap">%s</a>', get_permalink(), wp_make_content_images_responsive( $image ) );
|
| 384 |
-
} else {
|
| 385 |
-
printf( '<div class="entry-image-wrap">%s</div>', wp_make_content_images_responsive( $image ) );
|
| 386 |
-
}
|
| 387 |
-
}
|
| 388 |
-
|
| 389 |
-
if ( $instance['show_title'] ) {
|
| 390 |
-
|
| 391 |
-
$header = '';
|
| 392 |
-
|
| 393 |
-
if ( ! empty( $instance['show_title'] ) ) {
|
| 394 |
-
|
| 395 |
-
$title = get_the_title() ? get_the_title() : __( '(no title)', 'gencwooc' );
|
| 396 |
-
|
| 397 |
-
/**
|
| 398 |
-
* Filter the featured post widget title.
|
| 399 |
-
*
|
| 400 |
-
* @since 2.2.0
|
| 401 |
-
*
|
| 402 |
-
* @param string $title Featured post title.
|
| 403 |
-
* @param array $instance {
|
| 404 |
-
* Widget settings for this instance.
|
| 405 |
-
*
|
| 406 |
-
* @type string $title Widget title.
|
| 407 |
-
* @type int $product_cat ID of the post category.
|
| 408 |
-
* @type int $product_num Number of posts to show.
|
| 409 |
-
* @type int $product_offset Number of posts to skip when
|
| 410 |
-
* retrieving.
|
| 411 |
-
* @type string $orderby Field to order posts by.
|
| 412 |
-
* @type string $order ASC fr ascending order, DESC for
|
| 413 |
-
* descending order of posts.
|
| 414 |
-
* @type bool $show_image True if featured image should be
|
| 415 |
-
* shown, false otherwise.
|
| 416 |
-
* @type bool $show_hidden True if hidden products should be
|
| 417 |
-
* shown, false otherwise.
|
| 418 |
-
* @type string $image_size Name of the image size.
|
| 419 |
-
* @type bool $show_title True if featured page title should
|
| 420 |
-
* be shown, false otherwise.
|
| 421 |
-
* @type int $extra_num Number of extra post titles to show.
|
| 422 |
-
* @type string $extra_title Heading for extra posts.
|
| 423 |
-
* @type bool $more_from_category True if showing category archive
|
| 424 |
-
* link, false otherwise.
|
| 425 |
-
* @type string $more_from_category_text Category archive link text.
|
| 426 |
-
* }
|
| 427 |
-
* @param array $args {
|
| 428 |
-
* Widget display arguments.
|
| 429 |
-
*
|
| 430 |
-
* @type string $before_widget Markup or content to display before the widget.
|
| 431 |
-
* @type string $before_title Markup or content to display before the widget title.
|
| 432 |
-
* @type string $after_title Markup or content to display after the widget title.
|
| 433 |
-
* @type string $after_widget Markup or content to display after the widget.
|
| 434 |
-
* }
|
| 435 |
-
*/
|
| 436 |
-
$title = apply_filters( 'genesis_featured_product_title', $title, $instance, $args );
|
| 437 |
-
$heading = genesis_a11y( 'headings' ) ? 'h4' : 'h2';
|
| 438 |
-
|
| 439 |
-
$header .= genesis_markup( array(
|
| 440 |
-
'open' => "<{$heading} %s>",
|
| 441 |
-
'close' => "</{$heading}>",
|
| 442 |
-
'context' => 'entry-product-title',
|
| 443 |
-
'content' => sprintf( '<a href="%s">%s</a>', get_permalink(), $title ),
|
| 444 |
-
'echo' => false,
|
| 445 |
-
) );
|
| 446 |
-
|
| 447 |
-
}
|
| 448 |
-
|
| 449 |
-
genesis_markup( array(
|
| 450 |
-
'open' => '<header %s>',
|
| 451 |
-
'close' => '</header>',
|
| 452 |
-
'context' => 'entry-product-header',
|
| 453 |
-
'content' => $header,
|
| 454 |
-
));
|
| 455 |
-
|
| 456 |
-
}
|
| 457 |
-
|
| 458 |
-
if ( $instance['show_price'] && $product->get_price_html() ) {
|
| 459 |
-
printf( '<span class="price">%s</span>', $product->get_price_html() );
|
| 460 |
-
}
|
| 461 |
-
|
| 462 |
-
if ( $instance['show_add_to_cart'] ) {
|
| 463 |
-
woocommerce_template_loop_add_to_cart( $product->get_id() );
|
| 464 |
-
}
|
| 465 |
-
|
| 466 |
-
genesis_markup( array(
|
| 467 |
-
'close' => '</li>',
|
| 468 |
-
'context' => 'entry-product',
|
| 469 |
-
));
|
| 470 |
-
|
| 471 |
-
}
|
| 472 |
-
|
| 473 |
-
genesis_markup( array(
|
| 474 |
-
'close' => '</ul>',
|
| 475 |
-
'context' => 'featured-products-list',
|
| 476 |
-
));
|
| 477 |
-
|
| 478 |
-
if ( $instance['more_from_category'] && $instance['product_cat'] !== '' ) {
|
| 479 |
-
|
| 480 |
-
$cat = get_term_by( 'name', $instance['product_cat'], 'product_cat' );
|
| 481 |
-
|
| 482 |
-
printf(
|
| 483 |
-
'<p class="more-from-category"><a href="%1$s" title="%2$s">%3$s</a></p>',
|
| 484 |
-
esc_url( get_term_link( $cat->term_taxonomy_id ) ),
|
| 485 |
-
esc_attr( $cat->name ),
|
| 486 |
-
esc_html( $instance['more_from_category_text'] )
|
| 487 |
-
);
|
| 488 |
-
}
|
| 489 |
-
|
| 490 |
-
$this->widget_end( $args );
|
| 491 |
-
|
| 492 |
-
}
|
| 493 |
-
|
| 494 |
-
// Restore original query.
|
| 495 |
-
wp_reset_postdata();
|
| 496 |
-
|
| 497 |
-
echo $this->cache_widget( $args, ob_get_clean() );
|
| 498 |
-
|
| 499 |
-
}
|
| 500 |
-
|
| 501 |
-
}
|
| 502 |
-
|
| 503 |
-
add_action( 'widgets_init', 'gencwooc_register_featured_products_widget' );
|
| 504 |
-
function gencwooc_register_featured_products_widget() {
|
| 505 |
-
register_widget( 'Gencwooc_Featured_Products' );
|
| 506 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
