-
Notifications
You must be signed in to change notification settings - Fork 152
/
wordpress-s3.php
112 lines (91 loc) · 3.88 KB
/
wordpress-s3.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
/*
Plugin Name: WP Offload Media Lite
Plugin URI: https://deliciousbrains.com
Description: Automatically copies media uploads to Amazon S3, DigitalOcean Spaces or Google Cloud Storage for storage and delivery. Optionally configure Amazon CloudFront or another CDN for even faster delivery.
Author: Delicious Brains
Version: 3.2.10
Author URI: https://deliciousbrains.com/?utm_campaign=WP%2BOffload%2BS3&utm_source=wordpress.org&utm_medium=free%2Bplugin%2Blisting
Update URI: false
Network: True
Text Domain: amazon-s3-and-cloudfront
Domain Path: /languages/
// Copyright (c) 2013 Delicious Brains. All rights reserved.
//
// Released under the GPL license
// http://www.opensource.org/licenses/gpl-license.php
//
// **********************************************************************
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// **********************************************************************
//
// Forked Amazon S3 for WordPress with CloudFront (http://wordpress.org/extend/plugins/tantan-s3-cloudfront/)
// which is a fork of Amazon S3 for WordPress (http://wordpress.org/extend/plugins/tantan-s3/).
// Then completely rewritten.
*/
// phpcs:disable SlevomatCodingStandard.Variables.UnusedVariable
$GLOBALS['aws_meta']['amazon-s3-and-cloudfront']['version'] = '3.2.10';
require_once dirname( __FILE__ ) . '/classes/as3cf-compatibility-check.php';
add_action( 'activated_plugin', array( 'AS3CF_Compatibility_Check', 'deactivate_other_instances' ) );
global $as3cf_compat_check;
$as3cf_compat_check = new AS3CF_Compatibility_Check(
'WP Offload Media Lite',
'amazon-s3-and-cloudfront',
__FILE__
);
/**
* @throws Exception
*/
function as3cf_init() {
if ( class_exists( 'Amazon_S3_And_CloudFront' ) ) {
return;
}
global $as3cf_compat_check;
if ( method_exists( 'AS3CF_Compatibility_Check', 'is_plugin_active' ) && $as3cf_compat_check->is_plugin_active( 'amazon-s3-and-cloudfront-pro/amazon-s3-and-cloudfront-pro.php' ) ) {
// Don't load if pro plugin installed
return;
}
if ( ! $as3cf_compat_check->is_compatible() ) {
return;
}
global $as3cf;
$abspath = dirname( __FILE__ );
// Autoloader.
require_once $abspath . '/wp-offload-media-autoloader.php';
new WP_Offload_Media_Autoloader( 'WP_Offload_Media', $abspath );
require_once $abspath . '/include/functions.php';
require_once $abspath . '/classes/as3cf-utils.php';
require_once $abspath . '/classes/as3cf-error.php';
require_once $abspath . '/classes/as3cf-filter.php';
require_once $abspath . '/classes/filters/as3cf-local-to-s3.php';
require_once $abspath . '/classes/filters/as3cf-s3-to-local.php';
require_once $abspath . '/classes/as3cf-notices.php';
require_once $abspath . '/classes/as3cf-plugin-base.php';
require_once $abspath . '/classes/as3cf-plugin-compatibility.php';
require_once $abspath . '/classes/amazon-s3-and-cloudfront.php';
// Load settings and core components.
$as3cf = new Amazon_S3_And_CloudFront( __FILE__ );
// Initialize managers and their registered components.
do_action( 'as3cf_init', $as3cf );
// Set up initialized components, e.g. add integration hooks.
do_action( 'as3cf_setup', $as3cf );
// Plugin is ready to rock, let 3rd parties know.
do_action( 'as3cf_ready', $as3cf );
}
add_action( 'init', 'as3cf_init' );
// If AWS still active need to be around to satisfy addon version checks until upgraded.
add_action( 'aws_init', 'as3cf_init', 11 );
/**
* Initialize the checking for plugin updates.
*/
function as3cf_check_for_upgrades() {
$properties = array(
'plugin_slug' => 'amazon-s3-and-cloudfront',
'plugin_basename' => plugin_basename( __FILE__ ),
);
require_once __DIR__ . '/classes/as3cf-plugin-updater.php';
new DeliciousBrains\WP_Offload_Media\AS3CF_Plugin_Updater( $properties );
}
add_action( 'admin_init', 'as3cf_check_for_upgrades' );