コード例 #1
0
ファイル: class-maera-timber.php プロジェクト: wpmu/maera
 /**
  * Custom implementation for get_context method.
  */
 public function get_context()
 {
     global $content_width;
     if (class_exists('Easy_Digital_Downloads')) {
         global $edd_options;
     }
     $context = Timber::get_context();
     $sidebar_primary = Timber::get_widgets('sidebar_primary');
     $sidebar_footer = Timber::get_widgets('sidebar_footer');
     $context['theme_mods'] = get_theme_mods();
     $context['site_options'] = wp_load_alloptions();
     $context['teaser_mode'] = apply_filters('maera/teaser/mode', 'excerpt');
     $context['thumbnail']['width'] = apply_filters('maera/image/width', 600);
     $context['thumbnail']['height'] = apply_filters('maera/image/height', 371);
     $context['menu']['primary'] = has_nav_menu('primary_navigation') ? new TimberMenu('primary_navigation') : null;
     $context['sidebar']['primary'] = apply_filters('maera/sidebar/primary', $sidebar_primary);
     $context['sidebar']['footer'] = apply_filters('maera/sidebar/footer', $sidebar_footer);
     $context['pagination'] = Timber::get_pagination();
     $context['comment_form'] = TimberHelper::get_comment_form();
     $context['comments_args'] = array('style' => 'ul', 'reply_text' => __('Reply', 'maera'), 'short_ping' => true, 'avatar_size' => 60);
     $context['site_logo'] = get_option('site_logo', false);
     $context['content_width'] = $content_width;
     $context['sidebar_template'] = maera_templates_sidebar();
     if (class_exists('Easy_Digital_Downloads')) {
         $data['edd_options'] = $edd_options;
         $data['download_categories'] = Timber::get_terms('download_category');
         $data['download_tags'] = Timber::get_terms('download_tag');
         $data['default_image'] = new TimberImage(get_template_directory_uri() . '/assets/images/default.png');
     }
     return apply_filters('maera/timber/context', $context);
 }
コード例 #2
0
ファイル: widgets.php プロジェクト: AliBritt/pressgang
 /**
  * add_to_context
  *
  * Add available widgets to the Timber context
  *
  * @param $context
  *
  * @return array
  */
 public static function add_to_context($context)
 {
     foreach (static::$widgets as $key => &$widget) {
         $context["widget_{$key}"] = \Timber::get_widgets($widget['id']);
     }
     return $context;
 }
コード例 #3
0
ファイル: sidebars.php プロジェクト: benedict-w/pressgang
 /**
  * add_to_context
  *
  * Add available sidebars to the Timber context
  *
  * @param $context
  *
  * @return array
  */
 public function add_to_context($context)
 {
     foreach ($this->sidebars as $key => &$sidebar) {
         $context["widget_{$key}"] = \Timber::get_widgets($sidebar['id']);
     }
     return $context;
 }
コード例 #4
0
 function add_to_context($context)
 {
     $context['site'] = $this;
     $context['nav_bar'] = new TimberMenu('main-nav-bar');
     $context['nav_widgets'] = Timber::get_widgets('site_nav_widgets');
     $context['sidebar'] = Timber::get_widgets('site_sidebar');
     return $context;
 }
コード例 #5
0
ファイル: timber.php プロジェクト: Dedato/vosdegoeij
 function add_to_context($context)
 {
     $context['main_menu'] = new TimberMenu('primary_navigation');
     $context['site'] = $this;
     $context['display_sidebar'] = Setup\display_sidebar();
     $context['sidebar_primary'] = Timber::get_widgets('sidebar-primary');
     $context['options'] = get_fields('option');
     return $context;
 }
コード例 #6
0
 function testHTML()
 {
     // replace this with some actual testing code
     $widgets = wp_get_sidebars_widgets();
     $data = array();
     $content = Timber::get_widgets('sidebar-1');
     $content = trim($content);
     $this->assertEquals('<', substr($content, 0, 1));
 }
