|
1 | 1 | <?php |
2 | 2 | /** |
3 | | - * Add tasks for settings saved. |
| 3 | + * Add tasks for set valuable post types. |
4 | 4 | * |
5 | 5 | * @package Progress_Planner |
6 | 6 | */ |
7 | 7 |
|
8 | 8 | namespace Progress_Planner\Suggested_Tasks\Providers; |
9 | 9 |
|
10 | 10 | /** |
11 | | - * Add tasks for settings saved. |
| 11 | + * Add tasks for set valuable post types. |
12 | 12 | */ |
13 | 13 | class Set_Valuable_Post_Types extends Tasks_Interactive { |
14 | 14 |
|
@@ -119,30 +119,31 @@ protected function get_title() { |
119 | 119 |
|
120 | 120 | /** |
121 | 121 | * Check if the task should be added. |
122 | | - * We add tasks only to users who have have completed "Fill the settings page" task |
123 | | - * and have upgraded from v1.2 or have 'include_post_types' option empty. |
| 122 | + * We add tasks only to users who have upgraded from v1.2 or have 'include_post_types' option empty. |
124 | 123 | * Reason being that this option was migrated, |
125 | 124 | * but it could be missed, and post type selection should be revisited. |
126 | 125 | * |
127 | 126 | * @return bool |
128 | 127 | */ |
129 | 128 | public function should_add_task() { |
130 | | - $saved_posts = \progress_planner()->get_suggested_tasks_db()->get_tasks_by( [ 'provider_id' => 'settings-saved' ] ); |
131 | | - if ( empty( $saved_posts ) ) { |
| 129 | + $activity = \progress_planner()->get_activities__query()->query_activities( |
| 130 | + [ |
| 131 | + 'category' => 'suggested_task', |
| 132 | + 'data_id' => static::PROVIDER_ID, |
| 133 | + ] |
| 134 | + ); |
| 135 | + if ( ! empty( $activity ) ) { |
132 | 136 | return false; |
133 | 137 | } |
134 | 138 |
|
135 | | - // Is the task trashed? |
136 | | - $post_trashed = 'trash' === $saved_posts[0]->post_status; |
137 | | - |
138 | 139 | // Upgraded from <= 1.2? |
139 | 140 | $upgraded = (bool) \get_option( 'progress_planner_set_valuable_post_types', false ); |
140 | 141 |
|
141 | 142 | // Include post types option empty? |
142 | 143 | $include_post_types = \progress_planner()->get_settings()->get( 'include_post_types', [] ); |
143 | 144 |
|
144 | | - // Add the task only to users who have completed the "Settings saved" task and have upgraded from v1.2 or have 'include_post_types' option empty. |
145 | | - return $post_trashed && ( true === $upgraded || empty( $include_post_types ) ); |
| 145 | + // Add the task only to users who have upgraded from v1.2 or have 'include_post_types' option empty. |
| 146 | + return ( true === $upgraded || empty( $include_post_types ) ); |
146 | 147 | } |
147 | 148 |
|
148 | 149 | /** |
|
0 commit comments