/**
  * Init theme config for shop.
  *
  */
 function dt_woocommerce_init_template_config($name = '')
 {
     dt_woocommerce_add_config_actions();
     if ('shop' != $name) {
         return;
     }
     $config = presscore_get_config();
     $post_id = null;
     if (is_shop()) {
         $post_id = woocommerce_get_page_id('shop');
     } else {
         if (is_cart()) {
             $post_id = woocommerce_get_page_id('cart');
         } else {
             if (is_checkout()) {
                 $post_id = woocommerce_get_page_id('checkout');
             }
         }
     }
     presscore_config_base_init($post_id);
     if (is_product_category() || is_product_tag()) {
         $post_id = woocommerce_get_page_id('shop');
         if ($post_id) {
             $config->set('post_id', $post_id);
             presscore_config_populate_sidebar_and_footer_options();
             $config->set('post_id', null);
         }
     }
     if (!is_product()) {
         add_filter('presscore_get_page_title', 'dt_woocommerce_get_page_title', 20);
     }
     // replace theme breadcrumbs
     add_filter('presscore_get_breadcrumbs-html', 'dt_woocommerce_replace_theme_breadcrumbs', 20, 2);
 }
 function presscore_config_base_init($new_post_id = null)
 {
     static $init_done = false;
     if ($init_done) {
         return;
     }
     $config = Presscore_Config::get_instance();
     $post_id = $config->get('post_id');
     if (!$post_id) {
         $new_post_id = apply_filters('presscore_config_post_id_filter', $new_post_id);
         if ($new_post_id) {
             $post_id = $new_post_id;
             $config->set('post_id', $post_id);
         }
     }
     do_action('presscore_config_before_base_init');
     if (!$post_id) {
         presscore_config_populate_archive_vars();
         $init_done = true;
         return;
     }
     //////////////////////
     // common settings //
     //////////////////////
     presscore_config_get_theme_option();
     presscore_config_populate_header_options();
     presscore_config_populate_sidebar_and_footer_options();
     presscore_config_logo_options();
     /////////////////////////////
     // config for post types //
     /////////////////////////////
     $cur_post_type = get_post_type($post_id);
     $template = $config->get('template');
     switch ($cur_post_type) {
         case 'page':
             $config->set('page_id', $post_id);
             if ('blog' == $template) {
                 presscore_congif_populate_blog_vars();
             }
             break;
         case 'post':
             presscore_congif_populate_single_post_vars();
             break;
         case 'attachment':
             presscore_congif_populate_single_attachment_vars();
             break;
     }
     do_action("presscore_config_base_init_{$cur_post_type}", $template);
     do_action('presscore_config_base_init', $cur_post_type, $template);
     $init_done = true;
 }
 /**
  * This function configure sidebar and footer as for the 'shop' woocommerce page.
  *
  * @param string $name
  */
 function dt_woocommerce_configure_archive_templates($name = '')
 {
     if ('shop' !== $name) {
         return;
     }
     if (is_product_category() || is_product_tag()) {
         $post_id = woocommerce_get_page_id('shop');
         if ($post_id) {
             presscore_get_config()->set('post_id', $post_id);
             presscore_config_populate_sidebar_and_footer_options();
             presscore_get_config()->set('post_id', null);
         }
     }
 }
Ejemplo n.º 4
0
 function presscore_config_base_init($new_post_id = null)
 {
     ///////////////////////////
     // config for archives //
     ///////////////////////////
     if (null == $new_post_id && (is_archive() || is_search() || is_home() || is_404())) {
         presscore_config_populate_archive_vars();
         return;
     }
     ///////////////////
     // set post id //
     ///////////////////
     $config = Presscore_Config::get_instance();
     $post_id = $config->get('post_id');
     if (null == $post_id) {
         global $post;
         if ($new_post_id) {
             $post_id = $new_post_id;
         } else {
             if (!empty($post)) {
                 $post_id = $post->ID;
             }
         }
         $config->set('post_id', $post_id);
     }
     if (empty($post_id)) {
         return;
     }
     //////////////////////
     // common settings //
     //////////////////////
     presscore_config_populate_header_options();
     presscore_config_populate_sidebar_and_footer_options();
     presscore_config_populate_footer_theme_options();
     presscore_config_logo_options();
     presscore_config_populate_buttons_options();
     presscore_config_get_theme_option();
     /////////////////////////////
     // config for post types //
     /////////////////////////////
     $cur_post_type = get_post_type($post_id);
     switch ($cur_post_type) {
         case 'page':
             $config->set('page_id', $post_id);
             switch ($config->get('template')) {
                 case 'portfolio':
                     presscore_congif_populate_portfolio_vars();
                     break;
                 case 'albums':
                     presscore_congif_populate_albums_vars();
                     break;
                 case 'media':
                     presscore_congif_populate_media_vars();
                     break;
                 case 'blog':
                     presscore_congif_populate_blog_vars();
                     break;
                 case 'team':
                     presscore_congif_populate_team_vars();
                     break;
                 case 'testimonials':
                     presscore_congif_populate_testimonials_vars();
                     break;
             }
             break;
         case 'post':
             presscore_congif_populate_single_post_vars();
             break;
         case 'dt_portfolio':
             presscore_congif_populate_single_portfolio_vars();
             break;
         case 'dt_gallery':
             presscore_congif_populate_single_album_vars();
             break;
         case 'attachment':
             presscore_congif_populate_single_attachment_vars();
             break;
     }
     do_action('presscore_config_base_init');
 }