Merge pull request #47 from darkwing/db-defaults
Organize option defaults
This commit is contained in:
Коммит
e206e7e838
|
@ -63,8 +63,8 @@ class SW_Cache_Admin {
|
|||
|
||||
public function on_switch_theme() {
|
||||
if(get_option('wp_sw_cache_enabled')) {
|
||||
update_option('wp_sw_cache_enabled', 0);
|
||||
update_option('wp_sw_cache_files', array());
|
||||
update_option('wp_sw_cache_enabled', SW_Cache_DB::$options['wp_sw_cache_enabled']);
|
||||
update_option('wp_sw_cache_files', SW_Cache_DB::$options['wp_sw_cache_files']);
|
||||
add_action('admin_notices', array($this, 'show_switch_theme_message'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,19 @@
|
|||
class SW_Cache_DB {
|
||||
|
||||
private static $instance;
|
||||
public static $options;
|
||||
|
||||
public function __construct() {
|
||||
self::$options = array(
|
||||
// For v1 we'll prompt the user enable the plugin manually upon activation
|
||||
'wp_sw_cache_enabled' => 0,
|
||||
// The "style.css" file is a standard WordPress file, so we can safely assume this exists
|
||||
'wp_sw_cache_files' => array('styles.css'),
|
||||
// Create an initial SW version
|
||||
'wp_sw_cache_version' => time(),
|
||||
// Setting debug initially will help the user understand what the SW is doing via the console
|
||||
'wp_sw_cache_debug' => 0
|
||||
);
|
||||
}
|
||||
|
||||
public static function getInstance() {
|
||||
|
@ -15,24 +26,18 @@ class SW_Cache_DB {
|
|||
}
|
||||
|
||||
public static function on_activate() {
|
||||
// For v1 we'll prompt the user enable the plugin manually upon activation
|
||||
update_option('wp_sw_cache_enabled', 0);
|
||||
// The "style.css" file is a standard WordPress file, so we can safely assume this exists
|
||||
update_option('wp_sw_cache_files', array('style.css'));
|
||||
// Create an initial SW version
|
||||
SW_Cache_Main::update_version();
|
||||
// Setting debug initially will help the user understand what the SW is doing via the console
|
||||
update_option('wp_sw_cache_debug', 1);
|
||||
foreach(self::$options as $option => $default) {
|
||||
update_option($option, $default);
|
||||
}
|
||||
}
|
||||
|
||||
public static function on_deactivate() {
|
||||
}
|
||||
|
||||
public static function on_uninstall() {
|
||||
delete_option('wp_sw_cache_enabled');
|
||||
delete_option('wp_sw_cache_version');
|
||||
delete_option('wp_sw_cache_files');
|
||||
delete_option('wp_sw_cache_debug');
|
||||
foreach(self::$options as $option => $default) {
|
||||
delete_option($option);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче