Example #1
0
 function fields()
 {
     global $wp_registered_sidebars, $post;
     if ('product' == $post->post_type) {
         $global_sidebar_location = et_get_option('woocommerce_sidebar_location', extra_global_sidebar_location());
     } else {
         $global_sidebar_location = extra_global_sidebar_location();
     }
     $this->fields = array('_extra_sidebar_location' => array('title' => __('Sidebar location', 'extra'), 'type' => 'select', 'options' => array('' => sprintf(__('Default (%s)', 'extra'), ucwords($global_sidebar_location)), 'right' => __('Right', 'extra'), 'left' => __('Left', 'extra'), 'none' => __('No Sidebar', 'extra')), 'attributes' => array('data-location' => extra_global_sidebar_location())));
     $this->fields['_extra_sidebar'] = array('title' => __('Choose Sidebar/Widget Area', 'extra'), 'type' => 'select', 'options' => array());
     if ('product' == $post->post_type) {
         $global_sidebar = et_get_option('woocommerce_sidebar', extra_global_sidebar());
     } else {
         $global_sidebar = extra_global_sidebar();
     }
     if (!empty($wp_registered_sidebars[$global_sidebar])) {
         $sidebar = $wp_registered_sidebars[$global_sidebar];
         $this->fields['_extra_sidebar']['options'][''] = sprintf(__('Default (%s)', 'extra'), $sidebar['name']);
     } else {
         $this->fields['_extra_sidebar']['options'][''] = __('Default', 'extra');
     }
     if ($wp_registered_sidebars && is_array($wp_registered_sidebars)) {
         foreach ($wp_registered_sidebars as $id => $options) {
             $this->fields['_extra_sidebar']['options'][$id] = $options['name'];
         }
     }
     if ('post' == $post->post_type) {
         $this->fields['_extra_featured_post'] = array('title' => __('Featured Post', 'extra'));
     }
     if (extra_check_feature_availability_in_post_type($post->post_type, 'hide_title_meta_in_single')) {
         $this->fields['_post_extra_title_meta_hide_single'] = array('title' => __('Hide Title & Meta on Post', 'extra'), 'value_sanitize_function' => 'wp_validate_boolean', 'type' => 'checkbox');
     }
     if (extra_check_feature_availability_in_post_type($post->post_type, 'hide_featured_image_in_single')) {
         $this->fields['_post_extra_featured_image_hide_single'] = array('title' => __('Hide Featured Image on Post', 'extra'), 'value_sanitize_function' => 'wp_validate_boolean', 'type' => 'checkbox');
     }
     if (et_get_post_meta_setting('all', 'rating_stars') && in_array($post->post_type, extra_get_rating_post_types())) {
         $this->fields['_post_extra_rating_hide'] = array('title' => __('Hide Post Rating', 'extra'), 'value_sanitize_function' => 'wp_validate_boolean', 'type' => 'checkbox');
     }
 }
Example #2
0
function extra_sidebar()
{
    $is_woocommerce_sidebar = 'product' === get_query_var('post_type') || is_tax('product_cat') || is_tax('product_tag');
    if ($is_woocommerce_sidebar) {
        $post_id = empty($post_id) ? get_the_ID() : $post_id;
        $sidebar = get_post_meta($post_id, '_extra_sidebar', true);
        $sidebar_location = get_post_meta($post_id, '_extra_sidebar_location', true);
    } else {
        if (is_singular()) {
            $post_id = empty($post_id) ? get_the_ID() : $post_id;
            $sidebar = get_post_meta($post_id, '_extra_sidebar', true);
            $sidebar_location = get_post_meta($post_id, '_extra_sidebar_location', true);
        } else {
            if (is_archive()) {
                if ($layout_id = extra_get_tax_layout_id()) {
                    $sidebar = get_post_meta($layout_id, '_extra_sidebar', true);
                    $sidebar_location = get_post_meta($layout_id, '_extra_sidebar_location', true);
                }
            } else {
                if (is_home() && et_extra_show_home_layout()) {
                    if ($layout_id = extra_get_home_layout_id()) {
                        $sidebar = get_post_meta($layout_id, '_extra_sidebar', true);
                        $sidebar_location = get_post_meta($layout_id, '_extra_sidebar_location', true);
                    }
                }
            }
        }
    }
    if (empty($sidebar_location)) {
        if ($is_woocommerce_sidebar) {
            $sidebar_location = et_get_option('woocommerce_sidebar_location', extra_global_sidebar_location());
        } else {
            $sidebar_location = extra_global_sidebar_location();
        }
    }
    if ('none' === $sidebar_location) {
        return;
    }
    if (empty($sidebar)) {
        if ($is_woocommerce_sidebar) {
            $sidebar = et_get_option('woocommerce_sidebar', extra_global_sidebar());
        } else {
            $sidebar = extra_global_sidebar();
        }
    }
    return $sidebar;
}