当前位置: 首页>>代码示例>>PHP>>正文


PHP Timber::get_context方法代码示例

本文整理汇总了PHP中Timber::get_context方法的典型用法代码示例。如果您正苦于以下问题:PHP Timber::get_context方法的具体用法?PHP Timber::get_context怎么用?PHP Timber::get_context使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Timber的用法示例。


在下文中一共展示了Timber::get_context方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testFunctionsPHP

 function testFunctionsPHP()
 {
     $context = Timber::get_context();
     $this->assertEquals('StarterSite', get_class($context['site']));
     $this->assertTrue(current_theme_supports('post-thumbnails'));
     $this->assertEquals('bar', $context['foo']);
 }
开发者ID:nachtbrakert,项目名称:mathieujonker.nl,代码行数:7,代码来源:test-timber-starter-theme.php

示例2: 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);
 }
开发者ID:wpmu,项目名称:maera,代码行数:34,代码来源:class-maera-timber.php

示例3: form

 public function form($instance)
 {
     $context = \Timber::get_context();
     $context['title'] = !empty($instance['title']) ? $instance['title'] : __('Test', self::I18N_DOMAIN);
     $context['widget'] = $this;
     \Timber::render('timber-test-widget-form.twig', $context);
 }
开发者ID:emilyhorsman,项目名称:timber-test-widget,代码行数:7,代码来源:timber-test-widget.class.php

示例4: load_view

 public function load_view()
 {
     $context = Timber::get_context();
     $context['data'] = $this->data;
     $context['constants'] = get_slate_constants();
     Timber::render(theme_views . '/single.twig', $context);
 }
开发者ID:bmc75,项目名称:wpmvc,代码行数:7,代码来源:single-service.php

示例5: testLinkOnSubdirectoryInstall

 function testLinkOnSubdirectoryInstall()
 {
     update_option('siteurl', 'http://example.org/wordpress', true);
     $context = Timber::get_context();
     $theme = $context['site']->theme;
     $output = Timber::compile_string('{{site.theme.link}}', $context);
     $this->assertEquals('http://example.org/wp-content/themes/' . $theme->slug, $output);
 }
开发者ID:Butterwell,项目名称:timber,代码行数:8,代码来源:test-timber-theme.php

示例6: testGetData

 function testGetData()
 {
     $_GET['foo'] = 'bar';
     $template = '{{request.get.foo}}';
     $context = Timber::get_context();
     $str = Timber::compile_string($template, $context);
     $this->assertEquals('bar', $str);
 }
开发者ID:mrgrain,项目名称:timber,代码行数:8,代码来源:test-timber-request.php

示例7: getCallback

 /**
  *
  * {$inheritdoc}
  *
  */
 public function getCallback()
 {
     $context = \Timber::get_context();
     $context['options'] = $this->getOptions();
     $context['field_name'] = self::META_NAME_PAGE_TYPE;
     $context['current_value'] = $this->getCurrentValue();
     \Timber::render($this->dic['CMS']->getViewPath('meta_boxes/page-type.html.twig'), $context);
 }
开发者ID:flexpress,项目名称:plugin-cms,代码行数:13,代码来源:PageType.php

示例8: testTimberContext

 function testTimberContext()
 {
     add_filter('timber/context', function ($context) {
         $context['person'] = "Nathan Hass";
         return $context;
     });
     $context = Timber::get_context();
     $this->assertEquals('Nathan Hass', $context['person']);
 }
开发者ID:rjagadishsingh,项目名称:timber,代码行数:9,代码来源:test-timber-hooks.php

示例9: twig_replacements

 /**
  * Get the twig file and pass the replacement to it.
  * This function is just a helper for the do_twig_replacements function.
  */
 public function twig_replacements($replacement = false)
 {
     // If no replacement has been defined, exit.
     if (!$replacement) {
         return;
     }
     $context = Timber::get_context();
     $context['element'] = $replacement;
     Timber::render(array('twig-str_replace.twig'), $context, Maera()->cache->cache_duration());
 }
开发者ID:wpmu,项目名称:maera,代码行数:14,代码来源:class-maera-shell.php

示例10: menuPageCallback

 /**
  *
  * Callback methods for the options page
  *
  * @author Tim Perry
  *
  */
 public function menuPageCallback()
 {
     $args = array('public' => true);
     $context = \Timber::get_context();
     $context['postTypes'] = get_post_types($args, 'names');
     $context['settingsGroupName'] = self::SETTINGS_GROUP_NAME;
     $context['fieldName'] = self::OPTION_NAME_SHOW_ON;
     $context['currentValue'] = get_option(self::OPTION_NAME_SHOW_ON);
     \Timber::render($this->getPath() . '/views/options-page.twig', $context);
 }
开发者ID:flexpress,项目名称:plugin-accordion,代码行数:17,代码来源:Accordion.php

示例11: testContextLoop

 /**
  * This throws an infite loop if memorization isn't working
  */
 function testContextLoop()
 {
     add_filter('timber_context', function ($context) {
         $context = Timber::get_context();
         $context['zebra'] = 'silly horse';
         return $context;
     });
     $context = Timber::get_context();
     $this->assertEquals('http://example.org', $context['http_host']);
 }
开发者ID:mrgrain,项目名称:timber,代码行数:13,代码来源:test-timber-context.php

示例12: 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));
 }
开发者ID:aauroux,项目名称:timber,代码行数:10,代码来源:test-timber-sidebar.php

示例13: testFunctionsPHP

 function testFunctionsPHP()
 {
     self::_setupStarterTheme();
     require_once get_template_directory() . '/functions.php';
     $context = Timber::get_context();
     $this->assertEquals('StarterSite', get_class($context['site']));
     $this->assertTrue(current_theme_supports('post-thumbnails'));
     $this->assertEquals('bar', $context['foo']);
     switch_theme('twentythirteen');
 }
开发者ID:aauroux,项目名称:timber,代码行数:10,代码来源:test-timber-starter-theme.php

示例14: 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));
 }
开发者ID:alexaldama,项目名称:timber,代码行数:10,代码来源:test-timber-sidebar.php

示例15: get_filtered_context

 /**
  * Returns filtered Timber Context
  *
  * @param array $args Elements to be filtered.
  * @param bool  $override_with_empty Whether to override default when empty is provided.
  * @return array
  */
 public function get_filtered_context($args = false, $override_with_empty = true)
 {
     if (!$override_with_empty) {
         $args = $this->remove_empty($args);
     }
     $this->setup_filters($args);
     $context = Timber::get_context();
     $context = $this->add_context_elements($context);
     $this->remove_filters($args);
     return $context;
 }
开发者ID:softcatala,项目名称:wp-softcatala,代码行数:18,代码来源:contextfilterer.php


注:本文中的Timber::get_context方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。