PluginProbe
Post Grid Gutenberg Blocks – PostX / 5.0.31
Post Grid Gutenberg Blocks – PostX v5.0.31
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 / Heading.php

Heading.php in Post Grid Gutenberg Blocks – PostX 5.0.31, at blocks/Heading.php

70 lines 2.3 KB
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 Heading {
7
8 public function __construct() {
9 add_action( 'init', array( $this, 'register' ) );
10 }
11
12 public function get_attributes() {
13
14 return array(
15 'blockId' => '',
16 // Heading Setting/Style
17 'headingText' => 'This is a Heading Example',
18 'headingURL' => '',
19 'openInTab' => false,
20 'headingBtnText' => 'View More',
21 'headingStyle' => 'style9',
22 'headingTag' => 'h2',
23 'headingAlign' => 'left',
24 'subHeadingShow' => false,
25 'subHeadingText' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ut sem augue. Sed at felis ut enim dignissim sodales.',
26
27 // Custom Meta Support
28
29 // Wrapper Style
30 'advanceId' => '',
31 'advanceZindex' => '',
32 'hideExtraLarge' => false,
33 'hideTablet' => false,
34 'hideMobile' => false,
35 'advanceCss' => '',
36 );
37 }
38
39 public function register() {
40 register_block_type(
41 'ultimate-post/heading',
42 array(
43 'editor_script' => 'ultp-blocks-editor-script',
44 'editor_style' => 'ultp-blocks-editor-css',
45 'render_callback' => array( $this, 'content' ),
46 )
47 );
48 }
49
50 public function content( $attr, $noAjax ) {
51 $attr = wp_parse_args( $attr, $this->get_attributes() );
52
53 $wraper_before = '';
54 $block_name = 'heading';
55 $attr['headingShow'] = true;
56 $attr['className'] = isset( $attr['className'] ) && $attr['className'] ? preg_replace( '/[^A-Za-z0-9_ -]/', '', $attr['className'] ) : '';
57 $attr['align'] = isset( $attr['align'] ) && $attr['align'] ? preg_replace( '/[^A-Za-z0-9_ -]/', '', $attr['align'] ) : '';
58 $attr['advanceId'] = isset( $attr['advanceId'] ) ? sanitize_html_class( $attr['advanceId'] ) : '';
59 $attr['blockId'] = isset( $attr['blockId'] ) ? sanitize_html_class( $attr['blockId'] ) : '';
60
61 $wraper_before .= '<div ' . ( $attr['advanceId'] ? 'id="' . $attr['advanceId'] . '" ' : '' ) . ' class="wp-block-ultimate-post-' . $block_name . ' ultp-block-' . $attr['blockId'] . '' . ( $attr['align'] ? ' align' . $attr['align'] : '' ) . '' . ( $attr['className'] ? ' ' . $attr['className'] : '' ) . '">';
62 $wraper_before .= '<div class="ultp-block-wrapper">';
63 include ULTP_PATH . 'blocks/template/heading.php';
64 $wraper_before .= '</div>';
65 $wraper_before .= '</div>';
66
67 return $wraper_before;
68 }
69 }
70