Timber - Version 1.1.6

Version Description

  • Kill those transients! Timber now wipes expired ones away 9a5851bf36110dcb399e277d51230f1addb0c53c
  • Fixed a warning that was annoying and nobody liked and didn't have any friends c53b4c832cfced01157f8196688468ad3318d3fb
Download this release

Release Info

Developer jarednova
Plugin Icon 128x128 Timber
Version 1.1.6
Comparing to
See all releases

Code changes from version 1.1.5 to 1.1.6

lib/Cache/Cleaner.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Timber\Cache;
4
+
5
+ class Cleaner {
6
+
7
+ protected static function delete_transients_single_site() {
8
+ global $wpdb;
9
+ $sql = "
10
+ DELETE
11
+ a, b
12
+ FROM
13
+ {$wpdb->options} a, {$wpdb->options} b
14
+ WHERE
15
+ a.option_name LIKE '%_transient_%' AND
16
+ a.option_name NOT LIKE '%_transient_timeout_%' AND
17
+ b.option_name = CONCAT(
18
+ '_transient_timeout_',
19
+ SUBSTRING(
20
+ a.option_name,
21
+ CHAR_LENGTH('_transient_') + 1
22
+ )
23
+ )
24
+ AND b.option_value < UNIX_TIMESTAMP()
25
+ ";
26
+ return $wpdb->query($sql);
27
+ }
28
+
29
+ protected static function delete_transients_multisite() {
30
+ global $wpdb;
31
+ $sql = "
32
+ DELETE
33
+ a, b
34
+ FROM
35
+ {$wpdb->sitemeta} a, {$wpdb->sitemeta} b
36
+ WHERE
37
+ a.meta_key LIKE '_site_transient_%' AND
38
+ a.meta_key NOT LIKE '_site_transient_timeout_%' AND
39
+ b.meta_key = CONCAT(
40
+ '_site_transient_timeout_',
41
+ SUBSTRING(
42
+ a.meta_key,
43
+ CHAR_LENGTH('_site_transient_') + 1
44
+ )
45
+ )
46
+ AND b.meta_value < UNIX_TIMESTAMP()
47
+ ";
48
+
49
+ $clean = $wpdb->query($sql);
50
+ return $clean;
51
+ }
52
+
53
+ public static function delete_transients( ) {
54
+ global $_wp_using_ext_object_cache;
55
+
56
+ if ( $_wp_using_ext_object_cache ) {
57
+ return 0;
58
+ }
59
+
60
+ global $wpdb;
61
+ $records = 0;
62
+
63
+ // Delete transients from options table
64
+ $records .= self::delete_transients_single_site();
65
+
66
+ // Delete transients from multisite, if configured as such
67
+
68
+ if ( is_multisite() && is_main_network() ) {
69
+
70
+ $records .= self::delete_transients_multisite();
71
+ }
72
+ return $records;
73
+
74
+ }
75
+
76
+
77
+ }
lib/Loader.php CHANGED
@@ -2,6 +2,8 @@
2
 
3
  namespace Timber;
4
 
 
 
5
  class Loader {
6
 
7
  const CACHEGROUP = 'timberloader';
@@ -73,12 +75,17 @@ class Loader {
73
  }
74
 
75
  if ( false !== $output && false !== $expires && null !== $key ) {
 
76
  $this->set_cache($key, $output, self::CACHEGROUP, $expires, $cache_mode);
77
  }
78
  $output = apply_filters('timber_output', $output);
79
  return apply_filters('timber/output', $output, $data, $file);
80
  }
81
 
 
 
 
 
