Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple primary term second round #21361

Open
wants to merge 35 commits into
base: feature/decouple-hidden-fields
Choose a base branch
from

Conversation

vraja-pro
Copy link
Contributor

@vraja-pro vraja-pro commented May 2, 2024

Context

  • While decoupling the hidden fields from the metabox, we needed to have the show_in_rest as positive when registering the meta. That is done in the wpseo meta class. However, the primary terms meta is not added to the hidden fields from the $meta_fields. I added the primary terms in the init function of the wpseo meta class. After further examination we saw that registering the meta fields is done in a specific time and we want to be more flexable for taxonomies that are being registered in a later stage.

Summary

This PR can be summarized in the following changelog entry:

  • Refactor the way we decouple the primary terms hidden fields and register their metadata.

Relevant technical choices:

  • Registered rest field for all the primary terms, separated from the other meta fields because it is dynamic.
  • In that way we are registering the fields on rest_api_init and we are not limited to the WPSEO meta init method.

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • Make sure you have 2-3 categories for posts
  • Edit a post and select the primary category and save
  • Refresh and check the primary category was saved.
  • Repeat the test with classic editor.

Inspect the the page and look for an input with the id yoast_wpseo_primary_category. Manually change it's value to text, zero, or a negative number and save.
Refresh the page and inspect the page.

  • Check the text value is not there.

Without the metabox

  • Comment out line 81 in class-metabox.php:
// add_action( 'add_meta_boxes', [ $this, 'add_meta_box' ] );
  • Make sure you have 2-3 categories for posts
  • Edit a post and select the primary category and save
  • Refresh and check the primary category was saved.
  • Change focus keyphrase and save, refresh and check it was saved.

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.

QA can test this PR by following these steps:

Impact check

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

UI changes

  • This PR changes the UI in the plugin. I have added the 'UI change' label to this PR.

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 #21223

@vraja-pro vraja-pro added the changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog label May 2, 2024
@vraja-pro vraja-pro linked an issue May 2, 2024 that may be closed by this pull request
5 tasks
Copy link
Member

@igorschoester igorschoester left a comment

Choose a reason for hiding this comment

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

CR 🏗️

Please add the why of things in your PR.
The base is pointing towards your other PR, I think you would want to merge into the feature branch?

src/integrations/watchers/primary-term-watcher.php Outdated Show resolved Hide resolved
src/initializers/primary-term-metadata.php Outdated Show resolved Hide resolved
admin/class-primary-term-admin.php Outdated Show resolved Hide resolved
src/initializers/primary-term-metadata.php Outdated Show resolved Hide resolved
src/initializers/primary-term-metadata.php Outdated Show resolved Hide resolved
@vraja-pro vraja-pro force-pushed the 21141-decouple-hidden-fields-for-metabox branch from f0a950e to ee04d6c Compare May 8, 2024 14:05
@vraja-pro vraja-pro force-pushed the decouple-primary-term-second-round branch 2 times, most recently from 59567de to c8dde6c Compare May 9, 2024 06:47
@vraja-pro vraja-pro force-pushed the decouple-primary-term-second-round branch from e0ddefa to 20e8eeb Compare May 14, 2024 14:59
Base automatically changed from 21141-decouple-hidden-fields-for-metabox to feature/decouple-hidden-fields May 16, 2024 15:11
@vraja-pro vraja-pro self-assigned this May 23, 2024
@coveralls
Copy link

coveralls commented May 23, 2024

Pull Request Test Coverage Report for Build 04df54d03c4cae059a7cff413a64420a715f62b4

Details

  • 44 of 80 (55.0%) changed or added relevant lines in 5 files are covered.
  • 594 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.006%) to 52.776%

Changes Missing Coverage Covered Lines Changed/Added Lines %
admin/class-admin.php 0 1 0.0%
packages/js/src/redux/initial-state/primaryTaxonomies.js 0 2 0.0%
admin/class-primary-term-admin.php 0 4 0.0%
src/initializers/primary-term-metadata.php 44 53 83.02%
packages/js/src/helpers/fields/blockEditorSync.js 0 20 0.0%
Files with Coverage Reduction New Missed Lines %
inc/class-wpseo-meta.php 1 20.58%
packages/js/src/redux/initial-state/primaryTaxonomies.js 1 0.0%
src/generated/container.php 592 0.0%
Totals Coverage Status
Change from base Build 1ed281fdbf6aa9284055b9f436a7f3afde9fc47c: 0.006%
Covered Lines: 28354
Relevant Lines: 54310

💛 - Coveralls

@vraja-pro vraja-pro assigned igorschoester and unassigned vraja-pro May 23, 2024
Copy link
Member

@igorschoester igorschoester left a comment

Choose a reason for hiding this comment

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

CR ✅
AT 🚫

Without the metabox, it does not save anymore

@vraja-pro vraja-pro force-pushed the decouple-primary-term-second-round branch from e0d36f6 to 6fe438c Compare May 27, 2024 13:54
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.

Decouple primary term hidden fields
3 participants