Skip to content

Commit d2c0c56

Browse files
committed
Stop saving prpl_popover_id as a post-meta
1 parent 0dcd36a commit d2c0c56

14 files changed

Lines changed: 36 additions & 23 deletions

classes/class-suggested-tasks-db.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ public function update_recommendation( $id, $data ) {
175175
switch ( $key ) {
176176
case 'points':
177177
case 'prpl_points':
178-
case 'prpl_popover_id':
179178
case 'prpl_external_link_url':
180179
$update_meta[ 'prpl_' . \str_replace( 'prpl_', '', (string) $key ) ] = $value;
181180
break;

classes/class-suggested-tasks.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,6 @@ public function register_post_type() {
314314
'show_in_rest' => true,
315315
'default' => 0,
316316
],
317-
'prpl_popover_id' => [
318-
'type' => 'string',
319-
'single' => true,
320-
'show_in_rest' => true,
321-
],
322317
'prpl_external_link_url' => [
323318
'type' => 'string',
324319
'single' => true,
@@ -450,6 +445,9 @@ public function rest_prepare_recommendation( $response, $post ) {
450445
? \esc_url( (string) $response->data['meta']['prpl_url'] )
451446
: '';
452447

448+
$response->data['prpl_popover_id'] = $provider->get_popover_id();
449+
450+
// This has to be the last item to be added because actions use data from previous items.
453451
$response->data['prpl_task_actions'] = $provider->get_task_actions( $response->data );
454452
}
455453

classes/suggested-tasks/class-tasks-interface.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ public function is_repetitive();
104104
*/
105105
public function get_task_actions( $data = [] );
106106

107+
/**
108+
* Get the popover ID.
109+
*
110+
* @return string
111+
*/
112+
public function get_popover_id();
113+
107114
/**
108115
* Add task actions specific to this task.
109116
*

classes/suggested-tasks/providers/class-blog-description.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class="regular-text"
134134
public function add_task_actions( $data = [], $actions = [] ) {
135135
$actions[] = [
136136
'priority' => 10,
137-
'html' => '<a href="#" class="prpl-tooltip-action-text" role="button" onclick="document.getElementById(\'' . \esc_attr( $data['meta']['prpl_popover_id'] ) . '\')?.showPopover()">' . \esc_html__( 'Set tagline', 'progress-planner' ) . '</a>',
137+
'html' => '<a href="#" class="prpl-tooltip-action-text" role="button" onclick="document.getElementById(\'prpl-popover-' . \esc_attr( static::POPOVER_ID ) . '\')?.showPopover()">' . \esc_html__( 'Set tagline', 'progress-planner' ) . '</a>',
138138
];
139139

140140
return $actions;

classes/suggested-tasks/providers/class-disable-comment-pagination.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public function print_popover_form_contents() {
131131
public function add_task_actions( $data = [], $actions = [] ) {
132132
$actions[] = [
133133
'priority' => 10,
134-
'html' => '<a href="#" class="prpl-tooltip-action-text" role="button" onclick="document.getElementById(\'' . \esc_attr( $data['meta']['prpl_popover_id'] ) . '\')?.showPopover()">' . \esc_html__( 'Disable pagination', 'progress-planner' ) . '</a>',
134+
'html' => '<a href="#" class="prpl-tooltip-action-text" role="button" onclick="document.getElementById(\'prpl-popover-' . \esc_attr( static::POPOVER_ID ) . '\')?.showPopover()">' . \esc_html__( 'Disable pagination', 'progress-planner' ) . '</a>',
135135
];
136136

137137
return $actions;

classes/suggested-tasks/providers/class-disable-comments.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public function print_popover_form_contents() {
162162
public function add_task_actions( $data = [], $actions = [] ) {
163163
$actions[] = [
164164
'priority' => 10,
165-
'html' => '<a href="#" class="prpl-tooltip-action-text" role="button" onclick="document.getElementById(\'' . \esc_attr( $data['meta']['prpl_popover_id'] ) . '\')?.showPopover()">' . \esc_html__( 'Disable comments', 'progress-planner' ) . '</a>',
165+
'html' => '<a href="#" class="prpl-tooltip-action-text" role="button" onclick="document.getElementById(\'prpl-popover-' . \esc_attr( static::POPOVER_ID ) . '\')?.showPopover()">' . \esc_html__( 'Disable comments', 'progress-planner' ) . '</a>',
166166
];
167167

168168
return $actions;

classes/suggested-tasks/providers/class-email-sending.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ public function print_popover_form_contents() {
321321
public function add_task_actions( $data = [], $actions = [] ) {
322322
$actions[] = [
323323
'priority' => 10,
324-
'html' => '<a href="#" class="prpl-tooltip-action-text" role="button" onclick="document.getElementById(\'' . \esc_attr( $data['meta']['prpl_popover_id'] ) . '\')?.showPopover()">' . \esc_html__( 'Test email sending', 'progress-planner' ) . '</a>',
324+
'html' => '<a href="#" class="prpl-tooltip-action-text" role="button" onclick="document.getElementById(\'prpl-popover-' . \esc_attr( static::POPOVER_ID ) . '\')?.showPopover()">' . \esc_html__( 'Test email sending', 'progress-planner' ) . '</a>',
325325
];
326326

327327
return $actions;

classes/suggested-tasks/providers/class-hello-world.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ protected function get_enqueue_data() {
164164
public function add_task_actions( $data = [], $actions = [] ) {
165165
$actions[] = [
166166
'priority' => 10,
167-
'html' => '<a href="#" class="prpl-tooltip-action-text" role="button" onclick="document.getElementById(\'' . \esc_attr( $data['meta']['prpl_popover_id'] ) . '\')?.showPopover()">' . \esc_html__( 'Delete', 'progress-planner' ) . '</a>',
167+
'html' => '<a href="#" class="prpl-tooltip-action-text" role="button" onclick="document.getElementById(\'prpl-popover-' . \esc_attr( static::POPOVER_ID ) . '\')?.showPopover()">' . \esc_html__( 'Delete', 'progress-planner' ) . '</a>',
168168
];
169169

170170
return $actions;

classes/suggested-tasks/providers/class-sample-page.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ protected function get_enqueue_data() {
163163
public function add_task_actions( $data = [], $actions = [] ) {
164164
$actions[] = [
165165
'priority' => 10,
166-
'html' => '<a href="#" class="prpl-tooltip-action-text" role="button" onclick="document.getElementById(\'' . \esc_attr( $data['meta']['prpl_popover_id'] ) . '\')?.showPopover()">' . \esc_html__( 'Delete', 'progress-planner' ) . '</a>',
166+
'html' => '<a href="#" class="prpl-tooltip-action-text" role="button" onclick="document.getElementById(\'prpl-popover-' . \esc_attr( static::POPOVER_ID ) . '\')?.showPopover()">' . \esc_html__( 'Delete', 'progress-planner' ) . '</a>',
167167
];
168168

169169
return $actions;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ public function handle_interactive_task_specific_submit() {
299299
public function add_task_actions( $data = [], $actions = [] ) {
300300
$actions[] = [
301301
'priority' => 10,
302-
'html' => '<a href="#" class="prpl-tooltip-action-text" role="button" onclick="document.getElementById(\'' . \esc_attr( $data['meta']['prpl_popover_id'] ) . '\')?.showPopover()">' . \esc_html__( 'Select locale', 'progress-planner' ) . '</a>',
302+
'html' => '<a href="#" class="prpl-tooltip-action-text" role="button" onclick="document.getElementById(\'prpl-popover-' . \esc_attr( static::POPOVER_ID ) . '\')?.showPopover()">' . \esc_html__( 'Select locale', 'progress-planner' ) . '</a>',
303303
];
304304

305305
return $actions;

0 commit comments

Comments
 (0)