| @@ -60,16 +60,13 @@ | ||
| 60 | 60 | BuilderHooks::instance(); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | BuilderCpt::instance(); |
| 64 | - | |
| 65 | - $this->elementor_init(); | |
| 66 | - $this->both_builder_frontend(); | |
| 67 | - | |
| 68 | - // add_action( 'elementor/init', [ $this, 'elementor_init' ] ); | |
| 69 | - add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'editor_scripts' ] ); | |
| 70 | - // add_action( 'template_redirect', [ $this, 'both_builder_frontend' ], 99 ); | |
| 71 | - | |
| 64 | + if ( defined( 'ELEMENTOR_VERSION' ) ) { | |
| 65 | + $this->elementor_init(); | |
| 66 | + $this->both_builder_frontend(); | |
| 67 | + add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'editor_scripts' ] ); | |
| 68 | + } | |
| 72 | 69 | // RT Select2 Ajax. |
| 73 | 70 | add_action( 'wp_ajax_rtsb_select2_object_search', [ $this, 'select2_ajax_posts_filter_autocomplete' ] ); |
| 74 | 71 | add_action( 'wp_ajax_nopriv_rtsb_select2_object_search', [ $this, 'select2_ajax_posts_filter_autocomplete' ] ); |
| 75 | 72 | // Select2 ajax save data. |
| @@ -555,8 +552,17 @@ | ||
| 555 | 552 | } |
| 556 | 553 | |
| 557 | 554 | if ( ! empty( $search ) ) { |
| 558 | 555 | $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_title LIKE %s", '%' . esc_sql( $search ) . '%' ); |
| 556 | + } | |
| 557 | + | |
| 558 | + // Add a query for shop_coupon post-type to check 'show on frontend' meta. | |
| 559 | + if ( 'shop_coupon' === $post_type ) { | |
| 560 | + $where .= " AND {$wpdb->posts}.ID IN ( | |
| 561 | + SELECT post_id FROM {$wpdb->postmeta} | |
| 562 | + WHERE meta_key = 'rtsb_show_on_frontend' | |
| 563 | + AND meta_value = 'on' | |
| 564 | + )"; | |
| 559 | 565 | } |
| 560 | 566 | |
| 561 | 567 | $query = "select post_title,ID from $wpdb->posts where post_status = 'publish' {$where} {$limit}"; |
| 562 | 568 | $results = $wpdb->get_results( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.NoCaching |