Repository navigation
Shadow: Add a PHP helper for block support classes and styles #84205
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
Merged
aaronrobertshaw
merged 12 commits into
trunk
from
update/shadow-classes-and-styles-php-helper
Nov 4, 2026
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
cc99845
Shadow: Add a PHP helper for block support classes and styles
aaronrobertshaw d03718c
Address review feedback
aaronrobertshaw 78784f1
Add backport changelog entry
aaronrobertshaw f1e43d1
Expect trunk's minimum width and height in the Post Navigation Link s…
aaronrobertshaw 59bbed0
Migrate Search and Icon to the shadow helper and trim the tests
aaronrobertshaw b6775d4
Move the shadow helper to WordPress 7.3
aaronrobertshaw a2d3d66
Keep trunk's shadow handling in Icon and Post Navigation Link
aaronrobertshaw da37ce2
Return early when shadow helper attributes are not an array
aaronrobertshaw 4b9ff49
PHPStan: Baseline the shadow helper until Core has it
aaronrobertshaw bc651f0
PHPStan: Generate the WordPress stubs from the core backport
westonruter 7679fd5
Revert the WordPress stubs pin to Core PR 14094
aaronrobertshaw 1a3c0e7
PHPStan: Ignore the missing wp_get_shadow_classes_and_styles() functi…
aaronrobertshaw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| https://github.com/WordPress/wordpress-develop/pull/14094 | ||
|
|
||
| * https://github.com/WordPress/gutenberg/pull/84205 | ||
| * https://github.com/WordPress/gutenberg/pull/84206 | ||
| * https://github.com/WordPress/gutenberg/pull/84207 | ||
| * https://github.com/WordPress/gutenberg/pull/84208 | ||
| * https://github.com/WordPress/gutenberg/pull/84209 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| <?php | ||
| /** | ||
| * Avatar block rendering tests. | ||
| * | ||
| * @package WordPress | ||
| * @subpackage Blocks | ||
| */ | ||
|
|
||
| /** | ||
| * Tests for the Avatar block. | ||
| * | ||
| * @group blocks | ||
| * | ||
| * @covers ::gutenberg_render_block_core_avatar | ||
| */ | ||
| class Render_Block_Avatar_Test extends WP_UnitTestCase { | ||
|
|
||
| /** | ||
| * @var int | ||
| */ | ||
| private static $user_id; | ||
|
|
||
| public static function wpSetUpBeforeClass( $factory ) { | ||
| self::$user_id = $factory->user->create( array( 'display_name' => 'Avatar Author' ) ); | ||
| } | ||
|
|
||
| /** | ||
| * Renders an Avatar block and returns the image's class and style attributes. | ||
| * | ||
| * @param array $style Style attribute. | ||
| * @return array Class and style of the image. | ||
| */ | ||
| private function render_image_attributes( $style ) { | ||
| $block = new WP_Block( | ||
| array( | ||
| 'blockName' => 'core/avatar', | ||
| 'attrs' => array( | ||
| 'userId' => self::$user_id, | ||
| 'style' => $style, | ||
| ), | ||
| ) | ||
| ); | ||
|
|
||
| $processor = new WP_HTML_Tag_Processor( $block->render() ); | ||
| $this->assertTrue( $processor->next_tag( 'img' ) ); | ||
|
|
||
| return array( | ||
| 'class' => $processor->get_attribute( 'class' ), | ||
| 'style' => $processor->get_attribute( 'style' ), | ||
| ); | ||
| } | ||
|
|
||
| public function test_shadow_follows_border_on_the_image() { | ||
| $actual = $this->render_image_attributes( | ||
| array( | ||
| 'border' => array( | ||
| 'radius' => '10px', | ||
| 'color' => '#ff0000', | ||
| ), | ||
| 'shadow' => '1px 1px 1px #000', | ||
| ) | ||
| ); | ||
|
|
||
| $this->assertSame( 'avatar avatar-96 photo wp-block-avatar__image has-border-color', $actual['class'] ); | ||
| $this->assertSame( 'border-color:#ff0000;border-radius:10px;box-shadow:1px 1px 1px #000;', $actual['style'] ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.