Version Description
Download this release
Release Info
Developer | jarednova |
Plugin | Timber |
Version | 0.15.1 |
Comparing to | |
See all releases |
Code changes from version 0.15.0 to 0.15.1
- README.md +7 -1
- functions/timber-image.php +4 -1
- functions/timber-post.php +2 -2
- functions/timber-term.php +18 -1
- readme.txt +1 -1
- timber.php +21 -2
README.md
CHANGED
@@ -7,7 +7,7 @@ By Jared Novack (<a href="http://twitter.com/jarednova">@JaredNova</a>) and <a h
|
|
7 |
[![Build Status](https://travis-ci.org/jarednova/timber.png)](https://travis-ci.org/jarednova/timber)
|
8 |
|
9 |
### Because WordPress is awesome, but the_loop isn't
|
10 |
-
Timber helps you create fully-customized WordPress themes faster with more sustainable code. With Timber, you write your HTML using the [Twig Template Engine](http://twig.sensiolabs.org/) separate from your PHP files.
|
11 |
|
12 |
This cleans-up your theme code so, for example, your php file can focus on being the data, while your twig file can focus 100% on the HTML and display.
|
13 |
|
@@ -39,6 +39,12 @@ Just drag the `timber` folder into `wp-content/plugins` -- then activate in your
|
|
39 |
|
40 |
* * *
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
#### What does it look like?
|
43 |
Nothing. Timber is meant for you to build a theme on. Like the [Starkers](https://github.com/viewportindustries/starkers) or [Boilerplate theme](https://github.com/zencoder/html5-boilerplate-for-wordpress) it comes style-free, because you're the style expert. Instead, Timber handles the logic you need to make a kick-ass looking site.
|
44 |
|
7 |
[![Build Status](https://travis-ci.org/jarednova/timber.png)](https://travis-ci.org/jarednova/timber)
|
8 |
|
9 |
### Because WordPress is awesome, but the_loop isn't
|
10 |
+
Timber helps you create fully-customized WordPress themes faster with more sustainable code. With Timber, you write your HTML using the [Twig Template Engine](http://twig.sensiolabs.org/) separate from your PHP files.
|
11 |
|
12 |
This cleans-up your theme code so, for example, your php file can focus on being the data, while your twig file can focus 100% on the HTML and display.
|
13 |
|
39 |
|
40 |
* * *
|
41 |
|
42 |
+
### Mission Statement
|
43 |
+
Timber is a tool for developers who want to translate their HTML into high-quality WordPress themes through an intuitive, consistent and fully-accessible interface.
|
44 |
+
* **Intuitive**: The API is written to be user-centric around a programmer's expectations.
|
45 |
+
* **Consistent**: All WordPress objects can be accessed through polymorphic properties like slug, ID and name.
|
46 |
+
* **Accessible**: No black boxes. Every effort is made so the developer has access to 100% of their HTML.
|
47 |
+
|
48 |
#### What does it look like?
|
49 |
Nothing. Timber is meant for you to build a theme on. Like the [Starkers](https://github.com/viewportindustries/starkers) or [Boilerplate theme](https://github.com/zencoder/html5-boilerplate-for-wordpress) it comes style-free, because you're the style expert. Instead, Timber handles the logic you need to make a kick-ass looking site.
|
50 |
|
functions/timber-image.php
CHANGED
@@ -71,7 +71,10 @@ class TimberImage extends TimberCore {
|
|
71 |
$image_custom = get_post_custom($iid);
|
72 |
$basic = get_post($iid);
|
73 |
$this->caption = $basic->post_excerpt;
|
74 |
-
|
|
|
|
|
|
|
75 |
} else if (is_array($image_info) && isset($image_info['image'])) {
|
76 |
$image_info = $image_info['image'];
|
77 |
} else if (is_object($image_info)) {
|
71 |
$image_custom = get_post_custom($iid);
|
72 |
$basic = get_post($iid);
|
73 |
$this->caption = $basic->post_excerpt;
|
74 |
+
if ($basic){
|
75 |
+
$image_custom = array_merge($image_custom, get_object_vars($basic));
|
76 |
+
}
|
77 |
+
$image_info = array_merge($image_info, $image_custom);
|
78 |
} else if (is_array($image_info) && isset($image_info['image'])) {
|
79 |
$image_info = $image_info['image'];
|
80 |
} else if (is_object($image_info)) {
|
functions/timber-post.php
CHANGED
@@ -228,14 +228,14 @@ class TimberPost extends TimberCore {
|
|
228 |
|
229 |
function get_next() {
|
230 |
if (!isset($this->next)){
|
231 |
-
$this->next = new $this->PostClass(get_adjacent_post( false, "",
|
232 |
}
|
233 |
return $this->next;
|
234 |
}
|
235 |
|
236 |
function get_prev() {
|
237 |
if (!isset($this->prev)){
|
238 |
-
$this->prev = new $this->PostClass(get_adjacent_post( false, "",
|
239 |
}
|
240 |
return $this->prev;
|
241 |
}
|
228 |
|
229 |
function get_next() {
|
230 |
if (!isset($this->next)){
|
231 |
+
$this->next = new $this->PostClass(get_adjacent_post( false, "", false ));
|
232 |
}
|
233 |
return $this->next;
|
234 |
}
|
235 |
|
236 |
function get_prev() {
|
237 |
if (!isset($this->prev)){
|
238 |
+
$this->prev = new $this->PostClass(get_adjacent_post( false, "", true ));
|
239 |
}
|
240 |
return $this->prev;
|
241 |
}
|
functions/timber-term.php
CHANGED
@@ -3,7 +3,9 @@
|
|
3 |
class TimberTerm extends TimberCore {
|
4 |
|
5 |
var $taxonomy;
|
|
|
6 |
var $PostClass = 'TimberPost';
|
|
|
7 |
|
8 |
public static $representation = 'term';
|
9 |
|
@@ -111,7 +113,7 @@ class TimberTerm extends TimberCore {
|
|
111 |
return $this->get_link();
|
112 |
}
|
113 |
|
114 |
-
function get_posts($numberposts = 10, $post_type = 'any', $PostClass = '') {
|
115 |
if (!strlen($PostClass)) {
|
116 |
$PostClass = $this->PostClass;
|
117 |
}
|
@@ -127,9 +129,24 @@ class TimberTerm extends TimberCore {
|
|
127 |
return Timber::get_posts($args, $PostClass);
|
128 |
}
|
129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
/* Alias
|
131 |
====================== */
|
132 |
|
|
|
|
|
|
|
|
|
133 |
public function link(){
|
134 |
return $this->get_link();
|
135 |
}
|
3 |
class TimberTerm extends TimberCore {
|
4 |
|
5 |
var $taxonomy;
|
6 |
+
var $_children;
|
7 |
var $PostClass = 'TimberPost';
|
8 |
+
var $TermClass = 'TimberTerm';
|
9 |
|
10 |
public static $representation = 'term';
|
11 |
|
113 |
return $this->get_link();
|
114 |
}
|
115 |
|
116 |
+
public function get_posts($numberposts = 10, $post_type = 'any', $PostClass = '') {
|
117 |
if (!strlen($PostClass)) {
|
118 |
$PostClass = $this->PostClass;
|
119 |
}
|
129 |
return Timber::get_posts($args, $PostClass);
|
130 |
}
|
131 |
|
132 |
+
public function get_children(){
|
133 |
+
if (!isset($this->_children)){
|
134 |
+
$children = get_term_children($this->ID, $this->taxonomy);
|
135 |
+
foreach($children as &$child){
|
136 |
+
$child = new TimberTerm($child);
|
137 |
+
}
|
138 |
+
$this->_children = $children;
|
139 |
+
}
|
140 |
+
return $this->_children;
|
141 |
+
}
|
142 |
+
|
143 |
/* Alias
|
144 |
====================== */
|
145 |
|
146 |
+
public function children(){
|
147 |
+
return $this->get_children();
|
148 |
+
}
|
149 |
+
|
150 |
public function link(){
|
151 |
return $this->get_link();
|
152 |
}
|
readme.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
Contributors: jarednova
|
3 |
Tags: template engine, templates, twig
|
4 |
Requires at least: 3.5
|
5 |
-
Stable tag: 0.15.
|
6 |
Tested up to: 3.6.1
|
7 |
PHP version: 5.3.0 or greater
|
8 |
License: GPLv2 or later
|
2 |
Contributors: jarednova
|
3 |
Tags: template engine, templates, twig
|
4 |
Requires at least: 3.5
|
5 |
+
Stable tag: 0.15.1
|
6 |
Tested up to: 3.6.1
|
7 |
PHP version: 5.3.0 or greater
|
8 |
License: GPLv2 or later
|
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.15.
|
8 |
Author URI: http://upstatement.com/
|
9 |
*/
|
10 |
|
@@ -247,14 +247,27 @@ class Timber {
|
|
247 |
/* Term Retrieval
|
248 |
================================ */
|
249 |
|
250 |
-
public static function get_terms($args, $TermClass = 'TimberTerm'){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
if (is_string($args) && strstr($args, '=')){
|
252 |
//a string and a query string!
|
253 |
$parsed = TimberTermGetter::get_term_query_from_query_string($args);
|
|
|
|
|
|
|
254 |
return self::handle_term_query($parsed->taxonomies, $parsed->args, $TermClass);
|
255 |
} else if (is_string($args)){
|
256 |
//its just a string with a single taxonomy
|
257 |
$parsed = TimberTermGetter::get_term_query_from_string($args);
|
|
|
|
|
|
|
258 |
return self::handle_term_query($parsed->taxonomies, $parsed->args, $TermClass);
|
259 |
} else if (is_array($args) && TimberHelper::is_array_assoc($args)){
|
260 |
//its an associative array, like a good ole query
|
@@ -263,6 +276,9 @@ class Timber {
|
|
263 |
} else if (is_array($args)){
|
264 |
//its just an array of strings or IDs (hopefully)
|
265 |
$parsed = TimberTermGetter::get_term_query_from_array($args);
|
|
|
|
|
|
|
266 |
return self::handle_term_query($parsed->taxonomies, $parsed->args, $TermClass);
|
267 |
} else {
|
268 |
//no clue, what you talkin' bout?
|
@@ -271,6 +287,9 @@ class Timber {
|
|
271 |
}
|
272 |
|
273 |
public static function handle_term_query($taxonomies, $args, $TermClass){
|
|
|
|
|
|
|
274 |
$terms = get_terms($taxonomies, $args);
|
275 |
foreach($terms as &$term){
|
276 |
$term = new $TermClass($term->term_id);
|
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.15.1
|
8 |
Author URI: http://upstatement.com/
|
9 |
*/
|
10 |
|
247 |
/* Term Retrieval
|
248 |
================================ */
|
249 |
|
250 |
+
public static function get_terms($args, $maybe_args = array(), $TermClass = 'TimberTerm'){
|
251 |
+
if (is_string($maybe_args) && !strstr($maybe_args, '=')){
|
252 |
+
//the user is sending the $TermClass in the second argument
|
253 |
+
$TermClass = $maybe_args;
|
254 |
+
}
|
255 |
+
if (is_string($maybe_args) && strstr($maybe_args, '=')){
|
256 |
+
parse_str($maybe_args, $maybe_args);
|
257 |
+
}
|
258 |
if (is_string($args) && strstr($args, '=')){
|
259 |
//a string and a query string!
|
260 |
$parsed = TimberTermGetter::get_term_query_from_query_string($args);
|
261 |
+
if (is_array($maybe_args)){
|
262 |
+
$parsed->args = array_merge($parsed->args, $maybe_args);
|
263 |
+
}
|
264 |
return self::handle_term_query($parsed->taxonomies, $parsed->args, $TermClass);
|
265 |
} else if (is_string($args)){
|
266 |
//its just a string with a single taxonomy
|
267 |
$parsed = TimberTermGetter::get_term_query_from_string($args);
|
268 |
+
if (is_array($maybe_args)){
|
269 |
+
$parsed->args = array_merge($parsed->args, $maybe_args);
|
270 |
+
}
|
271 |
return self::handle_term_query($parsed->taxonomies, $parsed->args, $TermClass);
|
272 |
} else if (is_array($args) && TimberHelper::is_array_assoc($args)){
|
273 |
//its an associative array, like a good ole query
|
276 |
} else if (is_array($args)){
|
277 |
//its just an array of strings or IDs (hopefully)
|
278 |
$parsed = TimberTermGetter::get_term_query_from_array($args);
|
279 |
+
if (is_array($maybe_args)){
|
280 |
+
$parsed->args = array_merge($parsed->args, $maybe_args);
|
281 |
+
}
|
282 |
return self::handle_term_query($parsed->taxonomies, $parsed->args, $TermClass);
|
283 |
} else {
|
284 |
//no clue, what you talkin' bout?
|
287 |
}
|
288 |
|
289 |
public static function handle_term_query($taxonomies, $args, $TermClass){
|
290 |
+
if (!isset($args['hide_empty'])){
|
291 |
+
$args['hide_empty'] = false;
|
292 |
+
}
|
293 |
$terms = get_terms($taxonomies, $args);
|
294 |
foreach($terms as &$term){
|
295 |
$term = new $TermClass($term->term_id);
|