Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions classes/admin/class-enqueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public function localize_script( $handle, $localize_data = [] ) {

// Check if user wants to see all recommendations.
$show_all_recommendations = isset( $_GET['prpl_show_all_recommendations'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$tasks_per_page = $show_all_recommendations ? -1 : \Progress_Planner\Admin\Widgets\Suggested_Tasks::PER_PAGE_DEFAULT;
$tasks_per_page = $show_all_recommendations ? -1 : \Progress_Planner\Admin\Widgets\Suggested_Tasks::get_per_page();

// Get tasks from task providers (limited to 5 by default, or unlimited if showing all).
$tasks = \progress_planner()->get_suggested_tasks()->get_tasks_in_rest_format(
Expand Down Expand Up @@ -269,7 +269,7 @@ public function localize_script( $handle, $localize_data = [] ) {
],
'delayCelebration' => $delay_celebration,
'tasksPerPage' => $tasks_per_page,
'perPageDefault' => \Progress_Planner\Admin\Widgets\Suggested_Tasks::PER_PAGE_DEFAULT,
'perPageDefault' => \Progress_Planner\Admin\Widgets\Suggested_Tasks::get_per_page(),
],
];
break;
Expand Down
20 changes: 20 additions & 0 deletions classes/admin/widgets/class-suggested-tasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,26 @@ final class Suggested_Tasks extends Widget {
*/
public const PER_PAGE_DEFAULT = 5;

/**
* Number of tasks to show per page on the WP Dashboard.
*
* @var int
*/
public const PER_PAGE_DASHBOARD = 3;

/**
* Get the number of tasks to show per page based on the current screen.
*
* @return int
*/
public static function get_per_page() {
$screen = \get_current_screen();
if ( $screen && 'dashboard' === $screen->id ) {
return self::PER_PAGE_DASHBOARD;
}
return self::PER_PAGE_DEFAULT;
}

/**
* The widget ID.
*
Expand Down
Loading