Timber - Version 0.16.3

Version Description

  • Added width, height and aspect methods for TimberImages
  • Timber::pagination can now accept a single integer as the overall "size" argument (for the total number of pages that get shown)
  • TimberPost->class (usage: <article class="{{post.class}}">) will now show you the products of post_class
  • Sanity checks for ACF (thanks @parisholley)
  • Fixed bug in TimberPost::prev and TimberPost::next that could return draft posts (thanks @slimndap)
  • Fixed bug with extra ellipsis in some previews (thanks @parisholley)
Download this release

Release Info

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

Code changes from version 0.16.2 to 0.16.3

functions/timber-archives.php CHANGED
@@ -34,7 +34,7 @@ class TimberArchives extends TimberCore {
34
  return $output;
35
  }
36
 
37
- function get_items_montly($args, $last_changed, $join, $where, $order, $limit){
38
  global $wpdb, $wp_locale;
39
  $output = array();
40
  $defaults = array(
@@ -55,13 +55,25 @@ class TimberArchives extends TimberCore {
55
  foreach ( (array) $results as $result ) {
56
  $url = get_month_link( $result->year, $result->month );
57
  /* translators: 1: month name, 2: 4-digit year */
58
- if ($show_year){
 
59
  $text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($result->month), $result->year);
60
  } else {
61
  $text = sprintf(__('%1$s'), $wp_locale->get_month($result->month));
62
  }
63
- $output[] = self::get_archives_link($url, $text);
 
 
 
 
 
 
 
 
 
 
64
  }
 
65
  }
66
  return $output;
67
  }
@@ -74,6 +86,8 @@ class TimberArchives extends TimberCore {
74
  'format' => 'html', 'before' => '',
75
  'after' => '', 'show_post_count' => false,
76
  'order' => 'DESC',
 
 
77
  );
78
 
79
  $r = wp_parse_args( $args, $defaults );
@@ -111,7 +125,7 @@ class TimberArchives extends TimberCore {
111
  $archive_week_end_date_format = get_option('date_format');
112
  }
113
 
114
- $where = apply_filters( 'getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r );
115
  $join = apply_filters( 'getarchives_join', '', $r );
116
 
117
  $output = array();
@@ -123,7 +137,7 @@ class TimberArchives extends TimberCore {
123
  }
124
 
125
  if ( 'monthly' == $type ) {
126
- $output = $this->get_items_montly($args, $last_changed, $join, $where, $order, $limit);
127
  } elseif ('yearly' == $type) {
128
  $output = $this->get_items_yearly($args, $last_changed, $join, $where, $order, $limit);
129
  } elseif ( 'yearlymonthly' == $type || 'yearmonth' == $type){
34
  return $output;
35
  }
36
 
37
+ function get_items_montly($args, $last_changed, $join, $where, $order, $limit, $nested = true){
38
  global $wpdb, $wp_locale;
39
  $output = array();
40
  $defaults = array(
55
  foreach ( (array) $results as $result ) {
56
  $url = get_month_link( $result->year, $result->month );
57
  /* translators: 1: month name, 2: 4-digit year */
58
+
59
+ if ($show_year && !$nested){
60
  $text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($result->month), $result->year);
61
  } else {
62
  $text = sprintf(__('%1$s'), $wp_locale->get_month($result->month));
63
  }
64
+ if ($nested){
65
+ $output[$result->year][] = self::get_archives_link($url, $text);
66
+ } else {
67
+ $output[] = self::get_archives_link($url, $text);
68
+ }
69
+ }
70
+ }
71
+ if ($nested){
72
+ $out2 = array();
73
+ foreach($output as $year=>$months){
74
+ $out2[] = array('name' => $year, 'children' => $months);
75
  }
76
+ return $out2;
77
  }
78
  return $output;
79
  }
86
  'format' => 'html', 'before' => '',
87
  'after' => '', 'show_post_count' => false,
