Timber - Version 0.21.8

Version Description

  • Fixes to things in docs
  • Added ID to timber/image/src filter (thanks @aaronhippie)
  • Fixed edgecase with HTTP_HOST vs SERVER_NAME (thanks @maketimetodesign)
Download this release

Release Info

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

Code changes from version 0.21.7 to 0.21.8

lib/cache/KeyGenerator.php CHANGED
@@ -6,25 +6,25 @@ use Asm89\Twig\CacheExtension\CacheStrategy\KeyGeneratorInterface;
6
 
7
  class KeyGenerator implements KeyGeneratorInterface {
8
 
9
- /**
10
- * @param mixed $value
11
- * @return string
12
- */
13
- public function generateKey($value) {
14
- if (is_a($value, 'TimberKeyGeneratorInterface')) {
15
- return $value->_get_cache_key();
16
- }
17
-
18
- if (is_array($value) && isset($value['_cache_key'])) {
19
- return $value['_cache_key'];
20
- }
21
-
22
- $key = md5(json_encode($value));
23
- if (is_object($value)) {
24
- $key = get_class($value) . '|' . $key;
25
- }
26
-
27
- return $key;
28
- }
29
 
30
  }
6
 
7
  class KeyGenerator implements KeyGeneratorInterface {
8
 
9
+ /**
10
+ * @param mixed $value
11
+ * @return string
12
+ */
13
+ public function generateKey($value) {
14
+ if (is_a($value, 'TimberKeyGeneratorInterface')) {
15
+ return $value->_get_cache_key();
16
+ }
17
+
18
+ if (is_array($value) && isset($value['_cache_key'])) {
19
+ return $value['_cache_key'];
20
+ }
21
+
22
+ $key = md5(json_encode($value));
23
+ if (is_object($value)) {
24
+ $key = get_class($value) . '|' . $key;
25
+ }
26
+
27
+ return $key;
28
+ }
29
 
30
  }
lib/cache/TimberKeyGeneratorInterface.php CHANGED
@@ -4,5 +4,5 @@ namespace Timber\Cache;
4
 
5
  interface TimberKeyGeneratorInterface
6
  {
7
- public function _get_cache_key();
8
  }
4
 
5
  interface TimberKeyGeneratorInterface
6
  {
7
+ public function _get_cache_key();
8
  }
lib/cache/WPObjectCacheAdapter.php CHANGED
@@ -3,27 +3,26 @@
3
  use Asm89\Twig\CacheExtension\CacheProviderInterface;
4
  use TimberLoader;
5
 
6
- class WPObjectCacheAdapter implements CacheProviderInterface
7
- {
8
 
9
- private $cache_group;
10
 
11
- /**
12
- * @var TimberLoader
13
- */
14
- private $timberloader;
15
 
16
- public function __construct(TimberLoader $timberloader, $cache_group = 'timber') {
17
- $this->cache_group = $cache_group;
18
- $this->timberloader = $timberloader;
19
- }
20
 
21
- public function fetch($key) {
22
- return $this->timberloader->get_cache($key, $this->cache_group, TimberLoader::CACHE_USE_DEFAULT);
23
- }
24
 
25
- public function save($key, $value, $expire = 0) {
26
- return $this->timberloader->set_cache($key, $value, $this->cache_group, $expire, TimberLoader::CACHE_USE_DEFAULT);
27
- }
28
 
29
  }
3
  use Asm89\Twig\CacheExtension\CacheProviderInterface;
4
  use TimberLoader;
5
 
6
+ class WPObjectCacheAdapter implements CacheProviderInterface {
 
7
 
8
+ private $cache_group;
9
 
10
+ /**
11
+ * @var TimberLoader
12
+ */
13
+ private $timberloader;
14
 
15
+ public function __construct(TimberLoader $timberloader, $cache_group = 'timber') {
16
+ $this->cache_group = $cache_group;
17
+ $this->timberloader = $timberloader;
18
+ }
19
 
20
+ public function fetch($key) {
21
+ return $this->timberloader->get_cache($key, $this->cache_group, TimberLoader::CACHE_USE_DEFAULT);
22
+ }
23
 
24
+ public function save($key, $value, $expire = 0) {
25
+ return $this->timberloader->set_cache($key, $value, $this->cache_group, $expire, TimberLoader::CACHE_USE_DEFAULT);
26
+ }
27
 
28
  }
lib/image/timber-image-operation-letterbox.php CHANGED
@@ -10,88 +10,88 @@
10
  */
11
  class TimberImageOperationLetterbox extends TimberImageOperation {
12
 
13
- private $w, $h, $color;
14
 
15
- /**
16
- * @param int $w width of result image
17
- * @param int $h height
18
- * @param string $color hex string, for color of padding bands
19
- */
20
- function __construct($w, $h, $color) {
21
- $this->w = $w;
22
- $this->h = $h;
23
- $this->color = $color;
24
- }
25
 
26
- /**
27
- * @param string $src_filename the basename of the file (ex: my-awesome-pic)
28
- * @param string $src_extension the extension (ex: .jpg)
29
- * @return string the final filename to be used
30
- * (ex: my-awesome-pic-lbox-300x200-FF3366.jpg)
31
- */
32
- public function filename($src_filename, $src_extension) {
33
- $color = str_replace( '#', '', $this->color );
34
- $newbase = $src_filename . '-lbox-' . $this->w . 'x' . $this->h . '-' . $color;
35
- $new_name = $newbase . '.' . $src_extension;
36
- return $new_name;
37
- }
38
 
39
- /**
40
- * Performs the actual image manipulation,
41
- * including saving the target file.
42
- *
43
- * @param string $load_filename filepath (not URL) to source file
44
- * (ex: /src/var/www/wp-content/uploads/my-pic.jpg)
45
- * @param string $save_filename filepath (not URL) where result file should be saved
46
- * (ex: /src/var/www/wp-content/uploads/my-pic-lbox-300x200-FF3366.jpg)
47
- * @return bool true if everything went fine, false otherwise
48
- */
49
- public function run($load_filename, $save_filename) {
50
- $w = $this->w;
51
- $h = $this->h;
52
 
53
- $bg = imagecreatetruecolor( $w, $h );
54
- $c = self::hexrgb( $this->color );
55
- $bgColor = imagecolorallocate( $bg, $c['red'], $c['green'], $c['blue'] );
56
- imagefill( $bg, 0, 0, $bgColor );
57
- $image = wp_get_image_editor( $load_filename );
58
- if ( !is_wp_error( $image ) ) {
59
- $current_size = $image->get_size();
60
- $ow = $current_size['width'];
61
- $oh = $current_size['height'];
62
- $new_aspect = $w / $h;
63
- $old_aspect = $ow / $oh;
64
- if ( $new_aspect > $old_aspect ) {
65
- //taller than goal
66
- $h_scale = $h / $oh;
67
- $owt = $ow * $h_scale;
68
- $y = 0;
69
- $x = $w / 2 - $owt / 2;
70
- $oht = $h;
71
- $image->crop( 0, 0, $ow, $oh, $owt, $oht );
72
- } else {
73
- $w_scale = $w / $ow;
74
- $oht = $oh * $w_scale;
75
- $x = 0;
76
- $y = $h / 2 - $oht / 2;
77
- $owt = $w;
78
- $image->crop( 0, 0, $ow, $oh, $owt, $oht );
79
- }
80
- $image->save( $save_filename );
81
- $func = 'imagecreatefromjpeg';
82
- $ext = pathinfo( $save_filename, PATHINFO_EXTENSION );
83
- if ( $ext == 'gif' ) {
84
- $func = 'imagecreatefromgif';
85
- } else if ( $ext == 'png' ) {
86
- $func = 'imagecreatefrompng';
87
- }
88
- $image = $func( $save_filename );
89
- imagecopy( $bg, $image, $x, $y, 0, 0, $owt, $oht );
90
- imagejpeg( $bg, $save_filename );
91
- return true;
92
- } else {
93
- TimberHelper::error_log( $image );
94
- }
95
- return false;
96
- }
97
  }
10
  */
