Version Description
Download this release
Release Info
Developer | jarednova |
Plugin | Timber |
Version | 0.10.5 |
Comparing to | |
See all releases |
Code changes from version 0.10.4 to 0.10.5
- README.md +16 -1
- functions/functions-twig.php +2 -0
- objects/timber-post.php +5 -3
- readme.txt +1 -1
- timber.php +11 -2
README.md
CHANGED
@@ -4,11 +4,26 @@
|
|
4 |
By Jared Novack (<a href="http://twitter.com/jarednova">@JaredNova</a>) and <a href="http://upstatement.com">Upstatement</a> (<a href="http://twitter.com/upstatement">@Upstatement</a>)</div>
|
5 |
</div>
|
6 |
|
|
|
|
|
7 |
### Because WordPress is awesome, but the_loop isn't
|
8 |
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.
|
9 |
|
10 |
-
This cleans-up your theme code so, for example, your php file can focus on being the data, while your twig
|
|
|
|
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
Once Timber is installed and activated in your plugin directory, it gives any WordPress theme the ability to take advantage of the power of Twig and other Timber features.
|
13 |
|
14 |
### Looking for docs?
|
4 |
By Jared Novack (<a href="http://twitter.com/jarednova">@JaredNova</a>) and <a href="http://upstatement.com">Upstatement</a> (<a href="http://twitter.com/upstatement">@Upstatement</a>)</div>
|
5 |
</div>
|
6 |
|
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 |
+
|
14 |
+
This is what Timber's `.twig` files look like:
|
15 |
|
16 |
+
```html
|
17 |
+
{% extends "base.twig" %}
|
18 |
+
{% block content %}
|
19 |
+
<h1 class="big-title">{{foo}}</h1>
|
20 |
+
<h2>{{post.title}}</h2>
|
21 |
+
<img src="{{post.thumbnail.src}}" />
|
22 |
+
<div class="body">
|
23 |
+
{{post.content}}
|
24 |
+
</div>
|
25 |
+
{% endblock %}
|
26 |
+
```
|
27 |
Once Timber is installed and activated in your plugin directory, it gives any WordPress theme the ability to take advantage of the power of Twig and other Timber features.
|
28 |
|
29 |
### Looking for docs?
|
functions/functions-twig.php
CHANGED
@@ -45,6 +45,8 @@ class TimberTwig
|
|
45 |
return __($text, $domain);
|
46 |
}));
|
47 |
|
|
|
|
|
48 |
return $twig;
|
49 |
}
|
50 |
|
45 |
return __($text, $domain);
|
46 |
}));
|
47 |
|
48 |
+
$twig = apply_filters('get_twig', $twig);
|
49 |
+
|
50 |
return $twig;
|
51 |
}
|
52 |
|
objects/timber-post.php
CHANGED
@@ -14,9 +14,11 @@ class TimberPost extends TimberCore
|
|
14 |
* @param mixed $pid
|
15 |
* @return \TimberPost TimberPost object -- woo!
|
16 |
*/
|
17 |
-
function __construct($pid = null)
|
18 |
-
|
19 |
-
|
|
|
|
|
20 |
ob_start();
|
21 |
the_post();
|
22 |
$pid = get_the_ID();
|
14 |
* @param mixed $pid
|
15 |
* @return \TimberPost TimberPost object -- woo!
|
16 |
*/
|
17 |
+
function __construct($pid = null) {
|
18 |
+
if ($pid === null && get_the_ID()){
|
19 |
+
$pid = get_the_ID();
|
20 |
+
$this->ID = $pid;
|
21 |
+
} else if ($pid === null && have_posts()) {
|
22 |
ob_start();
|
23 |
the_post();
|
24 |
$pid = get_the_ID();
|
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.10.
|
6 |
Tested up to: 3.6
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
2 |
Contributors: jarednova
|
3 |
Tags: template engine, templates, twig
|
4 |
Requires at least: 3.5
|
5 |
+
Stable tag: 0.10.5
|
6 |
Tested up to: 3.6
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
timber.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Timber
|
4 |
Description: The WordPress Timber Library allows you to write themes using the power Twig templates
|
5 |
Author: Jared Novack + Upstatement
|
6 |
-
Version: 0.10.
|
7 |
Author URI: http://timber.upstatement.com/
|
8 |
*/
|
9 |
|
@@ -150,7 +150,15 @@ class Timber {
|
|
150 |
if (strstr($slug, '#')) {
|
151 |
//we have a post_type directive here
|
152 |
$q = explode('#', $slug);
|
153 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
}
|
155 |
$results = $wpdb->get_col($query);
|
156 |
return self::handle_post_results($results, $PostClass);
|
@@ -274,6 +282,7 @@ class Timber {
|
|
274 |
$data['theme_dir'] = str_replace($_SERVER['DOCUMENT_ROOT'], '', get_stylesheet_directory());
|
275 |
$data['language_attributes'] = WPHelper::ob_function('language_attributes');
|
276 |
$data['stylesheet_uri'] = get_stylesheet_uri();
|
|
|
277 |
$data = apply_filters('timber_context', $data);
|
278 |
return $data;
|
279 |
}
|
3 |
Plugin Name: Timber
|
4 |
Description: The WordPress Timber Library allows you to write themes using the power Twig templates
|
5 |
Author: Jared Novack + Upstatement
|
6 |
+
Version: 0.10.5
|
7 |
Author URI: http://timber.upstatement.com/
|
8 |
*/
|
9 |
|
150 |
if (strstr($slug, '#')) {
|
151 |
//we have a post_type directive here
|
152 |
$q = explode('#', $slug);
|
153 |
+
$q = array_filter($q);
|
154 |
+
$q = array_values($q);
|
155 |
+
if (count($q) == 1){
|
156 |
+
$query = "SELECT ID FROM $wpdb->posts WHERE post_name = '$q[0]'";
|
157 |
+
} else if (count($q) == 2){
|
158 |
+
$query = "SELECT ID FROM $wpdb->posts WHERE post_name = '$q[1]' AND post_type = '$q[0]'";
|
159 |
+
} else {
|
160 |
+
error_log('something we dont understand about '.$slug);
|
161 |
+
}
|
162 |
}
|
163 |
$results = $wpdb->get_col($query);
|
164 |
return self::handle_post_results($results, $PostClass);
|
282 |
$data['theme_dir'] = str_replace($_SERVER['DOCUMENT_ROOT'], '', get_stylesheet_directory());
|
283 |
$data['language_attributes'] = WPHelper::ob_function('language_attributes');
|
284 |
$data['stylesheet_uri'] = get_stylesheet_uri();
|
285 |
+
$data['template_uri'] = get_template_directory_uri();
|
286 |
$data = apply_filters('timber_context', $data);
|
287 |
return $data;
|
288 |
}
|