Make WordPress Core

Opened 22 months ago

Closed 22 months ago

Last modified 21 months ago

#56796 closed defect (bug) (fixed)

Naming of filters in `class-wp-theme-json-resolver.php` (`theme_json_*`)

Reported by: kebbet's profile kebbet Owned by: hellofromtonya's profile hellofromTonya
Milestone: 6.1 Priority: normal
Severity: normal Version: 6.1
Component: Editor Keywords: has-patch commit
Focuses: Cc:


With 6.1 we are introducing filters for theme.json, all named theme_json_* which results in filters like:

  • theme_json_default
  • theme_json_theme
  • theme_json_blocks
  • theme_json_user
  • theme_json_theme

Are we ok with this?

To me, the naming is a bit odd, espcially theme_json_theme. Could better names for the filter be used?

Change History (15)

#1 @desrosj
22 months ago

  • Milestone changed from Awaiting Review to 6.1

Thanks @kebbet! Moving to 6.1 for consideration. I agree, it seems a bit odd. But also not sure of a better suggestion.

#2 @mukesh27
22 months ago

  • Keywords needs-patch added
  • Milestone changed from 6.1 to Awaiting Review

+1 We are using wp_ prefix for the new filters.

#3 @mukesh27
22 months ago

  • Milestone changed from Awaiting Review to 6.1

#4 @kebbet
22 months ago

Plus theme_json_get_style_nodes in wp-includes/class-wp-theme-json.php and wp-includes/script-loader.php which is about to be introduced in 6.1 aswell.

This ticket was mentioned in Slack in #core by desrosj. View the logs.

22 months ago

This ticket was mentioned in PR #3443 on WordPress/wordpress-develop by kebbet.

22 months ago

  • Keywords has-patch added; needs-patch removed

Adding _data to filter names.

#7 @kebbet
22 months ago

  • Keywords needs-patch added; has-patch removed

The linked PR leaves out theme_json_get_style_nodes from any changes.

#8 @kebbet
22 months ago

  • Keywords has-patch added; needs-patch removed

SergeyBiryukov commented on PR #3443:

22 months ago

Should we consider putting data in the middle, e.g. theme_json_data_default, etc. to closer match WP_Theme_JSON_Data?

Not sure about adding the wp_ prefix, but seems to make sense here too? theme_json_get_style_nodes would then also need the prefix.

hellofromtonya commented on PR #3443:

22 months ago

Test failures are unrelated to this PR and are currently present in trunk.

#11 @hellofromTonya
22 months ago

  • Keywords commit added
  • Owner set to hellofromTonya
  • Status changed from new to reviewing

There's consensus to use the wp_theme_json_data_{$context} naming structure. PR 3443 has been approved by 2 committers. It's ready for commit.

#12 @hellofromTonya
22 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 54501:

Editor: Rename new theme_json_{$context} filters.

The newly introduced filters are renamed to use the wp_theme_json_data{$context} structure:

  • theme_json_default renamed to wp_theme_json_data_default
  • theme_json_theme renamed to wp_theme_json_data_theme
  • theme_json_blocks renamed to wp_theme_json_data_blocks
  • theme_json_user renamed to wp_theme_json_data_user

The following new filter gets the wp_ prefix added:

  • theme_json_get_style_nodes renamed to wp_theme_json_get_style_nodes

Follow-up to [56467], [54183], [54118].

Props kebbet, desrosj, mukesh27, ocean90, sergeybiryukov, davidbaumwald, hellofromTonya.
Fixes #56796.

hellofromtonya commented on PR #3443:

22 months ago

Committed via changeset Thank you everyone for your contributions 🎉

@oandregal commented on PR #3443:

22 months ago

This PR needs a few follow-ups:

  • x [The devnote for 6.1] (it had already been published when this PR was proposed). I've gone ahead and update it.
  • [ ] The documentation for this in the handbook.
  • [ ] The same code in Gutenberg.

I've prepared to address the last two items. Would anyone be available for review?

#15 @SergeyBiryukov
21 months ago

In 54631:

Tests: Correct the wp_theme_json_data_default filter name in assertion messages.

The theme_json_default filter was previously renamed to wp_theme_json_data_default.

This commit updates the messages in WP_Theme_JSON_Resolver tests to match the new name.

Follow-up to [54501], [54630].

See #56796, #56835.

Note: See TracTickets for help on using tickets.