Cachify - Version 2.2.0

Version Description

  • Werkzeugleiste: Anzeige des "Cache leeren" Buttons im Frontend der Website
  • Werkzeugleiste: Steuerung der Anzeige des "Cache leeren" Buttons via Hook
Download this release

Release Info

Developer sergej.mueller
Plugin Icon 128x128 Cachify
Version 2.2.0
Comparing to
See all releases

Code changes from version 2.1.9 to 2.2.0

Files changed (3) hide show
  1. cachify.php +1 -1
  2. inc/cachify.class.php +100 -68
  3. readme.txt +5 -1
cachify.php CHANGED
@@ -8,7 +8,7 @@ Author: Sergej Müller
8
  Author URI: http://wpcoder.de
9
  Plugin URI: http://cachify.de
10
  License: GPLv2 or later
11
- Version: 2.1.9
12
  */
13
 
14
  /*
8
  Author URI: http://wpcoder.de
9
  Plugin URI: http://cachify.de
10
  License: GPLv2 or later
11
+ Version: 2.2.0
12
  */
13
 
14
  /*
inc/cachify.class.php CHANGED
@@ -74,7 +74,7 @@ final class Cachify {
74
  * Konstruktor der Klasse
75
  *
76
  * @since 1.0.0
77
- * @change 2.1.7
78
  *
79
  * @param void
80
  * @return void
@@ -125,6 +125,23 @@ final class Cachify {
125
  )
126
  );
127
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  /* Backend */
129
  if ( is_admin() ) {
130
  add_action(
@@ -156,13 +173,7 @@ final class Cachify {
156
  'register_settings'
157
  )
158
  );
159
- add_action(
160
- 'admin_init',
161
- array(
162
- __CLASS__,
163
- 'process_flush_request'
164
- )
165
- );
166
  add_action(
167
  'admin_menu',
168
  array(
@@ -194,14 +205,7 @@ final class Cachify {
194
  'edit_comment'
195
  )
196
  );
197
- add_action(
198
- 'admin_bar_menu',
199
- array(
200
- __CLASS__,
201
- 'add_flush_icon'
202
- ),
203
- 90
204
- );
205
  add_action(
206
  'dashboard_glance_items',
207
  array(
@@ -596,38 +600,6 @@ final class Cachify {
596
  }
597
 
598
 
599
- /**
600
- * Hinzufügen eines Admin-Bar-Menüs
601
- *
602
- * @since 1.2
603
- * @change 2.1.5
604
- *
605
- * @param object Objekt mit Menü-Eigenschaften
606
- */
607
-
608
- public static function add_flush_icon($wp_admin_bar)
609
- {
610
- /* Aussteigen */
611
- if ( ! is_admin_bar_showing() OR ! is_super_admin() ) {
612
- return;
613
- }
614
-
615
- /* Display the admin icon anytime */
616
- echo '<style>#wp-admin-bar-cachify{display:list-item !important} .ab-icon{margin:0 !important} .ab-icon:before{content:"\f182";top:2px;margin:0}</style>';
617
-
618
- /* Hinzufügen */
619
- $wp_admin_bar->add_menu(
620
- array(
621
- 'id' => 'cachify',
622
- 'href' => add_query_arg('_cachify', 'flush'),
623
- 'parent' => 'top-secondary',
624
- 'title' => '<span class="ab-icon dashicons"></span>',
625
- 'meta' => array( 'title' => __('Flush the cachify cache', 'cachify') )
626
- )
627
- );
628
- }
629
-
630
-
631
  /**
632
  * Anzeige des Spam-Counters auf dem Dashboard
633
  *
@@ -701,29 +673,72 @@ final class Cachify {
701
  }
702
 
703
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
704
  /**
705
  * Verarbeitung der Plugin-Meta-Aktionen
706
  *
707
  * @since 0.5
708
- * @change 2.1.3
 
 
709
  *
710
  * @param array $data Metadaten der Plugins
711
  */
712
 
713
  public static function process_flush_request($data)
714
  {
715
- /* Leer? */
716
- if ( empty($_GET['_cachify']) OR $_GET['_cachify'] !== 'flush' OR ! is_super_admin() ) {
717
  return;
718
  }
719
 
720
- /* Global */
721
- global $wpdb;
 
 
 
 
 
 
 
722
 
723
  /* Multisite & Network */
724
  if ( is_multisite() && is_plugin_active_for_network(CACHIFY_BASE) ) {
725
  /* Alter Blog */
726
- $old = $wpdb->blogid;
727
 
728
  /* Blog-IDs */
729
  $ids = self::_get_blog_ids();
@@ -738,25 +753,40 @@ final class Cachify {
738
  switch_to_blog($old);
739
 
740
  /* Notiz */
741
- add_action(
742
- 'network_admin_notices',
743
- array(
744
- __CLASS__,
745
- 'flush_notice'
746
- )
747
- );
 
 
748
  } else {
749
  /* Leeren */
750
  self::flush_total_cache();
751
 
752
  /* Notiz */
753
- add_action(
754
- 'admin_notices',
755
- array(
756
- __CLASS__,
757
- 'flush_notice'
 
 
 
 
 
 
 
 
 
 
 
758
  )
759
  );
 
 
760
  }
761
  }
762
 
@@ -765,13 +795,15 @@ final class Cachify {
765
  * Hinweis nach erfolgreichem Cache-Leeren
766
  *
767
  * @since 1.2
768
- * @change 2.1.3
 
 
769
  */
770
 
771
  public static function flush_notice()
772
  {
773
  /* Kein Admin */
774
- if ( ! is_super_admin() ) {
775
  return false;
776
  }
777
 
74
  * Konstruktor der Klasse
75
  *
76
  * @since 1.0.0
77
+ * @change 2.2.0
78
  *
79
  * @param void
80
  * @return void
125
  )
126
  );
127
 
128
+ /* Flush icon */
129
+ add_action(
130
+ 'admin_bar_menu',
131
+ array(
132
+ __CLASS__,
133
+ 'add_flush_icon'
134
+ ),
135
+ 90
136
+ );
137
+ add_action(
138
+ 'init',
139
+ array(
140
+ __CLASS__,
141
+ 'process_flush_request'
142
+ )
143
+ );
144
+
145
  /* Backend */
146
  if ( is_admin() ) {
147
  add_action(
173
  'register_settings'
174
  )
175
  );
176
+
 
 
 
 
 
 
177
  add_action(
178
  'admin_menu',
179
  array(
205
  'edit_comment'
206
  )
207
  );
208
+
 
 
 
 
 
 
 
209
  add_action(
210
  'dashboard_glance_items',
211
  array(
600
  }
601
 
602
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
603
  /**
604
  * Anzeige des Spam-Counters auf dem Dashboard
605
  *
673
  }
674
 
675
 
676
+ /**
677
+ * Hinzufügen eines Admin-Bar-Menüs
678
+ *
679
+ * @since 1.2
680
+ * @change 2.2.0
681
+ *
682
+ * @hook mixed cachify_user_can_flush_cache
683
+ *
684
+ * @param object Objekt mit Menü-Eigenschaften
685
+ */
686
+
687
+ public static function add_flush_icon($wp_admin_bar)
688
+ {
689
+ /* Aussteigen */
690
+ if ( ! is_admin_bar_showing() OR ! apply_filters('cachify_user_can_flush_cache', current_user_can('manage_options')) ) {
691
+ return;
692
+ }
693
+
694
+ /* Display the admin icon anytime */
695
+ echo '<style>#wp-admin-bar-cachify{display:list-item !important} .ab-icon{margin:0 !important} .ab-icon:before{content:"\f182";top:2px;margin:0}</style>';
696
+
697
+ /* Hinzufügen */
698
+ $wp_admin_bar->add_menu(
699
+ array(
700
+ 'id' => 'cachify',
701
+ 'href' => wp_nonce_url( add_query_arg('_cachify', 'flush'), '_cachify_flush_nonce'),
702
+ 'parent' => 'top-secondary',
703
+ 'title' => '<span class="ab-icon dashicons"></span>',
704
+ 'meta' => array( 'title' => __('Flush the cachify cache', 'cachify') )
705
+ )
706
+ );
707
+ }
708
+
709
+
710
  /**
711
  * Verarbeitung der Plugin-Meta-Aktionen
712
  *
713
  * @since 0.5
714
+ * @change 2.2.0
715
+ *
716
+ * @hook mixed cachify_user_can_flush_cache
717
  *
718
  * @param array $data Metadaten der Plugins
719
  */
720
 
721
  public static function process_flush_request($data)
722
  {
723
+ /* Skip if not a flush request */
724
+ if ( empty($_GET['_cachify']) OR $_GET['_cachify'] !== 'flush' ) {
725
  return;
726
  }
727
 
728
+ /* Check nonce */
729
+ if ( empty($_GET['_wpnonce']) OR ! wp_verify_nonce($_GET['_wpnonce'], '_cachify_flush_nonce') ) {
730
+ return;
731
+ }
732
+
733
+ /* Skip if not necessary */
734
+ if ( ! is_admin_bar_showing() OR ! apply_filters('cachify_user_can_flush_cache', current_user_can('manage_options')) ) {
735
+ return;
736
+ }
737
 
738
  /* Multisite & Network */
739
  if ( is_multisite() && is_plugin_active_for_network(CACHIFY_BASE) ) {
740
  /* Alter Blog */
741
+ $old = $GLOBALS['wpdb']->blogid;
742
 
743
  /* Blog-IDs */
744
  $ids = self::_get_blog_ids();
753
  switch_to_blog($old);
754
 
755
  /* Notiz */
756
+ if ( is_admin() ) {
757
+ add_action(
758
+ 'network_admin_notices',
759
+ array(
760
+ __CLASS__,
761
+ 'flush_notice'
762
+ )
763
+ );
764
+ }
765
  } else {
766
  /* Leeren */
767
  self::flush_total_cache();
768
 
769
  /* Notiz */
770
+ if ( is_admin() ) {
771
+ add_action(
772
+ 'admin_notices',
773
+ array(
774
+ __CLASS__,
775
+ 'flush_notice'
776
+ )
777
+ );
778
+ }
779
+ }
780
+
781
+ if ( ! is_admin() ) {
782
+ wp_redirect(
783
+ remove_query_arg(
784
+ '_cachify',
785
+ wp_get_referer()
786
  )
787
  );
788
+
789
+ exit();
790
  }
791
  }
792
 
795
  * Hinweis nach erfolgreichem Cache-Leeren
796
  *
797
  * @since 1.2
798
+ * @change 2.2.0
799
+ *
800
+ * @hook mixed cachify_user_can_flush_cache
801
  */
802
 
803
  public static function flush_notice()
804
  {
805
  /* Kein Admin */
806
+ if ( ! is_admin_bar_showing() OR ! apply_filters('cachify_user_can_flush_cache', current_user_can('manage_options')) ) {
807
  return false;
808
  }
809
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: sergej.mueller
3
  Tags: apc, cache, caching, performance
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZAQUT9RLPW8QN
5
  Requires at least: 3.8
6
- Tested up to: 4.0
7
  Stable tag: trunk
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -77,6 +77,10 @@ Fragen rund ums Plugin werden gern per E-Mail beantwortet. Beachtet auch die [Gu
77
 
78
  == Changelog ==
79
 
 
 
 
 
80
  = 2.1.9 =
81
  * Vervollständigung des Cachify-Pfades in `robots.txt`: `Disallow: /wp-content/cache/cachify/`
82
  * *Release-Zeitaufwand (Development & QA): 0,75 Stunden*
3
  Tags: apc, cache, caching, performance
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZAQUT9RLPW8QN
5
  Requires at least: 3.8
6
+ Tested up to: 4.0.1
7
  Stable tag: trunk
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
77
 
78
  == Changelog ==
79
 
80
+ = 2.2.0 =
81
+ * Werkzeugleiste: Anzeige des "Cache leeren" Buttons im Frontend der Website
82
+ * Werkzeugleiste: Steuerung der Anzeige des "Cache leeren" Buttons via Hook
83
+
84
  = 2.1.9 =
85
  * Vervollständigung des Cachify-Pfades in `robots.txt`: `Disallow: /wp-content/cache/cachify/`
86
  * *Release-Zeitaufwand (Development & QA): 0,75 Stunden*