= 80 || $hestia_sidebar_width <= 3 ) { $offset = ''; } if ( $sidebar_layout === 'full-width' ) { return $classes . ' col-md-offset-2'; } if ( $sidebar_layout === 'sidebar-left' ) { return is_customize_preview() ? $classes . ' ' . esc_attr( $offset ) : is_active_sidebar( 'sidebar-1' ) ? $classes . ' ' . esc_attr( $offset ) : $classes . ' col-md-offset-2'; } if ( $sidebar_layout === 'sidebar-right' ) { return is_customize_preview() ? $classes : is_active_sidebar( 'sidebar-1' ) ? $classes : $classes . ' col-md-offset-2'; } return $classes; } /** * Index content classes. * * @param string $classes index classes. * * @return string */ public function index_search_content_classes( $classes ) { $default = hestia_get_blog_layout_default(); $sidebar_layout = apply_filters( 'hestia_sidebar_layout', get_theme_mod( 'hestia_blog_sidebar_layout', $default ) ); $offset = 'col-md-offset-1'; $hestia_sidebar_width = get_theme_mod( 'hestia_sidebar_width', 25 ); if ( $hestia_sidebar_width >= 80 || $hestia_sidebar_width <= 3 ) { $offset = ''; } if ( $sidebar_layout === 'full-width' ) { return 'col-md-10 col-md-offset-1 blog-posts-wrap'; } if ( $sidebar_layout === 'sidebar-left' ) { return is_customize_preview() ? $classes . ' ' . esc_attr( $offset ) : is_active_sidebar( 'sidebar-1' ) ? $classes . ' ' . esc_attr( $offset ) : 'col-md-10 col-md-offset-1 blog-posts-wrap'; } if ( $sidebar_layout === 'sidebar-right' ) { return is_customize_preview() ? $classes : is_active_sidebar( 'sidebar-1' ) ? $classes : 'col-md-10 col-md-offset-1 blog-posts-wrap'; } return $classes; } /** * Adjust blog sidebar classes. * * @param string $classes the classes for blog sidebar. * * @return string */ public function blog_sidebar_classes( $classes ) { if ( is_page() ) { return $classes; } $default = hestia_get_blog_layout_default(); $sidebar_layout = apply_filters( 'hestia_sidebar_layout', get_theme_mod( 'hestia_blog_sidebar_layout', $default ) ); if ( $sidebar_layout === 'sidebar-left' ) { return $classes; } if ( function_exists( 'is_bbpress' ) && is_bbpress() ) { return $classes; } if ( function_exists( 'is_buddypress' ) && is_buddypress() ) { return $classes; } $offset = 'col-md-offset-1'; $hestia_sidebar_width = get_theme_mod( 'hestia_sidebar_width', 25 ); if ( $hestia_sidebar_width >= 80 || $hestia_sidebar_width <= 3 ) { $offset = ''; } $classes .= ' ' . $offset; return $classes; } /** * Render the page sidebar. */ public function render_page_sidebar() { if ( class_exists( 'WooCommerce' ) ) { if ( is_cart() || is_checkout() || is_account_page() ) { return; } if ( is_shop() ) { get_sidebar( 'woocommerce' ); return; } } get_sidebar(); return; } /** * Post content classes. * * @param string $classes post content classes. * * @return string */ public function content_classes( $classes ) { if ( ! class_exists( 'WooCommerce' ) ) { return $classes; } $sidebar_layout = $this->get_page_sidebar_layout(); if ( is_product() ) { return 'col-md-12'; } if ( $this->should_have_sidebar() ) { $classes = 'content-' . $sidebar_layout . ' col-md-9'; } return $classes; } /** * Change shop columns when we have a shop sidebar. */ public function sidebar_columns() { return apply_filters( 'hestia_shop_loop_columns', 3 ); // 3 products per row } /** * Utility to check if should have sidebar. * * @return bool */ private function should_have_sidebar() { if ( is_customize_preview() && $this->get_page_sidebar_layout() !== 'full-width' ) { return true; } if ( is_active_sidebar( 'sidebar-woocommerce' ) && $this->get_page_sidebar_layout() !== 'full-width' ) { return true; } return false; } /** * Get the sidebar layout. * * @return mixed|string */ public function get_page_sidebar_layout() { if ( is_shop() ) { return hestia_get_shop_sidebar_layout(); } return apply_filters( 'hestia_sidebar_layout', get_theme_mod( 'hestia_page_sidebar_layout', 'full-width' ) ); } }