Esempio n. 1
0
 /**
  * Hooks the WP filter single_template to deal with the shadow post
  * types for pages and singular templates, ensuring they use the
  * right template.
  *
  * @param string $template Path to a template file
  * @return Path to a template file
  **/
 public function single_template($template)
 {
     if (bbl_is_default_lang()) {
         return $template;
     }
     // Deal with the language front pages and custom page templates
     $post = get_post(get_the_ID());
     if ('page' == get_option('show_on_front')) {
         $front_page_transid = $this->get_transid(get_option('page_on_front'));
         $this_transid = $this->get_transid(get_the_ID());
         // Check if this is a translation of the page on the front of the site
         if ($front_page_transid == $this_transid) {
             // global $wp_query, $wp;
             if ('page' == $this->get_base_post_type($post->post_type)) {
                 if ($custom_page_template = get_post_meta(get_option('page_on_front'), '_wp_page_template', true)) {
                     $templates = (array) $custom_page_template;
                 } else {
                     $templates = (array) 'page.php';
                 }
                 if ($_template = locate_template($templates)) {
                     return $_template;
                 }
             }
         }
     }
     // Check if we're dealing with a page or a translation of a page
     if ('page' == $this->get_base_post_type($post->post_type)) {
         $custom_page_template = get_post_meta(get_the_ID(), '_wp_page_template', true);
         if ($custom_page_template && 'default' != $custom_page_template) {
             $templates = (array) $custom_page_template;
         } else {
             $templates = array('page.php');
         }
         if ($_template = locate_template($templates)) {
             return $_template;
         }
     }
     $templates[] = "single-{$this->get_base_post_type($post->post_type)}.php";
     $templates[] = "single.php";
     $template = get_query_template('bbl-single', $templates);
     return $template;
 }
Esempio n. 2
0
 /**
  * Hooks the WP filter taxonomy_template to deal with the shadow terms,
  * ensuring they use the right template.
  *
  * @param string $template Path to a template file 
  * @return Path to a template file
  **/
 public function taxonomy_template($template)
 {
     if (bbl_is_default_lang()) {
         return $template;
     }
     $term = get_queried_object();
     $base_taxonomy = $this->get_base_taxonomy($term->taxonomy);
     if ('category' == $base_taxonomy) {
         if (!empty($term->slug)) {
             $templates[] = "category-{$term->slug}.php";
             $templates[] = "category-{$term->term_id}.php";
         }
         $templates[] = 'category.php';
     } else {
         if ('post_tag' == $base_taxonomy) {
             if (!empty($term->slug)) {
                 $templates[] = "tag-{$term->slug}.php";
                 $templates[] = "tag-{$term->term_id}.php";
             }
             $templates[] = 'tag.php';
         } else {
             if (!empty($term->slug)) {
                 $taxonomy = $term->taxonomy;
                 $templates[] = "taxonomy-{$taxonomy}-{$term->slug}.php";
                 $templates[] = "taxonomy-{$taxonomy}.php";
             }
             $templates[] = 'taxonomy.php';
         }
     }
     $template = get_query_template('bbl-taxonomy', $templates);
     return $template;
 }