コード例 #7
0
 function add_to_context($context)
 {
     $context['device'] = device_class();
     $context['theme_url'] = get_stylesheet_directory_uri();
     $context['notes'] = 'These values are available everytime you call Timber::get_context();';
     $context['menu'] = new TimberMenu('primary');
     $context['dynamic_sidebar'] = Timber::get_widgets('sidebar-1');
     $context['site'] = $this;
     return $context;
 }
コード例 #8
0
 function add_to_context($context)
 {
     /* Add extra data */
     $context['foo'] = 'I am some other typical value set in your functions.php file, unrelated to the menu';
     /* Menu */
     $context['menu'] = new TimberMenu('primary_navigation');
     /* Site info */
     $context['site'] = $this;
     /* Site info */
     $context['display_sidebar'] = Setup\display_sidebar();
     $context['sidebar_primary'] = Timber::get_widgets('sidebar-primary');
     return $context;
 }
コード例 #9
0
 /**
  * Timber extras.
  */
 function timber_extras($data)
 {
     // get secondary sidebar
     $sidebar_secondary = Timber::get_widgets('sidebar_secondary');
     $data['sidebar']['secondary'] = apply_filters('maera/sidebar/secondary', $sidebar_secondary);
     $extra_widget_areas = Maera_BS_Widgets::extra_widget_areas_array();
     foreach ($extra_widget_areas as $extra_widget_area => $options) {
         if (0 != get_theme_mod($extra_widget_area . '_toggle', 0)) {
             $data['sidebar'][$extra_widget_area] = Timber::get_widgets($extra_widget_area);
         }
     }
     $comment_form_args = array('comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x('Comment', 'noun', 'maera_bs') . '</label><textarea class="form-control" id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>', 'id_submit' => 'comment-submit');
     $data['content_width'] = Maera_BS_Structure::content_width_px();
     $data['post_meta'] = Maera_BS_Meta::meta_elements();
     $data['comment_form'] = TimberHelper::get_comment_form(null, $comment_form_args);
     return $data;
 }
コード例 #10
0
 function add_to_context($context)
 {
     remove_filter('acf_the_content', 'wpautop');
     $context['site_info'] = get_field('site_info', 'options');
     $context['company_logo'] = get_field('company_logo', 'options');
     //site vars
     $context['site'] = $this;
     //Template settings
     $context['acSettings'] = acSettings();
     //Primary Menu
     $context['menuPrimary'] = new TimberMenu('primary');
     $context['menuHero'] = new TimberMenu('hero');
     foreach (unserialize(SIDEBARS) as $sidebar) {
         $context[strtolower($sidebar) . '_widgets'] = Timber::get_widgets($sidebar);
     }
     //        $context['primary_widgets'] = Timber::get_widgets('Primary');
     //        $context['subsidiary_widgets'] = Timber::get_widgets('Subsidiary');
     return $context;
 }
コード例 #11
0
 /**
  * Modify the Timber global context
  * @param  [type] $context [description]
  * @return [type]          [description]
  */
 function maera_res_context($context)
 {
     $context['currency'] = get_theme_mod('currency', '&#36;');
     $context['facebook_link'] = get_theme_mod('facebook_link', 'http://facebook.com/');
     $context['twitter_link'] = get_theme_mod('twitter_link', 'http://twitter.com/');
     $context['googleplus_link'] = get_theme_mod('googleplus_link', 'http://plus.google.com/');
     $context['youtube_link'] = get_theme_mod('youtube_link', 'http://youtube.com');
     $context['menu_sections'] = Timber::get_terms('restaurant_item_menu_section');
     $context['sidebar']['section_1'] = Timber::get_widgets('section_1');
     $context['sidebar']['section_2'] = Timber::get_widgets('section_2');
     $context['sidebar']['section_3'] = Timber::get_widgets('section_3');
     $context['sidebar']['section_4'] = Timber::get_widgets('section_4');
     $context['sidebar']['section_5'] = Timber::get_widgets('section_5');
     $context['sidebar']['footer'] = Timber::get_widgets('footer');
     if (is_post_type_archive('restaurant_item') && rp_is_restaurant()) {
         $query_args = array('post_type' => 'restaurant_item', 'posts_per_page' => 999, 'order' => get_theme_mod('restaurant_order', 'ASC'), 'order_by' => get_theme_mod('restaurant_order_by', 'ID'));
         $context['menu_item'] = Timber::query_post();
         $context['menu_items'] = Timber::get_posts($query_args);
     }
     return $context;
 }
コード例 #12
0
 public function get_sidebar_widgets($sidebar_slug)
 {
     return \Timber::get_widgets($sidebar_slug);
 }
コード例 #13
0
<?php

/**
 * The Template for displaying all single posts
 *
 *
 * @package  WordPress
 * @subpackage  Timber
 */
$context['home_left'] = Timber::get_widgets('home_left');
コード例 #14
0
<?php

/**
 * The Template for displaying rightwidgets on every page needed. 
 *
 *
 * @package  WordPress
 * @subpackage  Timber
 */
// Getting the widgets from what we registered in widgets.php
// 'rightside-widget' needs to match the widget 'id'
$data['rightside_widgets'] = Timber::get_widgets('rightside-widget');
// Send that data to the rightside-widgets.twig and to display that, you have to include rightside-widgets.twig in the page you want it to display in.
Timber::render(array('rightside-widgets.twig'), $data);
/*
1. registering widgets/sidebar in lib/widgets.php (Model)
2. hook that registration into WP when it runs (functions.php) (Model)
3. get the widget data inside of sidebar.php (Controller)
4. render the markup which can happen in two ways: (View)
Option 1: render that data to a specific file (View stage)
	Inside sidebar.php you have the render() to sidebar.twig (or whatever)
Option 2: make the data globally available (View stage)
	Inside functions.php create a context variable calling get_sidebar('sidebar.php')
*/
コード例 #15
0
<?php

/**
 * The template for displaying Author Archive pages
 *
 * Methods for TimberHelper can be found in the /functions sub-directory
 *
 * @package  WordPress
 * @subpackage  Underwood
 * @since    Underwood 0.0.1
 */
global $wp_query;
$data = Timber::get_context();
$data['posts'] = Timber::get_posts();
$data['pagination'] = Timber::get_pagination();
/* Dynamic Sidebar */
$data['sidebar'] = Timber::get_widgets('Sidebar');
if (isset($wp_query->query_vars['author'])) {
    $author = new TimberUser($wp_query->query_vars['author']);
    $data['author'] = $author;
    $data['title'] = 'Author Archives: ' . $author->name();
}
Timber::render(array('author.twig', 'archive.twig'), $data);
コード例 #16
0
<?php

/**
 * The Template for displaying rightwidgets on every page needed. 
 *
 *
 * @package  WordPress
 * @subpackage  Timber
 */
// Getting the widgets from what we registered in widgets.php
// 'rightside-widget' needs to match the widget 'id'
$data['footerml_widgets'] = Timber::get_widgets('footer-widgetmidleft');
// Send that data to the rightside-widgets.twig and to display that, you have to include rightside-widgets.twig in the page you want it to display in.
Timber::render(array('sidebar-footerml.twig'), $data);
/*
1. registering widgets/sidebar in lib/widgets.php (Model)
2. hook that registration into WP when it runs (functions.php) (Model)
3. get the widget data inside of sidebar.php (Controller)
4. render the markup which can happen in two ways: (View)
Option 1: render that data to a specific file (View stage)
	Inside sidebar.php you have the render() to sidebar.twig (or whatever)
Option 2: make the data globally available (View stage)
	Inside functions.php create a context variable calling get_sidebar('sidebar.php')
*/
コード例 #17
0
                $response['lletra'] = $lletra;
                $response['result'] = $api_response;
                $title = 'Diccionari multilingüe: paraules que comencen per ' . $lletra;
                $content_title = 'Diccionari multilingüe. Lletra «' . $lletra . '»';
                $canonical = '/diccionari-multilingue/lletra/' . $lletra . '/';
                $context_holder['cerca_result'] = Timber::fetch('ajax/multilingue-lletra.twig', array('response' => $response));
            } else {
                throw_error('500', 'Error connecting to API server');
                $context_holder['cerca_result'] = 'S\'ha produït un error en contactar amb el servidor. Proveu de nou.';
            }
        } else {
            throw_error('404', 'No Results For This Search');
            $context_holder['cerca_result'] = 'Esteu utilitzant la cerca per lletra. Heu cercat <strong>' . $context['lletra'] . '</strong>. La cerca només pot contenir una lletra';
        }
    }
}
$context_filterer = new SC_ContextFilterer($context_holder);
$context_overrides = array('title' => $title, 'description' => $description, 'canonical' => $canonical);
$context = $context_filterer->get_filtered_context($context_overrides, false);
$context['post'] = $post;
$context['paraula'] = $paraula;
$context['lletra'] = $lletra;
$context['content_title'] = $content_title;
$context['links'] = $post->get_field('link');
$context['credits'] = $post->get_field('credit');
$context['sidebar_top'] = Timber::get_widgets('sidebar_top_recursos');
$context['sidebar_elements'] = array('static/ajudeu.twig', 'static/dubte_forum.twig', 'baixades.twig', 'links.twig');
$context['sidebar_bottom'] = Timber::get_widgets('sidebar_bottom_recursos');
//Contact Form
$context['contact']['to_email'] = get_option('email_recursos');
Timber::render(array('diccionari-multilingue.twig'), $context);
コード例 #18
0
ファイル: full-width.php プロジェクト: ambercouch/ac_timber
<?php

