コード例 #1
0
ファイル: theme_functions.php プロジェクト: nikolaev-k/alwadi
 function rt_sidebar_location()
 {
     global $rt_sidebar_location, $post, $rt_is_template_builder, $rt_post_type;
     // default sidebar positions
     $sidebar = get_option(RT_THEMESLUG . '_sidebar_position');
     $sidebar_blog = get_option(RT_THEMESLUG . '_sidebar_position_blog');
     $sidebar_product = get_option(RT_THEMESLUG . '_sidebar_position_product');
     $sidebar_portfolio = get_option(RT_THEMESLUG . '_sidebar_position_portfolio');
     //check metabox selection - sidebar selection via metaboxes
     $metabox_selection = is_object($post) && !empty($rt_post_type) && !$rt_is_template_builder && (is_page() || is_single()) ? get_post_meta($post->ID, RT_COMMON_THEMESLUG . 'custom_sidebar_position', true) : false;
     // site part = regular pages
     if (!$rt_is_template_builder) {
         $sidebar = $metabox_selection ? $metabox_selection : $sidebar;
     }
     if (!is_search()) {
         // site part = blog
         if (!$rt_is_template_builder && rt_is_blog_page()) {
             $sidebar = $metabox_selection ? $metabox_selection : $sidebar_blog;
         }
         // site part = product
         if (!$rt_is_template_builder && rt_is_product_page()) {
             $sidebar = $metabox_selection ? $metabox_selection : $sidebar_product;
         }
         // site part = portfolio
         if (!$rt_is_template_builder && rt_is_portfolio_page()) {
             $sidebar = $metabox_selection ? $metabox_selection : $sidebar_portfolio;
         }
         // WooCommerce
         if (class_exists('Woocommerce')) {
             $woo_page_id = "";
             $woo_page_id = is_product_category() || is_shop() ? woocommerce_get_page_id('shop') : $woo_page_id;
             if ($woo_page_id) {
                 $sidebar = get_post_meta($woo_page_id, RT_COMMON_THEMESLUG . 'custom_sidebar_position', true) ? get_post_meta($woo_page_id, RT_COMMON_THEMESLUG . 'custom_sidebar_position', true) : $sidebar;
                 //sidebar location for woo shop
             }
         }
     }
     // if sidebar still empty use the right as default position
     if (empty($sidebar)) {
         $sidebar = "right";
     }
     //conten position
     $content_position = $sidebar == "left" ? $content = "right" : "left";
     $content_position = $sidebar == "full" || empty($sidebar) ? "full" : $content_position;
     $rt_sidebar_location = array($content_position, $sidebar);
 }
コード例 #2
0
ファイル: sidebar.php プロジェクト: nikolaev-k/alwadi
 function display_sidebars()
 {
     global $post;
     $post_id = isset($post) && isset($post->ID) ? $post->ID : "";
     $post_type = isset($post->post_type) ? $post->post_type : "";
     // WooCommerce
     if (class_exists('Woocommerce')) {
         if (is_woocommerce() || is_cart() || is_account_page() || is_checkout()) {
             dynamic_sidebar('woo-commerce-contents');
             $WooCommercePage = "TRUE";
         }
     }
     // Call Search Sidebar
     if (is_search() && $this->is_enabled_sidebar('sidebar-for-search')) {
         dynamic_sidebar('sidebar-for-search');
         dynamic_sidebar('common-sidebar');
         return false;
     }
     // Page Sidebar
     if (!rt_is_theme_page() && is_page() && $this->is_enabled_sidebar('sidebar-for-pages')) {
         dynamic_sidebar('sidebar-for-pages');
     }
     // Portfolio Sidebar - all portfolio contents
     if (rt_is_portfolio_page() && $this->is_enabled_sidebar('sidebar-for-portfolio')) {
         dynamic_sidebar('sidebar-for-portfolio');
     }
     // Portfolio Sidebar - single portfolio item
     if (is_single() && $post_type == 'portfolio' && $this->is_enabled_sidebar('sidebar-for-portfolio')) {
         dynamic_sidebar('sidebar-for-portfolios');
     }
     // Product Sidebar - all product contents
     if (rt_is_product_page() && $this->is_enabled_sidebar('sidebar-all-products')) {
         dynamic_sidebar('sidebar-all-products');
     }
     // Product Sidebar - single products
     if (is_single() && $post_type == 'products' && $this->is_enabled_sidebar('sidebar-for-products')) {
         dynamic_sidebar('sidebar-for-product');
     }
     // Product Sidebar Listings
     if ($post_id == RT_PRODUCTPAGE || get_query_var('taxonomy') == "product_categories" && $this->is_enabled_sidebar('sidebar-for-product-categories')) {
         dynamic_sidebar('sidebar-for-product-categories');
     }
     // Blog All
     if (rt_is_blog_page() && !isset($WooCommercePage) && $this->is_enabled_sidebar('sidebar-for-blog')) {
         dynamic_sidebar('sidebar-for-blog');
     }
     // Blog Single
     if (is_single() && $post->post_type == 'post' && $this->is_enabled_sidebar('sidebar-for-single')) {
         dynamic_sidebar('sidebar-for-single');
     }
     // Blog Categories
     if (is_category() && !isset($WooCommercePage) && $this->is_enabled_sidebar('sidebar-for-blog-categories')) {
         dynamic_sidebar('sidebar-for-blog-categories');
     }
     // Archives
     if (is_archive() && get_query_var('taxonomy') == "" && !isset($WooCommercePage) && !is_category() && $this->is_enabled_sidebar('sidebar-for-archive')) {
         dynamic_sidebar('sidebar-for-archive');
     }
     // Tags archives
     if (is_tag() && !isset($WooCommercePage) && $this->is_enabled_sidebar('sidebar-for-tags')) {
         dynamic_sidebar('sidebar-for-tags');
     }
     // Common Sidebar - For all site
     if ($this->is_enabled_sidebar('common-sidebar')) {
         dynamic_sidebar('common-sidebar');
     }
 }