block.json
6 months ago
controller.php
1 month ago
index.asset.php
6 months ago
index.js
6 months ago
style-index-rtl.css
6 months ago
style-index.css
6 months ago
view.php
6 months ago
controller.php
36 lines
| 1 | <?php |
| 2 | |
| 3 | use SureCart\Support\TimeDate; |
| 4 | |
| 5 | if ( empty( $block->context['review'] ) ) { |
| 6 | return; |
| 7 | } |
| 8 | |
| 9 | $classes = array(); |
| 10 | $review_timestamp = (int) $block->context['review']->created_at ?? ''; |
| 11 | $unformatted_date = TimeDate::formatDateAndTime( $review_timestamp ); |
| 12 | |
| 13 | if ( isset( $attributes['format'] ) && 'human-diff' === $attributes['format'] ) { |
| 14 | if ( $review_timestamp > time() ) { |
| 15 | // translators: %s: human-readable time difference. |
| 16 | $formatted_date = sprintf( __( '%s from now', 'surecart' ), human_time_diff( $review_timestamp ) ); |
| 17 | } else { |
| 18 | // translators: %s: human-readable time difference. |
| 19 | $formatted_date = sprintf( __( '%s ago', 'surecart' ), human_time_diff( $review_timestamp ) ); |
| 20 | } |
| 21 | } else { |
| 22 | $format = empty( $attributes['format'] ) ? get_option( 'date_format' ) : $attributes['format']; |
| 23 | $formatted_date = wp_date( $format, $review_timestamp ); |
| 24 | } |
| 25 | |
| 26 | if ( isset( $attributes['textAlign'] ) ) { |
| 27 | $classes[] = 'has-text-align-' . $attributes['textAlign']; |
| 28 | } |
| 29 | if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { |
| 30 | $classes[] = 'has-link-color'; |
| 31 | } |
| 32 | |
| 33 | $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) ); |
| 34 | |
| 35 | return 'file:./view.php'; |
| 36 |