PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.2.4
UiCore Elements – Free widgets and templates for Elementor v1.2.4
1.3.17 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 All 41 releases
uicore-elements / plugin.php

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

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