public static function ajax_parse_shortcode()
{
global $wp_scripts;
static $once = false;
if ($once) {
return;
}
$once = true;
if (empty($_POST['shortcode'])) {
wp_send_json_error();
}
$slug = sanitize_text_field($_POST['type']);
$full_shortcode = wp_kses_post(wp_unslash($_POST['shortcode']));
$shortcode = do_shortcode($full_shortcode);
if (empty($shortcode)) {
wp_send_json_error(array('type' => 'no-items', 'message' => __('No items found.')));
}
$head = '';
$styles = wpview_media_sandbox_styles();
foreach ($styles as $style) {
$head .= '<link type="text/css" rel="stylesheet" href="' . $style . '">';
}
if (!empty($wp_scripts)) {
$wp_scripts->done = array();
}
ob_start();
echo $shortcode;
$send = array('head' => $head, 'body' => ob_get_clean());
$send = apply_filters("shortcode_button_parse_mce_view_before_send", $send);
$send = apply_filters("shortcode_button_parse_mce_view_before_send_{$slug}", $send);
self::send_json_success($send);
}