From 84444df9771729d30b1c73c2c3748a9bcc4336e0 Mon Sep 17 00:00:00 2001 From: Andrew Misplon Date: Mon, 25 Dec 2017 09:54:19 -0800 Subject: [PATCH 1/4] Add WC sidebar and related position setting Close #315. --- functions.php | 12 ++++++++++++ inc/extras.php | 11 +++++++++++ inc/settings.php | 33 ++++++++++++++++++++++----------- sidebar-shop.php | 20 ++++++++++++++++++++ woocommerce.php | 2 +- 5 files changed, 66 insertions(+), 12 deletions(-) create mode 100644 sidebar-shop.php diff --git a/functions.php b/functions.php index edf8d39a..3144c1cc 100644 --- a/functions.php +++ b/functions.php @@ -220,6 +220,18 @@ function siteorigin_north_widgets_init() { 'after_title' => '', ) ); + if ( function_exists( 'is_woocommerce' ) ) { + register_sidebar( array( + 'name' => esc_html__( 'Shop Sidebar', 'siteorigin-north' ), + 'id' => 'sidebar-shop', + 'description' => esc_html__( 'Displays on WooCommerce pages.', 'siteorigin-north' ), + 'before_widget' => '', + 'before_title' => '

', + 'after_title' => '

', + ) ); + } + } endif; add_action( 'widgets_init', 'siteorigin_north_widgets_init' ); diff --git a/inc/extras.php b/inc/extras.php index 8e908fce..95f35d12 100644 --- a/inc/extras.php +++ b/inc/extras.php @@ -56,9 +56,20 @@ function siteorigin_north_body_classes( $classes ) { } if ( class_exists( 'Woocommerce' ) ) { + if ( ! siteorigin_setting( 'masthead_text_above' ) && ! is_active_sidebar( 'topbar-sidebar' ) && ! is_store_notice_showing() ) { $classes[] = 'no-topbar'; } + + if ( siteorigin_setting( 'woocommerce_sidebar_position' ) == 'left' && ( is_woocommerce() || is_cart() || is_checkout() ) ) { + $classes[] = 'layout-sidebar-left'; + } + + if ( siteorigin_setting( 'woocommerce_sidebar_position' ) == 'none' && ( is_woocommerce() || is_cart() || is_checkout() ) ) { + $classes[] = 'no-active-sidebar'; + } + + } elseif ( ! siteorigin_setting( 'masthead_text_above' ) && ! is_active_sidebar( 'topbar-sidebar' ) ) { $classes[] = 'no-topbar'; } diff --git a/inc/settings.php b/inc/settings.php index e92d060d..5d5cf31a 100644 --- a/inc/settings.php +++ b/inc/settings.php @@ -461,21 +461,31 @@ function siteorigin_north_woocommerce_settings( $settings ) { ), 'display_cart' => array( - 'type' => 'checkbox', - 'label' => esc_html__( 'Display Cart', 'siteorigin-north' ), + 'type' => 'checkbox', + 'label' => esc_html__( 'Display Cart', 'siteorigin-north' ), 'description' => esc_html__( 'Display WooCommerce cart in the main menu.', 'siteorigin-north' ), ), 'display_checkout_cart' => array( - 'type' => 'checkbox', - 'label' => esc_html__( 'Display Cart in Checkout', 'siteorigin-north' ), + 'type' => 'checkbox', + 'label' => esc_html__( 'Display Cart in Checkout', 'siteorigin-north' ), 'description' => esc_html__( 'Display WooCommerce cart in the main menu on cart and checkout page.', 'siteorigin-north' ), ), 'display_quick_view' => array( - 'type' => 'checkbox', - 'label' => esc_html__( 'Display Quick View button', 'siteorigin-north' ), - ) + 'type' => 'checkbox', + 'label' => esc_html__( 'Display Quick View button', 'siteorigin-north' ), + ), + + 'sidebar_position' => array( + 'type' => 'select', + 'label' => esc_html__( 'Shop Sidebar Position', 'siteorigin-north' ), + 'options' => array( + 'left' => esc_html__( 'Left', 'siteorigin-north' ), + 'right' => esc_html__( 'Right', 'siteorigin-north' ), + 'none' => esc_html__( 'None', 'siteorigin-north' ), + ), + ), ) ) @@ -1232,10 +1242,11 @@ function siteorigin_north_settings_defaults( $defaults ){ $defaults['footer_top_margin'] = '30px'; // WooCommerce defaults - $defaults['woocommerce_archive_columns'] = 3; - $defaults['woocommerce_display_cart'] = true; - $defaults['woocommerce_display_checkout_cart'] = false; - $defaults['woocommerce_display_quick_view'] = false; + $defaults['woocommerce_archive_columns'] = 3; + $defaults['woocommerce_display_cart'] = true; + $defaults['woocommerce_display_checkout_cart'] = false; + $defaults['woocommerce_display_quick_view'] = false; + $defaults['woocommerce_sidebar_position'] = 'right'; return $defaults; } diff --git a/sidebar-shop.php b/sidebar-shop.php new file mode 100644 index 00000000..7006770d --- /dev/null +++ b/sidebar-shop.php @@ -0,0 +1,20 @@ + + +
+ +
diff --git a/woocommerce.php b/woocommerce.php index 32db69c2..f2e5a34f 100644 --- a/woocommerce.php +++ b/woocommerce.php @@ -25,5 +25,5 @@ - + From 5758b197e8e3fdaf4b68c53298cb4882179b40f9 Mon Sep 17 00:00:00 2001 From: Andrew Misplon Date: Wed, 27 Dec 2017 08:37:03 -0800 Subject: [PATCH 2/4] Fix WC sidebar setting --- inc/extras.php | 8 +++---- sass/layout/_content-sidebar.scss | 9 ++++---- sass/layout/_sidebar-content.scss | 9 ++++---- style.css | 38 +++++++++++++++++++------------ 4 files changed, 37 insertions(+), 27 deletions(-) diff --git a/inc/extras.php b/inc/extras.php index 95f35d12..aac9d30e 100644 --- a/inc/extras.php +++ b/inc/extras.php @@ -59,15 +59,15 @@ function siteorigin_north_body_classes( $classes ) { if ( ! siteorigin_setting( 'masthead_text_above' ) && ! is_active_sidebar( 'topbar-sidebar' ) && ! is_store_notice_showing() ) { $classes[] = 'no-topbar'; - } + } if ( siteorigin_setting( 'woocommerce_sidebar_position' ) == 'left' && ( is_woocommerce() || is_cart() || is_checkout() ) ) { - $classes[] = 'layout-sidebar-left'; + $classes[] = 'layout-wc-sidebar-left'; } if ( siteorigin_setting( 'woocommerce_sidebar_position' ) == 'none' && ( is_woocommerce() || is_cart() || is_checkout() ) ) { - $classes[] = 'no-active-sidebar'; - } + $classes[] = 'no-active-wc-sidebar'; + } } elseif ( ! siteorigin_setting( 'masthead_text_above' ) && ! is_active_sidebar( 'topbar-sidebar' ) ) { diff --git a/sass/layout/_content-sidebar.scss b/sass/layout/_content-sidebar.scss index eb7157fe..0c961671 100644 --- a/sass/layout/_content-sidebar.scss +++ b/sass/layout/_content-sidebar.scss @@ -11,20 +11,22 @@ .site-content .widget-area { float: right; overflow: hidden; - width: $size__site-sidebar; padding-left: 40px; + width: $size__site-sidebar; } .site-footer { clear: both; - width: $size__site-main; min-width: 1060px; + width: $size__site-main; + body.responsive & { min-width: 0; } } -.no-active-sidebar { +.no-active-sidebar:not(.woocommerce):not(.woocommerce-page), +.no-active-wc-sidebar { .content-area { float: none; @@ -35,7 +37,6 @@ .site-main { margin: 0; } - } @media (max-width: 600px) { diff --git a/sass/layout/_sidebar-content.scss b/sass/layout/_sidebar-content.scss index 48e4d150..1ca883e2 100644 --- a/sass/layout/_sidebar-content.scss +++ b/sass/layout/_sidebar-content.scss @@ -1,4 +1,5 @@ -.layout-sidebar-left { +.layout-sidebar-left:not(.woocommerce):not(.woocommerce-page), +.layout-wc-sidebar-left { .content-area { float: right; @@ -13,8 +14,8 @@ .site-content .widget-area { float: left; overflow: hidden; - padding-left: 0; padding-right: 40px; + padding-left: 0; width: $size__site-sidebar; } @@ -23,12 +24,12 @@ width: $size__site-main; } - &.no-active-sidebar { + &.no-active-sidebar:not(.woocommerce):not(.woocommerce-page) { .content-area { float: none; - width: auto; margin: 0; + width: auto; } .site-main { diff --git a/style.css b/style.css index d558038a..9ea3e1ea 100644 --- a/style.css +++ b/style.css @@ -1213,22 +1213,24 @@ a { .site-content .widget-area { float: right; overflow: hidden; - width: 35%; - padding-left: 40px; } + padding-left: 40px; + width: 35%; } .site-footer { clear: both; - width: 100%; - min-width: 1060px; } + min-width: 1060px; + width: 100%; } body.responsive .site-footer { min-width: 0; } -.no-active-sidebar .content-area { +.no-active-sidebar:not(.woocommerce):not(.woocommerce-page) .content-area, +.no-active-wc-sidebar .content-area { float: none; width: auto; margin: 0; } -.no-active-sidebar .site-main { +.no-active-sidebar:not(.woocommerce):not(.woocommerce-page) .site-main, +.no-active-wc-sidebar .site-main { margin: 0; } @media (max-width: 600px) { @@ -1246,31 +1248,37 @@ a { /*-------------------------------------------------------------- ## Left Sidebar Layout --------------------------------------------------------------*/ -.layout-sidebar-left .content-area { +.layout-sidebar-left:not(.woocommerce):not(.woocommerce-page) .content-area, +.layout-wc-sidebar-left .content-area { float: right; margin: 0 0 0 -35%; width: 100%; } -.layout-sidebar-left .site-main { +.layout-sidebar-left:not(.woocommerce):not(.woocommerce-page) .site-main, +.layout-wc-sidebar-left .site-main { margin: 0 0 0 35%; } -.layout-sidebar-left .site-content .widget-area { +.layout-sidebar-left:not(.woocommerce):not(.woocommerce-page) .site-content .widget-area, +.layout-wc-sidebar-left .site-content .widget-area { float: left; overflow: hidden; - padding-left: 0; padding-right: 40px; + padding-left: 0; width: 35%; } -.layout-sidebar-left .site-footer { +.layout-sidebar-left:not(.woocommerce):not(.woocommerce-page) .site-footer, +.layout-wc-sidebar-left .site-footer { clear: both; width: 100%; } -.layout-sidebar-left.no-active-sidebar .content-area { +.layout-sidebar-left:not(.woocommerce):not(.woocommerce-page).no-active-sidebar:not(.woocommerce):not(.woocommerce-page) .content-area, +.layout-wc-sidebar-left.no-active-sidebar:not(.woocommerce):not(.woocommerce-page) .content-area { float: none; - width: auto; - margin: 0; } + margin: 0; + width: auto; } -.layout-sidebar-left.no-active-sidebar .site-main { +.layout-sidebar-left:not(.woocommerce):not(.woocommerce-page).no-active-sidebar:not(.woocommerce):not(.woocommerce-page) .site-main, +.layout-wc-sidebar-left.no-active-sidebar:not(.woocommerce):not(.woocommerce-page) .site-main { margin: 0; } /*-------------------------------------------------------------- From d92f020fecf23aa4384bda11532a4be681de9644 Mon Sep 17 00:00:00 2001 From: Andrew Misplon Date: Thu, 28 Dec 2017 11:12:46 -0800 Subject: [PATCH 3/4] Removed empty line --- inc/extras.php | 1 - 1 file changed, 1 deletion(-) diff --git a/inc/extras.php b/inc/extras.php index aac9d30e..8fdc32b8 100644 --- a/inc/extras.php +++ b/inc/extras.php @@ -68,7 +68,6 @@ function siteorigin_north_body_classes( $classes ) { if ( siteorigin_setting( 'woocommerce_sidebar_position' ) == 'none' && ( is_woocommerce() || is_cart() || is_checkout() ) ) { $classes[] = 'no-active-wc-sidebar'; } - } elseif ( ! siteorigin_setting( 'masthead_text_above' ) && ! is_active_sidebar( 'topbar-sidebar' ) ) { $classes[] = 'no-topbar'; From 636b749e5e479772b4463e47221fe1df41815606 Mon Sep 17 00:00:00 2001 From: Andrew Misplon Date: Thu, 28 Dec 2017 11:12:55 -0800 Subject: [PATCH 4/4] Changelog update --- changelog.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/changelog.txt b/changelog.txt index d4b26473..16465e6c 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,8 @@ == Changelog == += 1.4 - 28 December 2017 = +* Added WooCommerce sidebar widget area and theme setting. + = 1.3.25 - 14 December 2017 = * Resolved WooCommerce PayPal logo issue impacting child themes.