Version Description
- Initial Release
Download this release
Release Info
Developer | studiograsshopper |
Plugin | Genesis Connect for WooCommerce |
Version | 0.9.0 |
Comparing to | |
See all releases |
Version 0.9.0
- genesis-connect-woocommerce.php +110 -0
- lib/breadcrumb.php +226 -0
- lib/template-loader.php +142 -0
- readme.txt +140 -0
- sp-plugins-integration/genesis-simple-menus.php +67 -0
- sp-plugins-integration/genesis-simple-sidebars.php +136 -0
- templates/archive-product.php +102 -0
- templates/single-product.php +86 -0
- templates/taxonomy.php +56 -0
genesis-connect-woocommerce.php
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Genesis Connect for WooCommerce
|
4 |
+
Plugin URI: http://www.studiopress.com/plugins/genesis-connect-woocommerce
|
5 |
+
Version: 0.9.0
|
6 |
+
Author: StudioPress
|
7 |
+
Author URI: http://www.studiopress.com/
|
8 |
+
Description: Allows you to seamlessly integrate WooCommerce with the Genesis Framework and Genesis child themes.
|
9 |
+
|
10 |
+
License: GNU General Public License v2.0 (or later)
|
11 |
+
License URI: http://www.opensource.org/licenses/gpl-license.php
|
12 |
+
|
13 |
+
Special thanks to Ade Walker (http://www.studiograsshopper.ch/) for his contributions to this plugin.
|
14 |
+
*/
|
15 |
+
|
16 |
+
register_activation_hook( __FILE__, 'gencwooc_activation' );
|
17 |
+
/**
|
18 |
+
* Check the environment when plugin is activated
|
19 |
+
*
|
20 |
+
* Requirements:
|
21 |
+
* - WooCommerce needs to be installed and activated
|
22 |
+
* - Child theme needs to have add_theme_support( 'genesis-connect-woocommerce' ) in functions.php
|
23 |
+
*
|
24 |
+
* Note: register_activation_hook() isn't run after auto or manual upgrade, only on activation
|
25 |
+
* Note: this version of GCW is based on WooCommerce 1.4.4
|
26 |
+
*
|
27 |
+
* @since 0.9.0
|
28 |
+
*/
|
29 |
+
function gencwooc_activation() {
|
30 |
+
|
31 |
+
$message = '';
|
32 |
+
|
33 |
+
if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
|
34 |
+
$message .= sprintf( '<br /><br />%s', __( 'Install and activate the WooCommerce plugin.', 'gencwooc') );
|
35 |
+
}
|
36 |
+
|
37 |
+
if ( ! current_theme_supports( 'genesis-connect-woocommerce' ) ) {
|
38 |
+
$message .= sprintf( '<br /><br />%s<br />%s', __( "Add this code to your child theme's functions.php:", 'gencwooc' ), "<code> add_theme_support( 'genesis-connect-woocommerce' );</code>" );
|
39 |
+
}
|
40 |
+
|
41 |
+
if ( ! empty( $message ) ) {
|
42 |
+
|
43 |
+
deactivate_plugins( plugin_basename( __FILE__ ) ); /** Deactivate ourself */
|
44 |
+
|
45 |
+
$message = __( 'Sorry! In order to use the Genesis Connect for WooCommerce plugin you need to do the following:', 'gencwooc' ) . $message;
|
46 |
+
|
47 |
+
wp_die( $message, 'Genesis Connect for WooCommerce Plugin', array( 'back_link' => true ) );
|
48 |
+
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
|
53 |
+
|
54 |
+
/** Define the Genesis Connect for WooCommerce constants */
|
55 |
+
define( 'GCW_TEMPLATE_DIR', dirname( __FILE__ ) . '/templates' );
|
56 |
+
define( 'GCW_LIB_DIR', dirname( __FILE__ ) . '/lib');
|
57 |
+
define( 'GCW_SP_DIR', dirname( __FILE__ ) . '/sp-plugins-integration' );
|
58 |
+
|
59 |
+
|
60 |
+
|
61 |
+
add_action( 'after_setup_theme', 'gencwooc_setup' );
|
62 |
+
/**
|
63 |
+
* Setup GCW
|
64 |
+
*
|
65 |
+
* Checks whether WooCommerce is active, then checks if relevant
|
66 |
+
* theme support exists. Once past these checks, loads the necessary
|
67 |
+
* files, actions and filters for the plugin to do its thing.
|
68 |
+
*
|
69 |
+
* @since 0.9.0
|
70 |
+
*/
|
71 |
+
function gencwooc_setup() {
|
72 |
+
|
73 |
+
/** Fail silently if WooCommerce is not activated */
|
74 |
+
if ( ! in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) )
|
75 |
+
return;
|
76 |
+
|
77 |
+
/** Fail silently if theme doesn't support GCW */
|
78 |
+
if ( ! current_theme_supports( 'genesis-connect-woocommerce' ) )
|
79 |
+
return;
|
80 |
+
|
81 |
+
/** Environment is OK, let's go! */
|
82 |
+
|
83 |
+
global $woocommerce;
|
84 |
+
|
85 |
+
/** Load GCW files */
|
86 |
+
require_once( GCW_LIB_DIR . '/template-loader.php' );
|
87 |
+
|
88 |
+
/** Load modified Genesis breadcrumb filters and callbacks */
|
89 |
+
if ( ! current_theme_supports( 'gencwooc-woo-breadcrumbs') )
|
90 |
+
require_once( GCW_LIB_DIR . '/breadcrumb.php' );
|
91 |
+
|
92 |
+
/** Add Genesis Layout and SEO options to Product edit screen */
|
93 |
+
add_post_type_support( 'product', array( 'genesis-layouts', 'genesis-seo' ) );
|
94 |
+
|
95 |
+
/** Add Studiopress plugins support */
|
96 |
+
add_post_type_support( 'product', array( 'genesis-simple-sidebars', 'genesis-simple-menus' ) );
|
97 |
+
|
98 |
+
/** Take control of shop template loading */
|
99 |
+
remove_filter( 'template_include', array( &$woocommerce, 'template_loader' ) );
|
100 |
+
add_filter( 'template_include', 'gencwooc_template_loader', 20 );
|
101 |
+
|
102 |
+
/** Integration - Genesis Simple Sidebars */
|
103 |
+
if ( in_array( 'genesis-simple-sidebars/plugin.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) )
|
104 |
+
require_once( GCW_SP_DIR . '/genesis-simple-sidebars.php' );
|
105 |
+
|
106 |
+
/** Integration - Genesis Simple Menus */
|
107 |
+
if ( in_array( 'genesis-simple-menus/simple-menu.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) )
|
108 |
+
require_once( GCW_SP_DIR . '/genesis-simple-menus.php' );
|
109 |
+
|
110 |
+
}
|
lib/breadcrumb.php
ADDED
@@ -0,0 +1,226 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file contains functions related modifying Genesis Breadcrumb output
|
4 |
+
*
|
5 |
+
* @since 0.9.0
|
6 |
+
*
|
7 |
+
*
|
8 |
+
* By default, the Genesis Breadcrumb class does not handle Shop pages and taxonomy
|
9 |
+
* archives in the same way as WooC's breadcrumbs. These filters and callback
|
10 |
+
* functions modify the default Genesis breadcrumb output so that the breadcrumb
|
11 |
+
* trail mimics that of WooC's breadcrumbs, for:
|
12 |
+
* - Shop page (archive page)
|
13 |
+
* - Single product
|
14 |
+
* - Taxonomy archive
|
15 |
+
*
|
16 |
+
* Users who prefer to use WooC's 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.
|
26 |
+
* If this is the case, adjusting the filter callback priority in existing filter calls
|
27 |
+
* should ensure that each filter callback is called in the correct order.
|
28 |
+
*
|
29 |
+
* @see genesis/lib/classes/breadcrumb.php v1.8
|
30 |
+
* @see woocommerce/templates/shop/breadcrumb.php v1.4.4
|
31 |
+
*
|
32 |
+
* @TODO Replace with subclass of Genesis_Breadcrumb?
|
33 |
+
*/
|
34 |
+
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Prevent direct access to this file
|
38 |
+
*/
|
39 |
+
if ( ! defined( 'ABSPATH' ) )
|
40 |
+
exit( __( 'Sorry, you are not allowed to access this file directly.', 'genwooc' ) );
|
41 |
+
|
42 |
+
|
43 |
+
|
44 |
+
add_filter( 'genesis_archive_crumb', 'gencwooc_get_archive_crumb_filter', 10, 2 );
|
45 |
+
/**
|
46 |
+
* Filter the Genesis Breadcrumbs archive crumb
|
47 |
+
*
|
48 |
+
* Needed for Product Archive (Shop page) and Taxonomy archives
|
49 |
+
*
|
50 |
+
* Note: relevant WooCommerce settings (WooCommerce > Settings > Pages tab):
|
51 |
+
* - woocommerce_prepend_shop_page_to_urls (breadcrumbs and permalinks)
|
52 |
+
* - woocommerce_prepend_shop_page_to_products (permalinks only)
|
53 |
+
* - woocommerce_prepend_category_to_products (permalinks only)
|
54 |
+
*
|
55 |
+
* @since 0.9.0
|
56 |
+
*
|
57 |
+
* @param str $crumb Breadcrumb 'crumb' for archives
|
58 |
+
* @param array $args Genesis Breadcrumb args
|
59 |
+
* @return str $crumb, either modified $crumb, or original $crumb
|
60 |
+
*/
|
61 |
+
function gencwooc_get_archive_crumb_filter( $crumb, $args ) {
|
62 |
+
|
63 |
+
/** Are we on the product archive page? */
|
64 |
+
if ( is_post_type_archive( 'product') && get_option( 'page_on_front' ) !== woocommerce_get_page_id( 'shop' ) ) {
|
65 |
+
|
66 |
+
$shop_id = woocommerce_get_page_id( 'shop' );
|
67 |
+
|
68 |
+
$shop_name = $shop_id ? get_the_title( $shop_id ) : ucwords( get_option('woocommerce_shop_slug') );
|
69 |
+
|
70 |
+
if ( is_search() ) :
|
71 |
+
|
72 |
+
$crumb = gencwooc_get_crumb_link( get_post_type_archive_link( 'product' ), $shop_name, $shop_name, $args['sep'] . __( 'Search results for “', 'woocommerce' ) . get_search_query() . '”' );
|
73 |
+
|
74 |
+
else :
|
75 |
+
|
76 |
+
$crumb = gencwooc_get_crumb_link( get_post_type_archive_link( 'product' ), $shop_name, $shop_name );
|
77 |
+
|
78 |
+
endif;
|
79 |
+
|
80 |
+
return apply_filters( 'gencwooc_product_archive_crumb', $crumb, $args );
|
81 |
+
}
|
82 |
+
|
83 |
+
|
84 |
+
/** Are we on a shop taxonomy archive page? */
|
85 |
+
if ( is_tax( 'product_cat' ) || is_tax( 'product_tag' ) ) {
|
86 |
+
|
87 |
+
$crumb = '';
|
88 |
+
|
89 |
+
$prepend = '';
|
90 |
+
|
91 |
+
/** Should we prepend crumb with 'shop' page link? */
|
92 |
+
/** See Dashboard > WooC Settings > Pages tab */
|
93 |
+
$shop_url = get_option( 'woocommerce_prepend_shop_page_to_urls' );
|
94 |
+
$shop_id = woocommerce_get_page_id( 'shop' );
|
95 |
+
$shop_title = get_the_title( $shop_id );
|
96 |
+
|
97 |
+
if ( 'yes' == $shop_url && $shop_id && get_option( 'page_on_front' ) !== $shop_id )
|
98 |
+
$prepend = gencwooc_get_crumb_link( get_permalink( $shop_id ), $shop_title, $shop_title, $args['sep'] );
|
99 |
+
|
100 |
+
}
|
101 |
+
|
102 |
+
if ( is_tax( 'product_cat' ) ) {
|
103 |
+
|
104 |
+
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
|
105 |
+
|
106 |
+
$parents = array();
|
107 |
+
$parent = $term->parent;
|
108 |
+
while ( $parent ):
|
109 |
+
$parents[] = $parent;
|
110 |
+
$new_parent = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ) );
|
111 |
+
$parent = $new_parent->parent;
|
112 |
+
endwhile;
|
113 |
+
|
114 |
+
$crumb .= $prepend;
|
115 |
+
|
116 |
+
if ( ! empty( $parents ) ) :
|
117 |
+
$parents = array_reverse( $parents );
|
118 |
+
foreach ( $parents as $parent ) :
|
119 |
+
$item = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ) );
|
120 |
+
$crumb .= gencwooc_get_crumb_link( get_term_link( $item->slug, 'product_cat' ), $item->name, $item->name, $args['sep'] );
|
121 |
+
endforeach;
|
122 |
+
endif;
|
123 |
+
|
124 |
+
$crumb .= single_term_title( '', false );
|
125 |
+
|
126 |
+
return $crumb;
|
127 |
+
}
|
128 |
+
|
129 |
+
if ( is_tax( 'product_tag' ) ) {
|
130 |
+
|
131 |
+
$crumb .= $prepend . __( 'Products tagged “', 'gencwooc' ) . single_term_title( '', false ) . _x( '”', 'endquote', 'gencwooc' );
|
132 |
+
|
133 |
+
return $crumb;
|
134 |
+
}
|
135 |
+
|
136 |
+
/** Original unmodified */
|
137 |
+
return $crumb;
|
138 |
+
}
|
139 |
+
|
140 |
+
|
141 |
+
add_filter( 'genesis_single_crumb', 'gencwooc_get_single_crumb', 10, 2 );
|
142 |
+
/**
|
143 |
+
* Filter the Genesis Breadcrumbs singular crumb
|
144 |
+
*
|
145 |
+
* Needed for single Product pages
|
146 |
+
*
|
147 |
+
* @since 0.9.0
|
148 |
+
*
|
149 |
+
* @param str $crumb Breadcrumb 'crumb' for single posts
|
150 |
+
* @param array $args Genesis Breadcrumb args
|
151 |
+
* @return str $crumb, either modified $crumb, or original $crumb
|
152 |
+
*/
|
153 |
+
function gencwooc_get_single_crumb( $crumb, $args ) {
|
154 |
+
|
155 |
+
/** Are we on a single product page? */
|
156 |
+
if ( is_singular( 'product' ) ) {
|
157 |
+
|
158 |
+
global $post;
|
159 |
+
|
160 |
+
$crumb = '';
|
161 |
+
$prepend = '';
|
162 |
+
|
163 |
+
/** Should we prepend crumb with 'shop' page link? */
|
164 |
+
/** See Dashboard > WooC Settings > Pages tab */
|
165 |
+
$shop_url = get_option( 'woocommerce_prepend_shop_page_to_urls' );
|
166 |
+
$shop_id = woocommerce_get_page_id( 'shop' );
|
167 |
+
$shop_title = get_the_title( $shop_id );
|
168 |
+
|
169 |
+
if ( 'yes' == $shop_url && $shop_id && get_option( 'page_on_front' ) !== $shop_id )
|
170 |
+
$prepend = gencwooc_get_crumb_link( get_permalink( $shop_id ), $shop_title, $shop_title, $args['sep'] );
|
171 |
+
|
172 |
+
$crumb .= $prepend;
|
173 |
+
|
174 |
+
if ( $terms = wp_get_object_terms( $post->ID, 'product_cat' ) ) :
|
175 |
+
$term = current( $terms );
|
176 |
+
$parents = array();
|
177 |
+
$parent = $term->parent;
|
178 |
+
while ( $parent ):
|
179 |
+
$parents[] = $parent;
|
180 |
+
$new_parent = get_term_by( 'id', $parent, 'product_cat' );
|
181 |
+
$parent = $new_parent->parent;
|
182 |
+
endwhile;
|
183 |
+
|
184 |
+
if( ! empty( $parents ) ):
|
185 |
+
$parents = array_reverse( $parents );
|
186 |
+
foreach ( $parents as $parent ) :
|
187 |
+
$item = get_term_by( 'id', $parent, 'product_cat' );
|
188 |
+
$crumb .= gencwooc_get_crumb_link( get_term_link( $item->slug, 'product_cat' ), $item->name, $item->name, $args['sep'] );
|
189 |
+
endforeach;
|
190 |
+
endif;
|
191 |
+
$crumb .= gencwooc_get_crumb_link( get_term_link( $term->slug, 'product_cat' ), $term->name, $term->name, $args['sep'] );
|
192 |
+
endif;
|
193 |
+
|
194 |
+
$crumb .= get_the_title();
|
195 |
+
|
196 |
+
return apply_filters( 'gencwooc_single_product_crumb', $crumb, $args );
|
197 |
+
}
|
198 |
+
|
199 |
+
/** Fallback - original unmodified */
|
200 |
+
return $crumb;
|
201 |
+
}
|
202 |
+
|
203 |
+
|
204 |
+
/**
|
205 |
+
* Helper function to create anchor link for a single crumb.
|
206 |
+
*
|
207 |
+
* This is a copy of Genesis_Breadcrumb::get_breadcrumb_link() (G1.8)
|
208 |
+
*
|
209 |
+
* @since 0.9.0
|
210 |
+
*
|
211 |
+
* @param string $url URL for href attribute
|
212 |
+
* @param string $title title attribute
|
213 |
+
* @param string $content linked content
|
214 |
+
* @param string $sep Separator
|
215 |
+
* @return string HTML markup for anchor link and optional separator.
|
216 |
+
*/
|
217 |
+
function gencwooc_get_crumb_link( $url, $title, $content, $sep = false ) {
|
218 |
+
|
219 |
+
$link = sprintf( '<a href="%s" title="%s">%s</a>', esc_attr( $url ), esc_attr( $title ), esc_html( $content ) );
|
220 |
+
|
221 |
+
if ( $sep )
|
222 |
+
$link .= $sep;
|
223 |
+
|
224 |
+
return $link;
|
225 |
+
|
226 |
+
}
|
lib/template-loader.php
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* These functions manage loading of templates for WooCommerce
|
4 |
+
*
|
5 |
+
* @since 0.9.0
|
6 |
+
*
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Prevent direct access to this file
|
11 |
+
*/
|
12 |
+
if ( ! defined( 'ABSPATH' ) )
|
13 |
+
exit( __( 'Sorry, you are not allowed to access this file directly.', 'genwooc' ) );
|
14 |
+
|
15 |
+
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Load the Genesis-fied templates, instead of the WooCommerce defaults.
|
19 |
+
*
|
20 |
+
* Hooked to 'template_include' filter
|
21 |
+
*
|
22 |
+
* This template loader determines which template file will be used for the requested page, and uses the
|
23 |
+
* following hierarchy to find the template:
|
24 |
+
* 1. First looks in the child theme's 'woocommerce' folder.
|
25 |
+
* 2. If no template found, falls back to GCW's templates.
|
26 |
+
*
|
27 |
+
* For taxonomy templates, first looks in child theme's 'woocommerce' folder and searches for term specific template,
|
28 |
+
* then taxonomy specific template, then taxonomy.php. If no template found, falls back to GCW's taxonomy.php.
|
29 |
+
*
|
30 |
+
* GCW provides three templates in the plugin's 'templates' directory:
|
31 |
+
* - single-product.php
|
32 |
+
* - archive-product.php
|
33 |
+
* - taxonomy.php
|
34 |
+
*
|
35 |
+
* Users can override GCW templates by placing their own templates in their child theme's 'woocommerce' folder.
|
36 |
+
* The 'woocommerce' folder must be a folder in the child theme's root directory, eg themes/my-child-theme/woocommerce
|
37 |
+
* Permitted user templates (as per WP Template Hierarchy) are:
|
38 |
+
* - single-product.php
|
39 |
+
* - archive-product.php
|
40 |
+
* - taxonomy-{taxonomy-name}-{term-name}.php
|
41 |
+
* - taxonomy-{taxonomy-name}.php
|
42 |
+
* - taxonomy.php
|
43 |
+
*
|
44 |
+
* Note that in the case of taxonomy templates, this function accommodates ALL taxonomies registered to the
|
45 |
+
* 'product' custom post type. This means that it will cater for users' own custom taxonomies as well as WooC's.
|
46 |
+
*
|
47 |
+
* @since 0.9.0
|
48 |
+
*
|
49 |
+
* @param string $template Template file as per template hierarchy
|
50 |
+
* @return string $template Specific GCW template if a product page (single or archive)
|
51 |
+
* or a product taxonomy term, or returns original template
|
52 |
+
*/
|
53 |
+
function gencwooc_template_loader( $template ) {
|
54 |
+
|
55 |
+
|
56 |
+
if ( is_single() && 'product' == get_post_type() ) {
|
57 |
+
|
58 |
+
$template = locate_template( array( 'woocommerce/single-product.php' ) );
|
59 |
+
|
60 |
+
if ( ! $template )
|
61 |
+
$template = GCW_TEMPLATE_DIR . '/single-product.php';
|
62 |
+
|
63 |
+
}
|
64 |
+
elseif ( is_post_type_archive( 'product' ) || is_page( get_option( 'woocommerce_shop_page_id' ) ) ) {
|
65 |
+
|
66 |
+
$template = locate_template( array( 'woocommerce/archive-product.php' ) );
|
67 |
+
|
68 |
+
if ( ! $template )
|
69 |
+
$template = GCW_TEMPLATE_DIR . '/archive-product.php';
|
70 |
+
|
71 |
+
}
|
72 |
+
elseif ( is_tax() ) {
|
73 |
+
|
74 |
+
$term = get_query_var( 'term' );
|
75 |
+
|
76 |
+
$tax = get_query_var( 'taxonomy' );
|
77 |
+
|
78 |
+
/** Get an array of all relevant taxonomies */
|
79 |
+
$taxonomies = get_object_taxonomies( 'product', 'names' );
|
80 |
+
|
81 |
+
if ( in_array( $tax, $taxonomies ) ) {
|
82 |
+
|
83 |
+
$tax = sanitize_title( $tax );
|
84 |
+
$term = sanitize_title( $term );
|
85 |
+
|
86 |
+
$templates = array(
|
87 |
+
'woocommerce/taxonomy-'.$tax.'-'.$term.'.php',
|
88 |
+
'woocommerce/taxonomy-'.$tax.'.php',
|
89 |
+
'woocommerce/taxonomy.php',
|
90 |
+
);
|
91 |
+
|
92 |
+
$template = locate_template( $templates );
|
93 |
+
|
94 |
+
/** Fallback to GCW template */
|
95 |
+
if ( ! $template )
|
96 |
+
$template = GCW_TEMPLATE_DIR . '/taxonomy.php';
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
return $template;
|
101 |
+
|
102 |
+
}
|
103 |
+
|
104 |
+
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Shop Loop 'template part' loader
|
108 |
+
*
|
109 |
+
* Function looks for loop-shop.php in child theme's 'woocommerce' folder. If it doesn't exist,
|
110 |
+
* loads the default WooCommerce loop-shop.php file.
|
111 |
+
*
|
112 |
+
* Note: loop-shop.php is used to display products on the archive and taxonomy pages
|
113 |
+
*
|
114 |
+
* Users can override the default WooCommerce loop-shop.php by placing their own template (named loop-shop.php) in
|
115 |
+
* their child theme's 'woocommerce' folder. The'woocommerce' folder must be a folder in the
|
116 |
+
* child theme's root directory, eg themes/my-child-theme/woocommerce.
|
117 |
+
* It is recommended to use woocommerce/templates/loop-shop.php as the starting point of
|
118 |
+
* any custom loop template.
|
119 |
+
*
|
120 |
+
* Based on woocommerce_get_template_part()
|
121 |
+
*
|
122 |
+
* @since 0.9.0
|
123 |
+
* @global object $woocommerce WooCommerce instance
|
124 |
+
*/
|
125 |
+
function gencwooc_get_template_part( $slug, $name = '' ) {
|
126 |
+
|
127 |
+
global $woocommerce;
|
128 |
+
|
129 |
+
if ( 'shop' == $name ) :
|
130 |
+
|
131 |
+
if ( ! locate_template( array( 'woocommerce/loop-shop.php' ) ) ) :
|
132 |
+
|
133 |
+
load_template( $woocommerce->plugin_path() . '/templates/loop-shop.php', false );
|
134 |
+
|
135 |
+
return;
|
136 |
+
|
137 |
+
endif;
|
138 |
+
|
139 |
+
endif;
|
140 |
+
|
141 |
+
get_template_part( $slug, $name );
|
142 |
+
}
|
readme.txt
ADDED
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Plugin Name ===
|
2 |
+
Contributors: nathanrice, studiopress, studiograsshopper
|
3 |
+
Tags: genesis, genesiswp, studiopress, woocommerce
|
4 |
+
Requires at least: 3.3
|
5 |
+
Tested up to: 3.3.1
|
6 |
+
Stable tag: 0.9.0
|
7 |
+
|
8 |
+
This plugin allows you to seamlessly integrate WooCommerce with the Genesis Framework and Genesis child themes.
|
9 |
+
|
10 |
+
== Description ==
|
11 |
+
|
12 |
+
This plugin replaces WooCommerce's built-in shop templates with its own Genesis-ready versions, specifically the `single-product.php`, `archive-product.php` and `taxonomy.php` templates needed to display the single product page, the main shop page, and Product Category and Product Tag archive pages.
|
13 |
+
|
14 |
+
To allow easy customization of these templates, and ensure that you do not lose your customizations when the plugin is updated, you can place your own copies of these templates in your child theme's 'woocommerce' folder and customize these copies as much as you like. You can also create your own `taxonomy-{taxonomy}.php` and `taxonomy-{taxonomy}-{term}.php` templates in the same location and this plugin will find them and use them to display your shop's Product Category and Product Tag archives. See the [Template Hierarchy](http://codex.wordpress.org/Template_Hierarchy#Custom_Taxonomies_display) to learn more about naming requirements for taxonomy templates.
|
15 |
+
|
16 |
+
Additionally, the plugin makes [Genesis Simple Sidebars](http://wordpress.org/extend/plugins/genesis-simple-sidebars/) and [Genesis Simple Menus](http://wordpress.org/extend/plugins/genesis-simple-menus/) compatible with WooCommerce.
|
17 |
+
|
18 |
+
== Installation ==
|
19 |
+
|
20 |
+
1. Upload the entire `genesis-connect-woocommerce` folder to the `/wp-content/plugins/` directory
|
21 |
+
2. DO NOT change the name of the `genesis-connect-woocommerce` folder
|
22 |
+
3. Activate the plugin through the 'Plugins' menu in WordPress
|
23 |
+
4. Add this code to your Genesis child theme's `functions.php` file: `add_theme_support( 'genesis-connect-woocommerce' );`
|
24 |
+
5. That's it. Navigate to your shop pages and you should see the new templates in action.
|
25 |
+
|
26 |
+
Note: You must have a Genesis child theme activated, and WooCommerce installed and activated, before installing and activating this plugin.
|
27 |
+
|
28 |
+
== Frequently Asked Questions ==
|
29 |
+
|
30 |
+
= I've activated the plugin but it does not seem to do anything =
|
31 |
+
|
32 |
+
Make sure you have added this code to your Genesis child theme's `functions.php` file:
|
33 |
+
`add_theme_support( 'genesis-connect-woocommerce' );`
|
34 |
+
|
35 |
+
= Can I customize the Genesis Connect for Woocommerce templates? =
|
36 |
+
|
37 |
+
It's not recommended to customize the plugin's templates because, if you do, you will lose any customizations the next time the plugin is updated. Instead, take copies of the plugin's `single-product.php`, `archive-product.php` and `taxonomy.php` files, and place these copies in a folder called `woocommerce` in the root of your child theme's main folder, like this: `wp-content/themes/my-child-theme/woocommerce/`
|
38 |
+
|
39 |
+
Make sure you keep the same file names!
|
40 |
+
|
41 |
+
The plugin's templates provide a great starting point for your own customizations and can be found in the plugin's `templates` folder.
|
42 |
+
|
43 |
+
= I want to use WooCommerce's breadcrumbs, not Genesis breadcrumbs =
|
44 |
+
|
45 |
+
There's no need! Genesis Connect for WooCommerce modifies the default Genesis breadcrumbs to give the same crumb structure as WooCommerce's built-in breadcrumbs. The modified Genesis breadcrumbs will reflect all your existing Genesis breadcrumb customizations too.
|
46 |
+
|
47 |
+
= What if I want the main Shop page to be the site's front page? =
|
48 |
+
|
49 |
+
1. Go to the *Dashboard > Settings > Reading* page select A Static Page and select "Shop" as the front page.
|
50 |
+
2. It is recommended to turn off Genesis breadcrumbs for the Home page in *Dashboard > Genesis > Theme Settings > Breadcrumb options*.
|
51 |
+
|
52 |
+
= Does it work with Genesis Simple Sidebars? =
|
53 |
+
|
54 |
+
Yes.
|
55 |
+
|
56 |
+
= Does it work with Genesis Simple Sidebars? =
|
57 |
+
|
58 |
+
Yes.
|
59 |
+
|
60 |
+
= How does the plugin handle WooCommerce's CSS? =
|
61 |
+
|
62 |
+
Genesis Connect for WooCommerce does not modify WooCommerce's way of working with CSS. By default, WooCommerce provides its own `woocommerce.css` file containing basic styles for the shop pages which is located here: `wp-content/plugins/woocommerce/assets/css/woocommerce.css`.
|
63 |
+
|
64 |
+
To use this stylesheet, check the "*Enable WooCommerce CSS styles*" checkbox in the *WooCommerce Settings page > General tab*. Alternatively, you can add this code to your child theme's `functions.php` file: `define( 'WOOCOMMERCE_USE_CSS', true );`
|
65 |
+
|
66 |
+
Note that this code takes precedence over the checkbox in the *WooCommerce Settings page > General tab*; in other words, when you use this code, the checkbox is ignored.
|
67 |
+
|
68 |
+
If you decide to use the WooCommerce CSS and wish to customize its styles, do *not* edit the `woocommerce.css` file. Instead, make a copy of this file, rename it `style.css` and place it in your child theme's `woocommerce` folder, and make all your edits in this file. This ensures that you do not lose your CSS customizations when WooCommerce is updated.
|
69 |
+
|
70 |
+
Alternatively, you can add your WooCommerce styles to your child theme's main style.css stylesheet. In this case, you should disable the WooCommerce built-in stylesheet: either uncheck the "*Enable WooCommerce CSS styles*" checkbox in the *WooCommerce Settings page > General tab*, or a better option, add this code to your child theme's `functions.php` file: `define( 'WOOCOMMERCE_USE_CSS', false );`
|
71 |
+
|
72 |
+
If you are using a Genesis child theme specially designed for WooCommerce, refer to the theme's documentation to find out if all of the above has been been taken care of for you already.
|
73 |
+
|
74 |
+
= Where is the plugin's settings page? =
|
75 |
+
|
76 |
+
There isn't one! This plugin does not need one as all of its work is behind the scenes, integrating the display of WooCommerce within Genesis themes.
|
77 |
+
|
78 |
+
|
79 |
+
== Other Notes ==
|
80 |
+
|
81 |
+
= Technical Info =
|
82 |
+
|
83 |
+
For more technically minded users, this is what the plugin does:
|
84 |
+
|
85 |
+
* Unhooks the WooCommerce template loader function
|
86 |
+
* Adds its own template loader function to control the templates used by the single product, archive product and Product Category and Product Tag (taxonomy) archive pages.
|
87 |
+
* Adds Genesis Layouts and SEO support to the WooCommerce `Product` custom post type
|
88 |
+
* Provides three Genesis-ready templates to display the shop pages, located in the plugin's `templates` folder:
|
89 |
+
* single-product.php
|
90 |
+
* archive-product.php
|
91 |
+
* taxonomy.php
|
92 |
+
* These templates use WooCommerce core functions to display the shop loops which:
|
93 |
+
* unhook WooCommerce's built-in breadcrumbs
|
94 |
+
* unhook the Genesis Loop and replace it with the relevant WooCommerce shop loop
|
95 |
+
* remove WooCommerce's #container and #content divs, which are not required or wanted by Genesis
|
96 |
+
* The shop loop function in each template is heavily based on its WooCommerce counterpart, but has been modified to accommodate certain Genesis features such as the Taxonomy term headings and descriptions feature.
|
97 |
+
* The templates contain the `genesis();` function and therefore are fully customisable using Genesis hooks and filters.
|
98 |
+
* The template loader allows users to use their own templates in the child theme's 'woocommerce' folder. These user templates, if they exist in the child theme's `woocommerce' folder, will be loaded in place of the supplied Genesis Connect for WooCommerce templates
|
99 |
+
* Using appropriate filters, modifies the Genesis breadcrumbs output to mimic the breadcrumb structure provided by WooCommerce's built-in breadcrumbs.
|
100 |
+
|
101 |
+
= More about breadcrumbs =
|
102 |
+
|
103 |
+
By default, the Genesis breadcrumbs do not provide the same breadcrumb structure as those built-in to WooCommerce. Genesis Connect for WooCommerce modifies the normal Genesis Breadcrumbs output on shop pages to mimic the structure of those built-in to WooCommerce.
|
104 |
+
|
105 |
+
Note that the templates provided in this plugin automatically unhook WooCommerce's built-in breadcrumbs via this code in each template:
|
106 |
+
`remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );`
|
107 |
+
|
108 |
+
= Filters =
|
109 |
+
|
110 |
+
This plugin provides some filters which may be useful for developers.
|
111 |
+
|
112 |
+
`genesiswooc_custom_query`
|
113 |
+
Located in `gencwooc_single_product_loop()` in `templates/single-product.php`.
|
114 |
+
The filter callback function should return a query object or false.
|
115 |
+
|
116 |
+
`gencwooc_product_archive_crumb`
|
117 |
+
Located in `gencwooc_get_archive_crumb_filter()` in `lib/breadcrumb.php`.
|
118 |
+
Allows further modification of the single product page breadcrumbs.
|
119 |
+
|
120 |
+
`gencwooc_single_product_crumb`
|
121 |
+
Located in `gencwooc_get_single_crumb()` in `lib/breadcrumb.php`.
|
122 |
+
Allows further modification of the product archive (shop page) breadcrumbs.
|
123 |
+
|
124 |
+
= More info about WooCommerce CSS handling =
|
125 |
+
|
126 |
+
For the benefit of theme developers and customizers, here is a summary of possible scenarios for dealing with WooCommerce CSS:
|
127 |
+
|
128 |
+
* Case 1: If the *WooCommerce > General settings > Enable WooCommerce CSS* option is checked, the default stylesheet supplied with WooCommerce will be loaded (see `wp-content/plugins/woocommerce/assets/css/woocommerce.css`).
|
129 |
+
* Case 2: If *WooCommerce > General settings > Enable WooCommerce CSS* option is unchecked, no stylesheet is loaded.
|
130 |
+
* Case 3: If the user (or theme developer) sets `define( 'WOOCOMMERCE_USE_CSS', true );` in the child theme functions.php the options setting is ignored and the default WooCommerce stylesheet is loaded, ie has same effect as checking the settings box.
|
131 |
+
* Case 4: If the user (or theme developer) sets `define( 'WOOCOMMERCE_USE_CSS', false );` in the child theme functions.php the options setting is ignored and NO stylesheet is loaded, ie has same effect as unchecking the settings box. Note: the value of WOOCOMMERCE_USE_CSS always takes precedence over the WooCommerce Settings page option!
|
132 |
+
* If either Case 1 or Case 3 applies, if themes/my-child-theme/woocommerce/styles.css exists it will be loaded in place of the default woocommerce stylesheet (plugins/woocommerce/assets/css/woocommerce.css).
|
133 |
+
* If either Case 2 or 4 applies, as no built-in stylesheet is loaded, all WooCommerce CSS styles need to be added to the theme's main style.css stylesheet
|
134 |
+
* Note for Genesis child theme developers: For new themes, theme developers can use `define( 'WOOCOMMERCE_USE_CSS', false );` and place all WooCommerce styles in the theme's main stylesheet, or do nothing and let the user handle this via Case 1 or 3.
|
135 |
+
* The above information is based on WooCommerce 1.4.4
|
136 |
+
|
137 |
+
== Changelog ==
|
138 |
+
|
139 |
+
= 0.9.0 =
|
140 |
+
* Initial Release
|
sp-plugins-integration/genesis-simple-menus.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Integration - Genesis Simple Menus
|
4 |
+
*
|
5 |
+
* @since 0.9.0
|
6 |
+
*
|
7 |
+
* Genesis Simple Menus (GSM) version 0.1.4
|
8 |
+
*
|
9 |
+
* What GCW integration needs to do:
|
10 |
+
* 1. add_post_type_support for 'genesis-simple-menus'
|
11 |
+
* 2. deal with serving correct GSM menu for Shop page (product archive)
|
12 |
+
*
|
13 |
+
* What GCW does:
|
14 |
+
* 1. GCW adds post_type_support for GSM - see gencwooc_setup()
|
15 |
+
* 2. uses Genesis filters to intercept request and serve correct GSM menu on Shop Page
|
16 |
+
*
|
17 |
+
* Note: this file is loaded on the 'after_theme_setup' hook only if GSM
|
18 |
+
* is activated.
|
19 |
+
* @see gencwooc_setup() in genesis-connect-woocommerce.php
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Prevent direct access to this file
|
25 |
+
*/
|
26 |
+
if ( ! defined( 'ABSPATH' ) )
|
27 |
+
exit( __( 'Sorry, you are not allowed to access this file directly.', 'genwooc' ) );
|
28 |
+
|
29 |
+
|
30 |
+
add_filter( 'genesis_pre_get_option_subnav_type', 'gencwooc_gsm_subnav_type', 9 );
|
31 |
+
/**
|
32 |
+
* Tells Genesis to load a custom menu
|
33 |
+
*
|
34 |
+
* @since 0.9.0
|
35 |
+
*
|
36 |
+
* @see Genesis_Simple_Menus::wp_head()
|
37 |
+
* @param str $nav
|
38 |
+
* @return str 'nav-menu' which tells Genesis to get a custom menu
|
39 |
+
*/
|
40 |
+
function gencwooc_gsm_subnav_type( $nav ) {
|
41 |
+
return 'nav-menu';
|
42 |
+
}
|
43 |
+
|
44 |
+
|
45 |
+
add_filter( 'theme_mod_nav_menu_locations', 'gencwooc_gsm_theme_mod' );
|
46 |
+
/**
|
47 |
+
* Replace the menu selected in the WordPress Menu settings with the custom one for this request
|
48 |
+
*
|
49 |
+
* @since 0.9.0
|
50 |
+
*
|
51 |
+
* @see Genesis_Simple_Menus::wp_head()
|
52 |
+
* @param array $mods Array of theme mods
|
53 |
+
* @return array $mods Modified array of theme mods
|
54 |
+
*/
|
55 |
+
function gencwooc_gsm_theme_mod( $mods ) {
|
56 |
+
|
57 |
+
/** Post meta key as per GSM 0.1.4 */
|
58 |
+
$field_name = '_gsm_menu';
|
59 |
+
|
60 |
+
$shop_id = woocommerce_get_page_id( 'shop' );
|
61 |
+
|
62 |
+
if ( is_post_type_archive( 'product' ) && $_menu = get_post_meta( $shop_id, $field_name, true ) )
|
63 |
+
$mods['secondary'] = (int) $_menu;
|
64 |
+
|
65 |
+
return $mods;
|
66 |
+
|
67 |
+
}
|
sp-plugins-integration/genesis-simple-sidebars.php
ADDED
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Integration - Genesis Simple Sidebars
|
4 |
+
*
|
5 |
+
* @since 0.9.0
|
6 |
+
*
|
7 |
+
* Based on Genesis Simple Sidebars (GSS) version 0.9.2
|
8 |
+
*
|
9 |
+
* What GCW integration needs to do:
|
10 |
+
* 1. add_post_type_support for 'genesis-simple-sidebars'
|
11 |
+
* 2. deal with serving correct GSS sidebar(s) for Shop page (product archive)
|
12 |
+
*
|
13 |
+
* What GCW does:
|
14 |
+
* 1. GCW adds post_type_support for GSS - see gencwooc_setup()
|
15 |
+
* 2. intercepts GSS sidebar loading functions, deals with Shop Page,
|
16 |
+
* then hands back control of sidebar loading in all other cases to GSS
|
17 |
+
*
|
18 |
+
* Note: this file is loaded on the 'after_theme_setup' hook only if GSS
|
19 |
+
* is activated.
|
20 |
+
* @see gencwooc_setup() in genesis-connect-woocommerce.php
|
21 |
+
*
|
22 |
+
* @TODO simply these functions
|
23 |
+
*/
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Prevent direct access to this file
|
27 |
+
*/
|
28 |
+
if ( ! defined( 'ABSPATH' ) )
|
29 |
+
exit( __( 'Sorry, you are not allowed to access this file directly.', 'genwooc' ) );
|
30 |
+
|
31 |
+
|
32 |
+
add_action( 'get_header', 'gencwooc_ss_handler', 11 );
|
33 |
+
/**
|
34 |
+
* Take control of GSS sidebar loading
|
35 |
+
*
|
36 |
+
* Hooked to 'get_header' with priority of 11 to ensure that GSS's
|
37 |
+
* actions, which are unhooked here in this function, have been added
|
38 |
+
* and therefore can be removed.
|
39 |
+
*
|
40 |
+
* Unhooks GSS ss_do_sidebar() and ss_do_sidebar_alt() functions and
|
41 |
+
* hooks GCW versions of these functions to the same hooks instead.
|
42 |
+
* @see GSS ss_sidebars_init() in genesis-simple-sidebars/plugin.php
|
43 |
+
*
|
44 |
+
* Note for developers:
|
45 |
+
* ====================
|
46 |
+
* If you want to do more complex manipulations of sidebars, eg load another one
|
47 |
+
* altogether (ie not a GSS sidebar, G Sidebar or G Sidebar Alt), unhook this
|
48 |
+
* function and replace it with your own version.
|
49 |
+
*
|
50 |
+
* @since 0.9.0
|
51 |
+
*
|
52 |
+
*/
|
53 |
+
function gencwooc_ss_handler() {
|
54 |
+
|
55 |
+
/** Unhook GSS functions */
|
56 |
+
remove_action( 'genesis_sidebar', 'ss_do_sidebar' );
|
57 |
+
remove_action( 'genesis_sidebar_alt', 'ss_do_sidebar_alt' );
|
58 |
+
|
59 |
+
/** Hook replacement functions */
|
60 |
+
add_action( 'genesis_sidebar', 'gencwooc_ss_do_sidebar' );
|
61 |
+
add_action( 'genesis_sidebar_alt', 'gencwooc_ss_do_sidebar_alt' );
|
62 |
+
|
63 |
+
}
|
64 |
+
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Callback for dealing with Primary Sidebar loading
|
68 |
+
*
|
69 |
+
* Intercepts GSS code flow, so that Shop page can be dealt with, then
|
70 |
+
* hands back control to the GSS function for loading primary sidebars.
|
71 |
+
* Effectively, it's just a more complex version of ss_do_sidebar()
|
72 |
+
*
|
73 |
+
* Checks if we're on the product archive and a GSS sidebar has been
|
74 |
+
* assigned in the Shop WP Page editor, then, if both true, loads the relevant
|
75 |
+
* GSS sidebar on the Shop Page.
|
76 |
+
* If either of the above conditions return false, we hand back control to GSS
|
77 |
+
* by executing the normal ss_do_one_sidebar() function.
|
78 |
+
*
|
79 |
+
* @since 0.9.0
|
80 |
+
*
|
81 |
+
* @uses woocommerce_get_page_id()
|
82 |
+
*
|
83 |
+
*/
|
84 |
+
function gencwooc_ss_do_sidebar() {
|
85 |
+
|
86 |
+
$bar = '_ss_sidebar';
|
87 |
+
$shop_id = woocommerce_get_page_id( 'shop' );
|
88 |
+
|
89 |
+
if ( is_post_type_archive( 'product' ) && $_bar = get_post_meta( $shop_id, $bar, true ) ) {
|
90 |
+
|
91 |
+
dynamic_sidebar( $_bar );
|
92 |
+
|
93 |
+
} else {
|
94 |
+
|
95 |
+
/** Hand back control to GSS */
|
96 |
+
if ( ! ss_do_one_sidebar( $bar ) )
|
97 |
+
genesis_do_sidebar();
|
98 |
+
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Callback for dealing with Sidebar Alt loading
|
105 |
+
*
|
106 |
+
* Intercepts GSS code flow, so that Shop page can be dealt with, then
|
107 |
+
* hands back control to the GSS function for loading secondary sidebars.
|
108 |
+
* Effectively, it's just a more complex version of ss_do_sidebar_alt()
|
109 |
+
*
|
110 |
+
* Checks if we're on the product archive and a GSS sidebar has been
|
111 |
+
* assigned in the Shop WP Page editor, then, if both true, loads the relevant
|
112 |
+
* GSS sidebar on the Shop Page.
|
113 |
+
* If either of the above conditions return false, we hand back control to GSS
|
114 |
+
* by executing the normal ss_do_one_sidebar_alt() function.
|
115 |
+
*
|
116 |
+
* @since 0.9.0
|
117 |
+
*
|
118 |
+
* @uses woocommerce_get_page_id()
|
119 |
+
*
|
120 |
+
*/
|
121 |
+
function gencwooc_ss_do_sidebar_alt() {
|
122 |
+
|
123 |
+
$bar = '_ss_sidebar_alt';
|
124 |
+
$shop_id = woocommerce_get_page_id( 'shop' );
|
125 |
+
|
126 |
+
if ( is_post_type_archive( 'product' ) && $_bar = get_post_meta( $shop_id, $bar, true ) ) {
|
127 |
+
dynamic_sidebar( $_bar );
|
128 |
+
|
129 |
+
} else {
|
130 |
+
|
131 |
+
/** Hand back control to GSS */
|
132 |
+
if ( ! ss_do_one_sidebar_alt( $bar ) )
|
133 |
+
genesis_do_sidebar_alt();
|
134 |
+
|
135 |
+
}
|
136 |
+
}
|
templates/archive-product.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This template displays the archive for Products
|
4 |
+
*
|
5 |
+
* Based on WooCommerce 1.4.4
|
6 |
+
*
|
7 |
+
* Note for customisers/users: Do not edit this file!
|
8 |
+
* ==================================================
|
9 |
+
* If you want to customise this template, copy this file (keep same name) and place the
|
10 |
+
* copy in the child theme's woocommerce folder, ie themes/my-child-theme/woocommerce
|
11 |
+
* (Your theme may not have a 'woocommerce' folder, in which case create one.)
|
12 |
+
* The version in the child theme's woocommerce folder will override this template, and
|
13 |
+
* any future updates to this plugin won't wipe out your customisations.
|
14 |
+
*
|
15 |
+
* @since 0.9.0
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
|
19 |
+
/** Remove default Genesis loop */
|
20 |
+
remove_action( 'genesis_loop', 'genesis_do_loop' );
|
21 |
+
|
22 |
+
/** Remove WooCommerce breadcrumbs */
|
23 |
+
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
|
24 |
+
|
25 |
+
/** Uncomment the below line of code to add back WooCommerce breadcrumbs */
|
26 |
+
//add_action( 'genesis_before_loop', 'woocommerce_breadcrumb', 10, 0 );
|
27 |
+
|
28 |
+
/** Remove Woo #container and #content divs */
|
29 |
+
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
|
30 |
+
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
|
31 |
+
|
32 |
+
|
33 |
+
/** Get Shop Page ID */
|
34 |
+
global $shop_page_id;
|
35 |
+
$shop_page_id = get_option( 'woocommerce_shop_page_id' );
|
36 |
+
|
37 |
+
|
38 |
+
add_filter( 'genesis_pre_get_option_site_layout', 'genesiswooc_archive_layout' );
|
39 |
+
/**
|
40 |
+
* Manage page layout for the Product archive (Shop) page
|
41 |
+
*
|
42 |
+
* Set the layout in the Genesis layouts metabox in the Page Editor
|
43 |
+
*
|
44 |
+
* @since 0.9.0
|
45 |
+
*
|
46 |
+
* @param str $layout Genesis layout, eg 'content-sidebar', etc
|
47 |
+
* @global string|int $shop_page_id The ID of the Shop WP Page
|
48 |
+
* @return str $layout Shop Page layout from postmeta
|
49 |
+
*/
|
50 |
+
function genesiswooc_archive_layout( $layout ) {
|
51 |
+
|
52 |
+
global $shop_page_id;
|
53 |
+
|
54 |
+
$layout = get_post_meta( $shop_page_id, '_genesis_layout', true );
|
55 |
+
|
56 |
+
return $layout;
|
57 |
+
}
|
58 |
+
|
59 |
+
add_action( 'genesis_before_loop', 'genesiswooc_archive_product_loop' );
|
60 |
+
/**
|
61 |
+
* Display shop items
|
62 |
+
*
|
63 |
+
* Uses WooCommerce structure and contains all existing WooCommerce hooks
|
64 |
+
* Note that this will also display any content created in the Shop Page itself
|
65 |
+
*
|
66 |
+
* Code based on WooCommerce 1.4.1 woocommerce_archive_product_content()
|
67 |
+
* @see woocommerce/woocommerce-template.php
|
68 |
+
*
|
69 |
+
* @uses genesiswooc_get_template_part()
|
70 |
+
*
|
71 |
+
* @since 0.9.0
|
72 |
+
* @global string|int $shop_page_id The ID of the Shop WP Page
|
73 |
+
*/
|
74 |
+
function genesiswooc_archive_product_loop() {
|
75 |
+
|
76 |
+
global $shop_page_id;
|
77 |
+
|
78 |
+
if ( !is_search() ) :
|
79 |
+
$shop_page = get_post( $shop_page_id );
|
80 |
+
$shop_page_title = apply_filters( 'the_title', ( get_option( 'woocommerce_shop_page_title' ) ) ? get_option( 'woocommerce_shop_page_title' ) : $shop_page->post_title );
|
81 |
+
$shop_page_content = $shop_page->post_content;
|
82 |
+
else :
|
83 |
+
$shop_page_title = __( 'Search Results:', 'woocommerce' ) . ' “' . get_search_query() . '”';
|
84 |
+
if ( get_query_var( 'paged' ) ) $shop_page_title .= ' — ' . __( 'Page', 'woocommerce' ) . ' ' . get_query_var( 'paged' );
|
85 |
+
$shop_page_content = '';
|
86 |
+
endif;
|
87 |
+
|
88 |
+
do_action( 'woocommerce_before_main_content' );
|
89 |
+
?>
|
90 |
+
|
91 |
+
<h1 class="page-title"><?php echo $shop_page_title ?></h1>
|
92 |
+
|
93 |
+
<?php echo apply_filters( 'the_content', $shop_page_content );
|
94 |
+
|
95 |
+
gencwooc_get_template_part( 'loop', 'shop' );
|
96 |
+
|
97 |
+
do_action( 'woocommerce_pagination' );
|
98 |
+
|
99 |
+
do_action( 'woocommerce_after_main_content' );
|
100 |
+
}
|
101 |
+
|
102 |
+
genesis();
|
templates/single-product.php
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This template displays the single Product
|
4 |
+
*
|
5 |
+
* Based on WooCommerce 1.4.4
|
6 |
+
*
|
7 |
+
* Note for customisers/users: Do not edit this file!
|
8 |
+
* ==================================================
|
9 |
+
* If you want to customise this template, copy this file (keep same name) and place the
|
10 |
+
* copy in the child theme's woocommerce folder, ie themes/my-child-theme/woocommerce
|
11 |
+
* (Your theme may not have a 'woocommerce' folder, in which case create one.)
|
12 |
+
* The version in the child theme's woocommerce folder will override this template, and
|
13 |
+
* any future updates to this plugin won't wipe out your customisations.
|
14 |
+
*
|
15 |
+
*/
|
16 |
+
|
17 |
+
/** Remove default Genesis loop */
|
18 |
+
remove_action( 'genesis_loop', 'genesis_do_loop' );
|
19 |
+
|
20 |
+
/** Remove WooCommerce breadcrumbs */
|
21 |
+
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
|
22 |
+
|
23 |
+
/** Uncomment the below line of code to add back WooCommerce breadcrumbs */
|
24 |
+
//add_action( 'genesis_before_loop', 'woocommerce_breadcrumb', 10, 0 );
|
25 |
+
|
26 |
+
/** Remove Woo #container and #content divs */
|
27 |
+
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
|
28 |
+
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
|
29 |
+
|
30 |
+
|
31 |
+
add_action( 'genesis_loop', 'gencwooc_single_product_loop' );
|
32 |
+
/**
|
33 |
+
* Displays single product loop
|
34 |
+
*
|
35 |
+
* Uses WooCommerce structure and contains all existing WooCommerce hooks
|
36 |
+
*
|
37 |
+
* Code based on WooCommerce 1.4.1 woocommerce_single_product_content()
|
38 |
+
* @see woocommerce/woocommerce-template.php
|
39 |
+
*
|
40 |
+
* @since 0.9.0
|
41 |
+
*/
|
42 |
+
function gencwooc_single_product_loop() {
|
43 |
+
|
44 |
+
do_action( 'woocommerce_before_main_content' );
|
45 |
+
|
46 |
+
// Let developers override the query used, in case they want to use this function for their own loop/wp_query
|
47 |
+
$wc_query = false;
|
48 |
+
|
49 |
+
// Added a hook for developers in case they need to modify the query
|
50 |
+
$wc_query = apply_filters( 'gencwooc_custom_query', $wc_query );
|
51 |
+
|
52 |
+
if ( ! $wc_query) {
|
53 |
+
|
54 |
+
global $wp_query;
|
55 |
+
|
56 |
+
$wc_query = $wp_query;
|
57 |
+
}
|
58 |
+
|
59 |
+
if ( $wc_query->have_posts() ) while ( $wc_query->have_posts() ) : $wc_query->the_post(); ?>
|
60 |
+
|
61 |
+
<?php do_action('woocommerce_before_single_product'); ?>
|
62 |
+
|
63 |
+
<div itemscope itemtype="http://schema.org/Product" id="product-<?php the_ID(); ?>" <?php post_class(); ?>>
|
64 |
+
|
65 |
+
<?php do_action( 'woocommerce_before_single_product_summary' ); ?>
|
66 |
+
|
67 |
+
<div class="summary">
|
68 |
+
|
69 |
+
<h1 itemprop="name" class="product_title page-title"><?php the_title(); ?></h1>
|
70 |
+
|
71 |
+
<?php do_action( 'woocommerce_single_product_summary' ); ?>
|
72 |
+
|
73 |
+
</div>
|
74 |
+
|
75 |
+
<?php do_action( 'woocommerce_after_single_product_summary' ); ?>
|
76 |
+
|
77 |
+
</div>
|
78 |
+
|
79 |
+
<?php do_action( 'woocommerce_after_single_product' );
|
80 |
+
|
81 |
+
endwhile;
|
82 |
+
|
83 |
+
do_action( 'woocommerce_after_main_content' );
|
84 |
+
}
|
85 |
+
|
86 |
+
genesis();
|
templates/taxonomy.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This template displays the Product Category and Tag taxonomy term archives
|
4 |
+
*
|
5 |
+
* Based on WooCommerce 1.4.4
|
6 |
+
*
|
7 |
+
* Note for customisers/users: Do not edit this file!
|
8 |
+
* ==================================================
|
9 |
+
* If you want to customise this template, copy this file (keep same name) and place the
|
10 |
+
* copy in the child theme's woocommerce folder, ie themes/my-child-theme/woocommerce
|
11 |
+
* (Your theme may not have a 'woocommerce' folder, in which case create one.)
|
12 |
+
* The version in the child theme's woocommerce folder will override this template, and
|
13 |
+
* any future updates to this plugin won't wipe out your customisations.
|
14 |
+
*
|
15 |
+
*/
|
16 |
+
|
17 |
+
/** Remove default Genesis loop */
|
18 |
+
remove_action( 'genesis_loop', 'genesis_do_loop' );
|
19 |
+
|
20 |
+
/** Remove WooCommerce breadcrumbs */
|
21 |
+
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
|
22 |
+
|
23 |
+
/** Uncomment the below line of code to add back WooCommerce breadcrumbs */
|
24 |
+
//add_action( 'genesis_before_loop', 'woocommerce_breadcrumb', 10, 0 );
|
25 |
+
|
26 |
+
/** Remove Woo #container and #content divs */
|
27 |
+
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
|
28 |
+
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
|
29 |
+
|
30 |
+
|
31 |
+
add_action( 'genesis_loop', 'genesiswooc_product_taxonomy_loop' );
|
32 |
+
/**
|
33 |
+
* Displays shop items for the queried taxonomy term
|
34 |
+
*
|
35 |
+
* Uses WooCommerce structure and contains all existing WooCommerce hooks
|
36 |
+
*
|
37 |
+
* Code based on WooCommerce 1.4.1 woocommerce_product_taxonomy_content()
|
38 |
+
* @see woocommerce/woocommerce-template.php
|
39 |
+
*
|
40 |
+
* @uses genesiswooc_get_template_part()
|
41 |
+
*
|
42 |
+
* @since 0.9.0
|
43 |
+
*/
|
44 |
+
function genesiswooc_product_taxonomy_loop() {
|
45 |
+
|
46 |
+
do_action( 'woocommerce_before_main_content' );
|
47 |
+
|
48 |
+
gencwooc_get_template_part( 'loop', 'shop' );
|
49 |
+
|
50 |
+
do_action( 'woocommerce_pagination' );
|
51 |
+
|
52 |
+
do_action( 'woocommerce_after_main_content' );
|
53 |
+
|
54 |
+
}
|
55 |
+
|
56 |
+
genesis();
|