本文整理汇总了PHP中TimberHelper::function_wrapper方法的典型用法代码示例。如果您正苦于以下问题:PHP TimberHelper::function_wrapper方法的具体用法?PHP TimberHelper::function_wrapper怎么用?PHP TimberHelper::function_wrapper使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimberHelper
的用法示例。
在下文中一共展示了TimberHelper::function_wrapper方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initializeContext
public function initializeContext($context)
{
$context = parent::initializeContext($context);
$context['menu'] = new \TimberMenu();
$context['wp_nonce_field'] = \TimberHelper::function_wrapper('wp_nonce_field');
return $context;
}
示例2: testDoubleActionWPFooter
function testDoubleActionWPFooter()
{
global $wp_scripts;
$wp_scripts = null;
add_action('wp_footer', 'echo_junk');
$fw1 = TimberHelper::function_wrapper('wp_footer', array(), true);
$fw2 = TimberHelper::function_wrapper('wp_footer', array(), true);
$this->assertEquals($fw1->call(), $fw2->call());
$this->stringContains('foo', $fw2->call());
remove_action('wp_footer', 'echo_junk');
}
示例3: init
function init()
{
$this->name = get_bloginfo('name');
$this->title = $this->name;
$this->description = get_bloginfo('description');
$this->url = get_bloginfo('url');
$this->language = get_bloginfo('language');
$this->charset = get_bloginfo('charset');
$this->pingback_url = get_bloginfo('pingback_url');
$this->language_attributes = TimberHelper::function_wrapper('language_attributes');
}
示例4: init
protected function init()
{
$this->admin_email = get_bloginfo('admin_email');
$this->name = get_bloginfo('name');
$this->title = $this->name;
$this->description = get_bloginfo('description');
$this->url = get_bloginfo('url');
$this->language = get_bloginfo('language');
$this->charset = get_bloginfo('charset');
$this->pingback_url = get_bloginfo('pingback_url');
$this->theme = new TimberTheme();
$this->language_attributes = TimberHelper::function_wrapper('language_attributes');
$this->multisite = false;
}
示例5: sidebar
/**
* @param string $widget_id
* @return \TimberFunctionWrapper
*/
public function sidebar($widget_id = '')
{
return \TimberHelper::function_wrapper('dynamic_sidebar', array($widget_id), true);
}
示例6: get_widgets
/**
* Get widgets.
*
* @param int $widget_id
* @return TimberFunctionWrapper
*/
public static function get_widgets($widget_id)
{
return TimberHelper::function_wrapper('dynamic_sidebar', array($widget_id), true);
}
示例7: init
/**
* Executed for all types of sites: both multisite and "regular"
* @internal
*/
protected function init()
{
$this->rdf = get_bloginfo('rdf_url');
$this->rss = get_bloginfo('rss_url');
$this->rss2 = get_bloginfo('rss2_url');
$this->atom = get_bloginfo('atom_url');
$this->language = get_bloginfo('language');
$this->charset = get_bloginfo('charset');
$this->pingback = get_bloginfo('pingback_url');
$this->language_attributes = TimberHelper::function_wrapper('language_attributes');
/* deprecated benath this comment */
$this->pingback_url = get_bloginfo('pingback_url');
}
示例8: wpb_block_render_preview
function wpb_block_render_preview($buib, $post_id, $page_id)
{
wpb_block($buib, $post_id, $page_id)->render_preview();
}
/**
* @function wpb_block_render_template
* @since 0.1.0
*/
function wpb_block_render_template($buib, $post_id, $page_id)
{
wpb_block($buib, $post_id, $page_id)->render_template();
}
/**
* @function wpb_block_render_children
* @since 0.1.0
*/
function wpb_block_render_children($area_id)
{
Block::get_current()->render_children($area_id);
}
//------------------------------------------------------------------------------
// Twig Filters
//------------------------------------------------------------------------------
TimberHelper::function_wrapper('wpb_block_edit_link');
TimberHelper::function_wrapper('wpb_block_remove_link');
TimberHelper::function_wrapper('wpb_block_render_outline');
TimberHelper::function_wrapper('wpb_block_render_preview');
TimberHelper::function_wrapper('wpb_block_render_template');
TimberHelper::function_wrapper('wpb_block_render_children');
TimberHelper::function_wrapper('wpb_block_area');
示例9: _timber_context
/**
* filter timber context
* @hook timber_context
* @param $data context data
*/
public function _timber_context($data)
{
$list_func = array('_', '__', '_n', '_e', '_x', 'esc_attr', 'esc_url', 'esc_html', 'esc_html__', 'esc_textarea', 'esc_attr_e', 'esc_attr_x', 'esc_url_raw', 'urlencode', 'home_url', 'edit_post_link', 'get_option', 'sanitize_html_class', '_setup_postdata', 'hw_option', 'hw__post', 'hw__get', 'hw__req', '_hw_global', 'template_tool', '_treat');
foreach ($list_func as $func) {
$data[$func] = TimberHelper::function_wrapper($func);
}
//other functions
#$data['_partial'] = TimberHelper::function_wrapper(array($this, 'load_partial_template')); //wrong
//context object
if (!empty(self::$context)) {
$data = array_merge($data, self::$context);
}
return $data;
}
示例10: array
// Create a timber function wrapper for add script file
TimberHelper::function_wrapper('add_script_file', array(), false);
/**
* Localize Script
* FYI: this function is used by MG to configure require.js
*
* @param string $handle
* @param string $name
* @param array $data
*/
function localize_script($handle, $name, $data)
{
wp_localize_script($handle, $name, $data);
}
// Create a timber function wrapper for add script file
TimberHelper::function_wrapper('localize_script', array(), false);
// Theme scripts
function theme_scripts()
{
// jQuery is loaded using the same method from HTML5 Boilerplate:
// Grab Google CDN's latest jQuery with a protocol relative URL; fallback to local if offline
// It's kept in the header instead of footer to avoid conflicts with plugins.
if (!is_admin() && !in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'))) {
wp_deregister_script('jquery');
add_filter('script_loader_src', 'theme_jquery_local_fallback', 10, 2);
}
}
// Add enqueue scripts action
//add_action('wp_enqueue_scripts', 'theme_scripts', 110);
add_action('wp_loaded', 'theme_scripts', 110);
// http://wordpress.stackexchange.com/a/12450
示例11: return_next_comments_link
* @return string
*/
function return_next_comments_link($post, $label = '', $max_page = 0)
{
global $cpage;
if (!is_singular() || !get_option('page_comments')) {
return;
}
$commentsPerPage = (int) get_option('comments_per_page');
$nextpage = intval($cpage) + 1;
if (empty($max_page)) {
$max_page = get_comment_pages_count($post->comments, $commentsPerPage);
}
if ($nextpage > $max_page) {
return;
}
if (empty($label)) {
$label = __('Newer Comments »');
}
/**
* Filter the anchor tag attributes for the next comments page link.
*
* @since 2.7.0
*
* @param string $attributes Attributes for the anchor tag.
*/
return '<a href="' . esc_url(get_comments_pagenum_link($nextpage)) . '" ' . apply_filters('next_comments_link_attributes', '') . '>' . preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&$1', $label) . '</a>';
}
// Create a timber function wrapper for next comments link
TimberHelper::function_wrapper('return_next_comments_link', null, false);
示例12: get_field
$id = get_field('wpb_css_id', $post);
$class = get_field('wpb_css_class', $post);
$style = get_field('wpb_css_style', $post);
if ($id == null) {
$id = sprintf('%s-%s', $base, $post->ID);
} else {
$id = preg_replace('/[^a-zA-Z0-9]+/mis', '-', $id);
}
if ($class) {
$class = preg_replace('/[^a-zA-Z0-9]+/mis', '-', $class);
}
if ($style) {
$style = preg_replace('/[^a-zA-Z0-9]+/mis', '-', $style);
$style = sprintf('%s-%s', $base, $style);
}
return strtr('id="{id}" class="{base} {class} {style}"', array('{id}' => $id, '{base}' => $base, '{class}' => $class, '{style}' => $style));
}
//------------------------------------------------------------------------------
// Twig Filters
//------------------------------------------------------------------------------
TimberHelper::function_wrapper('wpb_render_block_edit_link');
TimberHelper::function_wrapper('wpb_render_block_copy_link');
TimberHelper::function_wrapper('wpb_render_block_move_link');
TimberHelper::function_wrapper('wpb_render_block_remove_link');
TimberHelper::function_wrapper('wpb_render_block_outline');
TimberHelper::function_wrapper('wpb_render_block_preview');
TimberHelper::function_wrapper('wpb_render_block_template');
TimberHelper::function_wrapper('wpb_render_block_children');
TimberHelper::function_wrapper('wpb_render_block_area');
TimberHelper::function_wrapper('wpb_render_block_attr');
示例13: theme_widgets_init
<?php
/**
* Register widget areas
*/
// Initialize widget areas
function theme_widgets_init()
{
// Sidebars
register_sidebar(array('name' => __('Sidebar', 'theme'), 'id' => 'sidebar-primary', 'before_widget' => '<section class="widget %1$s %2$s">', 'after_widget' => '</section>', 'before_title' => '<h3>', 'after_title' => '</h3>'));
// add more widget areas here...
}
// Add widget initialize action
add_action('widgets_init', 'theme_widgets_init');
// Create a timber function wrapper for dynamic sidebars
TimberHelper::function_wrapper('dynamic_sidebar', array('sidebar'), true);
示例14: add_menus_to_context
protected function add_menus_to_context($context)
{
$context['menu'] = new TimberMenu('primary');
$context['menu_left'] = TimberHelper::function_wrapper('wp_nav_menu', array(array('theme_location' => 'primary', 'container' => false, 'depth' => 0, 'items_wrap' => '<ul class="left">%3$s</ul>', 'fallback_cb' => false, 'walker' => new TimberFoundation_Walker(array('in_top_bar' => true, 'add_dividers' => true, 'item_type' => 'li', 'menu_type' => 'main-menu')))));
$context['menu_right'] = TimberHelper::function_wrapper('wp_nav_menu', array(array('theme_location' => 'topbar-right', 'container' => false, 'depth' => 0, 'items_wrap' => '<ul class="right">%3$s</ul>', 'fallback_cb' => false, 'walker' => new TimberFoundation_Walker(array('in_top_bar' => true, 'add_dividers' => true, 'item_type' => 'li', 'menu_type' => 'main-menu')))));
// Footer
$context['footer_menu'] = new TimberMenu('footer');
return $context;
}