| @@ -1,66 +1,31 @@ | ||
| 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 | - add_shortcode( 'postx_template', array( $this, 'shortcode_callback' ) ); | |
| 10 | - } | |
| 7 | + public function __construct(){ | |
| 8 | + add_shortcode('gutenberg_post_blocks', array($this, 'shortcode_callback')); | |
| 9 | + } | |
| 11 | 10 | |
| 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 | - ); | |
| 11 | + // Shortcode Callback | |
| 12 | + function shortcode_callback( $atts = array(), $content = null ) { | |
| 13 | + extract(shortcode_atts(array( | |
| 14 | + 'id' => '' | |
| 15 | + ), $atts)); | |
| 22 | 16 | |
| 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( ']]>', ']]>', $content ); | |
| 57 | - $content = preg_replace( '%<p> \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 | -} | |
| 17 | + $content = ''; | |
| 18 | + if($id){ | |
| 19 | + $init = new \ULTP\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(']]>', ']]>', $content); | |
| 26 | + return '<div class="ultp-shortcode" data-postid="'.$id.'">' . $content . '</div>'; | |
| 27 | + } | |
| 28 | + return ''; | |
| 29 | + } | |
| 30 | + | |
| 31 | +} | |