PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.3.16
UiCore Elements – Free widgets and templates for Elementor v1.3.16
1.3.16 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 All 40 releases
uicore-elements / plugin.php

plugin.php in UiCore Elements – Free widgets and templates for Elementor 1.3.16, at plugin.php

247 lines 5.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: UiCore Elements
4 Plugin URI: https://elements.uicore.co
5 Description: Free widgets and templates for Elementor
6 Version: 1.3.16
7 Author: UiCore
8 Author URI: https://uicore.co
9 License: GPL3
10 Text Domain: uicore-elements
11 Domain Path: /languages
12 * Elementor requires at least: 3.19.2
13 * Elementor tested up to: 4.2.0
14 */
15
16 namespace UiCoreElements;
17
18 // don't call the file directly
19 if (!defined('ABSPATH')) exit;
20
21 /**
22 * Base class
23 *
24 * @class Base The class that holds the entire plugin
25 */
26 final class Base
27 {
28
29 /**
30 * Plugin version
31 *
32 * @var string
33 */
34 public $version = '1.3.16';
35
36 /**
37 * Holds various class instances
38 *
39 * @var array
40 */
41 private $container = array();
42
43 /**
44 * Constructor for the Base class
45 *
46 * Sets up all the appropriate hooks and actions
47 * within our plugin.
48 */
49 public function __construct()
50 {
51
52 $this->define_constants();
53
54 register_activation_hook(__FILE__, array($this, 'activate'));
55 register_deactivation_hook(__FILE__, array($this, 'deactivate'));
56
57 add_action('plugins_loaded', array($this, 'init_plugin'));
58 }
59
60 /**
61 * Initializes the Base() class
62 *
63 * Checks for an existing Base() instance
64 * and if it doesn't find one, creates it.
65 */
66 public static function init()
67 {
68 static $instance = false;
69
70 if (! $instance) {
71 $instance = new Base();
72 }
73
74 return $instance;
75 }
76
77 /**
78 * Magic getter to bypass referencing plugin.
79 *
80 * @param $prop
81 *
82 * @return mixed
83 */
84 public function __get($prop)
85 {
86 if (array_key_exists($prop, $this->container)) {
87 return $this->container[$prop];
88 }
89
90 return $this->{$prop};
91 }
92
93 /**
94 * Magic isset to bypass referencing plugin.
95 *
96 * @param $prop
97 *
98 * @return mixed
99 */
100 public function __isset($prop)
101 {
102 return isset($this->{$prop}) || isset($this->container[$prop]);
103 }
104
105 /**
106 * Define the constants
107 *
108 * @return void
109 */
110 public function define_constants()
111 {
112 define('UICORE_ELEMENTS_VERSION', $this->version);
113 define('UICORE_ELEMENTS_FILE', __FILE__);
114 define('UICORE_ELEMENTS_PATH', dirname(UICORE_ELEMENTS_FILE));
115 define('UICORE_ELEMENTS_INCLUDES', UICORE_ELEMENTS_PATH . '/includes');
116 define('UICORE_ELEMENTS_URL', plugins_url('', UICORE_ELEMENTS_FILE));
117 define('UICORE_ELEMENTS_ASSETS', UICORE_ELEMENTS_URL . '/assets');
118 define('UICORE_ELEMENTS_BADGE', '<span title="Powered by UiCore Elements" style="font-size:10px;font-weight:500;background:#5dbad8;color:black;padding:2px 5px;border-radius:3px;margin-right:4px;">UiCore</span> ');
119 define('UICORE_ELEMENTS_NEW_OPTION', '<span title="New" style="font-size:10px;font-weight:500;background:#532df5;color:white;padding:2px 5px;border-radius:3px;margin-left:4px;line-height: 2em;">New</span> ');
120 }
121
122 /**
123 * Load the plugin after all plugis are loaded
124 *
125 * @return void
126 */
127 public function init_plugin()
128 {
129 if (\class_exists('Elementor\Plugin')) {
130 $this->includes();
131 $this->init_hooks();
132 }
133 }
134
135 /**
136 * Placeholder for activation function
137 *
138 * Nothing being called here yet.
139 */
140 public function activate()
141 {
142
143 $installed = get_option('uicore_elements_installed');
144
145 if (! $installed) {
146 update_option('uicore_elements_installed', time());
147 }
148
149 update_option('uicore_elements_version', UICORE_ELEMENTS_VERSION);
150 }
151
152 /**
153 * Placeholder for deactivation function
154 *
155 * Nothing being called here yet.
156 */
157 public function deactivate() {}
158
159 /**
160 * Include the required files
161 *
162 * @return void
163 */
164 public function includes()
165 {
166
167 require_once UICORE_ELEMENTS_INCLUDES . '/class-assets.php';
168 require_once UICORE_ELEMENTS_INCLUDES . '/class-elementor.php';
169 require_once UICORE_ELEMENTS_INCLUDES . '/class-design-cloud.php';
170 require_once UICORE_ELEMENTS_INCLUDES . '/class-rest-api.php';
171 require_once UICORE_ELEMENTS_INCLUDES . '/class-helper.php';
172
173 if ($this->is_request('admin')) {
174 require_once UICORE_ELEMENTS_INCLUDES . '/class-admin.php';
175 }
176
177 if ($this->is_request('frontend')) {
178 require_once UICORE_ELEMENTS_INCLUDES . '/class-frontend.php';
179 }
180 }
181
182 /**
183 * Initialize the hooks
184 *
185 * @return void
186 */
187 public function init_hooks()
188 {
189
190 add_action('init', array($this, 'init_classes'));
191
192 // Localize our plugin
193 add_action('init', array($this, 'localization_setup'));
194 }
195
196 /**
197 * Instantiate the required classes
198 *
199 * @return void
200 */
201 public function init_classes()
202 {
203
204 new REST_API();
205 new Elementor();
206 if ($this->is_request('admin')) {
207 $this->container['admin'] = new Admin();
208 }
209
210 if ($this->is_request('frontend')) {
211 $this->container['frontend'] = new Frontend();
212 }
213
214 $this->container['assets'] = new Assets();
215 }
216
217 /**
218 * Initialize plugin for localization
219 *
220 * @uses load_plugin_textdomain()
221 */
222 public function localization_setup()
223 {
224 load_plugin_textdomain('uicore-elements', false, dirname(plugin_basename(__FILE__)) . '/languages/');
225 }
226
227 /**
228 * What type of request is this?
229 *
230 * @param string $type admin, ajax, cron or frontend.
231 *
232 * @return bool
233 */
234 private function is_request($type)
235 {
236 switch ($type) {
237 case 'admin':
238 return is_admin();
239
240 case 'frontend':
241 return (! is_admin() || defined('DOING_AJAX')) && ! defined('DOING_CRON');
242 }
243 }
244 } // Base
245
246 $uicore_elements = Base::init();
247