82
  /**
83
  * @param array $filenames
84
  * @return bool
@@ -244,11 +251,11 @@ class Loader {
244
 
245
  $trans_key = substr($group.'_'.$key, 0, self::TRANS_KEY_LEN);
246
  if ( self::CACHE_TRANSIENT === $cache_mode ) {
247
- $value = get_transient($trans_key);
248
  } elseif ( self::CACHE_SITE_TRANSIENT === $cache_mode ) {
249
- $value = get_site_transient($trans_key);
250
  } elseif ( self::CACHE_OBJECT === $cache_mode && $object_cache ) {
251
- $value = wp_cache_get($key, $group);
252
  }
253
 
254
  return $value;
@@ -270,18 +277,18 @@ class Loader {
270
  }
271
 
272
  if ( (int) $expires < 1 ) {
273
- $expires = 0;
274
  }
275
 
276
  $cache_mode = self::_get_cache_mode($cache_mode);
277
  $trans_key = substr($group.'_'.$key, 0, self::TRANS_KEY_LEN);
278
 
279
  if ( self::CACHE_TRANSIENT === $cache_mode ) {
280
- set_transient($trans_key, $value, $expires);
281
  } elseif ( self::CACHE_SITE_TRANSIENT === $cache_mode ) {
282
- set_site_transient($trans_key, $value, $expires);
283
  } elseif ( self::CACHE_OBJECT === $cache_mode && $object_cache ) {
284
- wp_cache_set($key, $value, $group, $expires);
285
  }
286
 
287
  return $value;
2
 
3
  namespace Timber;
4
 
5
+ use Timber\Cache\Cleaner;
6
+
7
  class Loader {
8
 
9
  const CACHEGROUP = 'timberloader';
75
  }
76
 
77
  if ( false !== $output && false !== $expires && null !== $key ) {
78
+ $this->delete_cache();
79
  $this->set_cache($key, $output, self::CACHEGROUP, $expires, $cache_mode);
80
  }
81
  $output = apply_filters('timber_output', $output);
82
  return apply_filters('timber/output', $output, $data, $file);
83
  }
84
 
85
+ protected function delete_cache() {
86
+ Cleaner::delete_transients();
87
+ }
88
+
89
  /**
90
  * @param array $filenames
91
  * @return bool
251
 
252
  $trans_key = substr($group.'_'.$key, 0, self::TRANS_KEY_LEN);
253
  if ( self::CACHE_TRANSIENT === $cache_mode ) {
254
+ $value = get_transient($trans_key);
255
  } elseif ( self::CACHE_SITE_TRANSIENT === $cache_mode ) {
256
+ $value = get_site_transient($trans_key);
257
  } elseif ( self::CACHE_OBJECT === $cache_mode && $object_cache ) {
258
+ $value = wp_cache_get($key, $group);
259
  }
260
 
261
  return $value;
277
  }
278
 
279
  if ( (int) $expires < 1 ) {
280
+ $expires = 0;
281
  }
282
 
283
  $cache_mode = self::_get_cache_mode($cache_mode);
284
  $trans_key = substr($group.'_'.$key, 0, self::TRANS_KEY_LEN);
285
 
286
  if ( self::CACHE_TRANSIENT === $cache_mode ) {
287
+ set_transient($trans_key, $value, $expires);
288
  } elseif ( self::CACHE_SITE_TRANSIENT === $cache_mode ) {
289
+ set_site_transient($trans_key, $value, $expires);
290
  } elseif ( self::CACHE_OBJECT === $cache_mode && $object_cache ) {
291
+ wp_cache_set($key, $value, $group, $expires);
292
  }
293
 
294
  return $value;
lib/Timber.php CHANGED
@@ -35,7 +35,7 @@ use Timber\Loader;
35
  */
36
  class Timber {
37
 
38
- public static $version = '1.1.5';
39
  public static $locations;
40
  public static $dirname = 'views';
41
  public static $twig_cache = false;
@@ -56,7 +56,7 @@ class Timber {
56
  $this->test_compatibility();
57
  $this->backwards_compatibility();
58
  $this->init_constants();
59
- $this->init();
60
  }
61
  }
62
 
@@ -103,7 +103,7 @@ class Timber {
103
  /**
104
  * @codeCoverageIgnore
105
  */
106
- protected function init() {
107
  if ( class_exists('\WP') && !defined('TIMBER_LOADED') ) {
108
  Twig::init();
109
  ImageHelper::init();
35
  */
36
  class Timber {
37
 
38
+ public static $version = '1.1.6';
39
  public static $locations;
40
  public static $dirname = 'views';
41
  public static $twig_cache = false;
56
  $this->test_compatibility();
57
  $this->backwards_compatibility();
58
  $this->init_constants();
59
+ self::init();
60
  }
61
  }
62
 
103
  /**
104
  * @codeCoverageIgnore
105
  */
106
+ protected static function init() {
107
  if ( class_exists('\WP') && !defined('TIMBER_LOADED') ) {
108
  Twig::init();
109
  ImageHelper::init();
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.1.5
6
  Tested up to: 4.6
7
  PHP version: 5.3.0 or greater
8
  License: GPLv2 or later
@@ -41,6 +41,10 @@ Timber is great for any WordPress developer who cares about writing good, mainta
41
 
42
  == Changelog ==
43
 
 
 
 
 
44
  = 1.1.5 =
45
  * Removed change for custom loaders due to incompatability with Gantry
46
 
2
  Contributors: jarednova, connorjburton, lggorman
3
  Tags: template engine, templates, twig
4
  Requires at least: 3.7
5
+ Stable tag: 1.1.6
6
  Tested up to: 4.6
7
  PHP version: 5.3.0 or greater
8
  License: GPLv2 or later
41
 
42
  == Changelog ==
43
 
44
+ = 1.1.6 =
45
+ * Kill those transients! Timber now wipes expired ones away 9a5851bf36110dcb399e277d51230f1addb0c53c
46
+ * Fixed a warning that was annoying and nobody liked and didn't have any friends c53b4c832cfced01157f8196688468ad3318d3fb
47
+
48
  = 1.1.5 =
49
  * Removed change for custom loaders due to incompatability with Gantry
50
 
timber-starter-theme/screenshot.png CHANGED
Binary file
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: 1.1.5
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 Twig templates.
5
  Plugin URI: http://timber.upstatement.com
6
  Author: Jared Novack + Upstatement
7
+ Version: 1.1.6
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 ComposerAutoloaderInit9f0793d7d7bccbafe546583c0f31b05a::getLoader();
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit7bf9eed06307908b1a865769be6727dd::getLoader();
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit9f0793d7d7bccbafe546583c0f31b05a
6
  {
7
  private static $loader;
8
 
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit9f0793d7d7bccbafe546583c0f31b05a
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit9f0793d7d7bccbafe546583c0f31b05a', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit9f0793d7d7bccbafe546583c0f31b05a', 'loadClassLoader'));
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 ComposerAutoloaderInit7bf9eed06307908b1a865769be6727dd
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit7bf9eed06307908b1a865769be6727dd', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit7bf9eed06307908b1a865769be6727dd', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {