Timber - Version 1.5.2

Version Description

Fixes and improvements - Fixed a bug where multi-level menus weren't receiving proper data

Download this release

Release Info

Developer jarednova
Plugin Icon 128x128 Timber
Version 1.5.2
Comparing to
See all releases

Code changes from version 1.5.0 to 1.5.2

README.md CHANGED
@@ -80,6 +80,7 @@ Timber is great for any WordPress developer who cares about writing good, mainta
80
  #### Related Projects
81
  * [**Timber Starter Theme**](https://github.com/timber/starter-theme) The "_s" of Timber to give you an easy start to the most basic theme you can build upon and customize.
82
  * [**Timber Debug Bar**](https://github.com/timber/debug-bar-timber) Adds a debug bar panel that will show you which template is in-use and the data sent to your twig file.
 
83
  * [**TimberPhoton**](https://github.com/slimndap/TimberPhoton) Plug-in to use JetPack's free Photon image manipulation and CDN with Timber.
84
  * [**Timber CLI**](https://github.com/nclud/wp-timber-cli) A CLI for Timber.
85
  * [**Timber Sugar**](https://github.com/timber/sugar) A catch-all for goodies to use w Timber.
80
  #### Related Projects
81
  * [**Timber Starter Theme**](https://github.com/timber/starter-theme) The "_s" of Timber to give you an easy start to the most basic theme you can build upon and customize.
82
  * [**Timber Debug Bar**](https://github.com/timber/debug-bar-timber) Adds a debug bar panel that will show you which template is in-use and the data sent to your twig file.
83
+ * [**Timber Dump Extension**](https://github.com/nlemoine/timber-dump-extension) Debug output with nice formatting.
84
  * [**TimberPhoton**](https://github.com/slimndap/TimberPhoton) Plug-in to use JetPack's free Photon image manipulation and CDN with Timber.
85
  * [**Timber CLI**](https://github.com/nclud/wp-timber-cli) A CLI for Timber.
86
  * [**Timber Sugar**](https://github.com/timber/sugar) A catch-all for goodies to use w Timber.
lib/Image/Operation/Letterbox.php CHANGED
@@ -36,7 +36,11 @@ class Letterbox extends ImageOperation {
36
  * (ex: my-awesome-pic-lbox-300x200-FF3366.jpg)
37
  */
38
  public function filename( $src_filename, $src_extension ) {
39
- $color = str_replace('#', '', $this->color);
 
 
 
 
40
  $newbase = $src_filename.'-lbox-'.$this->w.'x'.$this->h.'-'.$color;
41
  $new_name = $newbase.'.'.$src_extension;
42
  return $new_name;
@@ -57,8 +61,14 @@ class Letterbox extends ImageOperation {
57
  $h = $this->h;
58
 
59
  $bg = imagecreatetruecolor($w, $h);
60
- $c = self::hexrgb($this->color);
61
- $bgColor = imagecolorallocate($bg, $c['red'], $c['green'], $c['blue']);
 
 
 
 
 
 
62
  imagefill($bg, 0, 0, $bgColor);
63
  $image = wp_get_image_editor($load_filename);
64
  if ( !is_wp_error($image) ) {
36
  * (ex: my-awesome-pic-lbox-300x200-FF3366.jpg)
37
  */
38
  public function filename( $src_filename, $src_extension ) {
39
+ $color = $this->color;
40
+ if ( !$color ) {
41
+ $color = 'trans';
42
+ }
43
+ $color = str_replace('#', '', $color);
44
  $newbase = $src_filename.'-lbox-'.$this->w.'x'.$this->h.'-'.$color;
45
  $new_name = $newbase.'.'.$src_extension;
46
  return $new_name;
61
  $h = $this->h;
62
 
63
  $bg = imagecreatetruecolor($w, $h);
64
+ if( !$this->color ) {
65
+ imagesavealpha($bg, true);
66
+ $bgColor = imagecolorallocatealpha($bg, 0, 0, 0, 127);
67
+ } else {
68
+ $c = self::hexrgb($this->color);
69
+ $bgColor = imagecolorallocate($bg, $c['red'], $c['green'], $c['blue']);
70
+ }
71
+
72
  imagefill($bg, 0, 0, $bgColor);
73
  $image = wp_get_image_editor($load_filename);
74
  if ( !is_wp_error($image) ) {
lib/ImageHelper.php CHANGED
@@ -152,7 +152,7 @@ class ImageHelper {
152
  * @param bool $force
153
  * @return string
154
  */
155
- public static function letterbox( $src, $w, $h, $color = '#000000', $force = false ) {
156
  $op = new Letterbox($w, $h, $color);
157
  return self::_operate($src, $op, $force);
158
  }
152
  * @param bool $force
153
  * @return string
154
  */
155
+ public static function letterbox( $src, $w, $h, $color = false, $force = false ) {
156
  $op = new Letterbox($w, $h, $color);
157
  return self::_operate($src, $op, $force);
158
  }
lib/Menu.php CHANGED
@@ -5,46 +5,6 @@ namespace Timber;
5
  use Timber\Core;
6
  use Timber\Post;
7
 
8
- /**
9
- * In Timber, you can use TimberMenu() to make a standard Wordpress menu available to the Twig template as an object you can loop through. And once the menu becomes available to the context, you can get items from it in a way that is a little smoother and more versatile than Wordpress's wp_nav_menu. (You need never again rely on a crazy "Walker Function!"). The first thing to do is to initialize the menu using TimberMenu(). This will make the menu available as an object to work with in the context. (TimberMenu can include a Wordpress menu slug or ID, or it can be sent with no parameter--and guess the right menu.)
10
- * @example
11
- * ```php
12
- * # functions.php
13
- * add_filter('timber/context', 'add_to_context');
14
- * function add_to_context($data){
15
- * // So here you are adding data to Timber's context object, i.e...
16
- * $data['foo'] = 'I am some other typical value set in your functions.php file, unrelated to the menu';
17
- * // Now, in similar fashion, you add a Timber menu and send it along to the context.
18
- * $data['menu'] = new TimberMenu(); // This is where you can also send a WordPress menu slug or ID
19
- * return $data;
20
- * }
21
- *
22
- * # index.php (or any PHP file)
23
- * // Since you want a menu object available on every page, I added it to the universal Timber context via the functions.php file. You could also this in each PHP file if you find that too confusing.
24
- * $context = Timber::get_context();
25
- * $context['posts'] = Timber::get_posts();
26
- * Timber::render('index.twig', $context);
27
- * ?>
28
- * ```
29
- *
30
- * ```twig
31
- * <nav>
32
- * <ul class="main-nav">
33
- * {% for item in menu.get_items %}
34
- * <li class="nav-main-item {{item.classes | join(' ')}}"><a class="nav-main-link" href="{{item.link}}">{{item.title}}</a>
35
- * {% if item.get_children %}
36
- * <ul class="nav-drop">
37
- * {% for child in item.get_children %}
38
- * <li class="nav-drop-item"><a href="{{child.link}}">{{child.title}}</a></li>
39
- * {% endfor %}
40
- * </ul>
41
- * {% endif %}
42
- * </li>
43
- * {% endfor %}
44
- * </ul>
45
- * </nav>
46
- * ```
47
- */
48
  class Menu extends Core {
49
 
50
  public $MenuItemClass = 'Timber\MenuItem';
@@ -52,32 +12,46 @@ class Menu extends Core {
52
 
53
  /**
54
  * @api
55
- * @var TimberMenuItem[]|null $items you need to iterate through
56
  */
57
  public $items = null;
 
58
  /**
59
  * @api
60
- * @var integer $id the ID# of the menu, corresponding to the wp_terms table
61
  */
62
  public $id;
63
- public $ID;
64
  /**
65
  * @api
66
- * @var string $name of the menu (ex: `Main Navigation`)
67
  */
68
- public $name;
 
69
  /**
70
- * @var integer $id the ID# of the menu, corresponding to the wp_terms table
 
71
  */
72
  public $term_id;
 
 
 
 
 
 
 
73
  /**
74
  * @api
75
- * @var string $name of the menu (ex: `Main Navigation`)
76
  */
77
  public $title;
78
 
79
  /**
80
- * @param integer|string $slug
 
 
 
 
81
  */
82
  public function __construct( $slug = 0 ) {
83
  $menu_id = false;
@@ -154,7 +128,7 @@ class Menu extends Core {
154
  if ( function_exists('wpml_object_id_filter') ) {
155
  $menu_id = wpml_object_id_filter($locations[$slug], 'nav_menu');
156
  }
157
-
158
  return $menu_id;
159
  }
160
  }
@@ -186,9 +160,12 @@ class Menu extends Core {
186
  }
187
 
188
  /**
189
- * @param array $menu_items
190
- * @param int $parent_id
191
- * @return TimberMenuItem|null
 
 
 
192
  */
193
  public function find_parent_item_in_menu( $menu_items, $parent_id ) {
194
  foreach ( $menu_items as &$item ) {
@@ -208,7 +185,7 @@ class Menu extends Core {
208
  $menu = array();
209
  foreach ( $items as $item ) {
210
  if ( isset($item->title) ) {
211
- //items from wp can come with a $title property which conflicts with methods
212
  $item->__title = $item->title;
213
  unset($item->title);
214
  }
@@ -235,12 +212,25 @@ class Menu extends Core {
235
  }
236
 
237
  /**
238
- * @return array
 
 
 
 
 
 
 
 
 
 
 
 
239
  */
240
  public function get_items() {
241
- if ( is_array($this->items) ) {
242
  return $this->items;
243
  }
 
244
  return array();
245
  }
246
  }
5
  use Timber\Core;
6
  use Timber\Post;
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  class Menu extends Core {
9
 
10
  public $MenuItemClass = 'Timber\MenuItem';
12
 
13
  /**
14
  * @api
15
+ * @var array|null Array of `Timber\Menu` objects you can to iterate through.
16
  */
17
  public $items = null;
18
+
19
  /**
20
  * @api
21
+ * @var integer The ID of the menu, corresponding to the wp_terms table.
22
  */
23
  public $id;
24
+
25
  /**
26
  * @api
27
+ * @var integer The ID of the menu, corresponding to the wp_terms table.
28
  */
29
+ public $ID;
30
+
31
  /**
32
+ * @api
33
+ * @var integer The ID of the menu, corresponding to the wp_terms table.
34
  */
35
  public $term_id;
36
+
37
+ /**
38
+ * @api
39
+ * @var string The name of the menu (ex: `Main Navigation`).
40
+ */
41
+ public $name;
42
+
43
  /**
44
  * @api
45
+ * @var string The name of the menu (ex: `Main Navigation`).
46
  */
47
  public $title;
48
 
49
  /**
50
+ * Initialize a menu.
51
+ *
52
+ * @param int|string $slug A menu slug, the term ID of the menu, the full name from the admin
53
+ * menu, the slug of theregistered location or nothing. Passing nothing
54
+ * is good if you only have one menu. Timber will grab what it finds.
55
  */
56
  public function __construct( $slug = 0 ) {
57
  $menu_id = false;
128
  if ( function_exists('wpml_object_id_filter') ) {
129
  $menu_id = wpml_object_id_filter($locations[$slug], 'nav_menu');
130
  }
131
+
132
  return $menu_id;
133
  }
134
  }
160
  }
161
 
162
  /**
163
+ * Find a parent menu item in a set of menu items.
164
+ *
165
+ * @api
166
+ * @param array $menu_items An array of menu items.
167
+ * @param int $parent_id The parent ID to look for.
168
+ * @return \Timber\MenuItem|bool A menu item. False if no parent was found.
169
  */
170
  public function find_parent_item_in_menu( $menu_items, $parent_id ) {
171
  foreach ( $menu_items as &$item ) {
185
  $menu = array();
186
  foreach ( $items as $item ) {
187
  if ( isset($item->title) ) {
188
+ // Items from WordPress can come with a $title property which conflicts with methods
189
  $item->__title = $item->title;
190
  unset($item->title);
191
  }
212
  }
213
 
214
  /**
215
+ * Get menu items.
216
+ *
217
+ * Instead of using this function, you can use the `$items` property directly to get the items
218
+ * for a menu.
219
+ *
220
+ * @api
221
+ * @example
222
+ * ```twig
223
+ * {% for item in menu.get_items %}
224
+ * <a href="{{ item.link }}">{{ item.title }}</a>
225
+ * {% endfor %}
226
+ * ```
227
+ * @return array Array of `Timber\MenuItem` objects. Empty array if no items could be found.
228
  */
229
  public function get_items() {
230
+ if ( is_array( $this->items ) ) {
231
  return $this->items;
232
  }
233
+
234
  return array();
235
  }
236
  }
lib/MenuItem.php CHANGED
@@ -8,9 +8,22 @@ use Timber\CoreInterface;
8
  use Timber\URLHelper;
9
 
10
  class MenuItem extends Core implements CoreInterface {
 
 
 
 
 
11
 
12
- public $children;
 
 
 
13
  public $has_child_class = false;
 
 
 
 
 
14
  public $classes = array();
15
  public $class = '';
16
  public $level = 0;
@@ -19,6 +32,34 @@ class MenuItem extends Core implements CoreInterface {
19
 
20
  public $PostClass = 'Timber\Post';
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  protected $_name;
23
  protected $_menu_item_object_id;
24
  protected $_menu_item_url;
@@ -26,8 +67,7 @@ class MenuItem extends Core implements CoreInterface {
26
  protected $master_object;
27
 
28
  /**
29
- *
30
- *
31
  * @param array|object $data
32
  */
33
  public function __construct( $data ) {
@@ -43,15 +83,9 @@ class MenuItem extends Core implements CoreInterface {
43
  }
44
 
45
  /**
46
- * @return string the label for the menu item
47
- */
48
- public function __toString() {
49
- return $this->name();
50
- }
51
-
52
- /**
53
- * add a class the menu item should have
54
- * @param string $class_name to be added
55
  */
56
  public function add_class( $class_name ) {
57
  $this->classes[] = $class_name;
@@ -59,9 +93,10 @@ class MenuItem extends Core implements CoreInterface {
59
  }
60
 
61
  /**
62
- * The label for the menu item
 
63
  * @api
64
- * @return string
65
  */
66
  public function name() {
67
  if ( $title = $this->title() ) {
@@ -74,18 +109,35 @@ class MenuItem extends Core implements CoreInterface {
74
  }
75
 
76
  /**
77
- * The slug for the menu item
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  * @api
79
  * @example
80
  * ```twig
81
  * <ul>
82
  * {% for item in menu.items %}
83
- * <li class="{{item.slug}}">
84
- * <a href="{{item.link}}">{{item.name}}</a>
85
  * </li>
86
  * {% endfor %}
87
  * </ul>
88
- * @return string the slug of the menu item kinda-like-this
 
89
  */
90
  public function slug() {
91
  if ( !isset($this->master_object) ) {
@@ -99,7 +151,7 @@ class MenuItem extends Core implements CoreInterface {
99
 
100
  /**
101
  * @internal
102
- * @return mixed whatever object (Post, Term, etc.) the menu item represents
103
  */
104
  protected function get_master_object() {
105
  if ( isset($this->_menu_item_object_id) ) {
@@ -108,51 +160,51 @@ class MenuItem extends Core implements CoreInterface {
108
  }
109
 
110
  /**
 
 
111
  * @internal
112
- * @see TimberMenuItem::link
113
- * @deprecated 1.0
114
  * @codeCoverageIgnore
115
- * @return string an absolute URL http://example.org/my-page
116
  */
117
  public function get_link() {
118
  return $this->link();
119
  }
120
 
121
  /**
 
 
122
  * @internal
123
  * @codeCoverageIgnore
124
- * @see TimberMenuItem::path()
125
- * @deprecated 1.0
126
- * @return string a relative url /my-page
127
  */
128
  public function get_path() {
129
  return $this->path();
130
  }
131
 
132
  /**
 
133
  *
134
- *
135
- * @param TimberMenuItem $item
136
  */
137
  public function add_child( $item ) {
138
  if ( !$this->has_child_class ) {
139
  $this->add_class('menu-item-has-children');
140
  $this->has_child_class = true;
141
  }
142
- if ( !isset($this->children) ) {
143
- $this->children = array();
144
- }
145
  $this->children[] = $item;
146
  $item->level = $this->level + 1;
147
- if ( $item->children ) {
148
  $this->update_child_levels();
149
  }
150
  }
151
 
152
  /**
153
- *
154
  * @internal
155
- * @return boolean|null
156
  */
157
  public function update_child_levels() {
158
  if ( is_array($this->children) ) {
@@ -165,9 +217,11 @@ class MenuItem extends Core implements CoreInterface {
165
  }
166
 
167
  /**
168
- * Imports the classes to be used in CSS
 
169
  * @internal
170
- * @param array|object $data
 
171
  */
172
  public function import_classes( $data ) {
173
  if ( is_array($data) ) {
@@ -180,9 +234,21 @@ class MenuItem extends Core implements CoreInterface {
180
  }
181
 
182
  /**
 
 
 
 
183
  *
184
  * @internal
185
- * @return array|bool
 
 
 
 
 
 
 
 
186
  */
187
  public function get_children() {
188
  if ( isset($this->children) ) {
@@ -192,13 +258,17 @@ class MenuItem extends Core implements CoreInterface {
192
  }
193
 
194
  /**
195
- * Checks to see if the menu item is an external link so if my site is `example.org`, `google.com/whatever` is an external link. Helpful when creating rules for the target of a link
 
 
 
 
196
  * @api
197
  * @example
198
  * ```twig
199
  * <a href="{{ item.link }}" target="{{ item.is_external ? '_blank' : '_self' }}">
200
  * ```
201
- * @return bool
202
  */
203
  public function is_external() {
204
  if ( $this->type() != 'custom' ) {
@@ -208,17 +278,33 @@ class MenuItem extends Core implements CoreInterface {
208
  }
209
 
210
  /**
211
- * Return the type of the menu item
 
 
 
 
 
 
212
  * @since 1.0.4
213
- * @return string
214
  */
215
  public function type() {
216
  return $this->_menu_item_type;
217
  }
218
 
219
  /**
220
- * @param string $key lookup key
221
- * @return mixed whatever value is storied in the database
 
 
 
 
 
 
 
 
 
 
222
  */
223
  public function meta( $key ) {
224
  if ( is_object($this->menu_object) && method_exists($this->menu_object, 'meta') ) {
@@ -232,25 +318,39 @@ class MenuItem extends Core implements CoreInterface {
232
  /* Aliases */
233
 
234
  /**
235
- * Get the child [TimberMenuItems](#TimberMenuItem)s of a [TimberMenuItem](#TimberMenuItem)
 
236
  * @api
237
- * @return array|bool
 
 
 
 
 
 
 
 
238
  */
239
  public function children() {
240
  return $this->get_children();
241
  }
242
 
243
  /**
244
- * Checks to see if a link is external, helpful when creating rules for the target of a link
245
- * @see TimberMenuItem::is_external
246
- * @return bool
 
 
 
 
247
  */
248
  public function external() {
249
  return $this->is_external();
250
  }
251
 
252
  /**
253
- * Get the full link to a Menu Item
 
254
  * @api
255
  * @example
256
  * ```twig
@@ -258,7 +358,7 @@ class MenuItem extends Core implements CoreInterface {
258
  * <li><a href="{{ item.link }}">{{ item.title }}</a></li>
259
  * {% endfor %}
260
  * ```
261
- * @return string a full URL like http://mysite.com/thing/
262
  */
263
  public function link() {
264
  if ( !isset($this->url) || !$this->url ) {
@@ -272,57 +372,64 @@ class MenuItem extends Core implements CoreInterface {
272
  }
273
 
274
  /**
275
- * Gets the link a menu item points at
 
276
  * @internal
277
- * @deprecated since 0.21.7 use link instead
278
- * @see link()
279
  * @codeCoverageIgnore
280
- * @return string a full URL like http://mysite.com/thing/
281
  */
282
  public function permalink() {
283
- Helper::warn('{{item.permalink}} is deprecated, use {{item.link}} instead');
284
  return $this->link();
285
  }
286
 
287
  /**
288
- * Return the relative path of a Menu Item's link
 
 
289
  * @example
290
  * ```twig
291
  * {% for item in menu.items %}
292
  * <li><a href="{{ item.path }}">{{ item.title }}</a></li>
293
  * {% endfor %}
294
  * ```
295
- * @return string the path of a URL like /foo
296
  */
297
  public function path() {
298
  return URLHelper::get_rel_url($this->link());
299
  }
300
 
301
  /**
302
- * Gets the public label for the menu item
 
 
303
  * @example
304
  * ```twig
305
  * {% for item in menu.items %}
306
  * <li><a href="{{ item.link }}">{{ item.title }}</a></li>
307
  * {% endfor %}
308
  * ```
309
- * @return string the public label like Foo
310
  */
311
  public function title() {
312
  if ( isset($this->__title) ) {
313
  return $this->__title;
314
  }
315
  }
316
-
317
  /**
318
- * Gets the post thumbnail image object
 
 
319
  * @example
320
  * ```twig
321
  * {% for item in menu.items %}
322
  * <li><a href="{{ item.link }}"><img src="{{ item.thumbnail }}"/></a></li>
323
  * {% endfor %}
324
  * ```
325
- * @return string the public thumbnail url
326
  */
327
  public function thumbnail() {
328
  if ( $this->menu_object && method_exists($this->menu_object, 'thumbnail')) {
8
  use Timber\URLHelper;
9
 
10
  class MenuItem extends Core implements CoreInterface {
11
+ /**
12
+ * @api
13
+ * @var array Array of children of a menu item. Empty if there are no child menu items.
14
+ */
15
+ public $children = array();
16
 
17
+ /**
18
+ * @api
19
+ * @var bool Whether the menu item has a `menu-item-has-children` CSS class.
20
+ */
21
  public $has_child_class = false;
22
+
23
+ /**
24
+ * @api
25
+ * @var array Array of class names.
26
+ */
27
  public $classes = array();
28
  public $class = '';
29
  public $level = 0;
32
 
33
  public $PostClass = 'Timber\Post';
34
 
35
+ /**
36
+ * Inherited property. Listed here to make it available in the documentation.
37
+ *
38
+ * @api
39
+ * @see _wp_menu_item_classes_by_context()
40
+ * @var bool Whether the menu item links to the currently displayed page.
41
+ */
42
+ public $current;
43
+
44
+ /**
45
+ * Inherited property. Listed here to make it available in the documentation.
46
+ *
47
+ * @api
48
+ * @see _wp_menu_item_classes_by_context()
49
+ * @var bool Whether the menu item refers to the parent item of the currently displayed page.
50
+ */
51
+ public $current_item_parent;
52
+
53
+ /**
54
+ * Inherited property. Listed here to make it available in the documentation.
55
+ *
56
+ * @api
57
+ * @see _wp_menu_item_classes_by_context()
58
+ * @var bool Whether the menu item refers to an ancestor (including direct parent) of the
59
+ * currently displayed page.
60
+ */
61
+ public $current_item_ancestor;
62
+
63
  protected $_name;
64
  protected $_menu_item_object_id;
65
  protected $_menu_item_url;
67
  protected $master_object;
68
 
69
  /**
70
+ * @internal
 
71
  * @param array|object $data
72
  */
73
  public function __construct( $data ) {
83
  }
84
 
85
  /**
86
+ * Add a CSS class the menu item should have.
87
+ *
88
+ * @param string $class_name CSS class name to be added.
 
 
 
 
 
 
89
  */
90
  public function add_class( $class_name ) {
91
  $this->classes[] = $class_name;
93
  }
94
 
95
  /**
96
+ * Get the label for the menu item.
97
+ *
98
  * @api
99
+ * @return string The label for the menu item.
100
  */
101
  public function name() {
102
  if ( $title = $this->title() ) {
109
  }
110
 
111
  /**
112
+ * Magic method to get the label for the menu item.
113
+ *
114
+ * @api
115
+ * @example
116
+ * ```twig
117
+ * <a href="{{ item.link }}">{{ item }}</a>
118
+ * ```
119
+ * @see \Timber\MenuItem::name()
120
+ * @return string The label for the menu item.
121
+ */
122
+ public function __toString() {
123
+ return $this->name();
124
+ }
125
+
126
+ /**
127
+ * Get the slug for the menu item.
128
+ *
129
  * @api
130
  * @example
131
  * ```twig
132
  * <ul>
133
  * {% for item in menu.items %}
134
+ * <li class="{{ item.slug }}">
135
+ * <a href="{{ item.link }}">{{ item.name }}</a>
136
  * </li>
137
  * {% endfor %}
138
  * </ul>
139
+ * ```
140
+ * @return string The URL-safe slug of the menu item.
141
  */
142
  public function slug() {
143
  if ( !isset($this->master_object) ) {
151
 
152
  /**
153
  * @internal
154
+ * @return mixed Whatever object (Post, Term, etc.) the menu item represents.
155
  */
156
  protected function get_master_object() {
157
  if ( isset($this->_menu_item_object_id) ) {
160
  }
161
 
162
  /**
163
+ * Get link.
164
+ *
165
  * @internal
166
+ * @see \Timber\MenuItem::link()
167
+ * @deprecated since 1.0
168
  * @codeCoverageIgnore
169
+ * @return string An absolute URL, e.g. `http://example.org/my-page`.
170
  */
171
  public function get_link() {
172
  return $this->link();
173
  }
174
 
175
  /**
176
+ * Get path.
177
+ *
178
  * @internal
179
  * @codeCoverageIgnore
180
+ * @see \Timber\MenuItem::path()
181
+ * @deprecated since 1.0
182
+ * @return string A relative URL, e.g. `/my-page`.
183
  */
184
  public function get_path() {
185
  return $this->path();
186
  }
187
 
188
  /**
189
+ * Add a new `Timber\MenuItem` object as a child of this menu item.
190
  *
191
+ * @param \Timber\MenuItem $item The menu item to add.
 
192
  */
193
  public function add_child( $item ) {
194
  if ( !$this->has_child_class ) {
195
  $this->add_class('menu-item-has-children');
196
  $this->has_child_class = true;
197
  }
 
 
 
198
  $this->children[] = $item;
199
  $item->level = $this->level + 1;
200
+ if ( count($this->children) ) {
201
  $this->update_child_levels();
202
  }
203
  }
204
 
205
  /**
 
206
  * @internal
207
+ * @return bool|null
208
  */
209
  public function update_child_levels() {
210
  if ( is_array($this->children) ) {
217
  }
218
 
219
  /**
220
+ * Imports the classes to be used in CSS.
221
+ *
222
  * @internal
223
+ *
224
+ * @param array|object $data
225
  */
226
  public function import_classes( $data ) {
227
  if ( is_array($data) ) {
234
  }
235
 
236
  /**
237
+ * Get children of a menu item.
238
+ *
239
+ * You can also directly access the children through the `$children` property (`item.children`
240
+ * in Twig).
241
  *
242
  * @internal
243
+ * @example
244
+ * ```twig
245
+ * {% for child in item.get_children %}
246
+ * <li class="nav-drop-item">
247
+ * <a href="{{ child.link }}">{{ child.title }}</a>
248
+ * </li>
249
+ * {% endfor %}
250
+ * ```
251
+ * @return array|bool Array of children of a menu item. Empty if there are no child menu items.
252
  */
253
  public function get_children() {
254
  if ( isset($this->children) ) {
258
  }
259
 
260
  /**
261
+ * Checks to see if the menu item is an external link.
262
+ *
263
+ * If your site is `example.org`, then `google.com/whatever` is an external link. This is
264
+ * helpful when you want to create rules for the target of a link.
265
+ *
266
  * @api
267
  * @example
268
  * ```twig
269
  * <a href="{{ item.link }}" target="{{ item.is_external ? '_blank' : '_self' }}">
270
  * ```
271
+ * @return bool Whether the link is external or not.
272
  */
273
  public function is_external() {
274
  if ( $this->type() != 'custom' ) {
278
  }
279
 
280
  /**
281
+ * Get the type of the menu item.
282
+ *
283
+ * Depending on what is the menu item links to. Can be `post_type` for posts, pages and custom
284
+ * posts, `post_type_archive` for post type archive pages, `taxonomy` for terms or `custom` for
285
+ * custom links.
286
+ *
287
+ * @api
288
  * @since 1.0.4
289
+ * @return string The type of the menu item.
290
  */
291
  public function type() {
292
  return $this->_menu_item_type;
293
  }
294
 
295
  /**
296
+ * Get a meta value of the menu item.
297
+ *
298
+ * Plugins like Advanced Custom Fields allow you to set custom fields for menu items. With this
299
+ * method you can retrieve the value of these.
300
+ *
301
+ * @example
302
+ * ```twig
303
+ * <a class="icon-{{ item.meta('icon') }}" href="{{ item.link }}">{{ item.title }}</a>
304
+ * ```
305
+ * @api
306
+ * @param string $key The meta key to get the value for.
307
+ * @return mixed Whatever value is stored in the database.
308
  */
309
  public function meta( $key ) {
310
  if ( is_object($this->menu_object) && method_exists($this->menu_object, 'meta') ) {
318
  /* Aliases */
319
 
320
  /**
321
+ * Get the child menu items of a `Timber\MenuItem`.
322
+ *
323
  * @api
324
+ * @example
325
+ * ```twig
326
+ * {% for child in item.children %}
327
+ * <li class="nav-drop-item">
328
+ * <a href="{{ child.link }}">{{ child.title }}</a>
329
+ * </li>
330
+ * {% endfor %}
331
+ * ```
332
+ * @return array|bool Array of children of a menu item. Empty if there are no child menu items.
333
  */
334
  public function children() {
335
  return $this->get_children();
336
  }
337
 
338
  /**
339
+ * Check if a link is external.
340
+ *
341
+ * This is helpful when creating rules for the target of a link.
342
+ *
343
+ * @internal
344
+ * @see \Timber\MenuItem::is_external()
345
+ * @return bool Whether the link is external or not.
346
  */
347
  public function external() {
348
  return $this->is_external();
349
  }
350
 
351
  /**
352
+ * Get the full link to a menu item.
353
+ *
354
  * @api
355
  * @example
356
  * ```twig
358
  * <li><a href="{{ item.link }}">{{ item.title }}</a></li>
359
  * {% endfor %}
360
  * ```
361
+ * @return string A full URL, like `http://mysite.com/thing/`.
362
  */
363
  public function link() {
364
  if ( !isset($this->url) || !$this->url ) {
372
  }
373
 
374
  /**
375
+ * Get the link the menu item points at.
376
+ *
377
  * @internal
378
+ * @deprecated since 0.21.7 Use link method instead.
379
+ * @see \Timber\MenuItem::link()
380
  * @codeCoverageIgnore
381
+ * @return string A full URL, like `http://mysite.com/thing/`.
382
  */
383
  public function permalink() {
384
+ Helper::warn( '{{ item.permalink }} is deprecated, use {{ item.link }} instead' );
385
  return $this->link();
386
  }
387
 
388
  /**
389
+ * Get the relative path of the menu item’s link.
390
+ *
391
+ * @api
392
  * @example
393
  * ```twig
394
  * {% for item in menu.items %}
395
  * <li><a href="{{ item.path }}">{{ item.title }}</a></li>
396
  * {% endfor %}
397
  * ```
398
+ * @return string The path of a URL, like `/foo`.
399
  */
400
  public function path() {
401
  return URLHelper::get_rel_url($this->link());
402
  }
403
 
404
  /**
405
+ * Get the public label for the menu item.
406
+ *
407
+ * @api
408
  * @example
409
  * ```twig
410
  * {% for item in menu.items %}
411
  * <li><a href="{{ item.link }}">{{ item.title }}</a></li>
412
  * {% endfor %}
413
  * ```
414
+ * @return string The public label, like "Foo".
415
  */
416
  public function title() {
417
  if ( isset($this->__title) ) {
418
  return $this->__title;
419
  }
420
  }
421
+
422
  /**
423
+ * Get the featured image of the post associated with the menu item.
424
+ *
425
+ * @api
426
  * @example
427
  * ```twig
428
  * {% for item in menu.items %}
429
  * <li><a href="{{ item.link }}"><img src="{{ item.thumbnail }}"/></a></li>
430
  * {% endfor %}
431
  * ```
432
+ * @return \Timber\Image|null The featured image object.
433
  */
434
  public function thumbnail() {
435
  if ( $this->menu_object && method_exists($this->menu_object, 'thumbnail')) {
lib/Theme.php CHANGED
@@ -31,6 +31,12 @@ class Theme extends Core {
31
  */
32
  public $name;
33
 
 
 
 
 
 
 
34
  /**
35
  * @api
36
  * @var TimberTheme|bool the TimberTheme object for the parent theme (if it exists), false otherwise
@@ -84,6 +90,7 @@ class Theme extends Core {
84
  protected function init( $slug = null ) {
85
  $this->theme = wp_get_theme($slug);
86
  $this->name = $this->theme->get('Name');
 
87
  $this->slug = $this->theme->get_stylesheet();
88
 
89
  $this->uri = $this->theme->get_template_directory_uri();
31
  */
32
  public $name;
33
 
34
+ /**
35
+ * @api
36
+ * @var string the version of the theme (ex: `1.2.3`)
37
+ */
38
+ public $version;
39
+
40
  /**
41
  * @api
42
  * @var TimberTheme|bool the TimberTheme object for the parent theme (if it exists), false otherwise
90
  protected function init( $slug = null ) {
91
  $this->theme = wp_get_theme($slug);
92
  $this->name = $this->theme->get('Name');
93
+ $this->version = $this->theme->get('Version');
94
  $this->slug = $this->theme->get_stylesheet();
95
 
96
  $this->uri = $this->theme->get_template_directory_uri();
lib/Twig.php CHANGED
@@ -68,15 +68,8 @@ class Twig {
68
  return new $ImageClass($pid);
69
  } ));
70
 
71
- $twig->addFunction(new Twig_Function('TimberTerm', function( $pid, $TermClass = 'Timber\Term' ) {
72
- if ( is_array($pid) && !Helper::is_array_assoc($pid) ) {
73
- foreach ( $pid as &$p ) {
74
- $p = new $TermClass($p);
75
- }
76
- return $pid;
77
- }
78
- return new $TermClass($pid);
79
- } ));
80
  $twig->addFunction(new Twig_Function('TimberUser', function( $pid, $UserClass = 'Timber\User' ) {
81
  if ( is_array($pid) && !Helper::is_array_assoc($pid) ) {
82
  foreach ( $pid as &$p ) {
@@ -106,15 +99,7 @@ class Twig {
106
  }
107
  return new $ImageClass($pid);
108
  } ));
109
- $twig->addFunction(new Twig_Function('Term', function( $pid, $TermClass = 'Timber\Term' ) {
110
- if ( is_array($pid) && !Helper::is_array_assoc($pid) ) {
111
- foreach ( $pid as &$p ) {
112
- $p = new $TermClass($p);
113
- }
114
- return $pid;
115
- }
116
- return new $TermClass($pid);
117
- } ));
118
  $twig->addFunction(new Twig_Function('User', function( $pid, $UserClass = 'Timber\User' ) {
119
  if ( is_array($pid) && !Helper::is_array_assoc($pid) ) {
120
  foreach ( $pid as &$p ) {
@@ -163,6 +148,50 @@ class Twig {
163
  return $twig;
164
  }
165
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
  /**
167
  *
168
  *
@@ -187,7 +216,7 @@ class Twig {
187
  $twig->addFilter(new \Twig_SimpleFilter('stripshortcodes', 'strip_shortcodes'));
188
  $twig->addFilter(new \Twig_SimpleFilter('array', array($this, 'to_array')));
189
  $twig->addFilter(new \Twig_SimpleFilter('excerpt', 'wp_trim_words'));
190
- $twig->addFilter(new \Twig_SimpleFilter('excerpt_chars', array('Timber\TextHelper','trim_characters')));
191
  $twig->addFilter(new \Twig_SimpleFilter('function', array($this, 'exec_function')));
192
  $twig->addFilter(new \Twig_SimpleFilter('pretags', array($this, 'twig_pretags')));
193
  $twig->addFilter(new \Twig_SimpleFilter('sanitize', 'sanitize_title'));
@@ -234,18 +263,18 @@ class Twig {
234
  public function add_timber_escapers( $twig ) {
235
 
236
  $twig->getExtension('Twig_Extension_Core')->setEscaper('esc_url', function( \Twig_Environment $env, $string ) {
237
- return esc_url( $string );
238
  });
239
  $twig->getExtension('Twig_Extension_Core')->setEscaper('wp_kses_post', function( \Twig_Environment $env, $string ) {
240
- return wp_kses_post( $string );
241
  });
242
 
243
  $twig->getExtension('Twig_Extension_Core')->setEscaper('esc_html', function( \Twig_Environment $env, $string ) {
244
- return esc_html( $string );
245
  });
246
 
247
  $twig->getExtension('Twig_Extension_Core')->setEscaper('esc_js', function( \Twig_Environment $env, $string ) {
248
- return esc_js( $string );
249
  });
250
 
251
  return $twig;
68
  return new $ImageClass($pid);
69
  } ));
70
 
71
+ $twig->addFunction(new Twig_Function('TimberTerm', array($this, 'handle_term_object')));
72
+
 
 
 
 
 
 
 
73
  $twig->addFunction(new Twig_Function('TimberUser', function( $pid, $UserClass = 'Timber\User' ) {
74
  if ( is_array($pid) && !Helper::is_array_assoc($pid) ) {
75
  foreach ( $pid as &$p ) {
99
  }
100
  return new $ImageClass($pid);
101
  } ));
102
+ $twig->addFunction(new Twig_Function('Term', array($this, 'handle_term_object')));
 
 
 
 
 
 
 
 
103
  $twig->addFunction(new Twig_Function('User', function( $pid, $UserClass = 'Timber\User' ) {
104
  if ( is_array($pid) && !Helper::is_array_assoc($pid) ) {
105
  foreach ( $pid as &$p ) {
148
  return $twig;
149
  }
150
 
151
+ /**
152
+ * Function for Term or TimberTerm() within Twig
153
+ * @since 1.5.1
154
+ * @author @jarednova
155
+ * @param integer $tid the term ID to search for
156
+ * @param string $taxonomy the taxonomy to search inside of. If sent a class name, it will use that class to support backwards compatibility
157
+ * @param string $TermClass the class to use for processing the term
158
+ * @return Term|array
159
+ */
160
+ function handle_term_object( $tid, $taxonomy = '', $TermClass = 'Timber\Term' ) {
161
+ if ( $taxonomy != $TermClass ) {
162
+ // user has sent any additonal parameters, process
163
+ $processed_args = self::process_term_args($taxonomy, $TermClass);
164
+ $taxonomy = $processed_args['taxonomy'];
165
+ $TermClass = $processed_args['TermClass'];
166
+ }
167
+ if ( is_array($tid) && !Helper::is_array_assoc($tid) ) {
168
+ foreach ( $tid as &$p ) {
169
+ $p = new $TermClass($p, $taxonomy);
170
+ }
171
+ return $tid;
172
+ }
173
+ return new $TermClass($tid, $taxonomy);
174
+ }
175
+
176
+ /**
177
+ * Process the arguments for handle_term_object to determine what arguments the user is sending
178
+ * @since 1.5.1
179
+ * @author @jarednova
180
+ * @param string $maybe_taxonomy probably a taxonomy, but it could be a Timber\Term subclass
181
+ * @param string $TermClass a string for the Timber\Term subclass
182
+ * @return array of processed arguments
183
+ */
184
+ protected static function process_term_args( $maybe_taxonomy, $TermClass ) {
185
+ // A user could be sending a TermClass in the first arg, let's test for that ...
186
+ if ( class_exists($maybe_taxonomy) ) {
187
+ $tc = new $maybe_taxonomy;
188
+ if ( is_subclass_of($tc, 'Timber\Term') ) {
189
+ return array('taxonomy' => '', 'TermClass' => $maybe_taxonomy);
190
+ }
191
+ }
192
+ return array('taxonomy' => $maybe_taxonomy, 'TermClass' => $TermClass);
193
+ }
194
+
195
  /**
196
  *
197
  *
216
  $twig->addFilter(new \Twig_SimpleFilter('stripshortcodes', 'strip_shortcodes'));
217
  $twig->addFilter(new \Twig_SimpleFilter('array', array($this, 'to_array')));
218
  $twig->addFilter(new \Twig_SimpleFilter('excerpt', 'wp_trim_words'));
219
+ $twig->addFilter(new \Twig_SimpleFilter('excerpt_chars', array('Timber\TextHelper', 'trim_characters')));
220
  $twig->addFilter(new \Twig_SimpleFilter('function', array($this, 'exec_function')));
221
  $twig->addFilter(new \Twig_SimpleFilter('pretags', array($this, 'twig_pretags')));
222
  $twig->addFilter(new \Twig_SimpleFilter('sanitize', 'sanitize_title'));
263
  public function add_timber_escapers( $twig ) {
264
 
265
  $twig->getExtension('Twig_Extension_Core')->setEscaper('esc_url', function( \Twig_Environment $env, $string ) {
266
+ return esc_url($string);
267
  });
268
  $twig->getExtension('Twig_Extension_Core')->setEscaper('wp_kses_post', function( \Twig_Environment $env, $string ) {
269
+ return wp_kses_post($string);
270
  });
271
 
272
  $twig->getExtension('Twig_Extension_Core')->setEscaper('esc_html', function( \Twig_Environment $env, $string ) {
273
+ return esc_html($string);
274
  });
275
 
276
  $twig->getExtension('Twig_Extension_Core')->setEscaper('esc_js', function( \Twig_Environment $env, $string ) {
277
+ return esc_js($string);
278
  });
279
 
280
  return $twig;
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: jarednova, connorjburton, lggorman
3
  Tags: template engine, templates, twig
4
  Requires at least: 3.7
5
- Stable tag: 1.5.0
6
- Tested up to: 4.8.1
7
  PHP version: 5.3.0 or greater
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -36,6 +36,20 @@ _Twig is the template language powering Timber; if you need a little background
36
  **Changes for Theme Developers**
37
  - Please add any usage changes here so theme developers are informed of changes.
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  = 1.5.0 =
40
 
41
  **Fixes and improvements**
2
  Contributors: jarednova, connorjburton, lggorman
3
  Tags: template engine, templates, twig
4
  Requires at least: 3.7
5
+ Stable tag: 1.5.1
6
+ Tested up to: 4.9
7
  PHP version: 5.3.0 or greater
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
36
  **Changes for Theme Developers**
37
  - Please add any usage changes here so theme developers are informed of changes.
38
 
39
+ = 1.5.2 =
40
+
41
+ **Fixes and improvements**
42
+ - Fixed a bug where multi-level menus weren't receiving proper data
43
+
44
+ = 1.5.1 =
45
+
46
+ **Fixes and improvements**
47
+ - Transparent PNGs now work with letterboxing #1554 (thanks @nlemoine)
48
+
49
+ **Changes for Theme Developers**
50
+ - You can now interact with Terms in Twig the same as PHP (ex: `{% set term = Term(34, "arts") %}`). The second arg will default to a subclass of Timber\Term if it exists #1159 (@jarednova)
51
+ - You can now get {{ theme.version }} to get the theme version! #1555 (thanks @herrschuessler)
52
+
53
  = 1.5.0 =
54
 
55
  **Fixes and improvements**
timber-starter-theme/.travis.yml CHANGED
@@ -3,9 +3,9 @@ sudo: false
3
  language: php
4
 
5
  php:
6
- - 5.3
7
  - 5.4
8
  - 5.5
 
9
 
10
  env:
11
  - WP_VERSION=latest WP_MULTISITE=0
@@ -16,4 +16,4 @@ before_script:
16
  - composer install --dev
17
 
18
  script:
19
- - phpunit
3
  language: php
4
 
5
  php:
 
6
  - 5.4
7
  - 5.5
8
+ - 7.1
9
 
10
  env:
11
  - WP_VERSION=latest WP_MULTISITE=0
16
  - composer install --dev
17
 
18
  script:
19
+ - phpunit
timber-starter-theme/archive.php CHANGED
@@ -35,6 +35,6 @@ if ( is_day() ) {
35
  array_unshift( $templates, 'archive-' . get_post_type() . '.twig' );
36
  }
37
 
38
- $context['posts'] = Timber::get_posts();
39
 
40
  Timber::render( $templates, $context );
35
  array_unshift( $templates, 'archive-' . get_post_type() . '.twig' );
36
  }
37
 
38
+ $context['posts'] = new Timber\PostQuery();
39
 
40
  Timber::render( $templates, $context );
timber-starter-theme/index.php CHANGED
@@ -12,9 +12,8 @@
12
  * @subpackage Timber
13
  * @since Timber 0.1
14
  */
15
-
16
  $context = Timber::get_context();
17
- $context['posts'] = Timber::get_posts();
18
  $context['foo'] = 'bar';
19
  $templates = array( 'index.twig' );
20
  if ( is_home() ) {
12
  * @subpackage Timber
13
  * @since Timber 0.1
14
  */
 
15
  $context = Timber::get_context();
16
+ $context['posts'] = new Timber\PostQuery();
17
  $context['foo'] = 'bar';
18
  $templates = array( 'index.twig' );
19
  if ( is_home() ) {
timber-starter-theme/sidebar.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  /**
3
- * The Template for displaying all single posts
4
  *
5
  *
6
  * @package WordPress
1
  <?php
2
  /**
3
+ * The Template for the sidebar containing the main widget area
4
  *
5
  *
6
  * @package WordPress
timber-starter-theme/templates/index.twig CHANGED
@@ -1,9 +1,11 @@
1
  {% extends "base.twig" %}
2
 
3
  {% block content %}
4
- <h2>{{foo}}</h2>
5
- <p>{{qux}}</p>
6
  {% for post in posts %}
7
  {% include ['tease-'~post.post_type~'.twig', 'tease.twig'] %}
8
  {% endfor %}
9
- {% endblock %}
 
 
1
  {% extends "base.twig" %}
2
 
3
  {% block content %}
4
+ <h2>{{ foo }}</h2>
5
+ <p>{{ qux }}</p>
6
  {% for post in posts %}
7
  {% include ['tease-'~post.post_type~'.twig', 'tease.twig'] %}
8
  {% endfor %}
9
+
10
+ {% include 'partial/pagination.twig' with { pagination: posts.pagination({show_all: false, mid_size: 3, end_size: 2}) } %}
11
+ {% endblock %}
timber-starter-theme/templates/partial/pagination.twig ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% if posts.pagination.pages is not empty %}
2
+ <div class="pagination-block">
3
+ <ul class="pagination">
4
+ {% if pagination.pages|first and pagination.pages|first.current != true %}
5
+ <li class="first btn">
6
+ <a href="{{ pagination.pages|first.link }}">First</a>
7
+ </li>
8
+ {% else %}
9
+ <li class="first btn disabled">
10
+ <a>First</a>
11
+ </li>
12
+ {% endif %}
13
+
14
+ {% if pagination.prev %}
15
+ <li class="prev btn">
16
+ <a href="{{ pagination.prev.link }}">Previous</a>
17
+ </li>
18
+ {% else %}
19
+ <li class="prev btn disabled">
20
+ <a>Previous</a>
21
+ </li>
22
+ {% endif %}
23
+
24
+ {% for page in pagination.pages %}
25
+ {% if page.link %}
26
+ <li>
27
+ <a href="{{ page.link }}" class="{{ page.class }}">{{ page.title }}</a>
28
+ </li>
29
+ {% else %}
30
+ <li class="current">
31
+ <a class="{{ page.class }}">{{ page.title }}</a>
32
+ </li>
33
+ {% endif %}
34
+ {% endfor %}
35
+
36
+ {% if pagination.next %}
37
+ <li class="next btn">
38
+ <a href="{{ pagination.next.link }}">
39
+ Next
40
+ </a>
41
+ </li>
42
+ {% else %}
43
+ <li class="next btn disabled">
44
+ <a>
45
+ Next
46
+ </a>
47
+ </li>
48
+ {% endif %}
49
+ {% if pagination.pages|last and pagination.pages|last.current != true %}
50
+ <li class="last btn">
51
+ <a href="{{ pagination.pages|last.link }}">Last</a>
52
+ </li>
53
+ {% else %}
54
+ <li class="last btn disabled">
55
+ <a>Last</a>
56
+ </li>
57
+ {% endif %}
58
+ </ul>
59
+ </div>
60
+ {% endif %}
timber-starter-theme/templates/tease-post.twig CHANGED
@@ -2,7 +2,7 @@
2
 
3
  {% block content %}
4
  <h2 class="h2"><a href="{{post.link}}">{{post.title}}</a></h2>
5
- <p>{{post.get_preview(25)}}</p>
6
  {% if post.thumbnail.src %}
7
  <img src="{{post.thumbnail.src}}" />
8
  {% endif %}
2
 
3
  {% block content %}
4
  <h2 class="h2"><a href="{{post.link}}">{{post.title}}</a></h2>
5
+ <p>{{post.preview.length(25)}}</p>
6
  {% if post.thumbnail.src %}
7
  <img src="{{post.thumbnail.src}}" />
8
  {% endif %}
timber-starter-theme/templates/tease.twig CHANGED
@@ -1,7 +1,7 @@
1
  <article class="tease tease-{{post.post_type}}" id="tease-{{post.ID}}">
2
  {% block content %}
3
  <h2 class="h2"><a href="{{post.link}}">{{post.title}}</a></h2>
4
- <p>{{post.get_preview}}</p>
5
  {% if post.get_thumbnail %}
6
  <img src="{{post.thumbnail.src}}" />
7
  {% endif %}
1
  <article class="tease tease-{{post.post_type}}" id="tease-{{post.ID}}">
2
  {% block content %}
3
  <h2 class="h2"><a href="{{post.link}}">{{post.title}}</a></h2>
4
+ <p>{{post.preview}}</p>
5
  {% if post.get_thumbnail %}
6
  <img src="{{post.thumbnail.src}}" />
7
  {% endif %}
timber.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Timber
4
  Description: The WordPress Timber Library allows you to write themes using the power of Twig templates.
5
  Plugin URI: http://timber.upstatement.com
6
  Author: Jared Novack + Upstatement
7
- Version: 1.5.0
8
  Author URI: http://upstatement.com/
9
  */
10
  // we look for Composer files first in the plugins dir.
4
  Description: The WordPress Timber Library allows you to write themes using the power of Twig templates.
5
  Plugin URI: http://timber.upstatement.com
6
  Author: Jared Novack + Upstatement
7
+ Version: 1.5.2
8
  Author URI: http://upstatement.com/
9
  */
10
  // we look for Composer files first in the plugins dir.
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
- return ComposerAutoloaderInite4b27420d2a2e71228ec8df046d75250::getLoader();
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInitceec62c1fa8d259bb5b01ab49f462533::getLoader();
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInite4b27420d2a2e71228ec8df046d75250
6
  {
7
  private static $loader;
8
 
@@ -19,9 +19,9 @@ class ComposerAutoloaderInite4b27420d2a2e71228ec8df046d75250
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInite4b27420d2a2e71228ec8df046d75250', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInite4b27420d2a2e71228ec8df046d75250', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInitceec62c1fa8d259bb5b01ab49f462533
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInitceec62c1fa8d259bb5b01ab49f462533', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInitceec62c1fa8d259bb5b01ab49f462533', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
vendor/composer/installed.json CHANGED
@@ -118,112 +118,6 @@
118
  "zikula"
119
  ]
120
  },
121
- {
122
- "name": "altorouter/altorouter",
123
- "version": "v1.1.0",
124
- "version_normalized": "1.1.0.0",
125
- "source": {
126
- "type": "git",
127
- "url": "https://github.com/dannyvankooten/AltoRouter.git",
128
- "reference": "09d9d946c546bae6d22a7654cdb3b825ffda54b4"
129
- },
130
- "dist": {
131
- "type": "zip",
132
- "url": "https://api.github.com/repos/dannyvankooten/AltoRouter/zipball/09d9d946c546bae6d22a7654cdb3b825ffda54b4",
133
- "reference": "09d9d946c546bae6d22a7654cdb3b825ffda54b4",
134
- "shasum": ""
135
- },
136
- "require": {
137
- "php": ">=5.3.0"
138
- },
139
- "time": "2014-04-16 09:44:40",
140
- "type": "library",
141
- "installation-source": "dist",
142
- "autoload": {
143
- "classmap": [
144
- "AltoRouter.php"
145
- ]
146
- },
147
- "notification-url": "https://packagist.org/downloads/",
148
- "license": [
149
- "MIT"
150
- ],
151
- "authors": [
152
- {
153
- "name": "Danny van Kooten",
154
- "email": "dannyvankooten@gmail.com",
155
- "homepage": "http://dannyvankooten.com/"
156
- },
157
- {
158
- "name": "Koen Punt",
159
- "homepage": "https://github.com/koenpunt"
160
- },
161
- {
162
- "name": "niahoo",
163
- "homepage": "https://github.com/niahoo"
164
- }
165
- ],
166
- "description": "A lightning fast router for PHP",
167
- "homepage": "https://github.com/dannyvankooten/AltoRouter",
168
- "keywords": [
169
- "lightweight",
170
- "router",
171
- "routing"
172
- ]
173
- },
174
- {
175
- "name": "upstatement/routes",
176
- "version": "0.4",
177
- "version_normalized": "0.4.0.0",
178
- "source": {
179
- "type": "git",
180
- "url": "https://github.com/Upstatement/routes.git",
181
- "reference": "fae7d46f56e8b5775f072774941a5f0a25cb86f3"
182
- },
183
- "dist": {
184
- "type": "zip",
185
- "url": "https://api.github.com/repos/Upstatement/routes/zipball/fae7d46f56e8b5775f072774941a5f0a25cb86f3",
186
- "reference": "fae7d46f56e8b5775f072774941a5f0a25cb86f3",
187
- "shasum": ""
188
- },
189
- "require": {
190
- "altorouter/altorouter": "1.1.0",
191
- "composer/installers": "~1.0",
192
- "php": ">=5.3.0"
193
- },
194
- "require-dev": {
195
- "phpunit/phpunit": "3.7.*",
196
- "satooshi/php-coveralls": "dev-master",
197
- "wp-cli/wp-cli": "*"
198
- },
199
- "time": "2016-07-06 12:53:24",
200
- "type": "library",
201
- "installation-source": "dist",
202
- "autoload": {
203
- "psr-0": {
204
- "Routes": ""
205
- }
206
- },
207
- "notification-url": "https://packagist.org/downloads/",
208
- "license": [
209
- "MIT"
210
- ],
211
- "authors": [
212
- {
213
- "name": "Jared Novack",
214
- "email": "jared@upstatement.com",
215
- "homepage": "http://upstatement.com"
216
- }
217
- ],
218
- "description": "Manage rewrites and routes in WordPress with this dead-simple plugin",
219
- "homepage": "http://routes.upstatement.com",
220
- "keywords": [
221
- "redirects",
222
- "rewrite",
223
- "routes",
224
- "routing"
225
- ]
226
- },
227
  {
228
  "name": "twig/twig",
229
  "version": "v1.34.4",
@@ -346,5 +240,111 @@
346
  "extension",
347
  "twig"
348
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
349
  }
350
  ]
118
  "zikula"
119
  ]
120
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  {
122
  "name": "twig/twig",
123
  "version": "v1.34.4",
240
  "extension",
241
  "twig"
242
  ]
243
+ },
244
+ {
245
+ "name": "altorouter/altorouter",
246
+ "version": "v1.1.0",
247
+ "version_normalized": "1.1.0.0",
248
+ "source": {
249
+ "type": "git",
250
+ "url": "https://github.com/dannyvankooten/AltoRouter.git",
251
+ "reference": "09d9d946c546bae6d22a7654cdb3b825ffda54b4"
252
+ },
253
+ "dist": {
254
+ "type": "zip",
255
+ "url": "https://api.github.com/repos/dannyvankooten/AltoRouter/zipball/09d9d946c546bae6d22a7654cdb3b825ffda54b4",
256
+ "reference": "09d9d946c546bae6d22a7654cdb3b825ffda54b4",
257
+ "shasum": ""
258
+ },
259
+ "require": {
260
+ "php": ">=5.3.0"
261
+ },
262
+ "time": "2014-04-16 09:44:40",
263
+ "type": "library",
264
+ "installation-source": "dist",
265
+ "autoload": {
266
+ "classmap": [
267
+ "AltoRouter.php"
268
+ ]
269
+ },
270
+ "notification-url": "https://packagist.org/downloads/",
271
+ "license": [
272
+ "MIT"
273
+ ],
274
+ "authors": [
275
+ {
276
+ "name": "Danny van Kooten",
277
+ "email": "dannyvankooten@gmail.com",
278
+ "homepage": "http://dannyvankooten.com/"
279
+ },
280
+ {
281
+ "name": "Koen Punt",
282
+ "homepage": "https://github.com/koenpunt"
283
+ },
284
+ {
285
+ "name": "niahoo",
286
+ "homepage": "https://github.com/niahoo"
287
+ }
288
+ ],
289
+ "description": "A lightning fast router for PHP",
290
+ "homepage": "https://github.com/dannyvankooten/AltoRouter",
291
+ "keywords": [
292
+ "lightweight",
293
+ "router",
294
+ "routing"
295
+ ]
296
+ },
297
+ {
298
+ "name": "upstatement/routes",
299
+ "version": "0.4",
300
+ "version_normalized": "0.4.0.0",
301
+ "source": {
302
+ "type": "git",
303
+ "url": "https://github.com/Upstatement/routes.git",
304
+ "reference": "fae7d46f56e8b5775f072774941a5f0a25cb86f3"
305
+ },
306
+ "dist": {
307
+ "type": "zip",
308
+ "url": "https://api.github.com/repos/Upstatement/routes/zipball/fae7d46f56e8b5775f072774941a5f0a25cb86f3",
309
+ "reference": "fae7d46f56e8b5775f072774941a5f0a25cb86f3",
310
+ "shasum": ""
311
+ },
312
+ "require": {
313
+ "altorouter/altorouter": "1.1.0",
314
+ "composer/installers": "~1.0",
315
+ "php": ">=5.3.0"
316
+ },
317
+ "require-dev": {
318
+ "phpunit/phpunit": "3.7.*",
319
+ "satooshi/php-coveralls": "dev-master",
320
+ "wp-cli/wp-cli": "*"
321
+ },
322
+ "time": "2016-07-06 12:53:24",
323
+ "type": "library",
324
+ "installation-source": "dist",
325
+ "autoload": {
326
+ "psr-0": {
327
+ "Routes": ""
328
+ }
329
+ },
330
+ "notification-url": "https://packagist.org/downloads/",
331
+ "license": [
332
+ "MIT"
333
+ ],
334
+ "authors": [
335
+ {
336
+ "name": "Jared Novack",
337
+ "email": "jared@upstatement.com",
338
+ "homepage": "http://upstatement.com"
339
+ }
340
+ ],
341
+ "description": "Manage rewrites and routes in WordPress with this dead-simple plugin",
342
+ "homepage": "http://routes.upstatement.com",
343
+ "keywords": [
344
+ "redirects",
345
+ "rewrite",
346
+ "routes",
347
+ "routing"
348
+ ]
349
  }
350
  ]