• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP TimberHelper类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中TimberHelper的典型用法代码示例。如果您正苦于以下问题:PHP TimberHelper类的具体用法?PHP TimberHelper怎么用?PHP TimberHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TimberHelper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
 }
开发者ID:wpmu,项目名称:maera,代码行数:34,代码来源:class-maera-timber.php


示例2: handle_post_results

 /**
  * @param array $results
  * @param string $PostClass
  * @return array
  */
 static function handle_post_results($results, $PostClass = 'TimberPost')
 {
     $posts = array();
     foreach ($results as $rid) {
         $PostClassUse = $PostClass;
         if (is_array($PostClass)) {
             $post_type = get_post_type($rid);
             $PostClassUse = 'TimberPost';
             if (isset($PostClass[$post_type])) {
                 $PostClassUse = $PostClass[$post_type];
             } else {
                 if (is_array($PostClass)) {
                     TimberHelper::error_log($post_type . ' of ' . $rid . ' not found in ' . print_r($PostClass, true));
                 } else {
                     TimberHelper::error_log($post_type . ' not found in ' . $PostClass);
                 }
             }
         }
         $post = new $PostClassUse($rid);
         if (isset($post->ID)) {
             $posts[] = $post;
         }
     }
     return new TimberPostsCollection($posts, $PostClass);
 }
开发者ID:aauroux,项目名称:timber,代码行数:30,代码来源:timber-post-getter.php


示例3: 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;
 }
开发者ID:StoutLogic,项目名称:understory-theme,代码行数:7,代码来源:Site.php


示例4: __construct

 public function __construct($posts = array(), $post_class = 'TimberPost')
 {
     $returned_posts = array();
     if (is_null($posts)) {
         $posts = array();
     }
     foreach ($posts as $post_object) {
         $post_class_use = $post_class;
         if (is_array($post_class)) {
             $post_type = get_post_type($post_object);
             $post_class_use = 'TimberPost';
             if (isset($post_class[$post_type])) {
                 $post_class_use = $post_class[$post_type];
             } else {
                 if (is_array($post_class)) {
                     TimberHelper::error_log($post_type . ' of ' . $post_object->ID . ' not found in ' . print_r($post_class, true));
                 } else {
                     TimberHelper::error_log($post_type . ' not found in ' . $post_class);
                 }
             }
         }
         // Don't create yet another object if $post_object is already of the right type
         if (is_a($post_object, $post_class_use)) {
             $post = $post_object;
         } else {
             $post = new $post_class_use($post_object);
         }
         if (isset($post->ID)) {
             $returned_posts[] = $post;
         }
     }
     $returned_posts = self::maybe_set_preview($returned_posts);
     parent::__construct($returned_posts, $flags = 0, 'TimberPostsIterator');
 }
开发者ID:Butterwell,项目名称:timber,代码行数:34,代码来源:timber-posts-collection.php


示例5: run

 /**
  * Performs the actual image manipulation,
  * including saving the target file.
  *
  * @param  string $load_filename filepath (not URL) to source file
  *                               (ex: /src/var/www/wp-content/uploads/my-pic.jpg)
  * @param  string $save_filename filepath (not URL) where result file should be saved
  *                               (ex: /src/var/www/wp-content/uploads/[email protected])
  * @return bool                  true if everything went fine, false otherwise
  */
 function run($load_filename, $save_filename)
 {
     $image = wp_get_image_editor($load_filename);
     if (!is_wp_error($image)) {
         $current_size = $image->get_size();
         $src_w = $current_size['width'];
         $src_h = $current_size['height'];
         // Get ratios
         $w = $src_w * $this->factor;
         $h = $src_h * $this->factor;
         $image->crop(0, 0, $src_w, $src_h, $w, $h);
         $result = $image->save($save_filename);
         if (is_wp_error($result)) {
             error_log('Error resizing image');
             error_log(print_r($result, true));
             return false;
         } else {
             return true;
         }
     } else {
         if (isset($image->error_data['error_loading_image'])) {
             TimberHelper::error_log('Error loading ' . $image->error_data['error_loading_image']);
         } else {
             TimberHelper::error_log($image);
         }
     }
     return false;
 }
开发者ID:wpmu,项目名称:maera,代码行数:38,代码来源:timber-image-operation-retina.php


