PluginProbe
Post Grid Gutenberg Blocks – PostX / 5.0.19
Post Grid Gutenberg Blocks – PostX v5.0.19
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 / addons / builder / blocks / Post_Content.php

Post_Content.php in Post Grid Gutenberg Blocks – PostX 5.0.19, at addons/builder/blocks/Post_Content.php

77 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_Content {
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 // Advanced Settings
17 // --------------------------
18 'advanceId' => '',
19 'advanceZindex' => '',
20 'hideExtraLarge' => false,
21 'hideDesktop' => false,
22 'hideTablet' => false,
23 'hideMobile' => false,
24 'advanceCss' => '',
25 );
26 }
27
28 public function register() {
29 register_block_type(
30 'ultimate-post/post-content',
31 array(
32 'editor_script' => 'ultp-blocks-editor-script',
33 'editor_style' => 'ultp-blocks-editor-css',
34 'render_callback' => array( $this, 'content' ),
35 )
36 );
37 }
38 public function content( $attr, $noAjax ) {
39 $attr = wp_parse_args( $attr, $this->get_attributes() );
40
41 $post_id = get_the_ID();
42 $block_name = 'post-content';
43 $wrapper_before = $wrapper_after = $content = '';
44 $post_content = get_the_content();
45 $post_type = get_post_type();
46 if ( $post_type != 'ultp_builder' && $post_type != 'revision' && $post_type != 'premade' ) { // premade used for ultp.wpxpo.com
47 $post_content = apply_filters( 'the_content', $post_content );
48 $post_content = str_replace( ']]>', ']]&gt;', $post_content );
49 }
50 if ( $post_content ) {
51
52 $attr['className'] = isset( $attr['className'] ) && $attr['className'] ? preg_replace( '/[^A-Za-z0-9_ -]/', '', $attr['className'] ) : '';
53 $attr['align'] = isset( $attr['align'] ) && $attr['align'] ? preg_replace( '/[^A-Za-z0-9_ -]/', '', $attr['align'] ) : '';
54 $attr['advanceId'] = isset( $attr['advanceId'] ) ? sanitize_html_class( $attr['advanceId'] ) : '';
55 $attr['blockId'] = isset( $attr['blockId'] ) ? sanitize_html_class( $attr['blockId'] ) : '';
56
57 // from v.2.9.7 for Loading Post Content Css
58 do_action(
59 'ultp_enqueue_postx_block_css',
60 array(
61 'post_id' => $post_id,
62 'css' => '',
63 )
64 );
65
66 $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'] : '' ) . '">';
67 $wrapper_before .= '<div class="ultp-block-wrapper">';
68 $content .= '<div class="ultp-builder-content" data-postid="' . $post_id . '">';
69 $content .= $post_content;
70 $content .= '</div>';
71 $wrapper_after .= '</div>';
72 $wrapper_after .= '</div>';
73 }
74 return $wrapper_before . $content . $wrapper_after;
75 }
76 }
77