Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
CRAP | n/a |
0 / 0 |
|
| Automattic\Jetpack\Jetpack_Mu_Wpcom\Wpcom_Legacy_FSE\render_post_content_block | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
30 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Render post content block file. |
| 4 | * |
| 5 | * @package automattic/jetpack-mu-wpcom |
| 6 | */ |
| 7 | |
| 8 | namespace Automattic\Jetpack\Jetpack_Mu_Wpcom\Wpcom_Legacy_FSE; |
| 9 | |
| 10 | use Automattic\Jetpack\Jetpack_Mu_Wpcom\Common; |
| 11 | |
| 12 | /** |
| 13 | * Renders post content. |
| 14 | * |
| 15 | * @param array $attributes Block attributes. |
| 16 | * @param string $content Block content. |
| 17 | * @return string |
| 18 | */ |
| 19 | function render_post_content_block( $attributes, $content ) { |
| 20 | // Early return to avoid infinite loops in the REST API. |
| 21 | if ( is_admin() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) ) { |
| 22 | return $content; |
| 23 | } |
| 24 | |
| 25 | Common\wpcom_record_tracks_event( 'wpcom_legacy_fse_render_block', array( 'block_name' => 'a8c/post-content' ) ); |
| 26 | |
| 27 | $align = isset( $attributes['align'] ) ? ' align' . $attributes['align'] : ''; |
| 28 | |
| 29 | ob_start(); |
| 30 | ?> |
| 31 | |
| 32 | <div class="post-content<?php echo esc_attr( $align ); ?>"> |
| 33 | <?php |
| 34 | // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 35 | echo apply_filters( 'the_content', get_the_content() ); |
| 36 | ?> |
| 37 | </div><!-- .post-content --> |
| 38 | |
| 39 | <?php |
| 40 | $content = ob_get_clean(); |
| 41 | |
| 42 | return $content; |
| 43 | } |