PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.0.2
ShopBuilder – WooCommerce Builder For Elementor v2.0.2
3.4.2 3.4.1 3.4.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 All 63 releases
← All changes | app/Controllers/Admin/Ajax/CreateTemplate.php +15 -32 2.1.112.0.2 View file →
@@ -6,9 +6,8 @@
6 6 use Elementor\Plugin;
7 7 use Elementor\TemplateLibrary\Source_Base;
8 8 use RadiusTheme\SB\Helpers\BuilderFns;
9 9 use RadiusTheme\SB\Helpers\Fns;
10 -use RadiusTheme\SB\Models\TemplateSettings;
11 10 use RadiusTheme\SB\Traits\SingletonTrait;
12 11
13 12 // Do not allow directly accessing this file.
14 13 if ( ! defined( 'ABSPATH' ) ) {
@@ -67,9 +66,9 @@
67 66 *
68 67 * @return void
69 68 */
70 69 public function response() {
71 - $page_type = isset( $_POST['page_type'] ) ? sanitize_text_field( wp_unslash( $_POST['page_type'] ) ) : null; // rtsb_tb_template_type - it represent to template type
70 + $page_type = isset( $_POST['page_type'] ) ? sanitize_text_field( wp_unslash( $_POST['page_type'] ) ) : null; //rtsb_tb_template_type - it represent to template type
72 71 $page_id = isset( $_POST['page_id'] ) ? absint( wp_unslash( $_POST['page_id'] ) ) : null;
73 72 $page_name = isset( $_POST['page_name'] ) ? sanitize_text_field( wp_unslash( $_POST['page_name'] ) ) : null;
74 73 $hasPro = isset( $_POST['hasPro'] ) ? sanitize_text_field( wp_unslash( $_POST['hasPro'] ) ) : null;
75 74 $edit_with = isset( $_POST['template_edit_with'] ) ? sanitize_text_field( wp_unslash( $_POST['template_edit_with'] ) ) : null;
@@ -78,9 +77,9 @@
78 77 $product_id = isset( $_POST['preview_product_id'] ) ? absint( $_POST['preview_product_id'] ) : null;
79 78
80 79 $url = '#';
81 80
82 - if ( ! wp_verify_nonce( Fns::get_nonce(), rtsb()->nonceText ) || ! $page_type ) {
81 + if ( ! Fns::verify_nonce() || ! $page_type ) {
83 82 $return = [
84 83 'success' => false,
85 84 'post_id' => $page_id,
86 85 ];
@@ -86,41 +85,29 @@
86 85 ];
87 86 wp_send_json( $return );
88 87
89 88 }
90 - if ( ! current_user_can( 'manage_options' ) ) {
91 - $return = [
92 - 'success' => false,
93 - 'post_id' => $page_id,
94 - ];
95 - wp_send_json( $return );
96 - }
97 89
98 - add_filter(
99 - 'pre_option_elementor_unfiltered_files_upload',
100 - function () {
101 - return '1';
102 - },
103 - 99
104 - );
90 + add_filter( 'pre_option_elementor_unfiltered_files_upload', function () {
91 + return '1';
92 + }, 99 );
105 93
106 94 Plugin::$instance->files_manager->clear_cache();
107 95 add_filter( 'rtsb_import_status', '__return_true' );
108 96
109 - $status = sanitize_text_field( wp_unslash( $_REQUEST['status'] ?? '' ) );
97 + $status = $_REQUEST['status'] ?? '';
110 98 $post_args = [ 'timeout' => 120 ];
111 99 $post_args['body'] = [
112 100 'status' => $status,
113 101 'layout_id' => $import_layout,
114 - 'has_pro' => $hasPro,
102 + 'has_pro' => $hasPro
115 103 ];
116 104 $layoutRequest = wp_remote_post( rtsb()->BASE_API, $post_args );
117 105
118 - $layoutJson = [];
119 - if ( ! is_wp_error( $layoutRequest ) && ! empty( $layoutRequest['body'] ) ) {
120 - $layoutJson = json_decode( $layoutRequest['body'], true );
106 + if ( is_wp_error( $layoutRequest ) ) {
107 + wp_send_json_error( [ 'messages' => $layoutRequest->get_error_messages() ] );
121 108 }
122 -
109 + $layoutJson = json_decode( $layoutRequest['body'], true );
123 110 $option_name = BuilderFns::option_name( $page_type );
124 111
125 112 $post_data = [
126 113 'ID' => $page_id,
@@ -159,13 +146,13 @@
159 146 $category_archive = array_unique( isset( $_POST['category_archive'] ) && is_array( $_POST['category_archive'] ) ? array_map( 'sanitize_text_field', $_POST['category_archive'] ) : [] );
160 147 $the_products = array_unique( isset( $_POST['the_products'] ) && is_array( $_POST['the_products'] ) ? array_map( 'absint', $_POST['the_products'] ) : [] );
161 148 if ( ! count( $the_products ) && ! count( $category_archive ) ) {
162 149 if ( 'default_template' === $default_template ) {
163 - TemplateSettings::instance()->set_option( $option_name, $page_id );
150 + update_option( $option_name, $page_id );
164 151 } else {
165 - $has_default = TemplateSettings::instance()->get_option( $option_name );
152 + $has_default = get_option( $option_name );
166 153 if ( ! $has_default ) {
167 - TemplateSettings::instance()->set_option( $option_name, '' );
154 + update_option( $option_name, '' );
168 155 }
169 156 }
170 157 }
171 158
@@ -183,9 +170,9 @@
183 170
184 171 if ( ! empty( $layoutJson['data'] ) ) {
185 172 $data = json_decode( $layoutJson['data'], true );
186 173 $content = $this->process_export_import_content( $data, 'on_import' );
187 - $content = wp_json_encode( $content );
174 + $content = json_encode( $content );
188 175 update_post_meta( $page_id, '_elementor_data', $content );
189 176 update_post_meta( $page_id, '_rtsb_import_id', $import_layout );
190 177 }
191 178 }
@@ -199,13 +186,9 @@
199 186 'new_page' => $new_page,
200 187
201 188 ];
202 189 if ( $edit_by ) {
203 - $return['edit_btn_text'] = sprintf(
204 - /* translators: %s: Edit */
205 - esc_html__( 'Edit with %s', 'shopbuilder' ),
206 - esc_html( $edit_by )
207 - );
190 + $return['edit_btn_text'] = esc_html__( sprintf( 'Edit with %s', $edit_by ), 'shopbuilder' );
208 191 }
209 192 wp_send_json( $return );
210 193 wp_die();
211 194 }