' . esc_html__( 'Template Settings', 'shopbuilder' ) . ''; if ( ! Fns::verify_nonce() ) { $return = [ 'success' => false, 'title' => $title, 'content' => esc_html__( 'Session Expired...', 'shopbuilder' ), ]; wp_send_json( $return ); } add_filter( 'option_' . Uploads_Manager::UNFILTERED_FILE_UPLOADS_KEY, '__return_true' ); Plugin::$instance->files_manager->clear_cache(); // user capability check. $user = wp_get_current_user(); $allowed_roles = [ 'editor', 'administrator', 'author' ]; if ( ! array_intersect( $allowed_roles, $user->roles ) ) { wp_die( __( 'You don\'t have permission to perform this action', 'rttpg' ) ); } // Check if the user is not logged in and the provided 'user_id' in the request does not match the currently logged-in user's ID. if ( ! is_user_logged_in() && $user->ID !== sanitize_text_field( $_REQUEST['user_id'] ) ) { wp_die( __( 'You don\'t have proper authorization to perform this action', 'rttpg' ) ); } $post_id = isset( $_POST['post_id'] ) ? absint( $_POST['post_id'] ) : null; $layout_id = isset( $_POST['layout_id'] ) ? absint( $_POST['layout_id'] ) : null; $template_type = null; $template_default = null; $url = ''; $tmp_title = ''; $_rtsb_import_id = ''; $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 release 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' ) ); $_rtsb_import_id = get_post_meta( $post_id, '_rtsb_import_id', true ); } $status = $_REQUEST['status'] ?? ''; $post_args = [ 'timeout' => 120 ]; $post_args['body'] = [ 'status' => $status, ]; $layoutRequest = wp_remote_post( rtsb()->BASE_API, $post_args ); if ( is_wp_error( $layoutRequest ) ) { wp_send_json_error( [ 'messages' => $layoutRequest->get_error_messages() ] ); } $layoutData = json_decode( $layoutRequest['body'], true ); ob_start(); ?>
'default', 'image_url' => \Elementor\Utils::get_placeholder_image_src(), 'preview_link' => '', 'title' => __( 'Blank Template', 'shopbuilder' ), ]; $this->get_modal_card_html( $default_item ); if ( ! empty( $layoutData['layouts'] ) ) { foreach ( $layoutData['layouts'] as $item ) { $this->get_modal_card_html( $item ); } } ?>
true, 'title' => $title, 'content' => $content, 'footer' => $footer, ]; wp_send_json( $return ); wp_die(); } public function default_layout_template_html( $key, $is_checked, $builder, $value = [] ) { $layout_type = $key . ( $builder ? '_' . $builder : null ); ?>
'>
<?php echo esc_attr( $item['title'] ); ?> has_pro() ) ) : ?>
has_pro() || $item['status'] == 'free' ) : ?>
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 . ' - ( ID ' . $product->ID . ' )', ]; } wp_send_json_success( $product_list ); wp_die(); } /** * Popups For Create Template * * @return void */ public function category_search() { if ( ! Fns::verify_nonce() ) { $return = [ 'success' => false, 'content' => esc_html__( 'Session Expired...', 'shopbuilder' ), ]; wp_send_json( $return ); } $search = isset( $_REQUEST['search'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['search'] ) ) : null; // phpcs:ignore WordPress.Security.NonceVerification.Missing $args = [ 'taxonomy' => [ 'product_cat' ], // taxonomy name 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => false, 'name__like' => $search, ]; $terms = get_terms( $args ); $count = count( $terms ); $term_list = []; if ( $count > 0 ) { foreach ( $terms as $term ) { $term_list['items'][] = [ 'id' => $term->slug, 'text' => $term->name, ]; } } wp_send_json_success( $term_list ); wp_die(); } }