# ultimate-post/5.0.41/addons/builder/blocks/Post_Content.php

Post Grid Gutenberg Blocks – PostX, version 5.0.41. 77 lines.

- Page: https://pluginprobe.com/plugins/ultimate-post/5.0.41/code/addons/builder/blocks/Post_Content.php
- Raw: https://pluginprobe.com/plugins/ultimate-post/5.0.41/raw/addons/builder/blocks/Post_Content.php
- Modified: 2026-09-16T12:17:26+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/ultimate-post/5.0.41/code/addons/builder/blocks/Post_Content.php#L10-L20`.

```php
<?php
namespace ULTP\blocks;

defined( 'ABSPATH' ) || exit;

class Post_Content {
	public function __construct() {
		add_action( 'init', array( $this, 'register' ) );
	}
	public function get_attributes() {

		return array(
			'blockId'        => '',

			// --------------------------
			// Advanced Settings
			// --------------------------
			'advanceId'      => '',
			'advanceZindex'  => '',
			'hideExtraLarge' => false,
			'hideDesktop'    => false,
			'hideTablet'     => false,
			'hideMobile'     => false,
			'advanceCss'     => '',
		);
	}

	public function register() {
		register_block_type(
			'ultimate-post/post-content',
			array(
				'editor_script'   => 'ultp-blocks-editor-script',
				'editor_style'    => 'ultp-blocks-editor-css',
				'render_callback' => array( $this, 'content' ),
			)
		);
	}
	public function content( $attr, $noAjax ) {
		$attr = wp_parse_args( $attr, $this->get_attributes() );

		$post_id        = get_the_ID();
		$block_name     = 'post-content';
		$wrapper_before = $wrapper_after = $content = '';
		$post_content   = get_the_content();
		$post_type      = get_post_type();
		if ( $post_type != 'ultp_builder' && $post_type != 'revision' && $post_type != 'premade' ) { // premade used for ultp.wpxpo.com
			$post_content = apply_filters( 'the_content', $post_content );
			$post_content = str_replace( ']]>', ']]&gt;', $post_content );
		}
		if ( $post_content ) {

			$attr['className'] = isset( $attr['className'] ) && $attr['className'] ? preg_replace( '/[^A-Za-z0-9_ -]/', '', $attr['className'] ) : '';
			$attr['align']     = isset( $attr['align'] ) && $attr['align'] ? preg_replace( '/[^A-Za-z0-9_ -]/', '', $attr['align'] ) : '';
			$attr['advanceId'] = isset( $attr['advanceId'] ) ? sanitize_html_class( $attr['advanceId'] ) : '';
			$attr['blockId']   = isset( $attr['blockId'] ) ? sanitize_html_class( $attr['blockId'] ) : '';

			// from v.2.9.7 for Loading Post Content Css
			do_action(
				'ultp_enqueue_postx_block_css',
				array(
					'post_id' => $post_id,
					'css'     => '',
				)
			);

			$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'] : '' ) . '">';
				$wrapper_before  .= '<div class="ultp-block-wrapper">';
					$content     .= '<div class="ultp-builder-content" data-postid="' . $post_id . '">';
						$content .= $post_content;
					$content     .= '</div>';
				$wrapper_after   .= '</div>';
			$wrapper_after       .= '</div>';
		}
		return $wrapper_before . $content . $wrapper_after;
	}
}

```
