wordpress-seo icon indicating copy to clipboard operation
wordpress-seo copied to clipboard

Decouple Schema hidden fields

Open vraja-pro opened this issue 1 year ago • 0 comments

  • [ ] schema_page_type - SchemaFields - redux/actions/schemaTab.js, /containers/SchemaTab.js
  • [ ] schema_article_type - SchemaFields - redux/actions/schemaTab.js, /containers/SchemaTab.js

Relevant technical choices:

  • I have removed the default value property name for schema_page_type in inc/class-wpseo-meta.php line 422 , all other metadata defs are using default_value and the property is used when getting the value.
  • I have removed the adding of defaults of schema metadata from the fields defs, since it is not used as default in the value itself but is used in the front end. I added the defaults to admin/formatter/class-post-metabox-formatter.php metabox window object and then used it in the store for initial state of the default values. That is used then in the dropdown list of schema types.

Actions

Cleanup reducer, container and component

Initial state

Old side effect files to be removed

Sync files

Fix setting default value for schema fields to match others property

Test instructions:

  • Edit a post

  • Go to schema tab in the metabox or the block editor sidebar

  • Check you see the defaults in brackets

  • Change Page type and Article type and save

  • [ ] Check the values are saved

  • Edit a Page

  • [ ] Check there is no Article type field

  • Change Page type and Article type and save

  • [ ] Check the values are saved

  • [ ] Repeat the steps for elementor

  • Create a custom post type without author support (use Custom Post Type UI plugin)

  • Check schema tab doesn't contain article type.

Test without metabox

  • Comment out line 81 in class-metabox.php:
// add_action( 'add_meta_boxes', [ $this, 'add_meta_box' ] );
  • Edit a post
  • Go to schema tab in the block editor sidebar
  • Change Page type and Article type and save
  • [ ] Check the values are saved
  • Edit a Page
  • [ ] Check there is no Article type field
  • Change Page type and Article type and save
  • [ ] Check the values are saved
  • [ ] Repeat the steps for elementor and check it is saved.

vraja-pro avatar Mar 12 '24 08:03 vraja-pro