PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.2.2
ShopBuilder – WooCommerce Builder For Elementor v2.2.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 +14 -7 2.1.9 → 2.2.2 View file →
@@ -1,12 +1,12 @@
1 1 <?php
2 2
3 3 namespace RadiusTheme\SB\Controllers\Admin\Ajax;
4 4
5 -use Elementor\Core\Files\Uploads_Manager;
6 5 use Elementor\Plugin;
7 6 use Elementor\TemplateLibrary\Source_Base;
8 7 use RadiusTheme\SB\Helpers\BuilderFns;
8 +use RadiusTheme\SB\Helpers\Cache;
9 9 use RadiusTheme\SB\Helpers\Fns;
10 10 use RadiusTheme\SB\Models\TemplateSettings;
11 11 use RadiusTheme\SB\Traits\SingletonTrait;
12 12
@@ -67,8 +67,9 @@
67 67 *
68 68 * @return void
69 69 */
70 70 public function response() {
71 + Cache::clear_transient_cache();
71 72 $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 73 $page_id = isset( $_POST['page_id'] ) ? absint( wp_unslash( $_POST['page_id'] ) ) : null;
73 74 $page_name = isset( $_POST['page_name'] ) ? sanitize_text_field( wp_unslash( $_POST['page_name'] ) ) : null;
74 75 $hasPro = isset( $_POST['hasPro'] ) ? sanitize_text_field( wp_unslash( $_POST['hasPro'] ) ) : null;
@@ -73,9 +74,9 @@
73 74 $page_name = isset( $_POST['page_name'] ) ? sanitize_text_field( wp_unslash( $_POST['page_name'] ) ) : null;
74 75 $hasPro = isset( $_POST['hasPro'] ) ? sanitize_text_field( wp_unslash( $_POST['hasPro'] ) ) : null;
75 76 $edit_with = isset( $_POST['template_edit_with'] ) ? sanitize_text_field( wp_unslash( $_POST['template_edit_with'] ) ) : null;
76 77 $default_template = isset( $_POST['default_template'] ) ? sanitize_text_field( wp_unslash( $_POST['default_template'] ) ) : null;
77 - $import_layout = isset( $_POST['import_default_layout'] ) ? sanitize_text_field( $_POST['import_default_layout'] ) : null;
78 + $import_layout = isset( $_POST['import_default_layout'] ) ? sanitize_text_field( $_POST['import_default_layout'] ) : null; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
78 79 $product_id = isset( $_POST['preview_product_id'] ) ? absint( $_POST['preview_product_id'] ) : null;
79 80
80 81 $url = '#';
81 82
@@ -151,19 +152,25 @@
151 152 }
152 153
153 154 $edit_by = '';
154 155 if ( $page_id ) {
156 + $edit_by = Fns::page_edit_with( $page_id );
157 + $template_for = sanitize_text_field( wp_unslash( $_POST['product_page_for'] ?? '' ) );
158 + $selected_category = array_unique( isset( $_POST['selected_category'] ) && is_array( $_POST['selected_category'] ) ? array_map( 'sanitize_text_field', $_POST['selected_category'] ) : [] ); //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
155 159 if ( 'product' == $page_type ) {
156 160 update_post_meta( $page_id, BuilderFns::$product_template_meta, $product_id );
161 + update_post_meta( $page_id, '_is_product_page_template_for', $template_for );
157 162 }
158 - $edit_by = Fns::page_edit_with( $page_id );
159 - $category_archive = array_unique( isset( $_POST['category_archive'] ) && is_array( $_POST['category_archive'] ) ? array_map( 'sanitize_text_field', $_POST['category_archive'] ) : [] );
160 - $the_products = array_unique( isset( $_POST['the_products'] ) && is_array( $_POST['the_products'] ) ? array_map( 'absint', $_POST['the_products'] ) : [] );
161 - if ( ! count( $the_products ) && ! count( $category_archive ) ) {
163 +
164 + $has_default = TemplateSettings::instance()->get_option( $option_name );
165 + if ( ( 'product' === $page_type && 'all_products' !== $template_for ) || ( 'archive' === $page_type && count( $selected_category ) ) ) {
166 + if ( ! $has_default ) {
167 + TemplateSettings::instance()->set_option( $option_name, '' );
168 + }
169 + } else {
162 170 if ( 'default_template' === $default_template ) {
163 171 TemplateSettings::instance()->set_option( $option_name, $page_id );
164 172 } else {
165 - $has_default = TemplateSettings::instance()->get_option( $option_name );
166 173 if ( ! $has_default ) {
167 174 TemplateSettings::instance()->set_option( $option_name, '' );
168 175 }
169 176 }