本文整理汇总了PHP中Timber::get_widgets方法的典型用法代码示例。如果您正苦于以下问题:PHP Timber::get_widgets方法的具体用法?PHP Timber::get_widgets怎么用?PHP Timber::get_widgets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timber
的用法示例。
在下文中一共展示了Timber::get_widgets方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_context
/**
* 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: add_to_context
/**
* 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: add_to_context
/**
* 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: add_to_context
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: add_to_context
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: testHTML
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: add_to_context
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: add_to_context
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: timber_extras
/**
* 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: add_to_context
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: maera_res_context
/**
* Modify the Timber global context
* @param [type] $context [description]
* @return [type] [description]
*/
function maera_res_context($context)
{
$context['currency'] = get_theme_mod('currency', '$');
$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: get_sidebar_widgets
public function get_sidebar_widgets($sidebar_slug)
{
return \Timber::get_widgets($sidebar_slug);
}
示例13:
<?php
/**
* The Template for displaying all single posts
*
*
* @package WordPress
* @subpackage Timber
*/
$context['home_left'] = Timber::get_widgets('home_left');
示例14: runs
<?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: TimberUser
<?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);