Ejemplo n.º 1
0
 /**
  * Shortcode callback function.
  *
  * @return string
  */
 protected function do_shortcode()
 {
     $default_template = key(G1_Collection_Manager()->get_collection_choices(array('post_type' => $this->get_post_type())));
     extract($this->extract());
     if (!strlen($template)) {
         $template = $default_template;
     }
     $lightbox_group = 'g1-custom-posts-lightbox';
     $out = '';
     $final_id = 'g1-custom-posts-shortcode-' . $this->get_counter();
     $final_class = array('g1-custom-posts-shortcode', 'g1-shortcode');
     $final_class = array_merge($final_class, explode(' ', $class));
     $query = $this->get_query();
     if ($query->have_posts()) {
         // Build config array based on the name of a collection
         $collection = G1_Collection_Manager()->get_collection($template);
         // Add effect
         $collection->add_class('g1-effect-' . sanitize_html_class($effect));
         // Apply custom filters
         $collection = apply_filters('g1_collection_shortcode', $collection, $final_id);
         // Our tricky way to pass variables to a template part
         g1_part_set_data(array('query' => $query, 'collection' => $collection, 'elems' => $this->get_elements()));
         if ($collection) {
             // Capture the template part of our collection
             ob_start();
             get_template_part($collection->get_file());
             $out1 = ob_get_clean();
         } else {
             $out1 = '';
         }
         // Compose the final template
         $out = '<div id="' . esc_attr($final_id) . '" class="' . sanitize_html_classes($final_class) . '">' . $out1 . '</div>';
     }
     return $out;
 }
Ejemplo n.º 2
0
 *
 * @package G1_Framework
 * @subpackage G1_Theme03
 * @since G1_Theme03 1.0.0
 */
// Prevent direct script access
if (!defined('ABSPATH')) {
    die('No direct script access allowed');
}
// Our tricky way to get variables that were passed to this template part
$g1_data = g1_part_get_data();
$g1_collection = $g1_data['collection'];
$g1_elems = G1_Elements()->get();
$g1_options = array('summary-type' => !empty($g1_data['summary-type']) ? $g1_data['summary-type'] : 'excerpt');
// Build config array based on the name of a collection
$g1_collection = G1_Collection_Manager()->get_collection($g1_collection);
$title = '';
$subtitle = '';
if (is_home()) {
    $title = __('Blog', 'g1_theme');
    $page_id = (int) get_option('page_for_posts');
    if ($page_id) {
        // WPML fallback
        if (function_exists('icl_object_id')) {
            $page_id = icl_object_id($page_id, 'page', true);
        }
        if ($page_id) {
            $title = get_the_title($page_id);
            $subtitle = wp_kses_data(get_post_meta($page_id, '_g1_subtitle', true));
        }
    }
Ejemplo n.º 3
0
                $choices[$id] = $collection->get_id();
            }
        }
        return $choices;
    }
}
function G1_Collection_Manager()
{
    static $instance = null;
    if (null === $instance) {
        $instance = new G1_Collection_Manager();
    }
    return $instance;
}
// Fire in the hole :)
G1_Collection_Manager();
class G1_Template_Manager
{
    protected $id;
    protected $templates;
    protected $template_base_class;
    public function __construct($id)
    {
        $this->set_id($id);
        $this->templates = array();
        $this->set_template_base_class('G1_Template');
        $this->setup_hooks();
    }
    protected function setup_hooks()
    {
        // Register templates before the WP Customizer is ready