Example #1
0
 public function add_theme_options($sections)
 {
     // single templates
     $templates = G1_Single_Template_Manager()->get_templates_choices(array('post_type' => 'post'));
     unset($templates['overview_left']);
     unset($templates['overview_right']);
     $single_options = array();
     foreach ($templates as $template_id => $template_path) {
         $single_options[$template_id] = array('title' => $template_id, 'img' => $template_path);
     }
     $single_std = '';
     if (!empty($single_options)) {
         $single_std = array_keys($single_options);
         $single_std = $single_std[0];
     }
     // archive templates
     $archive_templates = G1_Archive_Template_Manager()->get_templates_choices(array('post_type' => 'post'));
     $archive_options = array();
     foreach ($archive_templates as $template_id => $template_path) {
         // exclude filterable layouts
         if (strpos($template_id, 'filterable') !== false) {
             continue;
         }
         $archive_options[$template_id] = array('title' => $template_id, 'img' => $template_path);
     }
     $archive_std = '';
     if (!empty($archive_options)) {
         $archive_std = array_keys($archive_options);
         $archive_std = $archive_std[0];
     }
     $fields = array();
     $priority = 1;
     foreach ($this->get_post_types() as $post_type) {
         $post_type_label = str_replace('sfwd-', '', $post_type);
         $post_type_label = ucfirst($post_type_label);
         $fields[] = array('id' => 'post_type_' . $post_type . '_info', 'priority' => $priority, 'type' => 'info', 'desc' => '<h4>' . $post_type_label . '</h4>');
         $fields[] = array('id' => 'post_type_' . $post_type . '_single_template', 'priority' => $priority + 1, 'type' => 'radio_img', 'title' => __('Single template', Redux_TEXT_DOMAIN), 'options' => $single_options, 'std' => $single_std);
         $fields[] = array('id' => 'post_type_' . $post_type . '_archive_template', 'priority' => $priority + 2, 'type' => 'radio_img', 'title' => __('Archive template', Redux_TEXT_DOMAIN), 'options' => $archive_options, 'std' => $archive_std);
         $priority += 10;
     }
     $sections['learndash'] = array('priority' => 1100, 'icon' => 'folder-open', 'icon_class' => 'icon-large', 'title' => __('LearnDash', Redux_TEXT_DOMAIN), 'fields' => $fields);
     return $sections;
 }
Example #2
0
    {
        $object = get_queried_object();
        $templates = array();
        // global value
        $global_value = $this->get_global_value($object->post_type);
        if ($this->get_template_manager()->has_template($global_value)) {
            $template_obj = $this->get_template_manager()->get_template($global_value);
            $info = pathinfo($template_obj->get_file());
            $info = $info['dirname'] . '/' . $info['filename'];
            array_unshift($templates, "{$info}-{$object->post_type}.php", "{$info}.php");
        }
        // individual value
        $individual_value = $this->get_individual_value($object->ID);
        if ($this->get_template_manager()->has_template($individual_value)) {
            $template_obj = $this->get_template_manager()->get_template($individual_value);
            $info = pathinfo($template_obj->get_file());
            $info = $info['dirname'] . '/' . $info['filename'];
            array_unshift($templates, "{$info}-{$object->post_type}.php", "{$info}.php");
        }
        $templates = array_unique($templates);
        if (count($templates)) {
            $new_template = locate_template($templates);
            if (!empty($new_template)) {
                return $new_template;
            }
        }
        return $template;
    }
}
new G1_Single_Template_Feature(array('template_manager' => G1_Single_Template_Manager()));