* Only load default tasks during REST requests

* Add changelog entry
This commit is contained in:
Joshua T Flowers 2021-11-05 15:38:05 -04:00 committed by GitHub
parent 1a48569af9
commit 675cf379c1
3 changed files with 11 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: Performance
Only load default tasks during REST requests #7904

View File

@ -769,6 +769,7 @@ class OnboardingTasks extends \WC_REST_Data_Controller {
public function get_tasks( $request ) {
$extended_tasks = $request->get_param( 'extended_tasks' );
TaskLists::maybe_add_default_tasks();
TaskLists::maybe_add_extended_tasks( $extended_tasks );
$lists = TaskLists::get_lists();
@ -790,6 +791,7 @@ class OnboardingTasks extends \WC_REST_Data_Controller {
* @return WP_REST_Request|WP_Error
*/
public function dismiss_task( $request ) {
TaskLists::maybe_add_default_tasks();
$id = $request->get_param( 'id' );
$task = TaskLists::get_task( $id );
@ -824,6 +826,7 @@ class OnboardingTasks extends \WC_REST_Data_Controller {
* @return WP_REST_Request|WP_Error
*/
public function undo_dismiss_task( $request ) {
TaskLists::maybe_add_default_tasks();
$id = $request->get_param( 'id' );
$task = TaskLists::get_task( $id );
@ -860,6 +863,7 @@ class OnboardingTasks extends \WC_REST_Data_Controller {
* @return WP_REST_Response|WP_Error
*/
public function snooze_task( $request ) {
TaskLists::maybe_add_default_tasks();
$task_id = $request->get_param( 'id' );
$task_list_id = $request->get_param( 'task_list_id' );
$duration = $request->get_param( 'duration' );
@ -897,6 +901,7 @@ class OnboardingTasks extends \WC_REST_Data_Controller {
* @return WP_REST_Request|WP_Error
*/
public function undo_snooze_task( $request ) {
TaskLists::maybe_add_default_tasks();
$id = $request->get_param( 'id' );
$task = TaskLists::get_task( $id );
@ -932,6 +937,7 @@ class OnboardingTasks extends \WC_REST_Data_Controller {
* @return WP_REST_Response|WP_Error
*/
public function hide_task_list( $request ) {
TaskLists::maybe_add_default_tasks();
$id = $request->get_param( 'id' );
$task_list = TaskLists::get_list( $id );
@ -958,6 +964,7 @@ class OnboardingTasks extends \WC_REST_Data_Controller {
* @return WP_REST_Request|WP_Error
*/
public function action_task( $request ) {
TaskLists::maybe_add_default_tasks();
$id = $request->get_param( 'id' );
$task = TaskLists::get_task( $id );

View File

@ -65,7 +65,6 @@ class TaskLists {
*/
public static function init() {
self::init_default_lists();
add_action( 'init', array( __CLASS__, 'maybe_add_default_tasks' ) );
add_action( 'admin_init', array( __CLASS__, 'set_active_task' ), 5 );
add_action( 'admin_init', array( __CLASS__, 'init_tasks' ) );
}