/** Template Name: Full Width Page
 *
 * @package WordPress
 * @subpackage ac_timber
 */
$context = Timber::get_context();
$post = new TimberPost();
$context['post'] = $post;
$context['primary_widgets'] = Timber::get_widgets('Primary');
$context['footer_widgets'] = Timber::get_widgets('Footer');
$context['template_class'] = '--full-width';
//require_once get_template_directory() . '/lib/wp-timber/functions/timber--comment-form.php';
$templates = array('page-full-width.twig', 'page.twig');
Timber::render($templates, $context);
コード例 #19
0
<?php

/**
 * The main template file
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * E.g., it puts together the home page when no home.php file exists
 *
 * Methods for TimberHelper can be found in the /lib sub-directory
 *
 * @package  WordPress
 * @subpackage  Timber
 * @since   Timber 0.1
 */
if (!class_exists('Timber')) {
    echo 'Timber not activated. Make sure you activate the plugin in <a href="/wp-admin/plugins.php#timber">/wp-admin/plugins.php</a>';
    return;
}
$args = array('numberposts' => 3, 'post_type' => 'post');
$event_args = array();
$context = Timber::get_context();
$context['posts'] = get_posts($args);
// $context['events'] = do_shortcode( '[ESPRESSO_EVENTS show_expired=true]' );
$context['events'] = espresso_get_events($event_args);
$context['dynamic_sidebar'] = Timber::get_widgets('sidebar-1');
$templates = array('front-page.twig');
if (is_home()) {
    array_unshift($templates, 'home.twig');
}
Timber::render($templates, $context);
コード例 #20
0
 */

 if( class_exists('Dynamic_Featured_Image') ) {
      global $dynamic_featured_image;
      $featured_images = $dynamic_featured_image->get_featured_images( $post->ID );
  }

	$args = array(
		'category_name' => array('branding')
	);

