@@ -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(); |
@@ -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 { |
@@ -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 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | $menu = wp_get_nav_menu_items($menu_id); |
| 102 | 102 | if ($menu) { |
| 103 | 103 | _wp_menu_item_classes_by_context($menu); |
| 104 | - if (is_array($menu)){ |
|
| 104 | + if (is_array($menu)) { |
|
| 105 | 105 | $menu = self::order_children($menu); |
| 106 | 106 | } |
| 107 | 107 | $this->items = $menu; |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | $mi->__title = $mi->post_title; |
| 124 | 124 | } |
| 125 | 125 | _wp_menu_item_classes_by_context($menu); |
| 126 | - if (is_array($menu)){ |
|
| 126 | + if (is_array($menu)) { |
|
| 127 | 127 | $menu = self::order_children($menu); |
| 128 | 128 | } |
| 129 | 129 | $this->items = $menu; |
@@ -201,13 +201,13 @@ discard block |
||
| 201 | 201 | $item->__title = $item->title; |
| 202 | 202 | unset($item->title); |
| 203 | 203 | } |
| 204 | - if(isset($item->ID)){ |
|
| 205 | - if (is_object($item) && get_class($item) == 'WP_Post'){ |
|
| 204 | + if(isset($item->ID)) { |
|
| 205 | + if (is_object($item) && get_class($item) == 'WP_Post') { |
|
| 206 | 206 | $old_menu_item = $item; |
| 207 | 207 | $item = new $this->PostClass($item); |
| 208 | 208 | } |
| 209 | 209 | $menu_item = new $this->MenuItemClass($item); |
| 210 | - if (isset($old_menu_item)){ |
|
| 210 | + if (isset($old_menu_item)) { |
|
| 211 | 211 | $menu_item->import_classes($old_menu_item); |
| 212 | 212 | } |
| 213 | 213 | $index[$item->ID] = $menu_item; |
@@ -188,13 +188,13 @@ discard block |
||
| 188 | 188 | && get_class($wp_query->queried_object) == 'WP_Post' |
| 189 | 189 | ) { |
| 190 | 190 | $pid = $wp_query->queried_object_id; |
| 191 | - } else if ( $pid === null && $wp_query->is_home && isset($wp_query->queried_object_id) && $wp_query->queried_object_id ) { |
|
| 191 | + } else if ( $pid === null && $wp_query->is_home && isset($wp_query->queried_object_id) && $wp_query->queried_object_id ) { |
|
| 192 | 192 | //hack for static page as home page |
| 193 | 193 | $pid = $wp_query->queried_object_id; |
| 194 | 194 | } else if ( $pid === null ) { |
| 195 | 195 | $gtid = false; |
| 196 | 196 | $maybe_post = get_post(); |
| 197 | - if ( isset($maybe_post->ID) ){ |
|
| 197 | + if ( isset($maybe_post->ID) ) { |
|
| 198 | 198 | $gtid = true; |
| 199 | 199 | } |
| 200 | 200 | if ( $gtid ) { |
@@ -1028,7 +1028,7 @@ discard block |
||
| 1028 | 1028 | $post = $this; |
| 1029 | 1029 | $class_array = get_post_class($class, $this->ID); |
| 1030 | 1030 | $post = $old_global_post; |
| 1031 | - if ( is_array($class_array) ){ |
|
| 1031 | + if ( is_array($class_array) ) { |
|
| 1032 | 1032 | return implode(' ', $class_array); |
| 1033 | 1033 | } |
| 1034 | 1034 | return $class_array; |
@@ -1248,7 +1248,7 @@ discard block |
||
| 1248 | 1248 | /** |
| 1249 | 1249 | * @return string |
| 1250 | 1250 | */ |
| 1251 | - public function name(){ |
|
| 1251 | + public function name() { |
|
| 1252 | 1252 | return $this->title(); |
| 1253 | 1253 | } |
| 1254 | 1254 | |