block.json
8 months ago
controller.php
11 months ago
index-rtl.css
11 months ago
index.asset.php
6 months ago
index.css
11 months ago
index.js
6 months ago
style-index-rtl.css
10 months ago
style-index.css
10 months ago
view.php
11 months ago
controller.php
47 lines
| 1 | <?php |
| 2 | $product_id = isset( $_GET['product-quick-view'] ) ? (int) $_GET['product-quick-view'] : null; |
| 3 | $query = new WP_Query( |
| 4 | [ |
| 5 | 'post__in' => ! empty( $product_id ) ? [ $product_id ] : [ 0 ], // Ensures no posts are found if null. |
| 6 | 'post_type' => 'sc_product', |
| 7 | ] |
| 8 | ); |
| 9 | $close_url = remove_query_arg( 'product-quick-view' ); |
| 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 quick view. |
| 39 | wp_interactivity_state( |
| 40 | 'surecart/product-quick-view', |
| 41 | array( |
| 42 | 'open' => $query->have_posts(), |
| 43 | ) |
| 44 | ); |
| 45 | |
| 46 | return 'file:./view.php'; |
| 47 |