Skip to content

Commit 005dbeb

Browse files
committed
cleanup
1 parent 6e3f1c0 commit 005dbeb

File tree

1 file changed

+57
-58
lines changed

1 file changed

+57
-58
lines changed

s3-uploads.php

+57-58
Original file line numberDiff line numberDiff line change
@@ -8,63 +8,59 @@
88
Author URI: http://hmn.md
99
*/
1010

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';
1313
}
1414

15-
add_action('plugins_loaded', 's3_uploads_init');
15+
add_action( 'plugins_loaded', 's3_uploads_init' );
1616

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+
}
2221

23-
if (! defined('S3_UPLOADS_BUCKET') ) {
24-
return;
25-
}
22+
if ( ! defined( 'S3_UPLOADS_BUCKET' ) ) {
23+
return;
24+
}
2625

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+
}
3029

31-
if (! s3_uploads_enabled() ) {
32-
return;
33-
}
30+
if ( ! s3_uploads_enabled() ) {
31+
return;
32+
}
3433

35-
$instance = S3_Uploads::get_instance();
36-
$instance->setup();
34+
$instance = S3_Uploads::get_instance();
35+
$instance->setup();
3736
}
3837

3938
/**
4039
* Check whether the environment meets the plugin's requirements, like the minimum PHP version.
4140
*
4241
* @return bool True if the requirements are met, else false.
4342
*/
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+
}
5048

51-
return false;
52-
}
49+
return false;
50+
}
5351

54-
return true;
52+
return true;
5553
}
5654

5755
/**
5856
* Print an admin notice when the PHP version is not high enough.
5957
*
6058
* This has to be a named function for compatibility with PHP 5.2.
6159
*/
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+
);
6864
}
6965

7066
/**
@@ -75,36 +71,39 @@ function s3_uploads_outdated_php_version_notice()
7571
*
7672
* @return bool
7773
*/
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 );
8277

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+
}
8681

87-
return true;
82+
return true;
8883
}
8984

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+
}
105104
}
106105

107106
spl_autoload_register('s3_uploads_autoload', true);
108107

109108
// 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

Comments
 (0)