66 * @wordpress-plugin
77 * Plugin Name: Super Light Cache Buster
88 * Description: With a compressed size of under 10KB, this simple plugin adds random version numbers to CSS & JS assets to vanquish browser caching. Clear your Site and Server-side caches, and this plugin will do the rest.
9- * Version: 1.1.1
9+ * Version: 1.1.2
1010 * Author: Mwale Kalenga
1111 * Author URI: https://mwale.me
1212 * License: GPL-3.0+
1313 * License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
1414 */
1515
1616class Super_Light_Cache_Buster {
17- public $ all_fields = array (
17+ public static $ all_fields = array (
1818 array (
1919 'uid ' => 'slcb_plugin_state ' ,
2020 'label ' => 'Cache Buster Status ' ,
@@ -72,8 +72,6 @@ public function __construct() {
7272 // Don't invoke slcb_activation in v 1.1.0
7373 // plugin deactivation
7474 // Don't invoke slcb_deactivation in v 1.1.0
75- // plugin uninstallation
76- register_uninstall_hook ( __FILE__ , 'slcb_uninstaller ' );
7775 }
7876 public function create_plugin_settings_page () {
7977 // Add the menu item and page
@@ -85,21 +83,21 @@ public function create_plugin_settings_page() {
8583 add_submenu_page ( 'options-general.php ' , $ page_title , $ menu_title , $ capability , $ slug , $ callback );
8684 }
8785 public function plugin_settings_page_content () {?>
88- <div class="wrap">
89- <diV class="main_content">
90- <h2>Super Light Cache Buster Settings</h2><?php
86+ <div class="wrap">
87+ <div class="main_content">
88+ <h2>Super Light Cache Buster Settings</h2><?php
9189 if ( isset ( $ _GET ['settings-updated ' ] ) && $ _GET ['settings-updated ' ] ){
9290 // Don't invoke setWpCache in v 1.1.0
9391 } ?>
94- <form method="POST" action="options.php">
95- <?php
92+ <form method="POST" action="options.php">
93+ <?php
9694 settings_fields ( 'slcb_fields ' );
9795 do_settings_sections ( 'slcb_fields ' );
9896 submit_button ();
9997 ?>
100- </form>
101- <diV >
102- </div> <?php
98+ </form>
99+ <div >
100+ </div> <?php
103101 }
104102 public function admin_notice () { ?>
105103 <div class="notice notice-success is-dismissible">
@@ -128,7 +126,7 @@ public function section_callback( $arguments ) {
128126 }
129127 }
130128 public function setup_fields () {
131- $ fields = $ this -> all_fields ;
129+ $ fields = self :: $ all_fields ;
132130 foreach ( $ fields as $ field ){
133131 add_settings_field ( $ field ['uid ' ], $ field ['label ' ], array ( $ this , 'field_callback ' ), 'slcb_fields ' , $ field ['section ' ], $ field );
134132 register_setting ( 'slcb_fields ' , $ field ['uid ' ] );
@@ -183,15 +181,15 @@ public function field_callback( $arguments ) {
183181 }
184182 }
185183 public function get_SLCB_fields ($ offset1 , $ offset2 = 'default ' ) {
186- return ( $ this -> all_fields [$ offset1 ][$ offset2 ] );
184+ return ( self :: $ all_fields [$ offset1 ][$ offset2 ] );
187185 }
188186 public function get_SLCB_uids () {
189- $ uid = $ this -> all_fields [0 ]['uid ' ];
187+ $ uid = self :: $ all_fields [0 ]['uid ' ];
190188 print_r ($ uid );
191189 }
192- public function uninstall_SLCB () {
190+ public static function uninstall_SLCB () {
193191 $ uids = array ();
194- foreach ($ this -> all_fields as $ array ) {
192+ foreach (self :: $ all_fields as $ array ) {
195193 $ uids [] = $ array ['uid ' ];
196194 } # Potential alternative to foreach - $options = implode(", ", $uids);
197195 $ settingOptions = $ uids ;
@@ -242,9 +240,11 @@ public function slcb_deactivation() {
242240 $ this ->admin_error ($ this ->file_permissions_error );
243241 }
244242 }
245- public function slcb_uninstaller () {
246- $ this ->uninstall_SLCB ();
247- }
243+ }
244+
245+ if (class_exists ('Super_Light_Cache_Buster ' ) ) {
246+ // plugin uninstallation
247+ register_uninstall_hook ( __FILE__ , 'Super_Light_Cache_Buster::uninstall_SLCB ' );
248248}
249249
250250$ slcb_fields = new Super_Light_Cache_Buster ();
@@ -357,4 +357,4 @@ function remove_cache_constant( $slash = '' ) {
357357 $ config = preg_replace ("/( ?)(define)( ?)(\()( ?)([' \"])WP_CACHE([' \"])( ?)(,)( ?)(0|1|true|false)( ?)(\))( ?);/i " , "" , $ config );
358358 file_put_contents (ABSPATH . $ slash . "wp-config.php " , $ config );
359359 }
360- }
360+ }
0 commit comments