/** * Return html structure of shortcode in Page Builder area * * @param string $shortcode_name * @param string $content * @param string $shortcode_data * @param array $shortcode_params * * @return string */ public static function transformShortcodeToPagebuilder($shortcode_name, $content = '', $shortcode_data = '', $shortcode_params = '', $client = 'backend') { $class = JSNPagebuilderHelpersShortcode::getShortcodeClass($shortcode_name); if (class_exists($class)) { global $JSNPbElements; $JSNPbElements->setGeneratedStatus(true); $elements = $JSNPbElements->getElements(); $instance = isset($elements[strtolower($class)]) ? $elements[strtolower($class)] : null; if (!is_object($instance)) { $instance = new $class(); } $el_title = ""; // extract param of shortcode (now for column) if (isset($instance->config['extract_param'])) { parse_str(trim($shortcode_params), $output); foreach ($instance->config['extract_param'] as $param) { if (isset($output[$param])) { $instance->params[$param] = JSNPagebuilderHelpersFunctions::removeQuotes($output[$param]); } } } // get content in pagebuilder of shortcode: Element Title must always first option of Content tab if (isset($instance->items["content"]) && isset($instance->items["content"][0])) { $title = $instance->items["content"][0]; if (@$title["role"] == "title") { $params = JSNPagebuilderHelpersShortcode::shortcodeParseAtts($shortcode_params); $el_title = !empty($params[$title["id"]]) ? $params[$title["id"]] : ""; } } if ($client === 'backend') { $shortcode_view = $instance->element_in_pgbldr($content, $shortcode_data, $el_title); } else { // Render the shortcode frontend HTML $params = JSNPagebuilderHelpersShortcode::shortcodeParseAtts($shortcode_params); $shortcode_view = $instance->element_shortcode($params, $content); } return $shortcode_view; } }