@@ -143,7 +143,78 @@ public function print_popover_instructions() {
143143 * @return void
144144 */
145145 public function print_popover_form_contents () {
146- \progress_planner ()->the_view ( 'tasks/set-date-format-form-contents.php ' );
146+ /**
147+ * Filters the default date formats.
148+ *
149+ * @param string[] $default_date_formats Array of default date formats.
150+ */
151+ $ 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
152+
153+ $ prpl_custom = true ;
154+ ?>
155+ <div class="radios">
156+ <fieldset>
157+ <?php foreach ( $ prpl_date_formats as $ prpl_format ) : ?>
158+ <div class="prpl-radio-wrapper">
159+ <label class="prpl-custom-radio">
160+ <input
161+ type="radio"
162+ name="date_format"
163+ value="<?php echo \esc_attr ( $ prpl_format ); ?> "
164+ <?php
165+ if ( \get_option ( 'date_format ' ) === $ prpl_format ) { // checked() uses "==" rather than "===".
166+ echo " checked='checked' " ;
167+ $ prpl_custom = false ;
168+ }
169+ ?>
170+ />
171+ <span class="prpl-custom-control"></span>
172+ <span class="date-time-text format-i18n"><?php echo \esc_html ( \date_i18n ( $ prpl_format ) ); ?> </span>
173+ <code><?php echo \esc_html ( $ prpl_format ); ?> </code>
174+ </label>
175+ </div>
176+ <?php endforeach ; ?>
177+
178+ <?php /* Custom date format. */ ?>
179+ <div class="prpl-radio-wrapper">
180+ <label class="prpl-custom-radio">
181+ <input type="radio" name="date_format" id="date_format_custom_radio" value="\c\u\s\t\o\m" <?php \checked ( $ prpl_custom ); ?> />
182+ <span class="prpl-custom-control"></span> <span class="date-time-text date-time-custom-text">
183+ <?php
184+ \printf (
185+ /* translators: %s: Screen reader text "enter a custom date format in the following field". */
186+ \esc_html__ ( 'Custom: %s ' , 'progress-planner ' ),
187+ /* translators: Hidden accessibility text. */
188+ '<span class="screen-reader-text"> ' . \esc_html__ ( 'enter a custom date format in the following field ' , 'progress-planner ' ) . '</span> '
189+ );
190+ ?>
191+ </span>
192+ </label>
193+ <label for="date_format_custom" class="screen-reader-text">
194+ <?php
195+ /* translators: Hidden accessibility text. */
196+ \esc_html_e ( 'Custom date format: ' , 'progress-planner ' );
197+ ?>
198+ </label>
199+ <input type="text" name="date_format_custom" id="date_format_custom" value="<?php echo \esc_attr ( \get_option ( 'date_format ' ) ); ?> " class="small-text" />
200+ </div>
201+
202+ <?php /* Preview. */ ?>
203+ <p>
204+ <?php
205+ \printf (
206+ /* translators: %s: Preview text. */
207+ \wp_kses_post ( \__ ( '<strong>Preview:</strong> %s ' , 'progress-planner ' ) ),
208+ '<span class="example"> ' . \esc_html ( \date_i18n ( \get_option ( 'date_format ' ) ) ) . '</span><span class="spinner"></span> '
209+ );
210+ ?>
211+ </p>
212+ </fieldset>
213+ </div>
214+ <button type="submit" class="prpl-button prpl-button-primary" style="color: #fff;">
215+ <?php \esc_html_e ( 'Set date format ' , 'progress-planner ' ); ?>
216+ </button>
217+ <?php
147218 }
148219
149220 /**
0 commit comments