Skip to content

Create tasks based on post types#22718

Merged
thijsoo merged 10 commits intofeature/task-listfrom
838-backend-create-all-dynamic-tasks
Nov 19, 2025
Merged

Create tasks based on post types#22718
thijsoo merged 10 commits intofeature/task-listfrom
838-backend-create-all-dynamic-tasks

Conversation

@leonidasmi
Copy link
Copy Markdown
Contributor

@leonidasmi leonidasmi commented Nov 17, 2025

Context

  • This task is about creating tasks for the search appearance templates of the page/post/product post types.

Summary

This PR can be summarized in the following changelog entry:

  • Creates tasks based on post types.

Relevant technical choices:

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • Running the GET request (http://example.com/wp-json/yoast/v1/get_tasks) now also includes the following tasks too:
        "set-search-appearance-templates-post": {
            "id": "set-search-appearance-templates-post",
            "duration": 10,
            "priority": "high",
            "is_completed": false,
            "call_to_action": {
                "label": "Customize search appearance",
                "type": "link",
                "href": "http://dev.local/wp-admin/admin.php?page=wpseo_page_settings#/post-type/posts"
            },
            "copy_set": {
                "title": "Set search appearance templates for your posts",
                "why": "Custom search appearance templates help improve how your content looks in search results, driving more clicks.",
                "how": "Customize search appearance templates for your posts."
            }
        },
        "set-search-appearance-templates-page": {
            "id": "set-search-appearance-templates-page",
            "duration": 10,
            "priority": "high",
            "is_completed": false,
            "call_to_action": {
                "label": "Customize search appearance",
                "type": "link",
                "href": "http://dev.local/wp-admin/admin.php?page=wpseo_page_settings#/post-type/pages"
            },
            "copy_set": {
                "title": "Set search appearance templates for your pages",
                "why": "Custom search appearance templates help improve how your content looks in search results, driving more clicks.",
                "how": "Customize search appearance templates for your pages."
            }
        },
        "set-search-appearance-templates-product": {
            "id": "set-search-appearance-templates-product",
            "duration": 10,
            "priority": "high",
            "is_completed": false,
            "call_to_action": {
                "label": "Customize search appearance",
                "type": "link",
                "href": "http://dev.local/wp-admin/admin.php?page=wpseo_page_settings#/post-type/product"
            },
            "copy_set": {
                "title": "Set search appearance templates for your products",
                "why": "Custom search appearance templates help improve how your content looks in search results, driving more clicks.",
                "how": "Customize search appearance templates for your products."
            }
        }
  • the product one is included only when Woo is active
  • the logic behind the is_completed is:
    • if either one of the SEO title or meta description template for that post type is changed from the default value, it's true.
    • if none of the SEO title or meta description template for that post type is changed from the default value, it's false.
  • Check the href values and confirm that you are pointed to the settings of the respective post type
    • Smoke test the settings of taxonomies, because we did a small change to the routes of those too. Just go to Yoast settings->Categories & tags->Categories and save a couple of settings to confirm everything looks good.

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.

Documentation

  • I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

Quality assurance

  • I have tested this code to the best of my abilities.
  • During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • I have added unit tests to verify the code works as intended.
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.
  • I have written this PR in accordance with my team's definition of done.
  • I have checked that the base branch is correctly set.

Innovation

  • No innovation project is applicable for this PR.
  • This PR falls under an innovation project. I have attached the innovation label.
  • I have added my hours to the WBSO document.

Fixes #

@leonidasmi leonidasmi changed the base branch from trunk to feature/task-list November 17, 2025 09:16
@leonidasmi leonidasmi added the changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog label Nov 17, 2025
@leonidasmi leonidasmi added this to the feature/task-list milestone Nov 17, 2025
@leonidasmi leonidasmi force-pushed the 838-backend-create-all-dynamic-tasks branch from 04255c3 to c052dff Compare November 17, 2025 10:47
@coveralls
Copy link
Copy Markdown

coveralls commented Nov 17, 2025

Pull Request Test Coverage Report for Build e38babf55c2d6bc027a1405c8548cf4cac30b000

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 3 of 71 (4.23%) changed or added relevant lines in 6 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall first build on 838-backend-create-all-dynamic-tasks at 52.166%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/task-list/application/tasks-collector.php 0 2 0.0%
src/helpers/route-helper.php 0 9 0.0%
src/task-list/domain/tasks/abstract-post-type-task.php 0 10 0.0%
src/task-list/infrastructure/register-post-type-tasks-integration.php 0 17 0.0%
src/task-list/application/tasks/set-search-appearance-templates.php 0 30 0.0%
Totals Coverage Status
Change from base Build 55a8e7b462a870be13d15b732f896e4c55c315a6: 52.2%
Covered Lines: 30982
Relevant Lines: 59572

💛 - Coveralls

@leonidasmi leonidasmi marked this pull request as ready for review November 18, 2025 10:17
Copy link
Copy Markdown
Contributor

@thijsoo thijsoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions.

Comment thread src/integrations/settings-integration.php Outdated
Comment thread src/task-list/application/tasks-collector.php
/**
* Represents the task for setting search appearance templates.
*/
class Set_Search_Appearance_Templates extends Abstract_Post_Type_Task {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thinking that it might make sense to have these in the infrastructure folder since they are super tightly coupled with WP 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was a conscious decision actually, as I would like us to have all tasks gathered in a single layer and not scattered throughout multiple ones.

* @return Post_Type_Task_Interface
*/
public function duplicate_for_post_type( string $post_type ): Post_Type_Task_Interface {
$clone = clone $this;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be misremembering clone but I thought this copied memory pointers so when you do this and set ->duration on one object does this also change it in the other or is that fine 🤔

Copy link
Copy Markdown
Contributor Author

@leonidasmi leonidasmi Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I clone and then I do $clone->set_post_type( $post_type );, but my end results are what I expected 🤔

Not sure if/how I could improve this? I'd be happy to implement a different approach

Comment thread src/task-list/domain/tasks/post-type-task-interface.php
Copy link
Copy Markdown
Contributor

@thijsoo thijsoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CR + ACC 👍

@thijsoo thijsoo merged commit cf9a5eb into feature/task-list Nov 19, 2025
31 of 37 checks passed
@thijsoo thijsoo deleted the 838-backend-create-all-dynamic-tasks branch November 19, 2025 11:04
@leonidasmi leonidasmi mentioned this pull request Nov 27, 2025
18 tasks
@leonidasmi leonidasmi modified the milestones: feature/task-list, 26.6 Dec 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants