| @@ -69,13 +69,13 @@ | ||
| 69 | 69 | add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'editor_scripts' ] ); |
| 70 | 70 | // add_action( 'template_redirect', [ $this, 'both_builder_frontend' ], 99 ); |
| 71 | 71 | |
| 72 | 72 | // RT Select2 Ajax. |
| 73 | - add_action( 'wp_ajax_rtsb_select2_object_search', [ $this, 'select2_ajax_posts_filter_autocomplete' ] ); | |
| 74 | - add_action( 'wp_ajax_nopriv_rtsb_select2_object_search', [ $this, 'select2_ajax_posts_filter_autocomplete' ] ); | |
| 73 | + add_action( 'wp_ajax_rt_select2_object_search', [ $this, 'select2_ajax_posts_filter_autocomplete' ] ); | |
| 74 | + add_action( 'wp_ajax_nopriv_rt_select2_object_search', [ $this, 'select2_ajax_posts_filter_autocomplete' ] ); | |
| 75 | 75 | // Select2 ajax save data. |
| 76 | - add_action( 'wp_ajax_rtsb_select2_get_title', [ $this, 'select2_ajax_get_posts_value_titles' ] ); | |
| 77 | - add_action( 'wp_ajax_nopriv_rtsb_select2_get_title', [ $this, 'select2_ajax_get_posts_value_titles' ] ); | |
| 76 | + add_action( 'wp_ajax_rt_select2_get_title', [ $this, 'select2_ajax_get_posts_value_titles' ] ); | |
| 77 | + add_action( 'wp_ajax_nopriv_rt_select2_get_title', [ $this, 'select2_ajax_get_posts_value_titles' ] ); | |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | 81 | * Apply for frontend. |
| @@ -107,29 +107,21 @@ | ||
| 107 | 107 | * |
| 108 | 108 | * @return void |
| 109 | 109 | */ |
| 110 | 110 | public function add_elementor_widget_categories( $elements_manager ) { |
| 111 | - $categories = []; | |
| 112 | - $builder_id = get_queried_object_id(); | |
| 113 | - $id = Fns::wpml_object_id( $builder_id, BuilderFns::$post_type_tb, 'default' ); | |
| 114 | - $type = BuilderFns::builder_type( $id ); | |
| 111 | + $type = BuilderFns::builder_type( get_the_ID() ); | |
| 112 | + $builder_type = ! empty( BuilderFns::builder_page_types()[ $type ] ) ? BuilderFns::builder_page_types()[ $type ] : ''; | |
| 113 | + $builder_type = str_replace( 'My Account - ', '', $builder_type ); | |
| 114 | + $categories['rtsb-shopbuilder'] = [ | |
| 115 | + 'title' => esc_html__( 'ShopBuilder', 'shopbuilder' ) . ' - ' . ucfirst( $builder_type ), | |
| 116 | + 'icon' => 'fa fa-plug', | |
| 117 | + ]; | |
| 118 | + $categories['rtsb-shopbuilder-general'] = [ | |
| 119 | + 'title' => esc_html__( 'Shopbuilder - General', 'shopbuilder' ), | |
| 120 | + 'icon' => 'fa fa-plug', | |
| 121 | + ]; | |
| 115 | 122 | |
| 116 | - if ( $type ) { | |
| 117 | - $builder_type = ! empty( BuilderFns::builder_page_types()[ $type ] ) ? BuilderFns::builder_page_types()[ $type ] : ''; | |
| 118 | - $builder_type = str_replace( [ 'My Account - ', 'Endpoint: ' ], '', $builder_type ); | |
| 119 | - $categories['rtsb-shopbuilder'] = [ | |
| 120 | - 'title' => esc_html__( 'ShopBuilder', 'shopbuilder' ) . ' - ' . ucfirst( $builder_type ), | |
| 121 | - 'icon' => 'fa fa-plug', | |
| 122 | - ]; | |
| 123 | - } | |
| 124 | - if ( 'quick-view' !== $type ) { | |
| 125 | - $categories['rtsb-shopbuilder-general'] = [ | |
| 126 | - 'title' => esc_html__( 'Shopbuilder - General', 'shopbuilder' ), | |
| 127 | - 'icon' => 'fa fa-plug', | |
| 128 | - ]; | |
| 129 | - } | |
| 130 | - $categories = apply_filters( 'rtsb_elementor_widgets_category_lists', $categories ); | |
| 131 | - | |
| 123 | + $categories = apply_filters( 'rtsb_elementor_widgets_category_lists', $categories ); | |
| 132 | 124 | $other_categories = $elements_manager->get_categories(); |
| 133 | 125 | $categories = array_merge( |
| 134 | 126 | array_slice( $other_categories, 0, 1 ), |
| 135 | 127 | $categories, |
| @@ -135,10 +127,10 @@ | ||
| 135 | 127 | $categories, |
| 136 | 128 | array_slice( $other_categories, 1 ) |
| 137 | 129 | ); |
| 138 | 130 | |
| 139 | - $set_categories = function ( $categories ) use ( $elements_manager ) { | |
| 140 | - $elements_manager->categories = $categories; | |
| 131 | + $set_categories = function ( $categories ) { | |
| 132 | + $this->categories = $categories; | |
| 141 | 133 | }; |
| 142 | 134 | |
| 143 | 135 | $set_categories->call( $elements_manager, $categories ); |
| 144 | 136 | } |
| @@ -230,9 +222,9 @@ | ||
| 230 | 222 | * |
| 231 | 223 | * @return array |
| 232 | 224 | */ |
| 233 | 225 | public function rtsb_icons( $tabs = [] ) { |
| 234 | - $custom_icons = Fns::get_custom_icon_names(); | |
| 226 | + $custom_icons = $this->get_icons(); | |
| 235 | 227 | |
| 236 | 228 | $tabs['shopbuilder-icons'] = [ |
| 237 | 229 | 'name' => 'rtsb-fonts', |
| 238 | 230 | 'label' => esc_html__( 'ShopBuilder Icons', 'shopbuilder' ), |
| @@ -297,18 +289,8 @@ | ||
| 297 | 289 | |
| 298 | 290 | if ( BuilderFns::is_product() ) { |
| 299 | 291 | $product_id = Fns::get_prepared_product_id(); |
| 300 | 292 | $parent_class = wc_get_product_class( $parent_class, $product_id ); |
| 301 | - if ( function_exists( 'rtwpvs' ) ) { | |
| 302 | - $_product = Fns::get_product(); | |
| 303 | - if ( $_product->is_type( 'variable' ) ) { | |
| 304 | - $parent_class[] = 'rtwpvs-product'; | |
| 305 | - $beside_label = function_exists( 'rtwpvsp' ) && rtwpvs()->get_option( 'attribute_on_click_behavior' ); | |
| 306 | - if ( $beside_label ) { | |
| 307 | - $parent_class[] = 'rtwpvs-selected-term-beside-label'; | |
| 308 | - } | |
| 309 | - } | |
| 310 | - } | |
| 311 | 293 | } |
| 312 | 294 | |
| 313 | 295 | if ( BuilderFns::is_shop() ) { |
| 314 | 296 | $parent_class[] = 'shop'; |
| @@ -372,26 +354,22 @@ | ||
| 372 | 354 | * |
| 373 | 355 | * @return void |
| 374 | 356 | */ |
| 375 | 357 | public function select2_ajax_posts_filter_autocomplete() { |
| 376 | - if ( ! wp_verify_nonce( Fns::get_nonce(), rtsb()->nonceText ) ) { | |
| 377 | - wp_send_json_error( [] ); | |
| 378 | - } | |
| 358 | + | |
| 379 | 359 | $query_per_page = 15; |
| 380 | 360 | $post_type = 'post'; |
| 381 | 361 | $source_name = 'post_type'; |
| 382 | - $paged = absint( $_POST['page'] ?? 1 ); | |
| 362 | + $paged = $_POST['page'] ?? 1; | |
| 363 | + | |
| 383 | 364 | if ( ! empty( $_POST['post_type'] ) ) { |
| 384 | - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash | |
| 385 | 365 | $post_type = sanitize_text_field( $_POST['post_type'] ); |
| 386 | 366 | } |
| 387 | 367 | |
| 388 | 368 | if ( ! empty( $_POST['source_name'] ) ) { |
| 389 | - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash | |
| 390 | 369 | $source_name = sanitize_text_field( $_POST['source_name'] ); |
| 391 | 370 | } |
| 392 | 371 | |
| 393 | - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash | |
| 394 | 372 | $search = ! empty( $_POST['search'] ) ? sanitize_text_field( $_POST['search'] ) : ''; |
| 395 | 373 | $results = $post_list = []; |
| 396 | 374 | switch ( $source_name ) { |
| 397 | 375 | case 'taxonomy': |
| @@ -451,22 +429,17 @@ | ||
| 451 | 429 | * @return void |
| 452 | 430 | */ |
| 453 | 431 | public function select2_ajax_get_posts_value_titles() { |
| 454 | 432 | |
| 455 | - if ( ! wp_verify_nonce( Fns::get_nonce(), rtsb()->nonceText ) ) { | |
| 456 | - wp_send_json_error( [] ); | |
| 457 | - } | |
| 458 | - | |
| 459 | 433 | if ( empty( $_POST['id'] ) ) { |
| 460 | 434 | wp_send_json_error( [] ); |
| 461 | 435 | } |
| 462 | 436 | |
| 463 | - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 464 | 437 | if ( empty( array_filter( $_POST['id'] ) ) ) { |
| 465 | 438 | wp_send_json_error( [] ); |
| 466 | 439 | } |
| 467 | 440 | $ids = array_map( 'intval', $_POST['id'] ); |
| 468 | - $source_name = ! empty( $_POST['source_name'] ) ? sanitize_text_field( $_POST['source_name'] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash | |
| 441 | + $source_name = ! empty( $_POST['source_name'] ) ? sanitize_text_field( $_POST['source_name'] ) : ''; | |
| 469 | 442 | |
| 470 | 443 | switch ( $source_name ) { |
| 471 | 444 | case 'taxonomy': |
| 472 | 445 | $args = [ |
| @@ -475,11 +448,9 @@ | ||
| 475 | 448 | 'order' => 'ASC', |
| 476 | 449 | 'include' => implode( ',', $ids ), |
| 477 | 450 | ]; |
| 478 | 451 | |
| 479 | - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated | |
| 480 | 452 | if ( $_POST['post_type'] !== 'all' ) { |
| 481 | - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash | |
| 482 | 453 | $args['taxonomy'] = sanitize_text_field( $_POST['post_type'] ); |
| 483 | 454 | } |
| 484 | 455 | |
| 485 | 456 | $response = wp_list_pluck( get_terms( $args ), 'name', 'term_id' ); |
| @@ -497,9 +468,9 @@ | ||
| 497 | 468 | break; |
| 498 | 469 | default: |
| 499 | 470 | $post_info = get_posts( |
| 500 | 471 | [ |
| 501 | - 'post_type' => sanitize_text_field( $_POST['post_type'] ), // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotValidated | |
| 472 | + 'post_type' => sanitize_text_field( $_POST['post_type'] ), | |
| 502 | 473 | 'include' => implode( ',', $ids ), |
| 503 | 474 | ] |
| 504 | 475 | ); |
| 505 | 476 | $response = wp_list_pluck( $post_info, 'post_title', 'ID' ); |
| @@ -558,9 +529,9 @@ | ||
| 558 | 529 | $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_title LIKE %s", '%' . esc_sql( $search ) . '%' ); |
| 559 | 530 | } |
| 560 | 531 | |
| 561 | 532 | $query = "select post_title,ID from $wpdb->posts where post_status = 'publish' {$where} {$limit}"; |
| 562 | - $results = $wpdb->get_results( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.NoCaching | |
| 533 | + $results = $wpdb->get_results( $query ); | |
| 563 | 534 | |
| 564 | 535 | if ( ! empty( $results ) ) { |
| 565 | 536 | foreach ( $results as $row ) { |
| 566 | 537 | $data[ $row->ID ] = $row->post_title . ' [#' . $row->ID . ']'; |
| @@ -591,10 +562,10 @@ | ||
| 591 | 562 | |
| 592 | 563 | $pro_widgets = [ |
| 593 | 564 | [ |
| 594 | 565 | 'name' => 'rtsb-ajax-product-filters', |
| 595 | - 'title' => esc_html__( 'Ajax Product Filters', 'shopbuilder' ), | |
| 596 | - 'description' => esc_html__( 'Ajax Product Filters', 'shopbuilder' ), | |
| 566 | + 'title' => esc_html__( 'Ajax Product Filters', 'testimonial-slider-showcase' ), | |
| 567 | + 'description' => esc_html__( 'Ajax Product Filters', 'testimonial-slider-showcase' ), | |
| 597 | 568 | 'icon' => 'rtsb-el-custom rtsb-element icon-rtsb-ajax-product-filters rtsb-promotional-element', |
| 598 | 569 | 'categories' => '[ "rtsb-shopbuilder" ]', |
| 599 | 570 | ], |
| 600 | 571 | ]; |