-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 PHP parts of sticky position block support #3973
Backport PHP parts of sticky position block support #3973
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andrewserong Looks almost good to go, after reviewing this and cross-checking the relevant already approved/merged Gutenberg PRs.
Does this have to wait for the JS package update, or can it be committed to core before already?
Thanks for reviewing @felixarntz!
This can be committed before the JS package update, since this PR doesn't opt any of the blocks into the new control, so it doesn't expose anything to a user. I think it's preferable to land this PR first, so that when the JS packages update happens, the PHP parts will already be in place. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @andrewserong, Left nit-pick feedback and questions.
* | ||
* @param string $block_content Rendered block content. | ||
* @param array $block Block object. | ||
* @return string Filtered block content. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @return string Filtered block content. | |
* @return string Filtered block content. |
Per PHP Documentation Standards no needs to add spaces for return doc.
/* | ||
* Add to the style engine store to enqueue and render position styles. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/* | |
* Add to the style engine store to enqueue and render position styles. | |
*/ | |
// Add to the style engine store to enqueue and render position styles. |
Use a single-line comment instead of a multiline comment for single-line documents.
$this->theme_root = realpath( DIR_TESTDATA . '/themedir1' ); | ||
$this->orig_theme_dir = $GLOBALS['wp_theme_directories']; | ||
|
||
// /themes is necessary as theme.php functions assume /themes is the root if there is only one root. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// /themes is necessary as theme.php functions assume /themes is the root if there is only one root. | |
// '/themes' is necessary as theme.php functions assume '/themes' is the root if there is only one root. |
|
||
if ( | ||
! $has_position_support || | ||
empty( $block['attrs']['style']['position'] ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of empty
shell we use isset
? What do you think?
if ( true === $theme_has_sticky_support ) { | ||
$allowed_position_types[] = 'sticky'; | ||
} | ||
if ( true === $theme_has_fixed_support ) { | ||
$allowed_position_types[] = 'fixed'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we needs to bail early if the position is not sticky
or fixed
?
Merged into core in https://core.trac.wordpress.org/changeset/55285. |
This PR backports the PHP parts of the new sticky position block support, and is a follow-on from #3865
Backports the PHP parts of the following PRs:
Notes on this backport:
fixed
position type is excluded from the appearance tools opt-in: this is because fixed positioning isn't being opted-in for the Group block and isn't ready to be used as a default opt-in. The code paths exist forfixed
positioning as it will be supported in the future, but for now,sticky
is the only one exposed by default. (The overall block support should still support it as a valid value, though)Screenshots:
Testing instructions:
block.json
file add a"position": { "sticky": true }
object under"supports"
(Note: for this change to propagate in your testing, you might need to rebuild the block JSON cache locally).Group block markup for testing purposes:
Trac ticket: https://core.trac.wordpress.org/ticket/57618
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.