PluginProbe
Post Grid Gutenberg Blocks – PostX / 4.1.21
Post Grid Gutenberg Blocks – PostX v4.1.21
5.0.39 5.0.38 5.0.37 5.0.36 5.0.35 5.0.34 5.0.33 5.0.32 5.0.31 5.0.30 5.0.29 5.0.28 5.0.27 5.0.26 5.0.25 5.0.23 5.0.24 5.0.22 5.0.21 5.0.20 5.0.19 5.0.18 5.0.17 2.1.1 2.1.2 All 237 releases
ultimate-post / blocks / Button.php

Button.php in Post Grid Gutenberg Blocks – PostX 4.1.21, at blocks/Button.php

39 lines 935 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ULTP\blocks;
3
4 defined( 'ABSPATH' ) || exit;
5
6 class Button {
7 public function __construct() {
8 add_action( 'init', array( $this, 'register' ) );
9 }
10
11 public function register() {
12 register_block_type(
13 'ultimate-post/button',
14 array(
15 'render_callback' => array( $this, 'render' ),
16 )
17 );
18 }
19
20 public function render( $attr, $content ) {
21
22 if ( ultimate_post()->is_dc_active( $attr ) && isset( $attr['dc'] ) ) {
23
24 [ $text, $url ] = \ULTP\DCService::get_dc_content_for_rich_text( $attr );
25
26 // Replacing URL with dynamic content
27 if ( ! empty( $url ) ) {
28 $pattern = '/href="([^"]*)"/';
29 $replacement = 'href="' . esc_url( $url ) . '"';
30 $content = preg_replace( $pattern, $replacement, $content );
31 }
32
33 $content = \ULTP\DCService::replace( $content, wp_kses( $text, ultimate_post()->ultp_allowed_html_tags() ) );
34 }
35
36 return $content;
37 }
38 }
39