|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Template for the set date format task. |
| 4 | + * |
| 5 | + * @package Progress_Planner |
| 6 | + */ |
| 7 | + |
| 8 | +// Exit if accessed directly. |
| 9 | +if ( ! \defined( 'ABSPATH' ) ) { |
| 10 | + exit; |
| 11 | +} |
| 12 | + |
| 13 | +/** |
| 14 | + * Filters the default date formats. |
| 15 | + * |
| 16 | + * @param string[] $default_date_formats Array of default date formats. |
| 17 | + */ |
| 18 | +$prpl_date_formats = array_unique( \apply_filters( 'date_formats', [ __( 'F j, Y' ), 'F j, Y', 'Y-m-d', 'm/d/Y', 'd/m/Y', 'd.m.Y' ] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound, WordPress.WP.I18n.MissingArgDomain -- WP core filter & we want to add the default date format |
| 19 | + |
| 20 | +$prpl_custom = true; |
| 21 | + |
| 22 | +echo '<div class="radios">'; |
| 23 | +echo '<fieldset>'; |
| 24 | +foreach ( $prpl_date_formats as $prpl_format ) { |
| 25 | + echo '<div class="prpl-radio-wrapper">'; |
| 26 | + echo "<label class='prpl-custom-radio'><input type='radio' name='date_format' value='" . \esc_attr( $prpl_format ) . "'"; |
| 27 | + if ( \get_option( 'date_format' ) === $prpl_format ) { // checked() uses "==" rather than "===". |
| 28 | + echo " checked='checked'"; |
| 29 | + $prpl_custom = false; |
| 30 | + } |
| 31 | + echo ' /> <span class="prpl-custom-control"></span><span class="date-time-text format-i18n">' . \esc_html( \date_i18n( $prpl_format ) ) . '</span><code>' . \esc_html( $prpl_format ) . '</code></label>'; |
| 32 | + echo '</div>'; |
| 33 | +} |
| 34 | + |
| 35 | +echo '<div class="prpl-radio-wrapper">'; |
| 36 | +echo '<label class="prpl-custom-radio"><input type="radio" name="date_format" id="date_format_custom_radio" value="\c\u\s\t\o\m"'; |
| 37 | +checked( $prpl_custom ); |
| 38 | +echo '/> <span class="prpl-custom-control"></span> <span class="date-time-text date-time-custom-text">' . \esc_html( __( 'Custom:', 'progress-planner' ) ) . '<span class="screen-reader-text"> ' . |
| 39 | + /* translators: Hidden accessibility text. */ |
| 40 | + \esc_html( __( 'enter a custom date format in the following field', 'progress-planner' ) ) . |
| 41 | + '</span></span></label>' . |
| 42 | + '<label for="date_format_custom" class="screen-reader-text">' . |
| 43 | + /* translators: Hidden accessibility text. */ |
| 44 | + \esc_html( __( 'Custom date format:', 'progress-planner' ) ) . |
| 45 | + '</label>' . |
| 46 | + '<input type="text" name="date_format_custom" id="date_format_custom" value="' . \esc_attr( \get_option( 'date_format' ) ) . '" class="small-text" />' . |
| 47 | + '</div>' . |
| 48 | + '<p><strong>' . \esc_html( __( 'Preview:', 'progress-planner' ) ) . '</strong> <span class="example">' . \esc_html( \date_i18n( \get_option( 'date_format' ) ) ) . '</span>' . |
| 49 | + "<span class='spinner'></span>\n" . '</p>'; |
| 50 | +?> |
| 51 | +</fieldset> |
| 52 | +</div> |
| 53 | +<button type="submit" class="prpl-button prpl-button-primary" style="color: #fff;"> |
| 54 | + <?php \esc_html_e( 'Set date format', 'progress-planner' ); ?> |
| 55 | +</button> |
| 56 | +<?php |
0 commit comments