-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwp-workbox.php
More file actions
28 lines (25 loc) · 817 Bytes
/
wp-workbox.php
File metadata and controls
28 lines (25 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
/*
Plugin Name: Simple WP Workbox
Plugin URI: https://wordpress.org/plugins/simple-wp-workbox
Description: Opensource Workbox implementation to cache Wordpress files.
Version: 0.1a
Author: Enrico Gruner
Author URI: https://dev-creations.de
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: cdev-wp-workbox
Domain Path: /
*/
function pluginScripts() {
wp_enqueue_script( 'load-sw', plugins_url('/load-sw.js', __FILE__), [], '1.0' );
}
add_action( 'wp_enqueue_scripts', 'pluginScripts');
function onActivate() {
copy( plugins_url('/sw.js', __FILE__), get_home_path() . 'sw.js' );
}
register_activation_hook( __FILE__, 'onActivate');
function onUninstall() {
unlink(get_home_path() . 'sw.js' );
}
register_uninstall_hook( __FILE__, 'onUninstall');