| @@ -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; | |
| 5 | 6 | use Elementor\Plugin; |
| 6 | 7 | use Elementor\TemplateLibrary\Source_Base; |
| 7 | 8 | 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,9 +67,8 @@ | ||
| 67 | 67 | * |
| 68 | 68 | * @return void |
| 69 | 69 | */ |
| 70 | 70 | public function response() { |
| 71 | - Cache::clear_transient_cache(); | |
| 72 | 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 |
| 73 | 72 | $page_id = isset( $_POST['page_id'] ) ? absint( wp_unslash( $_POST['page_id'] ) ) : null; |
| 74 | 73 | $page_name = isset( $_POST['page_name'] ) ? sanitize_text_field( wp_unslash( $_POST['page_name'] ) ) : null; |
| 75 | 74 | $hasPro = isset( $_POST['hasPro'] ) ? sanitize_text_field( wp_unslash( $_POST['hasPro'] ) ) : null; |
| @@ -74,9 +73,9 @@ | ||
| 74 | 73 | $page_name = isset( $_POST['page_name'] ) ? sanitize_text_field( wp_unslash( $_POST['page_name'] ) ) : null; |
| 75 | 74 | $hasPro = isset( $_POST['hasPro'] ) ? sanitize_text_field( wp_unslash( $_POST['hasPro'] ) ) : null; |
| 76 | 75 | $edit_with = isset( $_POST['template_edit_with'] ) ? sanitize_text_field( wp_unslash( $_POST['template_edit_with'] ) ) : null; |
| 77 | 76 | $default_template = isset( $_POST['default_template'] ) ? sanitize_text_field( wp_unslash( $_POST['default_template'] ) ) : null; |
| 78 | - $import_layout = isset( $_POST['import_default_layout'] ) ? sanitize_text_field( $_POST['import_default_layout'] ) : null; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash | |
| 77 | + $import_layout = isset( $_POST['import_default_layout'] ) ? sanitize_text_field( $_POST['import_default_layout'] ) : null; | |
| 79 | 78 | $product_id = isset( $_POST['preview_product_id'] ) ? absint( $_POST['preview_product_id'] ) : null; |
| 80 | 79 | |
| 81 | 80 | $url = '#'; |
| 82 | 81 | |
| @@ -152,25 +151,19 @@ | ||
| 152 | 151 | } |
| 153 | 152 | |
| 154 | 153 | $edit_by = ''; |
| 155 | 154 | 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 | |
| 159 | 155 | if ( 'product' == $page_type ) { |
| 160 | 156 | update_post_meta( $page_id, BuilderFns::$product_template_meta, $product_id ); |
| 161 | - update_post_meta( $page_id, '_is_product_page_template_for', $template_for ); | |
| 162 | 157 | } |
| 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 { | |
| 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 ) ) { | |
| 170 | 162 | if ( 'default_template' === $default_template ) { |
| 171 | 163 | TemplateSettings::instance()->set_option( $option_name, $page_id ); |
| 172 | 164 | } else { |
| 165 | + $has_default = TemplateSettings::instance()->get_option( $option_name ); | |
| 173 | 166 | if ( ! $has_default ) { |
| 174 | 167 | TemplateSettings::instance()->set_option( $option_name, '' ); |
| 175 | 168 | } |
| 176 | 169 | } |