' . esc_html__( 'Template Settings', 'shopbuilder' ) . ''; if ( ! Fns::verify_nonce() ) { $return = [ 'success' => false, 'title' => $title, 'content' => esc_html__( 'Session Expired...', 'shopbuilder' ), ]; wp_send_json( $return ); } $post_id = isset( $_POST['post_id'] ) ? absint( $_POST['post_id'] ) : null; $template_type = null; $template_default = null; $url = null; $tmp_title = ''; $edit_by = did_action( 'elementor/loaded' ) ? 'elementor' : 'elementor'; if ( $post_id ) { $tmp_title = get_the_title( $post_id ); $type = get_post_meta( $post_id, BuilderFns::template_type_meta_key() ); $template_type = isset( $type[0] ) ? $type[0] : ''; $template_default = absint( BuilderFns::builder_page_id_by_type( $template_type ) ); $edit_by = Fns::page_edit_with( $post_id ); $action = 'edit'; // TODO:: This Condition Will remove after relase Gutenberg Addons. if ( 'gutenberg' == $edit_by ) { $action = 'elementor'; $edit_by = 'elementor'; } if ( 'elementor' == $edit_by ) { $action = 'elementor'; } $url = add_query_arg( [ 'post' => $post_id, 'action' => $action, ], admin_url( 'post.php' ) ); } ob_start(); ?>
true, 'title' => $title, 'content' => $content, 'footer' => $footer, ]; wp_send_json( $return ); wp_die(); } /** * Popups For Create Template * * @return void */ public function product_search() { if ( ! Fns::verify_nonce() ) { $return = [ 'success' => false, 'content' => esc_html__( 'Session Expired...', 'shopbuilder' ), ]; wp_send_json( $return ); } global $wpdb; $search = isset( $_REQUEST['search'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['search'] ) ) : null; // phpcs:ignore WordPress.Security.NonceVerification.Missing if ( empty( $search ) ) { $return = [ 'success' => false, 'content' => esc_html__( 'Empty string Not allowed...', 'shopbuilder' ), ]; wp_send_json( $return ); } $query = $wpdb->prepare( "SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'product' AND post_status = 'publish' AND post_title LIKE %s LIMIT %d", '%' . $search . '%', 10 ); $_product = wp_cache_get( md5( $query ), 'rtsb-product-query' ); if ( false === $_product ) { $_product = $wpdb->get_results( $query ); wp_cache_set( md5( $query ), $_product, 'rtsb-product-query' ); } $product_list = []; foreach ( $_product as $product ) { $product_list['items'][] = [ 'id' => $product->ID, 'text' => $product->post_title, ]; } wp_send_json_success( $product_list ); wp_die(); } }