PluginProbe
WP-Stateless – Google Cloud Storage / 2.1.4
WP-Stateless – Google Cloud Storage v2.1.4
4.4.3 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.3.0 2.3.1 2.3.2 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 All 62 releases
wp-stateless / lib / classes / class-compatibility.php

class-compatibility.php in WP-Stateless – Google Cloud Storage 2.1.4, at lib/classes/class-compatibility.php

100 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Compatibility with other plugins.
4 *
5 * This class serves as compatibility getway.
6 * Initiate all compatibility modules.
7 *
8 * @class Compatibility
9 */
10
11 namespace wpCloud\StatelessMedia {
12
13 class Module{
14
15 private static $modules = array();
16
17 public function __construct(){
18 $this->save_modules();
19
20 /**
21 * Dynamic Image Support
22 */
23 new DynamicImageSupport();
24
25 /**
26 * ACF image crop addons compatibility.
27 */
28 new CompatibilityAcfImageCrop();
29
30 /**
31 * Support for Easy Digital Downloads download method
32 */
33 new EDDDownloadMethod();
34
35 /**
36 * Support for SiteOrigin CSS files
37 */
38 new SOWidgetCSS();
39 }
40
41 public static function register_module($id, $title , $description, $enabled = 'false', $is_constant = false){
42 if (is_bool($enabled)) {
43 $enabled = $enabled ? 'true' : 'false';
44 }
45
46 self::$modules[] = array(
47 'id' => $id,
48 'title' => $title,
49 'enabled' => $enabled,
50 'description' => $description,
51 'is_constant' => $is_constant,
52 );
53 }
54
55 public static function get_modules(){
56 return self::$modules;
57 }
58
59 /**
60 * Handles saving module data.
61 */
62 public function save_modules(){
63 if (isset($_POST['action']) && $_POST['action'] == 'stateless_modules' && wp_verify_nonce($_POST['_smnonce'], 'wp-stateless-modules')) {
64 $modules = !empty($_POST['stateless-modules']) ? $_POST['stateless-modules'] : array();
65 $modules = apply_filters('stateless::modules::save', $modules);
66
67 update_option('stateless-modules', $modules, true);
68 }
69 }
70 }
71
72 abstract class ICompatibility{
73 protected $id = '';
74 protected $title = '';
75 protected $constant = '';
76 protected $description = '';
77
78 public function init(){
79 $is_constant = false;
80
81 if (defined($this->constant)) {
82 $this->enabled = constant($this->constant);
83 $is_constant = true;
84 }
85 else {
86 $modules = get_option('stateless-modules', array());
87 if (empty($this->enabled)) {
88 $this->enabled = !empty($modules[$this->id]) && $modules[$this->id] == 'true' ? true : false;
89 }
90 }
91
92 Module::register_module($this->id, $this->title, $this->description, $this->enabled, $is_constant);
93
94 if ($this->enabled) {
95 add_action('sm::module::init', array($this, 'module_init'));
96 }
97 }
98 }
99
100 }