PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.2.6
ShopBuilder – WooCommerce Builder For Elementor v3.2.6
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/DefaultTemplate.php +25 -15 2.1.133.2.6 View file →
@@ -2,8 +2,9 @@
2 2
3 3 namespace RadiusTheme\SB\Controllers\Admin\Ajax;
4 4
5 5 use RadiusTheme\SB\Helpers\BuilderFns;
6 +use RadiusTheme\SB\Helpers\Cache;
6 7 use RadiusTheme\SB\Helpers\Fns;
7 8 use RadiusTheme\SB\Models\TemplateSettings;
8 9 use RadiusTheme\SB\Traits\SingletonTrait;
9 10
@@ -40,22 +41,32 @@
40 41 if ( ! current_user_can( 'manage_options' ) ) {
41 42 wp_send_json_error();
42 43 }
43 44 $page_type = isset( $_POST['template_type'] ) ? sanitize_text_field( wp_unslash( $_POST['template_type'] ) ) : null; // phpcs:ignore WordPress.Security.NonceVerification.Missing
44 - $default_page_id = isset( $_POST['set_default_page_id'] ) && 'publish' === get_post_status( $_POST['set_default_page_id'] ) ? absint( wp_unslash( $_POST['set_default_page_id'] ) ) : null; // phpcs:ignore WordPress.Security.NonceVerification.Missing
45 - $page_id = isset( $_POST['page_id'] ) && 'publish' === get_post_status( $_POST['page_id'] ) ? absint( wp_unslash( $_POST['page_id'] ) ) : null; // phpcs:ignore WordPress.Security.NonceVerification.Missing
45 + $default_page_id = isset( $_POST['set_default_page_id'] ) && 'publish' === get_post_status( $_POST['set_default_page_id'] ) ? absint( wp_unslash( $_POST['set_default_page_id'] ) ) : null; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
46 + $page_id = isset( $_POST['page_id'] ) && 'publish' === get_post_status( $_POST['page_id'] ) ? absint( wp_unslash( $_POST['page_id'] ) ) : null; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
47 + Cache::clear_transient_cache();
48 + $the_cat_option = BuilderFns::archive_option_name_by_template_id( $page_id );
49 + $the_cats = TemplateSettings::instance()->get_option( $the_cat_option );
50 + $option_name = BuilderFns::option_name( $page_type );
51 + $product_page_for = get_post_meta( $page_id, '_is_product_page_template_for', true );
52 + $is_can_set_default = true;
53 + switch ( $page_type ) {
54 + case 'product':
55 + $product_page_for = empty( $product_page_for ) ? 'all_products' : $product_page_for;
56 + if ( 'all_products' !== $product_page_for ) {
57 + $is_can_set_default = null;
58 + }
59 + break;
60 + case 'archive':
61 + if ( ! empty( $the_cats ) ) {
62 + $is_can_set_default = null;
63 + }
64 + break;
65 + default:
66 + }
46 67
47 - // For Specific Product
48 - $the_option = BuilderFns::option_name_by_template_id( $page_id );
49 - $the_cat_option = BuilderFns::archive_option_name_by_template_id( $page_id );
50 -
51 - // $product_ids = get_option( $the_option );
52 - // $the_cats = get_option( $the_cat_option );
53 - $product_ids = TemplateSettings::instance()->get_option( $the_option );
54 - $the_cats = TemplateSettings::instance()->get_option( $the_cat_option );
55 - if ( empty( $product_ids ) && empty( $the_cats ) ) {
56 - $option_name = BuilderFns::option_name( $page_type );
57 - //update_option( $option_name, $default_page_id );
68 + if ( $is_can_set_default ) {
58 69 TemplateSettings::instance()->set_option( $option_name, $default_page_id );
59 70 }
60 71
61 72 do_action( 'rtsb/set/builder/default/template', $_POST, $page_id );
@@ -60,12 +71,11 @@
60 71
61 72 do_action( 'rtsb/set/builder/default/template', $_POST, $page_id );
62 73
63 74 $return = [
64 - 'post_id' => $default_page_id,
75 + 'post_id' => $default_page_id ,
65 76 'page_type' => $page_type,
66 77 ];
67 78 wp_send_json_success( $return );
68 79 wp_die();
69 80 }
70 -
71 81 }