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


PHP TimberHelper::is_array_assoc方法代码示例

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


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

示例1: __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

示例2: 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

示例3: 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

示例4: add_twig_filters

 /**
  * @param Twig_Environment $twig
  * @return Twig_Environment
  */
 function add_twig_filters($twig)
 {
     /* image filters */
     $twig->addFilter('resize', new Twig_Filter_Function(array('TimberImageHelper', 'resize')));
     $twig->addFilter('letterbox', new Twig_Filter_Function('wp_resize_letterbox'));
     $twig->addFilter('tojpg', new Twig_Filter_Function(array('TimberImageHelper', 'img_to_jpg')));
     $twig->addFilter('get_src_from_attachment_id', new Twig_Filter_Function('twig_get_src_from_attachment_id'));
     /* debugging filters */
     $twig->addFilter('docs', new Twig_Filter_function('twig_object_docs'));
     $twig->addFilter('get_class', new Twig_Filter_Function('twig_get_class'));
     $twig->addFilter('get_type', new Twig_Filter_Function('twig_get_type'));
     $twig->addFilter('print_r', new Twig_Filter_Function('twig_print_r'));
     $twig->addFilter('print_a', new Twig_Filter_Function('twig_print_a'));
     /* other filters */
     $twig->addFilter('stripshortcodes', new Twig_Filter_Function('strip_shortcodes'));
     $twig->addFilter('array', new Twig_Filter_Function(array($this, 'to_array')));
     $twig->addFilter('excerpt', new Twig_Filter_Function('twig_make_excerpt'));
     $twig->addFilter('function', new Twig_Filter_Function(array($this, 'exec_function')));
     $twig->addFilter('path', new Twig_Filter_Function('twig_get_path'));
     $twig->addFilter('pretags', new Twig_Filter_Function(array($this, 'twig_pretags')));
     $twig->addFilter('sanitize', new Twig_Filter_Function('sanitize_title'));
     $twig->addFilter('shortcodes', new Twig_Filter_Function('twig_shortcodes'));
     $twig->addFilter('time_ago', new Twig_Filter_Function('twig_time_ago'));
     $twig->addFilter('twitterify', new Twig_Filter_Function(array('TimberHelper', 'twitterify')));
     $twig->addFilter('twitterfy', new Twig_Filter_Function(array('TimberHelper', 'twitterify')));
     $twig->addFilter('wp_body_class', new Twig_Filter_Function('twig_body_class'));
     $twig->addFilter('wpautop', new Twig_Filter_Function('wpautop'));
     $twig->addFilter('relative', new Twig_Filter_Function(function ($link) {
         return TimberHelper::get_rel_url($link, true);
     }));
     $twig->addFilter('truncate', new Twig_Filter_Function(function ($text, $len) {
         return TimberHelper::trim_words($text, $len);
     }));
     /* actions and filters */
     $twig->addFunction(new Twig_SimpleFunction('action', function () {
         call_user_func_array('do_action', func_get_args());
     }));
     $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')));
     /* 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);
     }));
     /* bloginfo and translate */
     $twig->addFunction('bloginfo', new Twig_SimpleFunction('bloginfo', function ($show = '', $filter = 'raw') {
         return get_bloginfo($show, $filter);
     }));
     $twig->addFunction('__', new Twig_SimpleFunction('__', function ($text, $domain = 'default') {
         return __($text, $domain);
     }));
     $twig = apply_filters('get_twig', $twig);
     return $twig;
 }
开发者ID:pedrokoblitz,项目名称:centro-dialogo-aberto,代码行数:86,代码来源:functions-twig.php


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