buy-button.php
1 year ago
checkout-form.php
4 years ago
customer-dashboard-button.php
4 years ago
dashboard-tab.php
4 years ago
form.php
2 years ago
logout-button.php
4 years ago
sticky-purchase.php
11 months ago
sticky-purchase.php
30 lines
| 1 | <?php |
| 2 | |
| 3 | // If the sticky purchase button is empty or set to never, don't render it. |
| 4 | if ( empty( $settings['show_sticky_purchase_button'] ) || 'never' === $settings['show_sticky_purchase_button'] ) { |
| 5 | return; |
| 6 | } |
| 7 | |
| 8 | // Get the sticky purchase template. |
| 9 | $template = get_block_template( 'surecart/surecart//sticky-purchase', 'wp_template_part' ); |
| 10 | |
| 11 | // If the template is empty, don't render it. |
| 12 | if ( empty( $template ) || empty( $template->content ) ) { |
| 13 | return; |
| 14 | } |
| 15 | |
| 16 | // Add the show sticky purchase button context to the template. |
| 17 | $filter_block_context = static function ( $context ) use ( $settings ) { |
| 18 | $context['showStickyPurchaseButton'] = $settings['show_sticky_purchase_button']; |
| 19 | return $context; |
| 20 | }; |
| 21 | |
| 22 | // Add the filter to the template. |
| 23 | add_filter( 'render_block_context', $filter_block_context, 1 ); |
| 24 | |
| 25 | // Render the template. |
| 26 | echo do_blocks( $template->content ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 27 | |
| 28 | // Remove the filter from the template. |
| 29 | remove_filter( 'render_block_context', $filter_block_context, 1 ); |
| 30 |