BuyButton.php
3 months ago
CartMenuIcon.php
5 months ago
CollectionTag.php
1 year ago
CollectionTags.php
1 year ago
Media.php
1 year ago
PriceChoiceTemplate.php
1 year ago
PriceChooser.php
4 months ago
PriceData.php
1 year ago
Product.php
4 months ago
ProductCard.php
10 months ago
ProductContent.php
10 months ago
ProductData.php
1 year ago
ProductLineItemNote.php
10 months ago
ProductQuickAddButton.php
10 months ago
ProductReviewAverageRatingStars.php
4 months ago
ProductReviewAverageRatingValue.php
4 months ago
ProductReviewBreakdown.php
4 months ago
ProductReviewContent.php
4 months ago
ProductReviewList.php
2 months ago
ProductReviewRating.php
4 months ago
ProductReviewTotalRating.php
4 months ago
ProductReviews.php
4 months ago
Quantity.php
10 months ago
SaleBadge.php
1 year ago
SelectedPriceAdHocAmount.php
1 year ago
VariantPill.php
6 months ago
VariantPills.php
1 year ago
ProductReviewList.php
931 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCart\Integrations\Bricks\Elements; |
| 4 | |
| 5 | use SureCart\Integrations\Bricks\Concerns\ConvertsBlocks; |
| 6 | |
| 7 | if ( ! defined( 'ABSPATH' ) ) { |
| 8 | exit; // Exit if accessed directly. |
| 9 | } |
| 10 | |
| 11 | /** |
| 12 | * Product Review List element. |
| 13 | */ |
| 14 | class ProductReviewList extends \Bricks\Element { |
| 15 | use ConvertsBlocks; |
| 16 | |
| 17 | /** |
| 18 | * Element category. |
| 19 | * |
| 20 | * @var string |
| 21 | */ |
| 22 | public $category = 'SureCart Elements'; |
| 23 | |
| 24 | /** |
| 25 | * Element name. |
| 26 | * |
| 27 | * @var string |
| 28 | */ |
| 29 | public $name = 'surecart-product-review-list'; |
| 30 | |
| 31 | /** |
| 32 | * Element block name. |
| 33 | * |
| 34 | * @var string |
| 35 | */ |
| 36 | public $block_name = 'surecart/product-review-list'; |
| 37 | |
| 38 | /** |
| 39 | * Element icon. |
| 40 | * |
| 41 | * @var string |
| 42 | */ |
| 43 | public $icon = 'ti-list'; |
| 44 | |
| 45 | /** |
| 46 | * Get element label. |
| 47 | * |
| 48 | * @return string |
| 49 | */ |
| 50 | public function get_label() { |
| 51 | return esc_html__( 'Product Review List', 'surecart' ); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Set control groups. |
| 56 | * |
| 57 | * @return void |
| 58 | */ |
| 59 | public function set_control_groups() { |
| 60 | $this->control_groups['review_header'] = [ |
| 61 | 'title' => esc_html__( 'Review Header', 'surecart' ), |
| 62 | 'tab' => 'content', |
| 63 | ]; |
| 64 | |
| 65 | $this->control_groups['review_button'] = [ |
| 66 | 'title' => esc_html__( 'Add Review Button', 'surecart' ), |
| 67 | 'tab' => 'content', |
| 68 | 'required' => [ 'show_add_button', '=', true ], |
| 69 | ]; |
| 70 | |
| 71 | $this->control_groups['review_item'] = [ |
| 72 | 'title' => esc_html__( 'Review Item', 'surecart' ), |
| 73 | 'tab' => 'content', |
| 74 | ]; |
| 75 | |
| 76 | $this->control_groups['pagination'] = [ |
| 77 | 'title' => esc_html__( 'Pagination', 'surecart' ), |
| 78 | 'tab' => 'content', |
| 79 | ]; |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Set controls. |
| 84 | * |
| 85 | * @return void |
| 86 | */ |
| 87 | public function set_controls() { |
| 88 | $this->controls['show_header'] = [ |
| 89 | 'tab' => 'content', |
| 90 | 'group' => 'review_header', |
| 91 | 'label' => esc_html__( 'Show Header', 'surecart' ), |
| 92 | 'type' => 'checkbox', |
| 93 | 'default' => true, |
| 94 | ]; |
| 95 | |
| 96 | $this->controls['show_sidebar'] = [ |
| 97 | 'tab' => 'content', |
| 98 | 'group' => 'review_header', |
| 99 | 'label' => esc_html__( 'Show Filter & Sidebar', 'surecart' ), |
| 100 | 'type' => 'checkbox', |
| 101 | 'default' => true, |
| 102 | ]; |
| 103 | |
| 104 | $this->controls['show_add_button'] = [ |
| 105 | 'tab' => 'content', |
| 106 | 'group' => 'review_header', |
| 107 | 'label' => esc_html__( 'Show Add Review Button', 'surecart' ), |
| 108 | 'type' => 'checkbox', |
| 109 | 'default' => true, |
| 110 | ]; |
| 111 | |
| 112 | $this->controls['add_button_label'] = [ |
| 113 | 'tab' => 'content', |
| 114 | 'group' => 'review_button', |
| 115 | 'label' => esc_html__( 'Button Text', 'surecart' ), |
| 116 | 'type' => 'text', |
| 117 | 'default' => esc_html__( 'Write a Review', 'surecart' ), |
| 118 | 'required' => [ 'show_add_button', '=', true ], |
| 119 | ]; |
| 120 | |
| 121 | $this->controls['add_button_icon_size'] = [ |
| 122 | 'tab' => 'content', |
| 123 | 'group' => 'review_button', |
| 124 | 'label' => esc_html__( 'Icon Size', 'surecart' ), |
| 125 | 'type' => 'number', |
| 126 | 'default' => 15, |
| 127 | 'min' => 10, |
| 128 | 'max' => 100, |
| 129 | 'step' => 1, |
| 130 | 'required' => [ 'show_add_button', '=', true ], |
| 131 | 'description' => esc_html__( 'Size of the icon in pixels.', 'surecart' ), |
| 132 | 'css' => [ |
| 133 | [ |
| 134 | 'property' => 'width', |
| 135 | 'selector' => '.wp-block-surecart-product-review-add-button svg', |
| 136 | ], |
| 137 | [ |
| 138 | 'property' => 'height', |
| 139 | 'selector' => '.wp-block-surecart-product-review-add-button svg', |
| 140 | ], |
| 141 | ], |
| 142 | ]; |
| 143 | |
| 144 | $this->controls['add_button_text_color'] = [ |
| 145 | 'tab' => 'content', |
| 146 | 'group' => 'review_button', |
| 147 | 'label' => esc_html__( 'Button Text Color', 'surecart' ), |
| 148 | 'type' => 'color', |
| 149 | 'reset' => true, |
| 150 | 'required' => [ 'show_add_button', '=', true ], |
| 151 | 'default' => [ |
| 152 | 'hex' => '#000000', |
| 153 | ], |
| 154 | 'css' => [ |
| 155 | [ |
| 156 | 'property' => 'color', |
| 157 | 'selector' => '.wp-block-surecart-product-review-add-button .wp-block-button__link', |
| 158 | 'important' => true, |
| 159 | ], |
| 160 | ], |
| 161 | ]; |
| 162 | |
| 163 | $this->controls['add_button_icon_color'] = [ |
| 164 | 'tab' => 'content', |
| 165 | 'group' => 'review_button', |
| 166 | 'label' => esc_html__( 'Button Icon Color', 'surecart' ), |
| 167 | 'type' => 'color', |
| 168 | 'reset' => true, |
| 169 | 'required' => [ 'show_add_button', '=', true ], |
| 170 | 'default' => [ |
| 171 | 'hex' => '#000000', |
| 172 | ], |
| 173 | 'css' => [ |
| 174 | [ |
| 175 | 'property' => 'stroke', |
| 176 | 'selector' => '.wp-block-surecart-product-review-add-button svg', |
| 177 | 'important' => true, |
| 178 | ], |
| 179 | ], |
| 180 | ]; |
| 181 | |
| 182 | $this->controls['add_button_background_color'] = [ |
| 183 | 'tab' => 'content', |
| 184 | 'group' => 'review_button', |
| 185 | 'label' => esc_html__( 'Button Background Color', 'surecart' ), |
| 186 | 'type' => 'color', |
| 187 | 'reset' => true, |
| 188 | 'required' => [ 'show_add_button', '=', true ], |
| 189 | 'default' => [ |
| 190 | 'hex' => 'var(--bricks-color-primary)', |
| 191 | ], |
| 192 | 'css' => [ |
| 193 | [ |
| 194 | 'property' => 'background-color', |
| 195 | 'selector' => '.wp-block-surecart-product-review-add-button .wp-block-button__link', |
| 196 | 'important' => true, |
| 197 | ], |
| 198 | ], |
| 199 | ]; |
| 200 | |
| 201 | $this->controls['add_button_border_width'] = [ |
| 202 | 'tab' => 'content', |
| 203 | 'group' => 'review_button', |
| 204 | 'label' => esc_html__( 'Button Border Width', 'surecart' ), |
| 205 | 'type' => 'number', |
| 206 | 'units' => true, |
| 207 | 'required' => [ 'show_add_button', '=', true ], |
| 208 | 'css' => [ |
| 209 | [ |
| 210 | 'property' => 'border-width', |
| 211 | 'selector' => '.wp-block-surecart-product-review-add-button .wp-block-button__link', |
| 212 | 'important' => true, |
| 213 | ], |
| 214 | ], |
| 215 | ]; |
| 216 | |
| 217 | $this->controls['add_button_border_color'] = [ |
| 218 | 'tab' => 'content', |
| 219 | 'group' => 'review_button', |
| 220 | 'label' => esc_html__( 'Button Border Color', 'surecart' ), |
| 221 | 'type' => 'color', |
| 222 | 'reset' => true, |
| 223 | 'required' => [ 'show_add_button', '=', true ], |
| 224 | 'css' => [ |
| 225 | [ |
| 226 | 'property' => 'border-color', |
| 227 | 'selector' => '.wp-block-surecart-product-review-add-button .wp-block-button__link', |
| 228 | 'important' => true, |
| 229 | ], |
| 230 | ], |
| 231 | ]; |
| 232 | |
| 233 | $this->controls['add_button_border_radius'] = [ |
| 234 | 'tab' => 'content', |
| 235 | 'group' => 'review_button', |
| 236 | 'label' => esc_html__( 'Button Border Radius', 'surecart' ), |
| 237 | 'type' => 'number', |
| 238 | 'units' => true, |
| 239 | 'required' => [ 'show_add_button', '=', true ], |
| 240 | 'css' => [ |
| 241 | [ |
| 242 | 'property' => 'border-radius', |
| 243 | 'selector' => '.wp-block-surecart-product-review-add-button .wp-block-button__link', |
| 244 | 'important' => true, |
| 245 | ], |
| 246 | ], |
| 247 | ]; |
| 248 | |
| 249 | $this->controls['show_review_date'] = [ |
| 250 | 'tab' => 'content', |
| 251 | 'group' => 'review_item', |
| 252 | 'label' => esc_html__( 'Show Review Date', 'surecart' ), |
| 253 | 'type' => 'checkbox', |
| 254 | 'default' => true, |
| 255 | ]; |
| 256 | |
| 257 | $this->controls['show_content'] = [ |
| 258 | 'tab' => 'content', |
| 259 | 'group' => 'review_item', |
| 260 | 'label' => esc_html__( 'Show Review Content', 'surecart' ), |
| 261 | 'type' => 'checkbox', |
| 262 | 'default' => true, |
| 263 | ]; |
| 264 | |
| 265 | $this->controls['verified_badge_icon_size'] = [ |
| 266 | 'tab' => 'content', |
| 267 | 'group' => 'review_item', |
| 268 | 'label' => esc_html__( 'Verified Badge Icon Size', 'surecart' ), |
| 269 | 'type' => 'number', |
| 270 | 'units' => true, |
| 271 | 'default' => 16, |
| 272 | 'min' => 10, |
| 273 | 'max' => 50, |
| 274 | 'step' => 1, |
| 275 | 'description' => esc_html__( 'Size of the verified badge icon in pixels.', 'surecart' ), |
| 276 | 'css' => [ |
| 277 | [ |
| 278 | 'property' => 'width', |
| 279 | 'selector' => '.wp-block-surecart-product-review-verified-badge svg', |
| 280 | 'important' => true, |
| 281 | ], |
| 282 | [ |
| 283 | 'property' => 'height', |
| 284 | 'selector' => '.wp-block-surecart-product-review-verified-badge svg', |
| 285 | 'important' => true, |
| 286 | ], |
| 287 | [ |
| 288 | 'property' => 'gap', |
| 289 | 'selector' => '.wp-block-surecart-product-review-verified-badge', |
| 290 | 'value' => '4px', |
| 291 | 'important' => true, |
| 292 | ], |
| 293 | [ |
| 294 | 'property' => 'display', |
| 295 | 'selector' => '.wp-block-surecart-product-review-verified-badge .sc-product-review-verified-badge__icon', |
| 296 | 'value' => 'inline-flex', |
| 297 | 'important' => true, |
| 298 | ], |
| 299 | [ |
| 300 | 'property' => 'align-items', |
| 301 | 'selector' => '.wp-block-surecart-product-review-verified-badge .sc-product-review-verified-badge__icon', |
| 302 | 'value' => 'center', |
| 303 | 'important' => true, |
| 304 | ], |
| 305 | ], |
| 306 | ]; |
| 307 | |
| 308 | $this->controls['verified_badge_icon_color'] = [ |
| 309 | 'tab' => 'content', |
| 310 | 'group' => 'review_item', |
| 311 | 'label' => esc_html__( 'Verified Badge Icon Color', 'surecart' ), |
| 312 | 'type' => 'color', |
| 313 | 'reset' => true, |
| 314 | 'description' => esc_html__( 'Color of the verified badge icon.', 'surecart' ), |
| 315 | 'css' => [ |
| 316 | [ |
| 317 | 'property' => 'color', |
| 318 | 'selector' => '.wp-block-surecart-product-review-verified-badge .sc-product-review-verified-badge__icon', |
| 319 | 'important' => true, |
| 320 | ], |
| 321 | ], |
| 322 | ]; |
| 323 | |
| 324 | $this->controls['fill_color'] = [ |
| 325 | 'tab' => 'content', |
| 326 | 'group' => 'review_item', |
| 327 | 'label' => esc_html__( 'Star Color', 'surecart' ), |
| 328 | 'type' => 'color', |
| 329 | 'default' => [ |
| 330 | 'hex' => 'var(--bricks-color-primary)', |
| 331 | ], |
| 332 | 'reset' => true, |
| 333 | 'css' => [ |
| 334 | [ |
| 335 | 'property' => 'fill', |
| 336 | 'selector' => '.sc-star-row__label__svg', |
| 337 | 'important' => true, |
| 338 | ], |
| 339 | [ |
| 340 | 'property' => 'stroke', |
| 341 | 'selector' => '.sc-star-row__label__svg', |
| 342 | 'important' => true, |
| 343 | ], |
| 344 | ], |
| 345 | ]; |
| 346 | |
| 347 | // Star Icon size. |
| 348 | $this->controls['star_size'] = [ |
| 349 | 'tab' => 'content', |
| 350 | 'group' => 'review_item', |
| 351 | 'label' => esc_html__( 'Star Icon Size', 'surecart' ), |
| 352 | 'type' => 'number', |
| 353 | 'units' => true, |
| 354 | 'default' => 20, |
| 355 | 'min' => 10, |
| 356 | 'max' => 100, |
| 357 | 'step' => 1, |
| 358 | 'description' => esc_html__( 'Size of the star icon in pixels.', 'surecart' ), |
| 359 | 'css' => [ |
| 360 | [ |
| 361 | 'property' => 'width', |
| 362 | 'selector' => '.sc-star-row__label__svg', |
| 363 | 'important' => true, |
| 364 | ], |
| 365 | [ |
| 366 | 'property' => 'height', |
| 367 | 'selector' => '.sc-star-row__label__svg', |
| 368 | 'important' => true, |
| 369 | ], |
| 370 | ], |
| 371 | ]; |
| 372 | |
| 373 | // Review border color. |
| 374 | $this->controls['review_border_color'] = [ |
| 375 | 'tab' => 'content', |
| 376 | 'group' => 'review_item', |
| 377 | 'label' => esc_html__( 'Review Border Color', 'surecart' ), |
| 378 | 'type' => 'color', |
| 379 | 'reset' => true, |
| 380 | 'default' => [ |
| 381 | 'hex' => '#e5e7eb', |
| 382 | ], |
| 383 | 'css' => [ |
| 384 | [ |
| 385 | 'property' => 'border-bottom-color', |
| 386 | 'selector' => '.wp-block-surecart-product-review-list .sc-product-review-link > .wp-block-group', |
| 387 | 'important' => true, |
| 388 | ], |
| 389 | ], |
| 390 | ]; |
| 391 | |
| 392 | // Review spacing (padding top/bottom). |
| 393 | $this->controls['review_spacing'] = [ |
| 394 | 'tab' => 'content', |
| 395 | 'group' => 'review_item', |
| 396 | 'label' => esc_html__( 'Review Spacing', 'surecart' ), |
| 397 | 'type' => 'number', |
| 398 | 'units' => true, |
| 399 | 'default' => 24, |
| 400 | 'min' => 0, |
| 401 | 'max' => 200, |
| 402 | 'css' => [ |
| 403 | [ |
| 404 | 'property' => 'padding-top', |
| 405 | 'selector' => '.wp-block-surecart-product-review-list .sc-product-review-link > .wp-block-group', |
| 406 | 'important' => true, |
| 407 | ], |
| 408 | [ |
| 409 | 'property' => 'padding-bottom', |
| 410 | 'selector' => '.wp-block-surecart-product-review-list .sc-product-review-link > .wp-block-group', |
| 411 | 'important' => true, |
| 412 | ], |
| 413 | ], |
| 414 | ]; |
| 415 | |
| 416 | $this->controls['no_reviews_text'] = [ |
| 417 | 'tab' => 'content', |
| 418 | 'group' => 'review_item', |
| 419 | 'label' => esc_html__( 'No Reviews Text', 'surecart' ), |
| 420 | 'type' => 'text', |
| 421 | 'default' => esc_html__( 'No reviews yet, write one now?', 'surecart' ), |
| 422 | 'placeholder' => esc_html__( 'Enter text for when no reviews exist', 'surecart' ), |
| 423 | ]; |
| 424 | |
| 425 | $this->controls['show_pagination'] = [ |
| 426 | 'tab' => 'content', |
| 427 | 'group' => 'pagination', |
| 428 | 'label' => esc_html__( 'Show Pagination', 'surecart' ), |
| 429 | 'type' => 'checkbox', |
| 430 | 'default' => true, |
| 431 | ]; |
| 432 | |
| 433 | $this->controls['reviews_per_page'] = [ |
| 434 | 'tab' => 'content', |
| 435 | 'group' => 'pagination', |
| 436 | 'label' => esc_html__( 'Reviews Per Page', 'surecart' ), |
| 437 | 'type' => 'number', |
| 438 | 'default' => 10, |
| 439 | 'min' => 1, |
| 440 | 'max' => 100, |
| 441 | 'step' => 1, |
| 442 | 'description' => esc_html__( 'Number of reviews to display per page.', 'surecart' ), |
| 443 | ]; |
| 444 | } |
| 445 | |
| 446 | /** |
| 447 | * Render element. |
| 448 | * |
| 449 | * @return void |
| 450 | */ |
| 451 | public function render() { |
| 452 | $show_header = ! empty( $this->settings['show_header'] ); |
| 453 | $show_sidebar = ! empty( $this->settings['show_sidebar'] ); |
| 454 | $show_add_button = ! empty( $this->settings['show_add_button'] ); |
| 455 | $show_pagination = ! empty( $this->settings['show_pagination'] ); |
| 456 | $show_date = ! empty( $this->settings['show_review_date'] ); |
| 457 | $show_content = ! empty( $this->settings['show_content'] ); |
| 458 | $no_reviews_text = ! empty( $this->settings['no_reviews_text'] ) ? $this->settings['no_reviews_text'] : esc_html__( 'No reviews yet, write one now?', 'surecart' ); |
| 459 | |
| 460 | if ( $this->is_admin_editor() ) { |
| 461 | $this->render_preview( $show_header, $show_sidebar, $show_add_button, $show_date, $show_content, $show_pagination ); |
| 462 | return; |
| 463 | } |
| 464 | |
| 465 | // Get the Bricks element wrapper attributes for CSS targeting. |
| 466 | $rendered_attributes = $this->get_block_rendered_attributes(); |
| 467 | $wrapper_id = $rendered_attributes['id']; |
| 468 | $wrapper_class = $rendered_attributes['class']; |
| 469 | |
| 470 | // Wrap block content with Bricks element wrapper so CSS controls work on frontend. |
| 471 | $block_content = sc_pre_render_blocks( $this->get_review_list_content( $show_header, $show_sidebar, $show_add_button, $show_pagination, $show_date, $show_content, $no_reviews_text ) ); |
| 472 | |
| 473 | echo '<div id="' . esc_attr( $wrapper_id ) . '" class="' . esc_attr( $wrapper_class ) . '">' . $block_content . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 474 | } |
| 475 | |
| 476 | /** |
| 477 | * Get the review list block content. |
| 478 | * |
| 479 | * @param bool $show_header Show header. |
| 480 | * @param bool $show_sidebar Show sidebar. |
| 481 | * @param bool $show_add_button Show add button. |
| 482 | * @param bool $show_pagination Show pagination. |
| 483 | * @param bool $show_date Show date. |
| 484 | * @param bool $show_content Show content. |
| 485 | * @param string $no_reviews_text No reviews text. |
| 486 | * |
| 487 | * @return string |
| 488 | */ |
| 489 | private function get_review_list_content( $show_header, $show_sidebar, $show_add_button, $show_pagination, $show_date, $show_content, $no_reviews_text ): string { |
| 490 | $rendered_attributes = $this->get_block_rendered_attributes(); |
| 491 | $reviews_per_page = ! empty( $this->settings['reviews_per_page'] ) ? absint( $this->settings['reviews_per_page'] ) : 10; |
| 492 | |
| 493 | // Build block attributes. |
| 494 | $block_attrs = [ |
| 495 | 'metadata' => [ |
| 496 | 'categories' => [ 'surecart_review_list' ], |
| 497 | 'patternName' => 'surecart-product-review-standard', |
| 498 | 'name' => 'Default Review List', |
| 499 | ], |
| 500 | 'query' => [ |
| 501 | 'perPage' => $reviews_per_page, |
| 502 | 'pages' => 0, |
| 503 | 'offset' => 0, |
| 504 | ], |
| 505 | 'className' => $rendered_attributes['class'], |
| 506 | 'anchor' => $rendered_attributes['id'], |
| 507 | ]; |
| 508 | |
| 509 | $content = '<!-- wp:surecart/product-review-list ' . wp_json_encode( $block_attrs ) . ' -->'; |
| 510 | |
| 511 | // Product Reviews wrapper - only shows content when reviews exist. |
| 512 | $content .= '<!-- wp:surecart/product-reviews -->'; |
| 513 | |
| 514 | // Header. |
| 515 | if ( $show_header ) { |
| 516 | $content .= '<!-- wp:group {"metadata":{"name":"Header"},"style":{"spacing":{"margin":{"bottom":"10px"},"padding":{"top":"0","bottom":"0","left":"0","right":"0"}}},"layout":{"type":"flex","flexWrap":"nowrap","justifyContent":"space-between"}} -->'; |
| 517 | $content .= '<div class="wp-block-group" style="margin-bottom:10px;padding-top:0;padding-right:0;padding-bottom:0;padding-left:0">'; |
| 518 | $content .= $show_sidebar ? '<!-- wp:surecart/product-review-list-sidebar-toggle {"style":{"typography":{"fontWeight":"600","fontStyle":"normal"}}} /-->' : ' '; |
| 519 | |
| 520 | if ( $show_add_button ) { |
| 521 | $content .= $this->get_review_add_button_content(); |
| 522 | } |
| 523 | |
| 524 | $content .= '</div><!-- /wp:group -->'; |
| 525 | } |
| 526 | |
| 527 | // Content with Sidebar. |
| 528 | $content .= '<!-- wp:group {"style":{"spacing":{"padding":{"right":"0px","left":"0px"},"margin":{"top":"0","bottom":"0"}}},"layout":{"type":"flex","flexWrap":"nowrap","verticalAlignment":"top"}} -->'; |
| 529 | $content .= '<div class="wp-block-group" style="padding-right:0px;padding-left:0px;margin-top:0;margin-bottom:0">'; |
| 530 | |
| 531 | // Sidebar. |
| 532 | if ( $show_sidebar ) { |
| 533 | $content .= '<!-- wp:surecart/product-review-list-sidebar {"style":{"layout":{"selfStretch":"fixed","flexSize":"280px"},"position":{"type":"sticky","top":"0px"},"spacing":{"blockGap":"30px"}},"layout":{"type":"flex","orientation":"vertical"}} -->'; |
| 534 | $content .= '<!-- wp:surecart/product-review-list-filter-tags {"layout":{"type":"flex","orientation":"vertical","verticalAlignment":"top","flexWrap":"nowrap"}} -->'; |
| 535 | $content .= '<!-- wp:surecart/product-review-list-filter-tags-label {"style":{"typography":{"fontWeight":"700","fontStyle":"normal"}}} /-->'; |
| 536 | $content .= '<!-- wp:surecart/product-review-list-filter-tags-template {"style":{"spacing":{"blockGap":"8px"}},"layout":{"type":"flex","orientation":"horizontal"}} -->'; |
| 537 | $content .= '<!-- wp:surecart/product-review-list-filter-tag /-->'; |
| 538 | $content .= '<!-- /wp:surecart/product-review-list-filter-tags-template -->'; |
| 539 | $content .= '<!-- wp:surecart/product-review-list-filter-tags-clear-all {"style":{"typography":{"textDecoration":"underline","fontWeight":"700","fontStyle":"normal"}},"fontSize":"small"} /-->'; |
| 540 | $content .= '<!-- /wp:surecart/product-review-list-filter-tags -->'; |
| 541 | $content .= '<!-- wp:surecart/product-review-list-filter-checkboxes {"layout":{"type":"flex","orientation":"vertical","verticalAlignment":"top","flexWrap":"nowrap"},"style":{"spacing":{"blockGap":"8px"}}} -->'; |
| 542 | $content .= '<!-- wp:surecart/product-review-list-filter-checkboxes-label {"style":{"typography":{"fontWeight":"700","fontStyle":"normal"}}} /-->'; |
| 543 | $content .= '<!-- wp:surecart/product-review-list-filter-checkboxes-template {"style":{"spacing":{"blockGap":"6px","margin":{"top":"0","bottom":"0"}}},"layout":{"type":"flex","orientation":"vertical"}} -->'; |
| 544 | $content .= '<!-- wp:surecart/product-review-list-filter-checkbox /-->'; |
| 545 | $content .= '<!-- /wp:surecart/product-review-list-filter-checkboxes-template -->'; |
| 546 | $content .= '<!-- /wp:surecart/product-review-list-filter-checkboxes -->'; |
| 547 | $content .= '<!-- /wp:surecart/product-review-list-sidebar -->'; |
| 548 | } |
| 549 | |
| 550 | // Review Template. |
| 551 | $content .= '<!-- wp:group {"style":{"spacing":{"blockGap":"0px","padding":{"right":"0px","left":"0px"},"margin":{"top":"0","bottom":"0"}},"layout":{"selfStretch":"fill","flexSize":null}},"layout":{"type":"flex","orientation":"vertical","justifyContent":"stretch"}} -->'; |
| 552 | $content .= '<div class="wp-block-group" style="padding-right:0px;padding-left:0px;margin-top:0;margin-bottom:0">'; |
| 553 | $content .= $this->get_review_template_content( $show_date, $show_content ); |
| 554 | |
| 555 | // Pagination (inside the content group). |
| 556 | if ( $show_pagination ) { |
| 557 | $content .= '<!-- wp:surecart/product-review-pagination {"style":{"spacing":{"margin":{"top":"30px","bottom":"30px"}}}} -->'; |
| 558 | $content .= '<!-- wp:surecart/product-review-pagination-previous /-->'; |
| 559 | $content .= '<!-- wp:surecart/product-review-pagination-numbers /-->'; |
| 560 | $content .= '<!-- wp:surecart/product-review-pagination-next /-->'; |
| 561 | $content .= '<!-- /wp:surecart/product-review-pagination -->'; |
| 562 | } |
| 563 | |
| 564 | $content .= '</div>'; |
| 565 | $content .= '<!-- /wp:group -->'; |
| 566 | $content .= '</div>'; |
| 567 | $content .= '<!-- /wp:group -->'; |
| 568 | |
| 569 | // Close Product Reviews wrapper. |
| 570 | $content .= '<!-- /wp:surecart/product-reviews -->'; |
| 571 | |
| 572 | // No reviews content (outside of product-reviews wrapper). |
| 573 | $content .= '<!-- wp:surecart/product-review-list-no-reviews -->'; |
| 574 | $content .= '<!-- wp:paragraph {"align":"left","placeholder":"Add text or blocks that will display when a query returns no reviews.","style":{"spacing":{"margin":{"bottom":"16px"}}}} -->'; |
| 575 | $content .= '<p class="has-text-align-left" style="margin-bottom:16px">' . esc_html( $no_reviews_text ) . '</p><!-- /wp:paragraph -->'; |
| 576 | $content .= '<!-- wp:group {"style":{"spacing":{"padding":{"right":"0px","left":"0px"},"margin":{"top":"0","bottom":"0"}}},"layout":{"type":"flex","flexWrap":"nowrap"}} -->'; |
| 577 | |
| 578 | // no-reviews button with configured attributes. |
| 579 | $content .= '<div class="wp-block-group" style="padding-right:0px;padding-left:0px;margin-top:0;margin-bottom:0">' . $this->get_review_add_button_content() . '</div><!-- /wp:group -->'; |
| 580 | $content .= '<!-- /wp:surecart/product-review-list-no-reviews -->'; |
| 581 | |
| 582 | $content .= '<!-- /wp:surecart/product-review-list -->'; |
| 583 | |
| 584 | return $content; |
| 585 | } |
| 586 | |
| 587 | /** |
| 588 | * Get the review template block content. |
| 589 | * |
| 590 | * @param bool $show_date Show date. |
| 591 | * @param bool $show_content Show content. |
| 592 | * |
| 593 | * @return string |
| 594 | */ |
| 595 | private function get_review_template_content( $show_date, $show_content ): string { |
| 596 | $fill_color = empty( $this->get_raw_color( 'fill_color' ) ) ? 'var(--bricks-color-primary)' : $this->get_raw_color( 'fill_color' ); |
| 597 | $star_size = ! empty( $this->settings['star_size'] ) ? $this->settings['star_size'] : '20px'; |
| 598 | // Ensure star size has a unit for CSS, but extract number for block attribute. |
| 599 | if ( is_numeric( $star_size ) ) { |
| 600 | $star_size = $star_size . 'px'; |
| 601 | } |
| 602 | |
| 603 | // Extract numeric value for block attribute (blocks use numbers). |
| 604 | $star_size_num = (int) preg_replace( '/[^0-9]/', '', $star_size ); |
| 605 | |
| 606 | $rating_star_attrs = [ |
| 607 | 'fill_color' => $fill_color, |
| 608 | 'size' => $star_size_num, |
| 609 | 'style' => [ |
| 610 | 'spacing' => [ |
| 611 | 'margin' => [ |
| 612 | 'bottom' => '16px', |
| 613 | ], |
| 614 | ], |
| 615 | ], |
| 616 | ]; |
| 617 | |
| 618 | $verified_icon_attrs = [ |
| 619 | 'icon_size' => ! empty( $this->settings['verified_badge_icon_size'] ) ? absint( $this->settings['verified_badge_icon_size'] ) : 16, |
| 620 | 'icon_color' => ! empty( $this->settings['verified_badge_icon_color'] ) ? $this->get_raw_color( 'verified_badge_icon_color' ) : '', |
| 621 | 'style' => [ |
| 622 | 'spacing' => [ |
| 623 | 'blockGap' => '4px', |
| 624 | ], |
| 625 | ], |
| 626 | ]; |
| 627 | |
| 628 | $date_block = $show_date ? '<!-- wp:surecart/product-review-date {"format":"human-diff"} /-->' : ''; |
| 629 | $content_block = $show_content ? '<!-- wp:surecart/product-review-content /-->' : ''; |
| 630 | |
| 631 | // Use configured border color and spacing (fallbacks provided). |
| 632 | $border_color = $this->get_raw_color( 'review_border_color' ); |
| 633 | if ( empty( $border_color ) ) { |
| 634 | $border_color = '#e5e7eb'; |
| 635 | } |
| 636 | |
| 637 | $spacing = ! empty( $this->settings['review_spacing'] ) ? absint( $this->settings['review_spacing'] ) : 24; |
| 638 | |
| 639 | return '<!-- wp:surecart/product-review-template {"style":{"spacing":{"blockGap":"0px","margin":{"top":"0","bottom":"0"},"padding":{"top":"0","bottom":"0"}}},"layout":{"type":"grid","columnCount":1}} -->' . |
| 640 | '<!-- wp:group {"style":{"spacing":{"blockGap":"8px","padding":{"top":"' . $spacing . 'px","bottom":"' . $spacing . 'px","right":"0px","left":"0px"},"margin":{"top":"0","bottom":"0"}},"border":{"bottom":{"color":"' . esc_attr( $border_color ) . '","width":"1px"}}},"layout":{"type":"constrained","contentSize":"100%"}} -->' . |
| 641 | '<div class="wp-block-group" style="border-bottom-color:' . esc_attr( $border_color ) . ';border-bottom-width:1px;margin-top:0;margin-bottom:0;padding-top:' . $spacing . 'px;padding-bottom:' . $spacing . 'px;padding-right:0px;padding-left:0px"><!-- wp:group {"className":"sc-review-header-group","style":{"spacing":{"margin":{"top":"0","bottom":"16px"},"padding":{"right":"0px","left":"0px"}}},"layout":{"type":"flex","flexWrap":"nowrap","justifyContent":"space-between"}} -->' . |
| 642 | '<div class="wp-block-group sc-review-header-group" style="margin-top:0;margin-bottom:16px;padding-right:0px;padding-left:0px"><!-- wp:group {"style":{"spacing":{"blockGap":"8px","padding":{"right":"0px","left":"0px"},"margin":{"top":"0","bottom":"0"}}},"layout":{"type":"flex","flexWrap":"nowrap"}} -->' . |
| 643 | '<div class="wp-block-group" style="margin-top:0;margin-bottom:0;padding-right:0px;padding-left:0px"><!-- wp:surecart/product-review-reviewer-name {"style":{"spacing":{"padding":{"top":"0","bottom":"0"},"margin":{"right":"8px"}},"typography":{"fontStyle":"normal","fontWeight":"500"}}} /-->' . |
| 644 | '<!-- wp:surecart/product-review-verified-badge ' . wp_json_encode( $verified_icon_attrs ) . ' /--></div>' . |
| 645 | '<!-- /wp:group -->' . $date_block . '</div>' . |
| 646 | '<!-- /wp:group -->' . |
| 647 | '<!-- wp:surecart/product-review-rating-stars ' . wp_json_encode( $rating_star_attrs ) . ' /-->' . |
| 648 | '<!-- wp:surecart/product-review-title {"style":{"typography":{"fontStyle":"normal","fontWeight":"700","fontSize":"18px"},"spacing":{"margin":{"bottom":"8px"}}}} /-->' . $content_block . '</div>' . |
| 649 | '<!-- /wp:group -->' . |
| 650 | '<!-- /wp:surecart/product-review-template -->'; |
| 651 | } |
| 652 | |
| 653 | /** |
| 654 | * Get the review add button block content. |
| 655 | * |
| 656 | * @return string |
| 657 | */ |
| 658 | private function get_review_add_button_content(): string { |
| 659 | $btn_attrs = [ |
| 660 | 'width' => 100, |
| 661 | 'label' => ! empty( $this->settings['add_button_label'] ) ? wp_kses_post( $this->settings['add_button_label'] ) : esc_html__( 'Write a Review', 'surecart' ), |
| 662 | 'icon_size' => ! empty( $this->settings['add_button_icon_size'] ) ? absint( $this->settings['add_button_icon_size'] ) : 15, |
| 663 | 'style' => [ |
| 664 | 'color' => [ |
| 665 | 'text' => ! empty( $this->settings['add_button_text_color'] ) ? $this->get_raw_color( 'add_button_text_color' ) : '#000000', |
| 666 | 'background' => ! empty( $this->settings['add_button_background_color'] ) ? $this->get_raw_color( 'add_button_background_color' ) : 'var(--bricks-color-primary)', |
| 667 | ], |
| 668 | ], |
| 669 | ]; |
| 670 | |
| 671 | // Add border attributes if set. |
| 672 | if ( ! empty( $this->settings['add_button_border_width'] ) ) { |
| 673 | $btn_attrs['style']['border']['width'] = sanitize_text_field( $this->settings['add_button_border_width'] ); |
| 674 | $btn_attrs['style']['border']['style'] = 'solid'; |
| 675 | } |
| 676 | if ( ! empty( $this->settings['add_button_border_color'] ) ) { |
| 677 | $btn_attrs['style']['border']['color'] = $this->get_raw_color( 'add_button_border_color' ); |
| 678 | } |
| 679 | if ( ! empty( $this->settings['add_button_border_radius'] ) ) { |
| 680 | $btn_attrs['style']['border']['radius'] = sanitize_text_field( $this->settings['add_button_border_radius'] ); |
| 681 | } |
| 682 | |
| 683 | return '<!-- wp:surecart/product-review-add-button ' . wp_json_encode( $btn_attrs ) . ' /-->'; |
| 684 | } |
| 685 | |
| 686 | /** |
| 687 | * Render preview in editor. |
| 688 | * |
| 689 | * @param bool $show_header Show header. |
| 690 | * @param bool $show_sidebar Show sidebar. |
| 691 | * @param bool $show_add_button Show add button. |
| 692 | * @param bool $show_date Show date. |
| 693 | * @param bool $show_content Show content. |
| 694 | * @param bool $show_pagination Show pagination. |
| 695 | * |
| 696 | * @return void |
| 697 | */ |
| 698 | private function render_preview( $show_header, $show_sidebar, $show_add_button, $show_date, $show_content, $show_pagination ) { |
| 699 | $content = '<div class="wp-block-surecart-product-review-list" style="width: 100%;">'; |
| 700 | $fill_color = $this->get_raw_color( 'fill_color' ); |
| 701 | if ( empty( $fill_color ) ) { |
| 702 | $fill_color = 'var(--bricks-color-primary)'; |
| 703 | } |
| 704 | |
| 705 | // Header. |
| 706 | if ( $show_header ) { |
| 707 | $content .= '<div style="padding: 0; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center;">'; |
| 708 | |
| 709 | if ( $show_sidebar ) { |
| 710 | $content .= '<div style="display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer;">'; |
| 711 | $content .= wp_kses( |
| 712 | \SureCart::svg()->get( |
| 713 | 'sliders', |
| 714 | [ |
| 715 | 'aria-label' => __( 'Open sidebar', 'surecart' ), |
| 716 | 'width' => 16, |
| 717 | 'height' => 16, |
| 718 | 'class' => 'sc-sidebar-toggle__icon', |
| 719 | ] |
| 720 | ), |
| 721 | sc_allowed_svg_html() |
| 722 | ); |
| 723 | $content .= '<span>' . esc_html__( 'Filters', 'surecart' ) . '</span>'; |
| 724 | $content .= '</div>'; |
| 725 | } else { |
| 726 | // Ensure left side still has something when no sidebar is shown. |
| 727 | $content .= ' '; |
| 728 | } |
| 729 | |
| 730 | if ( $show_add_button ) { |
| 731 | $btn_icon_size = ! empty( $this->settings['add_button_icon_size'] ) ? absint( $this->settings['add_button_icon_size'] ) : 15; |
| 732 | $btn_label = ! empty( $this->settings['add_button_label'] ) ? wp_kses_post( $this->settings['add_button_label'] ) : esc_html__( 'Write a Review', 'surecart' ); |
| 733 | $btn_bg_color = ! empty( $this->settings['add_button_background_color'] ) ? $this->get_raw_color( 'add_button_background_color' ) : 'var(--bricks-color-primary)'; |
| 734 | $btn_text_color = ! empty( $this->settings['add_button_text_color'] ) ? $this->get_raw_color( 'add_button_text_color' ) : '#000000'; |
| 735 | |
| 736 | // Border styles for preview. |
| 737 | $btn_border_styles = ''; |
| 738 | if ( ! empty( $this->settings['add_button_border_width'] ) ) { |
| 739 | $border_width = is_numeric( $this->settings['add_button_border_width'] ) ? $this->settings['add_button_border_width'] . 'px' : $this->settings['add_button_border_width']; |
| 740 | $btn_border_styles .= 'border-width: ' . esc_attr( $border_width ) . '; border-style: solid;'; |
| 741 | } |
| 742 | if ( ! empty( $this->settings['add_button_border_color'] ) ) { |
| 743 | $btn_border_styles .= ' border-color: ' . esc_attr( $this->get_raw_color( 'add_button_border_color' ) ) . ';'; |
| 744 | } |
| 745 | if ( ! empty( $this->settings['add_button_border_radius'] ) ) { |
| 746 | $border_radius = is_numeric( $this->settings['add_button_border_radius'] ) ? $this->settings['add_button_border_radius'] . 'px' : $this->settings['add_button_border_radius']; |
| 747 | $btn_border_styles .= ' border-radius: ' . esc_attr( $border_radius ) . ';'; |
| 748 | } |
| 749 | |
| 750 | $default_border_radius = strpos( $btn_border_styles, 'border-radius' ) === false ? 'border-radius: 50px;' : ''; |
| 751 | $content .= '<div class="wp-block-surecart-product-review-add-button">'; |
| 752 | $content .= '<div class="wp-block-button__link" style="padding: 10px 20px; ' . $default_border_radius . ' display: inline-flex; align-items: center; gap: 8px; background-color: ' . esc_attr( $btn_bg_color ) . '; color: ' . esc_attr( $btn_text_color ) . '; ' . $btn_border_styles . '">'; |
| 753 | $content .= wp_kses( |
| 754 | \SureCart::svg()->get( |
| 755 | 'edit-2', |
| 756 | [ |
| 757 | 'class' => 'sc-add-review-button__icon', |
| 758 | 'aria-label' => __( 'Add Review', 'surecart' ), |
| 759 | 'width' => $btn_icon_size, |
| 760 | 'height' => $btn_icon_size, |
| 761 | ] |
| 762 | ), |
| 763 | sc_allowed_svg_html() |
| 764 | ); |
| 765 | $content .= '<span>' . esc_html( $btn_label ) . '</span>'; |
| 766 | $content .= '</div>'; |
| 767 | $content .= '</div>'; |
| 768 | } |
| 769 | |
| 770 | $content .= '</div>'; |
| 771 | } |
| 772 | |
| 773 | // Main content area. |
| 774 | $content .= '<div style="display: flex; gap: 30px; margin-bottom: 20px;">'; |
| 775 | |
| 776 | // Sidebar. |
| 777 | if ( $show_sidebar ) { |
| 778 | $content .= '<div style="width: 250px; min-width: 250px;">'; |
| 779 | $content .= '<div style="margin-bottom: 20px;"><div style="font-weight: 600; margin-bottom: 10px;">' . esc_html__( 'Applied Filters', 'surecart' ) . '</div>'; |
| 780 | $content .= '<div style="display: flex; gap: 8px; flex-wrap: wrap;">'; |
| 781 | $content .= '<span style="padding: 6px 12px; background: #f3f4f6; border-radius: 16px; font-size: 14px; display: inline-flex; align-items: center; gap: 6px;">5 Stars'; |
| 782 | $content .= wp_kses( |
| 783 | \SureCart::svg()->get( |
| 784 | 'x', |
| 785 | [ |
| 786 | 'class' => 'sc-tag__clear', |
| 787 | 'aria-label' => __( 'Remove tag', 'surecart' ), |
| 788 | 'width' => 12, |
| 789 | ] |
| 790 | ), |
| 791 | sc_allowed_svg_html() |
| 792 | ); |
| 793 | $content .= '</span></div>'; |
| 794 | $content .= '<div style="margin-top: 10px; text-decoration: underline; font-size: 14px; cursor: pointer; color: var(--bricks-color-primary, #6c63ff);">' . esc_html__( 'Clear All', 'surecart' ) . '</div>'; |
| 795 | $content .= '</div>'; |
| 796 | $content .= '<div><div style="font-weight: 600; margin-bottom: 12px;">' . esc_html__( 'Filter by', 'surecart' ) . '</div>'; |
| 797 | $content .= '<div style="display: flex; flex-direction: column; gap: 10px;">'; |
| 798 | for ( $i = 5; $i >= 1; $i-- ) { |
| 799 | $content .= '<label style="display: flex; align-items: center; gap: 8px;"><input type="checkbox" style="width: 16px; height: 16px;"/><span>' . esc_html( $i . ' Stars' ) . '</span></label>'; |
| 800 | } |
| 801 | $content .= '</div></div>'; |
| 802 | $content .= '</div>'; |
| 803 | } |
| 804 | |
| 805 | // Reviews. |
| 806 | $content .= '<div style="flex: 1;">'; |
| 807 | // Preview values for border color and spacing. |
| 808 | $preview_border_color = $this->get_raw_color( 'review_border_color' ); |
| 809 | if ( empty( $preview_border_color ) ) { |
| 810 | $preview_border_color = '#e5e7eb'; |
| 811 | } |
| 812 | $preview_spacing = ! empty( $this->settings['review_spacing'] ) ? $this->settings['review_spacing'] : 24; |
| 813 | if ( is_numeric( $preview_spacing ) ) { |
| 814 | $preview_spacing = $preview_spacing . 'px'; |
| 815 | } |
| 816 | for ( $i = 0; $i < 2; $i++ ) { |
| 817 | // Each review link contains a wp-block-group that gets the border and spacing. |
| 818 | $content .= '<div class="sc-product-review-link">'; |
| 819 | $content .= '<div class="wp-block-group" style="border-bottom: 1px solid ' . esc_attr( $preview_border_color ) . '; margin-top: 0; margin-bottom: 0; padding-top: ' . esc_attr( $preview_spacing ) . '; padding-bottom: ' . esc_attr( $preview_spacing ) . ';">'; |
| 820 | $content .= '<div style="display: flex; justify-content: space-between; margin-bottom: 12px;">'; |
| 821 | $content .= '<div style="display: flex; gap: 10px; align-items: center;">'; |
| 822 | $content .= '<span style="font-weight: 500;">' . esc_html__( 'John Doe', 'surecart' ) . '</span>'; |
| 823 | $content .= '<span style="display: inline-flex; align-items: center; gap: 4px; font-size: 14px;">'; |
| 824 | $verified_icon_size = ! empty( $this->settings['verified_badge_icon_size'] ) ? $this->settings['verified_badge_icon_size'] : '16px'; |
| 825 | |
| 826 | // Ensure verified icon size has a unit. |
| 827 | if ( is_numeric( $verified_icon_size ) ) { |
| 828 | $verified_icon_size = $verified_icon_size . 'px'; |
| 829 | } |
| 830 | |
| 831 | $content .= esc_html__( 'Verified Buyer', 'surecart' ); |
| 832 | $content .= '</span><span class="wp-block-surecart-product-review-verified-badge" style="display: inline-flex; align-items: center; gap: 4px;">'; |
| 833 | $content .= '<span class="sc-product-review-verified-badge__icon" style="display: inline-flex; align-items: center;">'; |
| 834 | $content .= wp_kses( |
| 835 | \SureCart::svg()->get( |
| 836 | 'verified', |
| 837 | [ |
| 838 | 'class' => 'sc-verified-badge__icon', |
| 839 | 'width' => esc_attr( $verified_icon_size ), |
| 840 | 'height' => esc_attr( $verified_icon_size ), |
| 841 | ] |
| 842 | ), |
| 843 | sc_allowed_svg_html() |
| 844 | ); |
| 845 | $content .= '</span></span></div>'; |
| 846 | if ( $show_date ) { |
| 847 | $content .= '<span style="color: #6b7280; font-size: 14px;">' . esc_html__( '2 days ago', 'surecart' ) . '</span>'; |
| 848 | } |
| 849 | $content .= '</div>'; |
| 850 | |
| 851 | // Stars. |
| 852 | $preview_star_size = ! empty( $this->settings['star_size'] ) ? $this->settings['star_size'] : '20px'; |
| 853 | |
| 854 | // Ensure star size has a unit. |
| 855 | if ( is_numeric( $preview_star_size ) ) { |
| 856 | $preview_star_size = $preview_star_size . 'px'; |
| 857 | } |
| 858 | |
| 859 | $content .= '<div style="display: inline-flex; gap: 2px; margin-bottom: 8px;" class="wp-block-surecart-product-review-rating-stars">'; |
| 860 | for ( $s = 1; $s <= 5; $s++ ) { |
| 861 | $content .= wp_kses( |
| 862 | \SureCart::svg()->get( |
| 863 | 'star', |
| 864 | [ |
| 865 | 'class' => 'sc-star-row__label__svg', |
| 866 | 'width' => esc_attr( $preview_star_size ), |
| 867 | 'height' => esc_attr( $preview_star_size ), |
| 868 | 'fill' => esc_attr( $fill_color ), |
| 869 | 'stroke' => esc_attr( $fill_color ), |
| 870 | ] |
| 871 | ), |
| 872 | sc_allowed_svg_html() |
| 873 | ); |
| 874 | } |
| 875 | $content .= '</div>'; |
| 876 | |
| 877 | $content .= '<div style="font-weight: 700; margin-bottom: 8px;">' . esc_html__( 'Great Product!', 'surecart' ) . '</div>'; |
| 878 | if ( $show_content ) { |
| 879 | $content .= '<p style="margin: 0; line-height: 1.6;">' . esc_html__( 'This is an excellent product. I highly recommend it to anyone looking for quality and reliability.', 'surecart' ) . '</p>'; |
| 880 | } |
| 881 | $content .= '</div>'; // close .wp-block-group. |
| 882 | $content .= '</div>'; // close .sc-product-review-link. |
| 883 | } |
| 884 | $content .= '</div>'; |
| 885 | |
| 886 | $content .= '</div>'; |
| 887 | |
| 888 | // Pagination. |
| 889 | if ( $show_pagination ) { |
| 890 | $prev_arrow = wp_kses( |
| 891 | \SureCart::svg()->get( |
| 892 | is_rtl() ? 'arrow-right' : 'arrow-left', |
| 893 | [ |
| 894 | 'class' => 'wp-block-surecart-product-review-pagination-prev__icon', |
| 895 | 'aria-hidden' => true, |
| 896 | 'width' => 16, |
| 897 | 'height' => 16, |
| 898 | ] |
| 899 | ), |
| 900 | sc_allowed_svg_html() |
| 901 | ); |
| 902 | |
| 903 | $next_arrow = wp_kses( |
| 904 | \SureCart::svg()->get( |
| 905 | is_rtl() ? 'arrow-left' : 'arrow-right', |
| 906 | [ |
| 907 | 'class' => 'wp-block-surecart-product-review-pagination-next__icon', |
| 908 | 'aria-hidden' => true, |
| 909 | 'width' => 16, |
| 910 | 'height' => 16, |
| 911 | ] |
| 912 | ), |
| 913 | sc_allowed_svg_html() |
| 914 | ); |
| 915 | |
| 916 | $content .= '<nav style="display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 20px;">'; |
| 917 | $content .= '<div style="padding: 10px 16px; background: transparent; border-radius: 4px; display: inline-flex; align-items: center; gap: 6px;">' . $prev_arrow . esc_html__( 'Previous', 'surecart' ) . '</div>'; |
| 918 | $content .= '<div style="display: flex; gap: 4px;"><span style="padding: 8px 12px;">1</span><span style="padding: 8px 12px; opacity: 0.5;">2</span><span style="padding: 8px 12px; opacity: 0.5;">3</span></div>'; |
| 919 | $content .= '<div style="padding: 10px 16px; background: transparent; border-radius: 4px; display: inline-flex; align-items: center; gap: 6px;">' . esc_html__( 'Next', 'surecart' ) . $next_arrow . '</div>'; |
| 920 | $content .= '</nav>'; |
| 921 | } |
| 922 | $content .= '</div>'; |
| 923 | |
| 924 | echo $this->preview( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 925 | $content, |
| 926 | '', |
| 927 | 'div' |
| 928 | ); |
| 929 | } |
| 930 | } |
| 931 |