PluginProbe
Post Grid Gutenberg Blocks – PostX / 5.0.41
Post Grid Gutenberg Blocks – PostX v5.0.41
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
← All changes | addons/templates/Shortcode.php +59 -24 2.1.15.0.41 View file →
@@ -1,31 +1,66 @@
1 1 <?php
2 2 namespace ULTP;
3 3
4 -defined('ABSPATH') || exit;
4 +defined( 'ABSPATH' ) || exit;
5 5
6 6 class Shortcode {
7 - public function __construct(){
8 - add_shortcode('gutenberg_post_blocks', array($this, 'shortcode_callback'));
9 - }
7 + public function __construct() {
8 + add_shortcode( 'gutenberg_post_blocks', array( $this, 'shortcode_callback' ) );
9 + add_shortcode( 'postx_template', array( $this, 'shortcode_callback' ) );
10 + }
10 11
11 - // Shortcode Callback
12 - function shortcode_callback( $atts = array(), $content = null ) {
13 - extract(shortcode_atts(array(
14 - 'id' => ''
15 - ), $atts));
12 + // Shortcode Callback
13 + function shortcode_callback( $atts = array(), $content = null ) {
14 + extract(
15 + shortcode_atts(
16 + array(
17 + 'id' => '',
18 + ),
19 + $atts
20 + )
21 + );
16 22
17 - $content = '';
18 - if($id){
19 - $init = new \ULTP\Initialization();
20 - $init->register_scripts_common();
21 - ultimate_post()->set_css_style($id);
22 - $content_post = get_post($id);
23 - $content = $content_post->post_content;
24 - $content = apply_filters('the_content', $content);
25 - $content = str_replace(']]>', ']]&gt;', $content);
26 - return '<div class="ultp-shortcode" data-postid="'.$id.'">' . $content . '</div>';
27 - }
28 - return '';
29 - }
30 -
31 -}
23 + $id = is_numeric( $id ) ? (float) $id : false;
24 +
25 + if ( $id ) {
26 + if ( class_exists( 'SitePress' ) ) {
27 + $id = apply_filters( 'wpml_object_id', $id, 'ultp_templates', true );
28 + }
29 + $content = '';
30 + $pre_content = '';
31 + $content_post = get_post( $id );
32 + if ( $content_post ) {
33 + if ( $content_post->post_status == 'publish' && $content_post->post_password == '' ) {
34 + do_action(
35 + 'ultp_enqueue_postx_block_css',
36 + array(
37 + 'post_id' => $id,
38 + 'css' => '',
39 + )
40 + );
41 + // Breakdance builder support for its shortcode render
42 + $current_url = isset( $_SERVER['REQUEST_URI'] ) ? esc_url( $_SERVER['REQUEST_URI'] ) : '';
43 + if ( ! empty( $_GET['_breakdance_doing_ajax'] ) ||
44 + strpos( $current_url, 'bricks/v1/render_element' ) !== false
45 + ) {
46 +
47 + if ( ! empty( $_GET['_breakdance_doing_ajax'] ) && get_template() == 'bricks' ) {
48 + get_header();
49 + }
50 + $pre_content .= ultimate_post()->build_css_for_inline_print( $id, true );
51 + }
52 +
53 + $content .= $content_post->post_content;
54 + $content = do_blocks( $content );
55 + $content = do_shortcode( $content );
56 + $content = str_replace( ']]>', ']]&gt;', $content );
57 + $content = preg_replace( '%<p>&nbsp;\s*</p>%', '', $content );
58 + $content = preg_replace( '/^(?:<br\s*\/?>\s*)+/', '', $content );
59 +
60 + return $pre_content . '<div class="ultp-shortcode" data-postid="' . $id . '">' . $content . '</div>';
61 + }
62 + }
63 + }
64 + return '';
65 + }
66 +}