Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years 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:

Description

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
2 years 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
2 years 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
2 years ago

  • Milestone changed from Awaiting Review to 6.1

#4 @kebbet
2 years 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.


2 years ago

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


2 years ago
#6

  • Keywords has-patch added; needs-patch removed

Adding _data to filter names.
https://core.trac.wordpress.org/ticket/56796

#7 @kebbet
2 years ago

  • Keywords needs-patch added; has-patch removed

The linked PR leaves out theme_json_get_style_nodes from any changes.

#8 @kebbet
2 years ago

  • Keywords has-patch added; needs-patch removed

SergeyBiryukov commented on PR #3443:


2 years ago
#9

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:


2 years ago
#10

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

#11 @hellofromTonya
2 years 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
2 years 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:


2 years ago
#13

Committed via changeset https://core.trac.wordpress.org/changeset/54501. Thank you everyone for your contributions 🎉

@oandregal commented on PR #3443:


2 years ago
#14

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 https://github.com/WordPress/gutenberg/pull/44940 to address the last two items. Would anyone be available for review?

#15 @SergeyBiryukov
2 years 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.