Version Description
- TimberImages now support alternate sizes
Download this release
Release Info
Developer | jarednova |
Plugin | Timber |
Version | 0.15.2 |
Comparing to | |
See all releases |
Code changes from version 0.15.1 to 0.15.2
- README.md +5 -1
- functions/timber-comment.php +9 -9
- functions/timber-image.php +17 -11
- functions/timber-loader.php +1 -1
- functions/timber-menu.php +8 -1
- functions/timber-post.php +4 -0
- functions/timber-site.php +47 -0
- functions/timber-theme.php +4 -7
- functions/timber-user.php +27 -9
- readme.txt +10 -1
- timber.php +17 -1
README.md
CHANGED
@@ -51,8 +51,12 @@ Nothing. Timber is meant for you to build a theme on. Like the [Starkers](https:
|
|
51 |
#### Who is it good for?
|
52 |
Timber is great for any WordPress developer who cares about writing good, maintainable code. It helps teams of designers and developers working together. At [Upstatement](http://upstatement.com) we made Timber because not everyone knows the ins-and-outs of the_loop(), WordPress codex and PHP (nor should they). With Timber your best WordPress dev can focus on building the .php files with requests from WordPress and pass the data into .twig files. Once there, designers can easily mark-up data and build out a site's look-and-feel.
|
53 |
|
|
|
|
|
|
|
|
|
54 |
#### Should I use it?
|
55 |
-
Well, it's **free**! And it's GPL-licensed, so use in personal or
|
56 |
|
57 |
#### Upgrade Notes
|
58 |
Twig is no longer a submodule, just a part of the repo. If you have trouble pulling, just delete the `Twig` folder. Then you should be good.
|
51 |
#### Who is it good for?
|
52 |
Timber is great for any WordPress developer who cares about writing good, maintainable code. It helps teams of designers and developers working together. At [Upstatement](http://upstatement.com) we made Timber because not everyone knows the ins-and-outs of the_loop(), WordPress codex and PHP (nor should they). With Timber your best WordPress dev can focus on building the .php files with requests from WordPress and pass the data into .twig files. Once there, designers can easily mark-up data and build out a site's look-and-feel.
|
53 |
|
54 |
+
#### Related Projects
|
55 |
+
* [**Timber Debug Bar**](https://github.com/upstatement/debug-bar-timber) Adds a debug bar panel that will show you want template is in-use and the data sent to your twig file.
|
56 |
+
* [**Twig**](https://github.com/fabpot/Twig) The template language used by Timber.
|
57 |
+
|
58 |
#### Should I use it?
|
59 |
+
Well, it's **free**! And it's GPL-licensed, so use in personal or commercial work. Just don't re-sell it.
|
60 |
|
61 |
#### Upgrade Notes
|
62 |
Twig is no longer a submodule, just a part of the repo. If you have trouble pulling, just delete the `Twig` folder. Then you should be good.
|
functions/timber-comment.php
CHANGED
@@ -10,18 +10,18 @@ class TimberComment extends TimberCore {
|
|
10 |
$this->init($cid);
|
11 |
}
|
12 |
|
13 |
-
/* core definition */
|
14 |
-
|
15 |
function author() {
|
16 |
if ($this->user_id) {
|
17 |
return new TimberUser($this->user_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
}
|
19 |
-
$
|
20 |
-
$fakeUser->name = 'Anonymous';
|
21 |
-
if ($this->comment_author) {
|
22 |
-
$fakeUser->name = $this->comment_author;
|
23 |
-
}
|
24 |
-
return $fakeUser;
|
25 |
}
|
26 |
|
27 |
function date() {
|
@@ -41,4 +41,4 @@ class TimberComment extends TimberCore {
|
|
41 |
$this->ID = $this->comment_ID;
|
42 |
}
|
43 |
|
44 |
-
}
|
10 |
$this->init($cid);
|
11 |
}
|
12 |
|
|
|
|
|
13 |
function author() {
|
14 |
if ($this->user_id) {
|
15 |
return new TimberUser($this->user_id);
|
16 |
+
} else {
|
17 |
+
$author = new TimberUser(0);
|
18 |
+
if (isset($this->comment_author) && $this->comment_author){
|
19 |
+
$author->name = $this->comment_author;
|
20 |
+
} else {
|
21 |
+
$author->name = 'Anonymous';
|
22 |
+
}
|
23 |
}
|
24 |
+
return $author;
|
|
|
|
|
|
|
|
|
|
|
25 |
}
|
26 |
|
27 |
function date() {
|
41 |
$this->ID = $this->comment_ID;
|
42 |
}
|
43 |
|
44 |
+
}
|
functions/timber-image.php
CHANGED
@@ -23,20 +23,26 @@ class TimberImage extends TimberCore {
|
|
23 |
return pathinfo($this->file);
|
24 |
}
|
25 |
|
26 |
-
function get_src() {
|
27 |
if (isset($this->abs_url)) {
|
28 |
return $this->abs_url;
|
29 |
}
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
31 |
$this->file = $this->_wp_attached_file;
|
32 |
}
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
40 |
}
|
41 |
|
42 |
function get_path() {
|
@@ -107,7 +113,7 @@ class TimberImage extends TimberCore {
|
|
107 |
|
108 |
/* Alias */
|
109 |
|
110 |
-
function src() {
|
111 |
-
return $this->get_src();
|
112 |
}
|
113 |
}
|
23 |
return pathinfo($this->file);
|
24 |
}
|
25 |
|
26 |
+
function get_src( $size = '' ) {
|
27 |
if (isset($this->abs_url)) {
|
28 |
return $this->abs_url;
|
29 |
}
|
30 |
+
|
31 |
+
if ($size && is_string($size) && isset($this->sizes[$size])) {
|
32 |
+
return reset(image_downsize($this->ID, $size));
|
33 |
+
}
|
34 |
+
|
35 |
+
if (!isset($this->file) && isset($this->_wp_attached_file)) {
|
36 |
$this->file = $this->_wp_attached_file;
|
37 |
}
|
38 |
+
|
39 |
+
if (!isset($this->file))
|
40 |
+
return false;
|
41 |
+
|
42 |
+
$dir = wp_upload_dir();
|
43 |
+
$base = ($dir["baseurl"]);
|
44 |
+
return trailingslashit($base) . $this->file;
|
45 |
+
|
46 |
}
|
47 |
|
48 |
function get_path() {
|
113 |
|
114 |
/* Alias */
|
115 |
|
116 |
+
function src($size = '') {
|
117 |
+
return $this->get_src($size);
|
118 |
}
|
119 |
}
|
functions/timber-loader.php
CHANGED
@@ -202,7 +202,7 @@ class TimberLoader {
|
|
202 |
|
203 |
$cache_mode = $this->_get_cache_mode( $cache_mode );
|
204 |
|
205 |
-
$value =
|
206 |
|
207 |
$trans_key = substr($group . '_' . $key, 0, self::TRANS_KEY_LEN);
|
208 |
if ( self::CACHE_TRANSIENT === $cache_mode )
|
202 |
|
203 |
$cache_mode = $this->_get_cache_mode( $cache_mode );
|
204 |
|
205 |
+
$value = false;
|
206 |
|
207 |
$trans_key = substr($group . '_' . $key, 0, self::TRANS_KEY_LEN);
|
208 |
if ( self::CACHE_TRANSIENT === $cache_mode )
|
functions/timber-menu.php
CHANGED
@@ -103,10 +103,17 @@ class TimberMenuItem extends TimberCore {
|
|
103 |
function __construct($data) {
|
104 |
$this->import($data);
|
105 |
$this->import_classes($data);
|
|
|
|
|
|
|
|
|
106 |
}
|
107 |
|
108 |
function name() {
|
109 |
-
|
|
|
|
|
|
|
110 |
}
|
111 |
|
112 |
function slug() {
|
103 |
function __construct($data) {
|
104 |
$this->import($data);
|
105 |
$this->import_classes($data);
|
106 |
+
if (isset($this->name)){
|
107 |
+
$this->_name = $this->name;
|
108 |
+
}
|
109 |
+
$this->name = $this->name();
|
110 |
}
|
111 |
|
112 |
function name() {
|
113 |
+
if (isset($this->title)){
|
114 |
+
return $this->title;
|
115 |
+
}
|
116 |
+
return $this->_name;
|
117 |
}
|
118 |
|
119 |
function slug() {
|
functions/timber-post.php
CHANGED
@@ -473,6 +473,10 @@ class TimberPost extends TimberCore {
|
|
473 |
return date(get_option('date_format'), strtotime($this->post_date));
|
474 |
}
|
475 |
|
|
|
|
|
|
|
|
|
476 |
function link() {
|
477 |
return $this->get_permalink();
|
478 |
}
|
473 |
return date(get_option('date_format'), strtotime($this->post_date));
|
474 |
}
|
475 |
|
476 |
+
function edit_link(){
|
477 |
+
return $this->get_edit_url();
|
478 |
+
}
|
479 |
+
|
480 |
function link() {
|
481 |
return $this->get_permalink();
|
482 |
}
|
functions/timber-site.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class TimberSite extends TimberCore {
|
4 |
+
function __construct($site_name_or_id = null){
|
5 |
+
$this->init($site_name_or_id);
|
6 |
+
}
|
7 |
+
|
8 |
+
function init($site_name_or_id){
|
9 |
+
if ($site_name_or_id === null){
|
10 |
+
//this is necessary for some reason, otherwise returns 1 all the time
|
11 |
+
restore_current_blog();
|
12 |
+
$site_name_or_id = get_current_blog_id();
|
13 |
+
}
|
14 |
+
$info = get_blog_details($site_name_or_id);
|
15 |
+
$this->import($info);
|
16 |
+
$this->ID = $info->blog_id;
|
17 |
+
$this->name = $this->blogname;
|
18 |
+
$this->title = $this->blogname;
|
19 |
+
$theme_slug = get_blog_option($info->blog_id, 'stylesheet');
|
20 |
+
//echo 'init '.$theme_slug;
|
21 |
+
$this->theme = new TimberTheme($theme_slug);
|
22 |
+
$this->description = get_blog_option($info->blog_id, 'blogdescription');
|
23 |
+
}
|
24 |
+
|
25 |
+
function __get($field){
|
26 |
+
if (!isset($this->$field)){
|
27 |
+
$this->$field = get_blog_option($this->ID, $field);
|
28 |
+
}
|
29 |
+
return $this->$field;
|
30 |
+
}
|
31 |
+
|
32 |
+
function get_link(){
|
33 |
+
return $this->siteurl;
|
34 |
+
}
|
35 |
+
|
36 |
+
function get_url(){
|
37 |
+
return $this->get_link();
|
38 |
+
}
|
39 |
+
|
40 |
+
function link(){
|
41 |
+
return $this->get_link();
|
42 |
+
}
|
43 |
+
|
44 |
+
function url(){
|
45 |
+
return $this->get_link();
|
46 |
+
}
|
47 |
+
}
|
functions/timber-theme.php
CHANGED
@@ -9,15 +9,12 @@
|
|
9 |
function init($slug = null){
|
10 |
$data = wp_get_theme($slug);
|
11 |
$this->name = $data->get('Name');
|
12 |
-
$ss =
|
13 |
-
$
|
14 |
-
$this->slug = array_pop($ss);
|
15 |
$this->parent_slug = $data->get('Template');
|
16 |
-
if ($this->parent_slug != $this->slug){
|
17 |
-
|
18 |
}
|
19 |
-
//$this->import($data);
|
20 |
-
//$this->slug =
|
21 |
}
|
22 |
|
23 |
}
|
9 |
function init($slug = null){
|
10 |
$data = wp_get_theme($slug);
|
11 |
$this->name = $data->get('Name');
|
12 |
+
$ss = $data->get_stylesheet();
|
13 |
+
$this->slug = $ss;
|
|
|
14 |
$this->parent_slug = $data->get('Template');
|
15 |
+
if ($this->parent_slug && $this->parent_slug != $this->slug){
|
16 |
+
$this->parent = new TimberTheme($this->parent_slug);
|
17 |
}
|
|
|
|
|
18 |
}
|
19 |
|
20 |
}
|
functions/timber-user.php
CHANGED
@@ -10,25 +10,43 @@ class TimberUser extends TimberCore {
|
|
10 |
$this->init($uid);
|
11 |
}
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
public function get_link() {
|
14 |
if (!$this->_link){
|
15 |
-
$
|
16 |
-
global $wp_rewrite;
|
17 |
-
$this->_link = $p . trailingslashit($wp_rewrite->author_base) . $this->slug();
|
18 |
}
|
19 |
return $this->_link;
|
20 |
}
|
21 |
|
22 |
function init($uid = false) {
|
23 |
-
if (
|
24 |
$uid = get_current_user_id();
|
25 |
}
|
26 |
-
|
27 |
-
|
28 |
-
$
|
|
|
|
|
|
|
|
|
29 |
}
|
30 |
-
$this->ID = $uid;
|
31 |
-
$this->import_custom();
|
32 |
}
|
33 |
|
34 |
function get_custom() {
|
10 |
$this->init($uid);
|
11 |
}
|
12 |
|
13 |
+
function __toString(){
|
14 |
+
$name = $this->name();
|
15 |
+
if (strlen($name)){
|
16 |
+
return $name;
|
17 |
+
}
|
18 |
+
if (strlen($this->name)){
|
19 |
+
return $this->name;
|
20 |
+
}
|
21 |
+
return '';
|
22 |
+
}
|
23 |
+
|
24 |
+
function __set($field, $value){
|
25 |
+
if ($field == 'name'){
|
26 |
+
$this->display_name = $value;
|
27 |
+
}
|
28 |
+
$this->$field = $value;
|
29 |
+
}
|
30 |
+
|
31 |
public function get_link() {
|
32 |
if (!$this->_link){
|
33 |
+
$this->_link = get_author_posts_url($this->ID);
|
|
|
|
|
34 |
}
|
35 |
return $this->_link;
|
36 |
}
|
37 |
|
38 |
function init($uid = false) {
|
39 |
+
if ($uid === false) {
|
40 |
$uid = get_current_user_id();
|
41 |
}
|
42 |
+
if ($uid){
|
43 |
+
$data = get_userdata($uid);
|
44 |
+
if (is_object($data) && isset($data)) {
|
45 |
+
$this->import($data->data);
|
46 |
+
}
|
47 |
+
$this->ID = $uid;
|
48 |
+
$this->import_custom();
|
49 |
}
|
|
|
|
|
50 |
}
|
51 |
|
52 |
function get_custom() {
|
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
|
@@ -23,6 +23,9 @@ _Twig is the template language powering Timber; if you need a little background
|
|
23 |
* **[Video Tutorials](https://github.com/jarednova/timber/wiki/Video-Tutorials)**
|
24 |
* [Overview / Getting Started Guide](https://github.com/jarednova/timber/wiki/getting-started)
|
25 |
|
|
|
|
|
|
|
26 |
#### What does it look like?
|
27 |
Nothing. Timber is meant for you to build a theme on. Like the [Starkers](https://github.com/viewportindustries/starkers) or [_s theme](https://github.com/Automattic/_s) it comes style-free, because you're the style expert. Instead, Timber handles the logic you need to make a kick-ass looking site.
|
28 |
|
@@ -38,6 +41,12 @@ Timber is great for any WordPress developer who cares about writing good, mainta
|
|
38 |
|
39 |
== Changelog ==
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
= 0.15.0 =
|
42 |
* Cacheing!!!
|
43 |
* Cacheing!!
|
2 |
Contributors: jarednova
|
3 |
Tags: template engine, templates, twig
|
4 |
Requires at least: 3.5
|
5 |
+
Stable tag: 0.15.2
|
6 |
Tested up to: 3.6.1
|
7 |
PHP version: 5.3.0 or greater
|
8 |
License: GPLv2 or later
|
23 |
* **[Video Tutorials](https://github.com/jarednova/timber/wiki/Video-Tutorials)**
|
24 |
* [Overview / Getting Started Guide](https://github.com/jarednova/timber/wiki/getting-started)
|
25 |
|
26 |
+
#### Related Projects
|
27 |
+
* [**Timber Debug Bar**](http://wordpress.org/plugins/debug-bar-timber/) Adds a debug bar panel that will show you want template is in-use and the data sent to your twig file.
|
28 |
+
|
29 |
#### What does it look like?
|
30 |
Nothing. Timber is meant for you to build a theme on. Like the [Starkers](https://github.com/viewportindustries/starkers) or [_s theme](https://github.com/Automattic/_s) it comes style-free, because you're the style expert. Instead, Timber handles the logic you need to make a kick-ass looking site.
|
31 |
|
41 |
|
42 |
== Changelog ==
|
43 |
|
44 |
+
= 0.15.2 =
|
45 |
+
* TimberImages now support alternate sizes
|
46 |
+
|
47 |
+
= 0.15.1 =
|
48 |
+
* Fix on revered prev/next post links
|
49 |
+
|
50 |
= 0.15.0 =
|
51 |
* Cacheing!!!
|
52 |
* Cacheing!!
|
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 |
|
@@ -24,6 +24,7 @@ require_once(__DIR__ . '/functions/timber-term-getter.php');
|
|
24 |
require_once(__DIR__ . '/functions/timber-image.php');
|
25 |
require_once(__DIR__ . '/functions/timber-menu.php');
|
26 |
require_once(__DIR__ . '/functions/timber-theme.php');
|
|
|
27 |
|
28 |
require_once(__DIR__ . '/functions/timber-loader.php');
|
29 |
require_once(__DIR__ . '/functions/timber-function-wrapper.php');
|
@@ -297,6 +298,21 @@ class Timber {
|
|
297 |
return $terms;
|
298 |
}
|
299 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
300 |
|
301 |
/* Template Setup and Display
|
302 |
================================ */
|
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.2
|
8 |
Author URI: http://upstatement.com/
|
9 |
*/
|
10 |
|
24 |
require_once(__DIR__ . '/functions/timber-image.php');
|
25 |
require_once(__DIR__ . '/functions/timber-menu.php');
|
26 |
require_once(__DIR__ . '/functions/timber-theme.php');
|
27 |
+
require_once(__DIR__ . '/functions/timber-site.php');
|
28 |
|
29 |
require_once(__DIR__ . '/functions/timber-loader.php');
|
30 |
require_once(__DIR__ . '/functions/timber-function-wrapper.php');
|
298 |
return $terms;
|
299 |
}
|
300 |
|
301 |
+
/* Site Retrieval
|
302 |
+
================================ */
|
303 |
+
|
304 |
+
public static function get_sites($blog_ids = false){
|
305 |
+
if (!is_array($blog_ids)){
|
306 |
+
global $wpdb;
|
307 |
+
$site_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
|
308 |
+
}
|
309 |
+
$return = array();
|
310 |
+
foreach($blog_ids as $blog_id){
|
311 |
+
$return[] = new TimberSite($blog_id);
|
312 |
+
}
|
313 |
+
return $return;
|
314 |
+
}
|
315 |
+
|
316 |
|
317 |
/* Template Setup and Display
|
318 |
================================ */
|