PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.0.8
UiCore Elements – Free widgets and templates for Elementor v1.0.8
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.0.8, at plugin.php

234 lines 5.4 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.0.8
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.23.2
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.0.8';
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 }
112
113 /**
114 * Load the plugin after all plugis are loaded
115 *
116 * @return void
117 */
118 public function init_plugin() {
119 if(\class_exists('Elementor\Plugin')){
120 $this->includes();
121 $this->init_hooks();
122 }
123 }
124
125 /**
126 * Placeholder for activation function
127 *
128 * Nothing being called here yet.
129 */
130 public function activate() {
131
132 $installed = get_option( 'uicore_elements_installed' );
133
134 if ( ! $installed ) {
135 update_option( 'uicore_elements_installed', time() );
136 }
137
138 update_option( 'uicore_elements_version', UICORE_ELEMENTS_VERSION );
139 }
140
141 /**
142 * Placeholder for deactivation function
143 *
144 * Nothing being called here yet.
145 */
146 public function deactivate() {
147
148 }
149
150 /**
151 * Include the required files
152 *
153 * @return void
154 */
155 public function includes() {
156
157 require_once UICORE_ELEMENTS_INCLUDES . '/class-assets.php';
158 require_once UICORE_ELEMENTS_INCLUDES . '/class-elementor.php';
159 require_once UICORE_ELEMENTS_INCLUDES . '/class-rest-api.php';
160 require_once UICORE_ELEMENTS_INCLUDES . '/class-helper.php';
161
162 if ( $this->is_request( 'admin' ) ) {
163 require_once UICORE_ELEMENTS_INCLUDES . '/class-admin.php';
164 }
165
166 if ( $this->is_request( 'frontend' ) ) {
167 require_once UICORE_ELEMENTS_INCLUDES . '/class-frontend.php';
168 }
169
170 }
171
172 /**
173 * Initialize the hooks
174 *
175 * @return void
176 */
177 public function init_hooks() {
178
179 add_action( 'init', array( $this, 'init_classes' ) );
180
181 // Localize our plugin
182 add_action( 'init', array( $this, 'localization_setup' ) );
183 }
184
185 /**
186 * Instantiate the required classes
187 *
188 * @return void
189 */
190 public function init_classes() {
191
192 new REST_API();
193 new Elementor();
194 if ( $this->is_request( 'admin' ) ) {
195 $this->container['admin'] = new Admin();
196 }
197
198 if ( $this->is_request( 'frontend' ) ) {
199 $this->container['frontend'] = new Frontend();
200 }
201
202 $this->container['assets'] = new Assets();
203 }
204
205 /**
206 * Initialize plugin for localization
207 *
208 * @uses load_plugin_textdomain()
209 */
210 public function localization_setup() {
211 load_plugin_textdomain( 'uicore-elements', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
212 }
213
214 /**
215 * What type of request is this?
216 *
217 * @param string $type admin, ajax, cron or frontend.
218 *
219 * @return bool
220 */
221 private function is_request( $type ) {
222 switch ( $type ) {
223 case 'admin' :
224 return is_admin();
225
226 case 'frontend' :
227 return ( ! is_admin() || defined( 'DOING_AJAX' ) ) && ! defined( 'DOING_CRON' );
228 }
229 }
230
231 } // Base
232
233 $uicore_elements = Base::init();
234