| @@ -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_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' ] ); | |
| 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' ] ); | |
| 75 | 75 | // Select2 ajax save data. |
| 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' ] ); | |
| 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' ] ); | |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | 81 | * Apply for frontend. |
| @@ -108,12 +108,15 @@ | ||
| 108 | 108 | * @return void |
| 109 | 109 | */ |
| 110 | 110 | public function add_elementor_widget_categories( $elements_manager ) { |
| 111 | 111 | $categories = []; |
| 112 | - $type = BuilderFns::builder_type( get_the_ID() ); | |
| 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 ); | |
| 115 | + | |
| 113 | 116 | if ( $type ) { |
| 114 | 117 | $builder_type = ! empty( BuilderFns::builder_page_types()[ $type ] ) ? BuilderFns::builder_page_types()[ $type ] : ''; |
| 115 | - $builder_type = str_replace( 'My Account - ', '', $builder_type ); | |
| 118 | + $builder_type = str_replace( [ 'My Account - ', 'Endpoint: ' ], '', $builder_type ); | |
| 116 | 119 | $categories['rtsb-shopbuilder'] = [ |
| 117 | 120 | 'title' => esc_html__( 'ShopBuilder', 'shopbuilder' ) . ' - ' . ucfirst( $builder_type ), |
| 118 | 121 | 'icon' => 'fa fa-plug', |
| 119 | 122 | ]; |
| @@ -123,9 +126,10 @@ | ||
| 123 | 126 | 'title' => esc_html__( 'Shopbuilder - General', 'shopbuilder' ), |
| 124 | 127 | 'icon' => 'fa fa-plug', |
| 125 | 128 | ]; |
| 126 | 129 | } |
| 127 | - $categories = apply_filters( 'rtsb_elementor_widgets_category_lists', $categories ); | |
| 130 | + $categories = apply_filters( 'rtsb_elementor_widgets_category_lists', $categories ); | |
| 131 | + | |
| 128 | 132 | $other_categories = $elements_manager->get_categories(); |
| 129 | 133 | $categories = array_merge( |
| 130 | 134 | array_slice( $other_categories, 0, 1 ), |
| 131 | 135 | $categories, |
| @@ -131,10 +135,10 @@ | ||
| 131 | 135 | $categories, |
| 132 | 136 | array_slice( $other_categories, 1 ) |
| 133 | 137 | ); |
| 134 | 138 | |
| 135 | - $set_categories = function ( $categories ) { | |
| 136 | - $this->categories = $categories; | |
| 139 | + $set_categories = function ( $categories ) use ( $elements_manager ) { | |
| 140 | + $elements_manager->categories = $categories; | |
| 137 | 141 | }; |
| 138 | 142 | |
| 139 | 143 | $set_categories->call( $elements_manager, $categories ); |
| 140 | 144 | } |
| @@ -226,9 +230,9 @@ | ||
| 226 | 230 | * |
| 227 | 231 | * @return array |
| 228 | 232 | */ |
| 229 | 233 | public function rtsb_icons( $tabs = [] ) { |
| 230 | - $custom_icons = $this->get_icons(); | |
| 234 | + $custom_icons = Fns::get_custom_icon_names(); | |
| 231 | 235 | |
| 232 | 236 | $tabs['shopbuilder-icons'] = [ |
| 233 | 237 | 'name' => 'rtsb-fonts', |
| 234 | 238 | 'label' => esc_html__( 'ShopBuilder Icons', 'shopbuilder' ), |
| @@ -376,15 +380,18 @@ | ||
| 376 | 380 | $post_type = 'post'; |
| 377 | 381 | $source_name = 'post_type'; |
| 378 | 382 | $paged = absint( $_POST['page'] ?? 1 ); |
| 379 | 383 | if ( ! empty( $_POST['post_type'] ) ) { |
| 384 | + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash | |
| 380 | 385 | $post_type = sanitize_text_field( $_POST['post_type'] ); |
| 381 | 386 | } |
| 382 | 387 | |
| 383 | 388 | if ( ! empty( $_POST['source_name'] ) ) { |
| 389 | + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash | |
| 384 | 390 | $source_name = sanitize_text_field( $_POST['source_name'] ); |
| 385 | 391 | } |
| 386 | 392 | |
| 393 | + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash | |
| 387 | 394 | $search = ! empty( $_POST['search'] ) ? sanitize_text_field( $_POST['search'] ) : ''; |
| 388 | 395 | $results = $post_list = []; |
| 389 | 396 | switch ( $source_name ) { |
| 390 | 397 | case 'taxonomy': |
| @@ -452,13 +459,14 @@ | ||
| 452 | 459 | if ( empty( $_POST['id'] ) ) { |
| 453 | 460 | wp_send_json_error( [] ); |
| 454 | 461 | } |
| 455 | 462 | |
| 463 | + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 456 | 464 | if ( empty( array_filter( $_POST['id'] ) ) ) { |
| 457 | 465 | wp_send_json_error( [] ); |
| 458 | 466 | } |
| 459 | 467 | $ids = array_map( 'intval', $_POST['id'] ); |
| 460 | - $source_name = ! empty( $_POST['source_name'] ) ? sanitize_text_field( $_POST['source_name'] ) : ''; | |
| 468 | + $source_name = ! empty( $_POST['source_name'] ) ? sanitize_text_field( $_POST['source_name'] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash | |
| 461 | 469 | |
| 462 | 470 | switch ( $source_name ) { |
| 463 | 471 | case 'taxonomy': |
| 464 | 472 | $args = [ |
| @@ -467,9 +475,11 @@ | ||
| 467 | 475 | 'order' => 'ASC', |
| 468 | 476 | 'include' => implode( ',', $ids ), |
| 469 | 477 | ]; |
| 470 | 478 | |
| 479 | + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated | |
| 471 | 480 | if ( $_POST['post_type'] !== 'all' ) { |
| 481 | + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash | |
| 472 | 482 | $args['taxonomy'] = sanitize_text_field( $_POST['post_type'] ); |
| 473 | 483 | } |
| 474 | 484 | |
| 475 | 485 | $response = wp_list_pluck( get_terms( $args ), 'name', 'term_id' ); |
| @@ -487,9 +497,9 @@ | ||
| 487 | 497 | break; |
| 488 | 498 | default: |
| 489 | 499 | $post_info = get_posts( |
| 490 | 500 | [ |
| 491 | - 'post_type' => sanitize_text_field( $_POST['post_type'] ), | |
| 501 | + 'post_type' => sanitize_text_field( $_POST['post_type'] ), // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotValidated | |
| 492 | 502 | 'include' => implode( ',', $ids ), |
| 493 | 503 | ] |
| 494 | 504 | ); |
| 495 | 505 | $response = wp_list_pluck( $post_info, 'post_title', 'ID' ); |
| @@ -581,10 +591,10 @@ | ||
| 581 | 591 | |
| 582 | 592 | $pro_widgets = [ |
| 583 | 593 | [ |
| 584 | 594 | 'name' => 'rtsb-ajax-product-filters', |
| 585 | - 'title' => esc_html__( 'Ajax Product Filters', 'testimonial-slider-showcase' ), | |
| 586 | - 'description' => esc_html__( 'Ajax Product Filters', 'testimonial-slider-showcase' ), | |
| 595 | + 'title' => esc_html__( 'Ajax Product Filters', 'shopbuilder' ), | |
| 596 | + 'description' => esc_html__( 'Ajax Product Filters', 'shopbuilder' ), | |
| 587 | 597 | 'icon' => 'rtsb-el-custom rtsb-element icon-rtsb-ajax-product-filters rtsb-promotional-element', |
| 588 | 598 | 'categories' => '[ "rtsb-shopbuilder" ]', |
| 589 | 599 | ], |
| 590 | 600 | ]; |