11
  class TimberImageOperationLetterbox extends TimberImageOperation {
12
 
13
+ private $w, $h, $color;
14
 
15
+ /**
16
+ * @param int $w width of result image
17
+ * @param int $h height
18
+ * @param string $color hex string, for color of padding bands
19
+ */
20
+ function __construct($w, $h, $color) {
21
+ $this->w = $w;
22
+ $this->h = $h;
23
+ $this->color = $color;
24
+ }
25
 
26
+ /**
27
+ * @param string $src_filename the basename of the file (ex: my-awesome-pic)
28
+ * @param string $src_extension the extension (ex: .jpg)
29
+ * @return string the final filename to be used
30
+ * (ex: my-awesome-pic-lbox-300x200-FF3366.jpg)
31
+ */
32
+ public function filename($src_filename, $src_extension) {
33
+ $color = str_replace( '#', '', $this->color );
34
+ $newbase = $src_filename . '-lbox-' . $this->w . 'x' . $this->h . '-' . $color;
35
+ $new_name = $newbase . '.' . $src_extension;
36
+ return $new_name;
37
+ }
38
 
39
+ /**
40
+ * Performs the actual image manipulation,
41
+ * including saving the target file.
42
+ *
43
+ * @param string $load_filename filepath (not URL) to source file
44
+ * (ex: /src/var/www/wp-content/uploads/my-pic.jpg)
45
+ * @param string $save_filename filepath (not URL) where result file should be saved
46
+ * (ex: /src/var/www/wp-content/uploads/my-pic-lbox-300x200-FF3366.jpg)
47
+ * @return bool true if everything went fine, false otherwise
48
+ */
49
+ public function run($load_filename, $save_filename) {
50
+ $w = $this->w;
51
+ $h = $this->h;
52
 
53
+ $bg = imagecreatetruecolor( $w, $h );
54
+ $c = self::hexrgb( $this->color );
55
+ $bgColor = imagecolorallocate( $bg, $c['red'], $c['green'], $c['blue'] );
56
+ imagefill( $bg, 0, 0, $bgColor );
57
+ $image = wp_get_image_editor( $load_filename );
58
+ if ( !is_wp_error( $image ) ) {
59
+ $current_size = $image->get_size();
60
+ $ow = $current_size['width'];
61
+ $oh = $current_size['height'];
62
+ $new_aspect = $w / $h;
63
+ $old_aspect = $ow / $oh;
64
+ if ( $new_aspect > $old_aspect ) {
65
+ //taller than goal
66
+ $h_scale = $h / $oh;
67
+ $owt = $ow * $h_scale;
68
+ $y = 0;
69
+ $x = $w / 2 - $owt / 2;
70
+ $oht = $h;
71
+ $image->crop( 0, 0, $ow, $oh, $owt, $oht );
72
+ } else {
73
+ $w_scale = $w / $ow;
74
+ $oht = $oh * $w_scale;
75
+ $x = 0;
76
+ $y = $h / 2 - $oht / 2;
77
+ $owt = $w;
78
+ $image->crop( 0, 0, $ow, $oh, $owt, $oht );
79
+ }
80
+ $image->save( $save_filename );
81
+ $func = 'imagecreatefromjpeg';
82
+ $ext = pathinfo( $save_filename, PATHINFO_EXTENSION );
83
+ if ( $ext == 'gif' ) {
84
+ $func = 'imagecreatefromgif';
85
+ } else if ( $ext == 'png' ) {
86
+ $func = 'imagecreatefrompng';
87
+ }
88
+ $image = $func( $save_filename );
89
+ imagecopy( $bg, $image, $x, $y, 0, 0, $owt, $oht );
90
+ imagejpeg( $bg, $save_filename );
91
+ return true;
92
+ } else {
93
+ TimberHelper::error_log( $image );
94
+ }
95
+ return false;
96
+ }
97
  }
lib/image/timber-image-operation-resize.php CHANGED
@@ -1,118 +1,118 @@
1
  <?php
2
  /**
3
- * Changes image to new size, by shrinking/enlarging
4
- * then cropping to respect new ratio.
5
- *
6
- * Arguments:
7
- * - width of new image
8
- * - height of new image
9
- * - crop method
10
- */
11
  class TimberImageOperationResize extends TimberImageOperation {
12
 
13
  private $w, $h, $crop;
14
 
15
- /**
16
- * @param int $w width of new image
17
- * @param int $h height of new image
18
- * @param string $crop cropping method, one of: 'default', 'center', 'top', 'bottom', 'left', 'right'.
19
- */
20
- function __construct($w, $h, $crop) {
21
- $this->w = $w;
22
- $this->h = $h;
23
- // Sanitize crop position
24
- $allowed_crop_positions = array( 'default', 'center', 'top', 'bottom', 'left', 'right' );
25
- if ( $crop !== false && !in_array( $crop, $allowed_crop_positions ) ) {
26
- $crop = $allowed_crop_positions[0];
27
- }
28
- $this->crop = $crop;
29
- }
30
 
31
- /**
32
- * @param string $src_filename the basename of the file (ex: my-awesome-pic)
33
- * @param string $src_extension the extension (ex: .jpg)
34
- * @return string the final filename to be used (ex: my-awesome-pic-300x200-c-default.jpg)
35
- */
36
- public function filename($src_filename, $src_extension) {
37
- $result = $src_filename . '-' . $this->w . 'x' . $this->h . '-c-' . ( $this->crop ? $this->crop : 'f' ); // Crop will be either user named or f (false)
38
- if($src_extension) {
39
- $result .= '.'.$src_extension;
40
- }
41
- return $result;
42
- }
43
 
44
- /**
45
- * Performs the actual image manipulation,
46
- * including saving the target file.
47
- *
48
- * @param string $load_filename filepath (not URL) to source file
49
- * (ex: /src/var/www/wp-content/uploads/my-pic.jpg)
50
- * @param string $save_filename filepath (not URL) where result file should be saved
51
- * (ex: /src/var/www/wp-content/uploads/my-pic-300x200-c-default.jpg)
52
- * @return bool true if everything went fine, false otherwise
53
- */
54
- public function run($load_filename, $save_filename) {
55
- $image = wp_get_image_editor( $load_filename );
56
- if ( !is_wp_error( $image ) ) {
57
- $w = $this->w;
58
- $h = $this->h;
59
- $crop = $this->crop;
60
 
61
- $current_size = $image->get_size();
62
- $src_w = $current_size['width'];
63
- $src_h = $current_size['height'];
64
- $src_ratio = $src_w / $src_h;
65
- if ( !$h ) {
66
- $h = round( $w / $src_ratio );
67
- }
68
- if ( !$w ) {
69
- //the user wants to resize based on constant height
70
- $w = round( $h * $src_ratio );
71
- }
72
- // Get ratios
73
- $dest_ratio = $w / $h;
74
- $src_wt = $src_h * $dest_ratio;
75
- $src_ht = $src_w / $dest_ratio;
76
- if ( !$crop ) {
77
- // Always crop, to allow resizing upwards
78
- $image->crop( 0, 0, $src_w, $src_h, $w, $h );
79
- } else {
80
- //start with defaults:
81
- $src_x = $src_w / 2 - $src_wt / 2;
82
- $src_y = ( $src_h - $src_ht ) / 6;
83
- //now specific overrides based on options:
84
- if ( $crop == 'center' ) {
85
- // Get source x and y
86
- $src_x = round( ( $src_w - $src_wt ) / 2 );
87
- $src_y = round( ( $src_h - $src_ht ) / 2 );
88
- } else if ( $crop == 'top' ) {
89
- $src_y = 0;
90
- } else if ( $crop == 'bottom' ) {
91
- $src_y = $src_h - $src_ht;
92
- } else if ( $crop == 'left' ) {
93
- $src_x = 0;
94
- } else if ( $crop == 'right' ) {
95
- $src_x = $src_w - $src_wt;
96
- }
97
- // Crop the image
98
- if ( $dest_ratio > $src_ratio ) {
99
- $image->crop( 0, $src_y, $src_w, $src_ht, $w, $h );
100
- } else {
101
- $image->crop( $src_x, 0, $src_wt, $src_h, $w, $h );
102
- }
103
- }
104
- $result = $image->save( $save_filename );
105
- if ( is_wp_error( $result ) ) {
106
- error_log( 'Error resizing image' );
107
- error_log( print_r( $result, true ) );
108
- return false;
109
- } else {
110
- return true;
111
- }
112
- } else if ( isset( $image->error_data['error_loading_image'] ) ) {
113
- TimberHelper::error_log( 'Error loading ' . $image->error_data['error_loading_image'] );
114
- } else {
115
- TimberHelper::error_log( $image );
116
- }
117
- }
118
  }
1
  <?php
