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

Backport: Duotone changes #4619

Closed
wants to merge 47 commits into from

Conversation

MaggieCabrera
Copy link

@MaggieCabrera MaggieCabrera commented Jun 15, 2023

This PR backports the changes made to the duotone related PHP files. I grouped them together instead of having one PR for each change because they would all depend on each other, which made more sense. This PR depends on the stabilized selectors API to be backported for the changes to work.

Trac ticket: https://core.trac.wordpress.org/ticket/58555
Backports:


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@ajlende
Copy link

ajlende commented Jun 15, 2023

Some of the duotone code depends on WordPress/gutenberg#46496 getting backported first.

@tellthemachines
Copy link
Contributor

@MaggieCabrera is there a Trac ticket for these changes? If not, we'll need to create one and add it in the PR description.

@MaggieCabrera
Copy link
Author

@MaggieCabrera is there a Trac ticket for these changes? If not, we'll need to create one and add it in the PR description.

No, I was planning on doing that today

Copy link
Contributor

@audrasjb audrasjb left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!
I left some comments concerning this changeset :)

src/wp-includes/block-supports/duotone.php Outdated Show resolved Hide resolved
src/wp-includes/class-wp-duotone.php Outdated Show resolved Hide resolved
src/wp-includes/class-wp-duotone.php Outdated Show resolved Hide resolved
src/wp-includes/class-wp-duotone.php Outdated Show resolved Hide resolved
src/wp-includes/class-wp-duotone.php Show resolved Hide resolved
@ramonjd
Copy link
Member

ramonjd commented Jun 21, 2023

Some of the duotone code depends on WordPress/gutenberg#46496 getting backported first.

Backport PR that includes #4619 over here:

It also includes changes from WordPress/gutenberg#49427

ramonjd added a commit to ramonjd/wordpress-develop that referenced this pull request Jun 21, 2023
Reverting changes to Tests_Theme_wpThemeJson that will need to be reinstated after WordPress#4619 merges
ramonjd added a commit to ramonjd/wordpress-develop that referenced this pull request Jun 22, 2023
Reverting changes to Tests_Theme_wpThemeJson that will need to be reinstated after WordPress#4619 merges
@ramonjd
Copy link
Member

ramonjd commented Jun 23, 2023

Would this PR also need backporting for duotone to work?

cc @ajlende

Copy link
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

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

I've added a few notes relating to the docblocks and locations.

I've used 🔢 to indicate that the item applies in multiple locations.

tests/phpunit/tests/block-supports/duotone.php Outdated Show resolved Hide resolved
'register_attribute' => array( 'WP_Duotone', 'register_duotone_support' ),
)
);

Copy link
Contributor

Choose a reason for hiding this comment

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

This block ought to be in the default-filters file.

Copy link

Choose a reason for hiding this comment

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

All of the other block supports (layout and position) have their hooks co-located with the support registration in block-supports. Should those be moved too? Or is it okay having these here?

Copy link
Contributor

Choose a reason for hiding this comment

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

@ajlende let's leave it as is for now (including in this PR). They probably all should be in default-filters but probably a discussion for another time.

src/wp-includes/block-supports/duotone.php Outdated Show resolved Hide resolved
src/wp-includes/class-wp-duotone.php Outdated Show resolved Hide resolved
src/wp-includes/class-wp-duotone.php Outdated Show resolved Hide resolved
src/wp-includes/class-wp-duotone.php Outdated Show resolved Hide resolved
src/wp-includes/class-wp-duotone.php Outdated Show resolved Hide resolved
src/wp-includes/class-wp-duotone.php Outdated Show resolved Hide resolved
Comment on lines 1022 to 1133
* Migrate the old experimental duotone support flag to its stabilized location
* under `supports.filter.duotone` and sets.
Copy link
Contributor

Choose a reason for hiding this comment

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

Again this needs to be split in to a summary and longer description/

When the developer docs are generated the first line is a short summary displayed below the title, followed by a longer description that goes in to detail. See https://developer.wordpress.org/reference/classes/wp_query/get_posts/ fpr example.

🔢 This chnage is needed in numerous places so I'll get you to reeveluate them rather than continue adding noise to the PR

Copy link
Author

Choose a reason for hiding this comment

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

@ajlende can you help with this one?

Copy link

Choose a reason for hiding this comment

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

Updated in 0b06740.

