PluginProbe ʕ •ᴥ•ʔ
Element Pack – Widgets, Templates & Addons for Elementor / 1.0.3
Element Pack – Widgets, Templates & Addons for Elementor v1.0.3
8.7.4 8.7.3 8.7.2 8.7.1 8.7.0 8.6.3 8.6.2 8.6.1 trunk 1.0 1.0.1 1.0.3 1.1.0 1.2.0 1.8.0 2.1.0 2.7.0 2.9.2 3.7.3 4.10.0 4.10.1 4.10.2 4.10.3 4.11.0 4.11.1 4.11.2 4.3.0 4.5.0 4.8.2 5.0.0 5.0.1 5.1.0 5.1.1 5.1.2 5.1.3 5.10.0 5.10.1 5.10.10 5.10.11 5.10.12 5.10.13 5.10.14 5.10.15 5.10.16 5.10.17 5.10.18 5.10.19 5.10.2 5.10.20 5.10.21 5.10.22 5.10.23 5.10.24 5.10.25 5.10.26 5.10.27 5.10.28 5.10.29 5.10.3 5.10.30 5.10.4 5.10.5 5.10.6 5.10.7 5.10.8 5.10.9 5.11.0 5.11.1 5.11.2 5.11.3 5.2.2 5.2.3 5.3.0 5.3.1 5.4.0 5.4.1 5.4.10 5.4.11 5.4.13 5.4.14 5.4.2 5.4.3 5.4.4 5.4.5 5.4.6 5.4.7 5.4.8 5.4.9 5.5.0 5.5.2 5.5.6 5.6.0 5.6.10 5.6.11 5.6.12 5.6.13 5.6.14 5.6.2 5.6.3 5.6.4 5.6.5 5.6.6 5.6.7 5.6.8 5.6.9 5.7.0 5.7.1 5.7.2 5.7.3 5.7.4 5.7.5 5.7.6 5.7.7 5.7.8 5.8.0 5.8.1 5.8.2 5.8.3 5.8.4 5.8.5 5.9.0 8.0.0 8.1.0 8.1.1 8.1.10 8.1.2 8.1.3 8.1.4 8.1.5 8.1.6 8.1.7 8.1.8 8.1.9 8.2.0 8.2.1 8.2.2 8.2.3 8.2.4 8.2.5 8.2.6 8.3.0 8.3.1 8.3.10 8.3.11 8.3.12 8.3.13 8.3.14 8.3.15 8.3.16 8.3.17 8.3.18 8.3.19 8.3.2 8.3.3 8.3.4 8.3.5 8.3.6 8.3.7 8.3.8 8.3.9 8.4.0 8.4.1 8.4.2 8.5.0 8.5.1 8.5.2 8.6.0
bdthemes-element-pack-lite / loader.php
bdthemes-element-pack-lite Last commit date
assets 6 years ago base 6 years ago includes 6 years ago languages 6 years ago modules 6 years ago bdthemes-element-pack-lite.php 6 years ago loader.php 6 years ago readme.txt 6 years ago
loader.php
363 lines
1 <?php
2 namespace ElementPack;
3
4 use Elementor\Utils;
5 use ElementPack\Includes\Element_Pack_WPML;
6
7 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
8
9 /**
10 * Main class for element pack
11 */
12 class Element_Pack_Loader {
13
14 /**
15 * @var Element_Pack_Loader
16 */
17 private static $_instance;
18
19 /**
20 * @var Manager
21 */
22 private $_modules_manager;
23
24 private $classes_aliases = [
25 'ElementPack\Modules\PanelPostsControl\Module' => 'ElementPack\Modules\QueryControl\Module',
26 'ElementPack\Modules\PanelPostsControl\Controls\Group_Control_Posts' => 'ElementPack\Modules\QueryControl\Controls\Group_Control_Posts',
27 'ElementPack\Modules\PanelPostsControl\Controls\Query' => 'ElementPack\Modules\QueryControl\Controls\Query',
28 ];
29
30 public $elements_data = [
31 'sections' => [],
32 'columns' => [],
33 'widgets' => [],
34 ];
35
36 /**
37 * @deprecated
38 *
39 * @return string
40 */
41 public function get_version() {
42 return BDTEP_VER;
43 }
44
45 /**
46 * return active theme
47 */
48 public function get_theme() {
49 return wp_get_theme();
50 }
51
52 /**
53 * Throw error on object clone
54 *
55 * The whole idea of the singleton design pattern is that there is a single
56 * object therefore, we don't want the object to be cloned.
57 *
58 * @since 1.0.0
59 * @return void
60 */
61 public function __clone() {
62 // Cloning instances of the class is forbidden
63 _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin&#8217; huh?', 'bdthemes-element-pack-lite' ), '1.6.0' );
64 }
65
66 /**
67 * Disable unserializing of the class
68 *
69 * @since 1.0.0
70 * @return void
71 */
72 public function __wakeup() {
73 // Unserializing instances of the class is forbidden
74 _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin&#8217; huh?', 'bdthemes-element-pack-lite' ), '1.6.0' );
75 }
76
77 /**
78 * @return \Elementor\Element_Pack_Loader
79 */
80
81 public static function elementor() {
82 return \Elementor\Plugin::$instance;
83 }
84
85 /**
86 * @return Element_Pack_Loader
87 */
88 public static function instance() {
89 if ( is_null( self::$_instance ) ) {
90 self::$_instance = new self();
91 }
92
93 return self::$_instance;
94 }
95
96
97
98 /**
99 * we loaded module manager + admin php from here
100 * @return [type] [description]
101 */
102 private function _includes() {
103
104 require BDTEP_INC_PATH . 'modules-manager.php';
105 require BDTEP_INC_PATH . 'class-elements-wpml-compatibility.php';
106
107 // Rooten theme header footer compatibility
108 if ('Rooten' === $this->get_theme()->name or 'Rooten' === $this->get_theme()->parent_theme) {
109 if (!class_exists('RootenCustomTemplate')) {
110 require BDTEP_INC_PATH . 'class-rooten-theme-compatibility.php';
111 }
112 }
113
114 if ( is_admin() ) {
115 if(!defined('BDTEP_CH')) {
116 require BDTEP_INC_PATH . 'admin.php';
117 // Load admin class for admin related content process
118 new Admin();
119 }
120 }
121
122 }
123
124 /**
125 * Autoloader function for all classes files
126 * @param [type] $class [description]
127 * @return [type] [description]
128 */
129 public function autoload( $class ) {
130 if ( 0 !== strpos( $class, __NAMESPACE__ ) ) {
131 return;
132 }
133
134 $has_class_alias = isset( $this->classes_aliases[ $class ] );
135
136 // Backward Compatibility: Save old class name for set an alias after the new class is loaded
137 if ( $has_class_alias ) {
138 $class_alias_name = $this->classes_aliases[ $class ];
139 $class_to_load = $class_alias_name;
140 } else {
141 $class_to_load = $class;
142 }
143
144 if ( ! class_exists( $class_to_load ) ) {
145 $filename = strtolower(
146 preg_replace(
147 [ '/^' . __NAMESPACE__ . '\\\/', '/([a-z])([A-Z])/', '/_/', '/\\\/' ],
148 [ '', '$1-$2', '-', DIRECTORY_SEPARATOR ],
149 $class_to_load
150 )
151 );
152 $filename = BDTEP_PATH . $filename . '.php';
153
154 if ( is_readable( $filename ) ) {
155 include( $filename );
156 }
157 }
158
159 if ( $has_class_alias ) {
160 class_alias( $class_alias_name, $class );
161 }
162 }
163
164 /**
165 * Register all script that need for any specific widget on call basis.
166 * @return [type] [description]
167 */
168 public function register_site_scripts() {
169
170 $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
171 $settings = get_option( 'element_pack_api_settings' );
172
173 wp_register_script( 'bdt-uikit-icons', BDTEP_URL . 'assets/js/bdt-uikit-icons' . $suffix . '.js', ['jquery', 'bdt-uikit'], '3.0.3', true );
174 wp_register_script( 'twentytwenty', BDTEP_URL . 'assets/vendor/js/jquery.twentytwenty' . $suffix . '.js', ['jquery'], '0.1.0', true );
175 wp_register_script( 'eventmove', BDTEP_URL . 'assets/vendor/js/jquery.event.move' . $suffix . '.js', ['jquery'], '2.0.0', true );
176 wp_register_script( 'aspieprogress', BDTEP_URL . 'assets/vendor/js/jquery-asPieProgress' . $suffix . '.js', ['jquery'], '0.4.7', true );
177 wp_register_script( 'cookieconsent', BDTEP_URL . 'assets/vendor/js/cookieconsent' . $suffix . '.js', ['jquery'], '3.1.0', true );
178
179
180 wp_register_script( 'recaptcha', 'https://www.google.com/recaptcha/api.js', ['jquery'], null, true );
181
182 wp_register_script( 'tilt', BDTEP_URL . 'assets/vendor/js/tilt.jquery' . $suffix . '.js', ['jquery'], null, true );
183 wp_register_script( 'bdt-justified-gallery', BDTEP_URL . 'assets/vendor/js/jquery.justifiedGallery' . $suffix . '.js', ['jquery'], '1.0.0', true );
184 }
185
186 public function register_site_styles() {
187 $direction_suffix = is_rtl() ? '.rtl' : '';
188
189 wp_register_style( 'twentytwenty', BDTEP_URL . 'assets/css/twentytwenty.css', [], BDTEP_VER );
190 wp_register_style( 'cookieconsent', BDTEP_URL . 'assets/css/cookieconsent' . $direction_suffix . '.css', [], BDTEP_VER );
191 }
192
193 /**
194 * Loading site related style from here.
195 * @return [type] [description]
196 */
197 public function enqueue_site_styles() {
198
199 $direction_suffix = is_rtl() ? '.rtl' : '';
200
201 wp_enqueue_style( 'element-pack-site', BDTEP_URL . 'assets/css/element-pack-site' . $direction_suffix . '.css', [], BDTEP_VER );
202 }
203
204
205 /**
206 * Loading site related script that needs all time such as uikit.
207 * @return [type] [description]
208 */
209 public function enqueue_site_scripts() {
210
211 $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
212
213 wp_enqueue_script( 'bdt-uikit', BDTEP_URL . 'assets/js/bdt-uikit' . $suffix . '.js', ['jquery'], BDTEP_VER );
214 wp_enqueue_script( 'element-pack-site', BDTEP_URL . 'assets/js/element-pack-site' . $suffix . '.js', ['jquery', 'elementor-frontend'], BDTEP_VER );
215
216 $script_config = [
217 'ajaxurl' => admin_url( 'admin-ajax.php' ),
218 'nonce' => wp_create_nonce( 'element-pack-site' ),
219 'contact_form' => [
220 'sending_msg' => esc_html_x('Sending message please wait...', 'Contact Form String', 'bdthemes-element-pack-lite'),
221 'captcha_nd' => esc_html_x('Invisible captcha not defined!', 'Contact Form String', 'bdthemes-element-pack-lite'),
222 'captcha_nr' => esc_html_x('Could not get invisible captcha response!', 'Contact Form String', 'bdthemes-element-pack-lite'),
223
224 ],
225 'elements_data' => $this->elements_data,
226 ];
227
228
229 // localize for user login widget ajax login script
230 wp_localize_script( 'bdt-uikit', 'element_pack_ajax_login_config', array(
231 'ajaxurl' => admin_url( 'admin-ajax.php' ),
232 'loadingmessage' => esc_html__('Sending user info, please wait...', 'bdthemes-element-pack-lite'),
233 ));
234
235 $script_config = apply_filters( 'element_pack/frontend/localize_settings', $script_config );
236
237 // TODO for editor script
238 wp_localize_script( 'bdt-uikit', 'ElementPackConfig', $script_config );
239
240 }
241
242 public function enqueue_admin_scripts() {
243
244 $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
245
246 wp_enqueue_script( 'element-pack-admin', BDTEP_URL . 'assets/js/element-pack-admin' . $suffix . '.js', ['jquery'], BDTEP_VER, true );
247 }
248
249 /**
250 * Load editor editor related style from here
251 * @return [type] [description]
252 */
253 public function enqueue_preview_styles() {
254 $direction_suffix = is_rtl() ? '.rtl' : '';
255
256 wp_enqueue_style('element-pack-preview', BDTEP_URL . 'assets/css/element-pack-preview' . $direction_suffix . '.css', '', BDTEP_VER );
257 }
258
259
260 public function enqueue_editor_styles() {
261 $direction_suffix = is_rtl() ? '.rtl' : '';
262
263 wp_enqueue_style('element-pack-editor', BDTEP_URL . 'assets/css/element-pack-editor' . $direction_suffix . '.css', '', BDTEP_VER );
264 }
265
266
267 /**
268 * Callback to shortcode.
269 * @param array $atts attributes for shortcode.
270 */
271 public function shortcode_template( $atts ) {
272
273 $atts = shortcode_atts(
274 array(
275 'id' => '',
276 ),
277 $atts,
278 'rooten_custom_template'
279 );
280
281 $id = ! empty( $atts['id'] ) ? intval( $atts['id'] ) : '';
282
283 if ( empty( $id ) ) {
284 return '';
285 }
286
287 if ( class_exists( '\Elementor\Post_CSS_File' ) ) {
288
289 // Load elementor styles.
290 $css_file = new \Elementor\Post_CSS_File( $id );
291 $css_file->enqueue();
292 }
293
294 return self::$elementor_instance->frontend->get_builder_content_for_display( $id );
295
296 }
297
298
299
300
301 // Load WPML compatibility instance
302 public function wpml_compatiblity() {
303 return Element_Pack_WPML::get_instance();
304 }
305
306
307 /**
308 * initialize the category
309 * @return [type] [description]
310 */
311 public function element_pack_init() {
312 $this->_modules_manager = new Manager();
313
314 $elementor = \Elementor\Plugin::$instance;
315
316 // Add element category in panel
317 $elementor->elements_manager->add_category( BDTEP_SLUG, [ 'title' => BDTEP_TITLE, 'icon' => 'font' ], 1 );
318
319 do_action( 'bdthemes_element_pack/init' );
320 }
321
322 private function setup_hooks() {
323 add_action( 'elementor/init', [ $this, 'element_pack_init' ] );
324 add_action( 'elementor/editor/after_enqueue_styles', [ $this, 'enqueue_editor_styles' ] );
325
326 add_action( 'elementor/frontend/before_register_styles', [ $this, 'register_site_styles' ] );
327 add_action( 'elementor/frontend/before_register_scripts', [ $this, 'register_site_scripts' ] );
328
329 add_action( 'elementor/preview/enqueue_styles', [ $this, 'enqueue_preview_styles' ] );
330
331 add_action( 'elementor/frontend/after_register_styles', [ $this, 'enqueue_site_styles' ] );
332 add_action( 'elementor/frontend/before_enqueue_scripts', [ $this, 'enqueue_site_scripts' ] );
333
334 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_scripts' ] );
335
336 add_shortcode( 'rooten_custom_template', array( $this, 'shortcode_template' ) );
337
338 }
339
340 /**
341 * Element_Pack_Loader constructor.
342 */
343 private function __construct() {
344 // Register class automatically
345 spl_autoload_register( [ $this, 'autoload' ] );
346 // Include some backend files
347 $this->_includes();
348 // Finally hooked up all things here
349 $this->setup_hooks();
350
351 $this->wpml_compatiblity()->init();
352 }
353 }
354
355 if ( ! defined( 'BDTEP_TESTS' ) ) {
356 // In tests we run the instance manually.
357 Element_Pack_Loader::instance();
358 }
359
360 // handy fundtion for push data
361 function element_pack_config() {
362 return Element_Pack_Loader::instance();
363 }