admin
2 years ago
components
2 years ago
data
2 years ago
elementor
2 years ago
gutenberg
2 years ago
library
2 years ago
class-config.php
2 years ago
class-plugin.php
2 years ago
class-plugin.php
194 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SuperbAddons; |
| 4 | |
| 5 | defined('ABSPATH') || exit(); |
| 6 | |
| 7 | use Exception; |
| 8 | use SuperbAddons\Elementor\Controllers\ElementorController; |
| 9 | use SuperbAddons\Admin\Controllers\DashboardController; |
| 10 | use SuperbAddons\Data\Controllers\LogController; |
| 11 | use SuperbAddons\Data\Controllers\RestController; |
| 12 | use SuperbAddons\Gutenberg\Controllers\GutenbergController; |
| 13 | use SuperbAddons\Library\Controllers\LibraryRequestController; |
| 14 | |
| 15 | class SuperbAddonsPlugin |
| 16 | { |
| 17 | private static $instance; |
| 18 | |
| 19 | public static function GetInstance() |
| 20 | { |
| 21 | if (!isset(self::$instance)) { |
| 22 | self::$instance = new self(); |
| 23 | } |
| 24 | return self::$instance; |
| 25 | } |
| 26 | |
| 27 | public function __construct() |
| 28 | { |
| 29 | register_activation_hook(SUPERBADDONS_BASE_PATH, array($this, 'ActivationHookFunction')); |
| 30 | register_deactivation_hook(SUPERBADDONS_BASE_PATH, array($this, 'DeactivationHookFunction')); |
| 31 | new DashboardController(); |
| 32 | new GutenbergController(); |
| 33 | new ElementorController(); |
| 34 | new LibraryRequestController(); |
| 35 | LogController::AddCronAction(); |
| 36 | RestController::RegisterRoutes(); |
| 37 | add_filter('wp_theme_json_data_default', array($this, 'UpdateThemeJsonDefaults')); |
| 38 | } |
| 39 | |
| 40 | public function UpdateThemeJsonDefaults($theme_json) |
| 41 | { |
| 42 | $defaults = array( |
| 43 | 'version' => '2', |
| 44 | 'settings' => array( |
| 45 | "appearanceTools" => true, |
| 46 | "spacing" => [ |
| 47 | "spacingScale" => [ |
| 48 | "steps" => 0 |
| 49 | ], |
| 50 | "spacingSizes" => [ |
| 51 | [ |
| 52 | "name" => "xxSmall", |
| 53 | "size" => "clamp(5px, 1vw, 10px)", |
| 54 | "slug" => "superbspacing-xxsmall" |
| 55 | ], |
| 56 | [ |
| 57 | "name" => "xSmall", |
| 58 | "size" => "clamp(10px, 2vw, 20px)", |
| 59 | "slug" => "superbspacing-xsmall" |
| 60 | ], |
| 61 | [ |
| 62 | "name" => "Small", |
| 63 | "size" => "clamp(20px, 4vw, 40px)", |
| 64 | "slug" => "superbspacing-small" |
| 65 | ], |
| 66 | [ |
| 67 | "name" => "Medium", |
| 68 | "size" => "clamp(30px, 6vw, 60px)", |
| 69 | "slug" => "superbspacing-medium" |
| 70 | ], |
| 71 | [ |
| 72 | "name" => "Large", |
| 73 | "size" => "clamp(40px, 8vw, 80px)", |
| 74 | "slug" => "superbspacing-large" |
| 75 | ], |
| 76 | [ |
| 77 | "name" => "xLarge", |
| 78 | "size" => "clamp(50px, 10vw, 100px)", |
| 79 | "slug" => "superbspacing-xlarge" |
| 80 | ], |
| 81 | [ |
| 82 | "name" => "xxLarge", |
| 83 | "size" => "clamp(60px, 12vw, 120px)", |
| 84 | "slug" => "superbspacing-xxlarge" |
| 85 | ] |
| 86 | ], |
| 87 | "units" => [ |
| 88 | "%", |
| 89 | "px", |
| 90 | "em", |
| 91 | "rem", |
| 92 | "vh", |
| 93 | "vw" |
| 94 | ] |
| 95 | ], |
| 96 | "typography" => [ |
| 97 | "dropCap" => false, |
| 98 | "fluid" => true, |
| 99 | "fontSizes" => [ |
| 100 | [ |
| 101 | "name" => "Tiny", |
| 102 | "slug" => "superbfont-tiny", |
| 103 | "size" => "0.9rem", |
| 104 | "fluid" => [ |
| 105 | "min" => "0.8rem", |
| 106 | "max" => "0.9rem" |
| 107 | ] |
| 108 | ], |
| 109 | [ |
| 110 | "name" => "xxSmall", |
| 111 | "slug" => "superbfont-xxsmall", |
| 112 | "size" => "1rem", |
| 113 | "fluid" => [ |
| 114 | "min" => "0.9rem", |
| 115 | "max" => "1rem" |
| 116 | ] |
| 117 | ], |
| 118 | [ |
| 119 | "name" => "xSmall", |
| 120 | "slug" => "superbfont-xsmall", |
| 121 | "size" => "1.1rem", |
| 122 | "fluid" => [ |
| 123 | "min" => "1rem", |
| 124 | "max" => "1.1rem" |
| 125 | ] |
| 126 | ], |
| 127 | [ |
| 128 | "name" => "Small", |
| 129 | "slug" => "superbfont-small", |
| 130 | "size" => "1.5rem", |
| 131 | "fluid" => [ |
| 132 | "min" => "1rem", |
| 133 | "max" => "1.5rem" |
| 134 | ] |
| 135 | ], |
| 136 | [ |
| 137 | "name" => "Medium", |
| 138 | "slug" => "superbfont-medium", |
| 139 | "size" => "2rem", |
| 140 | "fluid" => [ |
| 141 | "min" => "1.2rem", |
| 142 | "max" => "2rem" |
| 143 | ] |
| 144 | ], |
| 145 | [ |
| 146 | "name" => "Large", |
| 147 | "slug" => "superbfont-large", |
| 148 | "size" => "3rem", |
| 149 | "fluid" => [ |
| 150 | "min" => "1.5rem", |
| 151 | "max" => "3rem" |
| 152 | ] |
| 153 | ], |
| 154 | [ |
| 155 | "name" => "xLarge", |
| 156 | "slug" => "superbfont-xlarge", |
| 157 | "size" => "4rem", |
| 158 | "fluid" => [ |
| 159 | "min" => "2rem", |
| 160 | "max" => "4rem" |
| 161 | ] |
| 162 | ], |
| 163 | [ |
| 164 | "name" => "xxLarge", |
| 165 | "slug" => "superbfont-xxlarge", |
| 166 | "size" => "5rem", |
| 167 | "fluid" => [ |
| 168 | "min" => "2.5rem", |
| 169 | "max" => "5rem" |
| 170 | ] |
| 171 | ] |
| 172 | ] |
| 173 | ] |
| 174 | ), |
| 175 | ); |
| 176 | |
| 177 | return $theme_json->update_with($defaults); |
| 178 | } |
| 179 | |
| 180 | public function ActivationHookFunction() |
| 181 | { |
| 182 | try { |
| 183 | add_option('superbaddons_pre_activation', time(), false); |
| 184 | } catch (Exception $e) { |
| 185 | LogController::HandleException($e); |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | public function DeactivationHookFunction() |
| 190 | { |
| 191 | LogController::MaybeUnsubscribeCron(); |
| 192 | } |
| 193 | } |
| 194 |