File tree Expand file tree Collapse file tree
classes/suggested-tasks/providers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -245,21 +245,27 @@ protected function is_specific_task_completed( $task_id ) {
245245 public function get_tasks_to_inject () {
246246
247247 if (
248+ true === $ this ->is_task_snoozed () ||
248249 ! $ this ->should_add_task () // No need to add the task.
249250 ) {
250251 return [];
251252 }
252253
253- $ data = $ this ->data_collector ->collect ();
254+ $ data = $ this ->data_collector ->collect ();
255+ $ task_id = $ this ->get_task_id (
256+ [
257+ 'term_id ' => $ data ['term_id ' ],
258+ 'taxonomy ' => $ data ['taxonomy ' ],
259+ ]
260+ );
261+
262+ if ( true === \progress_planner ()->get_suggested_tasks ()->was_task_completed ( $ task_id ) ) {
263+ return [];
264+ }
254265
255266 return [
256267 [
257- 'task_id ' => $ this ->get_task_id (
258- [
259- 'term_id ' => $ data ['term_id ' ],
260- 'taxonomy ' => $ data ['taxonomy ' ],
261- ]
262- ),
268+ 'task_id ' => $ task_id ,
263269 'provider_id ' => $ this ->get_provider_id (),
264270 'category ' => $ this ->get_provider_category (),
265271 'term_id ' => $ data ['term_id ' ],
Original file line number Diff line number Diff line change @@ -410,7 +410,7 @@ public function get_tasks_to_inject() {
410410 if (
411411 true === $ this ->is_task_snoozed () ||
412412 ! $ this ->should_add_task () || // No need to add the task.
413- true === \progress_planner ()->get_suggested_tasks ()->was_task_completed ( $ this -> get_task_id () )
413+ true === \progress_planner ()->get_suggested_tasks ()->was_task_completed ( $ task_id )
414414 ) {
415415 return [];
416416 }
Original file line number Diff line number Diff line change @@ -238,21 +238,27 @@ protected function is_specific_task_completed( $task_id ) {
238238 public function get_tasks_to_inject () {
239239
240240 if (
241+ true === $ this ->is_task_snoozed () ||
241242 ! $ this ->should_add_task () // No need to add the task.
242243 ) {
243244 return [];
244245 }
245246
246- $ data = $ this ->data_collector ->collect ();
247+ $ data = $ this ->data_collector ->collect ();
248+ $ task_id = $ this ->get_task_id (
249+ [
250+ 'term_id ' => $ data ['term_id ' ],
251+ 'taxonomy ' => $ data ['taxonomy ' ],
252+ ]
253+ );
254+
255+ if ( true === \progress_planner ()->get_suggested_tasks ()->was_task_completed ( $ task_id ) ) {
256+ return [];
257+ }
247258
248259 return [
249260 [
250- 'task_id ' => $ this ->get_task_id (
251- [
252- 'term_id ' => $ data ['term_id ' ],
253- 'taxonomy ' => $ data ['taxonomy ' ],
254- ]
255- ),
261+ 'task_id ' => $ task_id ,
256262 'provider_id ' => $ this ->get_provider_id (),
257263 'category ' => $ this ->get_provider_category (),
258264 'term_id ' => $ data ['term_id ' ],
Original file line number Diff line number Diff line change @@ -51,6 +51,12 @@ class Cornerstone_Workout extends Tasks {
5151 */
5252 protected $ is_dismissable = true ;
5353
54+ /**
55+ * Whether the task is repetitive.
56+ *
57+ * @var bool
58+ */
59+ protected $ is_repetitive = true ;
5460
5561 /**
5662 * The task points.
@@ -167,26 +173,6 @@ public function should_add_task() {
167173 return true ;
168174 }
169175
170- /**
171- * Get an array of tasks to inject.
172- *
173- * @return array
174- */
175- public function get_tasks_to_inject () {
176- if ( ! $ this ->should_add_task () ) {
177- return [];
178- }
179-
180- return [
181- [
182- 'task_id ' => $ this ->get_task_id (),
183- 'provider_id ' => $ this ->get_provider_id (),
184- 'category ' => $ this ->get_provider_category (),
185- 'date ' => \gmdate ( 'YW ' ),
186- ],
187- ];
188- }
189-
190176 /**
191177 * Get the task details.
192178 *
Original file line number Diff line number Diff line change @@ -197,20 +197,27 @@ protected function is_specific_task_completed( $task_id ) {
197197 public function get_tasks_to_inject () {
198198
199199 if (
200+ true === $ this ->is_task_snoozed () ||
200201 ! $ this ->should_add_task () // No need to add the task.
201202 ) {
202203 return [];
203204 }
204205
205- $ data = $ this ->data_collector ->collect ();
206+ $ data = $ this ->data_collector ->collect ();
207+ $ task_id = $ this ->get_task_id (
208+ [
209+ 'post_id ' => $ data ['post_id ' ],
210+ ]
211+ );
212+
213+ // When we have data, check if task was completed.
214+ if ( true === \progress_planner ()->get_suggested_tasks ()->was_task_completed ( $ task_id ) ) {
215+ return [];
216+ }
206217
207218 return [
208219 [
209- 'task_id ' => $ this ->get_task_id (
210- [
211- 'post_id ' => $ data ['post_id ' ],
212- ]
213- ),
220+ 'task_id ' => $ task_id ,
214221 'provider_id ' => $ this ->get_provider_id (),
215222 'category ' => $ this ->get_provider_category (),
216223 'post_id ' => $ data ['post_id ' ],
Original file line number Diff line number Diff line change @@ -51,6 +51,13 @@ class Orphaned_Content_Workout extends Tasks {
5151 */
5252 protected $ is_dismissable = true ;
5353
54+ /**
55+ * Whether the task is repetitive.
56+ *
57+ * @var bool
58+ */
59+ protected $ is_repetitive = true ;
60+
5461 /**
5562 * The task points.
5663 *
@@ -166,26 +173,6 @@ public function should_add_task() {
166173 return true ;
167174 }
168175
169- /**
170- * Get an array of tasks to inject.
171- *
172- * @return array
173- */
174- public function get_tasks_to_inject () {
175- if ( ! $ this ->should_add_task () ) {
176- return [];
177- }
178-
179- return [
180- [
181- 'task_id ' => $ this ->get_task_id (),
182- 'provider_id ' => $ this ->get_provider_id (),
183- 'category ' => $ this ->get_provider_category (),
184- 'date ' => \gmdate ( 'YW ' ),
185- ],
186- ];
187- }
188-
189176 /**
190177 * Get the task details.
191178 *
You can’t perform that action at this time.
0 commit comments