本文整理汇总了PHP中Timber::get_sidebar方法的典型用法代码示例。如果您正苦于以下问题:PHP Timber::get_sidebar方法的具体用法?PHP Timber::get_sidebar怎么用?PHP Timber::get_sidebar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timber
的用法示例。
在下文中一共展示了Timber::get_sidebar方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPHPSidebar
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));
}
示例2: testTwigSidebar
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));
}
示例3: add_to_context
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;
}
示例4: add_to_context
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;
}
示例5: add_to_context
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;
}
示例6:
<?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);
}
示例7: TimberPost
<?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);
示例8: TimberPost
<?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);
}