示例6: __construct

 public function __construct($query = false, $posts_class = 'TimberPost')
 {
     add_action('pre_get_posts', array($this, 'fix_number_posts_wp_quirk'));
     if ($posts_class) {
         $this->_posts_class = $posts_class;
     }
     if (is_a($query, 'WP_Query')) {
         // We got a full-fledged WP Query, look no further!
         $the_query = $query;
     } elseif (false === $query) {
         // If query is explicitly set to false, use the main loop
         global $wp_query;
         $the_query =& $wp_query;
     } elseif (TimberHelper::is_array_assoc($query) || is_string($query) && strstr($query, '=')) {
         // We have a regularly formed WP query string or array to use
         $the_query = new WP_Query($query);
     } elseif (is_numeric($query) || is_string($query)) {
         // We have what could be a post name or post ID to pull out
         $the_query = self::get_query_from_string($query);
     } elseif (is_array($query) && count($query) && (is_integer($query[0]) || is_string($query[0]))) {
         // We have a list of pids (post IDs) to extract from
         $the_query = self::get_query_from_array_of_ids($query);
     } else {
         TimberHelper::error_log('I have failed you! in ' . basename(__FILE__) . '::' . __LINE__);
         TimberHelper::error_log($query);
         // We have failed hard, at least let get something.
         $the_query = new WP_Query();
     }
     $this->_query = $the_query;
 }
开发者ID:JimCaignard,项目名称:wordpress-sass-gulp-timber-starter,代码行数:30,代码来源:timber-query-iterator.php


示例7: call

 /**
  *
  *
  * @return string
  */
 public function call()
 {
     $args = $this->_parse_args(func_get_args(), $this->_args);
     if ($this->_use_ob) {
         return TimberHelper::ob_function($this->_function, $args);
     } else {
         return call_user_func_array($this->_function, $args);
     }
 }
开发者ID:Butterwell,项目名称:timber,代码行数:14,代码来源:timber-function-wrapper.php


示例8: add_to_context

 function add_to_context($context)
 {
     $context['current_url'] = TimberHelper::get_current_url();
     $context['pagination'] = Timber::get_pagination();
     $context['bethel_header_menu'] = new TimberMenu('primary');
     $context['bethel_sidebar_menu'] = new TimberMenu('sidebar');
     $context['site'] = $this;
     return $context;
 }
开发者ID:betheluniversity,项目名称:bethel-responsive-wp,代码行数:9,代码来源:functions.php


示例9: 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');
 }
开发者ID:pedrokoblitz,项目名称:centro-dialogo-aberto,代码行数:11,代码来源:timber-site.php


示例10: testGetPostsByMeta

 function testGetPostsByMeta()
 {
     $pids = array();
     $lauren = $this->factory->post->create(array('post_title' => 'Lauren Richler'));
     $jared = $this->factory->post->create(array('post_title' => 'Jared Novack'));
     update_post_meta($lauren, 'in', 'love');
     update_post_meta($jared, 'in', 'love');
     $in_love = TimberHelper::get_posts_by_meta('in', 'love');
     $this->assertContains($lauren, $in_love);
     $this->assertContains($jared, $in_love);
     $this->assertEquals(2, count($in_love));
 }
开发者ID:Butterwell,项目名称:timber,代码行数:12,代码来源:test-timber-deprecated.php


示例11: testGetObjectIndexByProperty

 function testGetObjectIndexByProperty()
 {
     $obj1 = new stdClass();
     $obj1->name = 'mark';
     $obj1->skill = 'acro yoga';
     $obj2 = new stdClass();
     $obj2->name = 'austin';
     $obj2->skill = 'cooking';
     $arr = array($obj1, $obj2);
     $index = TimberHelper::get_object_index_by_property($arr, 'skill', 'cooking');
     $this->assertEquals(1, $index);
     $obj = TimberHelper::get_object_by_property($arr, 'skill', 'cooking');
     $this->assertEquals('austin', $obj->name);
 }
开发者ID:aauroux,项目名称:timber,代码行数:14,代码来源:test-timber-helper.php


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