$context = Timber::get_context();
$post = Timber::query_post();
$context['post'] = $post;
$context['comment_form'] = TimberHelper::get_comment_form();
$context['sidebar_2'] = Timber::get_widgets('sidebar-2');
$context['video'] = get_the_post_video( $post->ID );
$context['images'] = $featured_images;
$context['related'] = Timber::get_posts( array( 'category__in' => wp_get_post_categories($post->ID), 'numberposts' => 5, 'post__not_in' => array($post->ID) ) );

// $context['related'] = Timber::get_posts($args);

// $context['related'] = Timber::get_terms('category', array('parent' => 0));


if ( post_password_required( $post->ID ) ) {
	Timber::render( 'single-password.twig', $context );
} else {
	Timber::render( array( 'single-articles.twig' ), $context );
}
コード例 #21
0
<?php

/**
 * The Template for displaying rightwidgets on every page needed. 
 *
 *
 * @package  WordPress
 * @subpackage  Timber
 */
// Getting the widgets from what we registered in widgets.php
// 'rightside-widget' needs to match the widget 'id'
$data['footerfr_widgets'] = Timber::get_widgets('footer-widgetfarright');
// Send that data to the rightside-widgets.twig and to display that, you have to include rightside-widgets.twig in the page you want it to display in.
Timber::render(array('sidebar-footerfr.twig'), $data);
/*
1. registering widgets/sidebar in lib/widgets.php (Model)
2. hook that registration into WP when it runs (functions.php) (Model)
3. get the widget data inside of sidebar.php (Controller)
4. render the markup which can happen in two ways: (View)
Option 1: render that data to a specific file (View stage)
	Inside sidebar.php you have the render() to sidebar.twig (or whatever)
Option 2: make the data globally available (View stage)
	Inside functions.php create a context variable calling get_sidebar('sidebar.php')
*/
コード例 #22
0
<?php

