| 1 |
<?php |
| 2 |
$prefix = 'bBlocksPosts'; |
| 3 |
$id = wp_unique_id( "$prefix-" ); |
| 4 |
$planClass = BBlocks\Inc\Utils::isPro() ? 'pro' : 'free'; |
| 5 |
|
| 6 |
use BBlocks\Inc\Posts\Posts as Posts; |
| 7 |
|
| 8 |
extract( $attributes ); |
| 9 |
|
| 10 |
if( 'ticker' === $layout ){ |
| 11 |
wp_enqueue_script( 'easyTicker' ); |
| 12 |
} |
| 13 |
|
| 14 |
$allPosts = get_posts( array_merge( Posts::query( $attributes ), [ 'posts_per_page' => -1 ] ) ); |
| 15 |
|
| 16 |
$skeletonAllowedTags = [ |
| 17 |
'style' => [], |
| 18 |
'div' => [ 'class' => [], 'id' => [] ], |
| 19 |
'article' => [ 'class' => [] ], |
| 20 |
'span' => [ 'class' => [] ], |
| 21 |
]; |
| 22 |
?> |
| 23 |
<div |
| 24 |
<?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- get_block_wrapper_attributes() is properly escaped ?> |
| 25 |
<?php echo get_block_wrapper_attributes( [ 'class' => "$planClass align$align" ] ); ?> |
| 26 |
id='<?php echo esc_attr( $id ); ?>' |
| 27 |
data-nonce='<?php echo esc_attr( wp_json_encode( wp_create_nonce( 'wp_ajax' ) ) ); ?>' |
| 28 |
data-attributes='<?php echo esc_attr( wp_json_encode( $attributes ) ); ?>' |
| 29 |
data-extra='<?php echo esc_attr( wp_json_encode( [ 'totalPosts' => count( $allPosts ) ] ) ); ?>' |
| 30 |
> |
| 31 |
<pre id='firstPosts' style='display: none;'> |
| 32 |
<?php echo esc_html( wp_json_encode( Posts::getPosts( $attributes ) ) ) ?> |
| 33 |
</pre> |
| 34 |
|
| 35 |
<?php echo wp_kses( Posts::loadingPlaceholder( $attributes, $prefix ), $skeletonAllowedTags ); ?> |
| 36 |
</div> |