-
Notifications
You must be signed in to change notification settings - Fork 37
Notice block: Migrate to use inner blocks #719
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
base: trunk
Are you sure you want to change the base?
Conversation
0ae020a to
dc0a6a9
Compare
ryelle
left a comment
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 for tackling this! It's working well for blocks created in the editor, but another use of this block is server-side - replacing the callout shortcodes & block. Could you check that as well?
An example you could look at is the PHP Inline Docs page (see the shortcodes in the markdown content).
The block markup is generated here:
wporg-mu-plugins/mu-plugins/blocks/notice/index.php
Lines 48 to 71 in 433e9cc
| /** | |
| * Generates and processes block markup for a notice. | |
| * | |
| * @param string $type The notice type. | |
| * @param string $content The content to insert into the block. | |
| * @return string The processed block markup. | |
| */ | |
| function generate_notice_block_markup( $type, $content ) { | |
| // Create a unique placeholder for the content. | |
| // Directly processing `$content` with `do_blocks` can lead to buggy layouts on make.wp.org. | |
| // See https://github.com/WordPress/wporg-mu-plugins/pull/337#issuecomment-1819992059. | |
| $placeholder = '<!-- CONTENT_PLACEHOLDER -->'; | |
| $block_markup = <<<EOT | |
| <!-- wp:wporg/notice {"type":"$type"} --> | |
| <div class="wp-block-wporg-notice is-{$type}-notice"> | |
| <div class="wp-block-wporg-notice__icon"></div> | |
| <div class="wp-block-wporg-notice__content">$placeholder</div></div> | |
| <!-- /wp:wporg/notice --> | |
| EOT; | |
| $processed_markup = do_blocks( $block_markup ); | |
| return str_replace( $placeholder, $content, $processed_markup ); | |
| } |
| "example": { | ||
| "attributes": { | ||
| "type": "alert", | ||
| "type": "alert", | ||
| "content": "<p>This is an alert notice.</p>" | ||
| } | ||
| } | ||
| }, |
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.
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.
Fixed in 7202287
|
@ryelle Thanks for the review!
This works just as it did before. ShortcodeEditor
<!-- wp:shortcode -->
[info]Testing info message[/info]
<!-- /wp:shortcode -->
<!-- wp:shortcode -->
[tip]Testing tip message[/tip]
<!-- /wp:shortcode -->Frontend
BlockEditor<!-- wp:wporg/callout -->
<div class="callout callout-info">
<!-- wp:paragraph -->
<p>Paragraph Block</p>
<!-- /wp:paragraph -->
<!-- wp:list -->
<ul class="wp-block-list">
<!-- wp:list-item -->
<li>List Item Block</li>
<!-- /wp:list-item -->
<!-- wp:list-item -->
<li>List Item Block</li>
<!-- /wp:list-item -->
</ul>
<!-- /wp:list -->
<!-- wp:paragraph -->
<p>Paragraph Block</p>
<!-- /wp:paragraph -->
</div>
<!-- /wp:wporg/callout -->Frontend
|




The
multilineprop of the RichText` component is deprecated. As a result, the following warning will be displayed in the browser console:To avoid this, migrate from the RichText component to Inner Blocks.
Testing Instructions
Updated Block: wporg/noticein your browser console.