88
  'order' => 'DESC',
89
+ 'post_type' => 'post',
90
+ 'nested' => true
91
  );
92
 
93
  $r = wp_parse_args( $args, $defaults );
125
  $archive_week_end_date_format = get_option('date_format');
126
  }
127
 
128
+ $where = apply_filters( 'getarchives_where', "WHERE post_type = '".$post_type."' AND post_status = 'publish'", $r );
129
  $join = apply_filters( 'getarchives_join', '', $r );
130
 
131
  $output = array();
137
  }
138
 
139
  if ( 'monthly' == $type ) {
140
+ $output = $this->get_items_montly($args, $last_changed, $join, $where, $order, $limit, $nested);
141
  } elseif ('yearly' == $type) {
142
  $output = $this->get_items_yearly($args, $last_changed, $join, $where, $order, $limit);
143
  } elseif ( 'yearlymonthly' == $type || 'yearmonth' == $type){
functions/timber-core.php CHANGED
@@ -8,7 +8,9 @@ class TimberCore {
8
  }
9
  if (is_array($info)) {
10
  foreach ($info as $key => $value) {
11
- $this->$key = $value;
 
 
12
  }
13
  }
14
  }
8
  }
9
  if (is_array($info)) {
10
  foreach ($info as $key => $value) {
11
+ if(!empty($key)){
12
+ $this->$key = $value;
13
+ }
14
  }
15
  }
16
  }