/**
 * The Template for displaying rightwidgets on every page needed. 
 *
 *
 * @package  WordPress
 * @subpackage  Timber
 */
// Getting the widgets from what we registered in widgets.php
// 'rightside-widget' needs to match the widget 'id'
$data['footermr_widgets'] = Timber::get_widgets('footer-widgetmidright');
// Send that data to the rightside-widgets.twig and to display that, you have to include rightside-widgets.twig in the page you want it to display in.
Timber::render(array('sidebar-footermr.twig'), $data);
/*
1. registering widgets/sidebar in lib/widgets.php (Model)
2. hook that registration into WP when it runs (functions.php) (Model)
3. get the widget data inside of sidebar.php (Controller)
4. render the markup which can happen in two ways: (View)
Option 1: render that data to a specific file (View stage)
	Inside sidebar.php you have the render() to sidebar.twig (or whatever)
Option 2: make the data globally available (View stage)
	Inside functions.php create a context variable calling get_sidebar('sidebar.php')
*/
コード例 #23
0
ファイル: woocommerce.php プロジェクト: benedict-w/pressgang
<?php

/**
 * Enables Timber Integration with Woocommerce, see https://github.com/timber/timber/wiki/WooCommerce-Integration
 */
$context = Timber::get_context();
$context['sidebar'] = Timber::get_widgets('shop-sidebar');
if (is_singular('product')) {
    $context['post'] = Timber::get_post();
    $product = get_product($context['post']->ID);
    $context['product'] = $product;
    Timber::render('woocommerce/single-product.twig', $context);
} else {
    $posts = Timber::get_posts();
    $context['products'] = $posts;
    if (is_product_category()) {
        $queried_object = get_queried_object();
        $term_id = $queried_object->term_id;
        $context['category'] = get_term($term_id, 'product_cat');
        $context['title'] = single_term_title('', false);
    }
    Timber::render('woocommerce/archive.twig', $context);
}
コード例 #24
0
ファイル: index.php プロジェクト: sturple/fg-theme-master
    $template = 'archive';
}
if (!is_page()) {
    get_blog_sidebar($data);
}
// render using Twig template index.twig
if ($template !== false) {
    require_once __DIR__ . '/include/twig-filter-functions.php';
    // adding footer widgets
    $data['widget_footer_sidebar_left'] = Timber::get_widgets('widget_footer_sidebar_left');
    $data['widget_footer_sidebar_right'] = Timber::get_widgets('widget_footer_sidebar_right');
    // adding page widgets
    $data['widget_home_sidebar'] = Timber::get_widgets('widget_home_sidebar');
    $data['widget_page_sidebar'] = Timber::get_widgets('widget_page_sidebar');
    $data['widget_contact_sidebar'] = Timber::get_widgets('widget_page_sidebar');
    $data['widget_blog_sidebar'] = Timber::get_widgets('widget_blog_sidebar');
    $cache_type_array = array('CACHE_NONE' => TimberLoader::CACHE_NONE, 'CACHE_OBJECT' => TimberLoader::CACHE_OBJECT, 'CACHE_TRANSIENT' => TimberLoader::CACHE_TRANSIENT, 'CACHE_SITE_TRANSIENT' => TimberLoader::CACHE_SITE_TRANSIENT, 'CACHE_USE_DEFAULT' => TimberLoader::CACHE_USE_DEFAULT);
    // checking for custom post types
    $template_post_type = get_post_type();
    if ($template_post_type !== 'post' and $template_post_type !== 'page' and !is_search()) {
        $template = array($template . '-' . $template_post_type . '.twig', $template . '.twig');
    } else {
        $template = $template . '.twig';
    }
    Timber::render($template, $data, get_option('theme_twig_cache_expire', '0'), $cache_type_array[get_option('theme_twig_cache', 'CACHE_NONE')]);
    if (get_option('theme_twig_cache_performance', 'true') == 'true') {
        //echo '<script type="text/javascript">console.log("Cache Type:' . get_option('theme_twig_cache','CACHE_NONE') .'","Time:' . TimberHelper::stop_timer($start) . '");</script>';
    }
}
function get_blog_sidebar(&$data)
{
コード例 #25
0
 *
 * @package  wp-softcatala
 */
//JS and Styles related to the page
wp_enqueue_script('sc-js-esdeveniments', get_template_directory_uri() . '/static/js/esdeveniments.js', array('sc-js-main'), WP_SOFTCATALA_VERSION, true);
wp_enqueue_script('sc-js-novetats', get_template_directory_uri() . '/static/js/novetats.js', array('sc-js-main'), WP_SOFTCATALA_VERSION, true);
wp_localize_script('sc-js-novetats', 'scajax', array('ajax_url' => admin_url('admin-ajax.php')));
//Template initialization
$templates = array('archive-esdeveniment.twig');
$post = Timber::query_post(get_option('page_for_posts'));
$context_holder['post'] = $post;
$context_holder['content_title'] = 'Esdeveniments';
$context_holder['links'] = $post->get_field('link');
$context_holder['sidebar_top'] = Timber::get_widgets('sidebar_top');
$context_holder['sidebar_elements'] = array('baixades.twig', 'links.twig');
$context_holder['sidebar_bottom'] = Timber::get_widgets('sidebar_bottom');
//Filters population
$context_holder['cat_link'] = get_category_link(get_query_var('esdeveniment_cat'));
$context_holder['categories']['temes'] = Timber::get_terms('esdeveniment_cat');
$context_holder['filters'] = get_the_event_filters();
//Search and filters
$search = get_query_var('cerca');
$tema = get_query_var('tema');
$filter = get_query_var('data');
$filterdate = get_final_time($filter);
//Generate $args query
if (!empty($search) || !empty($tema) || !empty($filter)) {
    $search_args = get_post_query_args('esdeveniment', SearchQueryType::Search, $search);
    $args = wp_parse_args($search_args, $wp_query->query);
    //search + active args
    $date_filter_args = get_post_query_args('esdeveniment', SearchQueryType::FilteredDate, $filterdate);
コード例 #26
0
 /**
  * Modify Timber global context
  */
 function timber_global_context($data)
 {
     $data['menu']['offcanvas'] = has_nav_menu('offcanvas') ? new TimberMenu('offcanvas') : null;
     $data['sidebar']['header'] = Timber::get_widgets('sidebar_header');
     return $data;
 }