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 +268 -3 1.3.0 → 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
@@ -167,8 +192,12 @@
167 192 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-sliders-more-grid-images.php';
168 193 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-sliders-grid-images.php';
169 194 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-sliders-carousel.php';
170 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';
171 200
172 201 if(wdk_get_option('wdk_experimental_features') && wdk_get_option('wdk_experimental_search_popup')) {
173 202 require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-search-popup.php';
174 203 }
@@ -192,9 +221,8 @@
192 221 $post_data = NULL;
193 222 if(isset($_GET['post']))
194 223 $post_data = get_post(intval($_GET['post']));
195 224 if(
196 - (wdk_get_option('wdk_experimental_features') && wdk_get_option('wdk_experimental_listing_card_elementor_layout')) ||
197 225 (isset($_GET['post']) && $_GET['post'] == $listing_page_id) ||
198 226 (isset($post_data->post_type) && $post_data->post_type == 'elementor_library')
199 227 )
200 228 {
@@ -275,8 +303,12 @@
275 303 $this->add_widget('Wdk\Elementor\Widgets\WdkButton');
276 304 $this->add_widget('Wdk\Elementor\Widgets\WdkButtonLogin');
277 305 $this->add_widget('Wdk\Elementor\Widgets\WdkButtonAddlisting');
278 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');
279 311
280 312 if(wdk_get_option('wdk_experimental_features') && wdk_get_option('wdk_experimental_search_popup')) {
281 313 $this->add_widget('Wdk\Elementor\Widgets\WdkSearchPopup');
282 314 }
@@ -291,8 +323,32 @@
291 323 \Elementor\Plugin::instance()->widgets_manager->register( $object );
292 324 };
293 325 }
294 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 +
295 351 /**
296 352 * Register Widget
297 353 *
298 354 * @since 1.0.0
@@ -300,9 +356,10 @@
300 356 * @access private
301 357 */
302 358 private function register_modules() {
303 359
304 - }
360 + }
361 +
305 362
306 363 /**
307 364 * On Widgets Registered
308 365 *
@@ -348,9 +405,194 @@
348 405 ]
349 406 );
350 407 }
351 408
409 +/**
410 + * Handle Live Editor Modal.
411 + *
412 + * @access public
413 + * @since 4.8.10
414 + */
415 + public function wdk_handle_live_editor() {
352 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 +
353 595 /**
354 596 * Start Elementor Addon
355 597 */
356 598 public function run() {
@@ -368,9 +610,9 @@
368 610 /* load module */
369 611 $this->loader();
370 612 //wmvc_dump($meta);
371 613 }
372 -
614 +
373 615
374 616 }
375 617
376 618 /* Init lib after elementor loaded */
@@ -403,8 +645,31 @@
403 645 \Elementor\Plugin::instance()->widgets_manager->register( $object );
404 646 });
405 647
406 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 +
407 672
408 673 require_once WPDIRECTORYKIT_PATH . '/elementor-extensions/class-ajax-handler.php';
409 674 $object = new Wdk\Elementor\Extensions\AjaxHandler();
410 675