@@ -44,7 +44,7 @@ |
||
44 | 44 | * (ex: /src/var/www/wp-content/uploads/[email protected]) |
45 | 45 | * @return bool true if everything went fine, false otherwise |
46 | 46 | */ |
47 | - function run($load_filename, $save_filename){ |
|
47 | + function run($load_filename, $save_filename) { |
|
48 | 48 | $image = wp_get_image_editor( $load_filename ); |
49 | 49 | if ( !is_wp_error( $image ) ) { |
50 | 50 | $current_size = $image->get_size(); |
@@ -35,7 +35,7 @@ |
||
35 | 35 | * (ex: /src/var/www/wp-content/uploads/my-pic.png) |
36 | 36 | * @return bool true if everything went fine, false otherwise |
37 | 37 | */ |
38 | - function run($load_filename, $save_filename){ |
|
38 | + function run($load_filename, $save_filename) { |
|
39 | 39 | $input = self::image_create( $load_filename ); |
40 | 40 | list( $width, $height ) = getimagesize( $load_filename ); |
41 | 41 | $output = imagecreatetruecolor( $width, $height ); |
@@ -6,14 +6,14 @@ discard block |
||
6 | 6 | */ |
7 | 7 | class TimberCommand { |
8 | 8 | |
9 | - public static function clear_cache($mode = 'all'){ |
|
10 | - if (is_array($mode)){ |
|
9 | + public static function clear_cache($mode = 'all') { |
|
10 | + if (is_array($mode)) { |
|
11 | 11 | $mode = reset($mode); |
12 | 12 | } |
13 | 13 | if ($mode == 'all') { |
14 | 14 | $twig_cache = self::clear_cache_twig(); |
15 | 15 | $timber_cache = self::clear_cache_timber(); |
16 | - if ($twig_cache && $timber_cache){ |
|
16 | + if ($twig_cache && $timber_cache) { |
|
17 | 17 | return true; |
18 | 18 | } |
19 | 19 | } else if ($mode == 'twig') { |
@@ -23,12 +23,12 @@ discard block |
||
23 | 23 | } |
24 | 24 | } |
25 | 25 | |
26 | - static function clear_cache_timber(){ |
|
26 | + static function clear_cache_timber() { |
|
27 | 27 | $loader = new TimberLoader(); |
28 | 28 | return $loader->clear_cache_timber(); |
29 | 29 | } |
30 | 30 | |
31 | - static function clear_cache_twig(){ |
|
31 | + static function clear_cache_twig() { |
|
32 | 32 | $loader = new TimberLoader(); |
33 | 33 | return $loader->clear_cache_twig(); |
34 | 34 | } |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | * wp timber clear_cache_twig |
26 | 26 | * |
27 | 27 | */ |
28 | - function clear_cache_twig(){ |
|
28 | + function clear_cache_twig() { |
|
29 | 29 | $clear = TimberCommand::clear_cache_twig(); |
30 | - if ($clear){ |
|
30 | + if ($clear) { |
|
31 | 31 | WP_CLI::success('Cleared contents of twig cache'); |
32 | 32 | } else { |
33 | 33 | WP_CLI::warning('Failed to clear twig cache'); |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | function clear_cache_timber() { |
46 | 46 | $clear = TimberCommand::clear_cache_timber(); |
47 | 47 | $message = 'Failed to clear timber cache'; |
48 | - if ($clear){ |
|
48 | + if ($clear) { |
|
49 | 49 | $message = "Cleared contents of Timber's Cache"; |
50 | 50 | WP_CLI::success($message); |
51 | 51 | } else { |
@@ -44,7 +44,7 @@ |
||
44 | 44 | $this->init($cid); |
45 | 45 | } |
46 | 46 | |
47 | - function __toString(){ |
|
47 | + function __toString() { |
|
48 | 48 | return $this->content(); |
49 | 49 | } |
50 | 50 |
@@ -63,7 +63,7 @@ |
||
63 | 63 | foreach ( $info as $key => $value ) { |
64 | 64 | if ( !empty( $key ) && $force ) { |
65 | 65 | $this->$key = $value; |
66 | - } else if ( !empty( $key ) && !method_exists($this, $key) ){ |
|
66 | + } else if ( !empty( $key ) && !method_exists($this, $key) ) { |
|
67 | 67 | $this->$key = $value; |
68 | 68 | } |
69 | 69 | } |
@@ -48,8 +48,9 @@ |
||
48 | 48 | |
49 | 49 | // lock timeout shouldn't be higher than 5 seconds, unless |
50 | 50 | // remote calls with high timeouts are made here |
51 | - if ( $enable_transients ) |
|
52 | - self::_lock_transient( $slug, $lock_timeout ); |
|
51 | + if ( $enable_transients ) { |
|
52 | + self::_lock_transient( $slug, $lock_timeout ); |
|
53 | + } |
|
53 | 54 | |
54 | 55 | $data = $callback(); |
55 | 56 |
@@ -325,7 +325,8 @@ |
||
325 | 325 | ); |
326 | 326 | $upload_dir = wp_upload_dir(); |
327 | 327 | $tmp = $url; |
328 | - if ( 0 === strpos($tmp, ABSPATH) ) { // we've been given a dir, not an url |
|
328 | + if ( 0 === strpos($tmp, ABSPATH) ) { |
|
329 | +// we've been given a dir, not an url |
|
329 | 330 | $result['absolute'] = true; |
330 | 331 | if ( 0 === strpos($tmp, $upload_dir['basedir']) ) { |
331 | 332 | $result['base']= self::BASE_UPLOADS; // upload based |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | return $twig; |
259 | 259 | } |
260 | 260 | |
261 | - public function clear_cache_timber($cache_mode = self::CACHE_USE_DEFAULT){ |
|
261 | + public function clear_cache_timber($cache_mode = self::CACHE_USE_DEFAULT) { |
|
262 | 262 | //_transient_timberloader |
263 | 263 | $object_cache = false; |
264 | 264 | if (isset($GLOBALS['wp_object_cache']) && is_object($GLOBALS['wp_object_cache'])) { |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | return true; |
278 | 278 | } else if (self::CACHE_OBJECT === $cache_mode && $object_cache) { |
279 | 279 | global $wp_object_cache; |
280 | - if (isset($wp_object_cache->cache[self::CACHEGROUP])){ |
|
280 | + if (isset($wp_object_cache->cache[self::CACHEGROUP])) { |
|
281 | 281 | unset($wp_object_cache->cache[self::CACHEGROUP]); |
282 | 282 | return true; |
283 | 283 | } |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | $twig = $this->get_twig(); |
290 | 290 | $twig->clearCacheFiles(); |
291 | 291 | $cache = $twig->getCache(); |
292 | - if ($cache){ |
|
292 | + if ($cache) { |
|
293 | 293 | self::rrmdir($twig->getCache()); |
294 | 294 | return true; |
295 | 295 | } |
@@ -348,14 +348,13 @@ discard block |
||
348 | 348 | $value = false; |
349 | 349 | |
350 | 350 | $trans_key = substr($group . '_' . $key, 0, self::TRANS_KEY_LEN); |
351 | - if (self::CACHE_TRANSIENT === $cache_mode) |
|
352 | - $value = get_transient($trans_key); |
|
353 | - |
|
354 | - elseif (self::CACHE_SITE_TRANSIENT === $cache_mode) |
|
355 | - $value = get_site_transient($trans_key); |
|
356 | - |
|
357 | - elseif (self::CACHE_OBJECT === $cache_mode && $object_cache) |
|
358 | - $value = wp_cache_get($key, $group); |
|
351 | + if (self::CACHE_TRANSIENT === $cache_mode) { |
|
352 | + $value = get_transient($trans_key); |
|
353 | + } elseif (self::CACHE_SITE_TRANSIENT === $cache_mode) { |
|
354 | + $value = get_site_transient($trans_key); |
|
355 | + } elseif (self::CACHE_OBJECT === $cache_mode && $object_cache) { |
|
356 | + $value = wp_cache_get($key, $group); |
|
357 | + } |
|
359 | 358 | |
360 | 359 | return $value; |
361 | 360 | } |
@@ -375,20 +374,20 @@ discard block |
||
375 | 374 | $object_cache = true; |
376 | 375 | } |
377 | 376 | |
378 | - if ((int)$expires < 1) |
|
379 | - $expires = 0; |
|
377 | + if ((int)$expires < 1) { |
|
378 | + $expires = 0; |
|
379 | + } |
|
380 | 380 | |
381 | 381 | $cache_mode = self::_get_cache_mode($cache_mode); |
382 | 382 | $trans_key = substr($group . '_' . $key, 0, self::TRANS_KEY_LEN); |
383 | 383 | |
384 | - if (self::CACHE_TRANSIENT === $cache_mode) |
|
385 | - set_transient($trans_key, $value, $expires); |
|
386 | - |
|
387 | - elseif (self::CACHE_SITE_TRANSIENT === $cache_mode) |
|
388 | - set_site_transient($trans_key, $value, $expires); |
|
389 | - |
|
390 | - elseif (self::CACHE_OBJECT === $cache_mode && $object_cache) |
|
391 | - wp_cache_set($key, $value, $group, $expires); |
|
384 | + if (self::CACHE_TRANSIENT === $cache_mode) { |
|
385 | + set_transient($trans_key, $value, $expires); |
|
386 | + } elseif (self::CACHE_SITE_TRANSIENT === $cache_mode) { |
|
387 | + set_site_transient($trans_key, $value, $expires); |
|
388 | + } elseif (self::CACHE_OBJECT === $cache_mode && $object_cache) { |
|
389 | + wp_cache_set($key, $value, $group, $expires); |
|
390 | + } |
|
392 | 391 | |
393 | 392 | return $value; |
394 | 393 | } |