@@ -281,7 +281,7 @@ public function register_post_type() {
281281 'show_in_admin_bar ' => \apply_filters ( 'progress_planner_tasks_show_ui ' , false ),
282282 'show_in_rest ' => true ,
283283 'rest_controller_class ' => \Progress_Planner \Rest \Recommendations_Controller::class,
284- 'supports ' => [ 'title ' , 'editor ' , 'author ' , 'custom-fields ' , 'page-attributes ' ],
284+ 'supports ' => [ 'title ' , 'excerpt ' , ' editor ' , 'author ' , 'custom-fields ' , 'page-attributes ' ],
285285 'rewrite ' => false ,
286286 'menu_icon ' => 'dashicons-admin-tools ' ,
287287 'menu_position ' => 5 ,
@@ -291,11 +291,6 @@ public function register_post_type() {
291291 );
292292
293293 $ rest_meta_fields = [
294- 'prpl_points ' => [
295- 'type ' => 'number ' ,
296- 'single ' => true ,
297- 'show_in_rest ' => true ,
298- ],
299294 'prpl_task_id ' => [
300295 'type ' => 'string ' ,
301296 'single ' => true ,
@@ -442,13 +437,14 @@ public function rest_prepare_recommendation( $response, $post ) {
442437
443438 // This has to be the last item to be added because actions use data from previous items.
444439 $ response ->data ['prpl_task_actions ' ] = $ provider ->get_task_actions ( $ response ->data );
440+ $ response ->data ['prpl_points ' ] = $ provider ->get_points ();
445441
446442 /*
447443 * Check if task was completed before - for example, comments were disabled and then re-enabled, and remove points if so.
448444 * Those are tasks which are completed by toggling an option, so non repetitive & not user tasks.
449445 */
450446 if ( ! \has_term ( 'user ' , 'prpl_recommendations_provider ' , $ post ->ID ) && ! $ provider ->is_repetitive () && $ provider ->task_has_activity ( $ response ->data ['meta ' ]['prpl_task_id ' ] ) ) {
451- $ response ->data ['meta ' ][ ' prpl_points ' ] = 0 ;
447+ $ response ->data ['prpl_points ' ] = 0 ;
452448 }
453449 }
454450
@@ -513,7 +509,15 @@ public function get_tasks_in_rest_format( array $args = [] ) {
513509 }
514510 }
515511
516- return $ tasks ;
512+ /**
513+ * Allow other classes to modify the tasks in REST format.
514+ *
515+ * @param array $tasks The tasks.
516+ * @param array $args The arguments.
517+ *
518+ * @return array
519+ */
520+ return \apply_filters ( 'progress_planner_suggested_tasks_in_rest_format ' , $ tasks , $ args );
517521 }
518522
519523 /**
0 commit comments