88Author URI: http://hmn.md
99*/
1010
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 ' ;
1313}
1414
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 ' ;
1621
17- function s3_uploads_init () {
18- if ( ! s3_uploads_check_requirements () ) {
19- return ;
20- }
22+ add_action ('plugins_loaded ' , 's3_uploads_init ' );
2123
22- if ( ! defined ( 'S3_UPLOADS_BUCKET ' ) ) {
23- return ;
24- }
24+ function s3_uploads_init ()
25+ {
26+ if (! s3_uploads_check_requirements () ) {
27+ return ;
28+ }
2529
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+ }
2933
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+ }
3337
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 ();
3644}
3745
3846/**
3947 * Check whether the environment meets the plugin's requirements, like the minimum PHP version.
4048 *
4149 * @return bool True if the requirements are met, else false.
4250 */
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+ }
4857
49- return false ;
50- }
58+ return false ;
59+ }
5160
52- return true ;
61+ return true ;
5362}
5463
5564/**
5665 * Print an admin notice when the PHP version is not high enough.
5766 *
5867 * This has to be a named function for compatibility with PHP 5.2.
5968 */
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+ );
6475}
6576
6677/**
@@ -71,39 +82,17 @@ function s3_uploads_outdated_php_version_notice() {
7182 *
7283 * @return bool
7384 */
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 );
7789
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+ }
8193
82- return true ;
94+ return true ;
8395}
8496
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-
10897// 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