PluginProbe
WP Directory Kit / 1.5.9
WP Directory Kit v1.5.9
1.5.9 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 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.8 All 37 releases
← All changes | elementor-elements/elementor-init.php +291 -3 1.1.6 → 1.5.9 View file →
@@ -54,8 +54,21 @@
54 54 private $elementor_category_name = 'wdk-elementor';
55 55 private $elementor_category_name_listing_preview = 'wdk-elementor-listing-preview';
56 56 private $elementor_category_name_listing_preview_sliders = 'wdk-elementor-listing-preview-sliders';
57 57
58 +
59 + /**
60 + * The name Elementors Custom Controls.
61 + *
62 + * @since 1.0.0
63 + * @access private
64 + * @var string $version The current version of this plugin.
65 + */
66 + private $custom_controls = [
67 + WPDIRECTORYKIT_PATH.'elementor-elements/classes/includes/controls/wdk-post-filter.php'=>'Wdk\Includes\Controls\Wdk_Post_Filter',
68 + WPDIRECTORYKIT_PATH.'elementor-elements/classes/includes/controls/wdk-field-selector.php'=>'Wdk\Includes\Controls\Wdk_Field_Selector',
69 + ];
70 +
58 71 /**
59 72 * Initialize the class and set its properties.
60 73 *
61 74 * @since 1.0.0
@@ -64,8 +77,19 @@
64 77 */
65 78 public function __construct( $plugin_name='wpdirectorykit', $version='1.0' ) {
66 79 $this->plugin_name = $plugin_name;
67 80 $this->version = $version;
81 +
82 +
83 + add_action( 'elementor/controls/register', array( $this, 'add_controls' ) );
84 +
85 + add_action( 'wp_ajax_wdk_handle_live_editor', array( $this, 'wdk_handle_live_editor' ) );
86 + add_action( 'wp_ajax_wdk_update_filter', array( $this, 'get_posts_list' ) );
87 +
88 +
89 + add_action( 'elementor/editor/before_enqueue_styles', array( $this, 'enqueue_editor_styles' ) );
90 + add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'load_live_editor_modal' ) );
91 + add_action( 'elementor/editor/after_enqueue_scripts', array( $this, 'after_enqueue_scripts' ) );
68 92 }
69 93
70 94 /**
71 95 * Register the stylesheets for the admin area.
@@ -105,8 +129,9 @@
105 129 * between the defined hooks and the functions defined in this
106 130 * class.
107 131 */
108 132 wp_enqueue_script( 'wdk-elementor-main', plugin_dir_url( __FILE__ ) . 'assets/js/wdk-main.js', array(), $this->version, true );
133 +
109 134 }
110 135
111 136 /**
112 137 * Load class/script files
@@ -133,13 +158,18 @@
133 158 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-field-files-list.php';
134 159 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-field-icon.php';
135 160 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-agents-listings.php';
136 161 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-similar-listings.php';
162 + require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-related-listings.php';
163 + require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-related-listings-table.php';
137 164 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-locations-grid.php';
138 165 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-categories-grid-cover.php';
139 166 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-locations-grid-cover.php';
140 167 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-categories-grid.php';
141 168 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-categories-list.php';
169 + require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-categories-tree.php';
170 + require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-locations-tree.php';
171 + require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-categories-tree-top.php';
142 172 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-locations-list.php';
143 173 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listings-results.php';
144 174 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listings-carousel.php';
145 175 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-slider.php';
@@ -161,9 +191,18 @@
161 191 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-sliders.php';
162 192 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-sliders-more-grid-images.php';
163 193 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-sliders-grid-images.php';
164 194 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-sliders-carousel.php';
195 + require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-last-search.php';
196 + require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-implode-shortcode.php';
197 + require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-tabs.php';
198 + require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-language-switcher.php';
199 + require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-button-share.php';
165 200
201 + if(wdk_get_option('wdk_experimental_features') && wdk_get_option('wdk_experimental_search_popup')) {
202 + require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-search-popup.php';
203 + }
204 +
166 205 do_action('wpdirectorykit/elementor-elements/includes');
167 206 }
168 207
169 208 /**
@@ -194,8 +233,10 @@
194 233 $this->add_widget('Wdk\Elementor\Widgets\WdkFieldImages');
195 234 $this->add_widget('Wdk\Elementor\Widgets\WdkFieldIcon');
196 235 $this->add_widget('Wdk\Elementor\Widgets\WdkListingAgentsListings');
197 236 $this->add_widget('Wdk\Elementor\Widgets\WdkListingSimilarListings');
237 + $this->add_widget('Wdk\Elementor\Widgets\WdkListingRelatedListingsTable');
238 + $this->add_widget('Wdk\Elementor\Widgets\WdkListingRelatedListings');
198 239 $this->add_widget('Wdk\Elementor\Widgets\WdkListingSlider');
199 240 $this->add_widget('Wdk\Elementor\Widgets\WdkListingFieldsSection');
200 241 $this->add_widget('Wdk\Elementor\Widgets\WdkListingMap');
201 242 $this->add_widget('Wdk\Elementor\Widgets\WdkListinAgent');
@@ -222,8 +263,10 @@
222 263 $this->add_widget('Wdk\Elementor\Widgets\WdkFieldImages');
223 264 $this->add_widget('Wdk\Elementor\Widgets\WdkFieldIcon');
224 265 $this->add_widget('Wdk\Elementor\Widgets\WdkListingAgentsListings');
225 266 $this->add_widget('Wdk\Elementor\Widgets\WdkListingSimilarListings');
267 + $this->add_widget('Wdk\Elementor\Widgets\WdkListingRelatedListingsTable');
268 + $this->add_widget('Wdk\Elementor\Widgets\WdkListingRelatedListings');
226 269 $this->add_widget('Wdk\Elementor\Widgets\WdkListingSlider');
227 270 $this->add_widget('Wdk\Elementor\Widgets\WdkListingFieldsSection');
228 271 $this->add_widget('Wdk\Elementor\Widgets\WdkListingMap');
229 272 $this->add_widget('Wdk\Elementor\Widgets\WdkListinAgent');
@@ -242,8 +285,11 @@
242 285 }
243 286
244 287 $this->add_widget('Wdk\Elementor\Widgets\WdkLocationsList');
245 288 $this->add_widget('Wdk\Elementor\Widgets\WdkCategoriesList');
289 + $this->add_widget('Wdk\Elementor\Widgets\WdkCategoriesTree');
290 + $this->add_widget('Wdk\Elementor\Widgets\WdkCategoriesTreeTop');
291 + $this->add_widget('Wdk\Elementor\Widgets\WdkLocationsTree');
246 292 $this->add_widget('Wdk\Elementor\Widgets\WdkListingsResults');
247 293 $this->add_widget('Wdk\Elementor\Widgets\WdkListingsCarousel');
248 294 $this->add_widget('Wdk\Elementor\Widgets\WdkCategoriesCarousel');
249 295 $this->add_widget('Wdk\Elementor\Widgets\WdkLocationsCarousel');
@@ -256,9 +302,18 @@
256 302 $this->add_widget('Wdk\Elementor\Widgets\WdkListingsList');
257 303 $this->add_widget('Wdk\Elementor\Widgets\WdkButton');
258 304 $this->add_widget('Wdk\Elementor\Widgets\WdkButtonLogin');
259 305 $this->add_widget('Wdk\Elementor\Widgets\WdkButtonAddlisting');
306 + $this->add_widget('Wdk\Elementor\Widgets\WdkLastSearch');
307 + $this->add_widget('Wdk\Elementor\Widgets\WdkImplodeShortcode');
308 + $this->add_widget('Wdk\Elementor\Widgets\WdkTabs');
309 + $this->add_widget('Wdk\Elementor\Widgets\WdkLanguageSwitcher');
310 + $this->add_widget('Wdk\Elementor\Widgets\WdkButtonShare');
260 311
312 + if(wdk_get_option('wdk_experimental_features') && wdk_get_option('wdk_experimental_search_popup')) {
313 + $this->add_widget('Wdk\Elementor\Widgets\WdkSearchPopup');
314 + }
315 +
261 316 do_action('wpdirectorykit/elementor-elements/register_widget', $this);
262 317 }
263 318
264 319 public function add_widget($class = ''){
@@ -268,8 +323,32 @@
268 323 \Elementor\Plugin::instance()->widgets_manager->register( $object );
269 324 };
270 325 }
271 326
327 +
328 + /**
329 + * Registers Custom Controls.
330 + *
331 + * @since 1.0.0
332 + * @access public
333 + *
334 + */
335 + public function add_controls() {
336 +
337 +
338 + $control_manager = \Elementor\Plugin::instance();
339 +
340 + $this->custom_controls = apply_filters('wpdirectorykit/elementor/custom_controls', $this->custom_controls);
341 +
342 + foreach ($this->custom_controls as $include_file => $class) {
343 + if(empty($class) || !file_exists($include_file)) continue;
344 +
345 + require_once $include_file;
346 + $control_manager->controls_manager->register( new $class() );
347 + }
348 +
349 + }
350 +
272 351 /**
273 352 * Register Widget
274 353 *
275 354 * @since 1.0.0
@@ -277,9 +356,10 @@
277 356 * @access private
278 357 */
279 358 private function register_modules() {
280 359
281 - }
360 + }
361 +
282 362
283 363 /**
284 364 * On Widgets Registered
285 365 *
@@ -325,9 +405,194 @@
325 405 ]
326 406 );
327 407 }
328 408
409 +/**
410 + * Handle Live Editor Modal.
411 + *
412 + * @access public
413 + * @since 4.8.10
414 + */
415 + public function wdk_handle_live_editor() {
329 416
417 + check_ajax_referer( 'wdk-live-editor', 'security' );
418 +
419 + if ( ! isset( $_POST['post_id'] ) ) {
420 + wp_send_json_error();
421 + }
422 +
423 + $post_id = sanitize_text_field( wp_unslash( $_POST['post_id'] ) );
424 + $meta_input = array(
425 + '_elementor_edit_mode' => 'builder',
426 + '_elementor_template_type' => 'page',
427 + '_wp_page_template' => 'elementor_canvas',
428 + );
429 +
430 + $post = null;
431 +
432 + if(!empty($post_id))
433 + $post = get_post( $post_id );
434 +
435 + if ( empty( $post ) ) { // create a new one.
436 +
437 + $post_title = 'WDK Template | #' . substr( md5( wp_rand(0000,9999) ), 0, 4 );
438 +
439 + $params = array(
440 + 'post_content' => '',
441 + 'post_type' => 'elementor_library',
442 + 'post_title' => $post_title,
443 + 'post_status' => 'publish',
444 + 'meta_input' => $meta_input,
445 + );
446 +
447 + $post_id = wp_insert_post( $params );
448 +
449 + } else {
450 + $post_id = $post->ID;
451 + $post_title = $post->post_title;
452 + }
453 +
454 + $edit_url = get_admin_url() . '/post.php?post=' . $post_id . '&action=elementor';
455 +
456 + $result = array(
457 + 'url' => $edit_url,
458 + 'id' => $post_id,
459 + 'title' => $post_title,
460 + );
461 +
462 + wp_send_json_success( $result );
463 + }
464 +
465 +
466 + /**
467 + * Get posts list
468 + *
469 + * Get posts list array
470 + *
471 + * @since 4.2.8
472 + * @access public
473 + */
474 + public static function get_posts_list() {
475 +
476 + check_ajax_referer( 'wdk-blog-widget-nonce', 'nonce' );
477 +
478 + $post_type = isset( $_POST['post_type'] ) ? wp_unslash( $_POST['post_type'] ) : '';
479 +
480 + $post_type = array_map( 'sanitize_text_field', $post_type );
481 +
482 + if ( empty( $post_type ) ) {
483 + wp_send_json_error( esc_html__( 'Empty Post Type.', 'wpdirectorykit' ) );
484 + }
485 +
486 + $list = get_posts(
487 + array(
488 + 'post_type' => $post_type,
489 + 'posts_per_page' => -1,
490 + 'update_post_term_cache' => false,
491 + 'update_post_meta_cache' => false,
492 + )
493 + );
494 +
495 + $options = array();
496 +
497 + if ( ! empty( $list ) && ! is_wp_error( $list ) ) {
498 + foreach ( $list as $post ) {
499 + $key = in_array( 'elementor_library', $post_type, true ) ? $post->post_title : $post->ID;
500 + $options[ $key ] = $post->post_title;
501 + }
502 + }
503 +
504 + wp_send_json_success( wp_json_encode( $options ) );
505 + }
506 +
507 + /**
508 + * Load Live Editor Modal.
509 + * Puts live editor popup html into the editor.
510 + *
511 + * @access public
512 + * @since 4.8.10
513 + */
514 + public function load_live_editor_modal() {
515 + ob_start();
516 + include_once WPDIRECTORYKIT_PATH . 'elementor-elements/classes/includes/live-editor-modal.php';
517 + $output = ob_get_contents();
518 + ob_end_clean();
519 + echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
520 + }
521 +
522 + /**
523 + * After Enqueue Scripts
524 + *
525 + * Loads editor scripts for our controls.
526 + *
527 + * @access public
528 + * @return void
529 + */
530 + public function after_enqueue_scripts() {
531 +
532 + wp_enqueue_script( 'wdk-elementor-live-editor', WPDIRECTORYKIT_URL . 'elementor-elements/classes/includes/js/live-editor.js', array(), $this->version, true );
533 +
534 + wp_localize_script( 'wdk-elementor-live-editor', 'liveEditor', array(
535 + 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
536 + 'nonce' => wp_create_nonce( 'wdk-live-editor' ),
537 + ));
538 +
539 + wp_enqueue_script(
540 + 'wdk-controls-handlers',
541 + WPDIRECTORYKIT_URL . 'elementor-elements/classes/includes/js/controls-handlers.js',
542 + array( 'elementor-editor', 'jquery' ),
543 + $this->version,
544 + true
545 + );
546 +
547 + wp_localize_script(
548 + 'wdk-controls-handlers',
549 + 'PremiumSettings',
550 + array(
551 + 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
552 + 'nonce' => wp_create_nonce( 'wdk-blog-widget-nonce' ),
553 + )
554 + );
555 + }
556 +
557 + /**
558 + * Loads plugin icons font
559 + *
560 + * @since 1.0.0
561 + * @access public
562 + * @return void
563 + */
564 + public function enqueue_editor_styles() {
565 +
566 + $theme = 'dark';
567 +
568 + wp_enqueue_style(
569 + 'wdk-elementor-live-editor',
570 + WPDIRECTORYKIT_URL . 'elementor-elements/classes/includes/css/wdk-elementor-live-editor.css',
571 + array(),
572 + $this->version
573 + );
574 +
575 + // Enqueue required style for Elementor dark UI Theme.
576 + if ( 'dark' == $theme ) {
577 + wp_add_inline_style(
578 + 'wdk-elementor-live-editor',
579 + '.elementor-panel .elementor-control-section_pa_docs .elementor-panel-heading-title.elementor-panel-heading-title,
580 + .elementor-control-raw-html.editor-pa-doc a {
581 + color: #e0e1e3 !important;
582 + }
583 + [class^="pa-"]::after,
584 + [class*=" pa-"]::after {
585 + color: #aaa;
586 + opacity: 1 !important;
587 + }
588 + .wdk-promotion-dialog .wdk-promotion-btn {
589 + background-color: #202124 !important
590 + }'
591 + );
592 + }
593 + }
594 +
330 595 /**
331 596 * Start Elementor Addon
332 597 */
333 598 public function run() {
@@ -345,9 +610,9 @@
345 610 /* load module */
346 611 $this->loader();
347 612 //wmvc_dump($meta);
348 613 }
349 -
614 +
350 615
351 616 }
352 617
353 618 /* Init lib after elementor loaded */
@@ -354,9 +619,9 @@
354 619 add_action( 'elementor/init', function() {
355 620 $wdk_elementor = new Wdk_Elementor( );
356 621 $wdk_elementor->run();
357 622 do_action('wpdirectorykit/elementor-elements/init');
358 -});
623 +}, 1);
359 624
360 625 /* example extension for wdk elements
361 626 add_action('wpdirectorykit/elementor-elements/includes', function(){
362 627 require_once WPDIRECTORYKIT_PATH . '/elementor-extensions/class-contact-form.php';
@@ -380,8 +645,31 @@
380 645 \Elementor\Plugin::instance()->widgets_manager->register( $object );
381 646 });
382 647
383 648 });
649 +
650 +
651 +if((get_option('wdk_experimental_features') && get_option('wdk_experimental_listing_card_elementor_layout'))) {
652 + add_action('wpdirectorykit/elementor-elements/register_widget', function(){
653 + $card_elements= [
654 + 'wdk-listing-card-button' => 'WdkListingCardButton',
655 + 'wdk-listing-card-field-value' => 'WdkListingCardFieldValue',
656 + 'wdk-listing-card-field-icon' => 'WdkListingCardFieldIcon',
657 + 'wdk-listing-card-field-label' => 'WdkListingCardFieldLabel',
658 + 'wdk-listing-card-thumbnail' => 'WdkListingCardThumbnail',
659 + ];
660 + foreach ($card_elements as $file => $object_name) {
661 + if(!file_exists(WPDIRECTORYKIT_PATH . '/elementor-extensions/'.$file.'.php')) continue;
662 +
663 + require_once WPDIRECTORYKIT_PATH . '/elementor-extensions/'.$file.'.php';
664 + $class_name = 'Wdk\\Elementor\\Extensions\\' . $object_name;
665 + $object = new $class_name();
666 + \Elementor\Plugin::instance()->widgets_manager->register( $object );
667 + }
668 + });
669 +}
670 +
671 +
384 672
385 673 require_once WPDIRECTORYKIT_PATH . '/elementor-extensions/class-ajax-handler.php';
386 674 $object = new Wdk\Elementor\Extensions\AjaxHandler();
387 675