forked from amimoto-ami/c3-cloudfront-clear-cache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
c3-cloudfront-clear-cache.php
83 lines (75 loc) · 1.87 KB
/
c3-cloudfront-clear-cache.php
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
* Plugin Name: C3 Cloudfront Cache Controller
* Version: 6.1.3
* Plugin URI:https://github.com/amimoto-ami/c3-cloudfront-clear-cache
* Description: Manage CloudFront Cache and provide some fixtures.
* Author: hideokamoto
* Author URI: https://wp-kyoto.net/
* Requires PHP: 7.0
* Text Domain: c3-cloudfront-clear-cache
*
* @package c3-cloudfront-clear-cache
*/
/**
* Load the class loader
*/
require_once( __DIR__ . '/loader.php' );
use C3_CloudFront_Cache_Controller\WP;
use C3_CloudFront_Cache_Controller\AWS;
/**
* Load AWS SDK and classes
*/
function c3_init() {
if ( ! class_exists( '\\Aws\\CloudFront\\CloudFrontClient' ) ) {
$aws_sdk_path = apply_filters( 'c3_aws_sdk_path', dirname( __FILE__ ) . '/libs/aws.phar' );
if ( isset( $aws_sdk_path ) ) {
require_once( $aws_sdk_path );
}
}
new C3_CloudFront_Cache_Controller\Invalidation_Service();
new C3_CloudFront_Cache_Controller\Cron_Service();
new C3_CloudFront_Cache_Controller\Settings_Service();
new C3_CloudFront_Cache_Controller\Views\Settings();
new WP\Fixtures();
}
add_action('after_theme_setup', 'c3_init');
/**
* For WP-CLI.
*/
if ( defined( 'WP_CLI' ) && WP_CLI ) {
WP_CLI::add_command( 'c3', 'C3_CloudFront_Cache_Controller\\WP\\WP_CLI_Command' );
}
/**
* Backward compatibility
*
* @since 6.1.1
* @package C3_CloudFront_Cache_Controller
*/
class CloudFront_Clear_Cache {
/**
* Class instance
*
* @var CloudFront_Clear_Cache
*/
private static $instance;
/**
* Create instance
*
* @return CloudFront_Clear_Cache
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
$c = __CLASS__;
self::$instance = new $c();
}
return self::$instance;
}
/**
* Run invalidation all
*/
public function c3_invalidation() {
$service = new C3_CloudFront_Cache_Controller\Invalidation_Service();
return $service->invalidate_all();
}
}