PluginProbe
Button Block – Stylish buttons that get more clicks / trunk
Button Block – Stylish buttons that get more clicks vtrunk
1.2.6 1.2.5 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 All 28 releases
button-block / build / render.php

render.php in Button Block – Stylish buttons that get more clicks trunk, at build/render.php

40 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( !defined( 'ABSPATH' ) ) { exit; }
3
4 $btnbId = wp_unique_id( 'btnButton-' );
5
6 // Extract attributes with defaults
7 $btnbIcon = isset( $attributes['icon'] ) ? (array) $attributes['icon'] : [];
8 $btnbAnimationType = isset( $attributes['animationType'] ) ? sanitize_text_field( $attributes['animationType'] ) : '';
9 $btnbUrl = isset( $attributes['url'] ) ? esc_url_raw( $attributes['url'] ) : '';
10 $btnbPopup = isset( $attributes['popup'] ) ? (array) $attributes['popup'] : [ 'type' => 'image', 'content' => '', 'caption' => '' ];
11
12 if( isset( $btnbIcon['class'] ) && !empty( $btnbIcon['class'] ) ){
13 wp_enqueue_style( 'font-awesome-7' );
14 }
15 if( !empty( $btnbAnimationType ) ){
16 wp_enqueue_script( 'aos' );
17 wp_enqueue_style( 'aos' );
18 }
19
20 $attributes['url'] = esc_url( $btnbUrl );
21 if ( 'content' === $btnbPopup['type'] ) {
22 $btnbContentBlocks = parse_blocks( $btnbPopup['content'] ?? '' );
23 $btnbPopup['content'] = '';
24 foreach ( $btnbContentBlocks as $btnbContentBlock ) {
25 $btnbPopup['content'] .= render_block( $btnbContentBlock );
26 }
27 } // Convert the blocks to dom elements
28 ?>
29 <div
30 <?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- get_block_wrapper_attributes() is properly escaped ?>
31 <?php echo get_block_wrapper_attributes(); ?>
32 id='<?php echo esc_attr( $btnbId ); ?>'
33 <?php
34 $btnbAttributes = $attributes;
35 if ( isset( $btnbAttributes['securityPassword'] ) ) {
36 unset( $btnbAttributes['securityPassword'] );
37 }
38 ?>
39 data-attributes='<?php echo esc_attr( wp_json_encode( $btnbAttributes ?? [] ) ); ?>'
40 ></div>