2
  /**
3
+ * Changes image to new size, by shrinking/enlarging
4
+ * then cropping to respect new ratio.
5
+ *
6
+ * Arguments:
7
+ * - width of new image
8
+ * - height of new image
9
+ * - crop method
10
+ */
11
  class TimberImageOperationResize extends TimberImageOperation {
12
 
13
  private $w, $h, $crop;
14
 
15
+ /**
16
+ * @param int $w width of new image
17
+ * @param int $h height of new image
18
+ * @param string $crop cropping method, one of: 'default', 'center', 'top', 'bottom', 'left', 'right'.
19
+ */
20
+ function __construct($w, $h, $crop) {
21
+ $this->w = $w;
22
+ $this->h = $h;
23
+ // Sanitize crop position
24
+ $allowed_crop_positions = array( 'default', 'center', 'top', 'bottom', 'left', 'right' );
25
+ if ( $crop !== false && !in_array( $crop, $allowed_crop_positions ) ) {
26
+ $crop = $allowed_crop_positions[0];
27
+ }
28
+ $this->crop = $crop;
29
+ }
30
 
31
+ /**
32
+ * @param string $src_filename the basename of the file (ex: my-awesome-pic)
33
+ * @param string $src_extension the extension (ex: .jpg)
34
+ * @return string the final filename to be used (ex: my-awesome-pic-300x200-c-default.jpg)
35
+ */
36
+ public function filename($src_filename, $src_extension) {
37
+ $result = $src_filename . '-' . $this->w . 'x' . $this->h . '-c-' . ( $this->crop ? $this->crop : 'f' ); // Crop will be either user named or f (false)
38
+ if($src_extension) {
39
+ $result .= '.'.$src_extension;
40
+ }
41
+ return $result;
42
+ }
43
 
44
+ /**
45
+ * Performs the actual image manipulation,
46
+ * including saving the target file.
47
+ *
48
+ * @param string $load_filename filepath (not URL) to source file
49
+ * (ex: /src/var/www/wp-content/uploads/my-pic.jpg)
50
+ * @param string $save_filename filepath (not URL) where result file should be saved
51
+ * (ex: /src/var/www/wp-content/uploads/my-pic-300x200-c-default.jpg)
52
+ * @return bool true if everything went fine, false otherwise
53
+ */
54
+ public function run($load_filename, $save_filename) {
55
+ $image = wp_get_image_editor( $load_filename );
56
+ if ( !is_wp_error( $image ) ) {
57
+ $w = $this->w;
58
+ $h = $this->h;
59
+ $crop = $this->crop;
60
 
61
+ $current_size = $image->get_size();
62
+ $src_w = $current_size['width'];
63
+ $src_h = $current_size['height'];
64
+ $src_ratio = $src_w / $src_h;
65
+ if ( !$h ) {
66
+ $h = round( $w / $src_ratio );
67
+ }
68
+ if ( !$w ) {
69
+ //the user wants to resize based on constant height
70
+ $w = round( $h * $src_ratio );
71
+ }
72
+ // Get ratios
73
+ $dest_ratio = $w / $h;
74
+ $src_wt = $src_h * $dest_ratio;
75
+ $src_ht = $src_w / $dest_ratio;
76
+ if ( !$crop ) {
77
+ // Always crop, to allow resizing upwards
78
+ $image->crop( 0, 0, $src_w, $src_h, $w, $h );
79
+ } else {
80
+ //start with defaults:
81
+ $src_x = $src_w / 2 - $src_wt / 2;
82
+ $src_y = ( $src_h - $src_ht ) / 6;
83
+ //now specific overrides based on options:
84
+ if ( $crop == 'center' ) {
85
+ // Get source x and y
86
+ $src_x = round( ( $src_w - $src_wt ) / 2 );
87
+ $src_y = round( ( $src_h - $src_ht ) / 2 );
88
+ } else if ( $crop == 'top' ) {
89
+ $src_y = 0;
90
+ } else if ( $crop == 'bottom' ) {
91
+ $src_y = $src_h - $src_ht;
92
+ } else if ( $crop == 'left' ) {
93
+ $src_x = 0;
94
+ } else if ( $crop == 'right' ) {
95
+ $src_x = $src_w - $src_wt;
96
+ }
97
+ // Crop the image
98
+ if ( $dest_ratio > $src_ratio ) {
99
+ $image->crop( 0, $src_y, $src_w, $src_ht, $w, $h );
100
+ } else {
101
+ $image->crop( $src_x, 0, $src_wt, $src_h, $w, $h );
102
+ }
103
+ }
104
+ $result = $image->save( $save_filename );
105
+ if ( is_wp_error( $result ) ) {
106
+ error_log( 'Error resizing image' );
107
+ error_log( print_r( $result, true ) );
108
+ return false;
109
+ } else {
110
+ return true;
111
+ }
112
+ } else if ( isset( $image->error_data['error_loading_image'] ) ) {
113
+ TimberHelper::error_log( 'Error loading ' . $image->error_data['error_loading_image'] );
114
+ } else {
115
+ TimberHelper::error_log( $image );
116
+ }
117
+ }
118
  }
lib/image/timber-image-operation.php CHANGED
@@ -9,41 +9,41 @@
9
  * - run
10
  */
11
  abstract class TimberImageOperation {
12
- /**
13
- * Builds the result filename, based on source filename and extension
14
- *
15
- * @param string $src_filename source filename (excluding extension and path)
16
- * @param string $src_extension source file extension
17
- * @return string resulting filename (including extension but excluding path)
18
- * ex: my-awesome-file.jpg
19
- */
20
- public abstract function filename($src_filename, $src_extension);
21
 
22
- /**
23
- * Performs the actual image manipulation,
24
- * including saving the target file.
25
- *
26
- * @param string $load_filename filepath (not URL) to source file
27
- * @param string $save_filename filepath (not URL) where result file should be saved
28
- * @return bool true if everything went fine, false otherwise
29
- */
30
- public abstract function run($load_filename, $save_filename);
31
 
32
- /**
33
- * Helper method to convert hex string to rgb array
34
- *
35
- * @param string $hexstr hex color string (like '#FF1455')
36
- * @return array array('red', 'green', 'blue') to int
37
- * ex: array('red' => 255, 'green' => 20, 'blue' => 85);
38
- */
39
- public static function hexrgb( $hexstr ) {
40
- if ( !strstr( $hexstr, '#' ) ) {
41
- $hexstr = '#' . $hexstr;
42
- }
43
- if ( strlen( $hexstr ) == 4 ) {
44
- $hexstr = '#' . $hexstr[1] . $hexstr[1] . $hexstr[2] . $hexstr[2] . $hexstr[3] . $hexstr[3];
45
- }
46
- $int = hexdec( $hexstr );
47
- return array( "red" => 0xFF & ( $int >> 0x10 ), "green" => 0xFF & ( $int >> 0x8 ), "blue" => 0xFF & $int );
48
- }
49
  }
9
  * - run
10
  */
11
  abstract class TimberImageOperation {
12
+ /**
13
+ * Builds the result filename, based on source filename and extension
14
+ *
15
+ * @param string $src_filename source filename (excluding extension and path)
16
+ * @param string $src_extension source file extension
17
+ * @return string resulting filename (including extension but excluding path)
18
+ * ex: my-awesome-file.jpg
19
+ */
20
+ public abstract function filename($src_filename, $src_extension);
21
 
22
+ /**
23
+ * Performs the actual image manipulation,
24
+ * including saving the target file.
25
+ *
26
+ * @param string $load_filename filepath (not URL) to source file
27
+ * @param string $save_filename filepath (not URL) where result file should be saved
28
+ * @return bool true if everything went fine, false otherwise
29
+ */
30
+ public abstract function run($load_filename, $save_filename);
31
 
32
+ /**
33
+ * Helper method to convert hex string to rgb array
34
+ *
35
+ * @param string $hexstr hex color string (like '#FF1455')
36
+ * @return array array('red', 'green', 'blue') to int
37
+ * ex: array('red' => 255, 'green' => 20, 'blue' => 85);
38
+ */
39
+ public static function hexrgb( $hexstr ) {
40
+ if ( !strstr( $hexstr, '#' ) ) {
41
+ $hexstr = '#' . $hexstr;
42
+ }
43
+ if ( strlen( $hexstr ) == 4 ) {
44
+ $hexstr = '#' . $hexstr[1] . $hexstr[1] . $hexstr[2] . $hexstr[2] . $hexstr[3] . $hexstr[3];
45
+ }
46
+ $int = hexdec( $hexstr );
47
+ return array( "red" => 0xFF & ( $int >> 0x10 ), "green" => 0xFF & ( $int >> 0x8 ), "blue" => 0xFF & $int );
48
+ }
49
  }
lib/timber-comment.php CHANGED
@@ -62,15 +62,15 @@ class TimberComment extends TimberCore implements TimberCoreInterface {
62
  }
63
 
64
  /**
 
 
 
 
65
  * @param int $size
66
  * @param string $default
67
  * @return bool|mixed|string
68
  */
