@@ -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; |
@@ -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 | } |
@@ -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 | /** |
@@ -27,20 +27,20 @@ discard block |
||
27 | 27 | public function init() { |
28 | 28 | |
29 | 29 | if ( |
30 | - 'on' === filter_input( INPUT_POST, 'wp_customize' ) |
|
31 | - && empty( filter_input( INPUT_POST, 'action' ) ) |
|
32 | - && current_user_can( 'customize' ) |
|
30 | + 'on' === filter_input(INPUT_POST, 'wp_customize') |
|
31 | + && empty(filter_input(INPUT_POST, 'action')) |
|
32 | + && current_user_can('customize') |
|
33 | 33 | ) { |
34 | 34 | return; // We don’t want cache running in Customizer previews. |
35 | 35 | } |
36 | 36 | |
37 | - foreach ( $this->handlers as $key => $type ) { |
|
38 | - if ( isset( $this[ $type ] ) ) { |
|
37 | + foreach ($this->handlers as $key => $type) { |
|
38 | + if (isset($this[$type])) { |
|
39 | 39 | /** @var Fragment_Cache $handler */ |
40 | - $handler = $this[ $type ]; |
|
40 | + $handler = $this[$type]; |
|
41 | 41 | $handler->enable(); |
42 | 42 | } else { |
43 | - unset( $this->handlers[ $key ] ); |
|
43 | + unset($this->handlers[$key]); |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | } |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return array |
54 | 54 | */ |
55 | - public function update_blocker_blocked( $blocked ) { |
|
55 | + public function update_blocker_blocked($blocked) { |
|
56 | 56 | |
57 | - $blocked['plugins'][] = plugin_basename( dirname( __DIR__ ) . '/fragment-cache.php' ); |
|
57 | + $blocked['plugins'][] = plugin_basename(dirname(__DIR__) . '/fragment-cache.php'); |
|
58 | 58 | |
59 | 59 | return $blocked; |
60 | 60 | } |
@@ -65,20 +65,20 @@ discard block |
||
65 | 65 | * @param string $type Handler type name. |
66 | 66 | * @param string $class_name Handler class name to instance. |
67 | 67 | */ |
68 | - public function add_fragment_handler( $type, $class_name ) { |
|
68 | + public function add_fragment_handler($type, $class_name) { |
|
69 | 69 | |
70 | - if ( isset( $this[ $type ] ) ) { |
|
70 | + if (isset($this[$type])) { |
|
71 | 71 | /** @var Fragment_Cache $handler */ |
72 | - $handler = $this[ $type ]; |
|
72 | + $handler = $this[$type]; |
|
73 | 73 | $handler->disable(); |
74 | - unset( $this[ $type ] ); |
|
74 | + unset($this[$type]); |
|
75 | 75 | } |
76 | 76 | |
77 | - $this[ $type ] = function ( $plugin ) use ( $type, $class_name ) { |
|
78 | - return new $class_name( array( 'type' => $type, 'timeout' => $plugin['timeout'] ) ); |
|
77 | + $this[$type] = function($plugin) use ($type, $class_name) { |
|
78 | + return new $class_name(array('type' => $type, 'timeout' => $plugin['timeout'])); |
|
79 | 79 | }; |
80 | 80 | |
81 | - if ( ! in_array( $type, $this->handlers, true ) ) { |
|
81 | + if ( ! in_array($type, $this->handlers, true)) { |
|
82 | 82 | $this->handlers[] = $type; |
83 | 83 | } |
84 | 84 | } |
@@ -14,19 +14,19 @@ 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 ); |
|
20 | - add_action( 'wp_ajax_customize_save', array( $this, 'customize_save' ), 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 | + add_action('wp_ajax_customize_save', array($this, 'customize_save'), 0); |
|
21 | 21 | |
22 | 22 | return; |
23 | 23 | } |
24 | 24 | |
25 | - add_filter( 'pre_wp_nav_menu', array( $this, 'pre_wp_nav_menu' ), 10, 2 ); |
|
26 | - add_filter( 'wp_nav_menu_objects', array( $this, 'wp_nav_menu_objects' ) ); |
|
25 | + add_filter('pre_wp_nav_menu', array($this, 'pre_wp_nav_menu'), 10, 2); |
|
26 | + add_filter('wp_nav_menu_objects', array($this, 'wp_nav_menu_objects')); |
|
27 | 27 | |
28 | - if ( version_compare( $wp_version, '3.9', '<' ) ) { |
|
29 | - add_filter( 'wp_nav_menu_args', array( $this, 'wp_nav_menu_args' ), 20 ); |
|
28 | + if (version_compare($wp_version, '3.9', '<')) { |
|
29 | + add_filter('wp_nav_menu_args', array($this, 'wp_nav_menu_args'), 20); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | |
@@ -35,17 +35,17 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function disable() { |
37 | 37 | |
38 | - if ( is_admin() ) { |
|
39 | - remove_action( 'admin_footer-nav-menus.php', array( $this, 'update_menus_edited' ) ); |
|
40 | - remove_action( 'wp_ajax_menu-locations-save', array( $this, 'update_menus_edited' ), 0 ); |
|
41 | - remove_action( 'wp_ajax_customize_save', array( $this, 'customize_save' ), 0 ); |
|
38 | + if (is_admin()) { |
|
39 | + remove_action('admin_footer-nav-menus.php', array($this, 'update_menus_edited')); |
|
40 | + remove_action('wp_ajax_menu-locations-save', array($this, 'update_menus_edited'), 0); |
|
41 | + remove_action('wp_ajax_customize_save', array($this, 'customize_save'), 0); |
|
42 | 42 | |
43 | 43 | return; |
44 | 44 | } |
45 | 45 | |
46 | - remove_filter( 'pre_wp_nav_menu', array( $this, 'pre_wp_nav_menu' ), 10 ); |
|
47 | - remove_filter( 'wp_nav_menu_objects', array( $this, 'wp_nav_menu_objects' ) ); |
|
48 | - remove_filter( 'wp_nav_menu_args', array( $this, 'wp_nav_menu_args' ), 20 ); |
|
46 | + remove_filter('pre_wp_nav_menu', array($this, 'pre_wp_nav_menu'), 10); |
|
47 | + remove_filter('wp_nav_menu_objects', array($this, 'wp_nav_menu_objects')); |
|
48 | + remove_filter('wp_nav_menu_args', array($this, 'wp_nav_menu_args'), 20); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -56,18 +56,18 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @return string |
58 | 58 | */ |
59 | - public function pre_wp_nav_menu( $menu, $args ) { |
|
59 | + public function pre_wp_nav_menu($menu, $args) { |
|
60 | 60 | |
61 | - $args = get_object_vars( $args ); |
|
61 | + $args = get_object_vars($args); |
|
62 | 62 | $args['echo'] = false; |
63 | - $args['fc_menus_edited'] = get_option( 'fc_menus_edited' ); |
|
64 | - $name = is_object( $args['menu'] ) ? $args['menu']->slug : $args['menu']; |
|
63 | + $args['fc_menus_edited'] = get_option('fc_menus_edited'); |
|
64 | + $name = is_object($args['menu']) ? $args['menu']->slug : $args['menu']; |
|
65 | 65 | |
66 | - if ( empty( $name ) && ! empty( $args['theme_location'] ) ) { |
|
66 | + if (empty($name) && ! empty($args['theme_location'])) { |
|
67 | 67 | $name = $args['theme_location']; |
68 | 68 | } |
69 | 69 | |
70 | - return $this->fetch( $name, $args, $args ); |
|
70 | + return $this->fetch($name, $args, $args); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -79,18 +79,18 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @return array |
81 | 81 | */ |
82 | - public function wp_nav_menu_args( $args ) { |
|
82 | + public function wp_nav_menu_args($args) { |
|
83 | 83 | |
84 | - _deprecated_function( __FUNCTION__, '1.3', 'Menu cache with arguments override unnecessary on WP >= 3.9.' ); |
|
84 | + _deprecated_function(__FUNCTION__, '1.3', 'Menu cache with arguments override unnecessary on WP >= 3.9.'); |
|
85 | 85 | |
86 | - if ( empty( $args['kessel_run'] ) ) { |
|
86 | + if (empty($args['kessel_run'])) { |
|
87 | 87 | |
88 | - add_filter( 'wp_get_nav_menus', '__return_empty_array' ); // These are not the droids you are looking for. |
|
88 | + add_filter('wp_get_nav_menus', '__return_empty_array'); // These are not the droids you are looking for. |
|
89 | 89 | |
90 | 90 | $args = array( |
91 | 91 | 'menu' => '', |
92 | 92 | 'theme_location' => '', |
93 | - 'fallback_cb' => array( $this, 'fallback_cb' ), |
|
93 | + 'fallback_cb' => array($this, 'fallback_cb'), |
|
94 | 94 | 'original_args' => $args, |
95 | 95 | ); |
96 | 96 | } |
@@ -105,12 +105,12 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return array |
107 | 107 | */ |
108 | - public function wp_nav_menu_objects( $menu_items ) { |
|
108 | + public function wp_nav_menu_objects($menu_items) { |
|
109 | 109 | |
110 | - foreach ( $menu_items as $item_key => $item ) { |
|
111 | - foreach ( $item->classes as $class_key => $class ) { |
|
112 | - if ( 0 === stripos( $class, 'current' ) ) { |
|
113 | - unset( $menu_items[ $item_key ]->classes[ $class_key ] ); |
|
110 | + foreach ($menu_items as $item_key => $item) { |
|
111 | + foreach ($item->classes as $class_key => $class) { |
|
112 | + if (0 === stripos($class, 'current')) { |
|
113 | + unset($menu_items[$item_key]->classes[$class_key]); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | } |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public function update_menus_edited() { |
125 | 125 | |
126 | - if ( ! empty( $_POST ) ) { |
|
127 | - update_option( 'fc_menus_edited', time() ); |
|
126 | + if ( ! empty($_POST)) { |
|
127 | + update_option('fc_menus_edited', time()); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
@@ -133,20 +133,20 @@ discard block |
||
133 | 133 | */ |
134 | 134 | public function customize_save() { |
135 | 135 | |
136 | - $customized = filter_input( INPUT_POST, 'customized' ); |
|
136 | + $customized = filter_input(INPUT_POST, 'customized'); |
|
137 | 137 | |
138 | - if ( empty( $customized ) ) { |
|
138 | + if (empty($customized)) { |
|
139 | 139 | return; |
140 | 140 | } |
141 | 141 | |
142 | - $customized = json_decode( $customized, true ); |
|
143 | - $settings = array_keys( $customized ); |
|
142 | + $customized = json_decode($customized, true); |
|
143 | + $settings = array_keys($customized); |
|
144 | 144 | |
145 | - foreach ( $settings as $setting ) { |
|
145 | + foreach ($settings as $setting) { |
|
146 | 146 | |
147 | - if ( 0 === stripos( $setting, 'nav_menu' ) ) { |
|
147 | + if (0 === stripos($setting, 'nav_menu')) { |
|
148 | 148 | |
149 | - update_option( 'fc_menus_edited', time() ); |
|
149 | + update_option('fc_menus_edited', time()); |
|
150 | 150 | |
151 | 151 | return; |
152 | 152 | } |
@@ -162,27 +162,27 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @return string |
164 | 164 | */ |
165 | - public function fallback_cb( $args ) { |
|
165 | + public function fallback_cb($args) { |
|
166 | 166 | |
167 | - _deprecated_function( __FUNCTION__, '1.3', 'Menu cache with arguments override unnecessary on WP >= 3.9.' ); |
|
167 | + _deprecated_function(__FUNCTION__, '1.3', 'Menu cache with arguments override unnecessary on WP >= 3.9.'); |
|
168 | 168 | |
169 | - remove_filter( 'wp_get_nav_menus', '__return_empty_array' ); |
|
169 | + remove_filter('wp_get_nav_menus', '__return_empty_array'); |
|
170 | 170 | |
171 | 171 | $args = $args['original_args']; |
172 | - unset( $args['original_args'] ); |
|
172 | + unset($args['original_args']); |
|
173 | 173 | $echo = $args['echo']; |
174 | 174 | $args['echo'] = false; |
175 | 175 | $args['kessel_run'] = true; |
176 | - $args['fc_menus_edited'] = get_option( 'fc_menus_edited' ); |
|
177 | - $name = is_object( $args['menu'] ) ? $args['menu']->slug : $args['menu']; |
|
176 | + $args['fc_menus_edited'] = get_option('fc_menus_edited'); |
|
177 | + $name = is_object($args['menu']) ? $args['menu']->slug : $args['menu']; |
|
178 | 178 | |
179 | - if ( empty( $name ) && ! empty( $args['theme_location'] ) ) { |
|
179 | + if (empty($name) && ! empty($args['theme_location'])) { |
|
180 | 180 | $name = $args['theme_location']; |
181 | 181 | } |
182 | 182 | |
183 | - $output = $this->fetch( $name, $args, $args ); |
|
183 | + $output = $this->fetch($name, $args, $args); |
|
184 | 184 | |
185 | - if ( $echo ) { |
|
185 | + if ($echo) { |
|
186 | 186 | echo $output; |
187 | 187 | } |
188 | 188 | |
@@ -197,11 +197,11 @@ discard block |
||
197 | 197 | * |
198 | 198 | * @return string |
199 | 199 | */ |
200 | - protected function callback( $name, $args ) { |
|
200 | + protected function callback($name, $args) { |
|
201 | 201 | |
202 | - remove_filter( 'pre_wp_nav_menu', array( $this, 'pre_wp_nav_menu' ), 10 ); |
|
203 | - $output = wp_nav_menu( $args ) . $this->get_comment( $name ); |
|
204 | - add_filter( 'pre_wp_nav_menu', array( $this, 'pre_wp_nav_menu' ), 10, 2 ); |
|
202 | + remove_filter('pre_wp_nav_menu', array($this, 'pre_wp_nav_menu'), 10); |
|
203 | + $output = wp_nav_menu($args) . $this->get_comment($name); |
|
204 | + add_filter('pre_wp_nav_menu', array($this, 'pre_wp_nav_menu'), 10, 2); |
|
205 | 205 | |
206 | 206 | return $output; |
207 | 207 | } |
@@ -12,11 +12,11 @@ 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' ) ); |
|
17 | - add_action( 'wp_ajax_update-widget', array( $this, 'update_widget' ), 0 ); |
|
15 | + if (is_admin()) { |
|
16 | + add_filter('widget_update_callback', array($this, 'widget_update_callback')); |
|
17 | + add_action('wp_ajax_update-widget', array($this, 'update_widget'), 0); |
|
18 | 18 | } else { |
19 | - add_filter( 'widget_display_callback', array( $this, 'widget_display_callback' ), 10, 3 ); |
|
19 | + add_filter('widget_display_callback', array($this, 'widget_display_callback'), 10, 3); |
|
20 | 20 | } |
21 | 21 | } |
22 | 22 | |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function disable() { |
27 | 27 | |
28 | - if ( is_admin() ) { |
|
29 | - remove_filter( 'widget_update_callback', array( $this, 'widget_update_callback' ) ); |
|
30 | - remove_action( 'wp_ajax_update-widget', array( $this, 'update_widget' ), 0 ); |
|
28 | + if (is_admin()) { |
|
29 | + remove_filter('widget_update_callback', array($this, 'widget_update_callback')); |
|
30 | + remove_action('wp_ajax_update-widget', array($this, 'update_widget'), 0); |
|
31 | 31 | } else { |
32 | - remove_filter( 'widget_display_callback', array( $this, 'widget_display_callback' ), 10 ); |
|
32 | + remove_filter('widget_display_callback', array($this, 'widget_display_callback'), 10); |
|
33 | 33 | } |
34 | 34 | } |
35 | 35 | |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return array |
42 | 42 | */ |
43 | - public function widget_update_callback( $instance ) { |
|
43 | + public function widget_update_callback($instance) { |
|
44 | 44 | |
45 | - if ( is_array( $instance ) ) { |
|
45 | + if (is_array($instance)) { |
|
46 | 46 | $instance['fc_widget_edited'] = time(); |
47 | 47 | } |
48 | 48 | |
@@ -54,34 +54,34 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function update_widget() { |
56 | 56 | |
57 | - $customized = filter_input( INPUT_POST, 'customized' ); |
|
57 | + $customized = filter_input(INPUT_POST, 'customized'); |
|
58 | 58 | |
59 | - if ( empty( $customized ) ) { |
|
59 | + if (empty($customized)) { |
|
60 | 60 | return; |
61 | 61 | } |
62 | 62 | |
63 | - $customized = json_decode( $customized, true ); |
|
63 | + $customized = json_decode($customized, true); |
|
64 | 64 | $changed = false; |
65 | 65 | |
66 | - foreach ( $customized as $key => $data ) { |
|
66 | + foreach ($customized as $key => $data) { |
|
67 | 67 | |
68 | - if ( ! isset( $data['encoded_serialized_instance'] ) || 0 !== stripos( $key, 'widget' ) ) { |
|
68 | + if ( ! isset($data['encoded_serialized_instance']) || 0 !== stripos($key, 'widget')) { |
|
69 | 69 | continue; |
70 | 70 | } |
71 | 71 | |
72 | - $instance = unserialize( base64_decode( $data['encoded_serialized_instance'] ) ); |
|
72 | + $instance = unserialize(base64_decode($data['encoded_serialized_instance'])); |
|
73 | 73 | $instance['fc_widget_edited'] = time(); |
74 | - $instance = base64_encode( serialize( $instance ) ); |
|
74 | + $instance = base64_encode(serialize($instance)); |
|
75 | 75 | |
76 | 76 | $data['encoded_serialized_instance'] = $instance; |
77 | - $data['instance_hash_key'] = wp_hash( $instance ); |
|
78 | - $customized[ $key ] = $data; |
|
77 | + $data['instance_hash_key'] = wp_hash($instance); |
|
78 | + $customized[$key] = $data; |
|
79 | 79 | |
80 | 80 | $changed = true; |
81 | 81 | } |
82 | 82 | |
83 | - if ( $changed ) { |
|
84 | - $_POST['customized'] = wp_json_encode( $customized ); |
|
83 | + if ($changed) { |
|
84 | + $_POST['customized'] = wp_json_encode($customized); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
@@ -94,15 +94,15 @@ discard block |
||
94 | 94 | * |
95 | 95 | * @return bool false |
96 | 96 | */ |
97 | - public function widget_display_callback( $instance, $widget, $args ) { |
|
97 | + public function widget_display_callback($instance, $widget, $args) { |
|
98 | 98 | |
99 | - $edited = isset( $instance['fc_widget_edited'] ) ? $instance['fc_widget_edited'] : ''; |
|
99 | + $edited = isset($instance['fc_widget_edited']) ? $instance['fc_widget_edited'] : ''; |
|
100 | 100 | |
101 | 101 | echo $this->fetch( |
102 | 102 | $widget->id, |
103 | 103 | array( |
104 | - 'callback' => array( $widget, 'widget' ), |
|
105 | - 'args' => array( $args, $instance ), |
|
104 | + 'callback' => array($widget, 'widget'), |
|
105 | + 'args' => array($args, $instance), |
|
106 | 106 | ), |
107 | 107 | $edited |
108 | 108 | ); |
@@ -118,11 +118,11 @@ discard block |
||
118 | 118 | * |
119 | 119 | * @return string |
120 | 120 | */ |
121 | - protected function callback( $name, $args ) { |
|
121 | + protected function callback($name, $args) { |
|
122 | 122 | |
123 | 123 | ob_start(); |
124 | - call_user_func_array( $args['callback'], $args['args'] ); |
|
124 | + call_user_func_array($args['callback'], $args['args']); |
|
125 | 125 | |
126 | - return ob_get_clean() . $this->get_comment( $name ); |
|
126 | + return ob_get_clean() . $this->get_comment($name); |
|
127 | 127 | } |
128 | 128 | } |