Skip to content

Commit 2a7312a

Browse files
committed
update timezone task description & try to pre-select timezone
1 parent 8de5249 commit 2a7312a

3 files changed

Lines changed: 23 additions & 28 deletions

File tree

assets/js/recommendations/interactive-task.js

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,9 @@ const prplInteractiveTaskFormListener = {
5757
if ( ! postId ) {
5858
return;
5959
}
60+
61+
// This will trigger the celebration event (confetti) as well.
6062
prplSuggestedTask.maybeComplete( postId );
61-
taskEl.setAttribute( 'data-task-action', 'celebrate' );
62-
document.dispatchEvent(
63-
new CustomEvent( 'prpl/celebrateTasks', {
64-
detail: {
65-
element: taskEl,
66-
},
67-
} )
68-
);
6963
} );
7064
} );
7165
} );
@@ -94,15 +88,9 @@ const prplInteractiveTaskFormListener = {
9488
if ( ! postId ) {
9589
return;
9690
}
91+
92+
// This will trigger the celebration event (confetti) as well.
9793
prplSuggestedTask.maybeComplete( postId );
98-
taskEl.setAttribute( 'data-task-action', 'celebrate' );
99-
document.dispatchEvent(
100-
new CustomEvent( 'prpl/celebrateTasks', {
101-
detail: {
102-
element: taskEl,
103-
},
104-
} )
105-
);
10694
} );
10795
},
10896

@@ -153,15 +141,9 @@ const prplInteractiveTaskFormListener = {
153141
if ( ! postId ) {
154142
return;
155143
}
144+
145+
// This will trigger the celebration event (confetti) as well.
156146
prplSuggestedTask.maybeComplete( postId );
157-
taskEl.setAttribute( 'data-task-action', 'celebrate' );
158-
document.dispatchEvent(
159-
new CustomEvent( 'prpl/celebrateTasks', {
160-
detail: {
161-
element: taskEl,
162-
},
163-
} )
164-
);
165147
} );
166148
} );
167149
},

assets/js/recommendations/select-timezone.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* global prplInteractiveTaskFormListener */
1+
/* global prplInteractiveTaskFormListener, prplDocumentReady */
22

33
/*
44
* Set the site timezone.
@@ -12,3 +12,15 @@ prplInteractiveTaskFormListener.siteSettings( {
1212
taskId: 'select-timezone',
1313
popoverId: 'prpl-popover-select-timezone',
1414
} );
15+
16+
prplDocumentReady( () => {
17+
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
18+
const timezoneSelect = document.querySelector( 'select#timezone' );
19+
const timezoneSaved = timezoneSelect?.dataset?.timezoneSaved || 'false';
20+
console.log( timezoneSelect );
21+
console.log( timezoneSaved );
22+
// Try to preselect the timezone.
23+
if ( timezone && timezoneSelect && 'false' === timezoneSaved ) {
24+
timezoneSelect.value = timezone;
25+
}
26+
} );

classes/suggested-tasks/providers/class-select-timezone.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ protected function get_title() {
6969
* @return string
7070
*/
7171
protected function get_description() {
72-
return \esc_html__( 'Set site timezone to ensure scheduled posts and pages are published at desired time.', 'progress-planner' );
72+
return \esc_html__( 'Setting the time zone correctly on your site is valuable. By setting the correct time zone, you ensure scheduled tasks happen exactly when you want them to happen. To correctly account for daylight savings\', we recommend you use the city-based time zone instead of the UTC offset (e.g. Amsterdam or London).', 'progress-planner' );
7373
}
7474

7575
/**
@@ -95,7 +95,7 @@ public function should_add_task() {
9595
*/
9696
public function print_popover_instructions() {
9797
echo '<p>';
98-
\esc_html_e( 'Set site timezone to ensure scheduled posts and pages are published at desired time.', 'progress-planner' );
98+
\esc_html_e( 'Setting the time zone correctly on your site is valuable. By setting the correct time zone, you ensure scheduled tasks happen exactly when you want them to happen. To correctly account for daylight savings\', we recommend you use the city-based time zone instead of the UTC offset (e.g. Amsterdam or London).', 'progress-planner' );
9999
echo '</p>';
100100
}
101101

@@ -107,6 +107,7 @@ public function print_popover_instructions() {
107107
public function print_popover_form_contents() {
108108
$current_offset = \get_option( 'gmt_offset' );
109109
$tzstring = \get_option( 'timezone_string' );
110+
$was_tzstring_saved = '' !== $tzstring || '0' !== $current_offset ? 'true' : 'false';
110111

111112
// Remove old Etc mappings. Fallback to gmt_offset.
112113
if ( str_contains( $tzstring, 'Etc/GMT' ) ) {
@@ -124,7 +125,7 @@ public function print_popover_form_contents() {
124125
}
125126
?>
126127
<label>
127-
<select id="timezone" name="timezone">
128+
<select id="gmt_offset" name="gmt_offset" data-timezone-saved="<?php echo \esc_attr( $was_tzstring_saved ); ?>">
128129
<?php echo \wp_timezone_choice( $tzstring, \get_user_locale() ); ?>
129130
</select>
130131
</label>

0 commit comments

Comments
 (0)