Version Description
- Fixed errors in tests (thanks @lggorman)
- Fixed error in comments_link (thanks @tehlivi)
Download this release
Release Info
Developer | jarednova |
Plugin | Timber |
Version | 0.22.5 |
Comparing to | |
See all releases |
Code changes from version 0.22.4 to 0.22.5
- lib/image/timber-image-operation-resize.php +4 -0
- lib/image/timber-image-operation-tojpg.php +4 -2
- lib/timber-archives.php +3 -3
- lib/timber-comment.php +1 -3
- lib/timber-image.php +19 -19
- lib/timber-post.php +1 -1
- lib/timber-term-getter.php +168 -169
- readme.txt +6 -2
- timber.php +1 -1
- vendor/autoload.php +1 -1
- vendor/composer/autoload_real.php +4 -4
lib/image/timber-image-operation-resize.php
CHANGED
@@ -49,6 +49,10 @@ class TimberImageOperationResize extends TimberImageOperation {
|
|
49 |
return $result;
|
50 |
}
|
51 |
|
|
|
|
|
|
|
|
|
52 |
protected function run_animated_gif( $load_filename, $save_filename ) {
|
53 |
$image = wp_get_image_editor( $load_filename );
|
54 |
$current_size = $image->get_size();
|
49 |
return $result;
|
50 |
}
|
51 |
|
52 |
+
/**
|
53 |
+
* @param string $load_filename
|
54 |
+
* @param string $save_filename
|
55 |
+
*/
|
56 |
protected function run_animated_gif( $load_filename, $save_filename ) {
|
57 |
$image = wp_get_image_editor( $load_filename );
|
58 |
$current_size = $image->get_size();
|
lib/image/timber-image-operation-tojpg.php
CHANGED
@@ -35,7 +35,7 @@ class TimberImageOperationToJpg extends TimberImageOperation {
|
|
35 |
* (ex: /src/var/www/wp-content/uploads/my-pic.png)
|
36 |
* @return bool true if everything went fine, false otherwise
|
37 |
*/
|
38 |
-
function run($load_filename, $save_filename){
|
39 |
$input = self::image_create( $load_filename );
|
40 |
list( $width, $height ) = getimagesize( $load_filename );
|
41 |
$output = imagecreatetruecolor( $width, $height );
|
@@ -48,6 +48,7 @@ class TimberImageOperationToJpg extends TimberImageOperation {
|
|
48 |
}
|
49 |
|
50 |
/**
|
|
|
51 |
* @return resource an image identifier representing the image obtained from the given filename
|
52 |
* will return the same data type regardless of whether the source is gif or png
|
53 |
*/
|
@@ -65,8 +66,9 @@ class TimberImageOperationToJpg extends TimberImageOperation {
|
|
65 |
if ( $ext == 'png' ) {
|
66 |
return imagecreatefrompng($filename);
|
67 |
}
|
68 |
-
if ( $ext == 'jpg' || $ext == 'jpeg') {
|
69 |
return imagecreatefromjpeg($filename);
|
70 |
}
|
|
|
71 |
}
|
72 |
}
|
35 |
* (ex: /src/var/www/wp-content/uploads/my-pic.png)
|
36 |
* @return bool true if everything went fine, false otherwise
|
37 |
*/
|
38 |
+
function run($load_filename, $save_filename) {
|
39 |
$input = self::image_create( $load_filename );
|
40 |
list( $width, $height ) = getimagesize( $load_filename );
|
41 |
$output = imagecreatetruecolor( $width, $height );
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
+
* @param string $filename
|
52 |
* @return resource an image identifier representing the image obtained from the given filename
|
53 |
* will return the same data type regardless of whether the source is gif or png
|
54 |
*/
|
66 |
if ( $ext == 'png' ) {
|
67 |
return imagecreatefrompng($filename);
|
68 |
}
|
69 |
+
if ( $ext == 'jpg' || $ext == 'jpeg' ) {
|
70 |
return imagecreatefromjpeg($filename);
|
71 |
}
|
72 |
+
throw new InvalidArgumentException( 'image_create only accepts PNG, GIF and JPGs. File extension was: '.$ext );
|
73 |
}
|
74 |
}
|
lib/timber-archives.php
CHANGED
@@ -83,7 +83,7 @@ class TimberArchives extends TimberCore {
|
|
83 |
|
84 |
/**
|
85 |
* @internal
|
86 |
-
* @param array
|
87 |
* @param string $last_changed
|
88 |
* @param string $join
|
89 |
* @param string $where
|
@@ -102,8 +102,8 @@ class TimberArchives extends TimberCore {
|
|
102 |
wp_cache_set($key, $results, 'posts');
|
103 |
}
|
104 |
if ($results) {
|
105 |
-
foreach ((array)$results as $result) {
|
106 |
-
$url = get_year_link($result->year);
|
107 |
$text = sprintf('%d', $result->year);
|
108 |
$output[] = $this->get_archives_link($url, $text);
|
109 |
}
|
83 |
|
84 |
/**
|
85 |
* @internal
|
86 |
+
* @param array $args
|
87 |
* @param string $last_changed
|
88 |
* @param string $join
|
89 |
* @param string $where
|
102 |
wp_cache_set($key, $results, 'posts');
|
103 |
}
|
104 |
if ($results) {
|
105 |
+
foreach ( (array)$results as $result ) {
|
106 |
+
$url = get_year_link( $result->year );
|
107 |
$text = sprintf('%d', $result->year);
|
108 |
$output[] = $this->get_archives_link($url, $text);
|
109 |
}
|
lib/timber-comment.php
CHANGED
@@ -44,7 +44,7 @@ class TimberComment extends TimberCore implements TimberCoreInterface {
|
|
44 |
$this->init($cid);
|
45 |
}
|
46 |
|
47 |
-
function __toString(){
|
48 |
return $this->content();
|
49 |
}
|
50 |
|
@@ -265,8 +265,6 @@ class TimberComment extends TimberCore implements TimberCoreInterface {
|
|
265 |
* Enqueue the WP threaded comments javascript,
|
266 |
* and fetch the reply link for various comments.
|
267 |
* @api
|
268 |
-
* @param int $comment_id
|
269 |
-
* @param int $post_id
|
270 |
* @return string
|
271 |
*/
|
272 |
public function reply_link( $reply_text = 'Reply' ) {
|
44 |
$this->init($cid);
|
45 |
}
|
46 |
|
47 |
+
function __toString() {
|
48 |
return $this->content();
|
49 |
}
|
50 |
|
265 |
* Enqueue the WP threaded comments javascript,
|
266 |
* and fetch the reply link for various comments.
|
267 |
* @api
|
|
|
|
|
268 |
* @return string
|
269 |
*/
|
270 |
public function reply_link( $reply_text = 'Reply' ) {
|
lib/timber-image.php
CHANGED
@@ -87,7 +87,7 @@ class TimberImage extends TimberPost implements TimberCoreInterface {
|
|
87 |
* @return string the src of the file
|
88 |
*/
|
89 |
public function __toString() {
|
90 |
-
if ($this->get_src()) {
|
91 |
return $this->get_src();
|
92 |
}
|
93 |
return '';
|
@@ -107,7 +107,7 @@ class TimberImage extends TimberPost implements TimberCoreInterface {
|
|
107 |
* @return array|int
|
108 |
*/
|
109 |
protected function get_dimensions($dim = null) {
|
110 |
-
if (isset($this->_dimensions)) {
|
111 |
return $this->get_dimensions_loaded($dim);
|
112 |
}
|
113 |
if ( file_exists($this->file_loc) && filesize($this->file_loc) ) {
|
@@ -125,13 +125,13 @@ class TimberImage extends TimberPost implements TimberCoreInterface {
|
|
125 |
* @return array|int
|
126 |
*/
|
127 |
protected function get_dimensions_loaded($dim) {
|
128 |
-
if ($dim === null) {
|
129 |
return $this->_dimensions;
|
130 |
}
|
131 |
-
if ($dim == 'w' || $dim == 'width') {
|
132 |
return $this->_dimensions[0];
|
133 |
}
|
134 |
-
if ($dim == 'h' || $dim == 'height') {
|
135 |
return $this->_dimensions[1];
|
136 |
}
|
137 |
return null;
|
@@ -173,7 +173,7 @@ class TimberImage extends TimberPost implements TimberCoreInterface {
|
|
173 |
* @return string with http/https corrected depending on what's appropriate for server
|
174 |
*/
|
175 |
protected static function _maybe_secure_url($url) {
|
176 |
-
if (is_ssl() && strpos($url, 'https') !== 0 && strpos($url, 'http') === 0) {
|
177 |
$url = 'https' . substr($url, strlen('http'));
|
178 |
}
|
179 |
return $url;
|
@@ -182,7 +182,7 @@ class TimberImage extends TimberPost implements TimberCoreInterface {
|
|
182 |
public static function wp_upload_dir() {
|
183 |
static $wp_upload_dir = false;
|
184 |
|
185 |
-
if (!$wp_upload_dir) {
|
186 |
$wp_upload_dir = wp_upload_dir();
|
187 |
}
|
188 |
|
@@ -203,7 +203,7 @@ class TimberImage extends TimberPost implements TimberCoreInterface {
|
|
203 |
$this->init_with_file_path($iid);
|
204 |
return;
|
205 |
}
|
206 |
-
if (strstr(strtolower($iid), '.jpg')) {
|
207 |
$this->init_with_relative_path($iid);
|
208 |
return;
|
209 |
}
|
@@ -214,24 +214,24 @@ class TimberImage extends TimberPost implements TimberCoreInterface {
|
|
214 |
$this->import($image_info);
|
215 |
$basedir = self::wp_upload_dir();
|
216 |
$basedir = $basedir['basedir'];
|
217 |
-
if (isset($this->file)) {
|
218 |
$this->file_loc = $basedir . DIRECTORY_SEPARATOR . $this->file;
|
219 |
-
} else if (isset($this->_wp_attached_file)) {
|
220 |
$this->file = reset($this->_wp_attached_file);
|
221 |
$this->file_loc = $basedir . DIRECTORY_SEPARATOR . $this->file;
|
222 |
}
|
223 |
-
if (isset($image_info['id'])) {
|
224 |
$this->ID = $image_info['id'];
|
225 |
-
} else if (is_numeric($iid)) {
|
226 |
$this->ID = $iid;
|
227 |
}
|
228 |
-
if (isset($this->ID)) {
|
229 |
$custom = get_post_custom($this->ID);
|
230 |
foreach ($custom as $key => $value) {
|
231 |
$this->$key = $value[0];
|
232 |
}
|
233 |
} else {
|
234 |
-
if (is_array($iid) || is_object($iid)) {
|
235 |
TimberHelper::error_log('Not able to init in TimberImage with iid=');
|
236 |
TimberHelper::error_log($iid);
|
237 |
} else {
|
@@ -268,7 +268,7 @@ class TimberImage extends TimberPost implements TimberCoreInterface {
|
|
268 |
*/
|
269 |
protected function init_with_url($url) {
|
270 |
$this->abs_url = $url;
|
271 |
-
if (TimberURLHelper::is_local($url)) {
|
272 |
$this->file = ABSPATH . TimberURLHelper::get_rel_url($url);
|
273 |
$this->file_loc = ABSPATH . TimberURLHelper::get_rel_url($url);
|
274 |
}
|
@@ -336,7 +336,7 @@ class TimberImage extends TimberPost implements TimberCoreInterface {
|
|
336 |
* ```
|
337 |
*/
|
338 |
public function link() {
|
339 |
-
if (strlen($this->abs_url)) {
|
340 |
return $this->abs_url;
|
341 |
}
|
342 |
return get_permalink($this->ID);
|
@@ -347,7 +347,7 @@ class TimberImage extends TimberPost implements TimberCoreInterface {
|
|
347 |
* @return bool|TimberPost
|
348 |
*/
|
349 |
public function parent() {
|
350 |
-
if (!$this->post_parent) {
|
351 |
return false;
|
352 |
}
|
353 |
return new $this->PostClass($this->post_parent);
|
@@ -373,8 +373,8 @@ class TimberImage extends TimberPost implements TimberCoreInterface {
|
|
373 |
* @api
|
374 |
* @example
|
375 |
* ```twig
|
376 |
-
|
377 |
-
|
378 |
* ```
|
379 |
* ```html
|
380 |
* <img src="http://example.org/wp-content/uploads/2015/08/pic.jpg" />
|
87 |
* @return string the src of the file
|
88 |
*/
|
89 |
public function __toString() {
|
90 |
+
if ( $this->get_src() ) {
|
91 |
return $this->get_src();
|
92 |
}
|
93 |
return '';
|
107 |
* @return array|int
|
108 |
*/
|
109 |
protected function get_dimensions($dim = null) {
|
110 |
+
if ( isset($this->_dimensions) ) {
|
111 |
return $this->get_dimensions_loaded($dim);
|
112 |
}
|
113 |
if ( file_exists($this->file_loc) && filesize($this->file_loc) ) {
|
125 |
* @return array|int
|
126 |
*/
|
127 |
protected function get_dimensions_loaded($dim) {
|
128 |
+
if ( $dim === null ) {
|
129 |
return $this->_dimensions;
|
130 |
}
|
131 |
+
if ( $dim == 'w' || $dim == 'width' ) {
|
132 |
return $this->_dimensions[0];
|
133 |
}
|
134 |
+
if ( $dim == 'h' || $dim == 'height' ) {
|
135 |
return $this->_dimensions[1];
|
136 |
}
|
137 |
return null;
|
173 |
* @return string with http/https corrected depending on what's appropriate for server
|
174 |
*/
|
175 |
protected static function _maybe_secure_url($url) {
|
176 |
+
if ( is_ssl() && strpos($url, 'https') !== 0 && strpos($url, 'http') === 0 ) {
|
177 |
$url = 'https' . substr($url, strlen('http'));
|
178 |
}
|
179 |
return $url;
|
182 |
public static function wp_upload_dir() {
|
183 |
static $wp_upload_dir = false;
|
184 |
|
185 |
+
if ( !$wp_upload_dir ) {
|
186 |
$wp_upload_dir = wp_upload_dir();
|
187 |
}
|
188 |
|
203 |
$this->init_with_file_path($iid);
|
204 |
return;
|
205 |
}
|
206 |
+
if ( strstr(strtolower($iid), '.jpg') ) {
|
207 |
$this->init_with_relative_path($iid);
|
208 |
return;
|
209 |
}
|
214 |
$this->import($image_info);
|
215 |
$basedir = self::wp_upload_dir();
|
216 |
$basedir = $basedir['basedir'];
|
217 |
+
if ( isset($this->file) ) {
|
218 |
$this->file_loc = $basedir . DIRECTORY_SEPARATOR . $this->file;
|
219 |
+
} else if ( isset($this->_wp_attached_file) ) {
|
220 |
$this->file = reset($this->_wp_attached_file);
|
221 |
$this->file_loc = $basedir . DIRECTORY_SEPARATOR . $this->file;
|
222 |
}
|
223 |
+
if ( isset($image_info['id']) ) {
|
224 |
$this->ID = $image_info['id'];
|
225 |
+
} else if ( is_numeric($iid) ) {
|
226 |
$this->ID = $iid;
|
227 |
}
|
228 |
+
if ( isset($this->ID) ) {
|
229 |
$custom = get_post_custom($this->ID);
|
230 |
foreach ($custom as $key => $value) {
|
231 |
$this->$key = $value[0];
|
232 |
}
|
233 |
} else {
|
234 |
+
if ( is_array($iid) || is_object($iid) ) {
|
235 |
TimberHelper::error_log('Not able to init in TimberImage with iid=');
|
236 |
TimberHelper::error_log($iid);
|
237 |
} else {
|
268 |
*/
|
269 |
protected function init_with_url($url) {
|
270 |
$this->abs_url = $url;
|
271 |
+
if ( TimberURLHelper::is_local($url) ) {
|
272 |
$this->file = ABSPATH . TimberURLHelper::get_rel_url($url);
|
273 |
$this->file_loc = ABSPATH . TimberURLHelper::get_rel_url($url);
|
274 |
}
|
336 |
* ```
|
337 |
*/
|
338 |
public function link() {
|
339 |
+
if ( strlen($this->abs_url) ) {
|
340 |
return $this->abs_url;
|
341 |
}
|
342 |
return get_permalink($this->ID);
|
347 |
* @return bool|TimberPost
|
348 |
*/
|
349 |
public function parent() {
|
350 |
+
if ( !$this->post_parent ) {
|
351 |
return false;
|
352 |
}
|
353 |
return new $this->PostClass($this->post_parent);
|
373 |
* @api
|
374 |
* @example
|
375 |
* ```twig
|
376 |
+
* <h1>{{post.title}}</h1>
|
377 |
+
* <img src="{{post.thumbnail.src}}" />
|
378 |
* ```
|
379 |
* ```html
|
380 |
* <img src="http://example.org/wp-content/uploads/2015/08/pic.jpg" />
|
lib/timber-post.php
CHANGED
@@ -700,6 +700,7 @@ class TimberPost extends TimberCore implements TimberCoreInterface {
|
|
700 |
return $children;
|
701 |
}
|
702 |
|
|
|
703 |
/**
|
704 |
* Get the comments for a post
|
705 |
* @internal
|
@@ -744,7 +745,6 @@ class TimberPost extends TimberCore implements TimberCoreInterface {
|
|
744 |
|
745 |
foreach($comments as $key => &$comment) {
|
746 |
$timber_comment = new $CommentClass($comment);
|
747 |
-
$timber_comment->reply_link = $this->TimberComment_reply_link($comment->comment_ID, $this->ID);
|
748 |
$timber_comments[$timber_comment->id] = $timber_comment;
|
749 |
}
|
750 |
|
700 |
return $children;
|
701 |
}
|
702 |
|
703 |
+
|
704 |
/**
|
705 |
* Get the comments for a post
|
706 |
* @internal
|
745 |
|
746 |
foreach($comments as $key => &$comment) {
|
747 |
$timber_comment = new $CommentClass($comment);
|
|
|
748 |
$timber_comments[$timber_comment->id] = $timber_comment;
|
749 |
}
|
750 |
|
lib/timber-term-getter.php
CHANGED
@@ -1,182 +1,181 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class TimberTermGetter
|
4 |
-
{
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
|
182 |
}
|
1 |
<?php
|
2 |
|
3 |
+
class TimberTermGetter {
|
|
|
4 |
|
5 |
+
/**
|
6 |
+
* @param string|array $args
|
7 |
+
* @param array $maybe_args
|
8 |
+
* @param string $TermClass
|
9 |
+
* @return mixed
|
10 |
+
*/
|
11 |
+
public static function get_terms($args = null, $maybe_args = array(), $TermClass = 'TimberTerm') {
|
12 |
+
if ( is_string($maybe_args) && !strstr($maybe_args, '=') ) {
|
13 |
+
//the user is sending the $TermClass in the second argument
|
14 |
+
$TermClass = $maybe_args;
|
15 |
+
}
|
16 |
+
if ( is_string($maybe_args) && strstr($maybe_args, '=') ) {
|
17 |
+
parse_str($maybe_args, $maybe_args);
|
18 |
+
}
|
19 |
+
if ( is_string($args) && strstr($args, '=') ) {
|
20 |
+
//a string and a query string!
|
21 |
+
$parsed = self::get_term_query_from_query_string($args);
|
22 |
+
if ( is_array($maybe_args) ) {
|
23 |
+
$parsed->args = array_merge($parsed->args, $maybe_args);
|
24 |
+
}
|
25 |
+
return self::handle_term_query($parsed->taxonomies, $parsed->args, $TermClass);
|
26 |
+
} else if ( is_string($args) ) {
|
27 |
+
//its just a string with a single taxonomy
|
28 |
+
$parsed = self::get_term_query_from_string($args);
|
29 |
+
if ( is_array($maybe_args) ) {
|
30 |
+
$parsed->args = array_merge($parsed->args, $maybe_args);
|
31 |
+
}
|
32 |
+
return self::handle_term_query($parsed->taxonomies, $parsed->args, $TermClass);
|
33 |
+
} else if ( is_array($args) && TimberHelper::is_array_assoc($args) ) {
|
34 |
+
//its an associative array, like a good ole query
|
35 |
+
$parsed = self::get_term_query_from_assoc_array($args);
|
36 |
+
return self::handle_term_query($parsed->taxonomies, $parsed->args, $TermClass);
|
37 |
+
} else if ( is_array($args) ) {
|
38 |
+
//its just an array of strings or IDs (hopefully)
|
39 |
+
$parsed = self::get_term_query_from_array($args);
|
40 |
+
if ( is_array($maybe_args) ) {
|
41 |
+
$parsed->args = array_merge($parsed->args, $maybe_args);
|
42 |
+
}
|
43 |
+
return self::handle_term_query($parsed->taxonomies, $parsed->args, $TermClass);
|
44 |
+
} else if ( is_null($args) ) {
|
45 |
+
return self::handle_term_query(get_taxonomies(), array(), $TermClass);
|
46 |
+
}
|
47 |
+
return null;
|
48 |
+
}
|
49 |
|
50 |
+
/**
|
51 |
+
* @param string|array $taxonomies
|
52 |
+
* @param string|array $args
|
53 |
+
* @param string $TermClass
|
54 |
+
* @return mixed
|
55 |
+
*/
|
56 |
+
public static function handle_term_query($taxonomies, $args, $TermClass) {
|
57 |
+
if ( !isset($args['hide_empty']) ) {
|
58 |
+
$args['hide_empty'] = false;
|
59 |
+
}
|
60 |
+
if ( isset($args['term_id']) && is_int($args['term_id']) ) {
|
61 |
+
$args['term_id'] = array($args['term_id']);
|
62 |
+
}
|
63 |
+
if ( isset($args['term_id']) ) {
|
64 |
+
$args['include'] = $args['term_id'];
|
65 |
+
}
|
66 |
+
$terms = get_terms($taxonomies, $args);
|
67 |
+
foreach ($terms as &$term) {
|
68 |
+
$term = new $TermClass($term->term_id, $term->taxonomy);
|
69 |
+
}
|
70 |
+
return $terms;
|
71 |
+
}
|
72 |
|
73 |
+
/**
|
74 |
+
* @param string $query_string
|
75 |
+
* @return stdClass
|
76 |
+
*/
|
77 |
+
protected static function get_term_query_from_query_string($query_string) {
|
78 |
+
$args = array();
|
79 |
+
parse_str($query_string, $args);
|
80 |
+
$ret = self::get_term_query_from_assoc_array($args);
|
81 |
+
return $ret;
|
82 |
+
}
|
83 |
|
84 |
+
/**
|
85 |
+
* @param string $taxs
|
86 |
+
* @return stdClass
|
87 |
+
*/
|
88 |
+
protected static function get_term_query_from_string($taxs) {
|
89 |
+
$ret = new stdClass();
|
90 |
+
$ret->args = array();
|
91 |
+
if ( is_string($taxs) ) {
|
92 |
+
$taxs = array($taxs);
|
93 |
+
}
|
94 |
+
$ret->taxonomies = self::correct_taxonomy_names($taxs);
|
95 |
+
return $ret;
|
96 |
+
}
|
97 |
|
98 |
+
/**
|
99 |
+
* @param array $args
|
100 |
+
* @return stdClass
|
101 |
+
*/
|
102 |
+
public static function get_term_query_from_assoc_array($args) {
|
103 |
+
$ret = new stdClass();
|
104 |
+
$ret->args = $args;
|
105 |
+
if ( isset($ret->args['tax']) ) {
|
106 |
+
$ret->taxonomies = $ret->args['tax'];
|
107 |
+
} else if ( isset($ret->args['taxonomies']) ) {
|
108 |
+
$ret->taxonomies = $ret->args['taxonomies'];
|
109 |
+
} else if ( isset($ret->args['taxs']) ) {
|
110 |
+
$ret->taxonomies = $ret->args['taxs'];
|
111 |
+
} else if ( isset($ret->args['taxonomy']) ) {
|
112 |
+
$ret->taxonomies = $ret->args['taxonomy'];
|
113 |
+
}
|
114 |
+
if ( isset($ret->taxonomies) ) {
|
115 |
+
if ( is_string($ret->taxonomies) ) {
|
116 |
+
$ret->taxonomies = array($ret->taxonomies);
|
117 |
+
}
|
118 |
+
$ret->taxonomies = self::correct_taxonomy_names($ret->taxonomies);
|
119 |
+
} else {
|
120 |
+
$ret->taxonomies = get_taxonomies();
|
121 |
+
}
|
122 |
+
return $ret;
|
123 |
+
}
|
124 |
|
125 |
+
/**
|
126 |
+
* @param array $args
|
127 |
+
* @return stdClass
|
128 |
+
*/
|
129 |
+
public static function get_term_query_from_array($args) {
|
130 |
+
if ( is_array($args) && !empty($args) ) {
|
131 |
+
//okay its an array with content
|
132 |
+
if ( is_int($args[0]) ) {
|
133 |
+
return self::get_term_query_from_array_of_ids($args);
|
134 |
+
} else if ( is_string($args[0]) ) {
|
135 |
+
return self::get_term_query_from_array_of_strings($args);
|
136 |
+
}
|
137 |
+
}
|
138 |
+
return null;
|
139 |
+
}
|
140 |
|
141 |
+
/**
|
142 |
+
* @param integer[] $args
|
143 |
+
* @return stdClass
|
144 |
+
*/
|
145 |
+
public static function get_term_query_from_array_of_ids($args) {
|
146 |
+
$ret = new stdClass();
|
147 |
+
$ret->taxonomies = get_taxonomies();
|
148 |
+
$ret->args['include'] = $args;
|
149 |
+
return $ret;
|
150 |
+
}
|
151 |
|
152 |
+
/**
|
153 |
+
* @param string[] $args
|
154 |
+
* @return stdClass
|
155 |
+
*/
|
156 |
+
public static function get_term_query_from_array_of_strings($args) {
|
157 |
+
$ret = new stdClass();
|
158 |
+
$ret->taxonomies = self::correct_taxonomy_names($args);
|
159 |
+
$ret->args = array();
|
160 |
+
return $ret;
|
161 |
+
}
|
162 |
|
163 |
+
/**
|
164 |
+
* @param string|array $taxs
|
165 |
+
* @return array
|
166 |
+
*/
|
167 |
+
private static function correct_taxonomy_names($taxs) {
|
168 |
+
if ( is_string($taxs) ) {
|
169 |
+
$taxs = array($taxs);
|
170 |
+
}
|
171 |
+
foreach ($taxs as &$tax) {
|
172 |
+
if ( $tax == 'tags' || $tax == 'tag' ) {
|
173 |
+
$tax = 'post_tag';
|
174 |
+
} else if ( $tax == 'categories' ) {
|
175 |
+
$tax = 'category';
|
176 |
+
}
|
177 |
+
}
|
178 |
+
return $taxs;
|
179 |
+
}
|
180 |
|
181 |
}
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: jarednova, lggorman
|
3 |
Tags: template engine, templates, twig
|
4 |
Requires at least: 3.7
|
5 |
-
Stable tag: 0.22.
|
6 |
-
Tested up to: 4.
|
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,10 @@ Timber is great for any WordPress developer who cares about writing good, mainta
|
|
41 |
|
42 |
== Changelog ==
|
43 |
|
|
|
|
|
|
|
|
|
44 |
= 0.22.4 =
|
45 |
* Fixed [bug](https://github.com/jarednova/timber/issues/785) in get_calling_script file (thanks @gwagroves)
|
46 |
* Added tons of new tests and docs (thanks @lggorman and @jarednova)
|
2 |
Contributors: jarednova, lggorman
|
3 |
Tags: template engine, templates, twig
|
4 |
Requires at least: 3.7
|
5 |
+
Stable tag: 0.22.5
|
6 |
+
Tested up to: 4.4.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 |
|
42 |
== Changelog ==
|
43 |
|
44 |
+
= 0.22.5 =
|
45 |
+
* Fixed errors in tests (thanks @lggorman)
|
46 |
+
* Fixed error in comments_link (thanks @tehlivi)
|
47 |
+
|
48 |
= 0.22.4 =
|
49 |
* Fixed [bug](https://github.com/jarednova/timber/issues/785) in get_calling_script file (thanks @gwagroves)
|
50 |
* Added tons of new tests and docs (thanks @lggorman and @jarednova)
|
timber.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Timber
|
|
4 |
Description: The WordPress Timber Library allows you to write themes using the power Twig templates.
|
5 |
Plugin URI: http://timber.upstatement.com
|
6 |
Author: Jared Novack + Upstatement
|
7 |
-
Version: 0.22.
|
8 |
Author URI: http://upstatement.com/
|
9 |
*/
|
10 |
|
4 |
Description: The WordPress Timber Library allows you to write themes using the power Twig templates.
|
5 |
Plugin URI: http://timber.upstatement.com
|
6 |
Author: Jared Novack + Upstatement
|
7 |
+
Version: 0.22.5
|
8 |
Author URI: http://upstatement.com/
|
9 |
*/
|
10 |
|
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 ComposerAutoloaderInita300217f36ff83f02ad639201f3add11::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 ComposerAutoloaderInitda6ae1fb7a0f5ad33c0ddd4db606e55b
|
|
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 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
27 |
foreach ($map as $namespace => $path) {
|
@@ -44,7 +44,7 @@ class ComposerAutoloaderInitda6ae1fb7a0f5ad33c0ddd4db606e55b
|
|
44 |
}
|
45 |
}
|
46 |
|
47 |
-
function
|
48 |
{
|
49 |
require $file;
|
50 |
}
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInita300217f36ff83f02ad639201f3add11
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInita300217f36ff83f02ad639201f3add11', 'loadClassLoader'), true, true);
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInita300217f36ff83f02ad639201f3add11', 'loadClassLoader'));
|
25 |
|
26 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
27 |
foreach ($map as $namespace => $path) {
|
44 |
}
|
45 |
}
|
46 |
|
47 |
+
function composerRequirea300217f36ff83f02ad639201f3add11($file)
|
48 |
{
|
49 |
require $file;
|
50 |
}
|