PluginProbe
Post Grid Gutenberg Blocks – PostX / 4.0.3
Post Grid Gutenberg Blocks – PostX v4.0.3
5.0.41 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 All 238 releases
ultimate-post / addons / builder / blocks / Post_Title.php

Post_Title.php in Post Grid Gutenberg Blocks – PostX 4.0.3, at addons/builder/blocks/Post_Title.php

63 lines 2.7 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 Post_Title{
7 public function __construct() {
8 add_action('init', array($this, 'register'));
9 }
10 public function get_attributes() {
11
12 return array(
13 'blockId' => '',
14
15 /*============================
16 Post Title Settings
17 ============================*/
18 'titleTag' => 'h1',
19
20 //--------------------------
21 // Advanced Style
22 //--------------------------
23 'advanceId' => '',
24 'advanceZindex' => '',
25 'hideExtraLarge' => false,
26 'hideDesktop' => false,
27 'hideTablet' => false,
28 'hideMobile' => false,
29 'advanceCss' => '',
30 );
31 }
32 public function register() {
33 register_block_type( 'ultimate-post/post-title',
34 array(
35 'editor_script' => 'ultp-blocks-editor-script',
36 'editor_style' => 'ultp-blocks-editor-css',
37 'render_callback' => array($this, 'content')
38 )
39 );
40 }
41 public function content($attr, $noAjax) {
42 $attr = wp_parse_args($attr, $this->get_attributes());
43 $block_name = 'post-title';
44 $wrapper_before = $wrapper_after = $content = '';
45
46 $post_title = get_the_title();
47
48 if ($post_title) {
49 $attr['className'] = isset($attr['className']) && $attr['className'] ? preg_replace('/[^A-Za-z0-9_ -]/', '', $attr['className']) : '';
50 $attr['align'] = isset($attr['align']) && $attr['align'] ? preg_replace('/[^A-Za-z0-9_ -]/', '', $attr['align']) : '';
51 $attr['advanceId'] = isset($attr['advanceId']) ? sanitize_html_class( $attr['advanceId'] ) : '';
52 $attr['blockId'] = isset($attr['blockId']) ? sanitize_html_class( $attr['blockId'] ) : '';
53 $attr['titleTag'] = in_array( $attr['titleTag'], ultimate_post()->ultp_allowed_block_tags() ) ? $attr['titleTag'] : 'h1';
54
55 $wrapper_before .= '<div '.( $attr['advanceId'] ? 'id="'.$attr['advanceId'].'" ':'' ).' class="wp-block-ultimate-post-'.$block_name.' ultp-block-'.$attr["blockId"].( $attr["className"] ?' '.$attr["className"] : '' ).''.( $attr["align"] ? ' align' .$attr["align"] : '' ).'">';
56 $wrapper_before .= '<div class="ultp-block-wrapper">';
57 $content .= '<'.$attr['titleTag'].' class="ultp-builder-title">'.$post_title.'</'.$attr['titleTag'].'>';
58 $wrapper_after .= '</div>';
59 $wrapper_after .= '</div>';
60 }
61 return $wrapper_before.$content.$wrapper_after;
62 }
63 }