Version Description
- Fixed issue with {{post.author.name}}
- Bug fixes and code organization (@hsz, @jaredNova)
Download this release
Release Info
Developer | jarednova |
Plugin | Timber |
Version | 0.19.2 |
Comparing to | |
See all releases |
Code changes from version 0.19.1 to 0.19.2
- README.md +1 -1
- functions/timber-archives.php +1 -1
- functions/timber-helper.php +6 -6
- functions/timber-image.php +1 -0
- functions/timber-post.php +14 -13
- functions/timber-term.php +3 -3
- functions/timber-theme.php +4 -4
- functions/{functions-twig.php → timber-twig.php} +79 -174
- functions/timber-user.php +5 -3
- readme.txt +8 -4
- timber.php +2 -2
- vendor/autoload.php +1 -1
- vendor/composer/autoload_real.php +4 -4
README.md
CHANGED
@@ -13,7 +13,7 @@ This cleans-up your theme code so, for example, your php file can focus on being
|
|
13 |
|
14 |
This is what Timber's `.twig` files look like:
|
15 |
|
16 |
-
```html
|
17 |
{% extends "base.twig" %}
|
18 |
{% block content %}
|
19 |
<h1 class="big-title">{{foo}}</h1>
|
13 |
|
14 |
This is what Timber's `.twig` files look like:
|
15 |
|
16 |
+
```html+django
|
17 |
{% extends "base.twig" %}
|
18 |
{% block content %}
|
19 |
<h1 class="big-title">{{foo}}</h1>
|
functions/timber-archives.php
CHANGED
@@ -65,7 +65,7 @@ class TimberArchives extends TimberCore
|
|
65 |
* @param string $join
|
66 |
* @param string $where
|
67 |
* @param string $order
|
68 |
-
* @param
|
69 |
* @param bool $nested
|
70 |
* @return array
|
71 |
*/
|
65 |
* @param string $join
|
66 |
* @param string $where
|
67 |
* @param string $order
|
68 |
+
* @param int $limit
|
69 |
* @param bool $nested
|
70 |
* @return array
|
71 |
*/
|
functions/timber-helper.php
CHANGED
@@ -129,13 +129,13 @@ class TimberHelper
|
|
129 |
}
|
130 |
|
131 |
/**
|
132 |
-
* @param string $
|
133 |
* @param string $seplocation
|
134 |
* @return string
|
135 |
*/
|
136 |
-
public static function get_wp_title($
|
137 |
-
$
|
138 |
-
return trim(wp_title($
|
139 |
}
|
140 |
|
141 |
/* Text Utilities
|
@@ -518,7 +518,7 @@ class TimberHelper
|
|
518 |
return $page_links;
|
519 |
}
|
520 |
|
521 |
-
/* LEGACY These have since been re-organized; but keeping linkages for backwards-
|
522 |
|
523 |
public static function get_image_path($iid) {
|
524 |
return TimberImageHelper::get_image_path($iid);
|
@@ -580,5 +580,5 @@ class TimberHelper
|
|
580 |
|
581 |
class WPHelper extends TimberHelper
|
582 |
{
|
583 |
-
//for backwards
|
584 |
}
|
129 |
}
|
130 |
|
131 |
/**
|
132 |
+
* @param string $separator
|
133 |
* @param string $seplocation
|
134 |
* @return string
|
135 |
*/
|
136 |
+
public static function get_wp_title($separator = ' ', $seplocation = 'left') {
|
137 |
+
$separator = apply_filters('timber_wp_title_seperator', $separator);
|
138 |
+
return trim(wp_title($separator, false, $seplocation));
|
139 |
}
|
140 |
|
141 |
/* Text Utilities
|
518 |
return $page_links;
|
519 |
}
|
520 |
|
521 |
+
/* LEGACY These have since been re-organized; but keeping linkages for backwards-compatibility */
|
522 |
|
523 |
public static function get_image_path($iid) {
|
524 |
return TimberImageHelper::get_image_path($iid);
|
580 |
|
581 |
class WPHelper extends TimberHelper
|
582 |
{
|
583 |
+
//for backwards compatibility, will remove eventually
|
584 |
}
|
functions/timber-image.php
CHANGED
@@ -15,6 +15,7 @@ class TimberImage extends TimberCore
|
|
15 |
public $file;
|
16 |
public $sizes = array();
|
17 |
public $post_parent;
|
|
|
18 |
|
19 |
/**
|
20 |
* @param int $iid
|
15 |
public $file;
|
16 |
public $sizes = array();
|
17 |
public $post_parent;
|
18 |
+
public $caption;
|
19 |
|
20 |
/**
|
21 |
* @param int $iid
|
functions/timber-post.php
CHANGED
@@ -5,24 +5,24 @@ class TimberPost extends TimberCore
|
|
5 |
|
6 |
public $ImageClass = 'TimberImage';
|
7 |
public $PostClass = 'TimberPost';
|
8 |
-
public $_can_edit;
|
9 |
-
public $_get_terms;
|
10 |
-
public $_content;
|
11 |
-
public $object_type = 'post';
|
12 |
-
|
13 |
-
public $_custom_imported = false;
|
14 |
|
|
|
15 |
public static $representation = 'post';
|
16 |
|
17 |
-
public $
|
|
|
|
|
|
|
|
|
18 |
public $class;
|
|
|
19 |
public $id;
|
20 |
-
public $
|
21 |
public $post_date;
|
|
|
22 |
public $post_title;
|
23 |
-
public $
|
24 |
-
|
25 |
-
|
26 |
/**
|
27 |
* If you send the constructor nothing it will try to figure out the current post id based on being inside The_Loop
|
28 |
* @param mixed $pid
|
@@ -772,7 +772,6 @@ class TimberPost extends TimberCore
|
|
772 |
$ret['children'] = $this->children();
|
773 |
$ret['comments'] = $this->comments();
|
774 |
$ret['content'] = $this->content();
|
775 |
-
$ret['display_date'] = $this->display_date();
|
776 |
$ret['edit_link'] = $this->edit_link();
|
777 |
$ret['format'] = $this->format();
|
778 |
$ret['link'] = $this->link();
|
@@ -879,7 +878,8 @@ class TimberPost extends TimberCore
|
|
879 |
return $this->get_field($field_name);
|
880 |
}
|
881 |
|
882 |
-
|
|
|
883 |
* @return string
|
884 |
*/
|
885 |
public function modified_date($date_format = '') {
|
@@ -887,6 +887,7 @@ class TimberPost extends TimberCore
|
|
887 |
}
|
888 |
|
889 |
/**
|
|
|
890 |
* @return string
|
891 |
*/
|
892 |
public function modified_time($time_format = '') {
|
5 |
|
6 |
public $ImageClass = 'TimberImage';
|
7 |
public $PostClass = 'TimberPost';
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
+
public $object_type = 'post';
|
10 |
public static $representation = 'post';
|
11 |
|
12 |
+
public $_can_edit;
|
13 |
+
public $_custom_imported = false;
|
14 |
+
public $_content;
|
15 |
+
public $_get_terms;
|
16 |
+
|
17 |
public $class;
|
18 |
+
public $display_date;
|
19 |
public $id;
|
20 |
+
public $post_content;
|
21 |
public $post_date;
|
22 |
+
public $post_parent;
|
23 |
public $post_title;
|
24 |
+
public $post_type;
|
25 |
+
|
|
|
26 |
/**
|
27 |
* If you send the constructor nothing it will try to figure out the current post id based on being inside The_Loop
|
28 |
* @param mixed $pid
|
772 |
$ret['children'] = $this->children();
|
773 |
$ret['comments'] = $this->comments();
|
774 |
$ret['content'] = $this->content();
|
|
|
775 |
$ret['edit_link'] = $this->edit_link();
|
776 |
$ret['format'] = $this->format();
|
777 |
$ret['link'] = $this->link();
|
878 |
return $this->get_field($field_name);
|
879 |
}
|
880 |
|
881 |
+
/**
|
882 |
+
* @param string $date_format
|
883 |
* @return string
|
884 |
*/
|
885 |
public function modified_date($date_format = '') {
|
887 |
}
|
888 |
|
889 |
/**
|
890 |
+
* @param string $time_format
|
891 |
* @return string
|
892 |
*/
|
893 |
public function modified_time($time_format = '') {
|
functions/timber-term.php
CHANGED
@@ -3,15 +3,15 @@
|
|
3 |
class TimberTerm extends TimberCore
|
4 |
{
|
5 |
|
6 |
-
public $taxonomy;
|
7 |
-
public $_children;
|
8 |
public $PostClass = 'TimberPost';
|
9 |
public $TermClass = 'TimberTerm';
|
10 |
-
public $object_type = 'term';
|
11 |
|
|
|
12 |
public static $representation = 'term';
|
13 |
|
|
|
14 |
public $name;
|
|
|
15 |
|
16 |
/**
|
17 |
* @param int $tid
|
3 |
class TimberTerm extends TimberCore
|
4 |
{
|
5 |
|
|
|
|
|
6 |
public $PostClass = 'TimberPost';
|
7 |
public $TermClass = 'TimberTerm';
|
|
|
8 |
|
9 |
+
public $object_type = 'term';
|
10 |
public static $representation = 'term';
|
11 |
|
12 |
+
public $_children;
|
13 |
public $name;
|
14 |
+
public $taxonomy;
|
15 |
|
16 |
/**
|
17 |
* @param int $tid
|
functions/timber-theme.php
CHANGED
@@ -3,13 +3,13 @@
|
|
3 |
class TimberTheme extends TimberCore
|
4 |
{
|
5 |
|
|
|
6 |
public $name;
|
7 |
-
public $slug;
|
8 |
public $path;
|
9 |
-
public $uri;
|
10 |
-
public $link;
|
11 |
-
public $parent_slug;
|
12 |
public $parent;
|
|
|
|
|
|
|
13 |
|
14 |
/**
|
15 |
* @param string $slug
|
3 |
class TimberTheme extends TimberCore
|
4 |
{
|
5 |
|
6 |
+
public $link;
|
7 |
public $name;
|
|
|
8 |
public $path;
|
|
|
|
|
|
|
9 |
public $parent;
|
10 |
+
public $parent_slug;
|
11 |
+
public $slug;
|
12 |
+
public $uri;
|
13 |
|
14 |
/**
|
15 |
* @param string $slug
|
functions/{functions-twig.php → timber-twig.php}
RENAMED
@@ -22,30 +22,34 @@ class TimberTwig
|
|
22 |
|
23 |
/* debugging filters */
|
24 |
$twig->addFilter('docs', new Twig_Filter_function('twig_object_docs'));
|
25 |
-
$twig->addFilter('get_class', new Twig_Filter_Function('
|
26 |
-
$twig->addFilter('get_type', new Twig_Filter_Function('
|
27 |
-
$twig->addFilter('print_r', new Twig_Filter_Function(
|
28 |
-
|
|
|
|
|
|
|
|
|
29 |
|
30 |
/* other filters */
|
31 |
$twig->addFilter('stripshortcodes', new Twig_Filter_Function('strip_shortcodes'));
|
32 |
$twig->addFilter('array', new Twig_Filter_Function(array($this, 'to_array')));
|
33 |
$twig->addFilter('string', new Twig_Filter_Function(array($this, 'to_string')));
|
34 |
-
$twig->addFilter('excerpt', new Twig_Filter_Function('
|
35 |
$twig->addFilter('function', new Twig_Filter_Function(array($this, 'exec_function')));
|
36 |
$twig->addFilter('path', new Twig_Filter_Function('twig_get_path'));
|
37 |
$twig->addFilter('pretags', new Twig_Filter_Function(array($this, 'twig_pretags')));
|
38 |
$twig->addFilter('sanitize', new Twig_Filter_Function('sanitize_title'));
|
39 |
-
$twig->addFilter('shortcodes', new Twig_Filter_Function('
|
40 |
-
$twig->addFilter('time_ago', new Twig_Filter_Function('
|
41 |
$twig->addFilter('twitterify', new Twig_Filter_Function(array('TimberHelper', 'twitterify')));
|
42 |
$twig->addFilter('twitterfy', new Twig_Filter_Function(array('TimberHelper', 'twitterify')));
|
43 |
-
$twig->addFilter('wp_body_class', new Twig_Filter_Function('
|
44 |
$twig->addFilter('wpautop', new Twig_Filter_Function('wpautop'));
|
45 |
$twig->addFilter('relative', new Twig_Filter_Function(function ($link) {
|
46 |
return TimberURLHelper::get_rel_url($link, true);
|
47 |
}));
|
48 |
-
$twig->addFilter('date', new Twig_Filter_Function('
|
49 |
|
50 |
$twig->addFilter('truncate', new Twig_Filter_Function(function ($text, $len) {
|
51 |
return TimberHelper::trim_words($text, $len);
|
@@ -96,6 +100,15 @@ class TimberTwig
|
|
96 |
}
|
97 |
return new $TermClass($pid);
|
98 |
}));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
/* bloginfo and translate */
|
101 |
$twig->addFunction('bloginfo', new Twig_SimpleFunction('bloginfo', function ($show = '', $filter = 'raw') {
|
@@ -167,108 +180,78 @@ class TimberTwig
|
|
167 |
}
|
168 |
|
169 |
/**
|
170 |
-
* @param
|
171 |
-
* @return
|
172 |
*/
|
173 |
-
function
|
174 |
-
|
175 |
-
|
176 |
-
$
|
177 |
}
|
178 |
-
|
|
|
|
|
|
|
179 |
}
|
180 |
|
181 |
/**
|
182 |
-
* @param string $
|
183 |
-
* @param
|
184 |
-
* @return
|
185 |
*/
|
186 |
-
function
|
187 |
-
if (
|
188 |
-
$
|
189 |
}
|
190 |
-
|
191 |
-
$look_for = trailingslashit($dir) . trailingslashit(self::$dir_name) . $file;
|
192 |
-
if (file_exists($look_for)) {
|
193 |
-
return true;
|
194 |
-
}
|
195 |
-
}
|
196 |
-
return false;
|
197 |
}
|
198 |
|
199 |
-
|
200 |
|
201 |
-
/**
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
|
210 |
-
/**
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
|
218 |
-
/**
|
219 |
-
* @param mixed $this
|
220 |
-
* @return string
|
221 |
-
*/
|
222 |
-
function twig_get_type($this) {
|
223 |
-
return gettype($this);
|
224 |
}
|
225 |
|
|
|
226 |
|
227 |
-
/**
|
228 |
-
* @param int|string $from
|
229 |
-
* @param int|string $to
|
230 |
-
* @param string $format_past
|
231 |
-
* @param string $format_future
|
232 |
-
* @return string
|
233 |
-
*/
|
234 |
-
function twig_time_ago($from, $to = null, $format_past = '%s ago', $format_future = '%s from now') {
|
235 |
-
$to = $to === null ? time() : $to;
|
236 |
-
$to = is_int($to) ? $to : strtotime($to);
|
237 |
-
$from = is_int($from) ? $from : strtotime($from);
|
238 |
-
|
239 |
-
if ($from < $to) {
|
240 |
-
return sprintf($format_past, human_time_diff($from, $to));
|
241 |
-
} else {
|
242 |
-
return sprintf($format_future, human_time_diff($to, $from));
|
243 |
-
}
|
244 |
-
}
|
245 |
|
246 |
-
|
247 |
-
* @param mixed $body_classes
|
248 |
-
* @return string
|
249 |
-
*/
|
250 |
-
function twig_body_class($body_classes) {
|
251 |
-
ob_start();
|
252 |
-
if (is_array($body_classes)) {
|
253 |
-
$body_classes = explode(' ', $body_classes);
|
254 |
-
}
|
255 |
-
body_class($body_classes);
|
256 |
-
$return = ob_get_contents();
|
257 |
-
ob_end_clean();
|
258 |
-
return $return;
|
259 |
-
}
|
260 |
-
|
261 |
-
/**
|
262 |
-
* @param string $date
|
263 |
-
* @param string $format (optional)
|
264 |
-
* @return string
|
265 |
-
*/
|
266 |
-
function twig_intl_date($date, $format = null) {
|
267 |
-
if ($format === null) {
|
268 |
-
$format = get_option('date_format');
|
269 |
-
}
|
270 |
-
return date_i18n($format, strtotime($date));
|
271 |
-
}
|
272 |
|
273 |
/**
|
274 |
* @param string $string
|
@@ -276,85 +259,7 @@ function twig_intl_date($date, $format = null) {
|
|
276 |
* @return string
|
277 |
*/
|
278 |
function render_twig_string($string, $data = array()) {
|
279 |
-
$
|
280 |
-
$timber_loader->get_twig();
|
281 |
-
$loader = new Twig_Loader_String();
|
282 |
-
$twig = new Twig_Environment($loader);
|
283 |
-
return $twig->render($string, $data);
|
284 |
-
}
|
285 |
-
|
286 |
-
/**
|
287 |
-
* @param array $backtrace
|
288 |
-
* @return string
|
289 |
-
*/
|
290 |
-
function get_calling_script_dir($backtrace) {
|
291 |
-
$caller = $backtrace[0]['file'];
|
292 |
-
$pathinfo = pathinfo($caller);
|
293 |
-
$dir = $pathinfo['dirname'];
|
294 |
-
return $dir . '/';
|
295 |
}
|
296 |
|
297 |
-
//deprecated
|
298 |
-
|
299 |
-
/**
|
300 |
-
* @param int $aid
|
301 |
-
* @return string
|
302 |
-
*/
|
303 |
-
function twig_get_src_from_attachment_id($aid) {
|
304 |
-
return TimberImageHelper::get_image_path($aid);
|
305 |
-
}
|
306 |
-
|
307 |
-
/**
|
308 |
-
* @param string $url
|
309 |
-
* @return mixed
|
310 |
-
*/
|
311 |
-
function twig_get_path($url) {
|
312 |
-
$url = parse_url($url);
|
313 |
-
return $url['path'];
|
314 |
-
}
|
315 |
|
316 |
-
/**
|
317 |
-
* @param string $text
|
318 |
-
* @param int $length
|
319 |
-
* @return string
|
320 |
-
*/
|
321 |
-
function twig_make_excerpt($text, $length = 55) {
|
322 |
-
return wp_trim_words($text, $length);
|
323 |
-
}
|
324 |
-
|
325 |
-
/**
|
326 |
-
* @param array $arr
|
327 |
-
* @return mixed
|
328 |
-
*/
|
329 |
-
function twig_print_r($arr) {
|
330 |
-
return print_r($arr, true);
|
331 |
-
}
|
332 |
-
|
333 |
-
/**
|
334 |
-
* @param array $arr
|
335 |
-
* @return string
|
336 |
-
*/
|
337 |
-
function twig_print_a($arr) {
|
338 |
-
return '<pre>' . twig_object_docs($arr, true) . '</pre>';
|
339 |
-
}
|
340 |
-
|
341 |
-
/**
|
342 |
-
* @param mixed $obj
|
343 |
-
* @param bool $methods
|
344 |
-
* @return string
|
345 |
-
*/
|
346 |
-
function twig_object_docs($obj, $methods = true) {
|
347 |
-
$class = get_class($obj);
|
348 |
-
$properties = (array)$obj;
|
349 |
-
if ($methods) {
|
350 |
-
/** @var array $methods */
|
351 |
-
$methods = $obj->get_method_values();
|
352 |
-
}
|
353 |
-
$rets = array_merge($properties, $methods);
|
354 |
-
ksort($rets);
|
355 |
-
$str = print_r($rets, true);
|
356 |
-
$str = str_replace('Array', $class . ' Object', $str);
|
357 |
-
return $str;
|
358 |
-
}
|
359 |
-
|
360 |
-
new TimberTwig();
|
22 |
|
23 |
/* debugging filters */
|
24 |
$twig->addFilter('docs', new Twig_Filter_function('twig_object_docs'));
|
25 |
+
$twig->addFilter('get_class', new Twig_Filter_Function('get_class'));
|
26 |
+
$twig->addFilter('get_type', new Twig_Filter_Function('get_type'));
|
27 |
+
$twig->addFilter('print_r', new Twig_Filter_Function(function($arr){
|
28 |
+
return print_r($arr, true);
|
29 |
+
}));
|
30 |
+
$twig->addFilter('print_a', new Twig_Filter_Function(function($arr){
|
31 |
+
return '<pre>' . self::object_docs($arr, true) . '</pre>';
|
32 |
+
}));
|
33 |
|
34 |
/* other filters */
|
35 |
$twig->addFilter('stripshortcodes', new Twig_Filter_Function('strip_shortcodes'));
|
36 |
$twig->addFilter('array', new Twig_Filter_Function(array($this, 'to_array')));
|
37 |
$twig->addFilter('string', new Twig_Filter_Function(array($this, 'to_string')));
|
38 |
+
$twig->addFilter('excerpt', new Twig_Filter_Function('wp_trim_words'));
|
39 |
$twig->addFilter('function', new Twig_Filter_Function(array($this, 'exec_function')));
|
40 |
$twig->addFilter('path', new Twig_Filter_Function('twig_get_path'));
|
41 |
$twig->addFilter('pretags', new Twig_Filter_Function(array($this, 'twig_pretags')));
|
42 |
$twig->addFilter('sanitize', new Twig_Filter_Function('sanitize_title'));
|
43 |
+
$twig->addFilter('shortcodes', new Twig_Filter_Function('do_shortcode'));
|
44 |
+
$twig->addFilter('time_ago', new Twig_Filter_Function(array($this, 'time_ago')));
|
45 |
$twig->addFilter('twitterify', new Twig_Filter_Function(array('TimberHelper', 'twitterify')));
|
46 |
$twig->addFilter('twitterfy', new Twig_Filter_Function(array('TimberHelper', 'twitterify')));
|
47 |
+
$twig->addFilter('wp_body_class', new Twig_Filter_Function(array($this, 'body_class')));
|
48 |
$twig->addFilter('wpautop', new Twig_Filter_Function('wpautop'));
|
49 |
$twig->addFilter('relative', new Twig_Filter_Function(function ($link) {
|
50 |
return TimberURLHelper::get_rel_url($link, true);
|
51 |
}));
|
52 |
+
$twig->addFilter('date', new Twig_Filter_Function(array($this, 'intl_date')));
|
53 |
|
54 |
$twig->addFilter('truncate', new Twig_Filter_Function(function ($text, $len) {
|
55 |
return TimberHelper::trim_words($text, $len);
|
100 |
}
|
101 |
return new $TermClass($pid);
|
102 |
}));
|
103 |
+
$twig->addFunction(new Twig_SimpleFunction('TimberUser', function ($pid, $UserClass = 'TimberUser') {
|
104 |
+
if (is_array($pid) && !TimberHelper::is_array_assoc($pid)) {
|
105 |
+
foreach ($pid as &$p) {
|
106 |
+
$p = new $UserClass($p);
|
107 |
+
}
|
108 |
+
return $pid;
|
109 |
+
}
|
110 |
+
return new $UserClass($pid);
|
111 |
+
}));
|
112 |
|
113 |
/* bloginfo and translate */
|
114 |
$twig->addFunction('bloginfo', new Twig_SimpleFunction('bloginfo', function ($show = '', $filter = 'raw') {
|
180 |
}
|
181 |
|
182 |
/**
|
183 |
+
* @param mixed $body_classes
|
184 |
+
* @return string
|
185 |
*/
|
186 |
+
function body_class($body_classes) {
|
187 |
+
ob_start();
|
188 |
+
if (is_array($body_classes)) {
|
189 |
+
$body_classes = explode(' ', $body_classes);
|
190 |
}
|
191 |
+
body_class($body_classes);
|
192 |
+
$return = ob_get_contents();
|
193 |
+
ob_end_clean();
|
194 |
+
return $return;
|
195 |
}
|
196 |
|
197 |
/**
|
198 |
+
* @param string $date
|
199 |
+
* @param string $format (optional)
|
200 |
+
* @return string
|
201 |
*/
|
202 |
+
function intl_date($date, $format = null) {
|
203 |
+
if ($format === null) {
|
204 |
+
$format = get_option('date_format');
|
205 |
}
|
206 |
+
return date_i18n($format, strtotime($date));
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
}
|
208 |
|
209 |
+
//debug
|
210 |
|
211 |
+
/**
|
212 |
+
* @param mixed $obj
|
213 |
+
* @param bool $methods
|
214 |
+
* @return string
|
215 |
+
*/
|
216 |
+
function object_docs($obj, $methods = true) {
|
217 |
+
$class = get_class($obj);
|
218 |
+
$properties = (array)$obj;
|
219 |
+
if ($methods) {
|
220 |
+
/** @var array $methods */
|
221 |
+
$methods = $obj->get_method_values();
|
222 |
+
}
|
223 |
+
$rets = array_merge($properties, $methods);
|
224 |
+
ksort($rets);
|
225 |
+
$str = print_r($rets, true);
|
226 |
+
$str = str_replace('Array', $class . ' Object', $str);
|
227 |
+
return $str;
|
228 |
+
}
|
229 |
|
230 |
+
/**
|
231 |
+
* @param int|string $from
|
232 |
+
* @param int|string $to
|
233 |
+
* @param string $format_past
|
234 |
+
* @param string $format_future
|
235 |
+
* @return string
|
236 |
+
*/
|
237 |
+
function time_ago($from, $to = null, $format_past = '%s ago', $format_future = '%s from now') {
|
238 |
+
$to = $to === null ? time() : $to;
|
239 |
+
$to = is_int($to) ? $to : strtotime($to);
|
240 |
+
$from = is_int($from) ? $from : strtotime($from);
|
241 |
+
|
242 |
+
if ($from < $to) {
|
243 |
+
return sprintf($format_past, human_time_diff($from, $to));
|
244 |
+
} else {
|
245 |
+
return sprintf($format_future, human_time_diff($to, $from));
|
246 |
+
}
|
247 |
+
}
|
248 |
|
|
|
|
|
|
|
|
|
|
|
|
|
249 |
}
|
250 |
|
251 |
+
new TimberTwig();
|
252 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
253 |
|
254 |
+
/* deprecated */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
255 |
|
256 |
/**
|
257 |
* @param string $string
|
259 |
* @return string
|
260 |
*/
|
261 |
function render_twig_string($string, $data = array()) {
|
262 |
+
return Timber::render_string($string, $data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
}
|
264 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
265 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
functions/timber-user.php
CHANGED
@@ -3,15 +3,16 @@
|
|
3 |
class TimberUser extends TimberCore
|
4 |
{
|
5 |
|
6 |
-
public $_link;
|
7 |
public $object_type = 'user';
|
8 |
-
|
9 |
public static $representation = 'user';
|
10 |
|
|
|
|
|
11 |
public $display_name;
|
|
|
12 |
public $name;
|
13 |
public $user_nicename;
|
14 |
-
|
15 |
/**
|
16 |
* @param int|bool $uid
|
17 |
*/
|
@@ -82,6 +83,7 @@ class TimberUser extends TimberCore
|
|
82 |
}
|
83 |
$this->ID = $uid;
|
84 |
$this->id = $uid;
|
|
|
85 |
$this->import_custom();
|
86 |
}
|
87 |
}
|
3 |
class TimberUser extends TimberCore
|
4 |
{
|
5 |
|
|
|
6 |
public $object_type = 'user';
|
|
|
7 |
public static $representation = 'user';
|
8 |
|
9 |
+
public $_link;
|
10 |
+
|
11 |
public $display_name;
|
12 |
+
public $id;
|
13 |
public $name;
|
14 |
public $user_nicename;
|
15 |
+
|
16 |
/**
|
17 |
* @param int|bool $uid
|
18 |
*/
|
83 |
}
|
84 |
$this->ID = $uid;
|
85 |
$this->id = $uid;
|
86 |
+
$this->name = $this->name();
|
87 |
$this->import_custom();
|
88 |
}
|
89 |
}
|
readme.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
Contributors: jarednova
|
3 |
Tags: template engine, templates, twig
|
4 |
Requires at least: 3.7
|
5 |
-
Stable tag: 0.19.
|
6 |
Tested up to: 3.9
|
7 |
PHP version: 5.3.0 or greater
|
8 |
License: GPLv2 or later
|
@@ -16,7 +16,7 @@ Timber cleans-up your theme code so, for example, your php file can focus on bei
|
|
16 |
Once Timber is installed and activated in your plugin directory, it gives any WordPress theme the ability to take advantage of the power of Twig and other Timber features.
|
17 |
|
18 |
### Looking for docs?
|
19 |
-
* **[Project Page](http://
|
20 |
* [Timber Documentation](https://github.com/jarednova/timber/wiki/)
|
21 |
* [Twig Reference (from SensioLabs)](http://twig.sensiolabs.org/doc/templates.html)
|
22 |
_Twig is the template language powering Timber; if you need a little background on what a template language is, [Twig's homepage has an overview](http://twig.sensiolabs.org/)_
|
@@ -33,7 +33,7 @@ Nothing. Timber is meant for you to build a theme on. Like the [Starkers](https:
|
|
33 |
Timber is great for any WordPress developer who cares about writing good, maintainable code. It helps teams of designers and developers working together. At [Upstatement](http://upstatement.com) we made Timber because not everyone knows the ins-and-outs of the_loop(), WordPress codex and PHP (nor should they). With Timber your best WordPress dev can focus on building the .php files with requests from WordPress and pass the data into .twig files. Once there, designers can easily mark-up data and build out a site's look-and-feel.
|
34 |
|
35 |
#### Want to read more?
|
36 |
-
* [Timber on
|
37 |
* [Timber Overview on Tidy Repo](http://www.wpmayor.com/articles/timber-templating-language-wordpress/)
|
38 |
* ["What is WordPress Missing? A Template Language" on Torque](http://torquemag.io/what-is-wordpress-lacking-a-template-language/)
|
39 |
|
@@ -41,7 +41,11 @@ Timber is great for any WordPress developer who cares about writing good, mainta
|
|
41 |
|
42 |
== Changelog ==
|
43 |
|
44 |
-
= 0.19.
|
|
|
|
|
|
|
|
|
45 |
* Removed .git folder hiding in php-router
|
46 |
* Added support for WooCommerce and other plugins in starter theme (thanks @jamesagreenleaf)
|
47 |
* Starter theme now based on OO-style TimberSite convention
|
2 |
Contributors: jarednova
|
3 |
Tags: template engine, templates, twig
|
4 |
Requires at least: 3.7
|
5 |
+
Stable tag: 0.19.2
|
6 |
Tested up to: 3.9
|
7 |
PHP version: 5.3.0 or greater
|
8 |
License: GPLv2 or later
|
16 |
Once Timber is installed and activated in your plugin directory, it gives any WordPress theme the ability to take advantage of the power of Twig and other Timber features.
|
17 |
|
18 |
### Looking for docs?
|
19 |
+
* **[Project Page](http://upstatement.com/timber)**
|
20 |
* [Timber Documentation](https://github.com/jarednova/timber/wiki/)
|
21 |
* [Twig Reference (from SensioLabs)](http://twig.sensiolabs.org/doc/templates.html)
|
22 |
_Twig is the template language powering Timber; if you need a little background on what a template language is, [Twig's homepage has an overview](http://twig.sensiolabs.org/)_
|
33 |
Timber is great for any WordPress developer who cares about writing good, maintainable code. It helps teams of designers and developers working together. At [Upstatement](http://upstatement.com) we made Timber because not everyone knows the ins-and-outs of the_loop(), WordPress codex and PHP (nor should they). With Timber your best WordPress dev can focus on building the .php files with requests from WordPress and pass the data into .twig files. Once there, designers can easily mark-up data and build out a site's look-and-feel.
|
34 |
|
35 |
#### Want to read more?
|
36 |
+
* [Timber on GitHub](http://github.com/jarednova/timber/)
|
37 |
* [Timber Overview on Tidy Repo](http://www.wpmayor.com/articles/timber-templating-language-wordpress/)
|
38 |
* ["What is WordPress Missing? A Template Language" on Torque](http://torquemag.io/what-is-wordpress-lacking-a-template-language/)
|
39 |
|
41 |
|
42 |
== Changelog ==
|
43 |
|
44 |
+
= 0.19.2 =
|
45 |
+
* Fixed issue with {{post.author.name}}
|
46 |
+
* Bug fixes and code organization (@hsz, @jaredNova)
|
47 |
+
|
48 |
+
= 0.19.1 =
|
49 |
* Removed .git folder hiding in php-router
|
50 |
* Added support for WooCommerce and other plugins in starter theme (thanks @jamesagreenleaf)
|
51 |
* Starter theme now based on OO-style TimberSite convention
|
timber.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Timber
|
|
4 |
Plugin URI: http://timber.upstatement.com
|
5 |
Description: The WordPress Timber Library allows you to write themes using the power Twig templates
|
6 |
Author: Jared Novack + Upstatement
|
7 |
-
Version: 0.19.
|
8 |
Author URI: http://upstatement.com/
|
9 |
*/
|
10 |
|
@@ -16,7 +16,7 @@ if (file_exists($composer_autoload)){
|
|
16 |
require_once($composer_autoload);
|
17 |
}
|
18 |
|
19 |
-
require_once(__DIR__ . '/functions/
|
20 |
require_once(__DIR__ . '/functions/timber-helper.php');
|
21 |
require_once(__DIR__ . '/functions/timber-url-helper.php');
|
22 |
require_once(__DIR__ . '/functions/timber-image-helper.php');
|
4 |
Plugin URI: http://timber.upstatement.com
|
5 |
Description: The WordPress Timber Library allows you to write themes using the power Twig templates
|
6 |
Author: Jared Novack + Upstatement
|
7 |
+
Version: 0.19.2
|
8 |
Author URI: http://upstatement.com/
|
9 |
*/
|
10 |
|
16 |
require_once($composer_autoload);
|
17 |
}
|
18 |
|
19 |
+
require_once(__DIR__ . '/functions/timber-twig.php');
|
20 |
require_once(__DIR__ . '/functions/timber-helper.php');
|
21 |
require_once(__DIR__ . '/functions/timber-url-helper.php');
|
22 |
require_once(__DIR__ . '/functions/timber-image-helper.php');
|
vendor/autoload.php
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInitcef0c697444c47de03b382b296ede9e7::getLoader();
|
vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit5a0dca61483fec0916bb0b4cbcd01f05
|
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
-
spl_autoload_register(array('
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
-
spl_autoload_unregister(array('
|
25 |
|
26 |
$vendorDir = dirname(__DIR__);
|
27 |
$baseDir = dirname($vendorDir);
|
@@ -47,7 +47,7 @@ class ComposerAutoloaderInit5a0dca61483fec0916bb0b4cbcd01f05
|
|
47 |
}
|
48 |
}
|
49 |
|
50 |
-
function
|
51 |
{
|
52 |
require $file;
|
53 |
}
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInitcef0c697444c47de03b382b296ede9e7
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInitcef0c697444c47de03b382b296ede9e7', 'loadClassLoader'), true, true);
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInitcef0c697444c47de03b382b296ede9e7', 'loadClassLoader'));
|
25 |
|
26 |
$vendorDir = dirname(__DIR__);
|
27 |
$baseDir = dirname($vendorDir);
|
47 |
}
|
48 |
}
|
49 |
|
50 |
+
function composerRequirecef0c697444c47de03b382b296ede9e7($file)
|
51 |
{
|
52 |
require $file;
|
53 |
}
|