';
echo '
';
}
// define the woocommerce_sidebar callback
function courtyard_woocommerce_sidebar( ) {
courtyard_woocommerce_sidebar_select();
echo '
';
echo '
';
};
/*---------------------------------------------------------------------------------------------------------------*/
if ( ! function_exists( 'courtyard_woocommerce_sidebar_layout_class' ) ) :
/**
* Generate layout class for sidebar based on customizer and post meta settings for woocommerce pages.
*/
function courtyard_woocommerce_sidebar_layout_class() {
global $post;
$layout = get_theme_mod( 'courtyard_woocommerce_shop_sidebar', 'right_sidebar' );
// Front page displays in Reading Settings
$page_for_posts = get_option('page_for_posts');
// Get Layout meta
if($post) {
$layout_meta = get_post_meta( $post->ID, 'page_specific_layout', true );
}
// Home page if Posts page is assigned
if( is_home() && !( is_front_page() ) ) {
$queried_id = get_option( 'page_for_posts' );
$layout_meta = get_post_meta( $queried_id, 'page_specific_layout', true );
if( $layout_meta != 'default_layout' && $layout_meta != '' ) {
$layout = get_post_meta( $queried_id, 'page_specific_layout', true );
}
}
elseif( is_page() ) {
$layout = get_theme_mod( 'courtyard_woocommerce_shop_sidebar', 'right_sidebar' );
if( $layout_meta != 'default_layout' && $layout_meta != '' ) {
$layout = get_post_meta( $post->ID, 'page_specific_layout', true );
}
}
elseif( is_single() ) {
$layout = get_theme_mod( 'courtyard_woocommerce_product_sidebar', 'right_sidebar' );
if( $layout_meta != 'default_layout' && $layout_meta != '' ) {
$layout = get_post_meta( $post->ID, 'page_specific_layout', true );
}
}
return $layout;
}
endif;
/*--------------------------------------------------------------------------------------------------*/
if ( ! function_exists( 'courtyard_woocommerce_primary_sidebar_class' ) ) :
/**
* Select and show sidebar based on post meta and WooCommerce customizer default settings
*/
function courtyard_woocommerce_primary_sidebar_class() {
$layout = courtyard_woocommerce_sidebar_layout_class();
if ( $layout == "right_sidebar" ) {
$classes = 'col-md-8';
} elseif ( $layout == "left_sidebar" ) {
$classes = 'col-md-8 pull-right';
} elseif ( $layout == "no_sidebar_full_width" ) {
$classes = 'col-md-12';
}
return esc_html( $classes );
}
endif;
/*--------------------------------------------------------------------------------------------------*/
if ( ! function_exists( 'courtyard_woocommerce_secondary_sidebar_class' ) ) :
/**
* Select and show sidebar based on post meta and customizer default settings
*/
function courtyard_woocommerce_secondary_sidebar_class() {
$layout = courtyard_woocommerce_sidebar_layout_class();
if ( $layout == "right_sidebar" ) {
$classes = 'col-md-4 ';
} elseif ( $layout == "left_sidebar" ) {
$classes = 'col-md-4 pull-left';
} elseif ( $layout == "no_sidebar_full_width" ) {
$classes = 'col-md-12';
}
return esc_html( $classes );
}
endif;
/*--------------------------------------------------------------------------------------------------*/
if ( ! function_exists( 'courtyard_woocommerce_sidebar_select' ) ) :
/**
* Select and show sidebar based on post meta and WooCommerce customizer default settings
*/
function courtyard_woocommerce_sidebar_select() {
$layout = courtyard_woocommerce_sidebar_layout_class();
if( $layout != "no_sidebar_full_width" ) {
if ( $layout == "right_sidebar" || $layout = "left_sidebar" || $layout = "default_layout" ) {
echo '';
}
}
}
endif;
/*--------------------------------------------------------------------------------------------------*/
/**
* WooCommerce Cart Icon in Primary Menu
*/
function pt_woo_cart_icon( $items, $args ) {
if ( $args->theme_location == 'primary' ) {
if( class_exists( 'WooCommerce' ) ) :
$items .= '