| @@ -52,9 +52,23 @@ | ||
| 52 | 52 | * @var string $version The current version of this plugin. |
| 53 | 53 | */ |
| 54 | 54 | private $elementor_category_name = 'wdk-elementor'; |
| 55 | 55 | private $elementor_category_name_listing_preview = 'wdk-elementor-listing-preview'; |
| 56 | + private $elementor_category_name_listing_preview_sliders = 'wdk-elementor-listing-preview-sliders'; | |
| 56 | 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 | + | |
| 57 | 71 | /** |
| 58 | 72 | * Initialize the class and set its properties. |
| 59 | 73 | * |
| 60 | 74 | * @since 1.0.0 |
| @@ -63,8 +77,19 @@ | ||
| 63 | 77 | */ |
| 64 | 78 | public function __construct( $plugin_name='wpdirectorykit', $version='1.0' ) { |
| 65 | 79 | $this->plugin_name = $plugin_name; |
| 66 | 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' ) ); | |
| 67 | 92 | } |
| 68 | 93 | |
| 69 | 94 | /** |
| 70 | 95 | * Register the stylesheets for the admin area. |
| @@ -104,8 +129,9 @@ | ||
| 104 | 129 | * between the defined hooks and the functions defined in this |
| 105 | 130 | * class. |
| 106 | 131 | */ |
| 107 | 132 | wp_enqueue_script( 'wdk-elementor-main', plugin_dir_url( __FILE__ ) . 'assets/js/wdk-main.js', array(), $this->version, true ); |
| 133 | + | |
| 108 | 134 | } |
| 109 | 135 | |
| 110 | 136 | /** |
| 111 | 137 | * Load class/script files |
| @@ -127,15 +153,23 @@ | ||
| 127 | 153 | require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-elementor-base.php'; |
| 128 | 154 | require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-field-label.php'; |
| 129 | 155 | require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-field-value.php'; |
| 130 | 156 | require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-field-images.php'; |
| 157 | + require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-field-files.php'; | |
| 158 | + require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-field-files-list.php'; | |
| 131 | 159 | require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-field-icon.php'; |
| 160 | + require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-agents-listings.php'; | |
| 132 | 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'; | |
| 133 | 164 | require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-locations-grid.php'; |
| 134 | 165 | require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-categories-grid-cover.php'; |
| 135 | 166 | require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-locations-grid-cover.php'; |
| 136 | 167 | require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-categories-grid.php'; |
| 137 | 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'; | |
| 138 | 172 | require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-locations-list.php'; |
| 139 | 173 | require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listings-results.php'; |
| 140 | 174 | require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listings-carousel.php'; |
| 141 | 175 | require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-slider.php'; |
| @@ -152,8 +186,23 @@ | ||
| 152 | 186 | require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-button.php'; |
| 153 | 187 | require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-button-login.php'; |
| 154 | 188 | require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-button-addlisting.php'; |
| 155 | 189 | |
| 190 | + require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-carousel.php'; | |
| 191 | + require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-sliders.php'; | |
| 192 | + require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-sliders-more-grid-images.php'; | |
| 193 | + require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-sliders-grid-images.php'; | |
| 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'; | |
| 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 | + | |
| 156 | 205 | do_action('wpdirectorykit/elementor-elements/includes'); |
| 157 | 206 | } |
| 158 | 207 | |
| 159 | 208 | /** |
| @@ -168,15 +217,26 @@ | ||
| 168 | 217 | $listing_page_id = get_option('wdk_listing_page'); |
| 169 | 218 | |
| 170 | 219 | if(!empty($listing_page_id)) |
| 171 | 220 | { |
| 172 | - if(isset($_GET['post']) && $_GET['post'] == $listing_page_id) | |
| 221 | + $post_data = NULL; | |
| 222 | + if(isset($_GET['post'])) | |
| 223 | + $post_data = get_post(intval($_GET['post'])); | |
| 224 | + if( | |
| 225 | + (isset($_GET['post']) && $_GET['post'] == $listing_page_id) || | |
| 226 | + (isset($post_data->post_type) && $post_data->post_type == 'elementor_library') | |
| 227 | + ) | |
| 173 | 228 | { |
| 174 | 229 | $this->add_widget('Wdk\Elementor\Widgets\WdkFieldLabel'); |
| 175 | 230 | $this->add_widget('Wdk\Elementor\Widgets\WdkFieldValue'); |
| 231 | + $this->add_widget('Wdk\Elementor\Widgets\WdkFieldFiles'); | |
| 232 | + $this->add_widget('Wdk\Elementor\Widgets\WdkFieldFilesList'); | |
| 176 | 233 | $this->add_widget('Wdk\Elementor\Widgets\WdkFieldImages'); |
| 177 | 234 | $this->add_widget('Wdk\Elementor\Widgets\WdkFieldIcon'); |
| 235 | + $this->add_widget('Wdk\Elementor\Widgets\WdkListingAgentsListings'); | |
| 178 | 236 | $this->add_widget('Wdk\Elementor\Widgets\WdkListingSimilarListings'); |
| 237 | + $this->add_widget('Wdk\Elementor\Widgets\WdkListingRelatedListingsTable'); | |
| 238 | + $this->add_widget('Wdk\Elementor\Widgets\WdkListingRelatedListings'); | |
| 179 | 239 | $this->add_widget('Wdk\Elementor\Widgets\WdkListingSlider'); |
| 180 | 240 | $this->add_widget('Wdk\Elementor\Widgets\WdkListingFieldsSection'); |
| 181 | 241 | $this->add_widget('Wdk\Elementor\Widgets\WdkListingMap'); |
| 182 | 242 | $this->add_widget('Wdk\Elementor\Widgets\WdkListinAgent'); |
| @@ -181,8 +241,14 @@ | ||
| 181 | 241 | $this->add_widget('Wdk\Elementor\Widgets\WdkListingMap'); |
| 182 | 242 | $this->add_widget('Wdk\Elementor\Widgets\WdkListinAgent'); |
| 183 | 243 | $this->add_widget('Wdk\Elementor\Widgets\WdkListingAgentField'); |
| 184 | 244 | $this->add_widget('Wdk\Elementor\Widgets\WdkListingAgentAvatar'); |
| 245 | + | |
| 246 | + $this->add_widget('Wdk\Elementor\Widgets\WdkCoolListingCarousel'); | |
| 247 | + $this->add_widget('Wdk\Elementor\Widgets\WdkListingSlidersCarousel'); | |
| 248 | + $this->add_widget('Wdk\Elementor\Widgets\WdkListingSlidersGridMoreImages'); | |
| 249 | + $this->add_widget('Wdk\Elementor\Widgets\WdkListingSlidersGridImages'); | |
| 250 | + $this->add_widget('Wdk\Elementor\Widgets\WdkListingSliders'); | |
| 185 | 251 | do_action('wpdirectorykit/elementor-elements/register_widget/listing', $this); |
| 186 | 252 | } |
| 187 | 253 | else if(isset($_GET['post'])) |
| 188 | 254 | { |
| @@ -191,11 +257,16 @@ | ||
| 191 | 257 | else |
| 192 | 258 | { |
| 193 | 259 | $this->add_widget('Wdk\Elementor\Widgets\WdkFieldLabel'); |
| 194 | 260 | $this->add_widget('Wdk\Elementor\Widgets\WdkFieldValue'); |
| 261 | + $this->add_widget('Wdk\Elementor\Widgets\WdkFieldFiles'); | |
| 262 | + $this->add_widget('Wdk\Elementor\Widgets\WdkFieldFilesList'); | |
| 195 | 263 | $this->add_widget('Wdk\Elementor\Widgets\WdkFieldImages'); |
| 196 | 264 | $this->add_widget('Wdk\Elementor\Widgets\WdkFieldIcon'); |
| 265 | + $this->add_widget('Wdk\Elementor\Widgets\WdkListingAgentsListings'); | |
| 197 | 266 | $this->add_widget('Wdk\Elementor\Widgets\WdkListingSimilarListings'); |
| 267 | + $this->add_widget('Wdk\Elementor\Widgets\WdkListingRelatedListingsTable'); | |
| 268 | + $this->add_widget('Wdk\Elementor\Widgets\WdkListingRelatedListings'); | |
| 198 | 269 | $this->add_widget('Wdk\Elementor\Widgets\WdkListingSlider'); |
| 199 | 270 | $this->add_widget('Wdk\Elementor\Widgets\WdkListingFieldsSection'); |
| 200 | 271 | $this->add_widget('Wdk\Elementor\Widgets\WdkListingMap'); |
| 201 | 272 | $this->add_widget('Wdk\Elementor\Widgets\WdkListinAgent'); |
| @@ -200,8 +271,14 @@ | ||
| 200 | 271 | $this->add_widget('Wdk\Elementor\Widgets\WdkListingMap'); |
| 201 | 272 | $this->add_widget('Wdk\Elementor\Widgets\WdkListinAgent'); |
| 202 | 273 | $this->add_widget('Wdk\Elementor\Widgets\WdkListingAgentField'); |
| 203 | 274 | $this->add_widget('Wdk\Elementor\Widgets\WdkListingAgentAvatar'); |
| 275 | + | |
| 276 | + $this->add_widget('Wdk\Elementor\Widgets\WdkCoolListingCarousel'); | |
| 277 | + $this->add_widget('Wdk\Elementor\Widgets\WdkListingSlidersCarousel'); | |
| 278 | + $this->add_widget('Wdk\Elementor\Widgets\WdkListingSlidersGridMoreImages'); | |
| 279 | + $this->add_widget('Wdk\Elementor\Widgets\WdkListingSlidersGridImages'); | |
| 280 | + $this->add_widget('Wdk\Elementor\Widgets\WdkListingSliders'); | |
| 204 | 281 | do_action('wpdirectorykit/elementor-elements/register_widget/listing', $this); |
| 205 | 282 | } |
| 206 | 283 | |
| 207 | 284 | //POST data[elementor_post_lock][post_ID] |
| @@ -208,8 +285,11 @@ | ||
| 208 | 285 | } |
| 209 | 286 | |
| 210 | 287 | $this->add_widget('Wdk\Elementor\Widgets\WdkLocationsList'); |
| 211 | 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'); | |
| 212 | 292 | $this->add_widget('Wdk\Elementor\Widgets\WdkListingsResults'); |
| 213 | 293 | $this->add_widget('Wdk\Elementor\Widgets\WdkListingsCarousel'); |
| 214 | 294 | $this->add_widget('Wdk\Elementor\Widgets\WdkCategoriesCarousel'); |
| 215 | 295 | $this->add_widget('Wdk\Elementor\Widgets\WdkLocationsCarousel'); |
| @@ -222,9 +302,18 @@ | ||
| 222 | 302 | $this->add_widget('Wdk\Elementor\Widgets\WdkListingsList'); |
| 223 | 303 | $this->add_widget('Wdk\Elementor\Widgets\WdkButton'); |
| 224 | 304 | $this->add_widget('Wdk\Elementor\Widgets\WdkButtonLogin'); |
| 225 | 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'); | |
| 226 | 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 | + | |
| 227 | 316 | do_action('wpdirectorykit/elementor-elements/register_widget', $this); |
| 228 | 317 | } |
| 229 | 318 | |
| 230 | 319 | public function add_widget($class = ''){ |
| @@ -234,8 +323,32 @@ | ||
| 234 | 323 | \Elementor\Plugin::instance()->widgets_manager->register( $object ); |
| 235 | 324 | }; |
| 236 | 325 | } |
| 237 | 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 | + | |
| 238 | 351 | /** |
| 239 | 352 | * Register Widget |
| 240 | 353 | * |
| 241 | 354 | * @since 1.0.0 |
| @@ -243,9 +356,10 @@ | ||
| 243 | 356 | * @access private |
| 244 | 357 | */ |
| 245 | 358 | private function register_modules() { |
| 246 | 359 | |
| 247 | - } | |
| 360 | + } | |
| 361 | + | |
| 248 | 362 | |
| 249 | 363 | /** |
| 250 | 364 | * On Widgets Registered |
| 251 | 365 | * |
| @@ -281,21 +395,216 @@ | ||
| 281 | 395 | 'title' => esc_html__( 'Wdk Listing Preview', 'wpdirectorykit' ), |
| 282 | 396 | 'icon' => 'fa fa-plug', |
| 283 | 397 | ] |
| 284 | 398 | ); |
| 399 | + | |
| 400 | + $elements_manager->add_category( | |
| 401 | + $this->elementor_category_name_listing_preview_sliders, | |
| 402 | + [ | |
| 403 | + 'title' => esc_html__( 'Wdk Listing Sliders', 'wpdirectorykit' ), | |
| 404 | + 'icon' => 'fa fa-plug', | |
| 405 | + ] | |
| 406 | + ); | |
| 285 | 407 | } |
| 286 | 408 | |
| 409 | +/** | |
| 410 | + * Handle Live Editor Modal. | |
| 411 | + * | |
| 412 | + * @access public | |
| 413 | + * @since 4.8.10 | |
| 414 | + */ | |
| 415 | + public function wdk_handle_live_editor() { | |
| 287 | 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 | + | |
| 288 | 595 | /** |
| 289 | 596 | * Start Elementor Addon |
| 290 | 597 | */ |
| 291 | 598 | public function run() { |
| 292 | 599 | |
| 600 | + require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-elementor-base.php'; | |
| 601 | + | |
| 293 | 602 | add_action( 'wp_enqueue_scripts',[ $this, 'enqueue_styles' ]); |
| 294 | 603 | add_action( 'wp_enqueue_scripts',[ $this, 'enqueue_scripts' ]); |
| 295 | 604 | |
| 296 | 605 | add_action( 'elementor/elements/categories_registered', [ $this, 'load_category' ] ); |
| 297 | - add_action( 'elementor/widgets/widgets_registered', [ $this, 'on_widgets_registered' ] ); | |
| 606 | + add_action( 'elementor/widgets/register', [ $this, 'on_widgets_registered' ] ); | |
| 298 | 607 | |
| 299 | 608 | do_action('wpdirectorykit/elementor-elements/run'); |
| 300 | 609 | |
| 301 | 610 | /* load module */ |
| @@ -301,9 +610,9 @@ | ||
| 301 | 610 | /* load module */ |
| 302 | 611 | $this->loader(); |
| 303 | 612 | //wmvc_dump($meta); |
| 304 | 613 | } |
| 305 | - | |
| 614 | + | |
| 306 | 615 | |
| 307 | 616 | } |
| 308 | 617 | |
| 309 | 618 | /* Init lib after elementor loaded */ |
| @@ -310,9 +619,9 @@ | ||
| 310 | 619 | add_action( 'elementor/init', function() { |
| 311 | 620 | $wdk_elementor = new Wdk_Elementor( ); |
| 312 | 621 | $wdk_elementor->run(); |
| 313 | 622 | do_action('wpdirectorykit/elementor-elements/init'); |
| 314 | -}); | |
| 623 | +}, 1); | |
| 315 | 624 | |
| 316 | 625 | /* example extension for wdk elements |
| 317 | 626 | add_action('wpdirectorykit/elementor-elements/includes', function(){ |
| 318 | 627 | require_once WPDIRECTORYKIT_PATH . '/elementor-extensions/class-contact-form.php'; |
| @@ -336,8 +645,31 @@ | ||
| 336 | 645 | \Elementor\Plugin::instance()->widgets_manager->register( $object ); |
| 337 | 646 | }); |
| 338 | 647 | |
| 339 | 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 | + | |
| 340 | 672 | |
| 341 | 673 | require_once WPDIRECTORYKIT_PATH . '/elementor-extensions/class-ajax-handler.php'; |
| 342 | 674 | $object = new Wdk\Elementor\Extensions\AjaxHandler(); |
| 343 | 675 | |