| 1 |
<?php |
| 2 |
extract( $attributes ); |
| 3 |
|
| 4 |
$id = wp_unique_id( 'bBlocksButton-' ); |
| 5 |
$planClass = BBlocks\Inc\Utils::isPro() ? 'pro' : 'free'; |
| 6 |
|
| 7 |
$popup = $popup ?? [ 'type' => 'image', 'content' => '', 'caption' => '' ]; |
| 8 |
if ( 'content' === $popup['type'] ) { |
| 9 |
$blocks = parse_blocks( $popup['content'] ); |
| 10 |
$popup['content'] = ''; |
| 11 |
foreach ( $blocks as $block ) { |
| 12 |
$popup['content'] .= render_block( $block ); |
| 13 |
} |
| 14 |
} // Convert the blocks to dom elements |
| 15 |
?> |
| 16 |
<div |
| 17 |
<?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- get_block_wrapper_attributes() is properly escaped ?> |
| 18 |
<?php echo get_block_wrapper_attributes( [ 'class' => $planClass ] ); ?> |
| 19 |
id='<?php echo esc_attr( $id ); ?>' |
| 20 |
data-nonce='<?php echo esc_attr( wp_json_encode( wp_create_nonce( 'wp_ajax' ) ) ); ?>' |
| 21 |
data-attributes='<?php echo esc_attr( wp_json_encode( $attributes ) ); ?>' |
| 22 |
data-info='<?php echo esc_attr( wp_json_encode( [ |
| 23 |
'currentPostId' => get_the_ID(), |
| 24 |
'userRoles' => is_user_logged_in() ? wp_get_current_user()->roles : [], |
| 25 |
'loginURL' => wp_login_url() |
| 26 |
] ) ); ?>' |
| 27 |
></div> |