Plugin Directory

Changeset 2123371


Ignore:
Timestamp:
07/15/2019 05:12:39 PM (7 years ago)
Author:
nathanrice
Message:

Tagging 1.1.0

Location:
genesis-connect-woocommerce
Files:
12 added
2 deleted
27 edited
1 copied

Legend:

Unmodified
Added
Removed
  • genesis-connect-woocommerce/tags/1.1.0

    • Property svn:ignore
      •  

        old new  
         1.editorconfig
        12.git
        23.gitignore
        34.gitattributes
        45.svnignore
         6composer.json
         7composer.lock
        58node_modules
         9phpcs.xml.dist
         10vendor
  • genesis-connect-woocommerce/tags/1.1.0/admin/notices.php

    r1921233 r2123371  
    33 * Callbacks for `admin_notices` action to load HTML notices.
    44 *
    5  * @package genesis_connect_woocommerce
    6  * @version 1.0
     5 * @package Genesis_Connect_WooCommerce
     6 * @since 1.0
    77 */
    8 defined( 'ABSPATH' ) || exit;
    98
     9if ( ! 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 */
    1020function gencwooc_woocommerce_notice() {
    1121    include GCW_ADMIN_DIR . '/views/html-notice-needs-woocommerce.php';
    1222}
    1323
     24/**
     25 * Display notice message if Genesis is not active.
     26 *
     27 * Callback for WordPress 'admin_notices' action.
     28 *
     29 * @since 1.0
     30 */
    1431function gencwooc_genesis_notice() {
    1532    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  
    11<?php
    22/**
    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
    47 */
    58
    6 defined( 'ABSPATH' ) || exit;
     9if ( ! defined( 'ABSPATH' ) ) {
     10    exit;
     11}
    712
    813?>
    914<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>
    1118</div>
  • genesis-connect-woocommerce/tags/1.1.0/admin/views/html-notice-needs-woocommerce.php

    r1921233 r2123371  
    11<?php
    22/**
    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
    47 */
    58
    6 defined( 'ABSPATH' ) || exit;
     9if ( ! defined( 'ABSPATH' ) ) {
     10    exit;
     11}
    712
    813?>
    914<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>
    1118</div>
  • genesis-connect-woocommerce/tags/1.1.0/genesis-connect-woocommerce.php

    r1921233 r2123371  
    11<?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 */
    1120
    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 */
     21define( 'GCW_DIR', dirname( __FILE__ ) );
    1922define( 'GCW_TEMPLATE_DIR', dirname( __FILE__ ) . '/templates' );
    20 define( 'GCW_LIB_DIR', dirname( __FILE__ ) . '/lib');
    21 define( 'GCW_ADMIN_DIR', dirname( __FILE__ ) . '/admin');
     23define( 'GCW_LIB_DIR', dirname( __FILE__ ) . '/lib' );
     24define( 'GCW_ADMIN_DIR', dirname( __FILE__ ) . '/admin' );
    2225define( 'GCW_WIDGETS_DIR', dirname( __FILE__ ) . '/widgets' );
    2326define( 'GCW_SP_DIR', dirname( __FILE__ ) . '/sp-plugins-integration' );
     
    2528add_action( 'after_setup_theme', 'gencwooc_setup' );
    2629/**
    27  * Setup GCW
     30 * Setup Genesis Connect for WooCommerce.
    2831 *
    29  * Checks whether WooCommerce is active, then checks if relevant
    30  * theme support exists. Once past these checks, loads the necessary
    31  * files, actions and filters for the plugin to 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.
    3235 *
    3336 * @since 0.9.0
     
    3639
    3740    require_once GCW_ADMIN_DIR . '/notices.php';
     41
    3842    $ready = true;
    3943
    4044    if ( ! function_exists( 'is_plugin_active' ) ) {
    41         require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
     45        require_once ABSPATH . '/wp-admin/includes/plugin.php';
    4246    }
    4347
    4448    if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
    4549        add_action( 'admin_notices', 'gencwooc_woocommerce_notice' );
     50
    4651        $ready = false;
    4752    }
     
    6166    global $woocommerce;
    6267
    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';
    6571
    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    }
    6875
    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 */
    7476    add_theme_support( 'woocommerce' );
    7577
    76     /** Add Genesis Layout, Genesis Scripts and SEO options to Product edit screen */
    7778    add_post_type_support( 'product', array( 'genesis-layouts', 'genesis-scripts', 'genesis-seo' ) );
    78 
    79     /** Add Studiopress plugins support */
    8079    add_post_type_support( 'product', array( 'genesis-simple-sidebars', 'genesis-simple-menus' ) );
    8180
    82     /** Add Widgets */
    8381    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';
    8583    }
    8684
    87     /** Take control of shop template loading */
    8885    remove_filter( 'template_include', array( &$woocommerce, 'template_loader' ) );
    8986    add_filter( 'template_include', 'gencwooc_template_loader', 20 );
    9087
    91     /** Integration - Genesis Simple Sidebars */
    9288    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';
    9490    }
    9591
    96     /** Integration - Genesis Simple Menus */
    9792    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';
    9994    }
    10095
    10196}
     97
     98add_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 */
     109function 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  
    11<?php
    22/**
    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:
    1512 * - Shop page (archive page)
    1613 * - Single product
    1714 * - Taxonomy archive
    1815 *
    19  * Users who prefer to use WooC's breadcrumbs can do so by adding this to their child
     16 * Users who prefer to use WooCommerce breadcrumbs can do so by adding this to their child
    2017 * theme's functions.php:
    2118 * - add_theme_support( 'gencwooc-woo-breadcrumbs' );
     
    2320 * - remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' );
    2421 *
    25  * @see readme.txt for more details
     22 * @see readme.txt For more details.
    2623 *
    2724 * As this modification code uses existing Genesis Breadcrumb filters there is a risk that
     
    3229 * @see genesis/lib/classes/breadcrumb.php v1.8
    3330 * @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
     33if ( ! defined( 'ABSPATH' ) ) {
     34    exit;
     35}
    4636
    4737add_filter( 'genesis_archive_crumb', 'gencwooc_get_archive_crumb_filter', 10, 2 );
    4838/**
    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.
    5242 *
    5343 * Note: relevant WooCommerce settings (WooCommerce > Settings > Pages tab):
     
    5747 *
    5848 * @since 0.9.0
    59  * @updated 0.9.7
    60  *
    61  * @param str $crumb Breadcrumb 'crumb' for archives
    62  * @param array $args Genesis Breadcrumb args
    63  * @return str $crumb, either modified $crumb, or original $crumb
     49 *
     50 * @param string $crumb Breadcrumb 'crumb' for archives.
     51 * @param array  $args Genesis Breadcrumb args.
     52 *
     53 * @return string $crumb Breadcrumb 'crumb' for archives.
    6454 */
    6555function gencwooc_get_archive_crumb_filter( $crumb, $args ) {
    6656
    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 &ldquo;', 'woocommerce' ) . get_search_query() . '&rdquo;' );
    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 &ldquo;', 'gencwooc' ) . get_search_query() . '&rdquo;'
     68            );
     69        }
    8370
    8471        return apply_filters( 'gencwooc_product_archive_crumb', $crumb, $args );
    8572    }
    8673
    87 
    88     /** Are we on a shop taxonomy archive page? */
    8974    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' );
    9979        $shop_title = get_the_title( $shop_id );
    10080
    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 ) {
    10282            $prepend = gencwooc_get_crumb_link( get_permalink( $shop_id ), $shop_title, $shop_title, $args['sep'] );
    103 
     83        }
    10484    }
    10585
    10686    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' ) );
    11088        $parents = array();
    111         $parent = $term->parent;
    112         while ( $parent ):
    113             $parents[] = $parent;
     89        $parent  = $term->parent;
     90
     91        while ( $parent ) {
     92            $parents[]  = $parent;
    11493            $new_parent = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ) );
    115             $parent = $new_parent->parent;
    116         endwhile;
     94            $parent     = $new_parent->parent;
     95        }
    11796
    11897        $crumb .= $prepend;
    11998
    120         if ( ! empty( $parents ) ) :
     99        if ( ! empty( $parents ) ) {
    121100            $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' ) );
    124104                $crumb .= gencwooc_get_crumb_link( get_term_link( $item->slug, 'product_cat' ), $item->name, $item->name, $args['sep'] );
    125             endforeach;
    126         endif;
     105            }
     106        }
    127107
    128108        $crumb .= single_term_title( '', false );
     
    132112
    133113    if ( is_tax( 'product_tag' ) ) {
    134 
    135114        $crumb .= $prepend . __( 'Products tagged &ldquo;', 'gencwooc' ) . single_term_title( '', false ) . _x( '&rdquo;', 'endquote', 'gencwooc' );
    136115
     
    138117    }
    139118
    140     /** Original unmodified */
    141119    return $crumb;
    142 }
    143 
     120
     121}
    144122
    145123add_filter( 'genesis_single_crumb', 'gencwooc_get_single_crumb', 10, 2 );
    146124/**
    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.
    156137 */
    157138function gencwooc_get_single_crumb( $crumb, $args ) {
    158139
    159     /** Are we on a single product page? */
    160140    if ( is_singular( 'product' ) ) {
    161 
    162141        global $post;
    163142
    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' );
    171147        $shop_title = get_the_title( $shop_id );
    172148
    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 ) {
    174150            $prepend = gencwooc_get_crumb_link( get_permalink( $shop_id ), $shop_title, $shop_title, $args['sep'] );
     151        }
    175152
    176153        $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 );
    180158            $parents = array();
    181             $parent = $term->parent;
    182             while ( $parent ):
    183                 $parents[] = $parent;
     159            $parent  = $term->parent;
     160
     161            while ( $parent ) {
     162                $parents[]  = $parent;
    184163                $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 ) ) {
    189168                $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' );
    192172                    $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
    195176            $crumb .= gencwooc_get_crumb_link( get_term_link( $term->slug, 'product_cat' ), $term->name, $term->name, $args['sep'] );
    196         endif;
     177        }
    197178
    198179        $crumb .= get_the_title();
     
    201182    }
    202183
    203     /** Fallback - original unmodified */
    204184    return $crumb;
    205 }
    206 
     185
     186}
    207187
    208188/**
    209189 * Helper function to create anchor link for a single crumb.
    210190 *
    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 *
    219200 * @return string HTML markup for anchor link and optional separator.
    220201 */
    221202function gencwooc_get_crumb_link( $url, $title, $content, $sep = false ) {
    222203
    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 ) {
    226212        $link .= $sep;
     213    }
    227214
    228215    return $link;
  • genesis-connect-woocommerce/tags/1.1.0/lib/posts-per-page.php

    r1575771 r2123371  
    11<?php
    22/**
    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.
    54 *
    6  * @package genesis_connect_woocommerce
    7  * @version 0.9.8
    8  *
     5 * @package Genesis_Connect_WooCommerce
    96 * @since 0.9.0
    107 */
    118
    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.' ) );
     9if ( ! defined( 'ABSPATH' ) ) {
     10    exit;
     11}
    1712
    1813add_filter( 'woocommerce_settings_tabs_array', 'genesis_connect_addon_tab', 50 );
    19 /*
     14/**
    2015 * Add a custom tab in the WooCommerce settings for Genesis Connect.
    2116 *
    2217 * @since 1.0.0
     18 *
     19 * @param array $tabs Used to add a tab to the WooCommerce settings page.
     20 *
    2321 * @return array $tabs Used to add a tab to the WooCommerce settings page.
    2422 */
    2523function genesis_connect_addon_tab( $tabs ) {
    2624
    27     // Add our own section.
    2825    $tabs['gencwooc'] = __( 'Genesis Connect Addons', 'gencwooc' );
     26
    2927    return $tabs;
    3028
     
    3634 *
    3735 * @since 1.0.0
    38  * @return array Multiple arrays holding our section information
    3936 */
    40 
    4137function genesis_connect_settings_tab() {
    42     woocommerce_admin_fields( genesis_connect_get_settings() );
     38    woocommerce_admin_fields( genesis_connect_get_settings() );
    4339}
    4440
     
    4844 *
    4945 * @since 1.0.0
    50  * @return array Settings to update.
    5146 */
    5247function genesis_connect_update_settings() {
    53     woocommerce_update_options( genesis_connect_get_settings() );
     48    woocommerce_update_options( genesis_connect_get_settings() );
    5449}
    5550
     
    5853 *
    5954 * @since 1.0.0
     55 *
    6056 * @return array $settings Array of our settings.
    6157 */
    6258function genesis_connect_get_settings() {
    63     $settings = array(
     59
     60    $settings = array(
    6461        'gencwooc_section_title' => array(
    6562            'name' => __( 'Genesis Connect Addons', 'gencwooc' ),
    6663            'type' => 'title',
    6764            'desc' => 'Set and save additional WooCommerce settings here.',
    68             'id'   => 'gencwooc_section_title'
     65            'id'   => 'gencwooc_section_title',
    6966        ),
    70         'products_per_page' => array(
     67        'products_per_page'      => array(
    7168            'name'    => __( 'Products Per Page', 'gencwooc' ),
    7269            'type'    => 'number',
     
    7471            'id'      => 'gencwooc_products_per_page',
    7572            '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
    8382}
    8483
     84add_filter( 'loop_shop_per_page', 'genesiswooc_products_per_page' );
    8585/**
    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).
    8887 *
    8988 * @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.
    9193 */
    92 add_filter( 'loop_shop_per_page', 'genesiswooc_products_per_page' );
    9394function genesiswooc_products_per_page( $count ) {
    9495
    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    }
    96101
    97102    return $count;
  • genesis-connect-woocommerce/tags/1.1.0/lib/template-loader.php

    r1921233 r2123371  
    11<?php
    22/**
    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
    86 * @since 0.9.0
    97 */
    108
    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 
     9if ( ! defined( 'ABSPATH' ) ) {
     10    exit;
     11}
    1812
    1913/**
    2014 * Load the Genesis-fied templates, instead of the WooCommerce defaults.
    2115 *
    22  * Hooked to 'template_include' filter
    23  *
    24  * This template loader determines which template file will be used for the requested page, and uses the
    25  * 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:
    2620 * 1. First looks in the child theme's 'woocommerce' folder.
    2721 * 2. If no template found, falls back to GCW's templates.
    2822 *
    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.
    3126 *
    3227 * GCW provides three templates in the plugin's 'templates' directory:
     
    3530 * - taxonomy.php
    3631 *
    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 *
    3936 * Permitted user templates (as per WP Template Hierarchy) are:
    4037 * - single-product.php
     
    4441 * - taxonomy.php
    4542 *
    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.
    4846 *
    4947 * @since 0.9.0
    5048 *
    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 template
     49 * @param string $template Template file as per template hierarchy.
     50 *
     51 * @return string $template Template file as per template hierarchy.
    5452 */
    5553function gencwooc_template_loader( $template ) {
     
    5957    }
    6058
    61     if ( is_single() && 'product' == get_post_type() ) {
    62 
     59    if ( is_single() && 'product' === get_post_type() ) {
    6360        $template = locate_template( array( 'woocommerce/single-product.php' ) );
    6461
    65         if ( ! $template )
     62        if ( ! $template ) {
    6663            $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' ) ) ) {
    7166        $template = locate_template( array( 'woocommerce/archive-product.php' ) );
    7267
    73         if ( ! $template )
     68        if ( ! $template ) {
    7469            $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' );
    8474        $taxonomies = get_object_taxonomies( 'product', 'names' );
    8575
    86         if ( in_array( $tax, $taxonomies ) ) {
    87 
    88             $tax = sanitize_title( $tax );
     76        if ( in_array( $tax, $taxonomies, true ) ) {
     77            $tax  = sanitize_title( $tax );
    8978            $term = sanitize_title( $term );
    9079
    9180            $templates = array(
    92                 'woocommerce/taxonomy-'.$tax.'-'.$term.'.php',
    93                 'woocommerce/taxonomy-'.$tax.'.php',
     81                "woocommerce/taxonomy-{$tax}-{$term}.php",
     82                "woocommerce/taxonomy-{$tax}.php",
    9483                'woocommerce/taxonomy.php',
    9584            );
     
    9786            $template = locate_template( $templates );
    9887
    99             /** Fallback to GCW template */
    100             if ( ! $template )
     88            if ( ! $template ) {
    10189                $template = GCW_TEMPLATE_DIR . '/taxonomy.php';
     90            }
    10291        }
    10392    }
     
    10796}
    10897
    109 
    110 
    111 /**
    112  * Shop Loop 'template part' loader
     98/**
     99 * Shop Loop 'template part' loader.
    113100 *
    114101 * ONLY RETAINED FOR BACKWARDS COMPATIBILITY for GCW pre-0.9.2 custom templates which
     
    118105 * loads the default WooCommerce loop-shop.php file.
    119106 *
    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 *
    125113 * It is recommended to use woocommerce/templates/loop-shop.php as the starting point of
    126114 * any custom loop template.
     
    129117 *
    130118 * 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
    132122 *
    133123 * @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 */
     128function gencwooc_get_template_part( $slug, $name = '' ) {
    138129
    139130    global $woocommerce;
     131
    140132    $template = '';
    141133
    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" ) ) {
    148139        $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 ) {
    155147        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 *
    168163 * @see woocommerce/woocommerce-template.php
    169164 *
    170  *
    171165 * @since 0.9.4
    172  * @updated 0.9.6
    173  * @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.
    174168 */
    175169function genesiswooc_product_archive() {
     
    177171    global $shop_page_id;
    178172
    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' ) . ' &ldquo;' . get_search_query() . '&rdquo;';
    185             if ( get_query_var( 'paged' ) ) $shop_page_title .= ' &mdash; ' . __( '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' ) . ' &ldquo;' . get_search_query() . '&rdquo;';
     179
     180        if ( get_query_var( 'paged' ) ) {
     181            $shop_page_title .= ' &mdash; ' . __( 'Page', 'gencwooc' ) . ' ' . get_query_var( 'paged' );
     182        }
     183
     184        $shop_page_content = '';
     185    }
    188186
    189187    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
    195195
    196196    woocommerce_get_template_part( 'loop', 'shop' );
     
    199199
    200200    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 *
    212213 * @see woocommerce/woocommerce-template.php
    213214 *
    214  *
    215215 * @since 0.9.4
    216216 */
     
    227227}
    228228
    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.
    239237 *
    240238 * @since 0.9.4
    241  * @updated 0.9.8
    242239 */
    243240function genesiswooc_content_product() {
    244241
    245242    /**
    246      * woocommerce_before_main_content hook
     243     * For woocommerce_before_main_content hook.
    247244     *
    248245     * @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
     
    253250    if ( apply_filters( 'woocommerce_show_page_title', true ) ) {
    254251        echo '<h1 class="woocommerce-products-header__title page-title">';
     252
    255253        woocommerce_page_title();
     254
    256255        echo '</h1>';
    257256    }
     
    268267         */
    269268        do_action( 'woocommerce_before_shop_loop' );
     269
    270270        woocommerce_product_loop_start();
     271
    271272        if ( wc_get_loop_prop( 'total' ) ) {
    272273            while ( have_posts() ) {
    273274                the_post();
     275
    274276                /**
    275277                 * Hook: woocommerce_shop_loop.
     
    278280                 */
    279281                do_action( 'woocommerce_shop_loop' );
     282
    280283                wc_get_template_part( 'content', 'product' );
    281284            }
    282285        }
     286
    283287        woocommerce_product_loop_end();
     288
    284289        /**
    285290         * Hook: woocommerce_after_shop_loop.
     
    296301        do_action( 'woocommerce_no_products_found' );
    297302    }
     303
    298304    /**
    299305     * Hook: woocommerce_after_main_content.
  • genesis-connect-woocommerce/tags/1.1.0/readme.txt

    r1921233 r2123371  
    33Tags: genesis, genesiswp, studiopress, woocommerce
    44Requires at least: 3.3
    5 Tested up to: 4.9
    6 Stable tag: 1.0
     5Tested up to: 5.2.2
     6Stable tag: 1.1.0
    77
    88This plugin allows you to seamlessly integrate WooCommerce with the Genesis Framework and Genesis child themes.
     
    131131
    132132== 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.
    133138
    134139= 1.0 =
     
    163168= 0.9.8 =
    164169* Released 9 July 2014
    165 * Updates genesiswooc_content_product() to reflect WooC 2.1+ templates and correct handling of WooC's page title filter function
     170* Updates genesiswooc_content_product() to reflect WooCommerce 2.1+ templates and correct handling of WooCommerce page title filter function
    166171
    167172= 0.9.7 =
     
    188193= 0.9.2 =
    189194* Released 15 March 2012
    190 * single-product.php - Single product title template file now hooked in as per WooC 1.5.2
     195* single-product.php - Single product title template file now hooked in as per WooCommerce 1.5.2
    191196
    192197= 0.9.1 =
  • genesis-connect-woocommerce/tags/1.1.0/sp-plugins-integration/genesis-simple-menus.php

    r1812865 r2123371  
    11<?php
    22/**
    3  * Integration - Genesis Simple Menus
     3 * Genesis Simple Menus integration.
    44 *
    5  * @package genesis_connect_woocommerce
    6  * @version 0.9.8
    7 
    8  *
     5 * @package Genesis_Connect_WooCommerce
    96 * @since 0.9.0
    107 *
     
    129 *
    1310 * 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)
    1613 *
    1714 * 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 Page
     15 *  1. GCW adds post_type_support for GSM - see gencwooc_setup()
     16 *  2. uses Genesis filters to intercept request and serve correct GSM menu on Shop Page
    2017 *
    2118 * Note: this file is loaded on the 'after_theme_setup' hook only if GSM
    2219 * is activated.
    2320 * @see gencwooc_setup() in genesis-connect-woocommerce.php
    24  *
    2521 */
    2622
    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 
     23if ( ! defined( 'ABSPATH' ) ) {
     24    exit;
     25}
    3326
    3427add_filter( 'genesis_pre_get_option_subnav_type', 'gencwooc_gsm_subnav_type', 9 );
    3528/**
    36  * Tells Genesis to load a custom menu
     29 * Tells Genesis to load a custom menu.
    3730 *
    3831 * @since 0.9.0
    3932 *
    4033 * @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.
    4338 */
    4439function gencwooc_gsm_subnav_type( $nav ) {
     
    4944add_filter( 'theme_mod_nav_menu_locations', 'gencwooc_gsm_theme_mod' );
    5045/**
    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.
    5247 *
    5348 * @since 0.9.0
    5449 *
    5550 * @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.
    5855 */
    5956function gencwooc_gsm_theme_mod( $mods ) {
    6057
    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 );
    6360
    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 ) {
    6762        $mods['secondary'] = (int) $_menu;
     63    }
    6864
    6965    return $mods;
  • genesis-connect-woocommerce/tags/1.1.0/sp-plugins-integration/genesis-simple-sidebars.php

    r1921233 r2123371  
    11<?php
    22/**
    3  * Integration - Genesis Simple Sidebars
     3 * Genesis Simple Sidebars integration.
    44 *
    5  * @package genesis_connect_woocommerce
    6  * @version 0.9.8
    7  *
     5 * @package Genesis_Connect_WooCommerce
    86 * @since 0.9.0
    97 *
    10  * Based on Genesis Simple Sidebars (GSS) version 0.9.2
     8 * Based on Genesis Simple Sidebars (GSS) version 0.9.2.
    119 *
    1210 * 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).
    1513 *
    1614 * 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.
    2018 *
    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.
    2320 * @see gencwooc_setup() in genesis-connect-woocommerce.php
    24  *
    25  * @TODO simply these functions
    2621 */
    2722
    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' ) );
     23if ( ! defined( 'ABSPATH' ) ) {
     24    exit;
     25}
    3326
    3427
    3528add_action( 'get_header', 'gencwooc_ss_handler', 11 );
    3629/**
    37  * Take control of GSS sidebar loading
     30 * Take control of GSS sidebar loading.
    3831 *
    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.
    4234 *
    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 *
    4538 * @see GSS ss_sidebars_init() in genesis-simple-sidebars/plugin.php
    4639 *
    4740 * Note for developers:
    4841 * ====================
    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 this
    51  * function and replace it with your 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.
    5245 *
    5346 * @since 0.9.0
    54  *
    5547 */
    5648function gencwooc_ss_handler() {
    5749
    58     /** Unhook GSS functions */
    5950    remove_action( 'genesis_sidebar', 'ss_do_sidebar' );
    6051    remove_action( 'genesis_sidebar_alt', 'ss_do_sidebar_alt' );
    6152
    62     /** Hook replacement functions */
    6353    add_action( 'genesis_sidebar', 'gencwooc_ss_do_sidebar' );
    6454    add_action( 'genesis_sidebar_alt', 'gencwooc_ss_do_sidebar_alt' );
     
    6858
    6959/**
    70  * Callback for dealing with Primary Sidebar loading
     60 * Callback for dealing with Primary Sidebar loading.
    7161 *
    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().
    7565 *
    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.
    7968 *
    8069 * If either of the above conditions return false, we load the regular sidebar.
     
    8372 *
    8473 * @uses woocommerce_get_page_id()
    85  *
    8674 */
    8775function gencwooc_ss_do_sidebar() {
    8876
    89     $bar = '_ss_sidebar';
    9077    $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 );
    9179
    92     if ( is_post_type_archive( 'product' ) && $_bar = get_post_meta( $shop_id, $bar, true ) ) {
    93 
     80    if ( is_post_type_archive( 'product' ) && $_bar ) {
    9481        dynamic_sidebar( $_bar );
    95 
    9682    } else {
    97 
    9883        genesis_do_sidebar();
    99 
    10084    }
    10185
     
    10488
    10589/**
    106  * Callback for dealing with Sidebar Alt loading
     90 * Callback for dealing with Sidebar Alt loading.
    10791 *
    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().
    11195 *
    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.
    11598 *
    11699 * If either of the above conditions return false, we load the regular alt sidebar.
     
    119102 *
    120103 * @uses woocommerce_get_page_id()
    121  *
    122104 */
    123105function gencwooc_ss_do_sidebar_alt() {
    124106
    125     $bar = '_ss_sidebar_alt';
    126107    $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 );
    127109
    128     if ( is_post_type_archive( 'product' ) && $_bar = get_post_meta( $shop_id, $bar, true ) ) {
    129 
     110    if ( is_post_type_archive( 'product' ) && $_bar ) {
    130111        dynamic_sidebar( $_bar );
    131 
    132112    } else {
    133 
    134113        genesis_do_sidebar_alt();
    135 
    136114    }
    137115
  • genesis-connect-woocommerce/tags/1.1.0/templates/archive-product.php

    r1921233 r2123371  
    11<?php
    22/**
    3  * This template displays the archive for Products
     3 * This template displays the archive for Products.
    44 *
    5  * @package genesis_connect_woocommerce
     5 * @package Genesis_Connect_WooCommerce
    66 * @version 0.9.8
     7 * @since 0.9.0
    78 *
    89 * Note for customisers/users: Do not edit this file!
     
    1314 * The version in the child theme's woocommerce folder will override this template, and
    1415 * any future updates to this plugin won't wipe out your customisations.
    15  *
    16  * @since 0.9.0
    17  *
    1816 */
    1917
    20 /** Remove default Genesis loop */
     18if ( ! defined( 'ABSPATH' ) ) {
     19    exit;
     20}
     21
    2122remove_action( 'genesis_loop', 'genesis_do_loop' );
    22 
    23 /** Remove Genesis archive title/description */
    2423remove_action( 'genesis_before_loop', 'genesis_do_taxonomy_title_description', 15 );
    25 
    26 /** Remove WooCommerce breadcrumbs */
    2724remove_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 */
    3325remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
    3426remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
     
    4234 * @since 0.9.0
    4335 *
    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.
    4639 */
    4740function genesiswooc_archive_layout( $layout ) {
     
    6154 * Display shop items (product custom post archive)
    6255 *
    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.
    6758 *
    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
    7064 *
    7165 * @since 0.9.0
    72  * @updated 0.9.4
    73  * @global object $woocommerce
     66 *
     67 * @global WooCommerce $woocommerce Current WooCommerce instance.
    7468 */
    7569function genesiswooc_archive_product_loop() {
     
    7973    $new = version_compare( $woocommerce->version, '1.6.0', '>=' );
    8074
    81     if ( $new )
     75    if ( $new ) {
    8276        genesiswooc_content_product();
     77    } else {
     78        genesiswooc_product_archive();
     79    }
    8380
    84     else
    85         genesiswooc_product_archive();
    8681}
    8782
  • genesis-connect-woocommerce/tags/1.1.0/templates/single-product.php

    r1921233 r2123371  
    11<?php
    22/**
    3  * This template displays the single Product
     3 * This template displays the single Product.
    44 *
    5  * @package genesis_connect_woocommerce
     5 * @package Genesis_Connect_WooCommerce
    66 * @version 0.9.8
     7 * @since 0.9.0
    78 *
    89 * Note for customisers/users: Do not edit this file!
     
    1314 * The version in the child theme's woocommerce folder will override this template, and
    1415 * any future updates to this plugin won't wipe out your customisations.
    15  *
    1616 */
    1717
    18 /** Remove default Genesis loop */
     18if ( ! defined( 'ABSPATH' ) ) {
     19    exit;
     20}
     21
    1922remove_action( 'genesis_loop', 'genesis_do_loop' );
    20 
    21 /** Remove WooCommerce breadcrumbs */
    2223remove_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 */
    2824remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
    2925remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
    3026
    31 
    3227add_action( 'genesis_loop', 'gencwooc_single_product_loop' );
    3328/**
    34  * Displays single product loop
     29 * Displays single product loop.
    3530 *
    36  * Uses WooCommerce structure and contains all existing WooCommerce hooks
     31 * Uses WooCommerce structure and contains all existing WooCommerce hooks.
    3732 *
    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 *
    3935 * @see woocommerce/woocommerce-template.php
    4036 *
     
    4541    do_action( 'woocommerce_before_main_content' );
    4642
    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 );
    4944
    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 ) {
    5546        global $wp_query;
    5647
     
    5849    }
    5950
    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();
    6154
    62         <?php do_action('woocommerce_before_single_product'); ?>
     55            do_action( 'woocommerce_before_single_product' );
     56            ?>
    6357
    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' ); ?>
    6560
    66             <?php do_action( 'woocommerce_before_single_product_summary' ); ?>
     61                <div class="summary">
     62                    <?php do_action( 'woocommerce_single_product_summary' ); ?>
     63                </div>
    6764
    68             <div class="summary">
    69 
    70                 <?php do_action( 'woocommerce_single_product_summary'); ?>
    71 
     65                <?php do_action( 'woocommerce_after_single_product_summary' ); ?>
    7266            </div>
    7367
    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    }
    8172
    8273    do_action( 'woocommerce_after_main_content' );
     74
    8375}
    8476
  • genesis-connect-woocommerce/tags/1.1.0/templates/taxonomy.php

    r1921233 r2123371  
    11<?php
    22/**
    3  * This template displays the Product Category and Tag taxonomy term archives
     3 * This template displays the Product Category and Tag taxonomy term archives.
    44 *
    5  * @package genesis_connect_woocommerce
     5 * @package Genesis_Connect_WooCommerce
    66 * @version 0.9.8
     7 * @since 0.9.0
    78 *
    89 * Note for customisers/users: Do not edit this file!
     
    1314 * The version in the child theme's woocommerce folder will override this template, and
    1415 * any future updates to this plugin won't wipe out your customisations.
    15  *
    1616 */
    1717
     18if ( ! defined( 'ABSPATH' ) ) {
     19    exit;
     20}
    1821
    19 /** Remove default Genesis loop */
    2022remove_action( 'genesis_loop', 'genesis_do_loop' );
     23remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description' );
     24remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
     25remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
     26remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
    2127
    22 // Remove the WooCommerce archive title and description.
    2328add_filter( 'woocommerce_show_page_title', '__return_false' );
    24 remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description' );
    2529
    2630add_filter( 'genesis_term_intro_text_output', 'genesiswooc_term_intro_text_output' );
     
    2832 * Fall back to the archive description if no intro text is set.
    2933 *
     34 * @since 1.0.0
     35 *
    3036 * @param string $intro_text The default Genesis archive intro text.
     37 *
    3138 * @return string Archive intro text, or archive description if no intro text set.
    32  *
    33  * @since 1.0
    3439 */
    3540function genesiswooc_term_intro_text_output( $intro_text ) {
     41
    3642    $wp_archive_description = get_the_archive_description();
    3743
     
    4147
    4248    return $intro_text;
     49
    4350}
    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 
    5651
    5752add_action( 'genesis_loop', 'genesiswooc_product_taxonomy_loop' );
    5853/**
    59  * Displays shop items for the queried taxonomy term
     54 * Displays shop items for the queried taxonomy term.
    6055 *
    6156 * 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 contents
    64  * 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.
    6560 *
    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
    6865 *
    6966 * @since 0.9.0
    70  * @updated 0.9.4
    7167 */
    7268function genesiswooc_product_taxonomy_loop() {
     
    7672    $new = version_compare( $woocommerce->version, '1.6.0', '>=' );
    7773
    78     if ( $new )
     74    if ( $new ) {
    7975        genesiswooc_content_product();
    80 
    81     else
     76    } else {
    8277        genesiswooc_product_taxonomy();
     78    }
    8379
    8480}
  • genesis-connect-woocommerce/trunk

    • Property svn:ignore
      •  

        old new  
         1.editorconfig
        12.git
        23.gitignore
        34.gitattributes
        45.svnignore
         6composer.json
         7composer.lock
        58node_modules
         9phpcs.xml.dist
         10vendor
  • genesis-connect-woocommerce/trunk/admin/notices.php

    r1921233 r2123371  
    33 * Callbacks for `admin_notices` action to load HTML notices.
    44 *
    5  * @package genesis_connect_woocommerce
    6  * @version 1.0
     5 * @package Genesis_Connect_WooCommerce
     6 * @since 1.0
    77 */
    8 defined( 'ABSPATH' ) || exit;
    98
     9if ( ! 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 */
    1020function gencwooc_woocommerce_notice() {
    1121    include GCW_ADMIN_DIR . '/views/html-notice-needs-woocommerce.php';
    1222}
    1323
     24/**
     25 * Display notice message if Genesis is not active.
     26 *
     27 * Callback for WordPress 'admin_notices' action.
     28 *
     29 * @since 1.0
     30 */
    1431function gencwooc_genesis_notice() {
    1532    include GCW_ADMIN_DIR . '/views/html-notice-needs-genesis.php';
  • genesis-connect-woocommerce/trunk/admin/views/html-notice-needs-genesis.php

    r1921233 r2123371  
    11<?php
    22/**
    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
    47 */
    58
    6 defined( 'ABSPATH' ) || exit;
     9if ( ! defined( 'ABSPATH' ) ) {
     10    exit;
     11}
    712
    813?>
    914<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>
    1118</div>
  • genesis-connect-woocommerce/trunk/admin/views/html-notice-needs-woocommerce.php

    r1921233 r2123371  
    11<?php
    22/**
    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
    47 */
    58
    6 defined( 'ABSPATH' ) || exit;
     9if ( ! defined( 'ABSPATH' ) ) {
     10    exit;
     11}
    712
    813?>
    914<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>
    1118</div>
  • genesis-connect-woocommerce/trunk/genesis-connect-woocommerce.php

    r1921233 r2123371  
    11<?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 */
    1120
    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 */
     21define( 'GCW_DIR', dirname( __FILE__ ) );
    1922define( 'GCW_TEMPLATE_DIR', dirname( __FILE__ ) . '/templates' );
    20 define( 'GCW_LIB_DIR', dirname( __FILE__ ) . '/lib');
    21 define( 'GCW_ADMIN_DIR', dirname( __FILE__ ) . '/admin');
     23define( 'GCW_LIB_DIR', dirname( __FILE__ ) . '/lib' );
     24define( 'GCW_ADMIN_DIR', dirname( __FILE__ ) . '/admin' );
    2225define( 'GCW_WIDGETS_DIR', dirname( __FILE__ ) . '/widgets' );
    2326define( 'GCW_SP_DIR', dirname( __FILE__ ) . '/sp-plugins-integration' );
     
    2528add_action( 'after_setup_theme', 'gencwooc_setup' );
    2629/**
    27  * Setup GCW
     30 * Setup Genesis Connect for WooCommerce.
    2831 *
    29  * Checks whether WooCommerce is active, then checks if relevant
    30  * theme support exists. Once past these checks, loads the necessary
    31  * files, actions and filters for the plugin to 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.
    3235 *
    3336 * @since 0.9.0
     
    3639
    3740    require_once GCW_ADMIN_DIR . '/notices.php';
     41
    3842    $ready = true;
    3943
    4044    if ( ! function_exists( 'is_plugin_active' ) ) {
    41         require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
     45        require_once ABSPATH . '/wp-admin/includes/plugin.php';
    4246    }
    4347
    4448    if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
    4549        add_action( 'admin_notices', 'gencwooc_woocommerce_notice' );
     50
    4651        $ready = false;
    4752    }
     
    6166    global $woocommerce;
    6267
    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';
    6571
    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    }
    6875
    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 */
    7476    add_theme_support( 'woocommerce' );
    7577
    76     /** Add Genesis Layout, Genesis Scripts and SEO options to Product edit screen */
    7778    add_post_type_support( 'product', array( 'genesis-layouts', 'genesis-scripts', 'genesis-seo' ) );
    78 
    79     /** Add Studiopress plugins support */
    8079    add_post_type_support( 'product', array( 'genesis-simple-sidebars', 'genesis-simple-menus' ) );
    8180
    82     /** Add Widgets */
    8381    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';
    8583    }
    8684
    87     /** Take control of shop template loading */
    8885    remove_filter( 'template_include', array( &$woocommerce, 'template_loader' ) );
    8986    add_filter( 'template_include', 'gencwooc_template_loader', 20 );
    9087
    91     /** Integration - Genesis Simple Sidebars */
    9288    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';
    9490    }
    9591
    96     /** Integration - Genesis Simple Menus */
    9792    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';
    9994    }
    10095
    10196}
     97
     98add_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 */
     109function gencwooc_load_plugin_textdomain() {
     110    load_plugin_textdomain( 'gencwooc', false, GCW_DIR . '/languages' );
     111}
  • genesis-connect-woocommerce/trunk/lib/breadcrumb.php

    r1812865 r2123371  
    11<?php
    22/**
    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:
    1512 * - Shop page (archive page)
    1613 * - Single product
    1714 * - Taxonomy archive
    1815 *
    19  * Users who prefer to use WooC's breadcrumbs can do so by adding this to their child
     16 * Users who prefer to use WooCommerce breadcrumbs can do so by adding this to their child
    2017 * theme's functions.php:
    2118 * - add_theme_support( 'gencwooc-woo-breadcrumbs' );
     
    2320 * - remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' );
    2421 *
    25  * @see readme.txt for more details
     22 * @see readme.txt For more details.
    2623 *
    2724 * As this modification code uses existing Genesis Breadcrumb filters there is a risk that
     
    3229 * @see genesis/lib/classes/breadcrumb.php v1.8
    3330 * @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
     33if ( ! defined( 'ABSPATH' ) ) {
     34    exit;
     35}
    4636
    4737add_filter( 'genesis_archive_crumb', 'gencwooc_get_archive_crumb_filter', 10, 2 );
    4838/**
    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.
    5242 *
    5343 * Note: relevant WooCommerce settings (WooCommerce > Settings > Pages tab):
     
    5747 *
    5848 * @since 0.9.0
    59  * @updated 0.9.7
    60  *
    61  * @param str $crumb Breadcrumb 'crumb' for archives
    62  * @param array $args Genesis Breadcrumb args
    63  * @return str $crumb, either modified $crumb, or original $crumb
     49 *
     50 * @param string $crumb Breadcrumb 'crumb' for archives.
     51 * @param array  $args Genesis Breadcrumb args.
     52 *
     53 * @return string $crumb Breadcrumb 'crumb' for archives.
    6454 */
    6555function gencwooc_get_archive_crumb_filter( $crumb, $args ) {
    6656
    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 &ldquo;', 'woocommerce' ) . get_search_query() . '&rdquo;' );
    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 &ldquo;', 'gencwooc' ) . get_search_query() . '&rdquo;'
     68            );
     69        }
    8370
    8471        return apply_filters( 'gencwooc_product_archive_crumb', $crumb, $args );
    8572    }
    8673
    87 
    88     /** Are we on a shop taxonomy archive page? */
    8974    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' );
    9979        $shop_title = get_the_title( $shop_id );
    10080
    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 ) {
    10282            $prepend = gencwooc_get_crumb_link( get_permalink( $shop_id ), $shop_title, $shop_title, $args['sep'] );
    103 
     83        }
    10484    }
    10585
    10686    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' ) );
    11088        $parents = array();
    111         $parent = $term->parent;
    112         while ( $parent ):
    113             $parents[] = $parent;
     89        $parent  = $term->parent;
     90
     91        while ( $parent ) {
     92            $parents[]  = $parent;
    11493            $new_parent = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ) );
    115             $parent = $new_parent->parent;
    116         endwhile;
     94            $parent     = $new_parent->parent;
     95        }
    11796
    11897        $crumb .= $prepend;
    11998
    120         if ( ! empty( $parents ) ) :
     99        if ( ! empty( $parents ) ) {
    121100            $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' ) );
    124104                $crumb .= gencwooc_get_crumb_link( get_term_link( $item->slug, 'product_cat' ), $item->name, $item->name, $args['sep'] );
    125             endforeach;
    126         endif;
     105            }
     106        }
    127107
    128108        $crumb .= single_term_title( '', false );
     
    132112
    133113    if ( is_tax( 'product_tag' ) ) {
    134 
    135114        $crumb .= $prepend . __( 'Products tagged &ldquo;', 'gencwooc' ) . single_term_title( '', false ) . _x( '&rdquo;', 'endquote', 'gencwooc' );
    136115
     
    138117    }
    139118
    140     /** Original unmodified */
    141119    return $crumb;
    142 }
    143 
     120
     121}
    144122
    145123add_filter( 'genesis_single_crumb', 'gencwooc_get_single_crumb', 10, 2 );
    146124/**
    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.
    156137 */
    157138function gencwooc_get_single_crumb( $crumb, $args ) {
    158139
    159     /** Are we on a single product page? */
    160140    if ( is_singular( 'product' ) ) {
    161 
    162141        global $post;
    163142
    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' );
    171147        $shop_title = get_the_title( $shop_id );
    172148
    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 ) {
    174150            $prepend = gencwooc_get_crumb_link( get_permalink( $shop_id ), $shop_title, $shop_title, $args['sep'] );
     151        }
    175152
    176153        $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 );
    180158            $parents = array();
    181             $parent = $term->parent;
    182             while ( $parent ):
    183                 $parents[] = $parent;
     159            $parent  = $term->parent;
     160
     161            while ( $parent ) {
     162                $parents[]  = $parent;
    184163                $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 ) ) {
    189168                $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' );
    192172                    $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
    195176            $crumb .= gencwooc_get_crumb_link( get_term_link( $term->slug, 'product_cat' ), $term->name, $term->name, $args['sep'] );
    196         endif;
     177        }
    197178
    198179        $crumb .= get_the_title();
     
    201182    }
    202183
    203     /** Fallback - original unmodified */
    204184    return $crumb;
    205 }
    206 
     185
     186}
    207187
    208188/**
    209189 * Helper function to create anchor link for a single crumb.
    210190 *
    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 *
    219200 * @return string HTML markup for anchor link and optional separator.
    220201 */
    221202function gencwooc_get_crumb_link( $url, $title, $content, $sep = false ) {
    222203
    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 ) {
    226212        $link .= $sep;
     213    }
    227214
    228215    return $link;
  • genesis-connect-woocommerce/trunk/lib/posts-per-page.php

    r1575771 r2123371  
    11<?php
    22/**
    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.
    54 *
    6  * @package genesis_connect_woocommerce
    7  * @version 0.9.8
    8  *
     5 * @package Genesis_Connect_WooCommerce
    96 * @since 0.9.0
    107 */
    118
    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.' ) );
     9if ( ! defined( 'ABSPATH' ) ) {
     10    exit;
     11}
    1712
    1813add_filter( 'woocommerce_settings_tabs_array', 'genesis_connect_addon_tab', 50 );
    19 /*
     14/**
    2015 * Add a custom tab in the WooCommerce settings for Genesis Connect.
    2116 *
    2217 * @since 1.0.0
     18 *
     19 * @param array $tabs Used to add a tab to the WooCommerce settings page.
     20 *
    2321 * @return array $tabs Used to add a tab to the WooCommerce settings page.
    2422 */
    2523function genesis_connect_addon_tab( $tabs ) {
    2624
    27     // Add our own section.
    2825    $tabs['gencwooc'] = __( 'Genesis Connect Addons', 'gencwooc' );
     26
    2927    return $tabs;
    3028
     
    3634 *
    3735 * @since 1.0.0
    38  * @return array Multiple arrays holding our section information
    3936 */
    40 
    4137function genesis_connect_settings_tab() {
    42     woocommerce_admin_fields( genesis_connect_get_settings() );
     38    woocommerce_admin_fields( genesis_connect_get_settings() );
    4339}
    4440
     
    4844 *
    4945 * @since 1.0.0
    50  * @return array Settings to update.
    5146 */
    5247function genesis_connect_update_settings() {
    53     woocommerce_update_options( genesis_connect_get_settings() );
     48    woocommerce_update_options( genesis_connect_get_settings() );
    5449}
    5550
     
    5853 *
    5954 * @since 1.0.0
     55 *
    6056 * @return array $settings Array of our settings.
    6157 */
    6258function genesis_connect_get_settings() {
    63     $settings = array(
     59
     60    $settings = array(
    6461        'gencwooc_section_title' => array(
    6562            'name' => __( 'Genesis Connect Addons', 'gencwooc' ),
    6663            'type' => 'title',
    6764            'desc' => 'Set and save additional WooCommerce settings here.',
    68             'id'   => 'gencwooc_section_title'
     65            'id'   => 'gencwooc_section_title',
    6966        ),
    70         'products_per_page' => array(
     67        'products_per_page'      => array(
    7168            'name'    => __( 'Products Per Page', 'gencwooc' ),
    7269            'type'    => 'number',
     
    7471            'id'      => 'gencwooc_products_per_page',
    7572            '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
    8382}
    8483
     84add_filter( 'loop_shop_per_page', 'genesiswooc_products_per_page' );
    8585/**
    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).
    8887 *
    8988 * @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.
    9193 */
    92 add_filter( 'loop_shop_per_page', 'genesiswooc_products_per_page' );
    9394function genesiswooc_products_per_page( $count ) {
    9495
    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    }
    96101
    97102    return $count;
  • genesis-connect-woocommerce/trunk/lib/template-loader.php

    r1921233 r2123371  
    11<?php
    22/**
    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
    86 * @since 0.9.0
    97 */
    108
    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 
     9if ( ! defined( 'ABSPATH' ) ) {
     10    exit;
     11}
    1812
    1913/**
    2014 * Load the Genesis-fied templates, instead of the WooCommerce defaults.
    2115 *
    22  * Hooked to 'template_include' filter
    23  *
    24  * This template loader determines which template file will be used for the requested page, and uses the
    25  * 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:
    2620 * 1. First looks in the child theme's 'woocommerce' folder.
    2721 * 2. If no template found, falls back to GCW's templates.
    2822 *
    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.
    3126 *
    3227 * GCW provides three templates in the plugin's 'templates' directory:
     
    3530 * - taxonomy.php
    3631 *
    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 *
    3936 * Permitted user templates (as per WP Template Hierarchy) are:
    4037 * - single-product.php
     
    4441 * - taxonomy.php
    4542 *
    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.
    4846 *
    4947 * @since 0.9.0
    5048 *
    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 template
     49 * @param string $template Template file as per template hierarchy.
     50 *
     51 * @return string $template Template file as per template hierarchy.
    5452 */
    5553function gencwooc_template_loader( $template ) {
     
    5957    }
    6058
    61     if ( is_single() && 'product' == get_post_type() ) {
    62 
     59    if ( is_single() && 'product' === get_post_type() ) {
    6360        $template = locate_template( array( 'woocommerce/single-product.php' ) );
    6461
    65         if ( ! $template )
     62        if ( ! $template ) {
    6663            $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' ) ) ) {
    7166        $template = locate_template( array( 'woocommerce/archive-product.php' ) );
    7267
    73         if ( ! $template )
     68        if ( ! $template ) {
    7469            $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' );
    8474        $taxonomies = get_object_taxonomies( 'product', 'names' );
    8575
    86         if ( in_array( $tax, $taxonomies ) ) {
    87 
    88             $tax = sanitize_title( $tax );
     76        if ( in_array( $tax, $taxonomies, true ) ) {
     77            $tax  = sanitize_title( $tax );
    8978            $term = sanitize_title( $term );
    9079
    9180            $templates = array(
    92                 'woocommerce/taxonomy-'.$tax.'-'.$term.'.php',
    93                 'woocommerce/taxonomy-'.$tax.'.php',
     81                "woocommerce/taxonomy-{$tax}-{$term}.php",
     82                "woocommerce/taxonomy-{$tax}.php",
    9483                'woocommerce/taxonomy.php',
    9584            );
     
    9786            $template = locate_template( $templates );
    9887
    99             /** Fallback to GCW template */
    100             if ( ! $template )
     88            if ( ! $template ) {
    10189                $template = GCW_TEMPLATE_DIR . '/taxonomy.php';
     90            }
    10291        }
    10392    }
     
    10796}
    10897
    109 
    110 
    111 /**
    112  * Shop Loop 'template part' loader
     98/**
     99 * Shop Loop 'template part' loader.
    113100 *
    114101 * ONLY RETAINED FOR BACKWARDS COMPATIBILITY for GCW pre-0.9.2 custom templates which
     
    118105 * loads the default WooCommerce loop-shop.php file.
    119106 *
    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 *
    125113 * It is recommended to use woocommerce/templates/loop-shop.php as the starting point of
    126114 * any custom loop template.
     
    129117 *
    130118 * 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
    132122 *
    133123 * @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 */
     128function gencwooc_get_template_part( $slug, $name = '' ) {
    138129
    139130    global $woocommerce;
     131
    140132    $template = '';
    141133
    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" ) ) {
    148139        $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 ) {
    155147        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 *
    168163 * @see woocommerce/woocommerce-template.php
    169164 *
    170  *
    171165 * @since 0.9.4
    172  * @updated 0.9.6
    173  * @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.
    174168 */
    175169function genesiswooc_product_archive() {
     
    177171    global $shop_page_id;
    178172
    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' ) . ' &ldquo;' . get_search_query() . '&rdquo;';
    185             if ( get_query_var( 'paged' ) ) $shop_page_title .= ' &mdash; ' . __( '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' ) . ' &ldquo;' . get_search_query() . '&rdquo;';
     179
     180        if ( get_query_var( 'paged' ) ) {
     181            $shop_page_title .= ' &mdash; ' . __( 'Page', 'gencwooc' ) . ' ' . get_query_var( 'paged' );
     182        }
     183
     184        $shop_page_content = '';
     185    }
    188186
    189187    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
    195195
    196196    woocommerce_get_template_part( 'loop', 'shop' );
     
    199199
    200200    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 *
    212213 * @see woocommerce/woocommerce-template.php
    213214 *
    214  *
    215215 * @since 0.9.4
    216216 */
     
    227227}
    228228
    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.
    239237 *
    240238 * @since 0.9.4
    241  * @updated 0.9.8
    242239 */
    243240function genesiswooc_content_product() {
    244241
    245242    /**
    246      * woocommerce_before_main_content hook
     243     * For woocommerce_before_main_content hook.
    247244     *
    248245     * @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
     
    253250    if ( apply_filters( 'woocommerce_show_page_title', true ) ) {
    254251        echo '<h1 class="woocommerce-products-header__title page-title">';
     252
    255253        woocommerce_page_title();
     254
    256255        echo '</h1>';
    257256    }
     
    268267         */
    269268        do_action( 'woocommerce_before_shop_loop' );
     269
    270270        woocommerce_product_loop_start();
     271
    271272        if ( wc_get_loop_prop( 'total' ) ) {
    272273            while ( have_posts() ) {
    273274                the_post();
     275
    274276                /**
    275277                 * Hook: woocommerce_shop_loop.
     
    278280                 */
    279281                do_action( 'woocommerce_shop_loop' );
     282
    280283                wc_get_template_part( 'content', 'product' );
    281284            }
    282285        }
     286
    283287        woocommerce_product_loop_end();
     288
    284289        /**
    285290         * Hook: woocommerce_after_shop_loop.
     
    296301        do_action( 'woocommerce_no_products_found' );
    297302    }
     303
    298304    /**
    299305     * Hook: woocommerce_after_main_content.
  • genesis-connect-woocommerce/trunk/readme.txt

    r1921233 r2123371  
    33Tags: genesis, genesiswp, studiopress, woocommerce
    44Requires at least: 3.3
    5 Tested up to: 4.9
    6 Stable tag: 1.0
     5Tested up to: 5.2.2
     6Stable tag: 1.1.0
    77
    88This plugin allows you to seamlessly integrate WooCommerce with the Genesis Framework and Genesis child themes.
     
    131131
    132132== 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.
    133138
    134139= 1.0 =
     
    163168= 0.9.8 =
    164169* Released 9 July 2014
    165 * Updates genesiswooc_content_product() to reflect WooC 2.1+ templates and correct handling of WooC's page title filter function
     170* Updates genesiswooc_content_product() to reflect WooCommerce 2.1+ templates and correct handling of WooCommerce page title filter function
    166171
    167172= 0.9.7 =
     
    188193= 0.9.2 =
    189194* Released 15 March 2012
    190 * single-product.php - Single product title template file now hooked in as per WooC 1.5.2
     195* single-product.php - Single product title template file now hooked in as per WooCommerce 1.5.2
    191196
    192197= 0.9.1 =
  • genesis-connect-woocommerce/trunk/sp-plugins-integration/genesis-simple-menus.php

    r1812865 r2123371  
    11<?php
    22/**
    3  * Integration - Genesis Simple Menus
     3 * Genesis Simple Menus integration.
    44 *
    5  * @package genesis_connect_woocommerce
    6  * @version 0.9.8
    7 
    8  *
     5 * @package Genesis_Connect_WooCommerce
    96 * @since 0.9.0
    107 *
     
    129 *
    1310 * 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)
    1613 *
    1714 * 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 Page
     15 *  1. GCW adds post_type_support for GSM - see gencwooc_setup()
     16 *  2. uses Genesis filters to intercept request and serve correct GSM menu on Shop Page
    2017 *
    2118 * Note: this file is loaded on the 'after_theme_setup' hook only if GSM
    2219 * is activated.
    2320 * @see gencwooc_setup() in genesis-connect-woocommerce.php
    24  *
    2521 */
    2622
    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 
     23if ( ! defined( 'ABSPATH' ) ) {
     24    exit;
     25}
    3326
    3427add_filter( 'genesis_pre_get_option_subnav_type', 'gencwooc_gsm_subnav_type', 9 );
    3528/**
    36  * Tells Genesis to load a custom menu
     29 * Tells Genesis to load a custom menu.
    3730 *
    3831 * @since 0.9.0
    3932 *
    4033 * @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.
    4338 */
    4439function gencwooc_gsm_subnav_type( $nav ) {
     
    4944add_filter( 'theme_mod_nav_menu_locations', 'gencwooc_gsm_theme_mod' );
    5045/**
    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.
    5247 *
    5348 * @since 0.9.0
    5449 *
    5550 * @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.
    5855 */
    5956function gencwooc_gsm_theme_mod( $mods ) {
    6057
    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 );
    6360
    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 ) {
    6762        $mods['secondary'] = (int) $_menu;
     63    }
    6864
    6965    return $mods;
  • genesis-connect-woocommerce/trunk/sp-plugins-integration/genesis-simple-sidebars.php

    r1921233 r2123371  
    11<?php
    22/**
    3  * Integration - Genesis Simple Sidebars
     3 * Genesis Simple Sidebars integration.
    44 *
    5  * @package genesis_connect_woocommerce
    6  * @version 0.9.8
    7  *
     5 * @package Genesis_Connect_WooCommerce
    86 * @since 0.9.0
    97 *
    10  * Based on Genesis Simple Sidebars (GSS) version 0.9.2
     8 * Based on Genesis Simple Sidebars (GSS) version 0.9.2.
    119 *
    1210 * 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).
    1513 *
    1614 * 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.
    2018 *
    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.
    2320 * @see gencwooc_setup() in genesis-connect-woocommerce.php
    24  *
    25  * @TODO simply these functions
    2621 */
    2722
    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' ) );
     23if ( ! defined( 'ABSPATH' ) ) {
     24    exit;
     25}
    3326
    3427
    3528add_action( 'get_header', 'gencwooc_ss_handler', 11 );
    3629/**
    37  * Take control of GSS sidebar loading
     30 * Take control of GSS sidebar loading.
    3831 *
    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.
    4234 *
    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 *
    4538 * @see GSS ss_sidebars_init() in genesis-simple-sidebars/plugin.php
    4639 *
    4740 * Note for developers:
    4841 * ====================
    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 this
    51  * function and replace it with your 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.
    5245 *
    5346 * @since 0.9.0
    54  *
    5547 */
    5648function gencwooc_ss_handler() {
    5749
    58     /** Unhook GSS functions */
    5950    remove_action( 'genesis_sidebar', 'ss_do_sidebar' );
    6051    remove_action( 'genesis_sidebar_alt', 'ss_do_sidebar_alt' );
    6152
    62     /** Hook replacement functions */
    6353    add_action( 'genesis_sidebar', 'gencwooc_ss_do_sidebar' );
    6454    add_action( 'genesis_sidebar_alt', 'gencwooc_ss_do_sidebar_alt' );
     
    6858
    6959/**
    70  * Callback for dealing with Primary Sidebar loading
     60 * Callback for dealing with Primary Sidebar loading.
    7161 *
    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().
    7565 *
    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.
    7968 *
    8069 * If either of the above conditions return false, we load the regular sidebar.
     
    8372 *
    8473 * @uses woocommerce_get_page_id()
    85  *
    8674 */
    8775function gencwooc_ss_do_sidebar() {
    8876
    89     $bar = '_ss_sidebar';
    9077    $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 );
    9179
    92     if ( is_post_type_archive( 'product' ) && $_bar = get_post_meta( $shop_id, $bar, true ) ) {
    93 
     80    if ( is_post_type_archive( 'product' ) && $_bar ) {
    9481        dynamic_sidebar( $_bar );
    95 
    9682    } else {
    97 
    9883        genesis_do_sidebar();
    99 
    10084    }
    10185
     
    10488
    10589/**
    106  * Callback for dealing with Sidebar Alt loading
     90 * Callback for dealing with Sidebar Alt loading.
    10791 *
    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().
    11195 *
    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.
    11598 *
    11699 * If either of the above conditions return false, we load the regular alt sidebar.
     
    119102 *
    120103 * @uses woocommerce_get_page_id()
    121  *
    122104 */
    123105function gencwooc_ss_do_sidebar_alt() {
    124106
    125     $bar = '_ss_sidebar_alt';
    126107    $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 );
    127109
    128     if ( is_post_type_archive( 'product' ) && $_bar = get_post_meta( $shop_id, $bar, true ) ) {
    129 
     110    if ( is_post_type_archive( 'product' ) && $_bar ) {
    130111        dynamic_sidebar( $_bar );
    131 
    132112    } else {
    133 
    134113        genesis_do_sidebar_alt();
    135 
    136114    }
    137115
  • genesis-connect-woocommerce/trunk/templates/archive-product.php

    r1921233 r2123371  
    11<?php
    22/**
    3  * This template displays the archive for Products
     3 * This template displays the archive for Products.
    44 *
    5  * @package genesis_connect_woocommerce
     5 * @package Genesis_Connect_WooCommerce
    66 * @version 0.9.8
     7 * @since 0.9.0
    78 *
    89 * Note for customisers/users: Do not edit this file!
     
    1314 * The version in the child theme's woocommerce folder will override this template, and
    1415 * any future updates to this plugin won't wipe out your customisations.
    15  *
    16  * @since 0.9.0
    17  *
    1816 */
    1917
    20 /** Remove default Genesis loop */
     18if ( ! defined( 'ABSPATH' ) ) {
     19    exit;
     20}
     21
    2122remove_action( 'genesis_loop', 'genesis_do_loop' );
    22 
    23 /** Remove Genesis archive title/description */
    2423remove_action( 'genesis_before_loop', 'genesis_do_taxonomy_title_description', 15 );
    25 
    26 /** Remove WooCommerce breadcrumbs */
    2724remove_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 */
    3325remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
    3426remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
     
    4234 * @since 0.9.0
    4335 *
    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.
    4639 */
    4740function genesiswooc_archive_layout( $layout ) {
     
    6154 * Display shop items (product custom post archive)
    6255 *
    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.
    6758 *
    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
    7064 *
    7165 * @since 0.9.0
    72  * @updated 0.9.4
    73  * @global object $woocommerce
     66 *
     67 * @global WooCommerce $woocommerce Current WooCommerce instance.
    7468 */
    7569function genesiswooc_archive_product_loop() {
     
    7973    $new = version_compare( $woocommerce->version, '1.6.0', '>=' );
    8074
    81     if ( $new )
     75    if ( $new ) {
    8276        genesiswooc_content_product();
     77    } else {
     78        genesiswooc_product_archive();
     79    }
    8380
    84     else
    85         genesiswooc_product_archive();
    8681}
    8782
  • genesis-connect-woocommerce/trunk/templates/single-product.php

    r1921233 r2123371  
    11<?php
    22/**
    3  * This template displays the single Product
     3 * This template displays the single Product.
    44 *
    5  * @package genesis_connect_woocommerce
     5 * @package Genesis_Connect_WooCommerce
    66 * @version 0.9.8
     7 * @since 0.9.0
    78 *
    89 * Note for customisers/users: Do not edit this file!
     
    1314 * The version in the child theme's woocommerce folder will override this template, and
    1415 * any future updates to this plugin won't wipe out your customisations.
    15  *
    1616 */
    1717
    18 /** Remove default Genesis loop */
     18if ( ! defined( 'ABSPATH' ) ) {
     19    exit;
     20}
     21
    1922remove_action( 'genesis_loop', 'genesis_do_loop' );
    20 
    21 /** Remove WooCommerce breadcrumbs */
    2223remove_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 */
    2824remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
    2925remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
    3026
    31 
    3227add_action( 'genesis_loop', 'gencwooc_single_product_loop' );
    3328/**
    34  * Displays single product loop
     29 * Displays single product loop.
    3530 *
    36  * Uses WooCommerce structure and contains all existing WooCommerce hooks
     31 * Uses WooCommerce structure and contains all existing WooCommerce hooks.
    3732 *
    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 *
    3935 * @see woocommerce/woocommerce-template.php
    4036 *
     
    4541    do_action( 'woocommerce_before_main_content' );
    4642
    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 );
    4944
    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 ) {
    5546        global $wp_query;
    5647
     
    5849    }
    5950
    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();
    6154
    62         <?php do_action('woocommerce_before_single_product'); ?>
     55            do_action( 'woocommerce_before_single_product' );
     56            ?>
    6357
    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' ); ?>
    6560
    66             <?php do_action( 'woocommerce_before_single_product_summary' ); ?>
     61                <div class="summary">
     62                    <?php do_action( 'woocommerce_single_product_summary' ); ?>
     63                </div>
    6764
    68             <div class="summary">
    69 
    70                 <?php do_action( 'woocommerce_single_product_summary'); ?>
    71 
     65                <?php do_action( 'woocommerce_after_single_product_summary' ); ?>
    7266            </div>
    7367
    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    }
    8172
    8273    do_action( 'woocommerce_after_main_content' );
     74
    8375}
    8476
  • genesis-connect-woocommerce/trunk/templates/taxonomy.php

    r1921233 r2123371  
    11<?php
    22/**
    3  * This template displays the Product Category and Tag taxonomy term archives
     3 * This template displays the Product Category and Tag taxonomy term archives.
    44 *
    5  * @package genesis_connect_woocommerce
     5 * @package Genesis_Connect_WooCommerce
    66 * @version 0.9.8
     7 * @since 0.9.0
    78 *
    89 * Note for customisers/users: Do not edit this file!
     
    1314 * The version in the child theme's woocommerce folder will override this template, and
    1415 * any future updates to this plugin won't wipe out your customisations.
    15  *
    1616 */
    1717
     18if ( ! defined( 'ABSPATH' ) ) {
     19    exit;
     20}
    1821
    19 /** Remove default Genesis loop */
    2022remove_action( 'genesis_loop', 'genesis_do_loop' );
     23remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description' );
     24remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
     25remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
     26remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
    2127
    22 // Remove the WooCommerce archive title and description.
    2328add_filter( 'woocommerce_show_page_title', '__return_false' );
    24 remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description' );
    2529
    2630add_filter( 'genesis_term_intro_text_output', 'genesiswooc_term_intro_text_output' );
     
    2832 * Fall back to the archive description if no intro text is set.
    2933 *
     34 * @since 1.0.0
     35 *
    3036 * @param string $intro_text The default Genesis archive intro text.
     37 *
    3138 * @return string Archive intro text, or archive description if no intro text set.
    32  *
    33  * @since 1.0
    3439 */
    3540function genesiswooc_term_intro_text_output( $intro_text ) {
     41
    3642    $wp_archive_description = get_the_archive_description();
    3743
     
    4147
    4248    return $intro_text;
     49
    4350}
    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 
    5651
    5752add_action( 'genesis_loop', 'genesiswooc_product_taxonomy_loop' );
    5853/**
    59  * Displays shop items for the queried taxonomy term
     54 * Displays shop items for the queried taxonomy term.
    6055 *
    6156 * 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 contents
    64  * 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.
    6560 *
    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
    6865 *
    6966 * @since 0.9.0
    70  * @updated 0.9.4
    7167 */
    7268function genesiswooc_product_taxonomy_loop() {
     
    7672    $new = version_compare( $woocommerce->version, '1.6.0', '>=' );
    7773
    78     if ( $new )
     74    if ( $new ) {
    7975        genesiswooc_content_product();
    80 
    81     else
     76    } else {
    8277        genesiswooc_product_taxonomy();
     78    }
    8379
    8480}
Note: See TracChangeset for help on using the changeset viewer.