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/Helpers/BuilderFns.php +29 -129 2.2.2 → 2.1.13 View file →
@@ -59,20 +59,8 @@
59 59 */
60 60 public static $view_template_for_archive_meta = 'rtsb_template_for_selected_category';
61 61
62 62 /**
63 - * Template builder
64 - *
65 - * @var string
66 - */
67 - public static $categories_product_page_template = 'rtsb_categories_product_page_template';
68 - /**
69 - * Template builder
70 - *
71 - * @var string
72 - */
73 - public static $tags_product_page_template = 'rtsb_tags_product_page_template';
74 - /**
75 63 * Page builder id.
76 64 *
77 65 * @return int
78 66 */
@@ -81,14 +69,16 @@
81 69
82 70 if ( ! array_key_exists( $type, self::builder_page_types() ) ) {
83 71 return 0;
84 72 }
73 +
85 74 // Wpml Supported.
86 75 $options = self::option_name( $type );
87 76 $post_id = TemplateSettings::instance()->get_option( $options );
88 77 if ( empty( $post ) ) {
89 - return 0;
78 + return $post_id;
90 79 }
80 +
91 81 if ( empty( $post_id ) ) {
92 82 $options = self::option_name( $type, true );
93 83 $post_id = TemplateSettings::instance()->get_option( $options );
94 84 }
@@ -96,87 +86,40 @@
96 86 $cache_key = 'rtsb_builder_page_id_by_type_' . $type;
97 87 if ( isset( self::$cache[ $cache_key ] ) ) {
98 88 return self::$cache[ $cache_key ];
99 89 }
100 -
101 90 switch ( $type ) {
102 91 case 'product':
103 - if ( 'product' !== $post->post_type ) {
104 - break;
105 - }
106 - $cache_key_product = 'template_for_product_page_' . get_the_ID();
107 - $template = get_transient( $cache_key_product );
108 - if ( $template && 'publish' === get_post_status( $template ) ) {
109 - $post_id = $template;
110 - break;
111 - }
112 - Cache::set_transient_cache_key( $cache_key_product );
113 - $builder_id = get_post_meta( get_the_ID(), self::$view_template_for_products_meta, true );
92 + if ( 'product' === $post->post_type ) {
93 + $builder_id = get_post_meta( get_the_ID(), self::$view_template_for_products_meta, true );
94 + $set_default = self::get_specific_product_as_default( $builder_id );
114 95
115 - if ( self::get_specific_product_as_default( $builder_id ) && 'publish' === get_post_status( $builder_id ) ) {
116 - $post_id = $builder_id;
117 - set_transient( $cache_key_product, $post_id, 12 * HOUR_IN_SECONDS ); // Cache duration: 12 hours.
118 - break;
119 - }
120 -
121 - $terms = get_the_terms( get_the_ID(), 'product_cat' );
122 - if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) {
123 - foreach ( $terms as $term ) {
124 - $template_id = get_term_meta( $term->term_id, self::$categories_product_page_template, true );
125 - if ( empty( $template_id ) || 'publish' !== get_post_status( $template_id ) ) {
126 - continue;
127 - }
128 - $set_default_option_name = self::option_name_product_page_specific_cat_set_default( $template_id );
129 - if ( TemplateSettings::instance()->get_option( $set_default_option_name ) ) {
130 - $post_id = $template_id;
131 - set_transient( $cache_key_product, $post_id, 12 * HOUR_IN_SECONDS ); // Cache duration: 12 hours.
132 - break 2;
133 - }
96 + if ( 'publish' === $post->post_status ) {
97 + $post_id = $builder_id && $set_default ? $builder_id : $post_id;
134 98 }
135 99 }
136 - $tags = get_the_terms( get_the_ID(), 'product_tag' );
137 - if ( ! is_wp_error( $tags ) && ! empty( $tags ) ) {
138 - foreach ( $tags as $term ) {
139 - $template_id = get_term_meta( $term->term_id, self::$tags_product_page_template, true );
140 - if ( empty( $template_id ) || 'publish' !== get_post_status( $template_id ) ) {
141 - continue;
142 - }
143 - $set_default_option_name = self::option_name_product_page_specific_tag_set_default( $template_id );
144 - if ( TemplateSettings::instance()->get_option( $set_default_option_name ) ) {
145 - $post_id = $template_id;
146 - set_transient( $cache_key_product, $post_id, 12 * HOUR_IN_SECONDS ); // Cache duration: 12 hours.
147 - break 2;
148 - }
149 - }
150 - }
151 - set_transient( $cache_key_product, $post_id, 12 * HOUR_IN_SECONDS );
152 100 break;
153 101 case 'archive':
154 102 $queried_object = get_queried_object();
103 +
155 104 if ( ! empty( $queried_object->taxonomy ) && 'product_cat' === $queried_object->taxonomy ) {
156 - $cache_key_archive = 'template_for_archive_page_' . $queried_object->term_id;
157 - $template = get_transient( $cache_key_archive );
158 - if ( $template && 'publish' === get_post_status( $template ) ) {
159 - $post_id = $template;
160 - break;
105 + $builder_id = get_term_meta( $queried_object->term_id, self::$view_template_for_archive_meta, true );
106 + $set_default = self::get_specific_category_as_default( $builder_id );
107 +
108 + if ( 'publish' === $post->post_status ) {
109 + $post_id = $builder_id && $set_default ? $builder_id : $post_id;
161 110 }
162 - Cache::set_transient_cache_key( $cache_key_archive );
163 - $builder_id = get_term_meta( $queried_object->term_id, self::$view_template_for_archive_meta, true );
164 - if ( self::get_specific_category_as_default( $builder_id ) && 'publish' === get_post_status( $builder_id ) ) {
165 - $post_id = $builder_id;
166 - set_transient( $cache_key_archive, $post_id, 12 * HOUR_IN_SECONDS ); // Cache duration: 12 hours.
167 - }
168 111 }
169 112 break;
170 113
171 114 default:
172 115 }
173 - if ( 'publish' === get_post_status( $post_id ) && self::builder_type( $post_id ) === $type ) {
116 + if ( 'publish' === $post->post_status && self::builder_type( $post_id ) === $type ) {
174 117 self::$cache[ $cache_key ] = $post_id;
175 118 return $post_id;
176 119 }
177 120
178 - return 0;
121 + return $post_id;
179 122 }
180 123
181 124 /**
182 125 * Page builder id.
@@ -185,9 +128,9 @@
185 128 */
186 129 public static function builder_page_id_by_page() {
187 130 $type = apply_filters( 'rtsb/builder/set/current/page/type', '' );
188 131 if ( ! $type ) {
189 - return 0;
132 + return;
190 133 }
191 134
192 135 return self::builder_page_id_by_type( $type );
193 136 }
@@ -256,9 +199,9 @@
256 199 return;
257 200 }
258 201 $options = self::option_name_for_specific_product_set_default( $post_id );
259 202
260 - return TemplateSettings::instance()->get_option( $options );
203 + return TemplateSettings::instance()->get_option( $options ); // get_option( $options );
261 204 }
262 205
263 206 /**
264 207 * @param $post_id
@@ -305,60 +248,8 @@
305 248 * @param $template_id
306 249 *
307 250 * @return string
308 251 */
309 - public static function option_name_product_page_selected_cat( $template_id ) {
310 - $_suff = null;
311 - if ( $template_id ) {
312 - $_suff = '_' . $template_id;
313 - }
314 -
315 - return self::$categories_product_page_template . $_suff;
316 - }
317 -
318 - /**
319 - * @param $post_id
320 - *
321 - * @return string|void
322 - */
323 - public static function option_name_product_page_specific_cat_set_default( $post_id ) {
324 - if ( ! $post_id ) {
325 - return;
326 - }
327 -
328 - return 'rtsb_template_product_page_specific_category_set_default_' . $post_id;
329 - }
330 -
331 - /**
332 - * @param $template_id
333 - *
334 - * @return string
335 - */
336 - public static function option_name_product_page_selected_tag( $template_id ) {
337 - $_suff = null;
338 - if ( $template_id ) {
339 - $_suff = '_' . $template_id;
340 - }
341 -
342 - return self::$tags_product_page_template . $_suff;
343 - }
344 - /**
345 - * @param $post_id
346 - *
347 - * @return string|void
348 - */
349 - public static function option_name_product_page_specific_tag_set_default( $post_id ) {
350 - if ( ! $post_id ) {
351 - return;
352 - }
353 -
354 - return 'rtsb_template_product_page_specific_tag_set_default_' . $post_id;
355 - }
356 - /**
357 - * @param $template_id
358 - *
359 - * @return string
360 - */
361 252 public static function archive_option_name_by_template_id( $template_id ) {
362 253 $_suff = null;
363 254 if ( $template_id ) {
364 255 $_suff = '_' . $template_id;
@@ -383,16 +274,17 @@
383 274 *
384 275 * @return string
385 276 */
386 277 public static function builder_type( $post_id ) {
278 +
387 279 $post_id = Fns::wpml_object_id( $post_id, self::$post_type_tb, 'default' );
388 280
389 281 if ( ! $post_id ) {
390 - return;
282 + return;
391 283 }
392 284
393 285 $cache_key = 'rtsb_template_type_' . $post_id;
394 - if ( ! empty( self::$cache[ $cache_key ] ) ) {
286 + if ( isset( self::$cache[ $cache_key ] ) ) {
395 287 return self::$cache[ $cache_key ];
396 288 }
397 289
398 290 $type = get_post_meta( $post_id, self::template_type_meta_key(), true );
@@ -474,8 +366,16 @@
474 366 *
475 367 * @return boolean
476 368 */
477 369 public static function is_page_builder( $type, $is_page, $is_require_auth = false ) {
370 + // if ( 'myaccount-dashboard' === $type ) {
371 + // $current_url = esc_url_raw( home_url( add_query_arg( null, null ) ) );
372 + //
373 + // if ( wc_get_account_endpoint_url( 'dashboard' ) !== $current_url ) {
374 + // return false;
375 + // }
376 + // }
377 +
478 378 if ( self::builder_type( get_the_ID() ) === $type ) {
479 379 return true;
480 380 }
481 381