ramonjd added a commit to ramonjd/wordpress-develop that referenced this pull request Jun 25, 2023
Reverting changes to Tests_Theme_wpThemeJson that will need to be reinstated after WordPress#4619 merges
ramonjd added a commit to ramonjd/wordpress-develop that referenced this pull request Jun 26, 2023
Reverting changes to Tests_Theme_wpThemeJson that will need to be reinstated after WordPress#4619 merges
@MaggieCabrera
Copy link
Author

Would this PR also need backporting for duotone to work?

* [Fix custom duotone filters in frontend gutenberg#50678](https://github.com/WordPress/gutenberg/pull/50678)

cc @ajlende

Apparently that was already ported to core here

@ajlende ajlende force-pushed the duotone-backports branch 2 times, most recently from 9f04e3c to 15c4d35 Compare June 26, 2023 17:55
@ajlende
Copy link

ajlende commented Jun 26, 2023

@peterwilsoncc All of the public methods are to be used exclusively with the hooks that we have defined. The other block supports have @access private added to their hooks—can that be used for public methods on the WP_Duotone class or should the whole class be marked private somehow?

Copy link
Member

@ramonjd ramonjd left a comment

Choose a reason for hiding this comment

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

I've tested this manually on top of:

Functionality-wise things are working well for me.

I think it'll just need a final comb from a core committer?

* @param string $slug The slug of the duotone preset.
* @return string The CSS variable.
*/
private static function get_css_var( $slug ) {
Copy link
Member

Choose a reason for hiding this comment

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

Do all these new methods require

@since 6.3.0

?

Copy link

Choose a reason for hiding this comment

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

Fixed in 817b916

@@ -143,8 +143,8 @@ class WP_Theme_JSON {
'path' => array( 'color', 'duotone' ),
'prevent_override' => array( 'color', 'defaultDuotone' ),
'use_default_names' => false,
'value_func' => 'wp_get_duotone_filter_property',
'css_vars' => '--wp--preset--duotone--$slug',
'value_func' => null, // CSS Custom Properties for duotone are handled by block supports in class-wp-duotone.php.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested annotation for docblock

* @since 6.3.0 Replaced value_func for duoone with null. Custom properties are handled by class-wp-duotone.php.

Copy link

Choose a reason for hiding this comment

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

Fixed in 3265f93

@ramonjd
Copy link
Member

ramonjd commented Jun 27, 2023

Hmm some of the failing tests are real though.

I'm seeing -wp--preset--duotone--custom-duotone: url('#wp-duotone-custom-duotone'); not being output in Tests_Theme_wpThemeJson::test_get_stylesheet

🤷

I guess we can rerun and debug when and if #4655 is committed and this PR rebased (?)

tellthemachines pushed a commit to ramonjd/wordpress-develop that referenced this pull request Jun 27, 2023
Reverting changes to Tests_Theme_wpThemeJson that will need to be reinstated after WordPress#4619 merges
@MaggieCabrera
Copy link
Author

I just rebased this after #4655 got merged

@getsource
Copy link
Member

This may be something you're already checking into, but in case it helps -- it looks like a few of the test failures may be PHPUnit tests that need to be updated:
https://github.com/WordPress/wordpress-develop/actions/runs/5387774760/jobs/9779547969#step:17:328

@ajlende
Copy link

ajlende commented Jun 27, 2023

Alright, I think the remaining failing tests are unrelated to these changes, and all the feedback has been addressed. I've also tested it now that it's been rebased with the selectors API changes. So this should be ready to go except for confirming one thing:

The other block supports have @access private added to their hooks—can that be used for public methods on the WP_Duotone class or should the whole class be marked private somehow?

I added @access private to the whole class. I hope that keeps docs from being generated for developer.wordpress.org. The documentation on docblock tags isn't clear about what prevents docs from being generated.

@peterwilsoncc
Copy link
Contributor

I added @access private to the whole class. I hope that keeps docs from being generated for developer.wordpress.org. The documentation on docblock tags isn't clear about what prevents docs from being generated.

@ajlende Items with @access private have posts generated on the developer docs, see _cleanup_image_add_caption() as an example (chosen at random).

Sorry, I'm unclear of the context for this #4619 (comment), would you be able to clarify?

MaggieCabrera and others added 24 commits June 29, 2023 11:23
Copy link
Contributor

@tellthemachines tellthemachines left a comment

Choose a reason for hiding this comment

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

LGTM! Duotone filters working well in editor and front end.

@tellthemachines
Copy link
Contributor

committed in r56101 / d966798.

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

Successfully merging this pull request may close these issues.

7 participants