| 1 |
<?php |
| 2 |
namespace ULTP; |
| 3 |
|
| 4 |
defined('ABSPATH') || exit; |
| 5 |
|
| 6 |
class Shortcode { |
| 7 |
public function __construct(){ |
| 8 |
add_shortcode('gutenberg_post_blocks', array($this, 'shortcode_callback')); |
| 9 |
} |
| 10 |
|
| 11 |
// Shortcode Callback |
| 12 |
function shortcode_callback( $atts = array(), $content = null ) { |
| 13 |
extract(shortcode_atts(array( |
| 14 |
'id' => '' |
| 15 |
), $atts)); |
| 16 |
|
| 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(']]>', ']]>', $content); |
| 26 |
return '<div class="ultp-shortcode" data-postid="'.$id.'">' . $content . '</div>'; |
| 27 |
} |
| 28 |
return ''; |
| 29 |
} |
| 30 |
|
| 31 |
} |