| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Server-side rendering of the `core/paragraph` block. 4 * 5 * @package WordPress 6 */ 7 8 /** 9 * Append the `wp-block-paragraph` class before rendering the stored 10 * `core/paragraph` block contents. 11 * 12 * For example, the following block content: 13 * <p class="align-left">Hello World</p> 14 * 15 * Would be transformed to: 16 * <p class="align-left wp-block-paragraph">Hello World</p> 17 * 18 * @since 7.0.0 19 * 20 * @param string $block_content The block content. 21 * 22 * @return string Filtered block content. 23 */ 24 function block_core_paragraph_add_class( $block_content ) { 25 if ( ! $block_content ) { 26 return $block_content; 27 } 28 29 $processor = new WP_HTML_Tag_Processor( $block_content ); 30 31 if ( $processor->next_tag( 'p' ) ) { 32 $processor->add_class( 'wp-block-paragraph' ); 33 } 34 35 return $processor->get_updated_html(); 36 } 37 38 add_filter( 'render_block_core/paragraph', 'block_core_paragraph_add_class' ); 39 40 /** 41 * Registers the `core/paragraph` block on server. 42 * 43 * @since 7.0.0 44 */ 45 function register_block_core_paragraph() { 46 register_block_type_from_metadata( __DIR__ . '/paragraph' ); 47 } 48 add_action( 'init', 'register_block_core_paragraph' );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Sun Jun 14 08:20:09 2026 | Cross-referenced by PHPXref |