PluginProbe ʕ •ᴥ•ʔ
Element Pack – Widgets, Templates & Addons for Elementor / 1.0
Element Pack – Widgets, Templates & Addons for Elementor v1.0
8.7.5 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
365 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( 'popper', BDTEP_URL . 'assets/vendor/js/popper' . $suffix . '.js', ['jquery'], null, true );
183 wp_register_script( 'tippyjs', BDTEP_URL . 'assets/vendor/js/tippy.all' . $suffix . '.js', ['jquery'], null, true );
184 wp_register_script( 'tilt', BDTEP_URL . 'assets/vendor/js/tilt.jquery' . $suffix . '.js', ['jquery'], null, true );
185 wp_register_script( 'bdt-justified-gallery', BDTEP_URL . 'assets/vendor/js/jquery.justifiedGallery' . $suffix . '.js', ['jquery'], '1.0.0', true );
186 }
187
188 public function register_site_styles() {
189 $direction_suffix = is_rtl() ? '.rtl' : '';
190
191 wp_register_style( 'twentytwenty', BDTEP_URL . 'assets/css/twentytwenty.css', [], BDTEP_VER );
192 wp_register_style( 'cookieconsent', BDTEP_URL . 'assets/css/cookieconsent' . $direction_suffix . '.css', [], BDTEP_VER );
193 }
194
195 /**
196 * Loading site related style from here.
197 * @return [type] [description]
198 */
199 public function enqueue_site_styles() {
200
201 $direction_suffix = is_rtl() ? '.rtl' : '';
202
203 wp_enqueue_style( 'element-pack-site', BDTEP_URL . 'assets/css/element-pack-site' . $direction_suffix . '.css', [], BDTEP_VER );
204 }
205
206
207 /**
208 * Loading site related script that needs all time such as uikit.
209 * @return [type] [description]
210 */
211 public function enqueue_site_scripts() {
212
213 $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
214
215 wp_enqueue_script( 'bdt-uikit', BDTEP_URL . 'assets/js/bdt-uikit' . $suffix . '.js', ['jquery'], BDTEP_VER );
216 wp_enqueue_script( 'element-pack-site', BDTEP_URL . 'assets/js/element-pack-site' . $suffix . '.js', ['jquery', 'elementor-frontend'], BDTEP_VER );
217
218 $script_config = [
219 'ajaxurl' => admin_url( 'admin-ajax.php' ),
220 'nonce' => wp_create_nonce( 'element-pack-site' ),
221 'contact_form' => [
222 'sending_msg' => esc_html_x('Sending message please wait...', 'Contact Form String', 'bdthemes-element-pack-lite'),
223 'captcha_nd' => esc_html_x('Invisible captcha not defined!', 'Contact Form String', 'bdthemes-element-pack-lite'),
224 'captcha_nr' => esc_html_x('Could not get invisible captcha response!', 'Contact Form String', 'bdthemes-element-pack-lite'),
225
226 ],
227 'elements_data' => $this->elements_data,
228 ];
229
230
231 // localize for user login widget ajax login script
232 wp_localize_script( 'bdt-uikit', 'element_pack_ajax_login_config', array(
233 'ajaxurl' => admin_url( 'admin-ajax.php' ),
234 'loadingmessage' => esc_html__('Sending user info, please wait...', 'bdthemes-element-pack-lite'),
235 ));
236
237 $script_config = apply_filters( 'element_pack/frontend/localize_settings', $script_config );
238
239 // TODO for editor script
240 wp_localize_script( 'bdt-uikit', 'ElementPackConfig', $script_config );
241
242 }
243
244 public function enqueue_admin_scripts() {
245
246 $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
247
248 wp_enqueue_script( 'element-pack-admin', BDTEP_URL . 'assets/js/element-pack-admin' . $suffix . '.js', ['jquery'], BDTEP_VER, true );
249 }
250
251 /**
252 * Load editor editor related style from here
253 * @return [type] [description]
254 */
255 public function enqueue_preview_styles() {
256 $direction_suffix = is_rtl() ? '.rtl' : '';
257
258 wp_enqueue_style('element-pack-preview', BDTEP_URL . 'assets/css/element-pack-preview' . $direction_suffix . '.css', '', BDTEP_VER );
259 }
260
261
262 public function enqueue_editor_styles() {
263 $direction_suffix = is_rtl() ? '.rtl' : '';
264
265 wp_enqueue_style('element-pack-editor', BDTEP_URL . 'assets/css/element-pack-editor' . $direction_suffix . '.css', '', BDTEP_VER );
266 }
267
268
269 /**
270 * Callback to shortcode.
271 * @param array $atts attributes for shortcode.
272 */
273 public function shortcode_template( $atts ) {
274
275 $atts = shortcode_atts(
276 array(
277 'id' => '',
278 ),
279 $atts,
280 'rooten_custom_template'
281 );
282
283 $id = ! empty( $atts['id'] ) ? intval( $atts['id'] ) : '';
284
285 if ( empty( $id ) ) {
286 return '';
287 }
288
289 if ( class_exists( '\Elementor\Post_CSS_File' ) ) {
290
291 // Load elementor styles.
292 $css_file = new \Elementor\Post_CSS_File( $id );
293 $css_file->enqueue();
294 }
295
296 return self::$elementor_instance->frontend->get_builder_content_for_display( $id );
297
298 }
299
300
301
302
303 // Load WPML compatibility instance
304 public function wpml_compatiblity() {
305 return Element_Pack_WPML::get_instance();
306 }
307
308
309 /**
310 * initialize the category
311 * @return [type] [description]
312 */
313 public function element_pack_init() {
314 $this->_modules_manager = new Manager();
315
316 $elementor = \Elementor\Plugin::$instance;
317
318 // Add element category in panel
319 $elementor->elements_manager->add_category( BDTEP_SLUG, [ 'title' => BDTEP_TITLE, 'icon' => 'font' ], 1 );
320
321 do_action( 'bdthemes_element_pack/init' );
322 }
323
324 private function setup_hooks() {
325 add_action( 'elementor/init', [ $this, 'element_pack_init' ] );
326 add_action( 'elementor/editor/after_enqueue_styles', [ $this, 'enqueue_editor_styles' ] );
327
328 add_action( 'elementor/frontend/before_register_styles', [ $this, 'register_site_styles' ] );
329 add_action( 'elementor/frontend/before_register_scripts', [ $this, 'register_site_scripts' ] );
330
331 add_action( 'elementor/preview/enqueue_styles', [ $this, 'enqueue_preview_styles' ] );
332
333 add_action( 'elementor/frontend/after_register_styles', [ $this, 'enqueue_site_styles' ] );
334 add_action( 'elementor/frontend/before_enqueue_scripts', [ $this, 'enqueue_site_scripts' ] );
335
336 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_scripts' ] );
337
338 add_shortcode( 'rooten_custom_template', array( $this, 'shortcode_template' ) );
339
340 }
341
342 /**
343 * Element_Pack_Loader constructor.
344 */
345 private function __construct() {
346 // Register class automatically
347 spl_autoload_register( [ $this, 'autoload' ] );
348 // Include some backend files
349 $this->_includes();
350 // Finally hooked up all things here
351 $this->setup_hooks();
352
353 $this->wpml_compatiblity()->init();
354 }
355 }
356
357 if ( ! defined( 'BDTEP_TESTS' ) ) {
358 // In tests we run the instance manually.
359 Element_Pack_Loader::instance();
360 }
361
362 // handy fundtion for push data
363 function element_pack_config() {
364 return Element_Pack_Loader::instance();
365 }