function pt_show_layout() { global $wp_query; /* Set the layout to default. */ $layout = 'one-col'; /* If viewing a front page, check if a layout has been specified. */ if (is_front_page() || is_page_template('front-page.php')) { $global_front_layout = get_option('front_layout') != '' ? get_option('front_layout') : 'one-col'; $post_id = $wp_query->get_queried_object_id(); $post_layout = pt_get_post_layout($post_id); if (isset($global_front_layout) && $global_front_layout == $post_layout) { $layout = $global_front_layout; } elseif (isset($global_front_layout) && $post_layout === 'default') { $layout = $global_front_layout; } else { $layout = $post_layout; } } else { /* If viewing a page, check if a layout has been specified. */ if (is_page()) { $global_page_layout = get_option('page_layout') != '' ? get_option('page_layout') : 'one-col'; $post_id = $wp_query->get_queried_object_id(); $post_layout = pt_get_post_layout($post_id); if (isset($global_page_layout) && $global_page_layout == $post_layout) { $layout = $global_page_layout; } elseif (isset($global_page_layout) && $post_layout === 'default') { $layout = $global_page_layout; } else { $layout = $post_layout; } } else { /* If viewing a blog page, check if a layout has been specified. */ if (is_home()) { $global_blog_layout = get_option('blog_layout') != '' ? get_option('blog_layout') : 'one-col'; $layout = $global_blog_layout; } else { /* If viewing a singular post, check if a layout has been specified. */ if (is_single()) { $global_single_layout = get_option('single_layout') != '' ? get_option('single_layout') : 'one-col'; $layout = $global_single_layout; } else { /* If viewing a taxonomy, check if a layout has been specified */ if (is_category() || is_tag() || is_tax() || is_archive() || is_search()) { $global_archive_layout = get_option('archive_layout') != '' ? get_option('archive_layout') : 'one-col'; $layout = $global_archive_layout; } } } } } if (class_exists('Woocommerce')) { /* If viewing a products page, check if a layout has been specified */ if (is_shop()) { $global_shop_layout = get_option('shop_layout') != '' ? get_option('shop_layout') : 'one-col'; $post_id = $wp_query->get_queried_object_id(); $post_layout = pt_get_post_layout($post_id); if (isset($global_shop_layout) && $global_shop_layout == $post_layout) { $layout = $global_shop_layout; } elseif (isset($global_shop_layout) && $post_layout === 'default') { $layout = $global_shop_layout; } else { $layout = $post_layout; } if (isset($_GET['layout'])) { $layout = $_GET['layout']; } } else { /* If viewing a single product page, check if a layout has been specified */ if (is_product()) { $global_product_layout = get_option('product_layout') != '' ? get_option('product_layout') : 'one-col'; $layout = $global_product_layout; } } } /* Return the layout and allow plugin/theme developers to override it. */ return esc_attr(apply_filters('get_theme_layout', "layout-{$layout}")); }
<?php /** * The sidebar containing the main widget area. * * If no active widgets in sidebar, let's hide it completely. * * @package WordPress * @subpackage Plum_Tree * @since Plum Tree 0.1 */ ?> <?php $current_layout = pt_get_post_layout($post->ID); if ($current_layout === 'default') { if (is_home()) { $current_layout = get_option('blog_layout'); } if (is_single()) { $current_layout = get_option('single_layout'); } if (is_page()) { $current_layout = get_option('page_layout'); } if (is_front_page() || is_page_template('front-page.php')) { $current_layout = get_option('front_layout'); } if (is_category() || is_tag() || is_tax() || is_archive() || is_search()) { $current_layout = get_option('archive_layout'); }