@@ -26,19 +26,19 @@ |
||
26 | 26 | |
27 | 27 | namespace Rarst\Fragment_Cache; |
28 | 28 | |
29 | -if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) { |
|
29 | +if (file_exists(__DIR__ . '/vendor/autoload.php')) { |
|
30 | 30 | require __DIR__ . '/vendor/autoload.php'; |
31 | 31 | } |
32 | 32 | |
33 | 33 | global $fragment_cache; |
34 | 34 | |
35 | -$fragment_cache = new Plugin( array( |
|
35 | +$fragment_cache = new Plugin(array( |
|
36 | 36 | 'timeout' => HOUR_IN_SECONDS, |
37 | 37 | 'update_server' => new \TLC_Transient_Update_Server(), |
38 | -) ); |
|
38 | +)); |
|
39 | 39 | |
40 | -$fragment_cache->add_fragment_handler( 'menu', 'Rarst\\Fragment_Cache\\Menu_Cache' ); |
|
41 | -$fragment_cache->add_fragment_handler( 'widget', 'Rarst\\Fragment_Cache\\Widget_Cache' ); |
|
42 | -$fragment_cache->add_fragment_handler( 'gallery', 'Rarst\\Fragment_Cache\\Gallery_Cache' ); |
|
40 | +$fragment_cache->add_fragment_handler('menu', 'Rarst\\Fragment_Cache\\Menu_Cache'); |
|
41 | +$fragment_cache->add_fragment_handler('widget', 'Rarst\\Fragment_Cache\\Widget_Cache'); |
|
42 | +$fragment_cache->add_fragment_handler('gallery', 'Rarst\\Fragment_Cache\\Gallery_Cache'); |
|
43 | 43 | |
44 | 44 | $fragment_cache->run(); |
@@ -17,11 +17,11 @@ discard block |
||
17 | 17 | |
18 | 18 | global $shortcode_tags; |
19 | 19 | |
20 | - if ( isset( $shortcode_tags['gallery'] ) ) { |
|
20 | + if (isset($shortcode_tags['gallery'])) { |
|
21 | 21 | $this->original_shortcode = $shortcode_tags['gallery']; |
22 | 22 | } |
23 | 23 | |
24 | - add_shortcode( 'gallery', array( $this, 'gallery_shortcode' ) ); |
|
24 | + add_shortcode('gallery', array($this, 'gallery_shortcode')); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function disable() { |
31 | 31 | |
32 | - if ( ! empty( $this->original_shortcode ) ) { |
|
33 | - add_shortcode( 'gallery', $this->original_shortcode ); |
|
32 | + if ( ! empty($this->original_shortcode)) { |
|
33 | + add_shortcode('gallery', $this->original_shortcode); |
|
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
@@ -41,18 +41,18 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return string |
43 | 43 | */ |
44 | - public function gallery_shortcode( $args ) { |
|
44 | + public function gallery_shortcode($args) { |
|
45 | 45 | |
46 | - if ( empty( $args ) ) { |
|
46 | + if (empty($args)) { |
|
47 | 47 | $args = array(); |
48 | 48 | } |
49 | 49 | |
50 | 50 | // Salt for cases post edited or attachments changed. |
51 | - $args['fc_post_modified'] = get_the_modified_time( 'U' ); |
|
51 | + $args['fc_post_modified'] = get_the_modified_time('U'); |
|
52 | 52 | $args['fc_post_attachments'] = $this->get_attachment_ids(); |
53 | 53 | |
54 | 54 | $post_id = get_the_ID(); |
55 | - $output = $this->fetch( 'post-' . $post_id, compact( 'args', 'post_id' ), $args ); |
|
55 | + $output = $this->fetch('post-' . $post_id, compact('args', 'post_id'), $args); |
|
56 | 56 | |
57 | 57 | return $output; |
58 | 58 | } |
@@ -68,17 +68,17 @@ discard block |
||
68 | 68 | |
69 | 69 | $post_id = get_the_ID(); |
70 | 70 | |
71 | - if ( ! isset( $attachments[ $post_id ] ) ) { |
|
71 | + if ( ! isset($attachments[$post_id])) { |
|
72 | 72 | |
73 | - $attachments[ $post_id ] = get_posts( array( |
|
73 | + $attachments[$post_id] = get_posts(array( |
|
74 | 74 | 'post_type' => 'attachment', |
75 | 75 | 'post_parent' => $post_id, |
76 | 76 | 'orderby' => 'ID', |
77 | 77 | 'fields' => 'ids', |
78 | - ) ); |
|
78 | + )); |
|
79 | 79 | } |
80 | 80 | |
81 | - return $attachments[ $post_id ]; |
|
81 | + return $attachments[$post_id]; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -89,14 +89,14 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @return string |
91 | 91 | */ |
92 | - protected function callback( $name, $args ) { |
|
92 | + protected function callback($name, $args) { |
|
93 | 93 | |
94 | 94 | global $post; |
95 | 95 | |
96 | - $post = get_post( $args['post_id'] ); |
|
97 | - setup_postdata( $post ); |
|
98 | - $shortcode = isset( $this->original_shortcode ) ? $this->original_shortcode : 'gallery_shortcode'; |
|
99 | - $output = call_user_func( $shortcode, $args['args'] ) . $this->get_comment( $name ); |
|
96 | + $post = get_post($args['post_id']); |
|
97 | + setup_postdata($post); |
|
98 | + $shortcode = isset($this->original_shortcode) ? $this->original_shortcode : 'gallery_shortcode'; |
|
99 | + $output = call_user_func($shortcode, $args['args']) . $this->get_comment($name); |
|
100 | 100 | wp_reset_postdata(); |
101 | 101 | |
102 | 102 | return $output; |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | */ |
13 | 13 | public function enable() { |
14 | 14 | |
15 | - if ( is_admin() ) { |
|
16 | - add_filter( 'widget_update_callback', array( $this, 'widget_update_callback' ) ); |
|
15 | + if (is_admin()) { |
|
16 | + add_filter('widget_update_callback', array($this, 'widget_update_callback')); |
|
17 | 17 | } else { |
18 | - add_filter( 'widget_display_callback', array( $this, 'widget_display_callback' ), 10, 3 ); |
|
18 | + add_filter('widget_display_callback', array($this, 'widget_display_callback'), 10, 3); |
|
19 | 19 | } |
20 | 20 | } |
21 | 21 | |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function disable() { |
26 | 26 | |
27 | - if ( is_admin() ) { |
|
28 | - remove_filter( 'widget_update_callback', array( $this, 'widget_update_callback' ) ); |
|
27 | + if (is_admin()) { |
|
28 | + remove_filter('widget_update_callback', array($this, 'widget_update_callback')); |
|
29 | 29 | } else { |
30 | - remove_filter( 'widget_display_callback', array( $this, 'widget_display_callback' ), 10 ); |
|
30 | + remove_filter('widget_display_callback', array($this, 'widget_display_callback'), 10); |
|
31 | 31 | } |
32 | 32 | } |
33 | 33 | |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @return array |
40 | 40 | */ |
41 | - public function widget_update_callback( $instance ) { |
|
41 | + public function widget_update_callback($instance) { |
|
42 | 42 | |
43 | - if ( is_array( $instance ) ) { |
|
43 | + if (is_array($instance)) { |
|
44 | 44 | $instance['fc_widget_edited'] = time(); |
45 | 45 | } |
46 | 46 | |
@@ -56,15 +56,15 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @return bool false |
58 | 58 | */ |
59 | - public function widget_display_callback( $instance, $widget, $args ) { |
|
59 | + public function widget_display_callback($instance, $widget, $args) { |
|
60 | 60 | |
61 | - $edited = isset( $instance['fc_widget_edited'] ) ? $instance['fc_widget_edited'] : ''; |
|
61 | + $edited = isset($instance['fc_widget_edited']) ? $instance['fc_widget_edited'] : ''; |
|
62 | 62 | |
63 | 63 | echo $this->fetch( |
64 | 64 | $widget->id, |
65 | 65 | array( |
66 | - 'callback' => array( $widget, 'widget' ), |
|
67 | - 'args' => array( $args, $instance ), |
|
66 | + 'callback' => array($widget, 'widget'), |
|
67 | + 'args' => array($args, $instance), |
|
68 | 68 | ), |
69 | 69 | $edited |
70 | 70 | ); |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return string |
82 | 82 | */ |
83 | - protected function callback( $name, $args ) { |
|
83 | + protected function callback($name, $args) { |
|
84 | 84 | |
85 | 85 | ob_start(); |
86 | - call_user_func_array( $args['callback'], $args['args'] ); |
|
86 | + call_user_func_array($args['callback'], $args['args']); |
|
87 | 87 | |
88 | - return ob_get_clean() . $this->get_comment( $name ); |
|
88 | + return ob_get_clean() . $this->get_comment($name); |
|
89 | 89 | } |
90 | 90 | } |
@@ -14,18 +14,18 @@ discard block |
||
14 | 14 | |
15 | 15 | global $wp_version; |
16 | 16 | |
17 | - if ( is_admin() ) { |
|
18 | - add_action( 'admin_footer-nav-menus.php', array( $this, 'update_menus_edited' ) ); |
|
19 | - add_action( 'wp_ajax_menu-locations-save', array( $this, 'update_menus_edited' ), 0 ); |
|
17 | + if (is_admin()) { |
|
18 | + add_action('admin_footer-nav-menus.php', array($this, 'update_menus_edited')); |
|
19 | + add_action('wp_ajax_menu-locations-save', array($this, 'update_menus_edited'), 0); |
|
20 | 20 | |
21 | 21 | return; |
22 | 22 | } |
23 | 23 | |
24 | - add_filter( 'pre_wp_nav_menu', array( $this, 'pre_wp_nav_menu' ), 10, 2 ); |
|
25 | - add_filter( 'wp_nav_menu_objects', array( $this, 'wp_nav_menu_objects' ) ); |
|
24 | + add_filter('pre_wp_nav_menu', array($this, 'pre_wp_nav_menu'), 10, 2); |
|
25 | + add_filter('wp_nav_menu_objects', array($this, 'wp_nav_menu_objects')); |
|
26 | 26 | |
27 | - if ( version_compare( $wp_version, '3.9', '<' ) ) { |
|
28 | - add_filter( 'wp_nav_menu_args', array( $this, 'wp_nav_menu_args' ), 20 ); |
|
27 | + if (version_compare($wp_version, '3.9', '<')) { |
|
28 | + add_filter('wp_nav_menu_args', array($this, 'wp_nav_menu_args'), 20); |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 | |
@@ -34,16 +34,16 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function disable() { |
36 | 36 | |
37 | - if ( is_admin() ) { |
|
38 | - remove_action( 'admin_footer-nav-menus.php', array( $this, 'update_menus_edited' ) ); |
|
39 | - remove_action( 'wp_ajax_menu-locations-save', array( $this, 'update_menus_edited' ), 0 ); |
|
37 | + if (is_admin()) { |
|
38 | + remove_action('admin_footer-nav-menus.php', array($this, 'update_menus_edited')); |
|
39 | + remove_action('wp_ajax_menu-locations-save', array($this, 'update_menus_edited'), 0); |
|
40 | 40 | |
41 | 41 | return; |
42 | 42 | } |
43 | 43 | |
44 | - remove_filter( 'pre_wp_nav_menu', array( $this, 'pre_wp_nav_menu' ), 10 ); |
|
45 | - remove_filter( 'wp_nav_menu_objects', array( $this, 'wp_nav_menu_objects' ) ); |
|
46 | - remove_filter( 'wp_nav_menu_args', array( $this, 'wp_nav_menu_args' ), 20 ); |
|
44 | + remove_filter('pre_wp_nav_menu', array($this, 'pre_wp_nav_menu'), 10); |
|
45 | + remove_filter('wp_nav_menu_objects', array($this, 'wp_nav_menu_objects')); |
|
46 | + remove_filter('wp_nav_menu_args', array($this, 'wp_nav_menu_args'), 20); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -54,18 +54,18 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return string |
56 | 56 | */ |
57 | - public function pre_wp_nav_menu( $menu, $args ) { |
|
57 | + public function pre_wp_nav_menu($menu, $args) { |
|
58 | 58 | |
59 | - $args = get_object_vars( $args ); |
|
59 | + $args = get_object_vars($args); |
|
60 | 60 | $args['echo'] = false; |
61 | - $args['fc_menus_edited'] = get_option( 'fc_menus_edited' ); |
|
62 | - $name = is_object( $args['menu'] ) ? $args['menu']->slug : $args['menu']; |
|
61 | + $args['fc_menus_edited'] = get_option('fc_menus_edited'); |
|
62 | + $name = is_object($args['menu']) ? $args['menu']->slug : $args['menu']; |
|
63 | 63 | |
64 | - if ( empty( $name ) && ! empty( $args['theme_location'] ) ) { |
|
64 | + if (empty($name) && ! empty($args['theme_location'])) { |
|
65 | 65 | $name = $args['theme_location']; |
66 | 66 | } |
67 | 67 | |
68 | - return $this->fetch( $name, $args, $args ); |
|
68 | + return $this->fetch($name, $args, $args); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -77,18 +77,18 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @return array |
79 | 79 | */ |
80 | - public function wp_nav_menu_args( $args ) { |
|
80 | + public function wp_nav_menu_args($args) { |
|
81 | 81 | |
82 | - _deprecated_function( __FUNCTION__, '1.3', 'Menu cache with arguments override unnecessary on WP >= 3.9.' ); |
|
82 | + _deprecated_function(__FUNCTION__, '1.3', 'Menu cache with arguments override unnecessary on WP >= 3.9.'); |
|
83 | 83 | |
84 | - if ( empty( $args['kessel_run'] ) ) { |
|
84 | + if (empty($args['kessel_run'])) { |
|
85 | 85 | |
86 | - add_filter( 'wp_get_nav_menus', '__return_empty_array' ); // These are not the droids you are looking for. |
|
86 | + add_filter('wp_get_nav_menus', '__return_empty_array'); // These are not the droids you are looking for. |
|
87 | 87 | |
88 | 88 | $args = array( |
89 | 89 | 'menu' => '', |
90 | 90 | 'theme_location' => '', |
91 | - 'fallback_cb' => array( $this, 'fallback_cb' ), |
|
91 | + 'fallback_cb' => array($this, 'fallback_cb'), |
|
92 | 92 | 'original_args' => $args, |
93 | 93 | ); |
94 | 94 | } |
@@ -103,12 +103,12 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @return array |
105 | 105 | */ |
106 | - public function wp_nav_menu_objects( $menu_items ) { |
|
106 | + public function wp_nav_menu_objects($menu_items) { |
|
107 | 107 | |
108 | - foreach ( $menu_items as $item_key => $item ) { |
|
109 | - foreach ( $item->classes as $class_key => $class ) { |
|
110 | - if ( 0 === stripos( $class, 'current' ) ) { |
|
111 | - unset( $menu_items[ $item_key ]->classes[ $class_key ] ); |
|
108 | + foreach ($menu_items as $item_key => $item) { |
|
109 | + foreach ($item->classes as $class_key => $class) { |
|
110 | + if (0 === stripos($class, 'current')) { |
|
111 | + unset($menu_items[$item_key]->classes[$class_key]); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | } |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function update_menus_edited() { |
123 | 123 | |
124 | - if ( ! empty( $_POST ) ) { |
|
125 | - update_option( 'fc_menus_edited', time() ); |
|
124 | + if ( ! empty($_POST)) { |
|
125 | + update_option('fc_menus_edited', time()); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
@@ -135,27 +135,27 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @return string |
137 | 137 | */ |
138 | - public function fallback_cb( $args ) { |
|
138 | + public function fallback_cb($args) { |
|
139 | 139 | |
140 | - _deprecated_function( __FUNCTION__, '1.3', 'Menu cache with arguments override unnecessary on WP >= 3.9.' ); |
|
140 | + _deprecated_function(__FUNCTION__, '1.3', 'Menu cache with arguments override unnecessary on WP >= 3.9.'); |
|
141 | 141 | |
142 | - remove_filter( 'wp_get_nav_menus', '__return_empty_array' ); |
|
142 | + remove_filter('wp_get_nav_menus', '__return_empty_array'); |
|
143 | 143 | |
144 | 144 | $args = $args['original_args']; |
145 | - unset( $args['original_args'] ); |
|
145 | + unset($args['original_args']); |
|
146 | 146 | $echo = $args['echo']; |
147 | 147 | $args['echo'] = false; |
148 | 148 | $args['kessel_run'] = true; |
149 | - $args['fc_menus_edited'] = get_option( 'fc_menus_edited' ); |
|
150 | - $name = is_object( $args['menu'] ) ? $args['menu']->slug : $args['menu']; |
|
149 | + $args['fc_menus_edited'] = get_option('fc_menus_edited'); |
|
150 | + $name = is_object($args['menu']) ? $args['menu']->slug : $args['menu']; |
|
151 | 151 | |
152 | - if ( empty( $name ) && ! empty( $args['theme_location'] ) ) { |
|
152 | + if (empty($name) && ! empty($args['theme_location'])) { |
|
153 | 153 | $name = $args['theme_location']; |
154 | 154 | } |
155 | 155 | |
156 | - $output = $this->fetch( $name, $args, $args ); |
|
156 | + $output = $this->fetch($name, $args, $args); |
|
157 | 157 | |
158 | - if ( $echo ) { |
|
158 | + if ($echo) { |
|
159 | 159 | echo $output; |
160 | 160 | } |
161 | 161 | |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @return string |
172 | 172 | */ |
173 | - protected function callback( $name, $args ) { |
|
173 | + protected function callback($name, $args) { |
|
174 | 174 | |
175 | - remove_filter( 'pre_wp_nav_menu', array( $this, 'pre_wp_nav_menu' ), 10 ); |
|
176 | - $output = wp_nav_menu( $args ) . $this->get_comment( $name ); |
|
177 | - add_filter( 'pre_wp_nav_menu', array( $this, 'pre_wp_nav_menu' ), 10, 2 ); |
|
175 | + remove_filter('pre_wp_nav_menu', array($this, 'pre_wp_nav_menu'), 10); |
|
176 | + $output = wp_nav_menu($args) . $this->get_comment($name); |
|
177 | + add_filter('pre_wp_nav_menu', array($this, 'pre_wp_nav_menu'), 10, 2); |
|
178 | 178 | |
179 | 179 | return $output; |
180 | 180 | } |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | */ |
18 | 18 | public function run() { |
19 | 19 | |
20 | - add_action( 'init', array( $this, 'init' ) ); |
|
21 | - add_filter( 'update_blocker_blocked', array( $this, 'update_blocker_blocked' ) ); |
|
20 | + add_action('init', array($this, 'init')); |
|
21 | + add_filter('update_blocker_blocked', array($this, 'update_blocker_blocked')); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -26,13 +26,13 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function init() { |
28 | 28 | |
29 | - foreach ( $this->handlers as $key => $type ) { |
|
30 | - if ( isset( $this[ $type ] ) ) { |
|
29 | + foreach ($this->handlers as $key => $type) { |
|
30 | + if (isset($this[$type])) { |
|
31 | 31 | /** @var Fragment_Cache $handler */ |
32 | - $handler = $this[ $type ]; |
|
32 | + $handler = $this[$type]; |
|
33 | 33 | $handler->enable(); |
34 | 34 | } else { |
35 | - unset( $this->handlers[ $key ] ); |
|
35 | + unset($this->handlers[$key]); |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | } |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return array |
46 | 46 | */ |
47 | - public function update_blocker_blocked( $blocked ) { |
|
47 | + public function update_blocker_blocked($blocked) { |
|
48 | 48 | |
49 | - $blocked['plugins'][] = plugin_basename( dirname( __DIR__ ) . '/fragment-cache.php' ); |
|
49 | + $blocked['plugins'][] = plugin_basename(dirname(__DIR__) . '/fragment-cache.php'); |
|
50 | 50 | |
51 | 51 | return $blocked; |
52 | 52 | } |
@@ -57,20 +57,20 @@ discard block |
||
57 | 57 | * @param string $type Handler type name. |
58 | 58 | * @param string $class_name Handler class name to instance. |
59 | 59 | */ |
60 | - public function add_fragment_handler( $type, $class_name ) { |
|
60 | + public function add_fragment_handler($type, $class_name) { |
|
61 | 61 | |
62 | - if ( isset( $this[ $type ] ) ) { |
|
62 | + if (isset($this[$type])) { |
|
63 | 63 | /** @var Fragment_Cache $handler */ |
64 | - $handler = $this[ $type ]; |
|
64 | + $handler = $this[$type]; |
|
65 | 65 | $handler->disable(); |
66 | - unset( $this[ $type ] ); |
|
66 | + unset($this[$type]); |
|
67 | 67 | } |
68 | 68 | |
69 | - $this[ $type ] = function ( $plugin ) use ( $type, $class_name ) { |
|
70 | - return new $class_name( array( 'type' => $type, 'timeout' => $plugin['timeout'] ) ); |
|
69 | + $this[$type] = function($plugin) use ($type, $class_name) { |
|
70 | + return new $class_name(array('type' => $type, 'timeout' => $plugin['timeout'])); |
|
71 | 71 | }; |
72 | 72 | |
73 | - if ( ! in_array( $type, $this->handlers, true ) ) { |
|
73 | + if ( ! in_array($type, $this->handlers, true)) { |
|
74 | 74 | $this->handlers[] = $type; |
75 | 75 | } |
76 | 76 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param array $args Configuration arguments. |
23 | 23 | */ |
24 | - public function __construct( $args ) { |
|
24 | + public function __construct($args) { |
|
25 | 25 | |
26 | 26 | $this->type = $args['type']; |
27 | 27 | $this->timeout = $args['timeout']; |
@@ -46,34 +46,34 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return mixed |
48 | 48 | */ |
49 | - public function fetch( $name, $args, $salt = '' ) { |
|
49 | + public function fetch($name, $args, $salt = '') { |
|
50 | 50 | |
51 | 51 | global $current_user; |
52 | 52 | |
53 | 53 | static $empty_user; |
54 | 54 | |
55 | - if ( self::$in_callback || apply_filters( 'fc_skip_cache', false, $this->type, $name, $args, $salt ) ) { |
|
56 | - return $this->callback( $name, $args ); |
|
55 | + if (self::$in_callback || apply_filters('fc_skip_cache', false, $this->type, $name, $args, $salt)) { |
|
56 | + return $this->callback($name, $args); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | // Anonymize front-end run for consistency. |
60 | - if ( is_user_logged_in() ) { |
|
60 | + if (is_user_logged_in()) { |
|
61 | 61 | |
62 | - if ( empty( $empty_user ) ) { |
|
63 | - $empty_user = new \WP_User( 0 ); |
|
62 | + if (empty($empty_user)) { |
|
63 | + $empty_user = new \WP_User(0); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | $stored_user = $current_user; |
67 | 67 | $current_user = $empty_user; |
68 | 68 | } |
69 | 69 | |
70 | - $salt = maybe_serialize( $salt ); |
|
71 | - $output = tlc_transient( 'fragment-cache-' . $this->type . '-' . $name . $salt ) |
|
72 | - ->updates_with( array( $this, 'wrap_callback' ), array( $name, $args ) ) |
|
73 | - ->expires_in( $this->timeout ) |
|
70 | + $salt = maybe_serialize($salt); |
|
71 | + $output = tlc_transient('fragment-cache-' . $this->type . '-' . $name . $salt) |
|
72 | + ->updates_with(array($this, 'wrap_callback'), array($name, $args)) |
|
73 | + ->expires_in($this->timeout) |
|
74 | 74 | ->get(); |
75 | 75 | |
76 | - if ( ! empty( $stored_user ) ) { |
|
76 | + if ( ! empty($stored_user)) { |
|
77 | 77 | $current_user = $stored_user; |
78 | 78 | } |
79 | 79 | |
@@ -88,10 +88,10 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return string |
90 | 90 | */ |
91 | - public function wrap_callback( $name, $args ) { |
|
91 | + public function wrap_callback($name, $args) { |
|
92 | 92 | |
93 | 93 | self::$in_callback = true; |
94 | - $output = $this->callback( $name, $args ); |
|
94 | + $output = $this->callback($name, $args); |
|
95 | 95 | self::$in_callback = false; |
96 | 96 | |
97 | 97 | return $output; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return string |
107 | 107 | */ |
108 | - abstract protected function callback( $name, $args ); |
|
108 | + abstract protected function callback($name, $args); |
|
109 | 109 | |
110 | 110 | /** |
111 | 111 | * Get human-readable HTML comment with timestamp to append to cached fragment. |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @return string |
116 | 116 | */ |
117 | - public function get_comment( $name ) { |
|
117 | + public function get_comment($name) { |
|
118 | 118 | |
119 | - return '<!-- ' . esc_html( $name ) . ' ' . esc_html( $this->type ) . ' cached on ' . date_i18n( DATE_RSS ) . ' -->'; |
|
119 | + return '<!-- ' . esc_html($name) . ' ' . esc_html($this->type) . ' cached on ' . date_i18n(DATE_RSS) . ' -->'; |
|
120 | 120 | } |
121 | 121 | } |