示例13: testAgainstFooterFunctionOutput

 function testAgainstFooterFunctionOutput()
 {
     global $wp_scripts;
     $wp_scripts = null;
     wp_enqueue_script('colorpicker', false, array(), false, true);
     wp_enqueue_script('fake-js', 'http://example.org/fake-js.js', array(), false, true);
     $wp_footer = TimberHelper::ob_function('wp_footer');
     global $wp_scripts;
     $wp_scripts = null;
     wp_enqueue_script('colorpicker', false, array(), false, true);
     wp_enqueue_script('fake-js', 'http://example.org/fake-js.js', array(), false, true);
     $str = Timber::compile_string('{{function("wp_footer")}}');
     $this->assertEquals($wp_footer, $str);
     $this->assertGreaterThan(50, strlen($str));
 }
开发者ID:Butterwell,项目名称:timber,代码行数:15,代码来源:test-timber-wp-functions.php


示例14: get_terms

 /**
  * @param string|array $args
  * @param array $maybe_args
  * @param string $TermClass
  * @return mixed
  */
 public static function get_terms($args = null, $maybe_args = array(), $TermClass = 'TimberTerm')
 {
     if (is_string($maybe_args) && !strstr($maybe_args, '=')) {
         //the user is sending the $TermClass in the second argument
         $TermClass = $maybe_args;
     }
     if (is_string($maybe_args) && strstr($maybe_args, '=')) {
         parse_str($maybe_args, $maybe_args);
     }
     if (is_string($args) && strstr($args, '=')) {
         //a string and a query string!
         $parsed = TimberTermGetter::get_term_query_from_query_string($args);
         if (is_array($maybe_args)) {
             $parsed->args = array_merge($parsed->args, $maybe_args);
         }
         return self::handle_term_query($parsed->taxonomies, $parsed->args, $TermClass);
     } else {
         if (is_string($args)) {
             //its just a string with a single taxonomy
             $parsed = TimberTermGetter::get_term_query_from_string($args);
             if (is_array($maybe_args)) {
                 $parsed->args = array_merge($parsed->args, $maybe_args);
             }
             return self::handle_term_query($parsed->taxonomies, $parsed->args, $TermClass);
         } else {
             if (is_array($args) && TimberHelper::is_array_assoc($args)) {
                 //its an associative array, like a good ole query
                 $parsed = TimberTermGetter::get_term_query_from_assoc_array($args);
                 return self::handle_term_query($parsed->taxonomies, $parsed->args, $TermClass);
             } else {
                 if (is_array($args)) {
                     //its just an array of strings or IDs (hopefully)
                     $parsed = TimberTermGetter::get_term_query_from_array($args);
                     if (is_array($maybe_args)) {
                         $parsed->args = array_merge($parsed->args, $maybe_args);
                     }
                     return self::handle_term_query($parsed->taxonomies, $parsed->args, $TermClass);
                 } else {
                     if (is_null($args)) {
                         return self::handle_term_query(get_taxonomies(), array(), $TermClass);
                     }
                 }
             }
         }
     }
     return null;
 }
开发者ID:aauroux,项目名称:timber,代码行数:53,代码来源:timber-term-getter.php


示例15: 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;
 }
开发者ID:sevir,项目名称:maera-bootstrap,代码行数:20,代码来源:class-maera-bs-timber.php


示例16: load_json

 function load_json($json_file)
 {
     if (file_exists($json_file)) {
         $json = file_get_contents($json_file);
         $json = json_decode($json);
         foreach ($json->bricks as &$brick) {
             $brick = new ZoneboardBlock($brick);
         }
         $this->json_data = $json;
         $this->_bricks = $json->bricks;
     } else {
         if (is_admin()) {
             $url = TimberHelper::get_current_url();
             $parts = parse_url($url);
             if (isset($parts['query']) && $parts['query'] == 'page=zoneboard' || isset($parts['path']) && strpos($parts['path'], 'wp-admin/plugins.php')) {
                 $this->show_message_for_missing_json_file($json_file);
             }
         }
     }
 }
开发者ID:ripestudios,项目名称:wp-plugins,代码行数:20,代码来源:zoneboard.php


