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

Closed
4 of 5 tasks
Tracked by #21141
vraja-pro opened this issue Mar 12, 2024 · 1 comment · May be fixed by #21361
Closed
4 of 5 tasks
Tracked by #21141

Decouple primary term hidden fields #21223

vraja-pro opened this issue Mar 12, 2024 · 1 comment · May be fixed by #21361
Assignees

Comments

@vraja-pro
Copy link
Contributor

vraja-pro commented Mar 12, 2024

Primary category

Saved in post meta data as: _yoast_wpseo_primary_{taxonomy-name}

  • Register post meta for all taxonomies (class-wpseo-meta.php)
  • Add primary_{taxonomy_name} values to ScriptData under metaData property (class-post-metabox-formator.php)
  • Use MetaboxFieldSync onChange in packages/js/src/components/PrimaryTaxonomyPicker.js
  • Fix the way we get primary category in packages/js/src/initializers/primary-category.js
  • primary_{taxonomy}

Reducer

Initializer

Update event listener

Components

Initial state

Register metadata

Tests

Test instuctions

  • 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.
@igorschoester
Copy link
Member

Works!! 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants