Add real form fields and provide defaults

This commit is contained in:
David Walsh 2016-01-22 09:35:15 -06:00
Родитель 5e5c0e9115
Коммит f97d6b6220
2 изменённых файлов: 19 добавлений и 4 удалений

Просмотреть файл

@ -34,8 +34,20 @@ class SW_Cache_Admin {
<form method="post" action="">
<h2><?php _e('Enable ServiceWorker Cache', 'wpswcache'); ?></h2>
<li>[checkbox] Option to enable or disable the service worker</li>
<li>[textbox] Cache Name:</li>
<table class="form-table">
<tr>
<th scope="row"><label for="wp_sw_cache_enabled"><?php _e('Enable Service Worker?', 'wpswcache'); ?></label></th>
<td>
<input type="checkbox" name="wp_sw_cache_enabled" id="wp_sw_cache_enabled" value="1" autofocus />
</td>
</tr>
<tr>
<th scope="row"><label for="wp_sw_cache_name"><?php _e('Cache Prefix?', 'wpswcache'); ?></label></th>
<td>
<input type="text" name="wp_sw_cache_name" id="wp_sw_cache_name" value="" />
</td>
</tr>
</table>
<h2><?php _e('Files to Cache', 'wpswcache'); ?></h2>
<p><?php _e('Select files that are used on a majority of pages.', 'wpswcache'); ?></p>

Просмотреть файл

@ -3,6 +3,7 @@
class SW_Cache_DB {
private static $instance;
private static $cache_prefix = 'wp-sw-cache';
public function __construct() {
}
@ -17,14 +18,16 @@ class SW_Cache_DB {
public static function on_activate() {
// Set default options.
update_option('wp_sw_cache_name', ''); // TODO: What should we call this by defualt?
update_option('wp_sw_cache_files', ''); // TODO: How do we want to structure this file list?
update_option('wp_sw_cache_enabled', false);
update_option('wp_sw_cache_name', $this->$cache_prefix); // TODO: What should we call this by defualt?
update_option('wp_sw_cache_files', array()); // TODO: How do we want to structure this file list?
}
public static function on_deactivate() {
}
public static function on_uninstall() {
delete_option('wp_sw_cache_enabled');
delete_option('wp_sw_cache_name');
delete_option('wp_sw_cache_files');
}