69
  public function avatar($size = 92, $default = '') {
70
- // Fetches the Gravatar
71
- // use it like this
72
- // {{comment.avatar(36,template_uri~"/img/dude.jpg")}}
73
-
74
  if (!get_option('show_avatars')) {
75
  return false;
76
  }
@@ -86,7 +86,7 @@ class TimberComment extends TimberCore implements TimberCoreInterface {
86
  $host = $this->avatar_host($email_hash);
87
  $default = $this->avatar_default($default, $email, $size, $host);
88
  if (!empty($email)) {
89
- $avatar = $this->avatar_out($email, $default, $host, $email_hash, $size);
90
  } else {
91
  $avatar = $default;
92
  }
@@ -197,6 +197,7 @@ class TimberComment extends TimberCore implements TimberCoreInterface {
197
  }
198
 
199
  /**
 
200
  * @param string $default
201
  * @param string $email
202
  * @param string $size
@@ -204,7 +205,6 @@ class TimberComment extends TimberCore implements TimberCoreInterface {
204
  * @return string
205
  */
206
  protected function avatar_default($default, $email, $size, $host) {
207
- # what if its relative.
208
  if (substr($default, 0, 1) == '/') {
209
  $default = home_url() . $default;
210
  }
@@ -228,22 +228,18 @@ class TimberComment extends TimberCore implements TimberCoreInterface {
228
  $default = $host . '/avatar/?s=' . $size;
229
  } else if (empty($email) && !strstr($default, 'http://')) {
230
  $default = $host . '/avatar/?d=' . $default . '&amp;s=' . $size;
231
- } else if (strpos($default, 'http://') === 0) {
232
- //theyre just linking to an image so don't do anything else
233
- //$default = add_query_arg( 's', $size, $default );
234
  }
235
  return $default;
236
  }
237
 
238
  /**
239
- * @param string $email
240
  * @param string $default
241
  * @param string $host
242
  * @param string $email_hash
243
  * @param string $size
244
  * @return mixed
245
  */
246
- protected function avatar_out($email, $default, $host, $email_hash, $size) {
247
  $out = $host . '/avatar/' . $email_hash . '?s=' . $size . '&amp;d=' . urlencode($default);
248
  $rating = get_option('avatar_rating');
249
  if (!empty($rating)) {
62
  }
63
 
64
  /**
65
+ * Fetches the Gravatar
66
+ * ```twig
67
+ * {{comment.avatar(36,template_uri~"/img/dude.jpg")}}
68
+ * ```
69
  * @param int $size
70
  * @param string $default
71
  * @return bool|mixed|string
72
  */
73
  public function avatar($size = 92, $default = '') {
 
 
 
 
74
  if (!get_option('show_avatars')) {
75
  return false;
76
  }
86
  $host = $this->avatar_host($email_hash);
87
  $default = $this->avatar_default($default, $email, $size, $host);
88
  if (!empty($email)) {
89
+ $avatar = $this->avatar_out($default, $host, $email_hash, $size);
90
  } else {
91
  $avatar = $default;
92
  }
197
  }
198
 
199
  /**
200
+ * @todo what if it's relative?
201
  * @param string $default
202
  * @param string $email
203
  * @param string $size
205
  * @return string
206
  */
207
  protected function avatar_default($default, $email, $size, $host) {
 
208
  if (substr($default, 0, 1) == '/') {
209
  $default = home_url() . $default;
210
  }
228
  $default = $host . '/avatar/?s=' . $size;
229
  } else if (empty($email) && !strstr($default, 'http://')) {
230
  $default = $host . '/avatar/?d=' . $default . '&amp;s=' . $size;
 
 
 
231
  }
232
  return $default;
233
  }
234
 
235
  /**
 
236
  * @param string $default
237
  * @param string $host
238
  * @param string $email_hash
239
  * @param string $size
240
  * @return mixed
241
  */
242
+ protected function avatar_out($default, $host, $email_hash, $size) {
243
  $out = $host . '/avatar/' . $email_hash . '?s=' . $size . '&amp;d=' . urlencode($default);
244
  $rating = get_option('avatar_rating');
245
  if (!empty($rating)) {
lib/timber-image-helper.php CHANGED
@@ -32,7 +32,7 @@ class TimberImageHelper {
32
  * @param int|string $w target width(int) or WordPress image size (WP-set or user-defined)
33
  * @param int $h target height (ignored if $w is WP image size)
34
  * @param string $crop
35
- * @param bool $force_resize
36
  * @return string (ex: )
37
  */
38
  public static function resize( $src, $w, $h = 0, $crop = 'default', $force = false ) {
@@ -58,7 +58,7 @@ class TimberImageHelper {
58
  * @type int h
59
  * }
60
  */
61
- private static function find_wp_dimensions($size) {
62
 
63
  // if ( in_array( $_size, array( 'thumbnail', 'medium', 'large' ) ) ) {
64
 
@@ -87,8 +87,8 @@ class TimberImageHelper {
87
  *
88
  * @return string url to the new image
89
  */
90
- public static function retina_resize( $src, $factor = 2, $force = false) {
91
- $op = new TimberImageOperationRetina($factor);
92
  return self::_operate($src, $op, $force);
93
  }
94
 
32
  * @param int|string $w target width(int) or WordPress image size (WP-set or user-defined)
33
  * @param int $h target height (ignored if $w is WP image size)
34
  * @param string $crop
35
+ * @param bool $force
36
  * @return string (ex: )
37
  */
38
  public static function resize( $src, $w, $h = 0, $crop = 'default', $force = false ) {
58
  * @type int h
59
  * }
60
  */
61
+ private static function find_wp_dimensions( $size ) {
62
 
63
  // if ( in_array( $_size, array( 'thumbnail', 'medium', 'large' ) ) ) {
64
 
87
  *
88
  * @return string url to the new image
89
  */
90
+ public static function retina_resize( $src, $multiplier = 2, $force = false ) {
91
+ $op = new TimberImageOperationRetina($multiplier);
92
  return self::_operate($src, $op, $force);
93
  }
94
 
lib/timber-image.php CHANGED
@@ -113,8 +113,8 @@ class TimberImage extends TimberPost implements TimberCoreInterface {
113
  $base = ($dir["baseurl"]);
114
 
115
  $src = trailingslashit($this->_maybe_secure_url($base)) . $this->file;
116
- $src = apply_filters('timber/image/src', $src);
117
- return apply_filters('timber_image_src', $src);
118
  }
119
 
120
  private static function _maybe_secure_url($url) {
113
  $base = ($dir["baseurl"]);
114
 
115
  $src = trailingslashit($this->_maybe_secure_url($base)) . $this->file;
116
+ $src = apply_filters('timber/image/src', $src, $this->ID);
117
+ return apply_filters('timber_image_src', $src, $this->ID);
118
  }
119
 
120
  private static function _maybe_secure_url($url) {
lib/timber-loader.php CHANGED
@@ -2,411 +2,411 @@
2
 
3
  class TimberLoader {
4
 
5
- const CACHEGROUP = 'timberloader';
6
-
7
- const TRANS_KEY_LEN = 50;
8
-
9
- const CACHE_NONE = 'none';
10
- const CACHE_OBJECT = 'cache';
11
- const CACHE_TRANSIENT = 'transient';
12
- const CACHE_SITE_TRANSIENT = 'site-transient';
13
- const CACHE_USE_DEFAULT = 'default';
14
-
15
- public static $cache_modes = array(
16
- self::CACHE_NONE,
17
- self::CACHE_OBJECT,
18
- self::CACHE_TRANSIENT,
19
- self::CACHE_SITE_TRANSIENT
20
- );
21
-
22
- protected $cache_mode = self::CACHE_TRANSIENT;
23
-
24
- public $locations;
25
-
26
- /**
27
- * @param bool $caller
28
- */
29
- function __construct($caller = false) {
30
- $this->locations = $this->get_locations($caller);
31
- $this->cache_mode = apply_filters('timber_cache_mode', $this->cache_mode);
32
- $this->cache_mode = apply_filters('timber/cache/mode', $this->cache_mode);
33
- }
34
-
35
- /**
36
- * @param string $file
37
- * @param array $data
38
- * @param bool $expires
39
- * @param string $cache_mode
40
- * @return bool|string
41
- */
42
- function render($file, $data = null, $expires = false, $cache_mode = self::CACHE_USE_DEFAULT) {
43
- // Different $expires if user is anonymous or logged in
44
- if (is_array($expires)) {
45
- if (is_user_logged_in() && isset($expires[1])) {
46
- $expires = $expires[1];
47
- } else {
48
- $expires = $expires[0];
49
- }
50
- }
51
-
52
- $key = null;
53
- $output = false;
54
- if (false !== $expires) {
55
- ksort($data);
56
- $key = md5($file . json_encode($data));
57
- $output = $this->get_cache($key, self::CACHEGROUP, $cache_mode);
58
- }
59
-
60
- if (false === $output || null === $output) {
61
- $twig = $this->get_twig();
62
- if (strlen($file)) {
63
- $loader = $this->get_loader();
64
- $result = $loader->getCacheKey($file);
65
- do_action('timber_loader_render_file', $result);
66
- }
67
- $data = apply_filters('timber_loader_render_data', $data);
68
- $data = apply_filters('timber/loader/render_data', $data);
69
- $output = $twig->render($file, $data);
70
- }
71
-
72
- if (false !== $output && false !== $expires && null !== $key) {
73
- $this->set_cache($key, $output, self::CACHEGROUP, $expires, $cache_mode);
74
- }
75
- $output = apply_filters('timber_output', $output);
76
- return apply_filters('timber/output', $output);
77
- }
78
-
79
- /**
80
- * @param array $filenames
81
- * @return bool
82
- */
83
- function choose_template($filenames) {
84
- if (is_array($filenames)) {
85
- /* its an array so we have to figure out which one the dev wants */
86
- foreach ($filenames as $filename) {
87
- if ($this->template_exists($filename)) {
88
- return $filename;
89
- }
90
- }
91
- return false;
92
- }
93
- return $filenames;
94
- }
95
-
96
- /**
97
- * @param string $file
98
- * @return bool
99
- */
100
- function template_exists($file) {
101
- foreach ($this->locations as $dir) {
102
- $look_for = trailingslashit($dir) . $file;
103
- if (file_exists($look_for)) {
104
- return true;
105
- }
106
- }
107
- return false;
108
- }
109
-
110
- /**
111
- * @return array
112
- */
113
- function get_locations_theme() {
114
- $theme_locs = array();
115
- $child_loc = get_stylesheet_directory();
116
- $parent_loc = get_template_directory();
117
- if (DIRECTORY_SEPARATOR == '\\') {
118
- $child_loc = str_replace('/', '\\', $child_loc);
119
- $parent_loc = str_replace('/', '\\', $parent_loc);
120
- }
121
- $theme_locs[] = $child_loc;
122
- foreach ($this->get_locations_theme_dir() as $dirname) {
123
- $theme_locs[] = trailingslashit($child_loc) . trailingslashit($dirname);
124
- }
125
- if ($child_loc != $parent_loc) {
126
- $theme_locs[] = $parent_loc;
127
- foreach ($this->get_locations_theme_dir() as $dirname) {
128
- $theme_locs[] = trailingslashit($parent_loc) . trailingslashit($dirname);
129
- }
130
- }
131
- //now make sure theres a trailing slash on everything
132
- $theme_locs = array_map('trailingslashit', $theme_locs);
133
- return $theme_locs;
134
- }
135
-
136
- /**
137
- * returns an array of the directory inside themes that holds twig files
138
- * @return string[] the names of directores, ie: array('templats', 'views');
139
- */
140
- private function get_locations_theme_dir() {
141
- if (is_string(Timber::$dirname)) {
142
- return array(Timber::$dirname);
143
- }
144
- return Timber::$dirname;
145
- }
146
-
147
- /**
148
- * @return array
149
- */
150
- function get_locations_user() {
151
- $locs = array();
152
- if (isset(Timber::$locations)) {
153
- if (is_string(Timber::$locations)) {
154
- Timber::$locations = array(Timber::$locations);
155
- }
156
- foreach (Timber::$locations as $tloc) {
157
- $tloc = realpath($tloc);
158
- if (is_dir($tloc)) {
159
- $locs[] = $tloc;
160
- }
161
- }
162
- }
163
- return $locs;
164
- }
165
-
166
- /**
167
- * @param bool $caller
168
- * @return array
169
- */
170
- function get_locations_caller($caller = false) {
171
- $locs = array();
172
- if ($caller && is_string($caller)) {
173
- $caller = trailingslashit($caller);
174
- if (is_dir($caller)) {
175
- $locs[] = $caller;
176
- }
177
- foreach ($this->get_locations_theme_dir() as $dirname) {
178
- $caller_sub = $caller . trailingslashit($dirname);
179
- if (is_dir($caller_sub)) {
180
- $locs[] = $caller_sub;
181
- }
182
- }
183
- }
184
- return $locs;
185
- }
186
-
187
- /**
188
- * @param bool $caller
189
- * @return array
190
- */
191
- function get_locations($caller = false) {
192
- //prioirty: user locations, caller (but not theme), child theme, parent theme, caller
193
- $locs = array();
194
- $locs = array_merge($locs, $this->get_locations_user());
195
- $locs = array_merge($locs, $this->get_locations_caller($caller));
196
- //remove themes from caller
197
- $locs = array_diff($locs, $this->get_locations_theme());
198
- $locs = array_merge($locs, $this->get_locations_theme());
199
- $locs = array_merge($locs, $this->get_locations_caller($caller));
200
- $locs = array_unique($locs);
201
- $locs = apply_filters('timber_locations', $locs);
202
- $locs = apply_filters('timber/locations', $locs);
203
- return $locs;
204
- }
205
-
206
- /**
207
- * @return Twig_Loader_Filesystem
208
- */
209
- function get_loader() {
210
- $paths = array();
211
- foreach ($this->locations as $loc) {
212
- $loc = realpath($loc);
213
- if (is_dir($loc)) {
214
- $loc = realpath($loc);
215
- $paths[] = $loc;
216
- } else {
217
- //error_log($loc.' is not a directory');
218
- }
219
- }
220
- if (!ini_get('open_basedir')) {
221
- $paths[] = '/';
222
- } else {
223
- $paths[] = ABSPATH;
224
- }
225
- $paths = apply_filters('timber/loader/paths', $paths);
226
- $loader = new Twig_Loader_Filesystem($paths);
227
- return $loader;
228
- }
229
-
230
- /**
231
- * @return Twig_Environment
232
- */
233
- function get_twig() {
234
- $loader = $this->get_loader();
235
- $params = array('debug' => WP_DEBUG, 'autoescape' => false);
236
- if (isset(Timber::$autoescape)) {
237
- $params['autoescape'] = Timber::$autoescape;
238
- }
239
- if (Timber::$cache == true) {
240
- Timber::$twig_cache = true;
241
- }
242
- if (Timber::$twig_cache) {
243
- $twig_cache_loc = apply_filters( 'timber/cache/location', TIMBER_LOC . '/cache/twig' );
244
- if (!file_exists($twig_cache_loc)) {
245
- mkdir($twig_cache_loc, 0777, true);
246
- }
247
- $params['cache'] = $twig_cache_loc;
248
- }
249
- $twig = new Twig_Environment($loader, $params);
250
- if (WP_DEBUG) {
251
- $twig->addExtension(new Twig_Extension_Debug());
252
- }
253
- $twig->addExtension($this->_get_cache_extension());
254
-
255
- $twig = apply_filters('twig_apply_filters', $twig);
256
- $twig = apply_filters('timber/loader/twig', $twig);
257
- return $twig;
258
- }
259
-
260
- public function clear_cache_timber($cache_mode = self::CACHE_USE_DEFAULT){
261
- //_transient_timberloader
262
- $object_cache = false;
263
- if (isset($GLOBALS['wp_object_cache']) && is_object($GLOBALS['wp_object_cache'])) {
264
- $object_cache = true;
265
- }
266
- $cache_mode = $this->_get_cache_mode($cache_mode);
267
- if (self::CACHE_TRANSIENT === $cache_mode) {
268
- global $wpdb;
269
- $query = $wpdb->prepare("DELETE FROM $wpdb->options WHERE option_name LIKE '%s'", '_transient_timberloader_%');
270
- $wpdb->query( $query );
271
- return true;
272
- } else if (self::CACHE_SITE_TRANSIENT === $cache_mode) {
273
- global $wpdb;
274
- $query = $wpdb->prepare("DELETE FROM $wpdb->options WHERE option_name LIKE '%s'", '_transient_timberloader_%');
275
- $wpdb->query( $query );
276
- return true;
277
- } else if (self::CACHE_OBJECT === $cache_mode && $object_cache) {
278
- global $wp_object_cache;
279
- if (isset($wp_object_cache->cache[self::CACHEGROUP])){
280
- unset($wp_object_cache->cache[self::CACHEGROUP]);
281
- return true;
282
- }
283
- }
284
- return false;
285
- }
286
-
287
- public function clear_cache_twig() {
288
- $twig = $this->get_twig();
289
- $twig->clearCacheFiles();
290
- $cache = $twig->getCache();
291
- if ($cache){
292
- self::rrmdir($twig->getCache());
293
- return true;
294
- }
295
- return false;
296
- }
297
-
298
- /**
299
- * @param string|false $dirPath
300
- */
301
- public static function rrmdir($dirPath) {
302
- if (! is_dir($dirPath)) {
303
- throw new InvalidArgumentException("$dirPath must be a directory");
304
- }
305
- if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') {
306
- $dirPath .= '/';
307
- }
308
- $files = glob($dirPath . '*', GLOB_MARK);
309
- foreach ($files as $file) {
310
- if (is_dir($file)) {
311
- self::rrmdir($file);
312
- } else {
313
- unlink($file);
314
- }
315
- }
316
- rmdir($dirPath);
317
  }
318
 
319
- /**
320
- * @return \Asm89\Twig\CacheExtension\Extension
321
- */
322
- private function _get_cache_extension() {
323
-
324
- $key_generator = new \Timber\Cache\KeyGenerator();
325
- $cache_provider = new \Timber\Cache\WPObjectCacheAdapter( $this );
326
- $cache_strategy = new \Asm89\Twig\CacheExtension\CacheStrategy\GenerationalCacheStrategy( $cache_provider, $key_generator );
327
- $cache_extension = new \Asm89\Twig\CacheExtension\Extension( $cache_strategy );
328
-
329
- return $cache_extension;
330
- }
331
-
332
- /**
333
- * @param string $key
334
- * @param string $group
335
- * @param string $cache_mode
336
- * @return bool
337
- */
338
- public function get_cache($key, $group = self::CACHEGROUP, $cache_mode = self::CACHE_USE_DEFAULT) {
339
- $object_cache = false;
340
-
341
- if (isset($GLOBALS['wp_object_cache']) && is_object($GLOBALS['wp_object_cache'])) {
342
- $object_cache = true;
343
- }
344
-
345
- $cache_mode = $this->_get_cache_mode($cache_mode);
346
-
347
- $value = false;
348
-
349
- $trans_key = substr($group . '_' . $key, 0, self::TRANS_KEY_LEN);
350
- if (self::CACHE_TRANSIENT === $cache_mode)
351
- $value = get_transient($trans_key);
352
-
353
- elseif (self::CACHE_SITE_TRANSIENT === $cache_mode)
354
- $value = get_site_transient($trans_key);
355
-
356
- elseif (self::CACHE_OBJECT === $cache_mode && $object_cache)
357
- $value = wp_cache_get($key, $group);
358
-
359
- return $value;
360
- }
361
-
362
- /**
363
- * @param string $key
364
- * @param string|boolean $value
365
- * @param string $group
366
- * @param int $expires
367
- * @param string $cache_mode
368
- * @return string|boolean
369
- */
370
- public function set_cache($key, $value, $group = self::CACHEGROUP, $expires = 0, $cache_mode = self::CACHE_USE_DEFAULT) {
371
- $object_cache = false;
372
-
373
- if (isset($GLOBALS['wp_object_cache']) && is_object($GLOBALS['wp_object_cache'])) {
374
- $object_cache = true;
375
- }
376
-
377
- if ((int)$expires < 1)
378
- $expires = 0;
379
-
380
- $cache_mode = self::_get_cache_mode($cache_mode);
381
- $trans_key = substr($group . '_' . $key, 0, self::TRANS_KEY_LEN);
382
-
383
- if (self::CACHE_TRANSIENT === $cache_mode)
384
- set_transient($trans_key, $value, $expires);
385
-
386
- elseif (self::CACHE_SITE_TRANSIENT === $cache_mode)
387
- set_site_transient($trans_key, $value, $expires);
388
-
389
- elseif (self::CACHE_OBJECT === $cache_mode && $object_cache)
390
- wp_cache_set($key, $value, $group, $expires);
391
-
392
- return $value;
393
- }
394
-
395
- /**
396
- * @param string $cache_mode
397
- * @return string
398
- */
399
- private function _get_cache_mode($cache_mode) {
400
- if (empty($cache_mode) || self::CACHE_USE_DEFAULT === $cache_mode) {
401
- $cache_mode = $this->cache_mode;
402
- }
403
-
404
- // Fallback if self::$cache_mode did not get a valid value
405
- if (!in_array($cache_mode, self::$cache_modes)) {
406
- $cache_mode = self::CACHE_OBJECT;
407
- }
408
-
409
- return $cache_mode;
410
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
411
 
412
  }
2
 
3
  class TimberLoader {
4
 
5
+ const CACHEGROUP = 'timberloader';
6
+
7
+ const TRANS_KEY_LEN = 50;
8
+
9
+ const CACHE_NONE = 'none';
10
+ const CACHE_OBJECT = 'cache';
11
+ const CACHE_TRANSIENT = 'transient';
12
+ const CACHE_SITE_TRANSIENT = 'site-transient';
13
+ const CACHE_USE_DEFAULT = 'default';
14
+
15
+ public static $cache_modes = array(
16
+ self::CACHE_NONE,
17
+ self::CACHE_OBJECT,
18
+ self::CACHE_TRANSIENT,
19
+ self::CACHE_SITE_TRANSIENT
20
+ );
21
+
22
+ protected $cache_mode = self::CACHE_TRANSIENT;
23
+
24
+ public $locations;
25
+
26
+ /**
27
+ * @param bool|string $caller the calling directory or false
28
+ */
29
+ function __construct($caller = false) {
30
+ $this->locations = $this->get_locations($caller);
31
+ $this->cache_mode = apply_filters('timber_cache_mode', $this->cache_mode);
32
+ $this->cache_mode = apply_filters('timber/cache/mode', $this->cache_mode);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  }
34
 
35
+ /**
36
+ * @param string $file
37
+ * @param array $data
38
+ * @param bool $expires
39
+ * @param string $cache_mode
40
+ * @return bool|string
41
+ */
42
+ function render($file, $data = null, $expires = false, $cache_mode = self::CACHE_USE_DEFAULT) {
43
+ // Different $expires if user is anonymous or logged in
44
+ if (is_array($expires)) {
45
+ if (is_user_logged_in() && isset($expires[1])) {
46
+ $expires = $expires[1];
47
+ } else {
48
+ $expires = $expires[0];
49
+ }
50
+ }
51
+
52
+ $key = null;
53
+ $output = false;
54
+ if (false !== $expires) {
55
+ ksort($data);
56
+ $key = md5($file . json_encode($data));
57
+ $output = $this->get_cache($key, self::CACHEGROUP, $cache_mode);
58
+ }
59
+
60
+ if (false === $output || null === $output) {
61
+ $twig = $this->get_twig();
62
+ if (strlen($file)) {
63
+ $loader = $this->get_loader();
64
+ $result = $loader->getCacheKey($file);
65
+ do_action('timber_loader_render_file', $result);
66
+ }
67
+ $data = apply_filters('timber_loader_render_data', $data);
68
+ $data = apply_filters('timber/loader/render_data', $data);
69
+ $output = $twig->render($file, $data);
70
+ }
71
+
72
+ if (false !== $output && false !== $expires && null !== $key) {
73
+ $this->set_cache($key, $output, self::CACHEGROUP, $expires, $cache_mode);
74
+ }
75
+ $output = apply_filters('timber_output', $output);
76
+ return apply_filters('timber/output', $output);
77
+ }
78
+
79
+ /**
80
+ * @param array $filenames
81
+ * @return bool
82
+ */
83
+ function choose_template($filenames) {
84
+ if (is_array($filenames)) {
85
+ /* its an array so we have to figure out which one the dev wants */
86
+ foreach ($filenames as $filename) {
87
+ if ($this->template_exists($filename)) {
88
+ return $filename;
89
+ }
90
+ }
91
+ return false;
92
+ }
93
+ return $filenames;
94
+ }
95
+
96
+ /**
97
+ * @param string $file
98
+ * @return bool
99
+ */
100
+ function template_exists($file) {
101
+ foreach ($this->locations as $dir) {
102
+ $look_for = trailingslashit($dir) . $file;
103
+ if (file_exists($look_for)) {
104
+ return true;
105
+ }
106
+ }
107
+ return false;
108
+ }
109
+
110
+ /**
111
+ * @return array
112
+ */
113
+ function get_locations_theme() {
114
+ $theme_locs = array();
115
+ $child_loc = get_stylesheet_directory();
116
+ $parent_loc = get_template_directory();
117
+ if (DIRECTORY_SEPARATOR == '\\') {
118
+ $child_loc = str_replace('/', '\\', $child_loc);
119
+ $parent_loc = str_replace('/', '\\', $parent_loc);
120
+ }
121
+ $theme_locs[] = $child_loc;
122
+ foreach ($this->get_locations_theme_dir() as $dirname) {
123
+ $theme_locs[] = trailingslashit($child_loc) . trailingslashit($dirname);
124
+ }
125
+ if ($child_loc != $parent_loc) {
126
+ $theme_locs[] = $parent_loc;
127
+ foreach ($this->get_locations_theme_dir() as $dirname) {
128
+ $theme_locs[] = trailingslashit($parent_loc) . trailingslashit($dirname);
129
+ }
130
+ }
131
+ //now make sure theres a trailing slash on everything
132
+ $theme_locs = array_map('trailingslashit', $theme_locs);
133
+ return $theme_locs;
134
+ }
135
+
136
+ /**
137
+ * returns an array of the directory inside themes that holds twig files
138
+ * @return string[] the names of directores, ie: array('templats', 'views');
139
+ */
140
+ private function get_locations_theme_dir() {
141
+ if (is_string(Timber::$dirname)) {
142
+ return array(Timber::$dirname);
143
+ }
144
+ return Timber::$dirname;
145
+ }
146
+
147
+ /**
148
+ * @return array
149
+ */
150
+ function get_locations_user() {
151
+ $locs = array();
152
+ if (isset(Timber::$locations)) {
153
+ if (is_string(Timber::$locations)) {
154
+ Timber::$locations = array(Timber::$locations);
155
+ }
156
+ foreach (Timber::$locations as $tloc) {
157
+ $tloc = realpath($tloc);
158
+ if (is_dir($tloc)) {
159
+ $locs[] = $tloc;
160
+ }
161
+ }
162
+ }
163
+ return $locs;
164
+ }
165
+
166
+ /**
167
+ * @param bool|string $caller the calling directory
168
+ * @return array
169
+ */
170
+ function get_locations_caller($caller = false) {
171
+ $locs = array();
172
+ if ($caller && is_string($caller)) {
173
+ $caller = trailingslashit($caller);
174
+ if (is_dir($caller)) {
175
+ $locs[] = $caller;
176
+ }
177
+ foreach ($this->get_locations_theme_dir() as $dirname) {
178
+ $caller_sub = $caller . trailingslashit($dirname);
179
+ if (is_dir($caller_sub)) {
180
+ $locs[] = $caller_sub;
181
+ }
182
+ }
183
+ }
184
+ return $locs;
185
+ }
186
+
187
+ /**
188
+ * @param bool|string $caller the calling directory (or false)
189
+ * @return array
190
+ */
191
+ function get_locations($caller = false) {
192
+ //prioirty: user locations, caller (but not theme), child theme, parent theme, caller
193
+ $locs = array();
194
+ $locs = array_merge($locs, $this->get_locations_user());
195
+ $locs = array_merge($locs, $this->get_locations_caller($caller));
196
+ //remove themes from caller
197
+ $locs = array_diff($locs, $this->get_locations_theme());
198
+ $locs = array_merge($locs, $this->get_locations_theme());
199
+ $locs = array_merge($locs, $this->get_locations_caller($caller));
200
+ $locs = array_unique($locs);
201
+ $locs = apply_filters('timber_locations', $locs);
202
+ $locs = apply_filters('timber/locations', $locs);
203
+ return $locs;
204
+ }
205
+
206
+ /**
207
+ * @return Twig_Loader_Filesystem
208
+ */
209
+ function get_loader() {
210
+ $paths = array();
211
+ foreach ($this->locations as $loc) {
212
+ $loc = realpath($loc);
213
+ if (is_dir($loc)) {
214
+ $loc = realpath($loc);
215
+ $paths[] = $loc;
216
+ } else {
217
+ //error_log($loc.' is not a directory');
218
+ }
219
+ }
220
+ if (!ini_get('open_basedir')) {
221
+ $paths[] = '/';
222
+ } else {
223
+ $paths[] = ABSPATH;
224
+ }
225
+ $paths = apply_filters('timber/loader/paths', $paths);
226
+ $loader = new Twig_Loader_Filesystem($paths);
227
+ return $loader;
228
+ }
229
+
230
+ /**
231
+ * @return Twig_Environment
232
+ */
233
+ function get_twig() {
234
+ $loader = $this->get_loader();
235
+ $params = array('debug' => WP_DEBUG, 'autoescape' => false);
236
+ if (isset(Timber::$autoescape)) {
237
+ $params['autoescape'] = Timber::$autoescape;
238
+ }
239
+ if (Timber::$cache === true) {
240
+ Timber::$twig_cache = true;
241
+ }
242
+ if (Timber::$twig_cache) {
243
+ $twig_cache_loc = apply_filters( 'timber/cache/location', TIMBER_LOC . '/cache/twig' );
244
+ if (!file_exists($twig_cache_loc)) {
245
+ mkdir($twig_cache_loc, 0777, true);
246
+ }
247
+ $params['cache'] = $twig_cache_loc;
248
+ }
249
+ $twig = new Twig_Environment($loader, $params);
250
+ if ( WP_DEBUG ) {
251
+ $twig->addExtension(new Twig_Extension_Debug());
252
+ }
253
+ $twig->addExtension($this->_get_cache_extension());
254
+
255
+ $twig = apply_filters('twig_apply_filters', $twig);
256
+ $twig = apply_filters('timber/loader/twig', $twig);
257
+ return $twig;
258
+ }
259
+
260
+ public function clear_cache_timber($cache_mode = self::CACHE_USE_DEFAULT){
261
+ //_transient_timberloader
262
+ $object_cache = false;
263
+ if (isset($GLOBALS['wp_object_cache']) && is_object($GLOBALS['wp_object_cache'])) {
264
+ $object_cache = true;
265
+ }
266
+ $cache_mode = $this->_get_cache_mode($cache_mode);
267
+ if (self::CACHE_TRANSIENT === $cache_mode) {
268
+ global $wpdb;
269
+ $query = $wpdb->prepare("DELETE FROM $wpdb->options WHERE option_name LIKE '%s'", '_transient_timberloader_%');
270
+ $wpdb->query( $query );
271
+ return true;
272
+ } else if (self::CACHE_SITE_TRANSIENT === $cache_mode) {
273
+ global $wpdb;
274
+ $query = $wpdb->prepare("DELETE FROM $wpdb->options WHERE option_name LIKE '%s'", '_transient_timberloader_%');
275
+ $wpdb->query( $query );
276
+ return true;
277
+ } else if (self::CACHE_OBJECT === $cache_mode && $object_cache) {
278
+ global $wp_object_cache;
279
+ if (isset($wp_object_cache->cache[self::CACHEGROUP])){
280
+ unset($wp_object_cache->cache[self::CACHEGROUP]);
281
+ return true;
282
+ }
283
+ }
284
+ return false;
285
+ }
286
+
287
+ public function clear_cache_twig() {
288
+ $twig = $this->get_twig();
289
+ $twig->clearCacheFiles();
290
+ $cache = $twig->getCache();
291
+ if ($cache){
292
+ self::rrmdir($twig->getCache());
293
+ return true;
294
+ }
295
+ return false;
296
+ }
297
+
298
+ /**
299
+ * @param string|false $dirPath
300
+ */
301
+ public static function rrmdir($dirPath) {
302
+ if (! is_dir($dirPath)) {
303
+ throw new InvalidArgumentException("$dirPath must be a directory");
304
+ }
305
+ if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') {
306
+ $dirPath .= '/';
307
+ }
308
+ $files = glob($dirPath . '*', GLOB_MARK);
309
+ foreach ($files as $file) {
310
+ if (is_dir($file)) {
311
+ self::rrmdir($file);
312
+ } else {
313
+ unlink($file);
314
+ }
315
+ }
316
+ rmdir($dirPath);
317
+ }
318
+
319
+ /**
320
+ * @return \Asm89\Twig\CacheExtension\Extension
321
+ */
322
+ private function _get_cache_extension() {
323
+
324
+ $key_generator = new \Timber\Cache\KeyGenerator();
325
+ $cache_provider = new \Timber\Cache\WPObjectCacheAdapter( $this );
326
+ $cache_strategy = new \Asm89\Twig\CacheExtension\CacheStrategy\GenerationalCacheStrategy( $cache_provider, $key_generator );
327
+ $cache_extension = new \Asm89\Twig\CacheExtension\Extension( $cache_strategy );
328
+
329
+ return $cache_extension;
330
+ }
331
+
332
+ /**
333
+ * @param string $key
334
+ * @param string $group
335
+ * @param string $cache_mode
336
+ * @return bool
337
+ */
338
+ public function get_cache($key, $group = self::CACHEGROUP, $cache_mode = self::CACHE_USE_DEFAULT) {
339
+ $object_cache = false;
340
+
341
+ if (isset($GLOBALS['wp_object_cache']) && is_object($GLOBALS['wp_object_cache'])) {
342
+ $object_cache = true;
343
+ }
344
+
345
+ $cache_mode = $this->_get_cache_mode($cache_mode);
346
+
347
+ $value = false;
348
+
349
+ $trans_key = substr($group . '_' . $key, 0, self::TRANS_KEY_LEN);
350
+ if (self::CACHE_TRANSIENT === $cache_mode)
351
+ $value = get_transient($trans_key);
352
+
353
+ elseif (self::CACHE_SITE_TRANSIENT === $cache_mode)
354
+ $value = get_site_transient($trans_key);
355
+
356
+ elseif (self::CACHE_OBJECT === $cache_mode && $object_cache)
357
+ $value = wp_cache_get($key, $group);
358
+
359
+ return $value;
360
+ }
361
+
362
+ /**
363
+ * @param string $key
364
+ * @param string|boolean $value
365
+ * @param string $group
366
+ * @param int $expires
367
+ * @param string $cache_mode
368
+ * @return string|boolean
369
+ */
370
+ public function set_cache($key, $value, $group = self::CACHEGROUP, $expires = 0, $cache_mode = self::CACHE_USE_DEFAULT) {
371
+ $object_cache = false;
372
+
373
+ if (isset($GLOBALS['wp_object_cache']) && is_object($GLOBALS['wp_object_cache'])) {
374
+ $object_cache = true;
375
+ }
376
+
377
+ if ((int)$expires < 1)
378
+ $expires = 0;
379
+
380
+ $cache_mode = self::_get_cache_mode($cache_mode);
381
+ $trans_key = substr($group . '_' . $key, 0, self::TRANS_KEY_LEN);
382
+
383
+ if (self::CACHE_TRANSIENT === $cache_mode)
384
+ set_transient($trans_key, $value, $expires);
385
+
386
+ elseif (self::CACHE_SITE_TRANSIENT === $cache_mode)
387
+ set_site_transient($trans_key, $value, $expires);
388
+
389
+ elseif (self::CACHE_OBJECT === $cache_mode && $object_cache)
390
+ wp_cache_set($key, $value, $group, $expires);
391
+
392
+ return $value;
393
+ }
394
+
395
+ /**
396
+ * @param string $cache_mode
397
+ * @return string
398
+ */
399
+ private function _get_cache_mode($cache_mode) {
400
+ if (empty($cache_mode) || self::CACHE_USE_DEFAULT === $cache_mode) {
401
+ $cache_mode = $this->cache_mode;
402
+ }
403
+
404
+ // Fallback if self::$cache_mode did not get a valid value
405
+ if (!in_array($cache_mode, self::$cache_modes)) {
406
+ $cache_mode = self::CACHE_OBJECT;
407
+ }
408
+
409
+ return $cache_mode;
410
+ }
411
 
412
  }
lib/timber-menu-item.php CHANGED
@@ -140,11 +140,14 @@ class TimberMenuItem extends TimberCore implements TimberCoreInterface {
140
  }
141
 
142
  /**
 
143
  *
144
- *
145
- * @param object $data
146
  */
147
  function import_classes( $data ) {
 
 
 
148
  $this->classes = array_merge( $this->classes, $data->classes );
149
  $this->classes = array_unique( $this->classes );
150
  $this->classes = apply_filters( 'nav_menu_css_class', $this->classes, $this );
140
  }
141
 
142
  /**
143
+ * Imports the classes to be used in CSS
144
  *
145
+ * @param array|object $data
 
146
  */
147
  function import_classes( $data ) {
148
+ if ( is_array($data) ) {
149
+ $data = (object) $data;
150
+ }
151
  $this->classes = array_merge( $this->classes, $data->classes );
152
  $this->classes = array_unique( $this->classes );
153
  $this->classes = apply_filters( 'nav_menu_css_class', $this->classes, $this );
lib/timber-url-helper.php CHANGED
@@ -13,9 +13,9 @@ class TimberURLHelper {
13
  $pageURL = "https://";;
14
  }
15
  if ( $_SERVER["SERVER_PORT"] != "80" ) {
16
- $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
17
  } else {
18
- $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
19
  }
20
  return $pageURL;
21
  }
@@ -63,7 +63,7 @@ class TimberURLHelper {
63
  */
64
  public static function get_rel_url( $url, $force = false ) {
65
  $url_info = parse_url( $url );
66
- if ( isset( $url_info['host'] ) && $url_info['host'] != $_SERVER['HTTP_HOST'] && !$force ) {
67
  return $url;
68
  }
69
  $link = '';
@@ -80,6 +80,21 @@ class TimberURLHelper {
80
  return $link;
81
  }
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  /**
84
  *
85
  *
@@ -87,7 +102,7 @@ class TimberURLHelper {
87
  * @return bool
88
  */
89
  public static function is_local( $url ) {
90
- if ( strstr( $url, $_SERVER['HTTP_HOST'] ) ) {
91
  return true;
92
  }
93
  return false;
@@ -227,7 +242,7 @@ class TimberURLHelper {
227
  */
228
  public static function is_external( $url ) {
229
  $has_http = strstr( strtolower( $url ), 'http' );
230
- $on_domain = strstr( $url, $_SERVER['HTTP_HOST'] );
231
  if ( $has_http && !$on_domain ) {
232
  return true;
233
  }
13
  $pageURL = "https://";;
14
  }
15
  if ( $_SERVER["SERVER_PORT"] != "80" ) {
16
+ $pageURL .= self::get_host() . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
17
  } else {
18
+ $pageURL .= self::get_host() . $_SERVER["REQUEST_URI"];
19
  }
20
  return $pageURL;
21
  }
63
  */
64
  public static function get_rel_url( $url, $force = false ) {
65
  $url_info = parse_url( $url );
66
+ if ( isset( $url_info['host'] ) && $url_info['host'] != self::get_host() && !$force ) {
67
  return $url;
68
  }
69
  $link = '';
80
  return $link;
81
  }
82
 
83
+ /**
84
+ * Some setups like HTTP_HOST, some like SERVER_NAME, it's complicated
85
+ * @link http://stackoverflow.com/questions/2297403/http-host-vs-server-name
86
+ * @return string the HTTP_HOST or SERVER_NAME
87
+ */
88
+ public static function get_host() {
89
+ if (isset($_SERVER['HTTP_HOST'])) {
90
+ return $_SERVER['HTTP_HOST'];
91
+ }
92
+ if (isset($_SERVER['SERVER_NAME'])) {
93
+ return $_SERVER['SERVER_NAME'];
94
+ }
95
+ return '';
96
+ }
97
+
98
  /**
99
  *
100
  *
102
  * @return bool
103
  */
104
  public static function is_local( $url ) {
105
+ if ( strstr( $url, self::get_host() ) ) {
106
  return true;
107
  }
108
  return false;
242
  */
243
  public static function is_external( $url ) {
244
  $has_http = strstr( strtolower( $url ), 'http' );
245
+ $on_domain = strstr( $url, self::get_host() );
246
  if ( $has_http && !$on_domain ) {
247
  return true;
248
  }
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: jarednova
3
  Tags: template engine, templates, twig
4
  Requires at least: 3.7
5
- Stable tag: 0.21.7
6
- Tested up to: 4.2.2
7
  PHP version: 5.3.0 or greater
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -41,6 +41,11 @@ Timber is great for any WordPress developer who cares about writing good, mainta
41
 
42
  == Changelog ==
43
 
 
 
 
 
 
44
  = 0.21.7 =
45
  * Fix for Image src in some situtations
46
 
2
  Contributors: jarednova
3
  Tags: template engine, templates, twig
4
  Requires at least: 3.7
5
+ Stable tag: 0.21.8
6
+ Tested up to: 4.2.3
7
  PHP version: 5.3.0 or greater
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
41
 
42
  == Changelog ==
43
 
44
+ = 0.21.8 =
45
+ * Fixes to things in docs
46
+ * Added ID to timber/image/src filter (thanks @aaronhippie)
47
+ * Fixed edgecase with HTTP_HOST vs SERVER_NAME (thanks @maketimetodesign)
48
+
49
  = 0.21.7 =
50
  * Fix for Image src in some situtations
51
 
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.21.7
8
  Author URI: http://upstatement.com/
9
  */
10
 
@@ -16,6 +16,7 @@ global $timber;
16
  // and finally in the current themes directories
17
  if ( file_exists( $composer_autoload = __DIR__ . '/vendor/autoload.php' ) /* check in self */
18
  || file_exists( $composer_autoload = WP_CONTENT_DIR.'/vendor/autoload.php') /* check in wp-content */
 
19
  || file_exists( $composer_autoload = get_stylesheet_directory().'/vendor/autoload.php') /* check in child theme */
20
  || file_exists( $composer_autoload = get_template_directory().'/vendor/autoload.php') /* check in parent theme */
21
  ) {
@@ -225,7 +226,7 @@ class Timber {
225
  */
226
  public static function get_context() {
227
  $data = array();
228
- $data['http_host'] = 'http://' . $_SERVER['HTTP_HOST'];
229
  $data['wp_title'] = TimberHelper::get_wp_title();
230
  $data['wp_head'] = TimberHelper::function_wrapper( 'wp_head' );
231
  $data['wp_footer'] = TimberHelper::function_wrapper( 'wp_footer' );
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.21.8
8
  Author URI: http://upstatement.com/
9
  */
10
 
16
  // and finally in the current themes directories
17
  if ( file_exists( $composer_autoload = __DIR__ . '/vendor/autoload.php' ) /* check in self */
18
  || file_exists( $composer_autoload = WP_CONTENT_DIR.'/vendor/autoload.php') /* check in wp-content */
19
+ || file_exists( $composer_autoload = plugin_dir_path( __FILE__ ).'vendor/autoload.php') /* check in plugin directory */
20
  || file_exists( $composer_autoload = get_stylesheet_directory().'/vendor/autoload.php') /* check in child theme */
21
  || file_exists( $composer_autoload = get_template_directory().'/vendor/autoload.php') /* check in parent theme */
22
  ) {
226
  */
227
  public static function get_context() {
228
  $data = array();
229
+ $data['http_host'] = 'http://' . TimberURLHelper::get_host();
230
  $data['wp_title'] = TimberHelper::get_wp_title();
231
  $data['wp_head'] = TimberHelper::function_wrapper( 'wp_head' );
232
  $data['wp_footer'] = TimberHelper::function_wrapper( 'wp_footer' );
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit893f1d80a50bb5946e39eb5610c579ee::getLoader();
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit5f4dd105040c53136ae075426ca9493e::getLoader();
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit893f1d80a50bb5946e39eb5610c579ee
6
  {
7
  private static $loader;
8
 
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit893f1d80a50bb5946e39eb5610c579ee
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit893f1d80a50bb5946e39eb5610c579ee', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit893f1d80a50bb5946e39eb5610c579ee', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
@@ -44,7 +44,7 @@ class ComposerAutoloaderInit893f1d80a50bb5946e39eb5610c579ee
44
  }
45
  }
46
 
47
- function composerRequire893f1d80a50bb5946e39eb5610c579ee($file)
48
  {
49
  require $file;
50
  }
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit5f4dd105040c53136ae075426ca9493e
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit5f4dd105040c53136ae075426ca9493e', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit5f4dd105040c53136ae075426ca9493e', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
44
  }
45
  }
46
 
47
+ function composerRequire5f4dd105040c53136ae075426ca9493e($file)
48
  {
49
  require $file;
50
  }