Beispiel #1
0
 /**
  * Return html structure of shortcode in Page Builder area
  *
  * @param type $shortcode_name
  * @param type $attr
  * @param type $content
  */
 public static function shortcode_to_pagebuilder($shortcode_name, $content = '', $shortcode_data = '', $shortcode_params = '')
 {
     $class = IG_Pb_Helper_Shortcode::get_shortcode_class($shortcode_name);
     if (class_exists($class)) {
         global $Ig_Pb;
         $elements = $Ig_Pb->get_elements();
         $instance = isset($elements['element'][strtolower($class)]) ? $elements['element'][strtolower($class)] : null;
         if (!is_object($instance)) {
             $instance = new $class();
         }
         $instance->init_element();
         $el_title = '';
         if ($class != 'IG_Widget') {
             // 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] = IG_Pb_Utils_Common::remove_quotes($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 = shortcode_parse_atts($shortcode_params);
                     $el_title = !empty($params[$title['id']]) ? $params[$title['id']] : __('(Untitled)', IGPBL);
                 }
             }
         } else {
             $widget_info = IG_Pb_Helper_Shortcode::extract_widget_params($shortcode_data);
             $el_title = !empty($widget_info['title']) ? $widget_info['title'] : '';
             $params = IG_Pb_Helper_Shortcode::extract_params($shortcode_data);
             $instance->config['shortcode'] = $params['widget_id'];
             $instance->config['el_type'] = 'widget';
         }
         $shortcode_view = $instance->element_in_pgbldr($content, $shortcode_data, $el_title);
         return $shortcode_view[0];
     }
 }