8
8
Author URI: http://hmn.md
9
9
*/
10
10
11
- if ( defined ( 'WP_CLI ' ) && WP_CLI ) {
12
- require_once dirname ( __FILE__ ) . '/inc/class-s3-uploads-wp-cli-command.php ' ;
11
+ if (defined ('WP_CLI ' ) && WP_CLI ) {
12
+ include_once dirname (__FILE__ ) . '/inc/class-s3-uploads-wp-cli-command.php ' ;
13
13
}
14
14
15
- add_action ( 'plugins_loaded ' , 's3_uploads_init ' );
15
+ require_once dirname (__FILE__ ) . '/inc/class-s3-uploads-changed-files-iterator.php ' ;
16
+ require_once dirname (__FILE__ ) . '/inc/class-s3-uploads-image-editor-imagick.php ' ;
17
+ require_once dirname (__FILE__ ) . '/inc/class-s3-uploads-local-stream-wrapper.php ' ;
18
+ require_once dirname (__FILE__ ) . '/inc/class-s3-uploads-stream-wrapper.php ' ;
19
+ require_once dirname (__FILE__ ) . '/inc/class-s3-uploads-uploadsyncbuilder.php ' ;
20
+ require_once dirname (__FILE__ ) . '/inc/class-s3-uploads.php ' ;
16
21
17
- function s3_uploads_init () {
18
- if ( ! s3_uploads_check_requirements () ) {
19
- return ;
20
- }
22
+ add_action ('plugins_loaded ' , 's3_uploads_init ' );
21
23
22
- if ( ! defined ( 'S3_UPLOADS_BUCKET ' ) ) {
23
- return ;
24
- }
24
+ function s3_uploads_init ()
25
+ {
26
+ if (! s3_uploads_check_requirements () ) {
27
+ return ;
28
+ }
25
29
26
- if ( ( ! defined ( ' S3_UPLOADS_KEY ' ) || ! defined ( ' S3_UPLOADS_SECRET ' ) ) && ! defined ( ' S3_UPLOADS_USE_INSTANCE_PROFILE ' ) ) {
27
- return ;
28
- }
30
+ if ( ! defined (' S3_UPLOADS_BUCKET ' ) ) {
31
+ return ;
32
+ }
29
33
30
- if ( ! s3_uploads_enabled ( ) ) {
31
- return ;
32
- }
34
+ if (( ! defined ( ' S3_UPLOADS_KEY ' ) || ! defined ( ' S3_UPLOADS_SECRET ' ) ) && ! defined ( ' S3_UPLOADS_USE_INSTANCE_PROFILE ' ) ) {
35
+ return ;
36
+ }
33
37
34
- $ instance = S3_Uploads::get_instance ();
35
- $ instance ->setup ();
38
+ if (! s3_uploads_enabled () ) {
39
+ return ;
40
+ }
41
+
42
+ $ instance = S3_Uploads::get_instance ();
43
+ $ instance ->setup ();
36
44
}
37
45
38
46
/**
39
47
* Check whether the environment meets the plugin's requirements, like the minimum PHP version.
40
48
*
41
49
* @return bool True if the requirements are met, else false.
42
50
*/
43
- function s3_uploads_check_requirements () {
44
- if ( version_compare ( '5.3.3 ' , PHP_VERSION , '> ' ) ) {
45
- if ( is_admin () && ! defined ( 'DOING_AJAX ' ) ) {
46
- add_action ( 'admin_notices ' , 's3_uploads_outdated_php_version_notice ' );
47
- }
51
+ function s3_uploads_check_requirements ()
52
+ {
53
+ if (version_compare ('5.3.3 ' , PHP_VERSION , '> ' ) ) {
54
+ if (is_admin () && ! defined ('DOING_AJAX ' ) ) {
55
+ add_action ('admin_notices ' , 's3_uploads_outdated_php_version_notice ' );
56
+ }
48
57
49
- return false ;
50
- }
58
+ return false ;
59
+ }
51
60
52
- return true ;
61
+ return true ;
53
62
}
54
63
55
64
/**
56
65
* Print an admin notice when the PHP version is not high enough.
57
66
*
58
67
* This has to be a named function for compatibility with PHP 5.2.
59
68
*/
60
- function s3_uploads_outdated_php_version_notice () {
61
- printf ( '<div class="error"><p>The S3 Uploads plugin requires PHP version 5.3.3 or higher. Your server is running PHP version %s.</p></div> ' ,
62
- PHP_VERSION
63
- );
69
+ function s3_uploads_outdated_php_version_notice ()
70
+ {
71
+ printf (
72
+ '<div class="error"><p>The S3 Uploads plugin requires PHP version 5.3.3 or higher. Your server is running PHP version %s.</p></div> ' ,
73
+ PHP_VERSION
74
+ );
64
75
}
65
76
66
77
/**
@@ -71,39 +82,17 @@ function s3_uploads_outdated_php_version_notice() {
71
82
*
72
83
* @return bool
73
84
*/
74
- function s3_uploads_enabled () {
75
- // Make sure the plugin is enabled when autoenable is on
76
- $ constant_autoenable_off = ( defined ( 'S3_UPLOADS_AUTOENABLE ' ) && false === S3_UPLOADS_AUTOENABLE );
85
+ function s3_uploads_enabled ()
86
+ {
87
+ // Make sure the plugin is enabled when autoenable is on
88
+ $ constant_autoenable_off = ( defined ('S3_UPLOADS_AUTOENABLE ' ) && false === S3_UPLOADS_AUTOENABLE );
77
89
78
- if ( $ constant_autoenable_off && 'enabled ' !== get_option ( 's3_uploads_enabled ' ) ) { // If the plugin is not enabled, skip
79
- return false ;
80
- }
90
+ if ($ constant_autoenable_off && 'enabled ' !== get_option ('s3_uploads_enabled ' ) ) { // If the plugin is not enabled, skip
91
+ return false ;
92
+ }
81
93
82
- return true ;
94
+ return true ;
83
95
}
84
96
85
- /**
86
- * Autoload callback.
87
- *
88
- * @param $class_name Name of the class to load.
89
- */
90
- function s3_uploads_autoload ( $ class_name ) {
91
- /*
92
- * Load plugin classes:
93
- * - Class name: S3_Uploads_Image_Editor_Imagick.
94
- * - File name: class-s3-uploads-image-editor-imagick.php.
95
- */
96
- $ class_file = 'class- ' . strtolower ( str_replace ( '_ ' , '- ' , $ class_name ) ) . '.php ' ;
97
- $ class_path = dirname ( __FILE__ ) . '/inc/ ' . $ class_file ;
98
-
99
- if ( file_exists ( $ class_path ) ) {
100
- require $ class_path ;
101
-
102
- return ;
103
- }
104
- }
105
-
106
- spl_autoload_register ( 's3_uploads_autoload ' );
107
-
108
97
// Require AWS Autoloader file.
109
- require_once dirname ( __FILE__ ) . '/lib/aws-sdk/aws-autoloader.php ' ;
98
+ require_once dirname (__FILE__ ) . '/lib/aws-sdk/aws-autoloader.php ' ;
0 commit comments