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