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