Skip to content

Commit

Permalink
Merge pull request #17 from Mwalek/uninstaller-not-found
Browse files Browse the repository at this point in the history
Uninstaller not found
  • Loading branch information
Mwalek authored Sep 29, 2022
2 parents d40b5f2 + 9a4d0df commit f6d52b6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 22 deletions.
14 changes: 13 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Tested up to: 6.0
Requires PHP: 5.2
License: GPLv3 or later
License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
Stable tag: 1.1.0
Stable tag: 1.1.2


Stop browser caching by randomizing asset version numbers.
Expand Down Expand Up @@ -42,6 +42,18 @@ This will delete all pages/posts from the cache, and Cache Buster will prevent t

== Changelog ==

= 1.1.2 =

Release Date - September 29, 2022

**Fixed**

* Fix warning/error thrown when Cache Buster is uninstalled.

**Enhanced**

* Use a static method when register_uninstall_hook is invoked.

= 1.1.1 =

Release Date - May 06, 2022
Expand Down
42 changes: 21 additions & 21 deletions super-light-cache-buster.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
* @wordpress-plugin
* Plugin Name: Super Light Cache Buster
* 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.
* Version: 1.1.1
* Version: 1.1.2
* Author: Mwale Kalenga
* Author URI: https://mwale.me
* License: GPL-3.0+
* License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
*/

class Super_Light_Cache_Buster {
public $all_fields = array(
public static $all_fields = array(
array(
'uid' => 'slcb_plugin_state',
'label' => 'Cache Buster Status',
Expand Down Expand Up @@ -72,8 +72,6 @@ public function __construct() {
// Don't invoke slcb_activation in v 1.1.0
// plugin deactivation
// Don't invoke slcb_deactivation in v 1.1.0
// plugin uninstallation
register_uninstall_hook( __FILE__, 'slcb_uninstaller' );
}
public function create_plugin_settings_page() {
// Add the menu item and page
Expand All @@ -85,21 +83,21 @@ public function create_plugin_settings_page() {
add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $slug, $callback );
}
public function plugin_settings_page_content() {?>
<div class="wrap">
<diV class="main_content">
<h2>Super Light Cache Buster Settings</h2><?php
<div class="wrap">
<div class="main_content">
<h2>Super Light Cache Buster Settings</h2><?php
if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] ){
// Don't invoke setWpCache in v 1.1.0
} ?>
<form method="POST" action="options.php">
<?php
<form method="POST" action="options.php">
<?php
settings_fields( 'slcb_fields' );
do_settings_sections( 'slcb_fields' );
submit_button();
?>
</form>
<diV>
</div> <?php
</form>
<div>
</div> <?php
}
public function admin_notice() { ?>
<div class="notice notice-success is-dismissible">
Expand Down Expand Up @@ -128,7 +126,7 @@ public function section_callback( $arguments ) {
}
}
public function setup_fields() {
$fields = $this->all_fields;
$fields = self::$all_fields;
foreach( $fields as $field ){
add_settings_field( $field['uid'], $field['label'], array( $this, 'field_callback' ), 'slcb_fields', $field['section'], $field );
register_setting( 'slcb_fields', $field['uid'] );
Expand Down Expand Up @@ -183,15 +181,15 @@ public function field_callback( $arguments ) {
}
}
public function get_SLCB_fields($offset1, $offset2 = 'default') {
return( $this->all_fields[$offset1][$offset2] );
return( self::$all_fields[$offset1][$offset2] );
}
public function get_SLCB_uids() {
$uid = $this->all_fields[0]['uid'];
$uid = self::$all_fields[0]['uid'];
print_r ($uid);
}
public function uninstall_SLCB () {
public static function uninstall_SLCB () {
$uids = array();
foreach($this->all_fields as $array) {
foreach(self::$all_fields as $array) {
$uids[] = $array['uid'];
} # Potential alternative to foreach - $options = implode(", ", $uids);
$settingOptions = $uids;
Expand Down Expand Up @@ -242,9 +240,11 @@ public function slcb_deactivation() {
$this->admin_error($this->file_permissions_error);
}
}
public function slcb_uninstaller() {
$this->uninstall_SLCB();
}
}

if (class_exists ('Super_Light_Cache_Buster') ) {
// plugin uninstallation
register_uninstall_hook( __FILE__, 'Super_Light_Cache_Buster::uninstall_SLCB' );
}

$slcb_fields = new Super_Light_Cache_Buster();
Expand Down Expand Up @@ -357,4 +357,4 @@ function remove_cache_constant( $slash = '' ) {
$config = preg_replace ("/( ?)(define)( ?)(\()( ?)(['\"])WP_CACHE(['\"])( ?)(,)( ?)(0|1|true|false)( ?)(\))( ?);/i", "", $config);
file_put_contents (ABSPATH . $slash . "wp-config.php", $config);
}
}
}

0 comments on commit f6d52b6

Please sign in to comment.