PluginProbe
Surge / 0.1.0
Surge v0.1.0
trunk 0.1.0 1.0.0 1.0.2 1.0.3 1.0.5 1.1.0 1.2.0 1.2.1
surge / surge.php

surge.php in Surge 0.1.0, at surge.php

60 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Surge
4 * Plugin URI: https://github.com/kovshenin/surge
5 * Description: A fast and simple page caching plugin for WordPress
6 * Author: Konstantin Kovshenin
7 * Author URI: https://konstantil.blog
8 * Text Domain: surge
9 * Domain Path: /languages
10 * Version: 0.1.0
11 *
12 * @package Surge
13 */
14
15 namespace Surge;
16
17 // Attempt to cache this request if cache is on.
18 if ( defined( 'WP_CACHE' ) && WP_CACHE ) {
19 include_once( __DIR__ . '/include/cache.php' );
20 }
21
22 // Load more files later when necessary.
23 add_action( 'plugins_loaded', function() {
24 if ( false === get_option( 'surge_installed', false ) ) {
25 if ( add_option( 'surge_installed', 0 ) ) {
26 require_once( __DIR__ . '/include/install.php' );
27 }
28 }
29
30 if ( wp_doing_cron() ) {
31 include_once( __DIR__ . '/include/cron.php' );
32 }
33
34 include_once( __DIR__ . '/include/invalidate.php' );
35 } );
36
37 // Site Health events
38 add_filter( 'site_status_tests', function( $tests ) {
39 include_once( __DIR__ . '/include/health.php' );
40
41 $tests['direct']['surge'] = [
42 'label' => 'Caching Test',
43 'test' => '\Surge\health_test',
44 ];
45
46 return $tests;
47 } );
48
49 // Schedule cron events.
50 add_action( 'shutdown', function() {
51 if ( ! wp_next_scheduled( 'surge_delete_expired' ) ) {
52 wp_schedule_event( time(), 'hourly', 'surge_delete_expired' );
53 }
54 } );
55
56 // Re-install on activation
57 register_activation_hook( __FILE__, function() {
58 delete_option( 'surge_installed' );
59 } );
60