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/ModalTemplate.php +54 -82 2.2.23.2.6 View file →
@@ -37,9 +37,9 @@
37 37 * Popups For Create Template
38 38 *
39 39 * @return void
40 40 */
41 - public function response() {
41 + public function response() { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.MaxExceeded
42 42 $title = '<h2>' . esc_html__( 'Template Settings', 'shopbuilder' ) . '</h2>';
43 43 if ( ! wp_verify_nonce( Fns::get_nonce(), rtsb()->nonceText ) ) {
44 44 $return = [
45 45 'success' => false,
@@ -56,9 +56,18 @@
56 56 'content' => esc_html__( 'Permission Denied...', 'shopbuilder' ),
57 57 ];
58 58 wp_send_json( $return );
59 59 }
60 + if ( ! defined( 'ELEMENTOR_VERSION' ) ) {
61 + $return = [
62 + 'success' => true,
63 + 'title' => $title,
64 + 'content' => '<h2 style="text-align: center;">' . esc_html__( 'Permission Denied. Please Install elementor', 'shopbuilder' ) . '</h2>',
65 + ];
60 66
67 + wp_send_json( $return );
68 + }
69 +
61 70 add_filter( 'option_' . Uploads_Manager::UNFILTERED_FILE_UPLOADS_KEY, '__return_true' );
62 71 Plugin::$instance->files_manager->clear_cache();
63 72
64 73 // user capability check.
@@ -64,20 +73,20 @@
64 73 // user capability check.
65 74 $user = wp_get_current_user();
66 75 $allowed_roles = [ 'editor', 'administrator', 'author' ];
67 76
68 - if ( ! array_intersect( $allowed_roles, $user->roles ) ) {
77 + if ( ! array_intersect( $allowed_roles, Fns::get_current_user_roles() ) ) {
69 78 wp_die( esc_html__( 'You don\'t have permission to perform this action', 'shopbuilder' ) );
70 79 }
71 80
72 81 // Check if the user is not logged in and the provided 'user_id' in the request does not match the currently logged-in user's ID.
73 - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
82 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.PHP.YodaConditions.NotYoda
74 83 if ( ! is_user_logged_in() && $user->ID !== sanitize_text_field( $_REQUEST['user_id'] ) ) {
75 84 wp_die( esc_html__( 'You don\'t have proper authorization to perform this action', 'shopbuilder' ) );
76 85 }
77 86
78 - $post_id = isset( $_POST['post_id'] ) ? absint( $_POST['post_id'] ) : null;
79 - $layout_id = isset( $_POST['layout_id'] ) ? absint( $_POST['layout_id'] ) : null;
87 + $post_id = isset( $_REQUEST['post_id'] ) ? absint( $_REQUEST['post_id'] ) : null;
88 + $layout_id = isset( $_REQUEST['layout_id'] ) ? absint( $_REQUEST['layout_id'] ) : null;
80 89
81 90 $template_type = null;
82 91 $product_page_for = 'all_products';
83 92 $template_default = null;
@@ -95,9 +104,9 @@
95 104 if ( rtsb()->has_pro() ) {
96 105 $product_page_for = get_post_meta( $post_id, '_is_product_page_template_for', true );
97 106 }
98 107
99 - // TODO:: This Condition Will remove after release Gutenberg Addons.
108 + /* This Condition Will remove after release Gutenberg Addons. */
100 109 if ( 'gutenberg' == $edit_by ) {
101 110 $action = 'elementor';
102 111 $edit_by = 'elementor';
103 112 }
@@ -115,21 +124,8 @@
115 124 );
116 125
117 126 $_rtsb_import_id = get_post_meta( $post_id, '_rtsb_import_id', true );
118 127 }
119 -
120 - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
121 - $status = $_REQUEST['status'] ?? '';
122 - $post_args = [ 'timeout' => 120 ];
123 - $post_args['body'] = [
124 - 'status' => $status,
125 - ];
126 - $layoutRequest = wp_remote_post( rtsb()->BASE_API, $post_args );
127 - $layoutData = [];
128 - if ( ! is_wp_error( $layoutRequest ) && ! empty( $layoutRequest['body'] ) ) {
129 - $layoutData = json_decode( $layoutRequest['body'], true );
130 - }
131 -
132 128 ob_start();
133 129
134 130 ?>
135 131 <form action="<?php echo esc_url( admin_url( 'edit.php?post_type=rtsb_builder' ) ); ?>" autocomplete="off" data-imported-id="<?php echo esc_attr( $_rtsb_import_id ); ?>">
@@ -359,8 +355,11 @@
359 355 $set_default = BuilderFns::get_specific_product_as_default( $post_id );
360 356 if ( $set_default ) {
361 357 $template_default = $post_id;
362 358 }
359 + if ( ! $set_default && $template_default === $post_id ) {
360 + $template_default = '';
361 + }
363 362 } else {
364 363 $set_default_option_name = '';
365 364 if ( 'product_cats' === $product_page_for ) {
366 365 $set_default_option_name = BuilderFns::option_name_product_page_specific_cat_set_default( $post_id );
@@ -366,9 +365,9 @@
366 365 $set_default_option_name = BuilderFns::option_name_product_page_specific_cat_set_default( $post_id );
367 366 } elseif ( 'product_tags' === $product_page_for ) {
368 367 $set_default_option_name = BuilderFns::option_name_product_page_specific_tag_set_default( $post_id );
369 368 }
370 - $default_id = TemplateSettings::instance()->get_option( $set_default_option_name );
369 + $default_id = ! empty( $set_default_option_name ) && TemplateSettings::instance()->get_option( $set_default_option_name );
371 370 if ( $default_id ) {
372 371 $template_default = $post_id;
373 372 }
374 373 }
@@ -376,9 +375,16 @@
376 375 $categories_name = apply_filters( 'rtsb/template/builder/selected/categories', [], $post_id, $template_type );
377 376 $set_default = BuilderFns::get_specific_category_as_default( $post_id );
378 377 if ( ! empty( $categories_name ) && $set_default ) {
379 378 $template_default = $post_id;
379 + } else {
380 + $option_name = BuilderFns::option_name( $template_type );
381 + $is_set_default = TemplateSettings::instance()->get_option( $option_name );
382 + $set_default = $is_set_default;
380 383 }
384 + if ( ! $set_default && $template_default === $post_id ) {
385 + $template_default = '';
386 + }
381 387 }
382 388
383 389 ?>
384 390 <span class="rtsb-switch-wrapper"
@@ -388,9 +394,9 @@
388 394 type="checkbox"
389 395 id="default_template"
390 396 name="default_template"
391 397 value="default_template"
392 - <?php echo esc_attr( ( $post_id && absint( $post_id ) === absint( $template_default ) ) ? 'checked' : '' ); ?>
398 + <?php echo esc_attr( ( $post_id && ( absint( $post_id ) === absint( $template_default ) ) ) ? 'checked' : '' ); ?>
393 399 >
394 400 <span class="rtsb-slider rtsb-round ">
395 401 <span class="rtsb-loader"></span>
396 402 </span>
@@ -397,32 +403,29 @@
397 403 </label>
398 404 </span>
399 405 </div>
400 406 <!-- TODO: Moday Layout -->
401 - <?php if ( ! $post_id ) { ?>
402 - <div class="set-default-layout-wrapper rtsb-tb-field-wraper">
403 - <label>
404 - <?php esc_html_e( 'Pre-built Templates ', 'shopbuilder' ); ?>
405 - <span id="modallabelPrefix"></span>
406 - </label>
407 - <div class="set-default-layout">
408 - <?php
409 - $default_item = [
410 - 'template_type' => 'default',
411 - 'image_url' => \Elementor\Utils::get_placeholder_image_src(),
412 - 'preview_link' => '',
413 - 'title' => __( 'Blank Template', 'shopbuilder' ),
414 - ];
415 -
416 - $this->get_modal_card_html( $default_item );
417 -
418 - if ( ! empty( $layoutData['layouts'] ) ) {
419 - foreach ( $layoutData['layouts'] as $item ) {
420 - $this->get_modal_card_html( $item );
421 - }
422 - }
423 - ?>
407 + <?php
408 + if ( ! $post_id ) {
409 + if ( defined( 'ELEMENTOR_PATH' ) && class_exists( '\Elementor\Utils' ) ) {
410 + $placeholderImageSrc = \Elementor\Utils::get_placeholder_image_src();
411 + } else {
412 + $placeholderImageSrc = '#';
413 + }
414 + ?>
415 + <div class="set-default-layout-wrapper rtsb-tb-field-wraper" style="opacity: 0" >
416 + <div style="display: flex; justify-content: space-between;">
417 + <label>
418 + <?php esc_html_e( 'Pre-built Templates ', 'shopbuilder' ); ?>
419 + <span id="modallabelPrefix"></span>
420 + </label>
421 + <div class="rtsb-tb-button-wrapper">
422 + <a class="btn" href="https://shopbuilderwp.com/themes/" target="_blank" style="opacity: 1; visibility: visible;">View Out Themes</a>
423 + </div>
424 424 </div>
425 + <div class="set-default-layout" data-has-pro="<?php echo esc_attr( rtsb()->has_pro() ); ?>" data-rest-url="<?php echo esc_url( rtsb()->BASE_API ); ?>" data-placeholder-image-src="<?php echo esc_url( $placeholderImageSrc ); ?>">
426 + <!-- Layout Will Add Via Ajax-->
427 + </div>
425 428 </div>
426 429 <?php } ?>
427 430 <input type="hidden" id="page_id" name="page_id" value="<?php echo esc_attr( $post_id ); ?>">
428 431 </div>
@@ -460,55 +463,20 @@
460 463 wp_send_json( $return );
461 464 wp_die();
462 465 }
463 466
464 - public function default_layout_template_html( $key, $is_checked, $builder, $value = [] ) {
465 - $layout_type = $key . ( $builder ? '_' . $builder : null );
466 - ?>
467 - <!-- Elementor -->
468 - <label class="layout-container type-<?php echo esc_attr( $key ); ?>"
469 - data-layout-type='<?php echo esc_attr( $layout_type ); ?>'>
470 - <input <?php echo esc_attr( $is_checked ); ?>
471 - class="rtsb-field" type="radio"
472 - value="<?php echo ! empty( $value['import_file'] ) ? esc_attr( $value['import_file'] ) : ''; ?>"
473 - name="import_default_layout"/>
474 -
475 - <span class="checkmark dashicons"></span>
476 - <div class="image-wrapper">
477 - <?php if ( ! empty( $value['image'] ) ) { ?>
478 - <img src="<?php echo esc_url( $value['image'] ); ?>" alt="">
479 - <?php } ?>
480 - </div>
481 - <?php if ( ! empty( $value['text_label'] ) ) { ?>
482 - <div class="image-label">
483 - <span class="label-text"><?php echo esc_html( $value['text_label'] ); ?></span>
484 - <?php if ( ! empty( $value['live_preview'] ) ) { ?>
485 - <a target="_blank" class="btn-live-preview" href="<?php echo esc_url( $value['live_preview'] ); ?>">
486 - <span class="dashicons dashicons-visibility"></span>
487 - <?php esc_html_e( 'Live Preview', 'shopbuilder' ); ?>
488 - </a>
489 - <?php } ?>
490 - </div>
491 - <?php } ?>
492 - </label>
493 - <?php
494 - }
495 -
496 467 /**
497 468 * Get Modal Card Markup.
498 469 *
499 - * @param $item
500 - * @param $checked
470 + * @param array $item Item.
501 471 *
502 472 * @return void
503 473 */
504 474 public function get_modal_card_html( $item ) {
505 -
506 475 ?>
507 476 <div class="layout-container rtsb-template-item type-<?php echo esc_attr( $item['template_type'] ); ?>"
508 477 data-layout-type='<?php echo esc_attr( $item['template_type'] ); ?>'>
509 478 <input class="rtsb-field" type="hidden" value="<?php echo esc_attr( $item['id'] ?? '' ); ?>" name="import_default_layout"/>
510 -
511 479 <div class="image-wrapper">
512 480 <?php if ( $item['image_url'] ) : ?>
513 481 <img src="<?php echo esc_url( $item['image_url'] ); ?>" alt="<?php echo esc_attr( $item['title'] ); ?>">
514 482 <?php endif; ?>
@@ -513,9 +481,10 @@
513 481 <img src="<?php echo esc_url( $item['image_url'] ); ?>" alt="<?php echo esc_attr( $item['title'] ); ?>">
514 482 <?php endif; ?>
515 483
516 484 <?php if ( 'default' != $item['template_type'] && ( ! rtsb()->has_pro() ) ) : ?>
517 - <div class="card-label">
485 + <div class="card-label lllllll">
486 + label
518 487 <span class="rtsb-btn-import <?php echo esc_attr( $item['status'] ?? 'free' ); ?>-btn">
519 488 <?php echo esc_html( $item['status'] ?? 'Free' ); ?>
520 489 </span>
521 490 </div>
@@ -533,9 +502,12 @@
533 502 <?php echo esc_html__( 'Preview', 'shopbuilder' ); ?>
534 503 </a>
535 504
536 505
537 - <?php if ( rtsb()->has_pro() || $item['status'] == 'free' ) : ?>
506 + <?php
507 + // phpcs:ignore WordPress.PHP.YodaConditions.NotYoda
508 + if ( rtsb()->has_pro() || $item['status'] == 'free' ) :
509 + ?>
538 510 <a class="rtsb-btn-import import-btn rtsb-import-layout">
539 511 <svg width="22" height="20" viewBox="0 0 22 20" fill="none" xmlns="http://www.w3.org/2000/svg">
540 512 <path d="M11 12.2295C10.9048 12.2296 10.8106 12.2113 10.7226 12.1757C10.6347 12.14 10.5547 12.0878 10.4874 12.0219C10.4201 11.956 10.3668 11.8778 10.3304 11.7917C10.294 11.7056 10.2753 11.6134 10.2754 11.5202L10.2754 0.912773C10.2754 0.72466 10.3517 0.544251 10.4876 0.411235C10.6235 0.278219 10.8078 0.203491 11 0.203491C11.1922 0.203491 11.3765 0.278219 11.5124 0.411235C11.6483 0.544251 11.7246 0.72466 11.7246 0.912773L11.7246 11.5202C11.7246 11.7083 11.6483 11.8887 11.5124 12.0218C11.3765 12.1548 11.1922 12.2295 11 12.2295Z"
541 513 fill="white"></path>