Skip to content

Commit 23af83e

Browse files
committed
handle integrations, adjust error displaying of error message, add wpseo_titles
1 parent 94668b4 commit 23af83e

15 files changed

Lines changed: 89 additions & 50 deletions

assets/css/page-widgets/suggested-tasks.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@
206206
&.prpl-note-error {
207207
color: var(--prpl-color-alert-error-text);
208208
background-color: var(--prpl-background-alert-error);
209+
margin-bottom: 0;
210+
211+
order: 98; /* One less than the spinner. */
212+
flex-grow: 1;
209213

210214
.prpl-note-icon {
211215
color: var(--prpl-color-alert-error);

assets/js/recommendations/interactive-task.js

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -228,17 +228,12 @@ const prplInteractiveTaskFormListener = {
228228

229229
console.error( 'Error in interactive task callback:', error );
230230

231-
// Add error message.
232-
const submitButton = formElement.querySelector(
233-
'button[type="submit"]'
231+
// Check if there's already an error message <p> element right after the form
232+
const existingErrorElement = formElement.parentNode.querySelector(
233+
'p.prpl-interactive-task-error-message'
234234
);
235235

236-
if (
237-
submitButton &&
238-
! formElement.querySelector(
239-
'.prpl-interactive-task-error-message'
240-
)
241-
) {
236+
if ( ! existingErrorElement ) {
242237
// Add paragraph with error message.
243238
const errorParagraph = document.createElement( 'p' );
244239
errorParagraph.classList.add(
@@ -248,11 +243,8 @@ const prplInteractiveTaskFormListener = {
248243
);
249244
errorParagraph.textContent = prplL10n( 'somethingWentWrong' );
250245

251-
// Append before submit button.
252-
submitButton.parentNode.insertBefore(
253-
errorParagraph,
254-
submitButton
255-
);
246+
// Append after the form element.
247+
formElement.insertAdjacentElement( 'afterend', errorParagraph );
256248
}
257249
},
258250

@@ -263,8 +255,15 @@ const prplInteractiveTaskFormListener = {
263255
* @return {void}
264256
*/
265257
showLoading: ( formElement ) => {
266-
// data-action="completeTask"
267-
formElement.querySelector( 'button[type="submit"]' ).disabled = true;
258+
let submitButton = formElement.querySelector( 'button[type="submit"]' );
259+
260+
if ( ! submitButton ) {
261+
submitButton = formElement.querySelector(
262+
'button[data-action="completeTask"]'
263+
);
264+
}
265+
266+
submitButton.disabled = true;
268267

269268
// Add spinner.
270269
const spinner = document.createElement( 'span' );
@@ -273,7 +272,7 @@ const prplInteractiveTaskFormListener = {
273272
'<span class="spinner" style="visibility: visible;"></span>'; // WP spinner.
274273

275274
// Append spinner after submit button.
276-
formElement.querySelector( 'button[type="submit"]' ).after( spinner );
275+
submitButton.after( spinner );
277276
},
278277

279278
/**
@@ -283,7 +282,18 @@ const prplInteractiveTaskFormListener = {
283282
* @return {void}
284283
*/
285284
hideLoading: ( formElement ) => {
286-
formElement.querySelector( 'button[type="submit"]' ).disabled = false;
287-
formElement.querySelector( 'span.prpl-spinner' )?.remove();
285+
let submitButton = formElement.querySelector( 'button[type="submit"]' );
286+
287+
if ( ! submitButton ) {
288+
submitButton = formElement.querySelector(
289+
'button[data-action="completeTask"]'
290+
);
291+
}
292+
293+
submitButton.disabled = false;
294+
const spinner = formElement.querySelector( 'span.prpl-spinner' );
295+
if ( spinner ) {
296+
spinner.remove();
297+
}
288298
},
289299
};

classes/suggested-tasks/providers/integrations/aioseo/class-archive-author.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,11 @@ public function print_popover_instructions() {
136136
*/
137137
public function print_popover_form_contents() {
138138
?>
139-
<button type="submit" class="prpl-button prpl-button-primary">
140-
<?php \esc_html_e( 'Noindex the author archive', 'progress-planner' ); ?>
141-
</button>
139+
<div class="prpl-steps-nav-wrapper">
140+
<button type="submit" class="prpl-button prpl-button-primary">
141+
<?php \esc_html_e( 'Noindex the author archive', 'progress-planner' ); ?>
142+
</button>
143+
</div>
142144
<?php
143145
}
144146

classes/suggested-tasks/providers/integrations/aioseo/class-archive-date.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,11 @@ public function print_popover_instructions() {
122122
*/
123123
public function print_popover_form_contents() {
124124
?>
125+
<div class="prpl-steps-nav-wrapper">
125126
<button type="submit" class="prpl-button prpl-button-primary">
126127
<?php \esc_html_e( 'Noindex the date archive', 'progress-planner' ); ?>
127128
</button>
129+
</div>
128130
<?php
129131
}
130132

classes/suggested-tasks/providers/integrations/aioseo/class-crawl-settings-feed-authors.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,11 @@ public function print_popover_instructions() {
133133
*/
134134
public function print_popover_form_contents() {
135135
?>
136-
<button type="submit" class="prpl-button prpl-button-primary">
137-
<?php \esc_html_e( 'Disable author RSS feeds', 'progress-planner' ); ?>
138-
</button>
136+
<div class="prpl-steps-nav-wrapper">
137+
<button type="submit" class="prpl-button prpl-button-primary">
138+
<?php \esc_html_e( 'Disable author RSS feeds', 'progress-planner' ); ?>
139+
</button>
140+
</div>
139141
<?php
140142
}
141143

classes/suggested-tasks/providers/integrations/aioseo/class-crawl-settings-feed-comments.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,11 @@ public function print_popover_instructions() {
101101
*/
102102
public function print_popover_form_contents() {
103103
?>
104-
<button type="submit" class="prpl-button prpl-button-primary">
105-
<?php \esc_html_e( 'Disable comment RSS feeds', 'progress-planner' ); ?>
106-
</button>
104+
<div class="prpl-steps-nav-wrapper">
105+
<button type="submit" class="prpl-button prpl-button-primary">
106+
<?php \esc_html_e( 'Disable comment RSS feeds', 'progress-planner' ); ?>
107+
</button>
108+
</div>
107109
<?php
108110
}
109111

classes/suggested-tasks/providers/integrations/yoast/class-add-yoast-providers.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ public function exclude_not_indexable_taxonomies( $exclude_taxonomies ) {
132132
*/
133133
public function add_interactive_task_allowed_options( $allowed_options ) {
134134
$allowed_options[] = 'wpseo';
135+
$allowed_options[] = 'wpseo_titles';
135136
return $allowed_options;
136137
}
137138
}

classes/suggested-tasks/providers/integrations/yoast/class-archive-author.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,11 @@ public function print_popover_instructions() {
126126
*/
127127
public function print_popover_form_contents() {
128128
?>
129-
<button type="submit" class="prpl-button prpl-button-primary">
130-
<?php \esc_html_e( 'Disable', 'progress-planner' ); ?>
131-
</button>
129+
<div class="prpl-steps-nav-wrapper">
130+
<button type="submit" class="prpl-button prpl-button-primary">
131+
<?php \esc_html_e( 'Disable', 'progress-planner' ); ?>
132+
</button>
133+
</div>
132134
<?php
133135
}
134136

classes/suggested-tasks/providers/integrations/yoast/class-archive-date.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,11 @@ public function print_popover_instructions() {
113113
*/
114114
public function print_popover_form_contents() {
115115
?>
116-
<button type="submit" class="prpl-button prpl-button-primary">
117-
<?php \esc_html_e( 'Disable', 'progress-planner' ); ?>
118-
</button>
116+
<div class="prpl-steps-nav-wrapper">
117+
<button type="submit" class="prpl-button prpl-button-primary">
118+
<?php \esc_html_e( 'Disable', 'progress-planner' ); ?>
119+
</button>
120+
</div>
119121
<?php
120122
}
121123

classes/suggested-tasks/providers/integrations/yoast/class-archive-format.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,11 @@ public function print_popover_instructions() {
126126
*/
127127
public function print_popover_form_contents() {
128128
?>
129+
<div class="prpl-steps-nav-wrapper">
129130
<button type="submit" class="prpl-button prpl-button-primary">
130-
<?php \esc_html_e( 'Disable', 'progress-planner' ); ?>
131-
</button>
131+
<?php \esc_html_e( 'Disable', 'progress-planner' ); ?>
132+
</button>
133+
</div>
132134
<?php
133135
}
134136

0 commit comments

Comments
 (0)