@@ -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 | } |