block.json
6 months ago
controller.php
5 months ago
index-rtl.css
6 months ago
index.asset.php
4 months ago
index.css
6 months ago
index.js
4 months ago
style-index-rtl.css
4 months ago
style-index.css
4 months ago
view.php
6 months ago
controller.php
59 lines
| 1 | <?php |
| 2 | $product_id = isset( $_GET['product-review-form'] ) ? absint( $_GET['product-review-form'] ) : null; // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 3 | $has_product_id = ! empty( $product_id ); |
| 4 | |
| 5 | // Only fetch product if we have an ID (for server-side rendering when opened via URL). |
| 6 | $product = sc_get_product( $product_id ); |
| 7 | $sc_product_id = $product ? $product->id : ''; |
| 8 | |
| 9 | $close_url = $has_product_id ? get_permalink( $product_id ) : ''; |
| 10 | $position_class = $attributes['alignment'] ? 'position-' . str_replace( ' ', '-', $attributes['alignment'] ) : ''; |
| 11 | |
| 12 | $styles = sc_get_block_styles( false ); |
| 13 | $style = $styles['color']['css'] ?? ''; |
| 14 | |
| 15 | if ( ! empty( $attributes['height'] ) ) { |
| 16 | $style .= 'height:' . $attributes['height'] . ';'; |
| 17 | } |
| 18 | if ( ! empty( $attributes['width'] ) ) { |
| 19 | $style .= 'max-width:' . $attributes['width'] . ';'; |
| 20 | } |
| 21 | |
| 22 | $content_style = ''; |
| 23 | |
| 24 | if ( ! empty( $styles['spacing']['declarations'] ) ) { |
| 25 | $declarations = $styles['spacing']['declarations']; |
| 26 | |
| 27 | $style .= ! empty( $declarations['margin-top'] ) ? esc_attr( safecss_filter_attr( 'margin-top:' . $declarations['margin-top'] ) ) . ';' : ''; |
| 28 | $style .= ! empty( $declarations['margin-bottom'] ) ? esc_attr( safecss_filter_attr( 'margin-bottom:' . $declarations['margin-bottom'] ) ) . ';' : ''; |
| 29 | $style .= ! empty( $declarations['margin-left'] ) ? esc_attr( safecss_filter_attr( 'margin-left:' . $declarations['margin-left'] ) ) . ';' : ''; |
| 30 | $style .= ! empty( $declarations['margin-right'] ) ? esc_attr( safecss_filter_attr( 'margin-right:' . $declarations['margin-right'] ) ) . ';' : ''; |
| 31 | |
| 32 | $content_style .= ! empty( $declarations['padding-top'] ) ? esc_attr( safecss_filter_attr( 'padding-top:' . $declarations['padding-top'] ) ) . ';' : ''; |
| 33 | $content_style .= ! empty( $declarations['padding-bottom'] ) ? esc_attr( safecss_filter_attr( 'padding-bottom:' . $declarations['padding-bottom'] ) ) . ';' : ''; |
| 34 | $content_style .= ! empty( $declarations['padding-left'] ) ? esc_attr( safecss_filter_attr( 'padding-left:' . $declarations['padding-left'] ) ) . ';' : ''; |
| 35 | $content_style .= ! empty( $declarations['padding-right'] ) ? esc_attr( safecss_filter_attr( 'padding-right:' . $declarations['padding-right'] ) ) . ';' : ''; |
| 36 | } |
| 37 | |
| 38 | // Set the interactivity state for the review form. |
| 39 | wp_interactivity_state( |
| 40 | 'surecart/product-review-form', |
| 41 | array( |
| 42 | 'open' => $has_product_id, |
| 43 | ) |
| 44 | ); |
| 45 | |
| 46 | |
| 47 | foreach ( $block->inner_blocks ?? [] as $inner_block ) { |
| 48 | switch ( $inner_block->parsed_block['blockName'] ?? '' ) { |
| 49 | case 'surecart/product-review-form-template': |
| 50 | $form_template = $inner_block; |
| 51 | break; |
| 52 | case 'surecart/product-review-confirmation-template': |
| 53 | $confirmation_template = $inner_block; |
| 54 | break; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | return 'file:./view.php'; |
| 59 |