Skip to content

Commit 7d0116d

Browse files
committed
move form contents to the view
1 parent 59e5fff commit 7d0116d

2 files changed

Lines changed: 57 additions & 44 deletions

File tree

classes/suggested-tasks/providers/class-set-date-format.php

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -153,50 +153,7 @@ public function print_popover_instructions() {
153153
* @return void
154154
*/
155155
public function print_popover_form_contents() {
156-
/**
157-
* Filters the default date formats.
158-
*
159-
* @param string[] $default_date_formats Array of default date formats.
160-
*/
161-
$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
162-
163-
$custom = true;
164-
165-
echo '<div class="radios">';
166-
echo '<fieldset>';
167-
foreach ( $date_formats as $format ) {
168-
echo '<div class="prpl-radio-wrapper">';
169-
echo "<label class='prpl-custom-radio'><input type='radio' name='date_format' value='" . \esc_attr( $format ) . "'";
170-
if ( \get_option( 'date_format' ) === $format ) { // checked() uses "==" rather than "===".
171-
echo " checked='checked'";
172-
$custom = false;
173-
}
174-
echo ' /> <span class="prpl-custom-control"></span><span class="date-time-text format-i18n">' . \esc_html( \date_i18n( $format ) ) . '</span><code>' . \esc_html( $format ) . '</code></label>';
175-
echo '</div>';
176-
}
177-
178-
echo '<div class="prpl-radio-wrapper">';
179-
echo '<label class="prpl-custom-radio"><input type="radio" name="date_format" id="date_format_custom_radio" value="\c\u\s\t\o\m"';
180-
checked( $custom );
181-
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"> ' .
182-
/* translators: Hidden accessibility text. */
183-
\esc_html( __( 'enter a custom date format in the following field', 'progress-planner' ) ) .
184-
'</span></span></label>' .
185-
'<label for="date_format_custom" class="screen-reader-text">' .
186-
/* translators: Hidden accessibility text. */
187-
\esc_html( __( 'Custom date format:', 'progress-planner' ) ) .
188-
'</label>' .
189-
'<input type="text" name="date_format_custom" id="date_format_custom" value="' . \esc_attr( \get_option( 'date_format' ) ) . '" class="small-text" />' .
190-
'</div>' .
191-
'<p><strong>' . \esc_html( __( 'Preview:', 'progress-planner' ) ) . '</strong> <span class="example">' . \esc_html( \date_i18n( \get_option( 'date_format' ) ) ) . '</span>' .
192-
"<span class='spinner'></span>\n" . '</p>';
193-
?>
194-
</fieldset>
195-
</div>
196-
<button type="submit" class="prpl-button prpl-button-primary" style="color: #fff;">
197-
<?php \esc_html_e( 'Set date format', 'progress-planner' ); ?>
198-
</button>
199-
<?php
156+
\progress_planner()->the_view( 'tasks/set-date-format-form-contents.php' );
200157
}
201158

202159
/**
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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

Comments
 (0)