示例17: get_pagination

 /**
  * Get pagination.
  *
  * @param array   $prefs
  * @return array mixed
  */
 public static function get_pagination($prefs = array())
 {
     global $wp_query;
     global $paged;
     global $wp_rewrite;
     $args = array();
     $args['total'] = ceil($wp_query->found_posts / $wp_query->query_vars['posts_per_page']);
     if ($wp_rewrite->using_permalinks()) {
         $url = explode('?', get_pagenum_link(0));
         if (isset($url[1])) {
             parse_str($url[1], $query);
             $args['add_args'] = $query;
         }
         $args['format'] = 'page/%#%';
         $args['base'] = trailingslashit($url[0]) . '%_%';
     } else {
         $big = 999999999;
         $args['base'] = str_replace($big, '%#%', esc_url(get_pagenum_link($big)));
     }
     $args['type'] = 'array';
     $args['current'] = max(1, get_query_var('paged'));
     $args['mid_size'] = max(9 - $args['current'], 3);
     $args['prev_next'] = false;
     if (is_int($prefs)) {
         $args['mid_size'] = $prefs - 2;
     } else {
         $args = array_merge($args, $prefs);
     }
     $data = array();
     $data['current'] = $args['current'];
     $data['total'] = $args['total'];
     $data['pages'] = TimberHelper::paginate_links($args);
     $next = get_next_posts_page_link($args['total']);
     if ($next) {
         $data['next'] = array('link' => untrailingslashit($next), 'class' => 'page-numbers next');
     }
     $prev = previous_posts(false);
     if ($prev) {
         $data['prev'] = array('link' => untrailingslashit($prev), 'class' => 'page-numbers prev');
     }
     if ($paged < 2) {
         $data['prev'] = '';
     }
     return $data;
 }
开发者ID:Butterwell,项目名称:timber,代码行数:51,代码来源:timber.php


示例18: is_home

<?php

/**
 * @package  WordPress
 * @subpackage  Timber
 * @since   Timber 0.1
 */
if (!class_exists('Timber')) {
    echo 'Timber not activated. Make sure you activate the plugin in <a href="/wp-admin/plugins.php#timber">/wp-admin/plugins.php</a>';
    return;
}
$context = Timber::get_context();
$context['post'] = Timber::get_post();
$context['is_home'] = is_home() || is_front_page();
if ($context['is_home']) {
    $context['site_css_contents'] = TimberHelper::transient('site_css_contents', function () {
        return file_get_contents(get_template_directory_uri() . "/assets/dist/css/application.min.css");
    }, 14400);
}
$templates = array('home.twig');
Timber::render($templates, $context);
开发者ID:leroyg,项目名称:launchframe,代码行数:21,代码来源:front-page.php


示例19: testOSort

 function testOSort()
 {
     $michael = new stdClass();
     $michael->name = 'Michael';
     $michael->year = 1981;
     $lauren = new stdClass();
     $lauren->name = 'Lauren';
     $lauren->year = 1984;
     $boo = new stdClass();
     $boo->name = 'Robbie';
     $boo->year = 1989;
     $people = array($lauren, $michael, $boo);
     TimberHelper::osort($people, 'year');
     $this->assertEquals('Michael', $people[0]->name);
     $this->assertEquals('Lauren', $people[1]->name);
     $this->assertEquals('Robbie', $people[2]->name);
     $this->assertEquals(1984, $people[1]->year);
 }
开发者ID:ruscon,项目名称:timber,代码行数:18,代码来源:test-timber-helper.php


