Skip to content
Open
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
2 changes: 1 addition & 1 deletion classes/suggested-tasks/class-task.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @property int|null $target_term_id The target term ID for the task
* @property string|null $target_taxonomy The target taxonomy for the task
* @property string|null $target_term_name The target term name for the task
* @property string|null $date The task date in YW format (year-week)
* @property string|null $date The task date in oW format (ISO year + ISO week)
*/
class Task {
/**
Expand Down
4 changes: 2 additions & 2 deletions classes/suggested-tasks/class-tasks-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ public function cleanup_pending_tasks() {
$task_provider = $this->get_task_provider( $task->get_provider_id() );

// Should we delete the task? Delete tasks which don't have a task provider or repetitive tasks which were created in the previous week.
if ( ! $task_provider || ( $task_provider->is_repetitive() && ( ! $task->date || \gmdate( 'YW' ) !== (string) $task->date ) ) ) {
if ( ! $task_provider || ( $task_provider->is_repetitive() && ( ! $task->date || \gmdate( 'oW' ) !== (string) $task->date ) ) ) {
\progress_planner()->get_suggested_tasks_db()->delete_recommendation( $task->ID );
}
}
Expand Down Expand Up @@ -346,7 +346,7 @@ public function handle_task_unsnooze( $new_status, $old_status, $post ) {
$task_provider = $this->get_task_provider( $task->get_provider_id() );

// Delete tasks which don't have a task provider or repetitive tasks which were created in the previous week.
if ( ! $task_provider || ( $task_provider->is_repetitive() && ( ! $task->date || \gmdate( 'YW' ) !== (string) $task->date ) ) ) {
if ( ! $task_provider || ( $task_provider->is_repetitive() && ( ! $task->date || \gmdate( 'oW' ) !== (string) $task->date ) ) ) {
\progress_planner()->get_suggested_tasks_db()->delete_recommendation( $task->ID );
}

Expand Down
2 changes: 1 addition & 1 deletion classes/suggested-tasks/providers/class-content-create.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function should_add_task() {
}

// Add tasks if there are no posts published this week.
return \gmdate( 'YW' ) !== \gmdate( 'YW', \strtotime( $last_published_post_data['post_date'] ) );
return \gmdate( 'oW' ) !== \gmdate( 'oW', \strtotime( $last_published_post_data['post_date'] ) );
}

/**
Expand Down
2 changes: 1 addition & 1 deletion classes/suggested-tasks/providers/class-content-review.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
$last_updated_posts,
$this->get_old_posts(
[
'post__not_in' => $important_page_ids, // This can be an empty array.

Check warning on line 232 in classes/suggested-tasks/providers/class-content-review.php

View workflow job for this annotation

GitHub Actions / test

WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in

Using exclusionary parameters, like post__not_in, in calls to get_posts() should be done with caution, see https://wpvip.com/documentation/performance-improvements-by-removing-usage-of-post__not_in/ for more information.
'post_type' => $this->include_post_types,
]
)
Expand Down Expand Up @@ -289,7 +289,7 @@
'provider_id' => $this->get_provider_id(),
'target_post_id' => $task_data['target_post_id'],
'target_post_type' => $task_data['target_post_type'],
'date' => \gmdate( 'YW' ),
'date' => \gmdate( 'oW' ),
'post_title' => $this->get_title_with_data( $task_data ),
'url' => $this->get_url_with_data( $task_data ),
'url_target' => $this->get_url_target(),
Expand Down Expand Up @@ -374,18 +374,18 @@
* @return array
*/
public function filter_update_posts_args( $args ) {
$args['post__not_in'] = isset( $args['post__not_in'] )

Check warning on line 377 in classes/suggested-tasks/providers/class-content-review.php

View workflow job for this annotation

GitHub Actions / test

WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in

Using exclusionary parameters, like post__not_in, in calls to get_posts() should be done with caution, see https://wpvip.com/documentation/performance-improvements-by-removing-usage-of-post__not_in/ for more information.
? $args['post__not_in']
: [];

$args['post__not_in'] = \array_merge(

Check warning on line 381 in classes/suggested-tasks/providers/class-content-review.php

View workflow job for this annotation

GitHub Actions / test

WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in

Using exclusionary parameters, like post__not_in, in calls to get_posts() should be done with caution, see https://wpvip.com/documentation/performance-improvements-by-removing-usage-of-post__not_in/ for more information.
$args['post__not_in'],
// Add the snoozed post IDs to the post__not_in array.
$this->get_snoozed_post_ids(),
);

if ( ! empty( $this->get_dismissed_post_ids() ) ) {
$args['post__not_in'] = \array_merge( $args['post__not_in'], $this->get_dismissed_post_ids() );

Check warning on line 388 in classes/suggested-tasks/providers/class-content-review.php

View workflow job for this annotation

GitHub Actions / test

WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in

Using exclusionary parameters, like post__not_in, in calls to get_posts() should be done with caution, see https://wpvip.com/documentation/performance-improvements-by-removing-usage-of-post__not_in/ for more information.
}

if ( \function_exists( 'YoastSEO' ) ) {
Expand Down
12 changes: 7 additions & 5 deletions classes/suggested-tasks/providers/class-tasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,9 @@ public function get_task_id( $task_data = [] ) {
$parts[] = $task_data['target_taxonomy'] ?? false;
// If the task is repetitive, add the date as the last part (format: YYYYWW, e.g., 202542 for week 42 of 2025).
// This creates a new task instance each week for repetitive tasks.
$parts[] = $this->is_repetitive() ? \gmdate( 'YW' ) : false;
// Note: We use 'oW' format (ISO year + ISO week) instead of 'YW' to handle year boundaries correctly.
// For example, Dec 29, 2025 is ISO week 01 of 2026, so 'oW' returns '202601' while 'YW' would incorrectly return '202501'.
$parts[] = $this->is_repetitive() ? \gmdate( 'oW' ) : false;

// Remove empty parts to keep IDs clean.
$parts = \array_filter( $parts );
Expand Down Expand Up @@ -447,7 +449,7 @@ public function is_task_relevant() {
* - Returns the task object if completed, false otherwise
*
* Repetitive tasks:
* - Must be completed within the same week they were created (using YW format: year + week number)
* - Must be completed within the same week they were created (using oW format: ISO year + ISO week number)
* - For example, a task created in week 42 of 2025 must be completed in 2025W42
* - This prevents tasks from previous weeks being marked as complete
* - Allows child classes to add completion data (e.g., post_id for "create post" tasks)
Expand Down Expand Up @@ -483,8 +485,8 @@ public function evaluate_task( $task_id ) {
$task->provider &&
$task->provider->slug === $this->get_provider_id() &&
\DateTime::createFromFormat( 'Y-m-d H:i:s', $task->post_date ) &&
// Check if the task was created in the current week (YW format: e.g., 202542 = week 42 of 2025).
\gmdate( 'YW' ) === \gmdate( 'YW', \DateTime::createFromFormat( 'Y-m-d H:i:s', $task->post_date )->getTimestamp() ) && // @phpstan-ignore-line
// Check if the task was created in the current week (oW format: ISO year + ISO week, e.g., 202542 = week 42 of 2025).
\gmdate( 'oW' ) === \gmdate( 'oW', \DateTime::createFromFormat( 'Y-m-d H:i:s', $task->post_date )->getTimestamp() ) && // @phpstan-ignore-line
$this->is_task_completed( \progress_planner()->get_suggested_tasks()->get_task_id_from_slug( $task->post_name ) )
) {
// Allow adding more data, for example in case of 'create-post' tasks we are adding the post_id.
Expand Down Expand Up @@ -599,7 +601,7 @@ public function get_task_details( $task_data = [] ) {
'parent' => $this->get_parent(),
'priority' => $this->get_priority(),
'points' => $this->get_points(),
'date' => \gmdate( 'YW' ),
'date' => \gmdate( 'oW' ),
'url' => $this->get_url_with_data( $task_data ),
'url_target' => $this->get_url_target(),
'link_setting' => $this->get_link_setting(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function handle_task_dismissal( $post_id ) {

// Store the task dismissal data.
$dismissal_data = [
'date' => \gmdate( 'YW' ),
'date' => \gmdate( 'oW' ),
'timestamp' => \time(),
];

Expand Down Expand Up @@ -157,7 +157,7 @@ protected function is_task_dismissed( $task_data ) {
$dismissal_data = $dismissed_tasks[ $provider_key ][ $task_identifier ];

// If the task was dismissed in the current week, don't show it again.
if ( $dismissal_data['date'] === \gmdate( 'YW' ) ) {
if ( $dismissal_data['date'] === \gmdate( 'oW' ) ) {
return true;
}

Expand Down
24 changes: 12 additions & 12 deletions tests/phpunit/test-class-suggested-tasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,30 @@ public function test_task_cleanup() {
// Tasks that should not be removed.
$tasks_to_keep = [
[
'post_title' => 'review-post-14-' . \gmdate( 'YW' ),
'task_id' => 'review-post-14-' . \gmdate( 'YW' ),
'date' => \gmdate( 'YW' ),
'post_title' => 'review-post-14-' . \gmdate( 'oW' ),
'task_id' => 'review-post-14-' . \gmdate( 'oW' ),
'date' => \gmdate( 'oW' ),
'category' => 'content-update',
'provider_id' => 'review-post',
],
[
'post_title' => 'create-post-' . \gmdate( 'YW' ),
'task_id' => 'create-post-' . \gmdate( 'YW' ),
'date' => \gmdate( 'YW' ),
'post_title' => 'create-post-' . \gmdate( 'oW' ),
'task_id' => 'create-post-' . \gmdate( 'oW' ),
'date' => \gmdate( 'oW' ),
'category' => 'content-new',
'provider_id' => 'create-post',
],
[
'post_title' => 'update-core-' . \gmdate( 'YW' ),
'task_id' => 'update-core-' . \gmdate( 'YW' ),
'date' => \gmdate( 'YW' ),
'post_title' => 'update-core-' . \gmdate( 'oW' ),
'task_id' => 'update-core-' . \gmdate( 'oW' ),
'date' => \gmdate( 'oW' ),
'category' => 'maintenance',
'provider_id' => 'update-core',
],
[
'post_title' => 'core-siteicon-' . \gmdate( 'YW' ),
'task_id' => 'core-siteicon-' . \gmdate( 'YW' ),
'date' => \gmdate( 'YW' ),
'post_title' => 'core-siteicon-' . \gmdate( 'oW' ),
'task_id' => 'core-siteicon-' . \gmdate( 'oW' ),
'date' => \gmdate( 'oW' ),
'provider_id' => 'core-siteicon',
'category' => 'configuration',
],
Expand Down
Loading