PluginProbe
Easy Elements for Elementor – Addons & Website Templates / 1.0.6
Easy Elements for Elementor – Addons & Website Templates v1.0.6
1.5.3 1.5.2 1.5.1 1.5.0 1.4.9 1.4.6 1.4.7 1.4.8 1.4.5 1.4.4 1.4.3 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 All 47 releases
easy-elements / base.php

base.php in Easy Elements for Elementor – Addons & Website Templates 1.0.6, at base.php

404 lines 11.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit;
4 }
5
6 final class Easyel_Elements_Elementor_Extension {
7
8 const VERSION = EASYELEMENTS_VER;
9
10 private static $_instance = null;
11
12 public static function instance() {
13 if ( is_null( self::$_instance ) ) {
14 self::$_instance = new self();
15 }
16 return self::$_instance;
17 }
18
19 public function __construct() {
20 add_action( 'init', [ $this, 'init' ] );
21
22 }
23
24 public function init() {
25 // Safety checks
26
27 add_action( 'elementor/widgets/register', [ $this, 'init_widgets' ], -1 );
28 add_action( 'elementor/elements/categories_registered', [ $this, 'add_elementor_categories' ],-99 );
29
30 add_filter( 'body_class', [ $this, "easy_add_extra_body_class" ] );
31 add_action( 'easy_header', [ $this, 'easyel_before_content_container_hfe'], 20 );
32 add_action( 'easy_footer', [ $this, 'easyel_after_content_container_hfe' ], 5 );
33
34 add_action( 'admin_notices', [ $this, 'easyelements_admin_notice_missing_elementor' ] );
35
36 }
37
38 public function easyelements_admin_notice_missing_elementor() {
39
40 $elementor = 'elementor/elementor.php';
41
42 if ( current_user_can( 'activate_plugins' ) && isset( $_GET['activate'], $_GET['_wpnonce'] ) ) {
43
44 $nonce = isset( $_GET['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_GET['_wpnonce'] ) ) : '';
45
46 if ( wp_verify_nonce( $nonce, 'activate-plugin_' . $elementor ) ) {
47 unset( $_GET['activate'] );
48 }
49 }
50
51 if ( ! current_user_can( 'install_plugins' ) ) {
52 return;
53 }
54
55 $elementor = 'elementor/elementor.php';
56 $elementor_path = WP_PLUGIN_DIR . '/' . $elementor;
57
58 $is_installed = file_exists( $elementor_path );
59 $is_active = function_exists( 'is_plugin_active' ) && is_plugin_active( $elementor );
60
61 if ( $is_active ) {
62 return;
63 }
64
65 if ( $is_installed ) {
66 $action_url = wp_nonce_url(
67 self_admin_url( 'plugins.php?action=activate&plugin=' . $elementor ),
68 'activate-plugin_' . $elementor
69 );
70
71 $button_label = esc_html__( 'Activate Elementor', 'easy-elements' );
72 $notice_text = esc_html__( 'Easy Elements is not working because the Elementor plugin is inactive.', 'easy-elements' );
73
74 } else {
75 $action_url = wp_nonce_url(
76 self_admin_url( 'update.php?action=install-plugin&plugin=elementor' ),
77 'install-plugin_elementor'
78 );
79
80 $button_label = esc_html__( 'Install Elementor', 'easy-elements' );
81 $notice_text = esc_html__( 'Easy Elements requires the Elementor plugin to be installed.', 'easy-elements' );
82 }
83
84 $message = '<p>' . $notice_text . '</p>';
85 $message .= '<p><a href="' . esc_url( $action_url ) . '" class="button-primary">' . $button_label . '</a></p>';
86
87 printf(
88 '<div class="notice notice-error is-dismissible">%s</div>',
89 wp_kses_post( $message )
90 );
91 }
92
93 // Container Full site
94 public function easyel_before_content_container_hfe() {
95 if ( is_admin() ) return;
96 if ( function_exists( 'elementor_theme_do_location' ) && \Elementor\Plugin::$instance->preview->is_preview() ) {
97 return;
98 }
99 echo '<div class="easyel-content-container">';
100 }
101
102 /**
103 * Close container before HFE Footer
104 */
105 function easyel_after_content_container_hfe() {
106 if ( is_admin() ) return;
107 if ( function_exists( 'elementor_theme_do_location' ) && \Elementor\Plugin::$instance->preview->is_preview() ) {
108 return;
109 }
110 echo '</div>';
111 }
112
113 public function easy_add_extra_body_class( $classes ) {
114 if ( is_plugin_active( 'easy-elements/easy-elements.php' ) ) {
115 $classes[] = 'eel-easy-elements';
116 }
117
118 return $classes;
119 }
120
121 public function add_elementor_categories( $elements_manager ) {
122
123 $new_categories = [
124 'easyelements_category' => [
125 'title' => __( 'Easy Elements', 'easy-elements' ),
126 'icon' => 'fa fa-plug',
127 ],
128 'easyelements_post_category' => [
129 'title' => __( 'Easy Post Type Elements', 'easy-elements' ),
130 'icon' => 'fa fa-file-alt',
131 ],
132 'easyelements_header_footer_category' => [
133 'title' => __( 'Easy Header Footer Elements', 'easy-elements' ),
134 'icon' => 'fa fa-header',
135 ],
136 'easyelements_category_form' => [
137 'title' => __( 'Easy Elements Form', 'easy-elements' ),
138 'icon' => 'fa fa-plug',
139 ],
140 'easyelements_category_pro' => [
141 'title' => __( 'Easy Elements Pro', 'easy-elements' ),
142 'icon' => 'fa fa-plug',
143 ],
144 ];
145
146 $existing = $elements_manager->get_categories();
147 $final_list = [];
148
149 foreach ( $existing as $key => $cat ) {
150 $final_list[ $key ] = $cat;
151
152 if ( $key === 'layout' ) {
153 foreach ( $new_categories as $new_key => $new_cat ) {
154 $final_list[ $new_key ] = $new_cat;
155 }
156 }
157 }
158
159 $apply_categories = function( $cats ) {
160 $this->categories = $cats;
161 };
162
163 $apply_categories->call( $elements_manager, $final_list );
164 }
165
166 public function init_widgets() {
167 $widgets_manager = \Elementor\Plugin::instance()->widgets_manager;
168
169 $widgets = [
170 'site_logo' => [
171 'class' => '\Easyel_Site_Logo_Widget',
172 'file' => __DIR__ . '/widgets/site-logo/site-logo.php',
173 'tab' => 'widget',
174 ],
175 'heading' => [
176 'class' => '\Easyel_Heading_Widget',
177 'file' => __DIR__ . '/widgets/heading/heading.php',
178 'tab' => 'widget',
179 ],
180 'clients_logo' => [
181 'class' => '\Easyel_Clients_Logo__Widget',
182 'file' => __DIR__ . '/widgets/clients-logo-grid/logo.php',
183 'tab' => 'widget',
184 ],
185 'icon_box' => [
186 'class' => '\Easyel_Icon_Box__Widget',
187 'file' => __DIR__ . '/widgets/icon-box/icon.php',
188 'tab' => 'widget',
189 ],
190 'tab' => [
191 'class' => '\Easyel_Tab_Widget',
192 'file' => __DIR__ . '/widgets/tab/tab.php',
193 'tab' => 'widget',
194 ],
195 'testimonials' => [
196 'class' => '\Easyel_Testimonials__Widget',
197 'file' => __DIR__ . '/widgets/testimonials-grid/testimonials.php',
198 'tab' => 'widget',
199 ],
200 'team_grid' => [
201 'class' => '\Easyel_Team_Grid__Widget',
202 'file' => __DIR__ . '/widgets/team-grid/team-grid.php',
203 'tab' => 'widget',
204 ],
205 'search' => [
206 'class' => '\Easyel_Search_Widget',
207 'file' => __DIR__ . '/widgets/search/search.php',
208 'tab' => 'widget',
209 ],
210 'contact_box' => [
211 'class' => '\Easyel_Contact_Box__Widget',
212 'file' => __DIR__ . '/widgets/contact-box/contact.php',
213 'tab' => 'widget',
214 ],
215 'faq' => [
216 'class' => '\Easyel_FAQ_Accordion_Widget',
217 'file' => __DIR__ . '/widgets/faq/faq.php',
218 'tab' => 'widget',
219 ],
220 'blog_grid' => [
221 'class' => '\Easyel_Blog_Grid__Widget',
222 'file' => __DIR__ . '/widgets/blog-grid/blog-grid.php',
223 'tab' => 'widget',
224 ],
225 'video' => [
226 'class' => '\Easyel_Video_Popup_Widget',
227 'file' => __DIR__ . '/widgets/video/video.php',
228 'tab' => 'widget',
229 ],
230 'pricing_table' => [
231 'class' => '\Easyel_Pricing_Table_Widget',
232 'file' => __DIR__ . '/widgets/pricing-table/pricing.php',
233 'tab' => 'widget',
234 ],
235 'service_list' => [
236 'class' => '\Easyel_Service_List_Widget',
237 'file' => __DIR__ . '/widgets/service-list/service-list.php',
238 'tab' => 'widget',
239 ],
240 'navigation_menu' => [
241 'class' => '\Easyel_Navigation_Menu_Widget',
242 'file' => __DIR__ . '/widgets/navigation-menu/navigation-menu.php',
243 'tab' => 'widget',
244 ],
245 'page_title' => [
246 'class' => '\Easyel_Page_Title_Widget',
247 'file' => __DIR__ . '/widgets/page-title/page-title.php',
248 'tab' => 'widget',
249 ],
250 'button' => [
251 'class' => '\Easyel_Button_Widget',
252 'file' => __DIR__ . '/widgets/button/button.php',
253 'tab' => 'widget',
254 ],
255 'process_grid' => [
256 'class' => '\Easyel_Process_Widget',
257 'file' => __DIR__ . '/widgets/process-grid/process-grid.php',
258 'tab' => 'widget',
259 ],
260 'process_list' => [
261 'class' => '\Easyel_Process_list_Widget',
262 'file' => __DIR__ . '/widgets/process-list/process-list.php',
263 'tab' => 'widget',
264 ],
265 'social_share' => [
266 'class' => '\Easyel_Social_Share_Widget',
267 'file' => __DIR__ . '/widgets/social-share/social-share.php',
268 'tab' => 'widget',
269 ],
270 'social_icon' => [
271 'class' => '\Easyel_Social_Icon_Widget',
272 'file' => __DIR__ . '/widgets/social-icon/social.php',
273 'tab' => 'widget',
274 ],
275 'breadcrumb' => [
276 'class' => '\Easyel_Breadcrumb_Widget',
277 'file' => __DIR__ . '/widgets/breadcrumb/breadcrumb.php',
278 'tab' => 'widget',
279 ],
280 'domain_search' => [
281 'class' => '\Easyel_Domain_Search_Widget',
282 'file' => __DIR__ . '/widgets/domain-search/domain-search.php',
283 'tab' => 'widget',
284 ],
285 'easy_offcanvas' => [
286 'class' => '\Easyel_Offcanvas_Widget',
287 'file' => __DIR__ . '/widgets/offcanvas/offcanvas.php',
288 'tab' => 'widget',
289 ],
290 'easy_table' => [
291 'class' => '\Easyel_Table_Elementor_Widget',
292 'file' => __DIR__ . '/widgets/table/table-normal.php',
293 'tab' => 'widget',
294 ],
295 'easy_scroll_to_top' => [
296 'class' => '\Easyel_Scroll_To_Top_Widget',
297 'file' => __DIR__ . '/widgets/scroll-to-top/scroll.php',
298 'tab' => 'widget',
299 ],
300 'easy_cf7' => [
301 'class' => '\easyel__CF7_Widget',
302 'file' => __DIR__ . '/widgets/cf7/contact-cf7.php',
303 'tab' => 'widget',
304 ],
305 'easy_gallery' => [
306 'class' => '\Easyel__Gallery_Widget',
307 'file' => __DIR__ . '/widgets/gallery/gallery.php',
308 'tab' => 'widget',
309 ],
310 'easy_progress' => [
311 'class' => '\Easyel_Progress_Widget',
312 'file' => __DIR__ . '/widgets/progress/progress.php',
313 'tab' => 'widget',
314 ],
315 'counter' => [
316 'class' => '\Easyel_Counter_Widget',
317 'file' => __DIR__ . '/widgets/counter/counter.php',
318 'tab' => 'widget',
319 ],
320 'countdown' => [
321 'class' => '\Easyel_Count_Down_Widget',
322 'file' => __DIR__ . '/widgets/countdown/countdown.php',
323 'tab' => 'widget',
324 ],
325
326 'excerpt' => [
327 'class' => '\Easyel_Excerpt_Widget',
328 'file' => EASYELEMENTS_DIR_PATH . '/widgets/excerpt/excerpt.php',
329 'tab' => 'widget'
330 ],
331
332 'post_title' => [
333 'class' => '\Easyel_Post_Title_Widget',
334 'file' => EASYELEMENTS_DIR_PATH . '/widgets/post-title/post-title.php',
335 'tab' => 'widget'
336 ],
337
338 'post_content' => [
339 'class' => '\Easyel_Post_Content_Widget',
340 'file' => EASYELEMENTS_DIR_PATH . '/widgets/post-content/post-content.php',
341 'tab' => 'widget'
342 ],
343
344 'featured_image' => [
345 'class' => '\Easyel_Featured_Image_Widget',
346 'file' => EASYELEMENTS_DIR_PATH . '/widgets/featured-image/featured-image.php',
347 'tab' => 'widget'
348 ],
349
350
351 'post_meta' => [
352 'class' => '\Easyel_Post_Meta_Widget',
353 'file' => EASYELEMENTS_DIR_PATH . '/widgets/post-meta/post-meta.php',
354 'tab' => 'widget'
355 ],
356
357 'post_pagination' => [
358 'class' => '\Easyel_Post_Pagination_Widget',
359 'file' => EASYELEMENTS_DIR_PATH . '/widgets/post-pagination/post-pagination.php',
360 'tab' => 'widget'
361 ],
362
363 'post_comments' => [
364 'class' => '\Easyel_Post_Comments_Widget',
365 'file' => EASYELEMENTS_DIR_PATH . '/widgets/post-comments/post-comments.php',
366 'tab' => 'widget'
367 ],
368 'post_tags' => [
369 'class' => '\Easyel_Post_Tags_Widget',
370 'file' => EASYELEMENTS_DIR_PATH . '/widgets/post-tag/post-tag.php',
371 'tab' => 'widget'
372 ],
373
374 'post_author' => [
375 'class' => '\Easyel_Post_Author_Info_Widget',
376 'file' => EASYELEMENTS_DIR_PATH . '/widgets/post-author/post-author.php',
377 'tab' => 'widget'
378 ],
379
380
381
382 ];
383
384 foreach ( $widgets as $key => $data ) {
385 $option_name = 'easy_element_' . $data['tab'] . '_' . $key;
386 $enabled = get_option( $option_name, '1' );
387
388 if ( 1 !== ( int ) $enabled ) {
389 continue; // Skip disabled widgets
390 }
391
392 if ( file_exists( $data['file'] ) ) {
393 require_once $data['file'];
394
395 if ( class_exists( $data['class'] ) ) {
396 $widgets_manager->register( new $data['class']() );
397 }
398 }
399 }
400 }
401
402 }
403
404 Easyel_Elements_Elementor_Extension::instance();