' . esc_html__( 'Template Settings', 'shopbuilder' ) . ''; if ( ! wp_verify_nonce( Fns::get_nonce(), rtsb()->nonceText ) ) { $return = [ 'success' => false, 'title' => $title, 'content' => esc_html__( 'Session Expired...', 'shopbuilder' ), ]; wp_send_json( $return ); } if ( ! current_user_can( 'manage_options' ) ) { $return = [ 'success' => false, 'title' => $title, 'content' => esc_html__( 'Permission Denied...', '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( esc_html__( 'You don\'t have permission to perform this action', 'shopbuilder' ) ); } // 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( esc_html__( 'You don\'t have proper authorization to perform this action', 'shopbuilder' ) ); } $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; $product_page_for = 'all_products'; $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 ); $template_type = get_post_meta( $post_id, BuilderFns::template_type_meta_key(), true ); $options = BuilderFns::option_name( $template_type ); $template_default = TemplateSettings::instance()->get_option( $options ); $edit_by = Fns::page_edit_with( $post_id ); $action = 'edit'; if ( rtsb()->has_pro() ) { $product_page_for = get_post_meta( $post_id, '_is_product_page_template_for', true ); } // 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 ); $layoutData = []; if ( ! is_wp_error( $layoutRequest ) && ! empty( $layoutRequest['body'] ) ) { $layoutData = json_decode( $layoutRequest['body'], true ); } ob_start(); ?>
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 ); ?> nonceText ) ) { $return = [ 'success' => false, 'content' => esc_html__( 'Session Expired...', 'shopbuilder' ), ]; wp_send_json( $return ); } if ( ! current_user_can( 'manage_options' ) ) { $return = [ 'success' => false, 'content' => esc_html__( 'Permission Denied...', '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 ); $cache_key = md5( $query ); $_product = wp_cache_get( $cache_key, 'shopbuilder' ); if ( false === $_product ) { $_product = $wpdb->get_results( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.NotPrepared wp_cache_set( $cache_key, $_product, 'shopbuilder' ); Cache::set_data_cache_key( $cache_key ); } $product_list = []; foreach ( $_product as $product ) { $product_list['items'][] = [ 'id' => $product->ID, 'text' => html_entity_decode( $product->post_title, ENT_QUOTES | ENT_HTML5 ) . ' - (ID#' . $product->ID . ')', ]; } wp_send_json_success( $product_list ); wp_die(); } /** * Popups For Create Template * * @return void */ public function term_search() { if ( ! wp_verify_nonce( Fns::get_nonce(), rtsb()->nonceText ) ) { $return = [ 'success' => false, 'content' => esc_html__( 'Session Expired...', 'shopbuilder' ), ]; wp_send_json( $return ); } if ( ! current_user_can( 'manage_options' ) ) { $return = [ 'success' => false, 'content' => esc_html__( 'Permission Denied...', 'shopbuilder' ), ]; wp_send_json( $return ); } $search = isset( $_REQUEST['search'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['search'] ) ) : null; // phpcs:ignore WordPress.Security.NonceVerification.Missing $taxonomy = isset( $_REQUEST['taxonomy'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['taxonomy'] ) ) : null; // phpcs:ignore WordPress.Security.NonceVerification.Missing if ( ! $taxonomy ) { $return = [ 'success' => false, 'content' => esc_html__( 'Invalid taxonomy', 'shopbuilder' ), ]; wp_send_json( $return ); } $args = [ 'taxonomy' => [ $taxonomy ], // 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' => html_entity_decode( $term->name, ENT_QUOTES | ENT_HTML5 ), ]; } } wp_send_json_success( $term_list ); wp_die(); } }