-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClass.php
More file actions
50 lines (44 loc) · 1.22 KB
/
Class.php
File metadata and controls
50 lines (44 loc) · 1.22 KB
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
<?php
namespace S3PmxiCompatibility;
class S3PmxiCompatibility {
/** WP All Import Views */
public $views = [
'pmxi-admin-import',
'pmxi-admin-manage',
'pmxi-admin-settings',
'pmxi-admin-history',
'pmxe-admin-import',
'pmxe-admin-manage',
'pmxe-admin-settings',
'pmxe-admin-history',
];
/** S3 Uploads Plugin path */
public $s3 = 's3-uploads/s3-uploads.php';
/**
* Deactivate the S3 Uploads Plugin (if active).
*/
public function deactivateS3() {
if ( !function_exists( 'is_plugin_active' ) ) {
include_once ABSPATH . 'wp-admin/includes/plugin.php';
}
if ( is_plugin_active( $this->s3 ) ) {
deactivate_plugins( $this->s3 );
}
}
/**
* Activates the S3 Uploads plugin if it exists and the constants are
* defined in the WP Configuration.
*
* @return [WP_Error|null] WP_Error on invalid file or 'NULL' on success
*/
public function activateS3() {
if ( is_admin() &&
file_exists( WP_PLUGIN_DIR . '/' . $this->s3 ) &&
defined( 'S3_UPLOADS_BUCKET' ) &&
defined( 'S3_UPLOADS_KEY' ) &&
defined( 'S3_UPLOADS_SECRET' ) &&
defined( 'S3_UPLOADS_REGION' ) ) {
return activate_plugin( $this->s3 );
}
}
}