Version Description
- Fix for Twig 2.0 compatibility issue #1464 (thanks @luism-s)
Download this release
Release Info
Developer | jarednova |
Plugin | Timber |
Version | 1.3.4 |
Comparing to | |
See all releases |
Code changes from version 1.3.3 to 1.3.4
- lib/FunctionWrapper.php +1 -1
- lib/Twig.php +24 -23
- lib/Twig_Function.php +17 -0
- readme.txt +6 -3
- timber.php +1 -1
- vendor/autoload.php +1 -1
- vendor/composer/autoload_classmap.php +1 -0
- vendor/composer/autoload_real.php +3 -3
lib/FunctionWrapper.php
CHANGED
@@ -72,7 +72,7 @@ class FunctionWrapper {
|
|
72 |
$wrapper = $this;
|
73 |
|
74 |
try {
|
75 |
-
$twig->addFunction( new
|
76 |
return call_user_func_array( array( $wrapper, 'call' ), func_get_args() );
|
77 |
} ) );
|
78 |
|
72 |
$wrapper = $this;
|
73 |
|
74 |
try {
|
75 |
+
$twig->addFunction( new Twig_Function( $this->_function, function() use ( $wrapper ) {
|
76 |
return call_user_func_array( array( $wrapper, 'call' ), func_get_args() );
|
77 |
} ) );
|
78 |
|
lib/Twig.php
CHANGED
@@ -10,6 +10,7 @@ use Timber\Term;
|
|
10 |
use Timber\Image;
|
11 |
use Timber\User;
|
12 |
|
|
|
13 |
class Twig {
|
14 |
|
15 |
public static $dir_name;
|
@@ -35,20 +36,20 @@ class Twig {
|
|
35 |
*/
|
36 |
public function add_timber_functions( $twig ) {
|
37 |
/* actions and filters */
|
38 |
-
$twig->addFunction(new
|
39 |
$args = func_get_args();
|
40 |
array_shift($args);
|
41 |
$args[] = $context;
|
42 |
call_user_func_array('do_action', $args);
|
43 |
}, array('needs_context' => true)));
|
44 |
|
45 |
-
$twig->addFunction(new
|
46 |
-
$twig->addFunction(new
|
47 |
|
48 |
-
$twig->addFunction(new
|
49 |
|
50 |
/* TimberObjects */
|
51 |
-
$twig->addFunction(new
|
52 |
if ( is_array($pid) && !Helper::is_array_assoc($pid) ) {
|
53 |
foreach ( $pid as &$p ) {
|
54 |
$p = new $PostClass($p);
|
@@ -57,7 +58,7 @@ class Twig {
|
|
57 |
}
|
58 |
return new $PostClass($pid);
|
59 |
} ));
|
60 |
-
$twig->addFunction(new
|
61 |
if ( is_array($pid) && !Helper::is_array_assoc($pid) ) {
|
62 |
foreach ( $pid as &$p ) {
|
63 |
$p = new $ImageClass($p);
|
@@ -67,7 +68,7 @@ class Twig {
|
|
67 |
return new $ImageClass($pid);
|
68 |
} ));
|
69 |
|
70 |
-
$twig->addFunction(new
|
71 |
if ( is_array($pid) && !Helper::is_array_assoc($pid) ) {
|
72 |
foreach ( $pid as &$p ) {
|
73 |
$p = new $TermClass($p);
|
@@ -76,7 +77,7 @@ class Twig {
|
|
76 |
}
|
77 |
return new $TermClass($pid);
|
78 |
} ));
|
79 |
-
$twig->addFunction(new
|
80 |
if ( is_array($pid) && !Helper::is_array_assoc($pid) ) {
|
81 |
foreach ( $pid as &$p ) {
|
82 |
$p = new $UserClass($p);
|
@@ -87,7 +88,7 @@ class Twig {
|
|
87 |
} ));
|
88 |
|
89 |
/* TimberObjects Alias */
|
90 |
-
$twig->addFunction(new
|
91 |
if ( is_array($pid) && !Helper::is_array_assoc($pid) ) {
|
92 |
foreach ( $pid as &$p ) {
|
93 |
$p = new $PostClass($p);
|
@@ -96,7 +97,7 @@ class Twig {
|
|
96 |
}
|
97 |
return new $PostClass($pid);
|
98 |
} ));
|
99 |
-
$twig->addFunction(new
|
100 |
if ( is_array($pid) && !Helper::is_array_assoc($pid) ) {
|
101 |
foreach ( $pid as &$p ) {
|
102 |
$p = new $ImageClass($p);
|
@@ -105,7 +106,7 @@ class Twig {
|
|
105 |
}
|
106 |
return new $ImageClass($pid);
|
107 |
} ));
|
108 |
-
$twig->addFunction(new
|
109 |
if ( is_array($pid) && !Helper::is_array_assoc($pid) ) {
|
110 |
foreach ( $pid as &$p ) {
|
111 |
$p = new $TermClass($p);
|
@@ -114,7 +115,7 @@ class Twig {
|
|
114 |
}
|
115 |
return new $TermClass($pid);
|
116 |
} ));
|
117 |
-
$twig->addFunction(new
|
118 |
if ( is_array($pid) && !Helper::is_array_assoc($pid) ) {
|
119 |
foreach ( $pid as &$p ) {
|
120 |
$p = new $UserClass($p);
|
@@ -125,37 +126,37 @@ class Twig {
|
|
125 |
} ));
|
126 |
|
127 |
/* bloginfo and translate */
|
128 |
-
$twig->addFunction(new
|
129 |
return get_bloginfo($show, $filter);
|
130 |
} ));
|
131 |
-
$twig->addFunction(new
|
132 |
return __($text, $domain);
|
133 |
} ));
|
134 |
-
$twig->addFunction(new
|
135 |
return translate($text, $domain);
|
136 |
} ));
|
137 |
-
$twig->addFunction(new
|
138 |
return _e($text, $domain);
|
139 |
} ));
|
140 |
-
$twig->addFunction(new
|
141 |
return _n($single, $plural, $number, $domain);
|
142 |
} ));
|
143 |
-
$twig->addFunction(new
|
144 |
return _x($text, $context, $domain);
|
145 |
} ));
|
146 |
-
$twig->addFunction(new
|
147 |
return _ex($text, $context, $domain);
|
148 |
} ));
|
149 |
-
$twig->addFunction(new
|
150 |
return _nx($single, $plural, $number, $context, $domain);
|
151 |
} ));
|
152 |
-
$twig->addFunction(new
|
153 |
return _n_noop($singular, $plural, $domain);
|
154 |
} ));
|
155 |
-
$twig->addFunction(new
|
156 |
return _nx_noop($singular, $plural, $context, $domain);
|
157 |
} ));
|
158 |
-
$twig->addFunction(new
|
159 |
return translate_nooped_plural($nooped_plural, $count, $domain);
|
160 |
} ));
|
161 |
|
10 |
use Timber\Image;
|
11 |
use Timber\User;
|
12 |
|
13 |
+
|
14 |
class Twig {
|
15 |
|
16 |
public static $dir_name;
|
36 |
*/
|
37 |
public function add_timber_functions( $twig ) {
|
38 |
/* actions and filters */
|
39 |
+
$twig->addFunction(new Twig_Function('action', function( $context ) {
|
40 |
$args = func_get_args();
|
41 |
array_shift($args);
|
42 |
$args[] = $context;
|
43 |
call_user_func_array('do_action', $args);
|
44 |
}, array('needs_context' => true)));
|
45 |
|
46 |
+
$twig->addFunction(new Twig_Function('function', array(&$this, 'exec_function')));
|
47 |
+
$twig->addFunction(new Twig_Function('fn', array(&$this, 'exec_function')));
|
48 |
|
49 |
+
$twig->addFunction(new Twig_Function('shortcode', 'do_shortcode'));
|
50 |
|
51 |
/* TimberObjects */
|
52 |
+
$twig->addFunction(new Twig_Function('TimberPost', function( $pid, $PostClass = 'Timber\Post' ) {
|
53 |
if ( is_array($pid) && !Helper::is_array_assoc($pid) ) {
|
54 |
foreach ( $pid as &$p ) {
|
55 |
$p = new $PostClass($p);
|
58 |
}
|
59 |
return new $PostClass($pid);
|
60 |
} ));
|
61 |
+
$twig->addFunction(new Twig_Function('TimberImage', function( $pid = false, $ImageClass = 'Timber\Image' ) {
|
62 |
if ( is_array($pid) && !Helper::is_array_assoc($pid) ) {
|
63 |
foreach ( $pid as &$p ) {
|
64 |
$p = new $ImageClass($p);
|
68 |
return new $ImageClass($pid);
|
69 |
} ));
|
70 |
|
71 |
+
$twig->addFunction(new Twig_Function('TimberTerm', function( $pid, $TermClass = 'Timber\Term' ) {
|
72 |
if ( is_array($pid) && !Helper::is_array_assoc($pid) ) {
|
73 |
foreach ( $pid as &$p ) {
|
74 |
$p = new $TermClass($p);
|
77 |
}
|
78 |
return new $TermClass($pid);
|
79 |
} ));
|
80 |
+
$twig->addFunction(new Twig_Function('TimberUser', function( $pid, $UserClass = 'Timber\User' ) {
|
81 |
if ( is_array($pid) && !Helper::is_array_assoc($pid) ) {
|
82 |
foreach ( $pid as &$p ) {
|
83 |
$p = new $UserClass($p);
|
88 |
} ));
|
89 |
|
90 |
/* TimberObjects Alias */
|
91 |
+
$twig->addFunction(new Twig_Function('Post', function( $pid, $PostClass = 'Timber\Post' ) {
|
92 |
if ( is_array($pid) && !Helper::is_array_assoc($pid) ) {
|
93 |
foreach ( $pid as &$p ) {
|
94 |
$p = new $PostClass($p);
|
97 |
}
|
98 |
return new $PostClass($pid);
|
99 |
} ));
|
100 |
+
$twig->addFunction(new Twig_Function('Image', function( $pid, $ImageClass = 'Timber\Image' ) {
|
101 |
if ( is_array($pid) && !Helper::is_array_assoc($pid) ) {
|
102 |
foreach ( $pid as &$p ) {
|
103 |
$p = new $ImageClass($p);
|
106 |
}
|
107 |
return new $ImageClass($pid);
|
108 |
} ));
|
109 |
+
$twig->addFunction(new Twig_Function('Term', function( $pid, $TermClass = 'Timber\Term' ) {
|
110 |
if ( is_array($pid) && !Helper::is_array_assoc($pid) ) {
|
111 |
foreach ( $pid as &$p ) {
|
112 |
$p = new $TermClass($p);
|
115 |
}
|
116 |
return new $TermClass($pid);
|
117 |
} ));
|
118 |
+
$twig->addFunction(new Twig_Function('User', function( $pid, $UserClass = 'Timber\User' ) {
|
119 |
if ( is_array($pid) && !Helper::is_array_assoc($pid) ) {
|
120 |
foreach ( $pid as &$p ) {
|
121 |
$p = new $UserClass($p);
|
126 |
} ));
|
127 |
|
128 |
/* bloginfo and translate */
|
129 |
+
$twig->addFunction(new Twig_Function('bloginfo', function( $show = '', $filter = 'raw' ) {
|
130 |
return get_bloginfo($show, $filter);
|
131 |
} ));
|
132 |
+
$twig->addFunction(new Twig_Function('__', function( $text, $domain = 'default' ) {
|
133 |
return __($text, $domain);
|
134 |
} ));
|
135 |
+
$twig->addFunction(new Twig_Function('translate', function( $text, $domain = 'default' ) {
|
136 |
return translate($text, $domain);
|
137 |
} ));
|
138 |
+
$twig->addFunction(new Twig_Function('_e', function( $text, $domain = 'default' ) {
|
139 |
return _e($text, $domain);
|
140 |
} ));
|
141 |
+
$twig->addFunction(new Twig_Function('_n', function( $single, $plural, $number, $domain = 'default' ) {
|
142 |
return _n($single, $plural, $number, $domain);
|
143 |
} ));
|
144 |
+
$twig->addFunction(new Twig_Function('_x', function( $text, $context, $domain = 'default' ) {
|
145 |
return _x($text, $context, $domain);
|
146 |
} ));
|
147 |
+
$twig->addFunction(new Twig_Function('_ex', function( $text, $context, $domain = 'default' ) {
|
148 |
return _ex($text, $context, $domain);
|
149 |
} ));
|
150 |
+
$twig->addFunction(new Twig_Function('_nx', function( $single, $plural, $number, $context, $domain = 'default' ) {
|
151 |
return _nx($single, $plural, $number, $context, $domain);
|
152 |
} ));
|
153 |
+
$twig->addFunction(new Twig_Function('_n_noop', function( $singular, $plural, $domain = 'default' ) {
|
154 |
return _n_noop($singular, $plural, $domain);
|
155 |
} ));
|
156 |
+
$twig->addFunction(new Twig_Function('_nx_noop', function( $singular, $plural, $context, $domain = 'default' ) {
|
157 |
return _nx_noop($singular, $plural, $context, $domain);
|
158 |
} ));
|
159 |
+
$twig->addFunction(new Twig_Function('translate_nooped_plural', function( $nooped_plural, $count, $domain = 'default' ) {
|
160 |
return translate_nooped_plural($nooped_plural, $count, $domain);
|
161 |
} ));
|
162 |
|
lib/Twig_Function.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Timber;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Temporary fix for conflicts between Twig_Function and Twig_SimpleFunction
|
7 |
+
* in different versions of Twig (1.* and 2.*)
|
8 |
+
*/
|
9 |
+
if ( version_compare(\Twig_Environment::VERSION, '2.0.0', '>=') ) {
|
10 |
+
|
11 |
+
class Twig_Function extends \Twig_Function { }
|
12 |
+
|
13 |
+
} else {
|
14 |
+
|
15 |
+
class Twig_Function extends \Twig_SimpleFunction { }
|
16 |
+
|
17 |
+
}
|
readme.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
Contributors: jarednova, connorjburton, lggorman
|
3 |
Tags: template engine, templates, twig
|
4 |
Requires at least: 3.7
|
5 |
-
Stable tag: 1.3.
|
6 |
Tested up to: 4.8
|
7 |
PHP version: 5.3.0 or greater
|
8 |
License: GPLv2 or later
|
@@ -41,6 +41,9 @@ Timber is great for any WordPress developer who cares about writing good, mainta
|
|
41 |
|
42 |
== Changelog ==
|
43 |
|
|
|
|
|
|
|
44 |
= 1.3.3 =
|
45 |
* Fix for HTTPs issues with images
|
46 |
|
@@ -63,11 +66,11 @@ Timber is great for any WordPress developer who cares about writing good, mainta
|
|
63 |
* Timber\Comments {{ comment.content }} now returns processed comment with `<p>` tags
|
64 |
* Fix for HTTP error when uploading media files in Windows #1346 (thanks Matias Griese)
|
65 |
* Fix for image resizing on alternative WP setups (thanks @gillesgoetsch)
|
66 |
-
* Exposing a function to global Twig scope through Timber\FunctionWrapper is deprecated, the
|
67 |
* Fixed issues with use of Twig 2.0 (#1370)
|
68 |
* Fixed up some things with Timber/Archives and getting post_count #1376
|
69 |
* Don't let Timber fail when converting TIFFs or other weird file types, instead return the passed value w/o modifying #1383
|
70 |
-
* Updated `FunctionWrapper` with appropriate warnings and Twig 2.0
|
71 |
Misc fixes to documentation
|
72 |
|
73 |
= 1.2.4 =
|
2 |
Contributors: jarednova, connorjburton, lggorman
|
3 |
Tags: template engine, templates, twig
|
4 |
Requires at least: 3.7
|
5 |
+
Stable tag: 1.3.4
|
6 |
Tested up to: 4.8
|
7 |
PHP version: 5.3.0 or greater
|
8 |
License: GPLv2 or later
|
41 |
|
42 |
== Changelog ==
|
43 |
|
44 |
+
= 1.3.4 =
|
45 |
+
* Fix for Twig 2.0 compatibility issue #1464 (thanks @luism-s)
|
46 |
+
|
47 |
= 1.3.3 =
|
48 |
* Fix for HTTPs issues with images
|
49 |
|
66 |
* Timber\Comments {{ comment.content }} now returns processed comment with `<p>` tags
|
67 |
* Fix for HTTP error when uploading media files in Windows #1346 (thanks Matias Griese)
|
68 |
* Fix for image resizing on alternative WP setups (thanks @gillesgoetsch)
|
69 |
+
* Exposing a function to global Twig scope through Timber\FunctionWrapper is deprecated, the preferred method to do this is through a Twig template like `{{ function('my_cool_function', 'my_argument') }}` (thanks @gchtr)
|
70 |
* Fixed issues with use of Twig 2.0 (#1370)
|
71 |
* Fixed up some things with Timber/Archives and getting post_count #1376
|
72 |
* Don't let Timber fail when converting TIFFs or other weird file types, instead return the passed value w/o modifying #1383
|
73 |
+
* Updated `FunctionWrapper` with appropriate warnings and Twig 2.0 compatibility (thank you thank you @gchtr)
|
74 |
Misc fixes to documentation
|
75 |
|
76 |
= 1.2.4 =
|
timber.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Timber
|
|
4 |
Description: The WordPress Timber Library allows you to write themes using the power of Twig templates.
|
5 |
Plugin URI: http://timber.upstatement.com
|
6 |
Author: Jared Novack + Upstatement
|
7 |
-
Version: 1.3.
|
8 |
Author URI: http://upstatement.com/
|
9 |
*/
|
10 |
// we look for Composer files first in the plugins dir.
|
4 |
Description: The WordPress Timber Library allows you to write themes using the power of Twig templates.
|
5 |
Plugin URI: http://timber.upstatement.com
|
6 |
Author: Jared Novack + Upstatement
|
7 |
+
Version: 1.3.4
|
8 |
Author URI: http://upstatement.com/
|
9 |
*/
|
10 |
// we look for Composer files first in the plugins dir.
|
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 ComposerAutoloaderInitfc5424fd7137f4e31703647a20f27b2f::getLoader();
|
vendor/composer/autoload_classmap.php
CHANGED
@@ -153,6 +153,7 @@ return array(
|
|
153 |
'Timber\\Theme' => $baseDir . '/lib/Theme.php',
|
154 |
'Timber\\Timber' => $baseDir . '/lib/Timber.php',
|
155 |
'Timber\\Twig' => $baseDir . '/lib/Twig.php',
|
|
|
156 |
'Timber\\URLHelper' => $baseDir . '/lib/URLHelper.php',
|
157 |
'Timber\\User' => $baseDir . '/lib/User.php',
|
158 |
'Twig\\Cache\\CacheInterface' => $vendorDir . '/twig/twig/src/Cache/CacheInterface.php',
|
153 |
'Timber\\Theme' => $baseDir . '/lib/Theme.php',
|
154 |
'Timber\\Timber' => $baseDir . '/lib/Timber.php',
|
155 |
'Timber\\Twig' => $baseDir . '/lib/Twig.php',
|
156 |
+
'Timber\\Twig_Function' => $baseDir . '/lib/Twig_Function.php',
|
157 |
'Timber\\URLHelper' => $baseDir . '/lib/URLHelper.php',
|
158 |
'Timber\\User' => $baseDir . '/lib/User.php',
|
159 |
'Twig\\Cache\\CacheInterface' => $vendorDir . '/twig/twig/src/Cache/CacheInterface.php',
|
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 ComposerAutoloaderInitc9a1d8f9e5e62801f21a9c9e63207e19
|
|
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) {
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInitfc5424fd7137f4e31703647a20f27b2f
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInitfc5424fd7137f4e31703647a20f27b2f', 'loadClassLoader'), true, true);
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInitfc5424fd7137f4e31703647a20f27b2f', 'loadClassLoader'));
|
25 |
|
26 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
27 |
foreach ($map as $namespace => $path) {
|