示例20: add_timber_filters

 /**
  *
  *
  * @param Twig_Environment $twig
  * @return Twig_Environment
  */
 function add_timber_filters($twig)
 {
     /* image filters */
     $twig->addFilter(new Twig_SimpleFilter('resize', array('TimberImageHelper', 'resize')));
     $twig->addFilter(new Twig_SimpleFilter('retina', array('TimberImageHelper', 'retina_resize')));
     $twig->addFilter(new Twig_SimpleFilter('letterbox', array('TimberImageHelper', 'letterbox')));
     $twig->addFilter(new Twig_SimpleFilter('tojpg', array('TimberImageHelper', 'img_to_jpg')));
     /* debugging filters */
     $twig->addFilter(new Twig_SimpleFilter('docs', 'twig_object_docs'));
     $twig->addFilter(new Twig_SimpleFilter('get_class', 'get_class'));
     $twig->addFilter(new Twig_SimpleFilter('get_type', 'get_type'));
     $twig->addFilter(new Twig_SimpleFilter('print_r', function ($arr) {
         return print_r($arr, true);
     }));
     $twig->addFilter(new Twig_SimpleFilter('print_a', function ($arr) {
         return '<pre>' . self::object_docs($arr, true) . '</pre>';
     }));
     /* other filters */
     $twig->addFilter(new Twig_SimpleFilter('stripshortcodes', 'strip_shortcodes'));
     $twig->addFilter(new Twig_SimpleFilter('array', array($this, 'to_array')));
     $twig->addFilter(new Twig_SimpleFilter('excerpt', 'wp_trim_words'));
     $twig->addFilter(new Twig_SimpleFilter('function', array($this, 'exec_function')));
     $twig->addFilter(new Twig_SimpleFilter('pretags', array($this, 'twig_pretags')));
     $twig->addFilter(new Twig_SimpleFilter('sanitize', 'sanitize_title'));
     $twig->addFilter(new Twig_SimpleFilter('shortcodes', 'do_shortcode'));
     $twig->addFilter(new Twig_SimpleFilter('time_ago', array($this, 'time_ago')));
     $twig->addFilter(new Twig_SimpleFilter('wpautop', 'wpautop'));
     $twig->addFilter(new Twig_SimpleFilter('relative', function ($link) {
         return TimberURLHelper::get_rel_url($link, true);
     }));
     $twig->addFilter(new Twig_SimpleFilter('date', array($this, 'intl_date')));
     $twig->addFilter(new Twig_SimpleFilter('truncate', function ($text, $len) {
         return TimberHelper::trim_words($text, $len);
     }));
     /* actions and filters */
     $twig->addFunction(new Twig_SimpleFunction('action', function ($context) {
         $args = func_get_args();
         array_shift($args);
         $args[] = $context;
         call_user_func_array('do_action', $args);
     }, array('needs_context' => true)));
     $twig->addFilter(new Twig_SimpleFilter('apply_filters', function () {
         $args = func_get_args();
         $tag = current(array_splice($args, 1, 1));
         return apply_filters_ref_array($tag, $args);
     }));
     $twig->addFunction(new Twig_SimpleFunction('function', array(&$this, 'exec_function')));
     $twig->addFunction(new Twig_SimpleFunction('fn', array(&$this, 'exec_function')));
     $twig->addFunction(new Twig_SimpleFunction('shortcode', 'do_shortcode'));
     /* TimberObjects */
     $twig->addFunction(new Twig_SimpleFunction('TimberPost', function ($pid, $PostClass = 'TimberPost') {
         if (is_array($pid) && !TimberHelper::is_array_assoc($pid)) {
             foreach ($pid as &$p) {
                 $p = new $PostClass($p);
             }
             return $pid;
         }
         return new $PostClass($pid);
     }));
     $twig->addFunction(new Twig_SimpleFunction('TimberImage', function ($pid, $ImageClass = 'TimberImage') {
         if (is_array($pid) && !TimberHelper::is_array_assoc($pid)) {
             foreach ($pid as &$p) {
                 $p = new $ImageClass($p);
             }
             return $pid;
         }
         return new $ImageClass($pid);
     }));
     $twig->addFunction(new Twig_SimpleFunction('TimberTerm', function ($pid, $TermClass = 'TimberTerm') {
         if (is_array($pid) && !TimberHelper::is_array_assoc($pid)) {
             foreach ($pid as &$p) {
                 $p = new $TermClass($p);
             }
             return $pid;
         }
         return new $TermClass($pid);
     }));
     $twig->addFunction(new Twig_SimpleFunction('TimberUser', function ($pid, $UserClass = 'TimberUser') {
         if (is_array($pid) && !TimberHelper::is_array_assoc($pid)) {
             foreach ($pid as &$p) {
                 $p = new $UserClass($p);
             }
             return $pid;
         }
         return new $UserClass($pid);
     }));
     /* TimberObjects Alias */
     $twig->addFunction(new Twig_SimpleFunction('Post', function ($pid, $PostClass = 'TimberPost') {
         if (is_array($pid) && !TimberHelper::is_array_assoc($pid)) {
             foreach ($pid as &$p) {
                 $p = new $PostClass($p);
             }
             return $pid;
         }
//.........这里部分代码省略.........
开发者ID:adrianjonmiller,项目名称:hearts-being-healed,代码行数:101,代码来源:timber-twig.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP TimberURLHelper类代码示例发布时间:2022-05-23
下一篇:
PHP Timber类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap