PluginProbe
WP Directory Kit / 1.4.8
WP Directory Kit v1.4.8
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 1.4.0 1.4.1 All 35 releases
← All changes | elementor-elements/elementor-init.php +280 -2 1.2.31.4.8 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
@@ -142,8 +167,9 @@
142 167 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-categories-grid.php';
143 168 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-categories-list.php';
144 169 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-categories-tree.php';
145 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';
146 172 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-locations-list.php';
147 173 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listings-results.php';
148 174 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listings-carousel.php';
149 175 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-slider.php';
@@ -165,9 +191,18 @@
165 191 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-sliders.php';
166 192 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-sliders-more-grid-images.php';
167 193 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-sliders-grid-images.php';
168 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';
169 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 +
170 205 do_action('wpdirectorykit/elementor-elements/includes');
171 206 }
172 207
173 208 /**
@@ -251,8 +286,9 @@
251 286
252 287 $this->add_widget('Wdk\Elementor\Widgets\WdkLocationsList');
253 288 $this->add_widget('Wdk\Elementor\Widgets\WdkCategoriesList');
254 289 $this->add_widget('Wdk\Elementor\Widgets\WdkCategoriesTree');
290 + $this->add_widget('Wdk\Elementor\Widgets\WdkCategoriesTreeTop');
255 291 $this->add_widget('Wdk\Elementor\Widgets\WdkLocationsTree');
256 292 $this->add_widget('Wdk\Elementor\Widgets\WdkListingsResults');
257 293 $this->add_widget('Wdk\Elementor\Widgets\WdkListingsCarousel');
258 294 $this->add_widget('Wdk\Elementor\Widgets\WdkCategoriesCarousel');
@@ -266,9 +302,18 @@
266 302 $this->add_widget('Wdk\Elementor\Widgets\WdkListingsList');
267 303 $this->add_widget('Wdk\Elementor\Widgets\WdkButton');
268 304 $this->add_widget('Wdk\Elementor\Widgets\WdkButtonLogin');
269 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');
270 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 +
271 316 do_action('wpdirectorykit/elementor-elements/register_widget', $this);
272 317 }
273 318
274 319 public function add_widget($class = ''){
@@ -278,8 +323,32 @@
278 323 \Elementor\Plugin::instance()->widgets_manager->register( $object );
279 324 };
280 325 }
281 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 +
282 351 /**
283 352 * Register Widget
284 353 *
285 354 * @since 1.0.0
@@ -287,9 +356,10 @@
287 356 * @access private
288 357 */
289 358 private function register_modules() {
290 359
291 - }
360 + }
361 +
292 362
293 363 /**
294 364 * On Widgets Registered
295 365 *
@@ -335,9 +405,194 @@
335 405 ]
336 406 );
337 407 }
338 408
409 +/**
410 + * Handle Live Editor Modal.
411 + *
412 + * @access public
413 + * @since 4.8.10
414 + */
415 + public function wdk_handle_live_editor() {
339 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( 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( __( 'Empty Post Type.', 'premium-addons-for-elementor' ) );
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 +
340 595 /**
341 596 * Start Elementor Addon
342 597 */
343 598 public function run() {
@@ -355,9 +610,9 @@
355 610 /* load module */
356 611 $this->loader();
357 612 //wmvc_dump($meta);
358 613 }
359 -
614 +
360 615
361 616 }
362 617
363 618 /* Init lib after elementor loaded */
@@ -390,8 +645,31 @@
390 645 \Elementor\Plugin::instance()->widgets_manager->register( $object );
391 646 });
392 647
393 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 +
394 672
395 673 require_once WPDIRECTORYKIT_PATH . '/elementor-extensions/class-ajax-handler.php';
396 674 $object = new Wdk\Elementor\Extensions\AjaxHandler();
397 675