Changeset 2123371
- Timestamp:
- 07/15/2019 05:12:39 PM (7 years ago)
- Location:
- genesis-connect-woocommerce
- Files:
-
- 12 added
- 2 deleted
- 27 edited
- 1 copied
-
tags/1.1.0 (copied) (copied from genesis-connect-woocommerce/trunk) (1 prop)
-
tags/1.1.0/.circleci (added)
-
tags/1.1.0/.circleci/config.yml (added)
-
tags/1.1.0/admin/notices.php (modified) (1 diff)
-
tags/1.1.0/admin/views/html-notice-needs-genesis.php (modified) (1 diff)
-
tags/1.1.0/admin/views/html-notice-needs-woocommerce.php (modified) (1 diff)
-
tags/1.1.0/genesis-connect-woocommerce.php (modified) (4 diffs)
-
tags/1.1.0/languages (added)
-
tags/1.1.0/languages/genesis-connect-woocommerce.pot (added)
-
tags/1.1.0/lib/breadcrumb.php (modified) (7 diffs)
-
tags/1.1.0/lib/posts-per-page.php (modified) (5 diffs)
-
tags/1.1.0/lib/template-loader.php (modified) (15 diffs)
-
tags/1.1.0/lib/widgets.php (added)
-
tags/1.1.0/readme.txt (modified) (4 diffs)
-
tags/1.1.0/sp-plugins-integration/genesis-simple-menus.php (modified) (3 diffs)
-
tags/1.1.0/sp-plugins-integration/genesis-simple-sidebars.php (modified) (5 diffs)
-
tags/1.1.0/templates/archive-product.php (modified) (5 diffs)
-
tags/1.1.0/templates/single-product.php (modified) (4 diffs)
-
tags/1.1.0/templates/taxonomy.php (modified) (5 diffs)
-
tags/1.1.0/widgets/class-gencwooc-featured-products.php (added)
-
tags/1.1.0/widgets/woocommerce-featured-widgets.php (deleted)
-
trunk (modified) (1 prop)
-
trunk/.circleci (added)
-
trunk/.circleci/config.yml (added)
-
trunk/admin/notices.php (modified) (1 diff)
-
trunk/admin/views/html-notice-needs-genesis.php (modified) (1 diff)
-
trunk/admin/views/html-notice-needs-woocommerce.php (modified) (1 diff)
-
trunk/genesis-connect-woocommerce.php (modified) (4 diffs)
-
trunk/languages (added)
-
trunk/languages/genesis-connect-woocommerce.pot (added)
-
trunk/lib/breadcrumb.php (modified) (7 diffs)
-
trunk/lib/posts-per-page.php (modified) (5 diffs)
-
trunk/lib/template-loader.php (modified) (15 diffs)
-
trunk/lib/widgets.php (added)
-
trunk/readme.txt (modified) (4 diffs)
-
trunk/sp-plugins-integration/genesis-simple-menus.php (modified) (3 diffs)
-
trunk/sp-plugins-integration/genesis-simple-sidebars.php (modified) (5 diffs)
-
trunk/templates/archive-product.php (modified) (5 diffs)
-
trunk/templates/single-product.php (modified) (4 diffs)
-
trunk/templates/taxonomy.php (modified) (5 diffs)
-
trunk/widgets/class-gencwooc-featured-products.php (added)
-
trunk/widgets/woocommerce-featured-widgets.php (deleted)
Legend:
- Unmodified
- Added
- Removed
-
genesis-connect-woocommerce/tags/1.1.0
- Property svn:ignore
-
old new 1 .editorconfig 1 2 .git 2 3 .gitignore 3 4 .gitattributes 4 5 .svnignore 6 composer.json 7 composer.lock 5 8 node_modules 9 phpcs.xml.dist 10 vendor
-
- Property svn:ignore
-
genesis-connect-woocommerce/tags/1.1.0/admin/notices.php
r1921233 r2123371 3 3 * Callbacks for `admin_notices` action to load HTML notices. 4 4 * 5 * @package genesis_connect_woocommerce6 * @ version1.05 * @package Genesis_Connect_WooCommerce 6 * @since 1.0 7 7 */ 8 defined( 'ABSPATH' ) || exit;9 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 */ 10 20 function gencwooc_woocommerce_notice() { 11 21 include GCW_ADMIN_DIR . '/views/html-notice-needs-woocommerce.php'; 12 22 } 13 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 */ 14 31 function gencwooc_genesis_notice() { 15 32 include GCW_ADMIN_DIR . '/views/html-notice-needs-genesis.php'; -
genesis-connect-woocommerce/tags/1.1.0/admin/views/html-notice-needs-genesis.php
r1921233 r2123371 1 1 <?php 2 2 /** 3 * Admin View: Notice - needs Genesis. 3 * View for WordPress `admin_notice` if Genesis is not active. 4 * 5 * @package Genesis_Connect_WooCommerce 6 * @since 1.0.0 4 7 */ 5 8 6 defined( 'ABSPATH' ) || exit; 9 if ( ! defined( 'ABSPATH' ) ) { 10 exit; 11 } 7 12 8 13 ?> 9 14 <div id="message" class="error notice"> 10 <p><?php _e( '<i>Genesis Connect for WooCommerce</i> requires a Genesis child theme. <strong>Please activate a Genesis theme or disable Genesis Connect.</strong>', 'gencwooc' ); ?></p> 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> 11 18 </div> -
genesis-connect-woocommerce/tags/1.1.0/admin/views/html-notice-needs-woocommerce.php
r1921233 r2123371 1 1 <?php 2 2 /** 3 * Admin View: Notice - needs WooCommerce. 3 * View for WordPress `admin_notice` if WooCommerce is not active. 4 * 5 * @package Genesis_Connect_WooCommerce 6 * @since 1.0.0 4 7 */ 5 8 6 defined( 'ABSPATH' ) || exit; 9 if ( ! defined( 'ABSPATH' ) ) { 10 exit; 11 } 7 12 8 13 ?> 9 14 <div id="message" class="error notice"> 10 <p><?php _e( '<i>Genesis Connect for WooCommerce</i> requires WooCommerce. <strong>Please activate WooCommerce or disable Genesis Connect.</strong>', 'gencwooc' ); ?></p> 15 <p> 16 <?php esc_html_e( 'Genesis Connect for WooCommerce requires WooCommerce. Please activate WooCommerce or disable Genesis Connect.', 'gencwooc' ); ?> 17 </p> 11 18 </div> -
genesis-connect-woocommerce/tags/1.1.0/genesis-connect-woocommerce.php
r1921233 r2123371 1 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 WC requires at least: 3.3.0 10 WC tested up to: 3.4 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 */ 11 20 12 License: GNU General Public License v2.0 (or later) 13 License URI: http://www.opensource.org/licenses/gpl-license.php 14 15 Special thanks to Ade Walker (http://www.studiograsshopper.ch/) for his contributions to this plugin. 16 */ 17 18 /** Define the Genesis Connect for WooCommerce constants */ 21 define( 'GCW_DIR', dirname( __FILE__ ) ); 19 22 define( 'GCW_TEMPLATE_DIR', dirname( __FILE__ ) . '/templates' ); 20 define( 'GCW_LIB_DIR', dirname( __FILE__ ) . '/lib' );21 define( 'GCW_ADMIN_DIR', dirname( __FILE__ ) . '/admin' );23 define( 'GCW_LIB_DIR', dirname( __FILE__ ) . '/lib' ); 24 define( 'GCW_ADMIN_DIR', dirname( __FILE__ ) . '/admin' ); 22 25 define( 'GCW_WIDGETS_DIR', dirname( __FILE__ ) . '/widgets' ); 23 26 define( 'GCW_SP_DIR', dirname( __FILE__ ) . '/sp-plugins-integration' ); … … 25 28 add_action( 'after_setup_theme', 'gencwooc_setup' ); 26 29 /** 27 * Setup G CW30 * Setup Genesis Connect for WooCommerce. 28 31 * 29 * Checks whether WooCommerce is active , then checks if relevant30 * theme support exists. Once past these checks, loads the necessary31 * files, actions and filters for the pluginto do its thing.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. 32 35 * 33 36 * @since 0.9.0 … … 36 39 37 40 require_once GCW_ADMIN_DIR . '/notices.php'; 41 38 42 $ready = true; 39 43 40 44 if ( ! function_exists( 'is_plugin_active' ) ) { 41 require_once ( ABSPATH . '/wp-admin/includes/plugin.php' );45 require_once ABSPATH . '/wp-admin/includes/plugin.php'; 42 46 } 43 47 44 48 if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) { 45 49 add_action( 'admin_notices', 'gencwooc_woocommerce_notice' ); 50 46 51 $ready = false; 47 52 } … … 61 66 global $woocommerce; 62 67 63 /** Load GCW files */ 64 require_once( GCW_LIB_DIR . '/template-loader.php' ); 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'; 65 71 66 // Load posts per page option 67 require_once( GCW_LIB_DIR . '/posts-per-page.php' ); 72 if ( ! current_theme_supports( 'gencwooc-woo-breadcrumbs' ) ) { 73 require_once GCW_LIB_DIR . '/breadcrumb.php'; 74 } 68 75 69 /** Load modified Genesis breadcrumb filters and callbacks */70 if ( ! current_theme_supports( 'gencwooc-woo-breadcrumbs') )71 require_once( GCW_LIB_DIR . '/breadcrumb.php' );72 73 /** Ensure WooCommerce 2.0+ compatibility */74 76 add_theme_support( 'woocommerce' ); 75 77 76 /** Add Genesis Layout, Genesis Scripts and SEO options to Product edit screen */77 78 add_post_type_support( 'product', array( 'genesis-layouts', 'genesis-scripts', 'genesis-seo' ) ); 78 79 /** Add Studiopress plugins support */80 79 add_post_type_support( 'product', array( 'genesis-simple-sidebars', 'genesis-simple-menus' ) ); 81 80 82 /** Add Widgets */83 81 if ( current_theme_supports( 'gencwooc-featured-products-widget' ) ) { 84 require_once ( GCW_WIDGETS_DIR . '/woocommerce-featured-widgets.php' );82 require_once GCW_WIDGETS_DIR . '/class-gencwooc-featured-products.php'; 85 83 } 86 84 87 /** Take control of shop template loading */88 85 remove_filter( 'template_include', array( &$woocommerce, 'template_loader' ) ); 89 86 add_filter( 'template_include', 'gencwooc_template_loader', 20 ); 90 87 91 /** Integration - Genesis Simple Sidebars */92 88 if ( is_plugin_active( 'genesis-simple-sidebars/plugin.php' ) ) { 93 require_once ( GCW_SP_DIR . '/genesis-simple-sidebars.php' );89 require_once GCW_SP_DIR . '/genesis-simple-sidebars.php'; 94 90 } 95 91 96 /** Integration - Genesis Simple Menus */97 92 if ( is_plugin_active( 'genesis-simple-menus/simple-menu.php' ) ) { 98 require_once ( GCW_SP_DIR . '/genesis-simple-menus.php' );93 require_once GCW_SP_DIR . '/genesis-simple-menus.php'; 99 94 } 100 95 101 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 } -
genesis-connect-woocommerce/tags/1.1.0/lib/breadcrumb.php
r1812865 r2123371 1 1 <?php 2 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 * archives in the same way as WooC's breadcrumbs. These filters and callback 13 * functions modify the default Genesis breadcrumb output so that the breadcrumb 14 * trail mimics that of WooC's breadcrumbs, for: 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: 15 12 * - Shop page (archive page) 16 13 * - Single product 17 14 * - Taxonomy archive 18 15 * 19 * Users who prefer to use WooC 'sbreadcrumbs can do so by adding this to their child16 * Users who prefer to use WooCommerce breadcrumbs can do so by adding this to their child 20 17 * theme's functions.php: 21 18 * - add_theme_support( 'gencwooc-woo-breadcrumbs' ); … … 23 20 * - remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' ); 24 21 * 25 * @see readme.txt for more details22 * @see readme.txt For more details. 26 23 * 27 24 * As this modification code uses existing Genesis Breadcrumb filters there is a risk that … … 32 29 * @see genesis/lib/classes/breadcrumb.php v1.8 33 30 * @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 31 */ 32 33 if ( ! defined( 'ABSPATH' ) ) { 34 exit; 35 } 46 36 47 37 add_filter( 'genesis_archive_crumb', 'gencwooc_get_archive_crumb_filter', 10, 2 ); 48 38 /** 49 * Filter the Genesis Breadcrumbs archive crumb 50 * 51 * Needed for Product Archive (Shop page) and Taxonomy archives 39 * Filter the Genesis Breadcrumbs archive crumb. 40 * 41 * Needed for Product Archive (Shop page) and Taxonomy archives. 52 42 * 53 43 * Note: relevant WooCommerce settings (WooCommerce > Settings > Pages tab): … … 57 47 * 58 48 * @since 0.9.0 59 * @updated 0.9.760 * 61 * @param str $crumb Breadcrumb 'crumb' for archives62 * @param array $args Genesis Breadcrumb args63 * @return str $crumb, either modified $crumb, or original $crumb49 * 50 * @param string $crumb Breadcrumb 'crumb' for archives. 51 * @param array $args Genesis Breadcrumb args. 52 * 53 * @return string $crumb Breadcrumb 'crumb' for archives. 64 54 */ 65 55 function gencwooc_get_archive_crumb_filter( $crumb, $args ) { 66 56 67 /** Are we on the product archive page? */ 68 if ( is_post_type_archive( 'product') && get_option( 'page_on_front' ) !== wc_get_page_id( 'shop' ) ) { 69 70 $shop_id = wc_get_page_id( 'shop' ); 71 72 $shop_name = $shop_id ? get_the_title( $shop_id ) : ucwords( get_option('woocommerce_shop_slug') ); 73 74 if ( is_search() ) : 75 76 $crumb = gencwooc_get_crumb_link( get_post_type_archive_link( 'product' ), $shop_name, $shop_name, $args['sep'] . __( 'Search results for “', 'woocommerce' ) . get_search_query() . '”' ); 77 78 else : 79 80 $crumb = $shop_name; 81 82 endif; 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 } 83 70 84 71 return apply_filters( 'gencwooc_product_archive_crumb', $crumb, $args ); 85 72 } 86 73 87 88 /** Are we on a shop taxonomy archive page? */89 74 if ( is_tax( 'product_cat' ) || is_tax( 'product_tag' ) ) { 90 91 $crumb = ''; 92 93 $prepend = ''; 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' ); 75 $crumb = ''; 76 $prepend = ''; 77 $shop_url = get_option( 'woocommerce_prepend_shop_page_to_urls' ); 78 $shop_id = wc_get_page_id( 'shop' ); 99 79 $shop_title = get_the_title( $shop_id ); 100 80 101 if ( 'yes' == $shop_url && $shop_id && get_option( 'page_on_front' ) !== $shop_id )81 if ( 'yes' === $shop_url && $shop_id && get_option( 'page_on_front' ) !== $shop_id ) { 102 82 $prepend = gencwooc_get_crumb_link( get_permalink( $shop_id ), $shop_title, $shop_title, $args['sep'] ); 103 83 } 104 84 } 105 85 106 86 if ( is_tax( 'product_cat' ) ) { 107 108 $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); 109 87 $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); 110 88 $parents = array(); 111 $parent = $term->parent; 112 while ( $parent ): 113 $parents[] = $parent; 89 $parent = $term->parent; 90 91 while ( $parent ) { 92 $parents[] = $parent; 114 93 $new_parent = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ) ); 115 $parent = $new_parent->parent;116 endwhile;94 $parent = $new_parent->parent; 95 } 117 96 118 97 $crumb .= $prepend; 119 98 120 if ( ! empty( $parents ) ) :99 if ( ! empty( $parents ) ) { 121 100 $parents = array_reverse( $parents ); 122 foreach ( $parents as $parent ) : 123 $item = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ) ); 101 102 foreach ( $parents as $parent ) { 103 $item = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ) ); 124 104 $crumb .= gencwooc_get_crumb_link( get_term_link( $item->slug, 'product_cat' ), $item->name, $item->name, $args['sep'] ); 125 endforeach;126 endif;105 } 106 } 127 107 128 108 $crumb .= single_term_title( '', false ); … … 132 112 133 113 if ( is_tax( 'product_tag' ) ) { 134 135 114 $crumb .= $prepend . __( 'Products tagged “', 'gencwooc' ) . single_term_title( '', false ) . _x( '”', 'endquote', 'gencwooc' ); 136 115 … … 138 117 } 139 118 140 /** Original unmodified */141 119 return $crumb; 142 } 143 120 121 } 144 122 145 123 add_filter( 'genesis_single_crumb', 'gencwooc_get_single_crumb', 10, 2 ); 146 124 /** 147 * Filter the Genesis Breadcrumbs singular crumb 148 * 149 * Needed for single Product pages 150 * 151 * @since 0.9.0 152 * 153 * @param str $crumb Breadcrumb 'crumb' for single posts 154 * @param array $args Genesis Breadcrumb args 155 * @return str $crumb, either modified $crumb, or original $crumb 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. 156 137 */ 157 138 function gencwooc_get_single_crumb( $crumb, $args ) { 158 139 159 /** Are we on a single product page? */160 140 if ( is_singular( 'product' ) ) { 161 162 141 global $post; 163 142 164 $crumb = ''; 165 $prepend = ''; 166 167 /** Should we prepend crumb with 'shop' page link? */ 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' ); 143 $crumb = ''; 144 $prepend = ''; 145 $shop_url = get_option( 'woocommerce_prepend_shop_page_to_urls' ); 146 $shop_id = wc_get_page_id( 'shop' ); 171 147 $shop_title = get_the_title( $shop_id ); 172 148 173 if ( 'yes' == $shop_url && $shop_id && get_option( 'page_on_front' ) !== $shop_id )149 if ( 'yes' === $shop_url && $shop_id && get_option( 'page_on_front' ) !== $shop_id ) { 174 150 $prepend = gencwooc_get_crumb_link( get_permalink( $shop_id ), $shop_title, $shop_title, $args['sep'] ); 151 } 175 152 176 153 $crumb .= $prepend; 177 178 if ( $terms = wp_get_object_terms( $post->ID, 'product_cat' ) ) : 179 $term = current( $terms ); 154 $terms = wp_get_object_terms( $post->ID, 'product_cat' ); 155 156 if ( $terms ) { 157 $term = current( $terms ); 180 158 $parents = array(); 181 $parent = $term->parent; 182 while ( $parent ): 183 $parents[] = $parent; 159 $parent = $term->parent; 160 161 while ( $parent ) { 162 $parents[] = $parent; 184 163 $new_parent = get_term_by( 'id', $parent, 'product_cat' ); 185 $parent = $new_parent->parent;186 endwhile;187 188 if ( ! empty( $parents ) ):164 $parent = $new_parent->parent; 165 } 166 167 if ( ! empty( $parents ) ) { 189 168 $parents = array_reverse( $parents ); 190 foreach ( $parents as $parent ) : 191 $item = get_term_by( 'id', $parent, 'product_cat' ); 169 170 foreach ( $parents as $parent ) { 171 $item = get_term_by( 'id', $parent, 'product_cat' ); 192 172 $crumb .= gencwooc_get_crumb_link( get_term_link( $item->slug, 'product_cat' ), $item->name, $item->name, $args['sep'] ); 193 endforeach; 194 endif; 173 } 174 } 175 195 176 $crumb .= gencwooc_get_crumb_link( get_term_link( $term->slug, 'product_cat' ), $term->name, $term->name, $args['sep'] ); 196 endif;177 } 197 178 198 179 $crumb .= get_the_title(); … … 201 182 } 202 183 203 /** Fallback - original unmodified */204 184 return $crumb; 205 } 206 185 186 } 207 187 208 188 /** 209 189 * Helper function to create anchor link for a single crumb. 210 190 * 211 * This is a copy of Genesis_Breadcrumb::get_breadcrumb_link() (G1.8) 212 * 213 * @since 0.9.0 214 * 215 * @param string $url URL for href attribute 216 * @param string $title title attribute 217 * @param string $content linked content 218 * @param string $sep Separator 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 * 219 200 * @return string HTML markup for anchor link and optional separator. 220 201 */ 221 202 function gencwooc_get_crumb_link( $url, $title, $content, $sep = false ) { 222 203 223 $link = sprintf( '<a href="%s" title="%s">%s</a>', esc_attr( $url ), esc_attr( $title ), esc_html( $content ) ); 224 225 if ( $sep ) 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 ) { 226 212 $link .= $sep; 213 } 227 214 228 215 return $link; -
genesis-connect-woocommerce/tags/1.1.0/lib/posts-per-page.php
r1575771 r2123371 1 1 <?php 2 2 /** 3 * These functions manage loading of plugin-specific addons to the WooCommerce 4 * settings page. 3 * These functions manage loading of plugin-specific addons to the WooCommerce settings page. 5 4 * 6 * @package genesis_connect_woocommerce 7 * @version 0.9.8 8 * 5 * @package Genesis_Connect_WooCommerce 9 6 * @since 0.9.0 10 7 */ 11 8 12 /** 13 * Prevent direct access to this file 14 */ 15 if ( ! defined( 'ABSPATH' ) ) 16 exit( _( 'Sorry, you are not allowed to access this file directly.' ) ); 9 if ( ! defined( 'ABSPATH' ) ) { 10 exit; 11 } 17 12 18 13 add_filter( 'woocommerce_settings_tabs_array', 'genesis_connect_addon_tab', 50 ); 19 /* 14 /** 20 15 * Add a custom tab in the WooCommerce settings for Genesis Connect. 21 16 * 22 17 * @since 1.0.0 18 * 19 * @param array $tabs Used to add a tab to the WooCommerce settings page. 20 * 23 21 * @return array $tabs Used to add a tab to the WooCommerce settings page. 24 22 */ 25 23 function genesis_connect_addon_tab( $tabs ) { 26 24 27 // Add our own section.28 25 $tabs['gencwooc'] = __( 'Genesis Connect Addons', 'gencwooc' ); 26 29 27 return $tabs; 30 28 … … 36 34 * 37 35 * @since 1.0.0 38 * @return array Multiple arrays holding our section information39 36 */ 40 41 37 function genesis_connect_settings_tab() { 42 woocommerce_admin_fields( genesis_connect_get_settings() );38 woocommerce_admin_fields( genesis_connect_get_settings() ); 43 39 } 44 40 … … 48 44 * 49 45 * @since 1.0.0 50 * @return array Settings to update.51 46 */ 52 47 function genesis_connect_update_settings() { 53 woocommerce_update_options( genesis_connect_get_settings() );48 woocommerce_update_options( genesis_connect_get_settings() ); 54 49 } 55 50 … … 58 53 * 59 54 * @since 1.0.0 55 * 60 56 * @return array $settings Array of our settings. 61 57 */ 62 58 function genesis_connect_get_settings() { 63 $settings = array( 59 60 $settings = array( 64 61 'gencwooc_section_title' => array( 65 62 'name' => __( 'Genesis Connect Addons', 'gencwooc' ), 66 63 'type' => 'title', 67 64 'desc' => 'Set and save additional WooCommerce settings here.', 68 'id' => 'gencwooc_section_title' 65 'id' => 'gencwooc_section_title', 69 66 ), 70 'products_per_page' => array(67 'products_per_page' => array( 71 68 'name' => __( 'Products Per Page', 'gencwooc' ), 72 69 'type' => 'number', … … 74 71 'id' => 'gencwooc_products_per_page', 75 72 'default' => apply_filters( 'genesiswooc_default_products_per_page', get_option( 'posts_per_page' ) ), 76 ), 77 'section_end' => array( 78 'type' => 'sectionend', 79 'id' => 'gencwooc_section_end' 80 ) 81 ); 82 return $settings; 73 ), 74 'section_end' => array( 75 'type' => 'sectionend', 76 'id' => 'gencwooc_section_end', 77 ), 78 ); 79 80 return $settings; 81 83 82 } 84 83 84 add_filter( 'loop_shop_per_page', 'genesiswooc_products_per_page' ); 85 85 /** 86 * Execute settings on the frontend (this should probably 87 * go somewhere else other than this file). 86 * Execute settings on the frontend (this should probably go somewhere else other than this file). 88 87 * 89 88 * @since 1.0.0 90 * @return array $q New query for the product page. 89 * 90 * @param integer $count Products per page to display. 91 * 92 * @return integer $count Products per page to display. 91 93 */ 92 add_filter( 'loop_shop_per_page', 'genesiswooc_products_per_page' );93 94 function genesiswooc_products_per_page( $count ) { 94 95 95 $count = get_option( 'gencwooc_products_per_page' ) ? get_option( 'gencwooc_products_per_page' ) : apply_filters( 'genesiswooc_default_products_per_page', get_option( 'posts_per_page' ) ); 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 } 96 101 97 102 return $count; -
genesis-connect-woocommerce/tags/1.1.0/lib/template-loader.php
r1921233 r2123371 1 1 <?php 2 2 /** 3 * These functions manage loading of templates for WooCommerce 4 * 5 * @package genesis_connect_woocommerce 6 * @version 0.9.8 7 * 3 * These functions manage loading of templates for WooCommerce. 4 * 5 * @package Genesis_Connect_WooCommerce 8 6 * @since 0.9.0 9 7 */ 10 8 11 /** 12 * Prevent direct access to this file 13 */ 14 if ( ! defined( 'ABSPATH' ) ) 15 exit( _( 'Sorry, you are not allowed to access this file directly.' ) ); 16 17 9 if ( ! defined( 'ABSPATH' ) ) { 10 exit; 11 } 18 12 19 13 /** 20 14 * Load the Genesis-fied templates, instead of the WooCommerce defaults. 21 15 * 22 * Hooked to 'template_include' filter 23 * 24 * This template loader determines which template file will be used for the requested page, and uses the25 * following hierarchy to find the template: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: 26 20 * 1. First looks in the child theme's 'woocommerce' folder. 27 21 * 2. If no template found, falls back to GCW's templates. 28 22 * 29 * For taxonomy templates, first looks in child theme's 'woocommerce' folder and searches for term specific template, 30 * then taxonomy specific template, then taxonomy.php. If no template found, falls back to GCW's taxonomy.php. 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. 31 26 * 32 27 * GCW provides three templates in the plugin's 'templates' directory: … … 35 30 * - taxonomy.php 36 31 * 37 * Users can override GCW templates by placing their own templates in their child theme's 'woocommerce' folder. 38 * The 'woocommerce' folder must be a folder in the child theme's root directory, eg themes/my-child-theme/woocommerce 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 * 39 36 * Permitted user templates (as per WP Template Hierarchy) are: 40 37 * - single-product.php … … 44 41 * - taxonomy.php 45 42 * 46 * Note that in the case of taxonomy templates, this function accommodates ALL taxonomies registered to the 47 * 'product' custom post type. This means that it will cater for users' own custom taxonomies as well as WooC's. 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. 48 46 * 49 47 * @since 0.9.0 50 48 * 51 * @param string $template Template file as per template hierarchy 52 * @return string $template Specific GCW template if a product page (single or archive)53 * or a product taxonomy term, or returns original template49 * @param string $template Template file as per template hierarchy. 50 * 51 * @return string $template Template file as per template hierarchy. 54 52 */ 55 53 function gencwooc_template_loader( $template ) { … … 59 57 } 60 58 61 if ( is_single() && 'product' == get_post_type() ) { 62 59 if ( is_single() && 'product' === get_post_type() ) { 63 60 $template = locate_template( array( 'woocommerce/single-product.php' ) ); 64 61 65 if ( ! $template ) 62 if ( ! $template ) { 66 63 $template = GCW_TEMPLATE_DIR . '/single-product.php'; 67 68 } 69 elseif ( is_post_type_archive( 'product' ) || is_page( wc_get_page_id( 'shop' ) ) ) { 70 64 } 65 } elseif ( is_post_type_archive( 'product' ) || is_page( wc_get_page_id( 'shop' ) ) ) { 71 66 $template = locate_template( array( 'woocommerce/archive-product.php' ) ); 72 67 73 if ( ! $template ) 68 if ( ! $template ) { 74 69 $template = GCW_TEMPLATE_DIR . '/archive-product.php'; 75 76 } 77 elseif ( is_tax() ) { 78 79 $term = get_query_var( 'term' ); 80 81 $tax = get_query_var( 'taxonomy' ); 82 83 /** Get an array of all relevant taxonomies */ 70 } 71 } elseif ( is_tax() ) { 72 $term = get_query_var( 'term' ); 73 $tax = get_query_var( 'taxonomy' ); 84 74 $taxonomies = get_object_taxonomies( 'product', 'names' ); 85 75 86 if ( in_array( $tax, $taxonomies ) ) { 87 88 $tax = sanitize_title( $tax ); 76 if ( in_array( $tax, $taxonomies, true ) ) { 77 $tax = sanitize_title( $tax ); 89 78 $term = sanitize_title( $term ); 90 79 91 80 $templates = array( 92 'woocommerce/taxonomy-'.$tax.'-'.$term.'.php',93 'woocommerce/taxonomy-'.$tax.'.php',81 "woocommerce/taxonomy-{$tax}-{$term}.php", 82 "woocommerce/taxonomy-{$tax}.php", 94 83 'woocommerce/taxonomy.php', 95 84 ); … … 97 86 $template = locate_template( $templates ); 98 87 99 /** Fallback to GCW template */ 100 if ( ! $template ) 88 if ( ! $template ) { 101 89 $template = GCW_TEMPLATE_DIR . '/taxonomy.php'; 90 } 102 91 } 103 92 } … … 107 96 } 108 97 109 110 111 /** 112 * Shop Loop 'template part' loader 98 /** 99 * Shop Loop 'template part' loader. 113 100 * 114 101 * ONLY RETAINED FOR BACKWARDS COMPATIBILITY for GCW pre-0.9.2 custom templates which … … 118 105 * loads the default WooCommerce loop-shop.php file. 119 106 * 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. 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 * 125 113 * It is recommended to use woocommerce/templates/loop-shop.php as the starting point of 126 114 * any custom loop template. … … 129 117 * 130 118 * Note: updated v0.9.3 to reflect changes to woocommerce_get_template_part() introduced in 131 * WooC v1.4+ and, effectively, this function is a clone of woocommerce_get_template_part() 119 * WooCommerce v1.4+ and, effectively, this function is a clone of woocommerce_get_template_part() 120 * 121 * @global object $woocommerce WooCommerce instance 132 122 * 133 123 * @since 0.9.0 134 * @updated 0.9.8 135 * @global object $woocommerce WooCommerce instance 136 */ 137 function gencwooc_get_template_part( $slug, $name = '' ) { 124 * 125 * @param string $slug The template slug. 126 * @param string $name The template name. 127 */ 128 function gencwooc_get_template_part( $slug, $name = '' ) { 138 129 139 130 global $woocommerce; 131 140 132 $template = ''; 141 133 142 // Look in yourtheme/slug-name.php and yourtheme/woocommerce/slug-name.php 143 if ( $name ) 144 $template = locate_template( array ( "{$slug}-{$name}.php", "{$woocommerce->template_url}{$slug}-{$name}.php" ) ); 145 146 // Get default slug-name.php 147 if ( !$template && $name && file_exists( $woocommerce->plugin_path() . "/templates/{$slug}-{$name}.php" ) ) 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" ) ) { 148 139 $template = $woocommerce->plugin_path() . "/templates/{$slug}-{$name}.php"; 149 150 // If template file doesn't exist, look in yourtheme/slug.php and yourtheme/woocommerce/slug.php 151 if ( !$template ) 152 $template = locate_template( array ( "{$slug}.php", "{$woocommerce->template_url}{$slug}.php" ) ); 153 154 if ( $template ) 140 } 141 142 if ( ! $template ) { 143 $template = locate_template( array( "{$slug}.php", "{$woocommerce->template_url}{$slug}.php" ) ); 144 } 145 146 if ( $template ) { 155 147 load_template( $template, false ); 156 } 157 158 159 /** 160 * Display shop items 161 * 162 * FOR BACKWARDS COMPATIBILITY with WooCommerce versions pre-1.6.0 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 * Code based on WooCommerce 1.5.5 woocommerce_archive_product_content() 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 * 168 163 * @see woocommerce/woocommerce-template.php 169 164 * 170 *171 165 * @since 0.9.4 172 * @updated 0.9.6173 * @global string|int $shop_page_id The ID of the Shop WP Page 166 * 167 * @global string|int $shop_page_id The ID of the Shop WP Page. 174 168 */ 175 169 function genesiswooc_product_archive() { … … 177 171 global $shop_page_id; 178 172 179 if ( !is_search() ) : 180 $shop_page = get_post( $shop_page_id ); 181 $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 ); 182 $shop_page_content = $shop_page->post_content; 183 else : 184 $shop_page_title = __( 'Search Results:', 'woocommerce' ) . ' “' . get_search_query() . '”'; 185 if ( get_query_var( 'paged' ) ) $shop_page_title .= ' — ' . __( 'Page', 'woocommerce' ) . ' ' . get_query_var( 'paged' ); 186 $shop_page_content = ''; 187 endif; 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 } 188 186 189 187 do_action( 'woocommerce_before_main_content' ); 190 ?> 191 192 <h1 class="page-title"><?php echo $shop_page_title ?></h1> 193 194 <?php echo apply_filters( 'the_content', $shop_page_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 195 196 196 woocommerce_get_template_part( 'loop', 'shop' ); … … 199 199 200 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() 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 * 212 213 * @see woocommerce/woocommerce-template.php 213 214 * 214 *215 215 * @since 0.9.4 216 216 */ … … 227 227 } 228 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 * Uses WooCommerce structure and contains all existing WooCommerce hooks 236 * 237 * Code based on WooCommerce 2.1.12 templates/archive-product.php 238 * 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. 239 237 * 240 238 * @since 0.9.4 241 * @updated 0.9.8242 239 */ 243 240 function genesiswooc_content_product() { 244 241 245 242 /** 246 * woocommerce_before_main_content hook243 * For woocommerce_before_main_content hook. 247 244 * 248 245 * @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content) … … 253 250 if ( apply_filters( 'woocommerce_show_page_title', true ) ) { 254 251 echo '<h1 class="woocommerce-products-header__title page-title">'; 252 255 253 woocommerce_page_title(); 254 256 255 echo '</h1>'; 257 256 } … … 268 267 */ 269 268 do_action( 'woocommerce_before_shop_loop' ); 269 270 270 woocommerce_product_loop_start(); 271 271 272 if ( wc_get_loop_prop( 'total' ) ) { 272 273 while ( have_posts() ) { 273 274 the_post(); 275 274 276 /** 275 277 * Hook: woocommerce_shop_loop. … … 278 280 */ 279 281 do_action( 'woocommerce_shop_loop' ); 282 280 283 wc_get_template_part( 'content', 'product' ); 281 284 } 282 285 } 286 283 287 woocommerce_product_loop_end(); 288 284 289 /** 285 290 * Hook: woocommerce_after_shop_loop. … … 296 301 do_action( 'woocommerce_no_products_found' ); 297 302 } 303 298 304 /** 299 305 * Hook: woocommerce_after_main_content. -
genesis-connect-woocommerce/tags/1.1.0/readme.txt
r1921233 r2123371 3 3 Tags: genesis, genesiswp, studiopress, woocommerce 4 4 Requires at least: 3.3 5 Tested up to: 4.96 Stable tag: 1. 05 Tested up to: 5.2.2 6 Stable tag: 1.1.0 7 7 8 8 This plugin allows you to seamlessly integrate WooCommerce with the Genesis Framework and Genesis child themes. … … 131 131 132 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. 133 138 134 139 = 1.0 = … … 163 168 = 0.9.8 = 164 169 * Released 9 July 2014 165 * Updates genesiswooc_content_product() to reflect WooC 2.1+ templates and correct handling of WooC'spage title filter function170 * Updates genesiswooc_content_product() to reflect WooCommerce 2.1+ templates and correct handling of WooCommerce page title filter function 166 171 167 172 = 0.9.7 = … … 188 193 = 0.9.2 = 189 194 * Released 15 March 2012 190 * single-product.php - Single product title template file now hooked in as per WooC 1.5.2195 * single-product.php - Single product title template file now hooked in as per WooCommerce 1.5.2 191 196 192 197 = 0.9.1 = -
genesis-connect-woocommerce/tags/1.1.0/sp-plugins-integration/genesis-simple-menus.php
r1812865 r2123371 1 1 <?php 2 2 /** 3 * Integration - Genesis Simple Menus3 * Genesis Simple Menus integration. 4 4 * 5 * @package genesis_connect_woocommerce 6 * @version 0.9.8 7 8 * 5 * @package Genesis_Connect_WooCommerce 9 6 * @since 0.9.0 10 7 * … … 12 9 * 13 10 * What GCW integration needs to do: 14 * 1. add_post_type_support for 'genesis-simple-menus'15 * 2. deal with serving correct GSM menu for Shop page (product archive)11 * 1. add_post_type_support for 'genesis-simple-menus' 12 * 2. deal with serving correct GSM menu for Shop page (product archive) 16 13 * 17 14 * What GCW does: 18 * 1. GCW adds post_type_support for GSM - see gencwooc_setup()19 * 2. uses Genesis filters to intercept request and serve correct GSM menu on Shop Page15 * 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 20 17 * 21 18 * Note: this file is loaded on the 'after_theme_setup' hook only if GSM 22 19 * is activated. 23 20 * @see gencwooc_setup() in genesis-connect-woocommerce.php 24 *25 21 */ 26 22 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 23 if ( ! defined( 'ABSPATH' ) ) { 24 exit; 25 } 33 26 34 27 add_filter( 'genesis_pre_get_option_subnav_type', 'gencwooc_gsm_subnav_type', 9 ); 35 28 /** 36 * Tells Genesis to load a custom menu 29 * Tells Genesis to load a custom menu. 37 30 * 38 31 * @since 0.9.0 39 32 * 40 33 * @see Genesis_Simple_Menus::wp_head() 41 * @param str $nav 42 * @return str 'nav-menu' which tells Genesis to get a custom menu 34 * 35 * @param string $nav The sub nav type. 36 * 37 * @return string The sub nav type. 43 38 */ 44 39 function gencwooc_gsm_subnav_type( $nav ) { … … 49 44 add_filter( 'theme_mod_nav_menu_locations', 'gencwooc_gsm_theme_mod' ); 50 45 /** 51 * Replace the menu selected in the WordPress Menu settings with the custom one for this request 46 * Replace the menu selected in the WordPress Menu settings with the custom one for this request. 52 47 * 53 48 * @since 0.9.0 54 49 * 55 50 * @see Genesis_Simple_Menus::wp_head() 56 * @param array $mods Array of theme mods 57 * @return array $mods Modified array of theme mods 51 * 52 * @param array $mods Array of theme mods. 53 * 54 * @return array $mods Array of theme mods. 58 55 */ 59 56 function gencwooc_gsm_theme_mod( $mods ) { 60 57 61 /** Post meta key as per GSM 0.1.4 */62 $ field_name = '_gsm_menu';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 ); 63 60 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 = get_post_meta( $shop_id, $field_name, true ) ) 61 if ( is_post_type_archive( 'product' ) && $_menu ) { 67 62 $mods['secondary'] = (int) $_menu; 63 } 68 64 69 65 return $mods; -
genesis-connect-woocommerce/tags/1.1.0/sp-plugins-integration/genesis-simple-sidebars.php
r1921233 r2123371 1 1 <?php 2 2 /** 3 * Integration - Genesis Simple Sidebars3 * Genesis Simple Sidebars integration. 4 4 * 5 * @package genesis_connect_woocommerce 6 * @version 0.9.8 7 * 5 * @package Genesis_Connect_WooCommerce 8 6 * @since 0.9.0 9 7 * 10 * Based on Genesis Simple Sidebars (GSS) version 0.9.2 8 * Based on Genesis Simple Sidebars (GSS) version 0.9.2. 11 9 * 12 10 * What GCW integration needs to do: 13 * 1. add_post_type_support for 'genesis-simple-sidebars'14 * 2. deal with serving correct GSS sidebar(s) for Shop page (product archive)11 * 1. Add_post_type_support for 'genesis-simple-sidebars'. 12 * 2. Deal with serving correct GSS sidebar(s) for Shop page (product archive). 15 13 * 16 14 * What GCW does: 17 * 1. GCW adds post_type_support for GSS - see gencwooc_setup()18 * 2. intercepts GSS sidebar loading functions, deals with Shop Page,19 * then hands back control of sidebar loading in all other cases to GSS 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. 20 18 * 21 * Note: this file is loaded on the 'after_theme_setup' hook only if GSS 22 * is activated. 19 * Note: this file is loaded on the 'after_theme_setup' hook only if GSS is activated. 23 20 * @see gencwooc_setup() in genesis-connect-woocommerce.php 24 *25 * @TODO simply these functions26 21 */ 27 22 28 /** 29 * Prevent direct access to this file 30 */ 31 if ( ! defined( 'ABSPATH' ) ) 32 exit( __( 'Sorry, you are not allowed to access this file directly.', 'genwooc' ) ); 23 if ( ! defined( 'ABSPATH' ) ) { 24 exit; 25 } 33 26 34 27 35 28 add_action( 'get_header', 'gencwooc_ss_handler', 11 ); 36 29 /** 37 * Take control of GSS sidebar loading 30 * Take control of GSS sidebar loading. 38 31 * 39 * Hooked to 'get_header' with priority of 11 to ensure that GSS's 40 * actions, which are unhooked here in this function, have been added 41 * and therefore can be removed. 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. 42 34 * 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. 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 * 45 38 * @see GSS ss_sidebars_init() in genesis-simple-sidebars/plugin.php 46 39 * 47 40 * Note for developers: 48 41 * ==================== 49 * If you want to do more complex manipulations of sidebars, eg load another one 50 * altogether (ie not a GSS sidebar, G Sidebar or G Sidebar Alt), unhook this51 * function and replace it withyour own version.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. 52 45 * 53 46 * @since 0.9.0 54 *55 47 */ 56 48 function gencwooc_ss_handler() { 57 49 58 /** Unhook GSS functions */59 50 remove_action( 'genesis_sidebar', 'ss_do_sidebar' ); 60 51 remove_action( 'genesis_sidebar_alt', 'ss_do_sidebar_alt' ); 61 52 62 /** Hook replacement functions */63 53 add_action( 'genesis_sidebar', 'gencwooc_ss_do_sidebar' ); 64 54 add_action( 'genesis_sidebar_alt', 'gencwooc_ss_do_sidebar_alt' ); … … 68 58 69 59 /** 70 * Callback for dealing with Primary Sidebar loading 60 * Callback for dealing with Primary Sidebar loading. 71 61 * 72 * Intercepts GSS code flow, so that Shop page can be dealt with, then 73 * hands back control to the GSS function for loading primary sidebars.74 * Effectively, it's just a more complex version of ss_do_sidebar()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(). 75 65 * 76 * Checks if we're on the product archive and a GSS sidebar has been 77 * assigned in the Shop WP Page editor, then, if both true, loads the relevant 78 * GSS sidebar on the Shop Page. 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. 79 68 * 80 69 * If either of the above conditions return false, we load the regular sidebar. … … 83 72 * 84 73 * @uses woocommerce_get_page_id() 85 *86 74 */ 87 75 function gencwooc_ss_do_sidebar() { 88 76 89 $bar = '_ss_sidebar';90 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 ); 91 79 92 if ( is_post_type_archive( 'product' ) && $_bar = get_post_meta( $shop_id, $bar, true ) ) { 93 80 if ( is_post_type_archive( 'product' ) && $_bar ) { 94 81 dynamic_sidebar( $_bar ); 95 96 82 } else { 97 98 83 genesis_do_sidebar(); 99 100 84 } 101 85 … … 104 88 105 89 /** 106 * Callback for dealing with Sidebar Alt loading 90 * Callback for dealing with Sidebar Alt loading. 107 91 * 108 * Intercepts GSS code flow, so that Shop page can be dealt with, then 109 * hands back control to the GSS function for loading secondary sidebars.110 * Effectively, it's just a more complex version of ss_do_sidebar_alt()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(). 111 95 * 112 * Checks if we're on the product archive and a GSS sidebar has been 113 * assigned in the Shop WP Page editor, then, if both true, loads the relevant 114 * GSS sidebar on the Shop Page. 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. 115 98 * 116 99 * If either of the above conditions return false, we load the regular alt sidebar. … … 119 102 * 120 103 * @uses woocommerce_get_page_id() 121 *122 104 */ 123 105 function gencwooc_ss_do_sidebar_alt() { 124 106 125 $bar = '_ss_sidebar_alt';126 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 ); 127 109 128 if ( is_post_type_archive( 'product' ) && $_bar = get_post_meta( $shop_id, $bar, true ) ) { 129 110 if ( is_post_type_archive( 'product' ) && $_bar ) { 130 111 dynamic_sidebar( $_bar ); 131 132 112 } else { 133 134 113 genesis_do_sidebar_alt(); 135 136 114 } 137 115 -
genesis-connect-woocommerce/tags/1.1.0/templates/archive-product.php
r1921233 r2123371 1 1 <?php 2 2 /** 3 * This template displays the archive for Products 3 * This template displays the archive for Products. 4 4 * 5 * @package genesis_connect_woocommerce5 * @package Genesis_Connect_WooCommerce 6 6 * @version 0.9.8 7 * @since 0.9.0 7 8 * 8 9 * Note for customisers/users: Do not edit this file! … … 13 14 * The version in the child theme's woocommerce folder will override this template, and 14 15 * any future updates to this plugin won't wipe out your customisations. 15 *16 * @since 0.9.017 *18 16 */ 19 17 20 /** Remove default Genesis loop */ 18 if ( ! defined( 'ABSPATH' ) ) { 19 exit; 20 } 21 21 22 remove_action( 'genesis_loop', 'genesis_do_loop' ); 22 23 /** Remove Genesis archive title/description */24 23 remove_action( 'genesis_before_loop', 'genesis_do_taxonomy_title_description', 15 ); 25 26 /** Remove WooCommerce breadcrumbs */27 24 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 25 remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 ); 34 26 remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 ); … … 42 34 * @since 0.9.0 43 35 * 44 * @param str $layout Current Genesis page layout, such as 'content-sidebar'. 45 * @return str Page layout if set for the shop page, otherwise the default site layout. 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. 46 39 */ 47 40 function genesiswooc_archive_layout( $layout ) { … … 61 54 * Display shop items (product custom post archive) 62 55 * 63 * This function has been refactored in 0.9.4 to provide compatibility with 64 * both WooC 1.6.0 and backwards compatibility with older versions. 65 * This is needed thanks to substantial changes to WooC template contents 66 * introduced in WooC 1.6.0. 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. 67 58 * 68 * @uses genesiswooc_content_product() if WooC is version 1.6.0+ 69 * @uses genesiswooc_product_archive() for earlier WooC versions 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 70 64 * 71 65 * @since 0.9.0 72 * @updated 0.9.473 * @global object $woocommerce66 * 67 * @global WooCommerce $woocommerce Current WooCommerce instance. 74 68 */ 75 69 function genesiswooc_archive_product_loop() { … … 79 73 $new = version_compare( $woocommerce->version, '1.6.0', '>=' ); 80 74 81 if ( $new ) 75 if ( $new ) { 82 76 genesiswooc_content_product(); 77 } else { 78 genesiswooc_product_archive(); 79 } 83 80 84 else85 genesiswooc_product_archive();86 81 } 87 82 -
genesis-connect-woocommerce/tags/1.1.0/templates/single-product.php
r1921233 r2123371 1 1 <?php 2 2 /** 3 * This template displays the single Product 3 * This template displays the single Product. 4 4 * 5 * @package genesis_connect_woocommerce5 * @package Genesis_Connect_WooCommerce 6 6 * @version 0.9.8 7 * @since 0.9.0 7 8 * 8 9 * Note for customisers/users: Do not edit this file! … … 13 14 * The version in the child theme's woocommerce folder will override this template, and 14 15 * any future updates to this plugin won't wipe out your customisations. 15 *16 16 */ 17 17 18 /** Remove default Genesis loop */ 18 if ( ! defined( 'ABSPATH' ) ) { 19 exit; 20 } 21 19 22 remove_action( 'genesis_loop', 'genesis_do_loop' ); 20 21 /** Remove WooCommerce breadcrumbs */22 23 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 24 remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 ); 29 25 remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 ); 30 26 31 32 27 add_action( 'genesis_loop', 'gencwooc_single_product_loop' ); 33 28 /** 34 * Displays single product loop 29 * Displays single product loop. 35 30 * 36 * Uses WooCommerce structure and contains all existing WooCommerce hooks 31 * Uses WooCommerce structure and contains all existing WooCommerce hooks. 37 32 * 38 * Code based on WooCommerce 1.5.5 woocommerce_single_product_content() 33 * Code based on WooCommerce 1.5.5 woocommerce_single_product_content(). 34 * 39 35 * @see woocommerce/woocommerce-template.php 40 36 * … … 45 41 do_action( 'woocommerce_before_main_content' ); 46 42 47 // Let developers override the query used, in case they want to use this function for their own loop/wp_query 48 $wc_query = false; 43 $wc_query = apply_filters( 'gencwooc_custom_query', false ); 49 44 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 45 if ( ! $wc_query ) { 55 46 global $wp_query; 56 47 … … 58 49 } 59 50 60 if ( $wc_query->have_posts() ) while ( $wc_query->have_posts() ) : $wc_query->the_post(); ?> 51 if ( $wc_query->have_posts() ) { 52 while ( $wc_query->have_posts() ) { 53 $wc_query->the_post(); 61 54 62 <?php do_action('woocommerce_before_single_product'); ?> 55 do_action( 'woocommerce_before_single_product' ); 56 ?> 63 57 64 <div id="product-<?php the_ID(); ?>" <?php post_class(); ?>> 58 <div id="product-<?php the_ID(); ?>" <?php post_class(); ?>> 59 <?php do_action( 'woocommerce_before_single_product_summary' ); ?> 65 60 66 <?php do_action( 'woocommerce_before_single_product_summary' ); ?> 61 <div class="summary"> 62 <?php do_action( 'woocommerce_single_product_summary' ); ?> 63 </div> 67 64 68 <div class="summary"> 69 70 <?php do_action( 'woocommerce_single_product_summary'); ?> 71 65 <?php do_action( 'woocommerce_after_single_product_summary' ); ?> 72 66 </div> 73 67 74 <?php do_action( 'woocommerce_after_single_product_summary' ); ?> 75 76 </div> 77 78 <?php do_action( 'woocommerce_after_single_product' ); 79 80 endwhile; 68 <?php 69 do_action( 'woocommerce_after_single_product' ); 70 } 71 } 81 72 82 73 do_action( 'woocommerce_after_main_content' ); 74 83 75 } 84 76 -
genesis-connect-woocommerce/tags/1.1.0/templates/taxonomy.php
r1921233 r2123371 1 1 <?php 2 2 /** 3 * This template displays the Product Category and Tag taxonomy term archives 3 * This template displays the Product Category and Tag taxonomy term archives. 4 4 * 5 * @package genesis_connect_woocommerce5 * @package Genesis_Connect_WooCommerce 6 6 * @version 0.9.8 7 * @since 0.9.0 7 8 * 8 9 * Note for customisers/users: Do not edit this file! … … 13 14 * The version in the child theme's woocommerce folder will override this template, and 14 15 * any future updates to this plugin won't wipe out your customisations. 15 *16 16 */ 17 17 18 if ( ! defined( 'ABSPATH' ) ) { 19 exit; 20 } 18 21 19 /** Remove default Genesis loop */20 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 ); 21 27 22 // Remove the WooCommerce archive title and description.23 28 add_filter( 'woocommerce_show_page_title', '__return_false' ); 24 remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description' );25 29 26 30 add_filter( 'genesis_term_intro_text_output', 'genesiswooc_term_intro_text_output' ); … … 28 32 * Fall back to the archive description if no intro text is set. 29 33 * 34 * @since 1.0.0 35 * 30 36 * @param string $intro_text The default Genesis archive intro text. 37 * 31 38 * @return string Archive intro text, or archive description if no intro text set. 32 *33 * @since 1.034 39 */ 35 40 function genesiswooc_term_intro_text_output( $intro_text ) { 41 36 42 $wp_archive_description = get_the_archive_description(); 37 43 … … 41 47 42 48 return $intro_text; 49 43 50 } 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 51 57 52 add_action( 'genesis_loop', 'genesiswooc_product_taxonomy_loop' ); 58 53 /** 59 * Displays shop items for the queried taxonomy term 54 * Displays shop items for the queried taxonomy term. 60 55 * 61 56 * This function has been refactored in 0.9.4 to provide compatibility with 62 * both WooC 1.6.0 and backwards compatibility with older versions.63 * This is needed thanks to substantial changes to WooC template contents64 * introduced in WooC 1.6.0.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. 65 60 * 66 * @uses genesiswooc_content_product() if WooC is version 1.6.0+ 67 * @uses genesiswooc_product_taxonomy() for earlier WooC versions 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 68 65 * 69 66 * @since 0.9.0 70 * @updated 0.9.471 67 */ 72 68 function genesiswooc_product_taxonomy_loop() { … … 76 72 $new = version_compare( $woocommerce->version, '1.6.0', '>=' ); 77 73 78 if ( $new ) 74 if ( $new ) { 79 75 genesiswooc_content_product(); 80 81 else 76 } else { 82 77 genesiswooc_product_taxonomy(); 78 } 83 79 84 80 } -
genesis-connect-woocommerce/trunk
- Property svn:ignore
-
old new 1 .editorconfig 1 2 .git 2 3 .gitignore 3 4 .gitattributes 4 5 .svnignore 6 composer.json 7 composer.lock 5 8 node_modules 9 phpcs.xml.dist 10 vendor
-
- Property svn:ignore
-
genesis-connect-woocommerce/trunk/admin/notices.php
r1921233 r2123371 3 3 * Callbacks for `admin_notices` action to load HTML notices. 4 4 * 5 * @package genesis_connect_woocommerce6 * @ version1.05 * @package Genesis_Connect_WooCommerce 6 * @since 1.0 7 7 */ 8 defined( 'ABSPATH' ) || exit;9 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 */ 10 20 function gencwooc_woocommerce_notice() { 11 21 include GCW_ADMIN_DIR . '/views/html-notice-needs-woocommerce.php'; 12 22 } 13 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 */ 14 31 function gencwooc_genesis_notice() { 15 32 include GCW_ADMIN_DIR . '/views/html-notice-needs-genesis.php'; -
genesis-connect-woocommerce/trunk/admin/views/html-notice-needs-genesis.php
r1921233 r2123371 1 1 <?php 2 2 /** 3 * Admin View: Notice - needs Genesis. 3 * View for WordPress `admin_notice` if Genesis is not active. 4 * 5 * @package Genesis_Connect_WooCommerce 6 * @since 1.0.0 4 7 */ 5 8 6 defined( 'ABSPATH' ) || exit; 9 if ( ! defined( 'ABSPATH' ) ) { 10 exit; 11 } 7 12 8 13 ?> 9 14 <div id="message" class="error notice"> 10 <p><?php _e( '<i>Genesis Connect for WooCommerce</i> requires a Genesis child theme. <strong>Please activate a Genesis theme or disable Genesis Connect.</strong>', 'gencwooc' ); ?></p> 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> 11 18 </div> -
genesis-connect-woocommerce/trunk/admin/views/html-notice-needs-woocommerce.php
r1921233 r2123371 1 1 <?php 2 2 /** 3 * Admin View: Notice - needs WooCommerce. 3 * View for WordPress `admin_notice` if WooCommerce is not active. 4 * 5 * @package Genesis_Connect_WooCommerce 6 * @since 1.0.0 4 7 */ 5 8 6 defined( 'ABSPATH' ) || exit; 9 if ( ! defined( 'ABSPATH' ) ) { 10 exit; 11 } 7 12 8 13 ?> 9 14 <div id="message" class="error notice"> 10 <p><?php _e( '<i>Genesis Connect for WooCommerce</i> requires WooCommerce. <strong>Please activate WooCommerce or disable Genesis Connect.</strong>', 'gencwooc' ); ?></p> 15 <p> 16 <?php esc_html_e( 'Genesis Connect for WooCommerce requires WooCommerce. Please activate WooCommerce or disable Genesis Connect.', 'gencwooc' ); ?> 17 </p> 11 18 </div> -
genesis-connect-woocommerce/trunk/genesis-connect-woocommerce.php
r1921233 r2123371 1 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 WC requires at least: 3.3.0 10 WC tested up to: 3.4 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 */ 11 20 12 License: GNU General Public License v2.0 (or later) 13 License URI: http://www.opensource.org/licenses/gpl-license.php 14 15 Special thanks to Ade Walker (http://www.studiograsshopper.ch/) for his contributions to this plugin. 16 */ 17 18 /** Define the Genesis Connect for WooCommerce constants */ 21 define( 'GCW_DIR', dirname( __FILE__ ) ); 19 22 define( 'GCW_TEMPLATE_DIR', dirname( __FILE__ ) . '/templates' ); 20 define( 'GCW_LIB_DIR', dirname( __FILE__ ) . '/lib' );21 define( 'GCW_ADMIN_DIR', dirname( __FILE__ ) . '/admin' );23 define( 'GCW_LIB_DIR', dirname( __FILE__ ) . '/lib' ); 24 define( 'GCW_ADMIN_DIR', dirname( __FILE__ ) . '/admin' ); 22 25 define( 'GCW_WIDGETS_DIR', dirname( __FILE__ ) . '/widgets' ); 23 26 define( 'GCW_SP_DIR', dirname( __FILE__ ) . '/sp-plugins-integration' ); … … 25 28 add_action( 'after_setup_theme', 'gencwooc_setup' ); 26 29 /** 27 * Setup G CW30 * Setup Genesis Connect for WooCommerce. 28 31 * 29 * Checks whether WooCommerce is active , then checks if relevant30 * theme support exists. Once past these checks, loads the necessary31 * files, actions and filters for the pluginto do its thing.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. 32 35 * 33 36 * @since 0.9.0 … … 36 39 37 40 require_once GCW_ADMIN_DIR . '/notices.php'; 41 38 42 $ready = true; 39 43 40 44 if ( ! function_exists( 'is_plugin_active' ) ) { 41 require_once ( ABSPATH . '/wp-admin/includes/plugin.php' );45 require_once ABSPATH . '/wp-admin/includes/plugin.php'; 42 46 } 43 47 44 48 if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) { 45 49 add_action( 'admin_notices', 'gencwooc_woocommerce_notice' ); 50 46 51 $ready = false; 47 52 } … … 61 66 global $woocommerce; 62 67 63 /** Load GCW files */ 64 require_once( GCW_LIB_DIR . '/template-loader.php' ); 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'; 65 71 66 // Load posts per page option 67 require_once( GCW_LIB_DIR . '/posts-per-page.php' ); 72 if ( ! current_theme_supports( 'gencwooc-woo-breadcrumbs' ) ) { 73 require_once GCW_LIB_DIR . '/breadcrumb.php'; 74 } 68 75 69 /** Load modified Genesis breadcrumb filters and callbacks */70 if ( ! current_theme_supports( 'gencwooc-woo-breadcrumbs') )71 require_once( GCW_LIB_DIR . '/breadcrumb.php' );72 73 /** Ensure WooCommerce 2.0+ compatibility */74 76 add_theme_support( 'woocommerce' ); 75 77 76 /** Add Genesis Layout, Genesis Scripts and SEO options to Product edit screen */77 78 add_post_type_support( 'product', array( 'genesis-layouts', 'genesis-scripts', 'genesis-seo' ) ); 78 79 /** Add Studiopress plugins support */80 79 add_post_type_support( 'product', array( 'genesis-simple-sidebars', 'genesis-simple-menus' ) ); 81 80 82 /** Add Widgets */83 81 if ( current_theme_supports( 'gencwooc-featured-products-widget' ) ) { 84 require_once ( GCW_WIDGETS_DIR . '/woocommerce-featured-widgets.php' );82 require_once GCW_WIDGETS_DIR . '/class-gencwooc-featured-products.php'; 85 83 } 86 84 87 /** Take control of shop template loading */88 85 remove_filter( 'template_include', array( &$woocommerce, 'template_loader' ) ); 89 86 add_filter( 'template_include', 'gencwooc_template_loader', 20 ); 90 87 91 /** Integration - Genesis Simple Sidebars */92 88 if ( is_plugin_active( 'genesis-simple-sidebars/plugin.php' ) ) { 93 require_once ( GCW_SP_DIR . '/genesis-simple-sidebars.php' );89 require_once GCW_SP_DIR . '/genesis-simple-sidebars.php'; 94 90 } 95 91 96 /** Integration - Genesis Simple Menus */97 92 if ( is_plugin_active( 'genesis-simple-menus/simple-menu.php' ) ) { 98 require_once ( GCW_SP_DIR . '/genesis-simple-menus.php' );93 require_once GCW_SP_DIR . '/genesis-simple-menus.php'; 99 94 } 100 95 101 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 } -
genesis-connect-woocommerce/trunk/lib/breadcrumb.php
r1812865 r2123371 1 1 <?php 2 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 * archives in the same way as WooC's breadcrumbs. These filters and callback 13 * functions modify the default Genesis breadcrumb output so that the breadcrumb 14 * trail mimics that of WooC's breadcrumbs, for: 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: 15 12 * - Shop page (archive page) 16 13 * - Single product 17 14 * - Taxonomy archive 18 15 * 19 * Users who prefer to use WooC 'sbreadcrumbs can do so by adding this to their child16 * Users who prefer to use WooCommerce breadcrumbs can do so by adding this to their child 20 17 * theme's functions.php: 21 18 * - add_theme_support( 'gencwooc-woo-breadcrumbs' ); … … 23 20 * - remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' ); 24 21 * 25 * @see readme.txt for more details22 * @see readme.txt For more details. 26 23 * 27 24 * As this modification code uses existing Genesis Breadcrumb filters there is a risk that … … 32 29 * @see genesis/lib/classes/breadcrumb.php v1.8 33 30 * @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 31 */ 32 33 if ( ! defined( 'ABSPATH' ) ) { 34 exit; 35 } 46 36 47 37 add_filter( 'genesis_archive_crumb', 'gencwooc_get_archive_crumb_filter', 10, 2 ); 48 38 /** 49 * Filter the Genesis Breadcrumbs archive crumb 50 * 51 * Needed for Product Archive (Shop page) and Taxonomy archives 39 * Filter the Genesis Breadcrumbs archive crumb. 40 * 41 * Needed for Product Archive (Shop page) and Taxonomy archives. 52 42 * 53 43 * Note: relevant WooCommerce settings (WooCommerce > Settings > Pages tab): … … 57 47 * 58 48 * @since 0.9.0 59 * @updated 0.9.760 * 61 * @param str $crumb Breadcrumb 'crumb' for archives62 * @param array $args Genesis Breadcrumb args63 * @return str $crumb, either modified $crumb, or original $crumb49 * 50 * @param string $crumb Breadcrumb 'crumb' for archives. 51 * @param array $args Genesis Breadcrumb args. 52 * 53 * @return string $crumb Breadcrumb 'crumb' for archives. 64 54 */ 65 55 function gencwooc_get_archive_crumb_filter( $crumb, $args ) { 66 56 67 /** Are we on the product archive page? */ 68 if ( is_post_type_archive( 'product') && get_option( 'page_on_front' ) !== wc_get_page_id( 'shop' ) ) { 69 70 $shop_id = wc_get_page_id( 'shop' ); 71 72 $shop_name = $shop_id ? get_the_title( $shop_id ) : ucwords( get_option('woocommerce_shop_slug') ); 73 74 if ( is_search() ) : 75 76 $crumb = gencwooc_get_crumb_link( get_post_type_archive_link( 'product' ), $shop_name, $shop_name, $args['sep'] . __( 'Search results for “', 'woocommerce' ) . get_search_query() . '”' ); 77 78 else : 79 80 $crumb = $shop_name; 81 82 endif; 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 } 83 70 84 71 return apply_filters( 'gencwooc_product_archive_crumb', $crumb, $args ); 85 72 } 86 73 87 88 /** Are we on a shop taxonomy archive page? */89 74 if ( is_tax( 'product_cat' ) || is_tax( 'product_tag' ) ) { 90 91 $crumb = ''; 92 93 $prepend = ''; 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' ); 75 $crumb = ''; 76 $prepend = ''; 77 $shop_url = get_option( 'woocommerce_prepend_shop_page_to_urls' ); 78 $shop_id = wc_get_page_id( 'shop' ); 99 79 $shop_title = get_the_title( $shop_id ); 100 80 101 if ( 'yes' == $shop_url && $shop_id && get_option( 'page_on_front' ) !== $shop_id )81 if ( 'yes' === $shop_url && $shop_id && get_option( 'page_on_front' ) !== $shop_id ) { 102 82 $prepend = gencwooc_get_crumb_link( get_permalink( $shop_id ), $shop_title, $shop_title, $args['sep'] ); 103 83 } 104 84 } 105 85 106 86 if ( is_tax( 'product_cat' ) ) { 107 108 $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); 109 87 $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); 110 88 $parents = array(); 111 $parent = $term->parent; 112 while ( $parent ): 113 $parents[] = $parent; 89 $parent = $term->parent; 90 91 while ( $parent ) { 92 $parents[] = $parent; 114 93 $new_parent = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ) ); 115 $parent = $new_parent->parent;116 endwhile;94 $parent = $new_parent->parent; 95 } 117 96 118 97 $crumb .= $prepend; 119 98 120 if ( ! empty( $parents ) ) :99 if ( ! empty( $parents ) ) { 121 100 $parents = array_reverse( $parents ); 122 foreach ( $parents as $parent ) : 123 $item = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ) ); 101 102 foreach ( $parents as $parent ) { 103 $item = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ) ); 124 104 $crumb .= gencwooc_get_crumb_link( get_term_link( $item->slug, 'product_cat' ), $item->name, $item->name, $args['sep'] ); 125 endforeach;126 endif;105 } 106 } 127 107 128 108 $crumb .= single_term_title( '', false ); … … 132 112 133 113 if ( is_tax( 'product_tag' ) ) { 134 135 114 $crumb .= $prepend . __( 'Products tagged “', 'gencwooc' ) . single_term_title( '', false ) . _x( '”', 'endquote', 'gencwooc' ); 136 115 … … 138 117 } 139 118 140 /** Original unmodified */141 119 return $crumb; 142 } 143 120 121 } 144 122 145 123 add_filter( 'genesis_single_crumb', 'gencwooc_get_single_crumb', 10, 2 ); 146 124 /** 147 * Filter the Genesis Breadcrumbs singular crumb 148 * 149 * Needed for single Product pages 150 * 151 * @since 0.9.0 152 * 153 * @param str $crumb Breadcrumb 'crumb' for single posts 154 * @param array $args Genesis Breadcrumb args 155 * @return str $crumb, either modified $crumb, or original $crumb 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. 156 137 */ 157 138 function gencwooc_get_single_crumb( $crumb, $args ) { 158 139 159 /** Are we on a single product page? */160 140 if ( is_singular( 'product' ) ) { 161 162 141 global $post; 163 142 164 $crumb = ''; 165 $prepend = ''; 166 167 /** Should we prepend crumb with 'shop' page link? */ 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' ); 143 $crumb = ''; 144 $prepend = ''; 145 $shop_url = get_option( 'woocommerce_prepend_shop_page_to_urls' ); 146 $shop_id = wc_get_page_id( 'shop' ); 171 147 $shop_title = get_the_title( $shop_id ); 172 148 173 if ( 'yes' == $shop_url && $shop_id && get_option( 'page_on_front' ) !== $shop_id )149 if ( 'yes' === $shop_url && $shop_id && get_option( 'page_on_front' ) !== $shop_id ) { 174 150 $prepend = gencwooc_get_crumb_link( get_permalink( $shop_id ), $shop_title, $shop_title, $args['sep'] ); 151 } 175 152 176 153 $crumb .= $prepend; 177 178 if ( $terms = wp_get_object_terms( $post->ID, 'product_cat' ) ) : 179 $term = current( $terms ); 154 $terms = wp_get_object_terms( $post->ID, 'product_cat' ); 155 156 if ( $terms ) { 157 $term = current( $terms ); 180 158 $parents = array(); 181 $parent = $term->parent; 182 while ( $parent ): 183 $parents[] = $parent; 159 $parent = $term->parent; 160 161 while ( $parent ) { 162 $parents[] = $parent; 184 163 $new_parent = get_term_by( 'id', $parent, 'product_cat' ); 185 $parent = $new_parent->parent;186 endwhile;187 188 if ( ! empty( $parents ) ):164 $parent = $new_parent->parent; 165 } 166 167 if ( ! empty( $parents ) ) { 189 168 $parents = array_reverse( $parents ); 190 foreach ( $parents as $parent ) : 191 $item = get_term_by( 'id', $parent, 'product_cat' ); 169 170 foreach ( $parents as $parent ) { 171 $item = get_term_by( 'id', $parent, 'product_cat' ); 192 172 $crumb .= gencwooc_get_crumb_link( get_term_link( $item->slug, 'product_cat' ), $item->name, $item->name, $args['sep'] ); 193 endforeach; 194 endif; 173 } 174 } 175 195 176 $crumb .= gencwooc_get_crumb_link( get_term_link( $term->slug, 'product_cat' ), $term->name, $term->name, $args['sep'] ); 196 endif;177 } 197 178 198 179 $crumb .= get_the_title(); … … 201 182 } 202 183 203 /** Fallback - original unmodified */204 184 return $crumb; 205 } 206 185 186 } 207 187 208 188 /** 209 189 * Helper function to create anchor link for a single crumb. 210 190 * 211 * This is a copy of Genesis_Breadcrumb::get_breadcrumb_link() (G1.8) 212 * 213 * @since 0.9.0 214 * 215 * @param string $url URL for href attribute 216 * @param string $title title attribute 217 * @param string $content linked content 218 * @param string $sep Separator 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 * 219 200 * @return string HTML markup for anchor link and optional separator. 220 201 */ 221 202 function gencwooc_get_crumb_link( $url, $title, $content, $sep = false ) { 222 203 223 $link = sprintf( '<a href="%s" title="%s">%s</a>', esc_attr( $url ), esc_attr( $title ), esc_html( $content ) ); 224 225 if ( $sep ) 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 ) { 226 212 $link .= $sep; 213 } 227 214 228 215 return $link; -
genesis-connect-woocommerce/trunk/lib/posts-per-page.php
r1575771 r2123371 1 1 <?php 2 2 /** 3 * These functions manage loading of plugin-specific addons to the WooCommerce 4 * settings page. 3 * These functions manage loading of plugin-specific addons to the WooCommerce settings page. 5 4 * 6 * @package genesis_connect_woocommerce 7 * @version 0.9.8 8 * 5 * @package Genesis_Connect_WooCommerce 9 6 * @since 0.9.0 10 7 */ 11 8 12 /** 13 * Prevent direct access to this file 14 */ 15 if ( ! defined( 'ABSPATH' ) ) 16 exit( _( 'Sorry, you are not allowed to access this file directly.' ) ); 9 if ( ! defined( 'ABSPATH' ) ) { 10 exit; 11 } 17 12 18 13 add_filter( 'woocommerce_settings_tabs_array', 'genesis_connect_addon_tab', 50 ); 19 /* 14 /** 20 15 * Add a custom tab in the WooCommerce settings for Genesis Connect. 21 16 * 22 17 * @since 1.0.0 18 * 19 * @param array $tabs Used to add a tab to the WooCommerce settings page. 20 * 23 21 * @return array $tabs Used to add a tab to the WooCommerce settings page. 24 22 */ 25 23 function genesis_connect_addon_tab( $tabs ) { 26 24 27 // Add our own section.28 25 $tabs['gencwooc'] = __( 'Genesis Connect Addons', 'gencwooc' ); 26 29 27 return $tabs; 30 28 … … 36 34 * 37 35 * @since 1.0.0 38 * @return array Multiple arrays holding our section information39 36 */ 40 41 37 function genesis_connect_settings_tab() { 42 woocommerce_admin_fields( genesis_connect_get_settings() );38 woocommerce_admin_fields( genesis_connect_get_settings() ); 43 39 } 44 40 … … 48 44 * 49 45 * @since 1.0.0 50 * @return array Settings to update.51 46 */ 52 47 function genesis_connect_update_settings() { 53 woocommerce_update_options( genesis_connect_get_settings() );48 woocommerce_update_options( genesis_connect_get_settings() ); 54 49 } 55 50 … … 58 53 * 59 54 * @since 1.0.0 55 * 60 56 * @return array $settings Array of our settings. 61 57 */ 62 58 function genesis_connect_get_settings() { 63 $settings = array( 59 60 $settings = array( 64 61 'gencwooc_section_title' => array( 65 62 'name' => __( 'Genesis Connect Addons', 'gencwooc' ), 66 63 'type' => 'title', 67 64 'desc' => 'Set and save additional WooCommerce settings here.', 68 'id' => 'gencwooc_section_title' 65 'id' => 'gencwooc_section_title', 69 66 ), 70 'products_per_page' => array(67 'products_per_page' => array( 71 68 'name' => __( 'Products Per Page', 'gencwooc' ), 72 69 'type' => 'number', … … 74 71 'id' => 'gencwooc_products_per_page', 75 72 'default' => apply_filters( 'genesiswooc_default_products_per_page', get_option( 'posts_per_page' ) ), 76 ), 77 'section_end' => array( 78 'type' => 'sectionend', 79 'id' => 'gencwooc_section_end' 80 ) 81 ); 82 return $settings; 73 ), 74 'section_end' => array( 75 'type' => 'sectionend', 76 'id' => 'gencwooc_section_end', 77 ), 78 ); 79 80 return $settings; 81 83 82 } 84 83 84 add_filter( 'loop_shop_per_page', 'genesiswooc_products_per_page' ); 85 85 /** 86 * Execute settings on the frontend (this should probably 87 * go somewhere else other than this file). 86 * Execute settings on the frontend (this should probably go somewhere else other than this file). 88 87 * 89 88 * @since 1.0.0 90 * @return array $q New query for the product page. 89 * 90 * @param integer $count Products per page to display. 91 * 92 * @return integer $count Products per page to display. 91 93 */ 92 add_filter( 'loop_shop_per_page', 'genesiswooc_products_per_page' );93 94 function genesiswooc_products_per_page( $count ) { 94 95 95 $count = get_option( 'gencwooc_products_per_page' ) ? get_option( 'gencwooc_products_per_page' ) : apply_filters( 'genesiswooc_default_products_per_page', get_option( 'posts_per_page' ) ); 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 } 96 101 97 102 return $count; -
genesis-connect-woocommerce/trunk/lib/template-loader.php
r1921233 r2123371 1 1 <?php 2 2 /** 3 * These functions manage loading of templates for WooCommerce 4 * 5 * @package genesis_connect_woocommerce 6 * @version 0.9.8 7 * 3 * These functions manage loading of templates for WooCommerce. 4 * 5 * @package Genesis_Connect_WooCommerce 8 6 * @since 0.9.0 9 7 */ 10 8 11 /** 12 * Prevent direct access to this file 13 */ 14 if ( ! defined( 'ABSPATH' ) ) 15 exit( _( 'Sorry, you are not allowed to access this file directly.' ) ); 16 17 9 if ( ! defined( 'ABSPATH' ) ) { 10 exit; 11 } 18 12 19 13 /** 20 14 * Load the Genesis-fied templates, instead of the WooCommerce defaults. 21 15 * 22 * Hooked to 'template_include' filter 23 * 24 * This template loader determines which template file will be used for the requested page, and uses the25 * following hierarchy to find the template: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: 26 20 * 1. First looks in the child theme's 'woocommerce' folder. 27 21 * 2. If no template found, falls back to GCW's templates. 28 22 * 29 * For taxonomy templates, first looks in child theme's 'woocommerce' folder and searches for term specific template, 30 * then taxonomy specific template, then taxonomy.php. If no template found, falls back to GCW's taxonomy.php. 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. 31 26 * 32 27 * GCW provides three templates in the plugin's 'templates' directory: … … 35 30 * - taxonomy.php 36 31 * 37 * Users can override GCW templates by placing their own templates in their child theme's 'woocommerce' folder. 38 * The 'woocommerce' folder must be a folder in the child theme's root directory, eg themes/my-child-theme/woocommerce 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 * 39 36 * Permitted user templates (as per WP Template Hierarchy) are: 40 37 * - single-product.php … … 44 41 * - taxonomy.php 45 42 * 46 * Note that in the case of taxonomy templates, this function accommodates ALL taxonomies registered to the 47 * 'product' custom post type. This means that it will cater for users' own custom taxonomies as well as WooC's. 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. 48 46 * 49 47 * @since 0.9.0 50 48 * 51 * @param string $template Template file as per template hierarchy 52 * @return string $template Specific GCW template if a product page (single or archive)53 * or a product taxonomy term, or returns original template49 * @param string $template Template file as per template hierarchy. 50 * 51 * @return string $template Template file as per template hierarchy. 54 52 */ 55 53 function gencwooc_template_loader( $template ) { … … 59 57 } 60 58 61 if ( is_single() && 'product' == get_post_type() ) { 62 59 if ( is_single() && 'product' === get_post_type() ) { 63 60 $template = locate_template( array( 'woocommerce/single-product.php' ) ); 64 61 65 if ( ! $template ) 62 if ( ! $template ) { 66 63 $template = GCW_TEMPLATE_DIR . '/single-product.php'; 67 68 } 69 elseif ( is_post_type_archive( 'product' ) || is_page( wc_get_page_id( 'shop' ) ) ) { 70 64 } 65 } elseif ( is_post_type_archive( 'product' ) || is_page( wc_get_page_id( 'shop' ) ) ) { 71 66 $template = locate_template( array( 'woocommerce/archive-product.php' ) ); 72 67 73 if ( ! $template ) 68 if ( ! $template ) { 74 69 $template = GCW_TEMPLATE_DIR . '/archive-product.php'; 75 76 } 77 elseif ( is_tax() ) { 78 79 $term = get_query_var( 'term' ); 80 81 $tax = get_query_var( 'taxonomy' ); 82 83 /** Get an array of all relevant taxonomies */ 70 } 71 } elseif ( is_tax() ) { 72 $term = get_query_var( 'term' ); 73 $tax = get_query_var( 'taxonomy' ); 84 74 $taxonomies = get_object_taxonomies( 'product', 'names' ); 85 75 86 if ( in_array( $tax, $taxonomies ) ) { 87 88 $tax = sanitize_title( $tax ); 76 if ( in_array( $tax, $taxonomies, true ) ) { 77 $tax = sanitize_title( $tax ); 89 78 $term = sanitize_title( $term ); 90 79 91 80 $templates = array( 92 'woocommerce/taxonomy-'.$tax.'-'.$term.'.php',93 'woocommerce/taxonomy-'.$tax.'.php',81 "woocommerce/taxonomy-{$tax}-{$term}.php", 82 "woocommerce/taxonomy-{$tax}.php", 94 83 'woocommerce/taxonomy.php', 95 84 ); … … 97 86 $template = locate_template( $templates ); 98 87 99 /** Fallback to GCW template */ 100 if ( ! $template ) 88 if ( ! $template ) { 101 89 $template = GCW_TEMPLATE_DIR . '/taxonomy.php'; 90 } 102 91 } 103 92 } … … 107 96 } 108 97 109 110 111 /** 112 * Shop Loop 'template part' loader 98 /** 99 * Shop Loop 'template part' loader. 113 100 * 114 101 * ONLY RETAINED FOR BACKWARDS COMPATIBILITY for GCW pre-0.9.2 custom templates which … … 118 105 * loads the default WooCommerce loop-shop.php file. 119 106 * 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. 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 * 125 113 * It is recommended to use woocommerce/templates/loop-shop.php as the starting point of 126 114 * any custom loop template. … … 129 117 * 130 118 * Note: updated v0.9.3 to reflect changes to woocommerce_get_template_part() introduced in 131 * WooC v1.4+ and, effectively, this function is a clone of woocommerce_get_template_part() 119 * WooCommerce v1.4+ and, effectively, this function is a clone of woocommerce_get_template_part() 120 * 121 * @global object $woocommerce WooCommerce instance 132 122 * 133 123 * @since 0.9.0 134 * @updated 0.9.8 135 * @global object $woocommerce WooCommerce instance 136 */ 137 function gencwooc_get_template_part( $slug, $name = '' ) { 124 * 125 * @param string $slug The template slug. 126 * @param string $name The template name. 127 */ 128 function gencwooc_get_template_part( $slug, $name = '' ) { 138 129 139 130 global $woocommerce; 131 140 132 $template = ''; 141 133 142 // Look in yourtheme/slug-name.php and yourtheme/woocommerce/slug-name.php 143 if ( $name ) 144 $template = locate_template( array ( "{$slug}-{$name}.php", "{$woocommerce->template_url}{$slug}-{$name}.php" ) ); 145 146 // Get default slug-name.php 147 if ( !$template && $name && file_exists( $woocommerce->plugin_path() . "/templates/{$slug}-{$name}.php" ) ) 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" ) ) { 148 139 $template = $woocommerce->plugin_path() . "/templates/{$slug}-{$name}.php"; 149 150 // If template file doesn't exist, look in yourtheme/slug.php and yourtheme/woocommerce/slug.php 151 if ( !$template ) 152 $template = locate_template( array ( "{$slug}.php", "{$woocommerce->template_url}{$slug}.php" ) ); 153 154 if ( $template ) 140 } 141 142 if ( ! $template ) { 143 $template = locate_template( array( "{$slug}.php", "{$woocommerce->template_url}{$slug}.php" ) ); 144 } 145 146 if ( $template ) { 155 147 load_template( $template, false ); 156 } 157 158 159 /** 160 * Display shop items 161 * 162 * FOR BACKWARDS COMPATIBILITY with WooCommerce versions pre-1.6.0 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 * Code based on WooCommerce 1.5.5 woocommerce_archive_product_content() 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 * 168 163 * @see woocommerce/woocommerce-template.php 169 164 * 170 *171 165 * @since 0.9.4 172 * @updated 0.9.6173 * @global string|int $shop_page_id The ID of the Shop WP Page 166 * 167 * @global string|int $shop_page_id The ID of the Shop WP Page. 174 168 */ 175 169 function genesiswooc_product_archive() { … … 177 171 global $shop_page_id; 178 172 179 if ( !is_search() ) : 180 $shop_page = get_post( $shop_page_id ); 181 $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 ); 182 $shop_page_content = $shop_page->post_content; 183 else : 184 $shop_page_title = __( 'Search Results:', 'woocommerce' ) . ' “' . get_search_query() . '”'; 185 if ( get_query_var( 'paged' ) ) $shop_page_title .= ' — ' . __( 'Page', 'woocommerce' ) . ' ' . get_query_var( 'paged' ); 186 $shop_page_content = ''; 187 endif; 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 } 188 186 189 187 do_action( 'woocommerce_before_main_content' ); 190 ?> 191 192 <h1 class="page-title"><?php echo $shop_page_title ?></h1> 193 194 <?php echo apply_filters( 'the_content', $shop_page_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 195 196 196 woocommerce_get_template_part( 'loop', 'shop' ); … … 199 199 200 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() 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 * 212 213 * @see woocommerce/woocommerce-template.php 213 214 * 214 *215 215 * @since 0.9.4 216 216 */ … … 227 227 } 228 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 * Uses WooCommerce structure and contains all existing WooCommerce hooks 236 * 237 * Code based on WooCommerce 2.1.12 templates/archive-product.php 238 * 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. 239 237 * 240 238 * @since 0.9.4 241 * @updated 0.9.8242 239 */ 243 240 function genesiswooc_content_product() { 244 241 245 242 /** 246 * woocommerce_before_main_content hook243 * For woocommerce_before_main_content hook. 247 244 * 248 245 * @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content) … … 253 250 if ( apply_filters( 'woocommerce_show_page_title', true ) ) { 254 251 echo '<h1 class="woocommerce-products-header__title page-title">'; 252 255 253 woocommerce_page_title(); 254 256 255 echo '</h1>'; 257 256 } … … 268 267 */ 269 268 do_action( 'woocommerce_before_shop_loop' ); 269 270 270 woocommerce_product_loop_start(); 271 271 272 if ( wc_get_loop_prop( 'total' ) ) { 272 273 while ( have_posts() ) { 273 274 the_post(); 275 274 276 /** 275 277 * Hook: woocommerce_shop_loop. … … 278 280 */ 279 281 do_action( 'woocommerce_shop_loop' ); 282 280 283 wc_get_template_part( 'content', 'product' ); 281 284 } 282 285 } 286 283 287 woocommerce_product_loop_end(); 288 284 289 /** 285 290 * Hook: woocommerce_after_shop_loop. … … 296 301 do_action( 'woocommerce_no_products_found' ); 297 302 } 303 298 304 /** 299 305 * Hook: woocommerce_after_main_content. -
genesis-connect-woocommerce/trunk/readme.txt
r1921233 r2123371 3 3 Tags: genesis, genesiswp, studiopress, woocommerce 4 4 Requires at least: 3.3 5 Tested up to: 4.96 Stable tag: 1. 05 Tested up to: 5.2.2 6 Stable tag: 1.1.0 7 7 8 8 This plugin allows you to seamlessly integrate WooCommerce with the Genesis Framework and Genesis child themes. … … 131 131 132 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. 133 138 134 139 = 1.0 = … … 163 168 = 0.9.8 = 164 169 * Released 9 July 2014 165 * Updates genesiswooc_content_product() to reflect WooC 2.1+ templates and correct handling of WooC'spage title filter function170 * Updates genesiswooc_content_product() to reflect WooCommerce 2.1+ templates and correct handling of WooCommerce page title filter function 166 171 167 172 = 0.9.7 = … … 188 193 = 0.9.2 = 189 194 * Released 15 March 2012 190 * single-product.php - Single product title template file now hooked in as per WooC 1.5.2195 * single-product.php - Single product title template file now hooked in as per WooCommerce 1.5.2 191 196 192 197 = 0.9.1 = -
genesis-connect-woocommerce/trunk/sp-plugins-integration/genesis-simple-menus.php
r1812865 r2123371 1 1 <?php 2 2 /** 3 * Integration - Genesis Simple Menus3 * Genesis Simple Menus integration. 4 4 * 5 * @package genesis_connect_woocommerce 6 * @version 0.9.8 7 8 * 5 * @package Genesis_Connect_WooCommerce 9 6 * @since 0.9.0 10 7 * … … 12 9 * 13 10 * What GCW integration needs to do: 14 * 1. add_post_type_support for 'genesis-simple-menus'15 * 2. deal with serving correct GSM menu for Shop page (product archive)11 * 1. add_post_type_support for 'genesis-simple-menus' 12 * 2. deal with serving correct GSM menu for Shop page (product archive) 16 13 * 17 14 * What GCW does: 18 * 1. GCW adds post_type_support for GSM - see gencwooc_setup()19 * 2. uses Genesis filters to intercept request and serve correct GSM menu on Shop Page15 * 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 20 17 * 21 18 * Note: this file is loaded on the 'after_theme_setup' hook only if GSM 22 19 * is activated. 23 20 * @see gencwooc_setup() in genesis-connect-woocommerce.php 24 *25 21 */ 26 22 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 23 if ( ! defined( 'ABSPATH' ) ) { 24 exit; 25 } 33 26 34 27 add_filter( 'genesis_pre_get_option_subnav_type', 'gencwooc_gsm_subnav_type', 9 ); 35 28 /** 36 * Tells Genesis to load a custom menu 29 * Tells Genesis to load a custom menu. 37 30 * 38 31 * @since 0.9.0 39 32 * 40 33 * @see Genesis_Simple_Menus::wp_head() 41 * @param str $nav 42 * @return str 'nav-menu' which tells Genesis to get a custom menu 34 * 35 * @param string $nav The sub nav type. 36 * 37 * @return string The sub nav type. 43 38 */ 44 39 function gencwooc_gsm_subnav_type( $nav ) { … … 49 44 add_filter( 'theme_mod_nav_menu_locations', 'gencwooc_gsm_theme_mod' ); 50 45 /** 51 * Replace the menu selected in the WordPress Menu settings with the custom one for this request 46 * Replace the menu selected in the WordPress Menu settings with the custom one for this request. 52 47 * 53 48 * @since 0.9.0 54 49 * 55 50 * @see Genesis_Simple_Menus::wp_head() 56 * @param array $mods Array of theme mods 57 * @return array $mods Modified array of theme mods 51 * 52 * @param array $mods Array of theme mods. 53 * 54 * @return array $mods Array of theme mods. 58 55 */ 59 56 function gencwooc_gsm_theme_mod( $mods ) { 60 57 61 /** Post meta key as per GSM 0.1.4 */62 $ field_name = '_gsm_menu';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 ); 63 60 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 = get_post_meta( $shop_id, $field_name, true ) ) 61 if ( is_post_type_archive( 'product' ) && $_menu ) { 67 62 $mods['secondary'] = (int) $_menu; 63 } 68 64 69 65 return $mods; -
genesis-connect-woocommerce/trunk/sp-plugins-integration/genesis-simple-sidebars.php
r1921233 r2123371 1 1 <?php 2 2 /** 3 * Integration - Genesis Simple Sidebars3 * Genesis Simple Sidebars integration. 4 4 * 5 * @package genesis_connect_woocommerce 6 * @version 0.9.8 7 * 5 * @package Genesis_Connect_WooCommerce 8 6 * @since 0.9.0 9 7 * 10 * Based on Genesis Simple Sidebars (GSS) version 0.9.2 8 * Based on Genesis Simple Sidebars (GSS) version 0.9.2. 11 9 * 12 10 * What GCW integration needs to do: 13 * 1. add_post_type_support for 'genesis-simple-sidebars'14 * 2. deal with serving correct GSS sidebar(s) for Shop page (product archive)11 * 1. Add_post_type_support for 'genesis-simple-sidebars'. 12 * 2. Deal with serving correct GSS sidebar(s) for Shop page (product archive). 15 13 * 16 14 * What GCW does: 17 * 1. GCW adds post_type_support for GSS - see gencwooc_setup()18 * 2. intercepts GSS sidebar loading functions, deals with Shop Page,19 * then hands back control of sidebar loading in all other cases to GSS 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. 20 18 * 21 * Note: this file is loaded on the 'after_theme_setup' hook only if GSS 22 * is activated. 19 * Note: this file is loaded on the 'after_theme_setup' hook only if GSS is activated. 23 20 * @see gencwooc_setup() in genesis-connect-woocommerce.php 24 *25 * @TODO simply these functions26 21 */ 27 22 28 /** 29 * Prevent direct access to this file 30 */ 31 if ( ! defined( 'ABSPATH' ) ) 32 exit( __( 'Sorry, you are not allowed to access this file directly.', 'genwooc' ) ); 23 if ( ! defined( 'ABSPATH' ) ) { 24 exit; 25 } 33 26 34 27 35 28 add_action( 'get_header', 'gencwooc_ss_handler', 11 ); 36 29 /** 37 * Take control of GSS sidebar loading 30 * Take control of GSS sidebar loading. 38 31 * 39 * Hooked to 'get_header' with priority of 11 to ensure that GSS's 40 * actions, which are unhooked here in this function, have been added 41 * and therefore can be removed. 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. 42 34 * 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. 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 * 45 38 * @see GSS ss_sidebars_init() in genesis-simple-sidebars/plugin.php 46 39 * 47 40 * Note for developers: 48 41 * ==================== 49 * If you want to do more complex manipulations of sidebars, eg load another one 50 * altogether (ie not a GSS sidebar, G Sidebar or G Sidebar Alt), unhook this51 * function and replace it withyour own version.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. 52 45 * 53 46 * @since 0.9.0 54 *55 47 */ 56 48 function gencwooc_ss_handler() { 57 49 58 /** Unhook GSS functions */59 50 remove_action( 'genesis_sidebar', 'ss_do_sidebar' ); 60 51 remove_action( 'genesis_sidebar_alt', 'ss_do_sidebar_alt' ); 61 52 62 /** Hook replacement functions */63 53 add_action( 'genesis_sidebar', 'gencwooc_ss_do_sidebar' ); 64 54 add_action( 'genesis_sidebar_alt', 'gencwooc_ss_do_sidebar_alt' ); … … 68 58 69 59 /** 70 * Callback for dealing with Primary Sidebar loading 60 * Callback for dealing with Primary Sidebar loading. 71 61 * 72 * Intercepts GSS code flow, so that Shop page can be dealt with, then 73 * hands back control to the GSS function for loading primary sidebars.74 * Effectively, it's just a more complex version of ss_do_sidebar()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(). 75 65 * 76 * Checks if we're on the product archive and a GSS sidebar has been 77 * assigned in the Shop WP Page editor, then, if both true, loads the relevant 78 * GSS sidebar on the Shop Page. 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. 79 68 * 80 69 * If either of the above conditions return false, we load the regular sidebar. … … 83 72 * 84 73 * @uses woocommerce_get_page_id() 85 *86 74 */ 87 75 function gencwooc_ss_do_sidebar() { 88 76 89 $bar = '_ss_sidebar';90 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 ); 91 79 92 if ( is_post_type_archive( 'product' ) && $_bar = get_post_meta( $shop_id, $bar, true ) ) { 93 80 if ( is_post_type_archive( 'product' ) && $_bar ) { 94 81 dynamic_sidebar( $_bar ); 95 96 82 } else { 97 98 83 genesis_do_sidebar(); 99 100 84 } 101 85 … … 104 88 105 89 /** 106 * Callback for dealing with Sidebar Alt loading 90 * Callback for dealing with Sidebar Alt loading. 107 91 * 108 * Intercepts GSS code flow, so that Shop page can be dealt with, then 109 * hands back control to the GSS function for loading secondary sidebars.110 * Effectively, it's just a more complex version of ss_do_sidebar_alt()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(). 111 95 * 112 * Checks if we're on the product archive and a GSS sidebar has been 113 * assigned in the Shop WP Page editor, then, if both true, loads the relevant 114 * GSS sidebar on the Shop Page. 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. 115 98 * 116 99 * If either of the above conditions return false, we load the regular alt sidebar. … … 119 102 * 120 103 * @uses woocommerce_get_page_id() 121 *122 104 */ 123 105 function gencwooc_ss_do_sidebar_alt() { 124 106 125 $bar = '_ss_sidebar_alt';126 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 ); 127 109 128 if ( is_post_type_archive( 'product' ) && $_bar = get_post_meta( $shop_id, $bar, true ) ) { 129 110 if ( is_post_type_archive( 'product' ) && $_bar ) { 130 111 dynamic_sidebar( $_bar ); 131 132 112 } else { 133 134 113 genesis_do_sidebar_alt(); 135 136 114 } 137 115 -
genesis-connect-woocommerce/trunk/templates/archive-product.php
r1921233 r2123371 1 1 <?php 2 2 /** 3 * This template displays the archive for Products 3 * This template displays the archive for Products. 4 4 * 5 * @package genesis_connect_woocommerce5 * @package Genesis_Connect_WooCommerce 6 6 * @version 0.9.8 7 * @since 0.9.0 7 8 * 8 9 * Note for customisers/users: Do not edit this file! … … 13 14 * The version in the child theme's woocommerce folder will override this template, and 14 15 * any future updates to this plugin won't wipe out your customisations. 15 *16 * @since 0.9.017 *18 16 */ 19 17 20 /** Remove default Genesis loop */ 18 if ( ! defined( 'ABSPATH' ) ) { 19 exit; 20 } 21 21 22 remove_action( 'genesis_loop', 'genesis_do_loop' ); 22 23 /** Remove Genesis archive title/description */24 23 remove_action( 'genesis_before_loop', 'genesis_do_taxonomy_title_description', 15 ); 25 26 /** Remove WooCommerce breadcrumbs */27 24 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 25 remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 ); 34 26 remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 ); … … 42 34 * @since 0.9.0 43 35 * 44 * @param str $layout Current Genesis page layout, such as 'content-sidebar'. 45 * @return str Page layout if set for the shop page, otherwise the default site layout. 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. 46 39 */ 47 40 function genesiswooc_archive_layout( $layout ) { … … 61 54 * Display shop items (product custom post archive) 62 55 * 63 * This function has been refactored in 0.9.4 to provide compatibility with 64 * both WooC 1.6.0 and backwards compatibility with older versions. 65 * This is needed thanks to substantial changes to WooC template contents 66 * introduced in WooC 1.6.0. 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. 67 58 * 68 * @uses genesiswooc_content_product() if WooC is version 1.6.0+ 69 * @uses genesiswooc_product_archive() for earlier WooC versions 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 70 64 * 71 65 * @since 0.9.0 72 * @updated 0.9.473 * @global object $woocommerce66 * 67 * @global WooCommerce $woocommerce Current WooCommerce instance. 74 68 */ 75 69 function genesiswooc_archive_product_loop() { … … 79 73 $new = version_compare( $woocommerce->version, '1.6.0', '>=' ); 80 74 81 if ( $new ) 75 if ( $new ) { 82 76 genesiswooc_content_product(); 77 } else { 78 genesiswooc_product_archive(); 79 } 83 80 84 else85 genesiswooc_product_archive();86 81 } 87 82 -
genesis-connect-woocommerce/trunk/templates/single-product.php
r1921233 r2123371 1 1 <?php 2 2 /** 3 * This template displays the single Product 3 * This template displays the single Product. 4 4 * 5 * @package genesis_connect_woocommerce5 * @package Genesis_Connect_WooCommerce 6 6 * @version 0.9.8 7 * @since 0.9.0 7 8 * 8 9 * Note for customisers/users: Do not edit this file! … … 13 14 * The version in the child theme's woocommerce folder will override this template, and 14 15 * any future updates to this plugin won't wipe out your customisations. 15 *16 16 */ 17 17 18 /** Remove default Genesis loop */ 18 if ( ! defined( 'ABSPATH' ) ) { 19 exit; 20 } 21 19 22 remove_action( 'genesis_loop', 'genesis_do_loop' ); 20 21 /** Remove WooCommerce breadcrumbs */22 23 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 24 remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 ); 29 25 remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 ); 30 26 31 32 27 add_action( 'genesis_loop', 'gencwooc_single_product_loop' ); 33 28 /** 34 * Displays single product loop 29 * Displays single product loop. 35 30 * 36 * Uses WooCommerce structure and contains all existing WooCommerce hooks 31 * Uses WooCommerce structure and contains all existing WooCommerce hooks. 37 32 * 38 * Code based on WooCommerce 1.5.5 woocommerce_single_product_content() 33 * Code based on WooCommerce 1.5.5 woocommerce_single_product_content(). 34 * 39 35 * @see woocommerce/woocommerce-template.php 40 36 * … … 45 41 do_action( 'woocommerce_before_main_content' ); 46 42 47 // Let developers override the query used, in case they want to use this function for their own loop/wp_query 48 $wc_query = false; 43 $wc_query = apply_filters( 'gencwooc_custom_query', false ); 49 44 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 45 if ( ! $wc_query ) { 55 46 global $wp_query; 56 47 … … 58 49 } 59 50 60 if ( $wc_query->have_posts() ) while ( $wc_query->have_posts() ) : $wc_query->the_post(); ?> 51 if ( $wc_query->have_posts() ) { 52 while ( $wc_query->have_posts() ) { 53 $wc_query->the_post(); 61 54 62 <?php do_action('woocommerce_before_single_product'); ?> 55 do_action( 'woocommerce_before_single_product' ); 56 ?> 63 57 64 <div id="product-<?php the_ID(); ?>" <?php post_class(); ?>> 58 <div id="product-<?php the_ID(); ?>" <?php post_class(); ?>> 59 <?php do_action( 'woocommerce_before_single_product_summary' ); ?> 65 60 66 <?php do_action( 'woocommerce_before_single_product_summary' ); ?> 61 <div class="summary"> 62 <?php do_action( 'woocommerce_single_product_summary' ); ?> 63 </div> 67 64 68 <div class="summary"> 69 70 <?php do_action( 'woocommerce_single_product_summary'); ?> 71 65 <?php do_action( 'woocommerce_after_single_product_summary' ); ?> 72 66 </div> 73 67 74 <?php do_action( 'woocommerce_after_single_product_summary' ); ?> 75 76 </div> 77 78 <?php do_action( 'woocommerce_after_single_product' ); 79 80 endwhile; 68 <?php 69 do_action( 'woocommerce_after_single_product' ); 70 } 71 } 81 72 82 73 do_action( 'woocommerce_after_main_content' ); 74 83 75 } 84 76 -
genesis-connect-woocommerce/trunk/templates/taxonomy.php
r1921233 r2123371 1 1 <?php 2 2 /** 3 * This template displays the Product Category and Tag taxonomy term archives 3 * This template displays the Product Category and Tag taxonomy term archives. 4 4 * 5 * @package genesis_connect_woocommerce5 * @package Genesis_Connect_WooCommerce 6 6 * @version 0.9.8 7 * @since 0.9.0 7 8 * 8 9 * Note for customisers/users: Do not edit this file! … … 13 14 * The version in the child theme's woocommerce folder will override this template, and 14 15 * any future updates to this plugin won't wipe out your customisations. 15 *16 16 */ 17 17 18 if ( ! defined( 'ABSPATH' ) ) { 19 exit; 20 } 18 21 19 /** Remove default Genesis loop */20 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 ); 21 27 22 // Remove the WooCommerce archive title and description.23 28 add_filter( 'woocommerce_show_page_title', '__return_false' ); 24 remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description' );25 29 26 30 add_filter( 'genesis_term_intro_text_output', 'genesiswooc_term_intro_text_output' ); … … 28 32 * Fall back to the archive description if no intro text is set. 29 33 * 34 * @since 1.0.0 35 * 30 36 * @param string $intro_text The default Genesis archive intro text. 37 * 31 38 * @return string Archive intro text, or archive description if no intro text set. 32 *33 * @since 1.034 39 */ 35 40 function genesiswooc_term_intro_text_output( $intro_text ) { 41 36 42 $wp_archive_description = get_the_archive_description(); 37 43 … … 41 47 42 48 return $intro_text; 49 43 50 } 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 51 57 52 add_action( 'genesis_loop', 'genesiswooc_product_taxonomy_loop' ); 58 53 /** 59 * Displays shop items for the queried taxonomy term 54 * Displays shop items for the queried taxonomy term. 60 55 * 61 56 * This function has been refactored in 0.9.4 to provide compatibility with 62 * both WooC 1.6.0 and backwards compatibility with older versions.63 * This is needed thanks to substantial changes to WooC template contents64 * introduced in WooC 1.6.0.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. 65 60 * 66 * @uses genesiswooc_content_product() if WooC is version 1.6.0+ 67 * @uses genesiswooc_product_taxonomy() for earlier WooC versions 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 68 65 * 69 66 * @since 0.9.0 70 * @updated 0.9.471 67 */ 72 68 function genesiswooc_product_taxonomy_loop() { … … 76 72 $new = version_compare( $woocommerce->version, '1.6.0', '>=' ); 77 73 78 if ( $new ) 74 if ( $new ) { 79 75 genesiswooc_content_product(); 80 81 else 76 } else { 82 77 genesiswooc_product_taxonomy(); 78 } 83 79 84 80 }
Note: See TracChangeset
for help on using the changeset viewer.