Example #1
0
 function testPHPSidebar()
 {
     add_filter('timber_context', function ($context) {
         $context['sidebar'] = Timber::get_sidebar('assets/my-sidebar.php');
         return $context;
     });
     $context = Timber::get_context();
     $result = Timber::compile('assets/main-w-sidebar-php.twig', $context);
     $this->assertEquals("A Fever You Can't Sweat Out by Panic! at the Disco from 2005", trim($result));
 }
 function testTwigSidebar()
 {
     $context = Timber::get_context();
     $sidebar_post = $this->factory->post->create(array('post_title' => 'Sidebar post content'));
     $sidebar_context = array();
     $sidebar_context['post'] = new TimberPost($sidebar_post);
     $context['sidebar'] = Timber::get_sidebar('assets/sidebar.twig', $sidebar_context);
     $result = Timber::compile('assets/main-w-sidebar.twig', $context);
     $this->assertEquals('I am the main stuff <h4>Sidebar post content</h4>', trim($result));
 }
 function add_to_context($context)
 {
     $context['foo'] = 'bar';
     $context['stuff'] = 'I am a value set in your functions.php file';
     $context['notes'] = 'These values are available everytime you call Timber::get_context();';
     $context['menu'] = new TimberMenu();
     $context['site'] = $this;
     return $context;
     // We want footer widgets on every page, so add it to the global context. Right? I'm starting to get stuck...
     $context['footer_one'] = Timber::get_sidebar('sidebar.php');
     return $context;
 }
Example #4
0
 function add_to_context($context)
 {
     $context['foo'] = 'bar';
     $context['stuff'] = 'I am a value set in your functions.php file';
     $context['notes'] = 'These values are available everytime you call Timber::get_context();';
     $context['menu'] = new TimberMenu();
     $context['site'] = $this;
     // "get_fields('options')" is from ACF
     $context['options'] = get_fields('options');
     // We want footer widgets on every page, so add it to the global context
     // So for example 'footer_widgets' is {{footer_widgets}} that gets inserted into the code.
     $context['footer_widgets'] = Timber::get_sidebar('sidebar.php');
     $context['rightside_widgets'] = Timber::get_sidebar('sidebar-rightwidgets.php');
     $context['footerml_widgets'] = Timber::get_sidebar('sidebar-footerml.php');
     $context['footermr_widgets'] = Timber::get_sidebar('sidebar-footermr.php');
     $context['footerfr_widgets'] = Timber::get_sidebar('sidebar-footerfr.php');
     return $context;
 }
Example #5
0
 function add_to_context($context)
 {
     $context['foo'] = 'bar';
     $context['stuff'] = 'I am a value set in your functions.php file';
     $context['notes'] = 'These values are available everytime you call Timber::get_context();';
     $context['menu'] = new TimberMenu('primary');
     //$context['custom_wp_nav_menu'] = wp_nav_menu( array( 'container_class' => 'menu-header', 'echo' => false, 'menu_class' => 'nav-menu' ) );
     $context['custom_wp_nav_menu'] = wp_nav_menu(array('container_class' => 'menu-header', 'echo' => false, 'menu_class' => 'nav-menu'));
     $context['site'] = $this;
     $context['no_image'] = get_template_directory_uri() . '/images/no_image.png';
     $context['theme_url'] = get_stylesheet_directory_uri();
     $context['is_logged_in'] = is_user_logged_in();
     $context['theme_mod'] = get_theme_mods();
     $context['options'] = wp_load_alloptions();
     $context['site_url'] = site_url();
     if (is_home() || is_front_page()) {
         $context['is_home'] = true;
     }
     /*
      *  Header Image
      */
     $context['site_logo'] = get_option('upload_image');
     $context['menu_upload_image'] = get_option('menu_upload_image');
     /*
      *  Footer 
      */
     $context['footer_tag_line'] = get_option('footer_text');
     $context['footer_address'] = get_option('address');
     $context['footer_site_url'] = site_url();
     $context['footer_inquiry_mail'] = get_option('inquiry_mail');
     $context['footer_telephone'] = get_option('telephone');
     $context['s_facebook'] = get_option('facebook');
     $context['s_twitter'] = get_option('twitter');
     $context['s_linkedin'] = get_option('linkedin');
     $context['footer_copyright'] = get_option('copyright');
     /* Sidebar */
     $context['blogsidebar'] = Timber::get_sidebar('sidebar-blog.php');
     return $context;
 }
Example #6
0
<?php

/**
 * The Template for displaying all single posts
 *
 * Methods for TimberHelper can be found in the /lib sub-directory
 *
 * @package  WordPress
 * @subpackage  Timber
 * @since    Timber 0.1
 */
$context = Timber::get_context();
$post = Timber::query_post();
$context['post'] = $post;
$context['sidebar'] = Timber::get_sidebar('sidebar.php');
$context['sidebar_class'] = 'has-sidebar';
$context['comment_form'] = TimberHelper::get_comment_form();
if (post_password_required($post->ID)) {
    Timber::render('single-password.twig', $context);
} else {
    Timber::render(array('single-' . $post->ID . '.twig', 'single-' . $post->post_type . '.twig', 'single.twig'), $context);
}
Example #7
0
<?php

/**
* The Template for displaying all single posts.
*
* @package WordPress
* @subpackage Boilerplate
* @since Boilerplate 1.0
*/
$data = Timber::get_context();
$data['post'] = new TimberPost();
$data['sidebar'] = Timber::get_sidebar('sidebar.php');
Timber::render('single.twig', $data);
Example #8
0
<?php

$data = Timber::get_context();
$pi = new TimberPost();
if (isset($pi->banner_image)) {
    $pi->banner_image = new TimberImage($pi->banner_image);
}
$data['post'] = $pi;
if ($pi->custom_title_tag) {
    $data['wp_title'] = $pi->custom_title_tag . ' - Upstatement Blog';
} else {
    $data['wp_title'] = $pi->get_title() . ' - Upstatement Blog';
}
if ($pi->custom_description) {
    $data['meta_desc'] = $pi->custom_description;
} else {
    $data['meta_desc'] = strip_tags($pi->get_preview(30, true, '', true));
}
$data['sidebar'] = Timber::get_sidebar();
if (post_password_required($post->ID)) {
    Timber::render('single-password.twig', $data);
} else {
    Timber::render('single.twig', $data);
}