_class .= ' single-product-sidebar'; } } /** * Set content column width * * @return integer */ public function get_sidebar_col_width() { return $this->sidebar_col_width; } /** * Set sidebar column width */ private function set_sidebar_col_width() { $specific = ''; // Set here page ID. Will be used to get custom value from metabox of specific PAGE | BLOG PAGE | SHOP PAGE. $page_id = $this->get_page_id(); $this->sidebar_col_width = woodmart_get_opt( 'sidebar_width' ); if ( $page_id ) { $specific = get_post_meta( $page_id, '_woodmart_sidebar_width', true ); } // Get specific sidebar size for Shop Page. if ( woodmart_woocommerce_installed() && ( is_shop() || is_product_category() || is_product_tag() || woodmart_is_product_attribute_archive() || ( is_search() && isset( $_GET['post_type'] ) && 'product' === $_GET['post_type'] ) ) ) { $this->sidebar_col_width = woodmart_get_opt( 'shop_sidebar_width' ); } elseif ( is_singular( 'product' ) ) { // Get specific layout for SINGLE PRODUCT PAGE. $this->sidebar_col_width = woodmart_get_opt( 'single_sidebar_width' ); } elseif ( is_home() || is_singular( 'post' ) || is_archive() ) { // Get specific sidebar size for Blog Page. $this->sidebar_col_width = woodmart_get_opt( 'blog_sidebar_width' ); } elseif ( is_singular( 'woodmart_layout' ) ) { $this->sidebar_col_width = 0; } if ( $specific && 'default' !== $specific ) { // Set specific sidebar size FOR THIS PAGE. $this->sidebar_col_width = $specific; } // Remove theme sidebar for dokan store list page. if ( function_exists( 'dokan_is_store_page' ) && dokan_is_store_page() ) { $this->sidebar_col_width = 0; } $layout = $this->get_page_layout(); // Remove sidebar if it has no widgets. $sidebar_name = $this->get_sidebar_name(); if ( ! is_active_sidebar( $sidebar_name ) && 'sidebar-product-single' !== $sidebar_name ) { $this->sidebar_col_width = 0; } if ( 'full-width' === $layout ) { $this->sidebar_col_width = 0; } if ( empty( $this->sidebar_col_width ) ) { $this->sidebar_col_width = 0; } } /** * Get page layout (sidebar position) * * @return string */ public function get_page_layout() { return apply_filters( 'woodmart_get_page_layout', $this->page_layout ); } /** * Set page layout (sidebar position) */ private function set_page_layout() { global $post, $WCMp; $specific = ''; // Set here page ID. Will be used to get custom value from metabox of specific PAGE | BLOG PAGE | SHOP PAGE. $page_id = $this->get_page_id(); $this->page_layout = woodmart_get_opt( 'main_layout' ); if ( ( is_singular( 'portfolio' ) || is_post_type_archive( 'portfolio' ) || is_tax( 'project-cat' ) ) && ! is_active_sidebar( 'portfolio-widgets-area' ) ) { $this->page_layout = 'full-width'; } if ( $page_id ) { $specific = get_post_meta( $page_id, '_woodmart_main_layout', true ); } if ( woodmart_woocommerce_installed() && ( is_shop() || is_product_category() || is_product_tag() || woodmart_is_product_attribute_archive() || ( is_search() && isset( $_GET['post_type'] ) && 'product' === $_GET['post_type'] ) ) ) { // Get specific layout for Shop Page. $this->page_layout = woodmart_get_opt( 'shop_layout' ); } elseif ( $this->is_account_pages() ) { $this->page_layout = 'full-width'; } elseif ( is_singular( 'product' ) ) { // Get specific layout for SINGLE PRODUCT PAGE. $this->page_layout = woodmart_get_opt( 'single_product_layout' ); } elseif ( isset( $WCMp ) && is_tax( $WCMp->taxonomy->taxonomy_name ) ) { $this->page_layout = woodmart_get_opt( 'blog_layout' ); } elseif ( is_singular( 'post' ) || woodmart_is_blog_archive() ) { // Get specific layout for Blog Page. $this->page_layout = woodmart_get_opt( 'blog_layout' ); // Disable sidebar if blog design is Masonry Grid. if ( 'masonry' === woodmart_get_opt( 'blog_design' ) && ! is_singular( 'post' ) ) { $this->page_layout = 'full-width'; } } if ( $specific && 'default' !== $specific ) { // Set specific layout FOR THIS PAGE. $this->page_layout = $specific; } } /** * Check if it is account page * * @return boolean */ public function is_account_page() { if ( function_exists( 'is_account_page' ) ) { return is_account_page(); } else { return false; } } /** * Check if it is some account pages * * @return boolean */ public function is_account_pages() { $wishlist_page_id = woodmart_get_opt( 'wishlist_page' ); if ( function_exists( 'is_account_page' ) ) { if ( is_account_page() ) { return true; } } if ( (int) $this->get_page_id() === (int) $wishlist_page_id ) { return true; } return false; } /** * Class for page content container * * @return mixed */ public function get_main_container_class() { $class = 'container'; $is_product_builder = Builder::get_instance()->has_custom_layout( 'single_product' ); // Different class for product page. if ( woodmart_woocommerce_installed() && is_singular( 'product' ) && ! get_query_var( 'edit' ) && ( ( function_exists( 'woodmart_elementor_has_location' ) && ! woodmart_elementor_has_location( 'single' ) ) || ! function_exists( 'woodmart_elementor_has_location' ) ) ) { $class = 'container-fluid'; if ( $is_product_builder && 'enabled' === woodmart_get_opt( 'negative_gap' ) ) { $class = 'container'; } } if ( ( (int) woodmart_get_portfolio_page_id() === (int) woodmart_page_ID() ) && woodmart_get_opt( 'portfolio_full_width' ) ) { $class = 'container-fluid container-no-gutters'; } if ( woodmart_is_elementor_full_width() ) { $class = 'container-fluid container-no-gutters'; } return apply_filters( 'woodmart_main_content_classes', $class ); } /** * Gets the value of page_id. * * @return mixed */ public function get_page_id() { return $this->page_id; } }