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