functions/timber-helper.php CHANGED
@@ -7,8 +7,10 @@ class TimberHelper {
7
  if (defined('WP_DISABLE_TRANSIENTS')){
8
  $disable_transients = WP_DISABLE_TRANSIENTS;
9
  }
 
10
  if (false === ($data = get_transient($slug)) || $disable_transients){
11
  $cache_lock_slug = $slug.'_lock';
 
12
  if (get_transient($cache_lock_slug)){
13
  //the server is currently executing the process.
14
  //We're just gonna dump these users. Sorry!
@@ -94,6 +96,13 @@ class TimberHelper {
94
  return $old_root_path;
95
  }
96
 
 
 
 
 
 
 
 
97
  public static function get_rel_url($url, $force = false){
98
  if (!strstr($url, $_SERVER['HTTP_HOST']) && !$force){
99
  return $url;
@@ -435,7 +444,7 @@ class TimberHelper {
435
  for ( $n = 1; $n <= $total; $n++ ) {
436
  $n_display = number_format_i18n($n);
437
  if ( $n == $current ) {
438
- $page_links[] = array('class' => 'page-number current', 'title' => $n_display, 'text' => $n_display);
439
  $dots = true;
440
  } else {
441
  if ( $show_all || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) {
@@ -445,7 +454,7 @@ class TimberHelper {
445
  $link = add_query_arg( $add_args, $link );
446
  }
447
  $link = trailingslashit($link).ltrim($add_fragment, '/');
448
- $page_links[] = array('class' => 'page-number', 'link' => esc_url( apply_filters( 'paginate_links', $link ) ), 'title' => $n_display);
449
  $dots = true;
450
  } elseif ( $dots && !$show_all ) {
451
  $page_links[] = array('class' => 'dots', 'title' => __( '&hellip;' ));
7
  if (defined('WP_DISABLE_TRANSIENTS')){
8
  $disable_transients = WP_DISABLE_TRANSIENTS;
9
  }
10
+
11
  if (false === ($data = get_transient($slug)) || $disable_transients){
12
  $cache_lock_slug = $slug.'_lock';
13
+
14
  if (get_transient($cache_lock_slug)){
15
  //the server is currently executing the process.
16
  //We're just gonna dump these users. Sorry!
96
  return $old_root_path;
97
  }
98
 
99
+ public static function is_local($url){
100
+ if (strstr($url, $_SERVER['HTTP_HOST'])){
101
+ return true;
102
+ }
103
+ return false;
104
+ }
105
+
106
  public static function get_rel_url($url, $force = false){
107
  if (!strstr($url, $_SERVER['HTTP_HOST']) && !$force){
108
  return $url;
444
  for ( $n = 1; $n <= $total; $n++ ) {
445
  $n_display = number_format_i18n($n);
446
  if ( $n == $current ) {
447
+ $page_links[] = array('class' => 'page-number page-numbers current', 'title' => $n_display, 'text' => $n_display, 'name' => $n_display);
448
  $dots = true;
449
  } else {
450
  if ( $show_all || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) {
454
  $link = add_query_arg( $add_args, $link );
455
  }
456
  $link = trailingslashit($link).ltrim($add_fragment, '/');
457
+ $page_links[] = array('class' => 'page-number page-numbers', 'link' => esc_url( apply_filters( 'paginate_links', $link ) ), 'title' => $n_display);
458
  $dots = true;
459
  } elseif ( $dots && !$show_all ) {
460
  $page_links[] = array('class' => 'dots', 'title' => __( '&hellip;' ));
functions/timber-image.php CHANGED
@@ -3,6 +3,7 @@
3
  class TimberImage extends TimberCore {
4
 
5
  var $_can_edit;
 
6
  var $abs_url;
7
  var $PostClass = 'TimberPost';
8
  var $object_type = 'image';
@@ -24,6 +25,38 @@ class TimberImage extends TimberCore {
24
  return pathinfo($this->file);
25
  }
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  function get_src( $size = '' ) {
28
  if (isset($this->abs_url)) {
29
  return $this->abs_url;
@@ -44,7 +77,6 @@ class TimberImage extends TimberCore {
44
  $dir = wp_upload_dir();
45
  $base = ($dir["baseurl"]);
46
  return trailingslashit($base) . $this->file;
47
-
48
  }
49
 
50
  function get_path() {
@@ -91,6 +123,14 @@ class TimberImage extends TimberCore {
91
  $image_info = get_object_vars($image_info);
92
  }
93
  $this->import($image_info);
 
 
 
 
 
 
 
 
94
  if (isset($image_info['id'])) {
95
  $this->ID = $image_info['id'];
96
  } else if (is_numeric($iid)) {
@@ -113,6 +153,9 @@ class TimberImage extends TimberCore {
113
 
114
  function init_with_url($url) {
115
  $this->abs_url = $url;
 
 
 
116
  }
117
 
118
  /* deprecated */
@@ -122,7 +165,21 @@ class TimberImage extends TimberCore {
122
 
123
  /* Alias */
124
 
125
- function src($size = '') {
 
 
 
 
 
 
 
 
 
 
126
  return $this->get_src($size);
127
  }
 
 
 
 
128
  }
3
  class TimberImage extends TimberCore {
4
 
5
  var $_can_edit;
6
+ var $_dimensions;
7
  var $abs_url;
8
  var $PostClass = 'TimberPost';
9
  var $object_type = 'image';
25
  return pathinfo($this->file);
26
  }
27
 
28
+ function get_dimensions($dim = null){
29
+ if (isset($this->_dimensions)){
30
+ return $this->get_dimensions_loaded($dim);
31
+ }
32
+ list($width, $height) = getimagesize($this->fileloc);
33
+ $this->_dimensions = array();
34
+ $this->_dimensions[0] = $width;
35
+ $this->_dimensions[1] = $height;
36
+ TimberHelper::error_log($this->_dimensions);
37
+ return $this->get_dimensions_loaded($dim);
38
+ }
39
+
40
+ function get_dimensions_loaded($dim){
41
+ if ($dim == null){
42
+ return $this->_dimensions;
43
+ }
44
+ if ($dim == 'w' || $dim == 'width'){
45
+ return $this->_dimensions[0];
46
+ }
47
+ if ($dim == 'h' || $dim == 'height'){
48
+ return $this->_dimensions[1];
49
+ }
50
+ }
51
+
52
+ function get_width(){
53
+ return $this->get_dimensions('width');
54
+ }
55
+
56
+ function get_height(){
57
+ return $this->get_dimensions('height');
58
+ }
59
+
60
  function get_src( $size = '' ) {
61
  if (isset($this->abs_url)) {
62
  return $this->abs_url;
77
  $dir = wp_upload_dir();
78
  $base = ($dir["baseurl"]);
79
  return trailingslashit($base) . $this->file;
 
80
  }
81
 
82
  function get_path() {
123
  $image_info = get_object_vars($image_info);
124
  }
125
  $this->import($image_info);
126
+ $basedir = wp_upload_dir();
127
+ $basedir = $basedir['basedir'];
128
+ if (isset($this->file)){
129
+ $this->file_loc = $basedir . $this->file;
130
+ } else if (isset($this->_wp_attached_file)){
131
+ $this->file = reset($this->_wp_attached_file);
132
+ $this->file_loc = $basedir . $this->file;
133
+ }
134
  if (isset($image_info['id'])) {
135
  $this->ID = $image_info['id'];
136
  } else if (is_numeric($iid)) {
153
 
154
  function init_with_url($url) {
155
  $this->abs_url = $url;
156
+ if (TimberHelper::is_local($url)){
157
+ $this->file = ABSPATH . TimberHelper::get_rel_url($url);
158
+ }
159
  }
160
 
161
  /* deprecated */
165
 
166
  /* Alias */
167
 
168
+ public function aspect(){
169
+ $w = intval($this->width());
170
+ $h = intval($this->height());
171
+ return $w/$h;
172
+ }
173
+
174
+ public function height(){
175
+ return $this->get_height();
176
+ }
177
+
178
+ public function src($size = '') {
179
  return $this->get_src($size);
180
  }
181
+
182
+ public function width(){
183
+ return $this->get_width();
184
+ }
185
  }
functions/timber-loader.php CHANGED
@@ -37,12 +37,14 @@ class TimberLoader {
37
  $expires = $expires[0];
38
  }
39
 
40
- ksort( $data );
41
- $key = md5( $file . json_encode( $data ) );
42
 
43
  $output = false;
44
- if ( false !== $expires )
 
 
45
  $output = $this->get_cache( $key, self::CACHEGROUP, $cache_mode );
 
46
 
47
  if ( false === $output || null === $output ) {
48
  $twig = $this->get_twig();
@@ -55,7 +57,7 @@ class TimberLoader {
55
  $output = $twig->render($file, $data);
56
  }
57
 
58
- if ( false !== $output && false !== $expires )
59
  $this->set_cache( $key, $output, self::CACHEGROUP, $expires, $cache_mode );
60
 
61
  return $output;
@@ -255,4 +257,4 @@ class TimberLoader {
255
 
256
  return $cache_mode;
257
  }
258
- }
37
  $expires = $expires[0];
38
  }
39
 
40
+ $key = null;
 
41
 
42
  $output = false;
43
+ if ( false !== $expires ){
44
+ ksort( $data );
45
+ $key = md5( $file . json_encode( $data ) );
46
  $output = $this->get_cache( $key, self::CACHEGROUP, $cache_mode );
47
+ }
48
 
49
  if ( false === $output || null === $output ) {
50
  $twig = $this->get_twig();
57
  $output = $twig->render($file, $data);
58
  }
59
 
60
+ if ( false !== $output && false !== $expires && null !== $key )
61
  $this->set_cache( $key, $output, self::CACHEGROUP, $expires, $cache_mode );
62
 
63
  return $output;
257
 
258
  return $cache_mode;
259
  }
260
+ }
functions/timber-menu.php CHANGED
@@ -18,18 +18,22 @@ class TimberMenu extends TimberCore {
18
  $menu_id = $this->get_menu_id_from_terms($slug);
19
  }
20
  if ($menu_id){
21
- $menu = wp_get_nav_menu_items($menu_id);
22
- $menu = self::order_children($menu);
23
- $this->items = $menu;
24
- $menu_info = wp_get_nav_menu_object($menu_id);
25
- $this->import($menu_info);
26
- $this->ID = $this->term_id;
27
  } else {
28
  TimberHelper::error_log("Sorry, the menu you were looking for wasn't found ('".$slug."'). Here's what Timber did find:");
29
  }
30
  return null;
31
  }
32
 
 
 
 
 
 
 
 
 
 
33
  private function get_menu_id_from_locations($slug, $locations){
34
  if ($slug === 0){
35
  $slug = $this->get_menu_id_from_terms($slug);
@@ -101,6 +105,7 @@ class TimberMenu extends TimberCore {
101
  class TimberMenuItem extends TimberCore {
102
 
103
  var $children;
 
104
 
105
  function __construct($data) {
106
  $this->import($data);
@@ -109,6 +114,12 @@ class TimberMenuItem extends TimberCore {
109
  $this->_name = $this->name;
110
  }
111
  $this->name = $this->name();
 
 
 
 
 
 
112
  }
113
 
114
  function name() {
@@ -131,6 +142,9 @@ class TimberMenuItem extends TimberCore {
131
  }
132
 
133
  function add_child($item) {
 
 
 
134
  if (!isset($this->children)) {
135
  $this->children = array();
136
  }
@@ -149,6 +163,11 @@ class TimberMenuItem extends TimberCore {
149
  }
150
 
151
  /* Aliases */
 
 
 
 
 
152
  function link(){
153
  return $this->get_link();
154
  }
18
  $menu_id = $this->get_menu_id_from_terms($slug);
19
  }
20
  if ($menu_id){
21
+ $this->init($menu_id);
 
 
 
 
 
22
  } else {
23
  TimberHelper::error_log("Sorry, the menu you were looking for wasn't found ('".$slug."'). Here's what Timber did find:");
24
  }
25
  return null;
26
  }
27
 
28
+ private function init($menu_id){
29
+ $menu = wp_get_nav_menu_items($menu_id);
30
+ $menu = self::order_children($menu);
31
+ $this->items = $menu;
32
+ $menu_info = wp_get_nav_menu_object($menu_id);
33
+ $this->import($menu_info);
34
+ $this->ID = $this->term_id;
35
+ }
36
+
37
  private function get_menu_id_from_locations($slug, $locations){
38
  if ($slug === 0){
39
  $slug = $this->get_menu_id_from_terms($slug);
105
  class TimberMenuItem extends TimberCore {
106
 
107
  var $children;
108
+ var $has_child_class = false;
109
 
110
  function __construct($data) {
111
  $this->import($data);
114
  $this->_name = $this->name;
115
  }
116
  $this->name = $this->name();
117
+ $this->add_class('menu-item-'.$this->ID);
118
+ }
119
+
120
+ function add_class($class_name){
121
+ $this->classes[] = $class_name;
122
+ $this->class .= ' '.$class_name;
123
  }
124
 
125
  function name() {
142
  }
143
 
144
  function add_child($item) {
145
+ if (!$this->has_child_class){
146
+ $this->add_class('menu-item-has-children');
147
+ }
148
  if (!isset($this->children)) {
149
  $this->children = array();
150
  }
163
  }
164
 
165
  /* Aliases */
166
+
167
+ function children(){
168
+ return $this->get_children();
169
+ }
170
+
171
  function link(){
172
  return $this->get_link();
173
  }
functions/timber-post.php CHANGED
@@ -41,6 +41,8 @@ class TimberPost extends TimberCore {
41
  }
42
  $post_info = $this->get_info($pid);
43
  $this->import($post_info);
 
 
44
  }
45
 
46
  /**
@@ -48,6 +50,7 @@ class TimberPost extends TimberCore {
48
  */
49
  function get_edit_url() {
50
  if ($this->can_edit()) {
 
51
  return '/wp-admin/post.php?post=' . $this->ID . '&action=edit';
52
  }
53
  return false;
@@ -136,7 +139,7 @@ class TimberPost extends TimberCore {
136
  $trimmed = false;
137
  if (isset($this->post_excerpt) && strlen($this->post_excerpt)) {
138
  if ($force) {
139
- $text = TimberHelper::trim_words($this->post_excerpt, $len);
140
  $trimmed = true;
141
  } else {
142
  $text = $this->post_excerpt;
@@ -233,10 +236,18 @@ class TimberPost extends TimberCore {
233
  }
234
 
235
  function get_next() {
236
- if (!isset($this->next)){
237
- $this->next = new $this->PostClass(get_adjacent_post( false, "", false ));
 
 
 
 
 
 
 
 
238
  }
239
- return $this->next;
240
  }
241
 
242
  public function get_path() {
@@ -244,10 +255,18 @@ class TimberPost extends TimberCore {
244
  }
245
 
246
  function get_prev() {
247
- if (!isset($this->prev)){
248
- $this->prev = new $this->PostClass(get_adjacent_post( false, "", true ));
 
 
 
 
 
 
 
 
249
  }
250
- return $this->prev;
251
  }
252
 
253
  function get_parent() {
@@ -566,8 +585,10 @@ class TimberPost extends TimberCore {
566
  return $this->get_title();
567
  }
568
 
569
- function post_class($class='') {
570
- return implode(' ', get_post_class($class,$this->ID));
 
 
571
  }
572
 
573
 
41
  }
42
  $post_info = $this->get_info($pid);
43
  $this->import($post_info);
44
+ //cant have a function, so gots to do it this way
45
+ $this->class = $this->post_class();
46
  }
47
 
48
  /**
50
  */
51
  function get_edit_url() {
52
  if ($this->can_edit()) {
53
+ return get_edit_post_link($this->ID);
54
  return '/wp-admin/post.php?post=' . $this->ID . '&action=edit';
55
  }
56
  return false;
139
  $trimmed = false;
140
  if (isset($this->post_excerpt) && strlen($this->post_excerpt)) {
141
  if ($force) {
142
+ $text = TimberHelper::trim_words($this->post_excerpt, $len, false);
143
  $trimmed = true;
144
  } else {
145
  $text = $this->post_excerpt;
236
  }
237
 
238
  function get_next() {
239
+ if (!isset($this->_next)){
240
+ global $post;
241
+ $this->_next = null;
242
+ $old_global = $post;
243
+ $post = $this;
244
+ $adjacent = get_adjacent_post(false, '', false);
245
+ if ($adjacent){
246
+ $this->_next = new $this->PostClass($adjacent);
247
+ }
248
+ $post = $old_global;
249
  }
250
+ return $this->_next;
251
  }
252
 
253
  public function get_path() {
255
  }
256
 
257
  function get_prev() {
258
+ if (!isset($this->_prev)){
259
+ global $post;
260
+ $this->_prev = null;
261
+ $old_global = $post;
262
+ $post = $this;
263
+ $adjacent = get_adjacent_post(false, '', true);
264
+ if ($adjacent){
265
+ $this->_prev = new $this->PostClass($adjacent);
266
+ }
267
+ $post = $old_global;
268
  }
269
+ return $this->_prev;
270
  }
271
 
272
  function get_parent() {
585
  return $this->get_title();
586
  }
587
 
588
+ public function post_class($class='') {
589
+ $pid = $this->ID;
590
+ $class_array = get_post_class($class, $pid);
591
+ return implode(' ', $class_array);
592
  }
593
 
594
 
functions/timber-site.php CHANGED
@@ -33,6 +33,9 @@
33
  $this->description = get_bloginfo('description');
34
  $this->url = get_bloginfo('url');
35
  $this->language = get_bloginfo('language');
 
 
 
36
  }
37
 
38
  function __get($field){
33
  $this->description = get_bloginfo('description');
34
  $this->url = get_bloginfo('url');
35
  $this->language = get_bloginfo('language');
36
+ $this->charset = get_bloginfo('charset');
37
+ $this->pingback_url = get_bloginfo('pingback_url');
38
+ $this->language_attributes = TimberHelper::function_wrapper('language_attributes');
39
  }
40
 
41
  function __get($field){
functions/timber-theme.php CHANGED
@@ -3,8 +3,7 @@
3
  class TimberTheme extends TimberCore {
4
 
5
  function __construct($slug = null){
6
- $this->
7
- init($slug);
8
  }
9
 
10
  function init($slug = null){
@@ -14,6 +13,7 @@
14
  $this->slug = $ss;
15
  $this->path = '/'.str_replace(ABSPATH, '', get_stylesheet_directory());
16
  $this->uri = get_stylesheet_directory_uri();
 
17
  $this->parent_slug = $data->get('Template');
18
  if (!$this->parent_slug){
19
  $this->path = '/'.str_replace(ABSPATH, '', get_template_directory());
@@ -24,4 +24,12 @@
24
  }
25
  }
26
 
 
 
 
 
 
 
 
 
27
  }
3
  class TimberTheme extends TimberCore {
4
 
5
  function __construct($slug = null){
6
+ $this->init($slug);
 
7
  }
8
 
9
  function init($slug = null){
13
  $this->slug = $ss;
14
  $this->path = '/'.str_replace(ABSPATH, '', get_stylesheet_directory());
15
  $this->uri = get_stylesheet_directory_uri();
16
+ $this->link = $this->uri;
17
  $this->parent_slug = $data->get('Template');
18
  if (!$this->parent_slug){
19
  $this->path = '/'.str_replace(ABSPATH, '', get_template_directory());
24
  }
25
  }
26
 
27
+ public function theme_mod($name, $default = false){
28
+ return get_theme_mod($name, $default);
29
+ }
30
+
31
+ public function theme_mods(){
32
+ return get_theme_mods();
33
+ }
34
+
35
  }
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: jarednova
3
  Tags: template engine, templates, twig
4
  Requires at least: 3.5
5
- Stable tag: 0.16.2
6
- Tested up to: 3.7.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
@@ -41,6 +41,14 @@ Timber is great for any WordPress developer who cares about writing good, mainta
41
 
42
  == Changelog ==
43
 
 
 
 
 
 
 
 
 
44
  = 0.16.2 =
45
  * Added has_term to TimberPost
46
  * Extra checks to make sure redirected links don't get 404 body class
2
  Contributors: jarednova
3
  Tags: template engine, templates, twig
4
  Requires at least: 3.5
5
+ Stable tag: 0.16.3
6
+ Tested up to: 3.8.0
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
41
 
42
  == Changelog ==
43
 
44
+ = 0.16.3 =
45
+ * Added width, height and aspect methods for TimberImages
46
+ * Timber::pagination can now accept a single integer as the overall "size" argument (for the total number of pages that get shown)
47
+ * TimberPost->class (usage: `<article class="{{post.class}}"`>) will now show you the products of post_class
48
+ * Sanity checks for ACF (thanks @parisholley)
49
+ * Fixed bug in TimberPost::prev and TimberPost::next that could return draft posts (thanks @slimndap)
50
+ * Fixed bug with extra ellipsis in some previews (thanks @parisholley)
51
+
52
  = 0.16.2 =
53
  * Added has_term to TimberPost
54
  * Extra checks to make sure redirected links don't get 404 body class
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.16.2
8
  Author URI: http://upstatement.com/
9
  */
10
 
@@ -343,6 +343,7 @@ class Timber {
343
  $data['stylesheet_uri'] = get_stylesheet_uri();
344
  $data['template_uri'] = get_template_directory_uri();
345
  $data['theme'] = new TimberTheme();
 
346
  $data = apply_filters('timber_context', $data);
347
  return $data;
348
  }
@@ -416,7 +417,8 @@ class Timber {
416
  ================================ */
417
 
418
  public static function get_widgets($widget_id){
419
- return TimberHelper::ob_function('dynamic_sidebar', array($widget_id));
 
420
  }
421
 
422
 
@@ -438,12 +440,16 @@ class Timber {
438
  public static function add_route($route, $callback, $args = array()) {
439
  global $timber;
440
  if (!isset($timber->router)) {
441
- require_once('functions/router/Router.php');
442
- require_once('functions/router/Route.php');
443
- $timber->router = new Router();
444
- $timber->router->setBasePath('/');
 
 
 
 
 
445
  }
446
- $timber->router->map($route, $callback, $args);
447
  }
448
 
449
  public static function cancel_query(){
@@ -526,15 +532,19 @@ class Timber {
526
  $args['current'] = max( 1, get_query_var('paged') );
527
  $args['mid_size'] = max(9 - $args['current'], 3);
528
  $args['prev_next'] = false;
529
- $args = array_merge($args, $prefs);
 
 
 
 
530
  $data['pages'] = TimberHelper::paginate_links($args);
531
  $next = next_posts($args['total'], false);
532
  if ($next){
533
- $data['next'] = array('link' => $next);
534
  }
535
  $prev = previous_posts(false);
536
  if ($prev){
537
- $data['prev'] = array('link' => $prev);
538
  }
539
  if ($paged < 2){
540
  $data['prev'] = '';
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.16.3
8
  Author URI: http://upstatement.com/
9
  */
10
 
343
  $data['stylesheet_uri'] = get_stylesheet_uri();
344
  $data['template_uri'] = get_template_directory_uri();
345
  $data['theme'] = new TimberTheme();
346
+ $data['site'] = new TimberSite();
347
  $data = apply_filters('timber_context', $data);
348
  return $data;
349
  }
417
  ================================ */
418
 
419
  public static function get_widgets($widget_id){
420
+ return TimberHelper::function_wrapper('dynamic_sidebar', array($widget_id));
421
+ //return TimberHelper::ob_function('dynamic_sidebar', array($widget_id));
422
  }
423
 
424
 
440
  public static function add_route($route, $callback, $args = array()) {
441
  global $timber;
442
  if (!isset($timber->router)) {
443
+ require_once(__DIR__.'/functions/router/Router.php');
444
+ require_once(__DIR__.'/functions/router/Route.php');
445
+ if (class_exists('Router')){
446
+ $timber->router = new Router();
447
+ $timber->router->setBasePath('/');
448
+ }
449
+ }
450
+ if (class_exists('Router')){
451
+ $timber->router->map($route, $callback, $args);
452
  }
 
453
  }
454
 
455
  public static function cancel_query(){
532
  $args['current'] = max( 1, get_query_var('paged') );
533
  $args['mid_size'] = max(9 - $args['current'], 3);
534
  $args['prev_next'] = false;
535
+ if (is_int($prefs)){
536
+ $args['mid_size'] = $prefs - 2;
537
+ } else {
538
+ $args = array_merge($args, $prefs);
539
+ }
540
  $data['pages'] = TimberHelper::paginate_links($args);
541
  $next = next_posts($args['total'], false);
542
  if ($next){
543
+ $data['next'] = array('link' => $next, 'class' => 'page-numbers next');
544
  }
545
  $prev = previous_posts(false);
546
  if ($prev){
547
+ $data['prev'] = array('link' => $prev, 'class' => 'page-numbers prev');
548
  }
549
  if ($paged < 2){
550
  $data['prev'] = '';