function frontier_end_template($code, $base, $template, $pod)
{
    global $template_post_blocks;
    if (!empty($template_post_blocks['before'][$pod->pod])) {
        $code = $template_post_blocks['before'][$pod->pod] . $code;
        unset($template_post_blocks['before'][$pod->pod]);
    }
    if (!empty($template_post_blocks['after'][$pod->pod])) {
        $code .= $template_post_blocks['after'][$pod->pod];
        unset($template_post_blocks['after'][$pod->pod]);
    }
    return pods_do_shortcode($code, array('each', 'pod_sub_template', 'once', 'pod_once_template', 'before', 'pod_before_template', 'after', 'pod_after_template', 'if', 'pod_if_field'));
}
 /**
  * Render the element
  *
  */
 public function render_element($atts, $content, $slug, $head = false)
 {
     $raw_atts = $atts;
     if (!empty($head)) {
         $instanceID = $this->element_instance_id('pods_templates' . $slug, 'header');
     } else {
         $instanceID = $this->element_instance_id('pods_templates' . $slug, 'footer');
     }
     //$configfiles = glob($this->get_path( __FILE__ ) .'configs/'.$slug.'-*.php');
     if (file_exists($this->get_path(__FILE__) . 'configs/fieldgroups-' . $slug . '.php')) {
         include $this->get_path(__FILE__) . 'configs/fieldgroups-' . $slug . '.php';
         $defaults = array();
         foreach ($configfiles as $file) {
             include $file;
             foreach ($group['fields'] as $variable => $conf) {
                 if (!empty($group['multiple'])) {
                     $value = array($this->process_value($conf['type'], $conf['default']));
                 } else {
                     $value = $this->process_value($conf['type'], $conf['default']);
                 }
                 if (!empty($group['multiple'])) {
                     if (isset($atts[$variable . '_1'])) {
                         $index = 1;
                         $value = array();
                         while (isset($atts[$variable . '_' . $index])) {
                             $value[] = $this->process_value($conf['type'], $atts[$variable . '_' . $index]);
                             $index++;
                         }
                     } elseif (isset($atts[$variable])) {
                         if (is_array($atts[$variable])) {
                             foreach ($atts[$variable] as &$varval) {
                                 $varval = $this->process_value($conf['type'], $varval);
                             }
                             $value = $atts[$variable];
                         } else {
                             $value[] = $this->process_value($conf['type'], $atts[$variable]);
                         }
                     }
                 } else {
                     if (isset($atts[$variable])) {
                         $value = $this->process_value($conf['type'], $atts[$variable]);
                     }
                 }
                 if (!empty($group['multiple']) && !empty($value)) {
                     foreach ($value as $key => $val) {
                         $groups[$group['master']][$key][$variable] = $val;
                     }
                 }
                 $defaults[$variable] = $value;
             }
         }
         $atts = $defaults;
     }
     // pull in the assets
     $assets = array();
     if (file_exists($this->get_path(__FILE__) . 'assets/assets-' . $slug . '.php')) {
         include $this->get_path(__FILE__) . 'assets/assets-' . $slug . '.php';
     }
     ob_start();
     if (file_exists($this->get_path(__FILE__) . 'includes/element-' . $slug . '.php')) {
         include $this->get_path(__FILE__) . 'includes/element-' . $slug . '.php';
     } else {
         if (file_exists($this->get_path(__FILE__) . 'includes/element-' . $slug . '.html')) {
             include $this->get_path(__FILE__) . 'includes/element-' . $slug . '.html';
         }
     }
     $out = ob_get_clean();
     if (!empty($head)) {
         // process headers - CSS
         if (file_exists($this->get_path(__FILE__) . 'assets/css/styles-' . $slug . '.php')) {
             ob_start();
             include $this->get_path(__FILE__) . 'assets/css/styles-' . $slug . '.php';
             $this->element_header_styles[] = ob_get_clean();
             add_action('wp_head', array($this, 'header_styles'));
         } else {
             if (file_exists($this->get_path(__FILE__) . 'assets/css/styles-' . $slug . '.css')) {
                 wp_enqueue_style($this->plugin_slug . '-' . $slug . '-styles', $this->get_url('assets/css/styles-' . $slug . '.css', __FILE__), array(), self::VERSION);
             }
         }
         // process headers - JS
         if (file_exists($this->get_path(__FILE__) . 'assets/js/scripts-' . $slug . '.php')) {
             ob_start();
             include $this->get_path(__FILE__) . 'assets/js/scripts-' . $slug . '.php';
             $this->element_footer_scripts[] = ob_get_clean();
         } else {
             if (file_exists($this->get_path(__FILE__) . 'assets/js/scripts-' . $slug . '.js')) {
                 wp_enqueue_script($this->plugin_slug . '-' . $slug . '-script', $this->get_url('assets/js/scripts-' . $slug . '.js', __FILE__), array('jquery'), self::VERSION, true);
             }
         }
         // get clean do shortcode for header checking
         ob_start();
         pods_do_shortcode($out, array('each', 'pod_sub_template', 'once', 'pod_once_template', 'before', 'pod_before_template', 'after', 'pod_after_template', 'if', 'pod_if_field'));
         ob_get_clean();
         return;
     }
     return pods_do_shortcode($out, array('each', 'pod_sub_template', 'once', 'pod_once_template', 'before', 'pod_before_template', 'after', 'pod_after_template', 'if', 'pod_if_field'));
 }