-
Notifications
You must be signed in to change notification settings - Fork 2
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
Feature/moose 66 update post content selector #117
Merged
dpellenwood
merged 14 commits into
main
from
feature/MOOSE-66-update-post-content-selector
Oct 31, 2023
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
83c03c5
Force core paragraph & list blocks to render a default CSS class name.
dpellenwood f4daeaf
Update list block styles to work with new block-specific selector.
dpellenwood b55517a
Remove unnecessary blockquote partial.
dpellenwood 5b811c2
Simplify heading selector.
dpellenwood cbfc33c
Simplify paragraph selector based on new block class name.
dpellenwood 7dbaaa5
Simplify anchor selectors.
dpellenwood 9f05ea0
Remove default focus-visible styles from reset. It's bleeding into th…
dpellenwood 62c8581
Update comment.
dpellenwood 75cdec0
Update remaining instances of `wp-site-blocks`
dpellenwood 442b505
linting.
dpellenwood c394994
update comment.
dpellenwood 3feb167
linting.
dpellenwood c864e9e
Update filter definition to fit existing architecture.
dpellenwood f547f6a
Merge branch 'main' into feature/MOOSE-66-update-post-content-selector
dpellenwood 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 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 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 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
18 changes: 18 additions & 0 deletions
18
wp-content/plugins/core/src/Blocks/Filters/List_Filter.php
This file contains 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,18 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Tribe\Plugin\Blocks\Filters; | ||
|
||
use Tribe\Plugin\Blocks\Filters\Contracts\Block_Content_Filter; | ||
use Tribe\Plugin\Blocks\Filters\Traits\Add_Block_Default_Class_Name; | ||
|
||
class List_Filter extends Block_Content_Filter { | ||
|
||
use Add_Block_Default_Class_Name; | ||
|
||
public const BLOCK = 'core/list'; | ||
|
||
public function filter_block_content( string $block_content, array $parsed_block, object $block ): string { | ||
return $this->add_class_name( $block_content, $parsed_block, $block ); | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
wp-content/plugins/core/src/Blocks/Filters/Paragraph_Filter.php
This file contains 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,18 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Tribe\Plugin\Blocks\Filters; | ||
|
||
use Tribe\Plugin\Blocks\Filters\Contracts\Block_Content_Filter; | ||
use Tribe\Plugin\Blocks\Filters\Traits\Add_Block_Default_Class_Name; | ||
|
||
class Paragraph_Filter extends Block_Content_Filter { | ||
|
||
use Add_Block_Default_Class_Name; | ||
|
||
public const BLOCK = 'core/paragraph'; | ||
|
||
public function filter_block_content( string $block_content, array $parsed_block, object $block ): string { | ||
return $this->add_class_name( $block_content, $parsed_block, $block ); | ||
} | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
wp-content/plugins/core/src/Blocks/Filters/Traits/Add_Block_Default_Class_Name.php
This file contains 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,43 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Tribe\Plugin\Blocks\Filters\Traits; | ||
|
||
trait Add_Block_Default_Class_Name { | ||
|
||
/** | ||
* Ensures there's a `wp-block-<block name>` CSS class rendered for the specific blocks mentioned above. | ||
* | ||
* This filter is a polyfill for core blocks that don't render their own CSS class name. | ||
* Without the class name on the block, CSS styling becomes much more problematic. | ||
* | ||
* Eventually WP Core should handle this for us and we can remove this filter. | ||
* | ||
* Related outstanding issues in Gutenberg: | ||
* * https://github.com/WordPress/gutenberg/pull/42269 | ||
* * https://github.com/WordPress/gutenberg/issues/50486 | ||
* * https://github.com/WordPress/gutenberg/pull/47282 | ||
* | ||
* @param string $block_content Rendered block content. | ||
* @param array $parsed_block The block being rendered. | ||
* @param object $block Block object. | ||
* | ||
* @return string Updated block content. | ||
*/ | ||
public function add_class_name( string $block_content, array $parsed_block, object $block ): string { | ||
if ( ! $block_content ) { | ||
return $block_content; | ||
} | ||
|
||
if ( ! $block->block_type || $block->block_type->is_dynamic() ) { | ||
return $block_content; | ||
} | ||
|
||
$tags = new \WP_HTML_Tag_Processor( $block_content ); | ||
if ( $tags->next_tag() ) { | ||
$tags->add_class( wp_get_block_default_classname( $block->name ) ); | ||
} | ||
|
||
return $tags->get_updated_html(); | ||
} | ||
|
||
} |
This file contains 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 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 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 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 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
14 changes: 0 additions & 14 deletions
14
wp-content/themes/core/assets/pcss/typography/blockquote.pcss
This file was deleted.
Oops, something went wrong.
This file contains 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 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 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 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.
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.
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.
@dpellenwood I'm getting some warnings in postcss when trying to use these styles due to the
ul&
andol&
not having a symbol to start:postcss-nesting: Nested selectors must start with a symbol and "ul&" begins with a letter.
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.
Interesting. I know that this was a later change to the spec, but it is valid now. (The second code example under this heading.) I think your project may not be using the latest version of
postcss-preset-env
or similar. That selector doesn't cause any errors here on Moose.