PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.4.0
ShopBuilder – WooCommerce Builder For Elementor v3.4.0
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 +24 -8 2.2.0 → 3.4.0 View file →
@@ -41,19 +41,19 @@
41 41 if ( ! current_user_can( 'manage_options' ) ) {
42 42 wp_send_json_error();
43 43 }
44 44 $page_type = isset( $_POST['template_type'] ) ? sanitize_text_field( wp_unslash( $_POST['template_type'] ) ) : 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.NonceVerification.Missing
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.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 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 -
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 );
53 52 $is_can_set_default = true;
54 53 switch ( $page_type ) {
55 54 case 'product':
55 + $product_page_for = empty( $product_page_for ) ? 'all_products' : $product_page_for;
56 56 if ( 'all_products' !== $product_page_for ) {
57 57 $is_can_set_default = null;
58 58 }
59 59 break;
@@ -63,10 +63,26 @@
63 63 }
64 64 break;
65 65 default:
66 66 }
67 +
67 68 if ( $is_can_set_default ) {
68 - TemplateSettings::instance()->set_option( $option_name, $default_page_id );
69 + $singleton_types = apply_filters(
70 + 'rtsb/builder/singleton_types',
71 + array_keys( BuilderFns::builder_page_types() )
72 + );
73 +
74 + if ( in_array( $page_type, $singleton_types, true ) ) {
75 + // Singleton path: one enabled template per type — overwrite the type-wide option.
76 + TemplateSettings::instance()->set_option( $option_name, $default_page_id );
77 + } elseif ( $page_id ) {
78 + // Pool path: multi-enabled type — flip per-post meta flag, don't touch the type-wide option.
79 + if ( ! empty( $default_page_id ) ) {
80 + update_post_meta( $page_id, '_rtsb_tb_enabled_in_pool', 'on' );
81 + } else {
82 + delete_post_meta( $page_id, '_rtsb_tb_enabled_in_pool' );
83 + }
84 + }
69 85 }
70 86
71 87 do_action( 'rtsb/set/builder/default/template', $_POST, $page_id );
72 88