Example #1
0
    function rt_shortcode_slider_slides($atts, $content = null)
    {
        //[slide link="link" title="title" img_url="" video_url="" styling="" title_color="" title_bg_color="" text_color="" text_bg_color="" title_size="" text_size=""]slide_text[/slide]
        global $rt_slider_width, $rt_slider_height, $rt_slider_script, $rt_total_slide, $rt_slide_count, $rt_caption_output, $rt_slide_output, $rt_slider_id, $rt_image_resize, $rt_image_crop;
        $text = $image_output = $resized_img_url = "";
        $rt_slide_count++;
        //defaults
        extract(shortcode_atts(array("link" => '', "title" => '', "title2" => '', "img_url" => '', "video_url" => '', "text_align" => 'left', "stretch_images" => true, "styling" => "", "title_color" => "", "title_bg_color" => "", "text_color" => "", "text_bg_color" => "", "title_size" => "", "text_size" => ""), $atts));
        //nivo slide id
        $nivo_slide_id = $rt_slider_script == "nivo_slider" ? "random_" . rand(100000, 1000000) : "";
        //randomized
        $nivo_image_sync_id = $nivo_slide_id ? "#" . $nivo_slide_id : "";
        //caption css
        $caption_css = "";
        if ($styling == "new") {
            $caption_css .= !empty($title_color) ? " color:" . rt_rgba2hex($title_color) . "; color:" . $title_color . ";" : "";
            $caption_css .= !empty($title_bg_color) ? "background-image:none; background-color:" . rt_rgba2hex($title_bg_color) . "; background-color:" . $title_bg_color . ";" : "background-color:transparent;padding-top:0;padding-bottom:0;";
            $caption_css .= !empty($title_size) ? " font-size:" . str_replace("px", "", $title_size) . "px;line-height:140%;" : "";
            $caption_css = !empty($caption_css) ? 'style="' . $caption_css . '"' : "";
        }
        //text css
        $text_css = "";
        if ($styling == "new") {
            $text_css .= !empty($text_color) ? " color:" . rt_rgba2hex($text_color) . "; color:" . $text_color . ";" : "";
            $text_css .= !empty($text_bg_color) ? "background-image:none; background-color:" . rt_rgba2hex($text_bg_color) . "; background-color:" . $text_bg_color . ";" : "background-color:transparent;padding-top:0;padding-bottom:0;";
            $text_css .= !empty($text_size) ? " font-size:" . str_replace("px", "", $text_size) . "px;line-height:140%;" : "";
            $text_css = !empty($text_css) ? 'style="' . $text_css . '"' : "";
        }
        //allowed html codes
        $allowed_html_title = array('br' => array());
        $allowed_html_text = array('a' => array('href' => array(), 'title' => array()), 'br' => array(), 'em' => array(), 'strong' => array());
        //title
        $title = !empty($title) ? !empty($link) ? '<div class="caption-one" ' . $caption_css . '><a href="' . $link . '" title="' . wp_kses($title, "") . '" ' . $caption_css . '>' . wp_kses(stripcslashes($title), $allowed_html_title) . '</a></div>' . "\n" : '<div class="caption-one" ' . $caption_css . '>' . wp_kses($title, $allowed_html_title) . '</div>' . "\n" : "";
        //text
        $text = !empty($content) ? '<div class="caption-text" ' . $text_css . '>' . trim(wp_kses(stripcslashes($content), $allowed_html_text)) . '</div>' . "\n" : "";
        //li class
        $li_class = $stretch_images == "true" ? "stretch" : "";
        //featured image output
        if (!empty($img_url)) {
            $img_url = rt_find_image_org_path($img_url);
            $image_id = rt_get_attachment_id_from_src($img_url);
            $image_alternative_text = get_post_meta($image_id, '_wp_attachment_image_alt', true);
            $image_meta_data = wp_get_attachment_metadata($image_id, "true");
            $image_height = isset($image_meta_data["height"]) ? $image_meta_data["height"] : "";
            //crop & resize = true
            if (!empty($rt_image_resize) && !empty($rt_image_crop)) {
                $resized_img_url = rt_vt_resize($image_id, $img_url, $rt_slider_width, $rt_slider_height, true, false);
            }
            //crop = true & resize = false
            if (empty($rt_image_resize) && !empty($rt_image_crop)) {
                $resized_img_url = rt_vt_resize($image_id, $img_url, $rt_slider_width, $rt_slider_height, false, true);
            }
            //crop = false & resize = true
            if (!empty($rt_image_resize) && empty($rt_image_crop)) {
                $resized_img_url = rt_vt_resize($image_id, $img_url, $rt_slider_width, $rt_slider_height, false, false);
            }
            //if resized or cropped
            if (isset($resized_img_url) && is_array($resized_img_url)) {
                $img_url = $resized_img_url["url"];
                $image_height = $resized_img_url["height"];
            }
            //first image height
            $rt_first_slide_height = $rt_slide_count == 1 && $image_height ? $image_height : 0;
            $rt_first_slide_data = $rt_slide_count == 1 ? 'data-flexfirstslide="true"' : "";
            $rt_first_slide_height_data = isset($rt_first_slide_height) && $rt_first_slide_height > 0 ? 'data-sliderminheight="' . $rt_first_slide_height . 'px"' : "";
            $image_output = !empty($link) ? sprintf('<a href="%s"><img src="%s" alt="%s" title="%s" /></a>' . "\n", $link, $img_url, $image_alternative_text, $nivo_image_sync_id) : sprintf('<img src="%s" alt="%s" title="%s" />' . "\n", $img_url, $image_alternative_text, $nivo_image_sync_id);
        }
        //output for flexslider
        if ($rt_slider_script == "flex_slider") {
            //caption
            $rt_caption_output = !empty($title) || !empty($text) ? sprintf('<div class="flex-caption %s"><div class="caption-holder">%s %s %s</div></div>' . "\n", $text_align, $title, $title2, $text) : "";
            //slide output
            $rt_slide_output = sprintf('<li class="%s" %s %s><div class="slide_data">%s %s</div></li>' . "\n", $li_class, $rt_first_slide_height_data, $rt_first_slide_data, $image_output, $rt_caption_output);
            return $rt_slide_output;
        }
        //output for nivoslider
        if ($rt_slider_script == "nivo_slider") {
            //caption
            $rt_caption_output .= !empty($title) || !empty($text) ? sprintf('
			<div id="%s" class="nivo-html-caption">			
				<div class="nivo-title caption-%s">
				%s
				</div>
				<div class="nivo-text">
				%s
				</div>
			</div>
			' . "\n", $nivo_slide_id, $rt_slide_count, $title, $text) : "";
            //slide output
            $rt_slide_output .= sprintf("%s", $image_output);
            if ($rt_total_slide == $rt_slide_count) {
                //the slider holder output
                $rt_slide_output = sprintf('

				<div class="nivo-container theme-default">
					<div class="nivoSlider" id="%s">
						%s
					</div>
						%s
				</div>

			', $rt_slider_id, $rt_slide_output, $rt_caption_output);
                return $rt_slide_output;
            }
        }
    }
 function generate_template_output($template_contents = "", $templateID = "")
 {
     global $rt_google_fonts;
     // output
     $template_output = "";
     $header_output = "";
     $footer_output = "";
     $footer_started = false;
     $css_output = array("color_sets" => array(), "backgrounds" => array(), "css_codes" => "", "fonts" => array());
     //template options
     $template_options = array();
     //variables
     $start_row = $next_item_width = $count_item_widths = $columns_started = "";
     $layout_width_values = array("four-five" => 48, "three-four" => 45, "two-three" => 40, "five" => 12, "four" => 15, "three" => 20, "two" => 30, "one" => 60);
     $column_class_names = array(2 => "four-five", 3 => "three-four", 4 => "two-three", 8 => "five", 7 => "four", 6 => "three", 5 => "two", 1 => "one");
     $row_counter = 1;
     $header_purpose = isset($header_purpose) && !empty($header_purpose) ? $header_purpose : false;
     $footer_purpose = isset($footer_purpose) && !empty($footer_purpose) ? $footer_purpose : false;
     // Create contents
     foreach ($template_contents as $item_num => $template) {
         //extract template vars
         extract(get_object_vars($template));
         //content type
         $content_type = isset($content_type) ? $content_type : "";
         //columns holder for other elemets
         if (!$header_purpose && empty($columns_started) && $content_type != "column" && $content_type != "grid" && $content_type != "slider_box" && $content_type != "space_box") {
             $template_output .= '[rt_columns]';
         }
         //colorsets and bacgrounds
         if ($content_type == "grid" && $part == "first") {
             // container
             if ($header_purpose) {
                 $container = "body .header-" . str_replace("templateid_", "", $templateID);
             } elseif ($footer_purpose) {
                 $container = "body #container .footer-" . str_replace("templateid_", "", $templateID);
             } else {
                 $container = '#row-' . str_replace("templateid_", "", $templateID) . '-' . $group_id . '';
             }
             // colorset
             $colorset_array = array("container" => $container, "selection" => $color_set["color_set_selection"], "values" => array());
             if ($color_set["color_set_selection"] == "new") {
                 $colorset_array["values"] = array("primary" => $color_set["primary"], "font" => $color_set["font"], "light_font" => $color_set["light_font"], "headings" => $color_set["headings"], "heading_links" => $color_set["heading_links"], "link" => $color_set["link"], "link_hover" => $color_set["link_hover"], "highlighted" => $color_set["highlighted"], "border" => $color_set["border"], "social_media" => $color_set["social_media"]);
             }
             array_push($css_output["color_sets"], $colorset_array);
             // background
             $background_array = array("container" => $container, "selection" => $background_options["background_selection"], "values" => array());
             // parallax background
             $parallax_background = isset($background_options["parallax_background"]) ? $background_options["parallax_background"] : "disabled_parallax";
             //create value set
             if ($background_options["background_selection"] == "new" && $parallax_background == "disabled_parallax") {
                 $background_array["values"] = array("background_color" => isset($background_options["background_color"]) ? $background_options["background_color"] : "", "background_image_url" => isset($background_options["background_image_url"]) ? $background_options["background_image_url"] : "", "background_attachment" => isset($background_options["background_attachment"]) ? $background_options["background_attachment"] : "", "background_position" => isset($background_options["background_position"]) ? $background_options["background_position"] : "", "background_repeat" => isset($background_options["background_repeat"]) ? $background_options["background_repeat"] : "", "background_size" => isset($background_options["background_size"]) ? $background_options["background_size"] : "");
             }
             array_push($css_output["backgrounds"], $background_array);
         }
         //header
         if ($content_type == "grid" && $header_purpose) {
             if ($part == "first") {
                 //first part
                 $template_output .= '[header selector_class="header-' . str_replace("templateid_", "", $templateID) . '" header_options="' . $header_options . '" breadcrumb="' . $breadcrumb . '" page_title="' . $page_title . '" breadcrumb_position="' . $breadcrumb_position . '"]';
                 //keep common values
                 $breadcrumb_position_keep = $breadcrumb_position;
                 $page_title_keep = $page_title;
                 $breadcrumb_keep = $breadcrumb;
                 //add values to $template_options
                 $template_options = array("breadcrumb_position" => $breadcrumb_position, "display_title" => $page_title, "display_breadcrumb" => $breadcrumb, "header_background_options" => $header_options, "first_top_widget_name" => $first_top_widget_name, "second_top_widget_name" => $second_top_widget_name);
             }
             if ($part == "second") {
                 //second part
                 $template_output .= "[/header]";
                 $header_output = $template_output;
                 $template_output = "";
             }
         } elseif ($content_type == "grid" && $footer_purpose) {
             if ($part == "first") {
                 //first part
                 $save_template_output = $template_output;
                 $template_output = "";
                 $template_output .= '[footer selector_class="footer-' . str_replace("templateid_", "", $templateID) . '"]';
                 //add values to $template_options
                 $template_options["display_widgets"] = $display_widgets;
                 $footer_started = true;
             }
             if ($part == "second") {
                 //second part
                 $template_output .= "[/footer]";
                 $footer_output = $template_output;
                 $template_output = $save_template_output;
             }
         } elseif ($content_type == "grid" && !$header_purpose && !$footer_purpose) {
             if ($part == "first") {
                 //first part
                 $row_id = 'row-' . str_replace("templateid_", "", $templateID) . '-' . $group_id . '';
                 //get row style
                 $row_class = "";
                 $row_class .= $background_options["background_selection"] == "ca2" ? "row-style-2" : "";
                 $row_class .= $background_options["background_selection"] == "ca3" ? "row-style-3" : "";
                 //get row width
                 $full_width_row = $row_style_options["row_width"] == "full" ? "true" : "";
                 //row css
                 $row_paddings = "";
                 $row_paddings .= !empty($row_style_options["padding_top"]) ? sprintf('#%1$s { padding-top: %2$spx; }', $row_id . "", $row_style_options["padding_top"]) : "";
                 $row_paddings .= !empty($row_style_options["padding_left"]) ? sprintf('#%1$s { padding-left: %2$spx; }', $row_id . "", $row_style_options["padding_left"]) : "";
                 $row_paddings .= !empty($row_style_options["padding_right"]) ? sprintf('#%1$s { padding-right: %2$spx; }', $row_id . "", $row_style_options["padding_right"]) : "";
                 $row_paddings .= !empty($row_style_options["padding_bottom"]) ? sprintf('#%1$s { padding-bottom: %2$spx; }', $row_id . "", $row_style_options["padding_bottom"]) : "";
                 $row_paddings = !empty($row_paddings) ? sprintf('%s', $row_paddings) . '' . sprintf('@media only screen and (max-width: 767px) { #%1$s { padding-left: 0px; padding-right: 0px; } }', $row_id) : "";
                 //columns css
                 $column_paddings = "";
                 $column_paddings .= !empty($column_options["padding_top"]) ? sprintf('#%1$s >  .row  > .box { padding-top: %2$spx; }', $row_id . "-content", $column_options["padding_top"]) : "";
                 $column_paddings .= !empty($column_options["padding_left"]) ? sprintf('#%1$s >  .row  > .box { padding-left: %2$spx; }', $row_id . "-content", $column_options["padding_left"]) : "";
                 $column_paddings .= !empty($column_options["padding_right"]) ? sprintf('#%1$s >  .row  > .box { padding-right: %2$spx; }', $row_id . "-content", $column_options["padding_right"]) : "";
                 $column_paddings .= !empty($column_options["padding_bottom"]) ? sprintf('#%1$s >  .row  > .box { padding-bottom: %2$spx; }', $row_id . "-content", $column_options["padding_bottom"]) : "";
                 $column_paddings .= !empty($column_paddings) ? sprintf('@media only screen and (max-width: 767px) {  #%1$s >  .row  > .box { padding-left: 5px;padding-right: 5px; }}', $row_id . "-content") : "";
                 $paddings = !empty($column_paddings) ? "true" : "";
                 $css_output["css_codes"] .= $row_paddings;
                 $css_output["css_codes"] .= $column_paddings;
                 $css_output["css_codes"] .= $column_options["background_selection"] == "new" ? sprintf('#%1$s >  .row  > .box { background-color: %2$s; background-color: %3$s; }', $row_id . "-content", rt_rgba2hex($column_options["background_color"]), $column_options["background_color"]) : "";
                 $css_output["css_codes"] .= $column_options["background_selection"] == "half_transparent" ? sprintf('#%1$s >  .row  > .box { background-image: url(%2$s/images/transparent-white.png); }', $row_id . "-content", RT_THEMEURI) : "";
                 $sidebar_id = is_array($sidebar_id) ? implode(",", $sidebar_id) : "";
                 $background_image_url = isset($background_options["background_image_url"]) ? $background_options["background_image_url"] : "";
                 $parallax_background = $background_options["background_selection"] == "new" && isset($background_options["parallax_background"]) ? $background_options["parallax_background"] : "disabled_parallax";
                 $template_output .= '[row full_width_row="' . $full_width_row . '" row_counter=' . $row_counter . ' page_title="' . $page_title_keep . '" breadcrumb="' . $breadcrumb_keep . '" breadcrumb_position="' . $breadcrumb_position_keep . '" id="' . $row_id . '" sidebar_selection = "' . $sidebar_selection . '" sidebar_id = "' . $sidebar_id . '" paddings = "' . $paddings . '" class="' . $row_class . '" parallax_background="' . $parallax_background . '" background_image_url = "' . $background_image_url . '"]';
                 $sidebar_id = $sidebar_selection = $column_paddings = "";
                 //the row counter
                 $row_counter++;
             }
             if ($part == "second") {
                 //second part
                 $template_output .= "[/row]";
             }
         } elseif ($content_type == "column") {
             $count_column_widths = isset($count_column_widths) ? $count_column_widths : 0;
             if ($part == "first") {
                 //first part
                 //create column holder
                 $template_output .= $count_column_widths == 0 || $count_column_widths == "" ? '[rt_columns]' : "";
                 //start counter for column holder
                 $this_column_width = $layout_width_values[$column_class_names[$layout]];
                 // finds width of this item as in $layout_width_values
                 $count_column_widths = $count_column_widths + $this_column_width;
                 //start column
                 $template_output .= '[rt_column layout="' . $column_class_names[$layout] . '"]';
                 $columns_started = true;
             }
             if ($part == "second") {
                 //second part
                 //end column
                 $template_output .= "[/rt_column]";
                 //find the next columns width
                 if (isset($template_contents[$item_num + 1]->content_type) && $template_contents[$item_num + 1]->content_type == "column") {
                     $next_column_width = $layout_width_values[$column_class_names[$template_contents[$item_num + 1]->layout]];
                 } else {
                     $next_column_width = 60;
                     // there is no next column so this must be hightest value
                 }
                 //close the column holder
                 if ($count_column_widths + $next_column_width > 60) {
                     $template_output .= '[/rt_columns]';
                     $count_column_widths = 0;
                     // reset the column counter
                     $columns_started = "";
                 }
             }
         } elseif ($content_type == "new_content_box") {
             $content_box_id = 'content-box-' . str_replace("templateid_", "", $templateID) . '-' . $group_id . '';
             $template_output .= '[content_box id="' . $content_box_id . '" title="' . htmlspecialchars($title) . '" title_position="' . $title_position . '" featured_image="' . $featured_image . '" image_style="' . $image_style . '" icon="' . $icon . '" icon_style="' . $icon_style . '" text_position="' . $text_position . '" link="' . htmlspecialchars($link) . '" link_text="' . htmlspecialchars($link_text) . '" link_target="' . htmlspecialchars($link_target) . '"]';
             //fix editor shortcodes
             $text = $this->fix_editor_columns($text);
             $text = $this->fix_editor_contents($text);
             $template_output .= $text;
             $template_output .= '[/content_box]';
         } elseif ($content_type == "content_icon_box") {
             $content_box_id = 'content-box-' . str_replace("templateid_", "", $templateID) . '-' . $group_id . '';
             $template_output .= '[content_icon_box id="' . $content_box_id . '" title="' . htmlspecialchars($title) . '" title_position="' . $title_position . '" icon="' . $icon . '" icon_style="' . $icon_style . '" text_position="' . $text_position . '" icon_color="' . $icon_color . '" icon_bg_color="' . $icon_bg_color . '" icon_border_color="' . $icon_border_color . '" link="' . htmlspecialchars($link) . '" link_text="' . htmlspecialchars($link_text) . '" link_target="' . htmlspecialchars($link_target) . '"]';
             //css output for this icons
             $css_output["css_codes"] .= !empty($icon_color) ? sprintf('.row #%1$s .heading_icon{color:%2$s !important;}', $content_box_id, $icon_color) : "";
             $css_output["css_codes"] .= !empty($icon_bg_color) ? sprintf('.row #%1$s .heading_icon{background-color:%2$s;}', $content_box_id, $icon_bg_color) : "";
             $css_output["css_codes"] .= !empty($icon_border_color) ? sprintf('.row #%1$s .heading_icon{border-color:%2$s;}#%1$s .pin:after{color:%2$s;border-color:%2$s;}', $content_box_id, $icon_border_color) : "";
             //fix editor shortcodes
             $text = $this->fix_editor_columns($text);
             $text = $this->fix_editor_contents($text);
             $template_output .= $text;
             $template_output .= '[/content_icon_box]';
         } elseif ($content_type == "text_box") {
             $text = $font_size = $font_color = $heading_color = $font_family_text = $font_family_heading = $font_family_heading_css = $font_family_text_css = "";
             extract($values);
             $text_box_id = 'text-box-' . str_replace("templateid_", "", $templateID) . '-' . $group_id . '';
             //font family heading
             if (!empty($font_family_text)) {
                 $font_family_text = stripslashes($font_family_text);
                 if (isset($rt_google_fonts[$font_family_text])) {
                     //check if it is a google font
                     $font_family_text_css = "'" . $rt_google_fonts[$font_family_text][0] . "',sans-serif";
                     $font_weight_text_css = isset($rt_google_fonts[$font_family_text][2]) ? $rt_google_fonts[$font_family_text][2] : "normal";
                 } else {
                     $font_family_text_css = $font_family_text;
                     $font_weight_text_css = "normal";
                 }
             }
             //font family heading
             if (!empty($font_family_heading)) {
                 $font_family_heading = stripslashes($font_family_heading);
                 if (isset($rt_google_fonts[$font_family_heading])) {
                     //check if it is a google font
                     $font_family_heading_css = "'" . $rt_google_fonts[$font_family_heading][0] . "',sans-serif";
                     $font_weight_heading_css = isset($rt_google_fonts[$font_family_heading][2]) ? $rt_google_fonts[$font_family_heading][2] : "normal";
                 } else {
                     $font_family_heading_css = $font_family_heading;
                     $font_weight_heading_css = "normal";
                 }
             }
             $heading_selector = sprintf('#%1$s h1,#%1$s h2,#%1$s h3,#%1$s h4,#%1$s h5,#%1$s h6', $text_box_id);
             $css_output["css_codes"] .= !empty($font_color) ? sprintf('#%1$s p{color:%2$s}', $text_box_id, $font_color) : "";
             $css_output["css_codes"] .= !empty($font_size) ? sprintf('#%1$s p{font-size:%2$spx;line-height:150%%;}', $text_box_id, $font_size) : "";
             $css_output["css_codes"] .= !empty($heading_color) ? sprintf('%1$s{color:%2$s;}', $heading_selector, $heading_color) : "";
             $css_output["css_codes"] .= !empty($font_family_text_css) ? '#' . $text_box_id . ' p{font-family:' . $font_family_text_css . '; font-weight:' . $font_weight_text_css . ' !important;}' : "";
             $css_output["css_codes"] .= !empty($font_family_heading_css) ? $heading_selector . '{font-family:' . $font_family_heading_css . '; font-weight:' . $font_weight_heading_css . ' !important;}' : "";
             /*
             add the selected fonts to the fonts array of this template to 
             be loaded with wp_enqueue in custom_styling.php
             */
             if (!empty($font_family_text)) {
                 array_push($css_output["fonts"], $font_family_text);
             }
             if (!empty($font_family_heading)) {
                 array_push($css_output["fonts"], $font_family_heading);
             }
             //fix editor shortcodes
             $text = $this->fix_editor_columns($text);
             $text = $this->fix_editor_contents($text);
             $template_output .= '[text_box id="' . $text_box_id . '"]';
             $template_output .= $text;
             $template_output .= '[/text_box]';
         } elseif ($content_type == "slider_box") {
             /*
             //[slider slider_width="650" slider_height="300" slider_script=""]
             	[slide link="link" title="title" img_url="" video_url="" styling="" title_color="" title_bg_color="" text_color="" text_bg_color="" title_size="" text_size=""]slide_text[/slide] 
             				[/slider]
             */
             $slides_output = "";
             foreach ($slides["slide_hidden_value"] as $key => $options) {
                 if (!empty($slides["slide_hidden_value"][$key])) {
                     $slide_title = $slide_text = $slide_image_url = $slide_link = $text_size = $title_size = $text_bg_color = $title_bg_color = $title_color = $styling = "";
                     $slide_title = !empty($slides["slide_title"][$key]) ? $slides["slide_title"][$key] : "";
                     $slide_text = !empty($slides["slide_text"][$key]) ? $slides["slide_text"][$key] : "";
                     $slide_image_url = !empty($slides["slide_image_url"][$key]) ? $slides["slide_image_url"][$key] : "";
                     $slide_link = !empty($slides["slide_link"][$key]) ? $slides["slide_link"][$key] : "";
                     $text_align = !empty($slides["text_align"][$key]) ? $slides["text_align"][$key] : "";
                     $stretch_images = !empty($slides["stretch_images"][$key]) ? $slides["stretch_images"][$key] : "";
                     $styling = !empty($slides["styling"][$key]) ? $slides["styling"][$key] : "";
                     $title_color = !empty($slides["title_color"][$key]) ? $slides["title_color"][$key] : "";
                     $title_bg_color = !empty($slides["title_bg_color"][$key]) ? $slides["title_bg_color"][$key] : "";
                     $text_color = !empty($slides["text_color"][$key]) ? $slides["text_color"][$key] : "";
                     $text_bg_color = !empty($slides["text_bg_color"][$key]) ? $slides["text_bg_color"][$key] : "";
                     $title_size = !empty($slides["title_size"][$key]) ? $slides["title_size"][$key] : "";
                     $text_size = !empty($slides["text_size"][$key]) ? $slides["text_size"][$key] : "";
                     if ($slide_title || $slide_text || $slide_image_url) {
                         $slides_output .= sprintf('[slide link="%s" title="%s" img_url="%s" text_align="%s" stretch_images="%s" styling="%s" title_color="%s" title_bg_color="%s" text_color="%s" text_bg_color="%s" title_size="%s" text_size="%s"]%s[/slide]', $slide_link, $slide_title, $slide_image_url, $text_align, $stretch_images, $styling, $title_color, $title_bg_color, $text_color, $text_bg_color, $title_size, $text_size, $slide_text);
                     }
                 }
             }
             $template_output .= sprintf('[slider slider_width="%s" slider_height="%s" slider_script="%s" image_resize="%s" image_crop="%s" slider_timeout="%s" flex_slider_effect="%s"]%s[/slider]', $slider_width, $slider_height, "flex_slider", $image_resize, $image_crop, $slider_timeout, $flex_slider_effect, $slides_output);
         } elseif ($content_type == "tabs_box") {
             /*
             //[tabs tab1="" tab1-icon="" tab2="" tab2-icon="" tab3="" tab3-icon=""][/tabs]
             	[tab][/tab]
             [/tabs]
             */
             $tab_captions_output = '[tabs tabs_style="' . $tabs_style . '" ';
             $tab_contents_output = "";
             $tab_count = 1;
             foreach ($tab_contents["caption"] as $key => $options) {
                 $tab_caption = $tab_text = $tab_icon = "";
                 $tab_caption = !empty($tab_contents["caption"][$key]) ? $tab_contents["caption"][$key] : "";
                 $tab_text = !empty($tab_contents["text"][$key]) ? $tab_contents["text"][$key] : "";
                 $tab_icon = !empty($tab_contents["icon"][$key]) ? $tab_contents["icon"][$key] : "";
                 $tab_captions_output .= !empty($tab_caption) ? 'tab' . $tab_count . '="' . htmlspecialchars($tab_caption) . '" ' : "";
                 $tab_captions_output .= !empty($tab_icon) ? 'tab' . $tab_count . '_icon="' . $tab_icon . '" ' : "";
                 $tab_contents_output .= !empty($tab_caption) ? '[tab]' . $tab_text . '[/tab]' : "";
                 $tab_count++;
             }
             $tab_captions_output .= "]";
             $template_output .= $tab_captions_output . " " . stripslashes($tab_contents_output);
             $template_output .= '[/tabs]';
         } elseif ($content_type == "accordion_box") {
             /*
             //[accordion align="" style=""]
             	[pane title="" icon=""][/pane]
             [/accordion]
             */
             $first_one_open = isset($first_one_open) && !empty($first_one_open) ? "true" : "";
             $accordion_contents_output = '';
             foreach ($accordion_contents["caption"] as $key => $options) {
                 $accordion_caption = $accordion_text = $accordion_icon = "";
                 $accordion_caption = !empty($accordion_contents["caption"][$key]) ? $accordion_contents["caption"][$key] : "";
                 $accordion_text = !empty($accordion_contents["text"][$key]) ? $accordion_contents["text"][$key] : "";
                 $accordion_icon = !empty($accordion_contents["icon"][$key]) ? $accordion_contents["icon"][$key] : "";
                 $accordion_contents_output .= !empty($accordion_caption) ? '[pane title="' . htmlspecialchars($accordion_caption) . '" ' : "";
                 $accordion_contents_output .= !empty($accordion_caption) && !empty($accordion_icon) ? 'icon="' . $accordion_icon . '" ' : "";
                 $accordion_contents_output .= !empty($accordion_caption) ? ']' . $accordion_text . '[/pane]' : "";
             }
             $template_output .= !empty($accordion_contents_output) ? sprintf('[accordion style="%s" first_one_open="%s"]%s[/accordion]', $accordion_style, $first_one_open, stripslashes($accordion_contents_output)) : "";
             $first_one_open = "";
         } elseif ($content_type == "icon_list_box") {
             /*
             //[icon_list title=""]
             	[icon_list_line icon=""]content[/icon_list_line]
             [/icon_list]
             */
             $icon_list_output = '';
             foreach ($list["text"] as $key => $options) {
                 $list_text = !empty($list["text"][$key]) ? $list["text"][$key] : "";
                 $list_icon = !empty($list["icon"][$key]) ? $list["icon"][$key] : "";
                 if (!empty($list_text)) {
                     $icon_list_output .= '[icon_list_line icon="' . $list_icon . '"]' . $list_text . '[/icon_list_line]';
                 }
             }
             $template_output .= !empty($icon_list_output) ? sprintf('[icon_list title="%s" icon_style="%s" item_width="%s"]%s[/icon_list]', $module_title, $icon_style, $item_width, $icon_list_output) : "";
         } elseif ($content_type == "blog_box") {
             /*
             //[blog_box pagination="" list_orderby="" list_order="" item_per_page="" list_style="" list_layout="" categories="" ]
             */
             $categories = isset($categories) && is_array($categories) ? implode($categories, ",") : "";
             $template_output .= sprintf('[blog_box pagination="%s" list_orderby="%s" list_order="%s" item_per_page="%s" list_style="%s" list_layout="%s" categories="%s"]', $pagination, $list_orderby, $list_order, $item_per_page, $list_style, $list_layout, $categories);
         } elseif ($content_type == "blog_carousel") {
             /*
             //[blog_carousel id="" crop="" style="" heading="" heading_icon="" item_width="5" list_orderby="" list_order="" max_item="" categories="" ids="" display_excerpts=""]
             */
             $crop = $style = $heading = $heading_icon = $item_width = $list_orderby = $list_order = $max_item = $categories = $display_excerpts = $limit_chars = "";
             extract($values);
             $blog_carousel_id = 'blog-carousel-' . str_replace("templateid_", "", $templateID) . '-' . $group_id . '';
             $categories = isset($categories) && is_array($categories) ? implode($categories, ",") : "";
             $template_output .= sprintf('[blog_carousel id="%s" crop="%s" style="%s" heading="%s" heading_icon="%s" item_width="%s" list_orderby="%s" list_order="%s" max_item="%s" categories="%s" ids="%s" display_excerpts="%s" limit_chars="%s"]', $blog_carousel_id, $crop, $style, $heading, $heading_icon, $item_width, $list_orderby, $list_order, $max_item, $categories, "", $display_excerpts, $limit_chars);
         } elseif ($content_type == "portfolio_box") {
             /*
             //[portfolio_box id="" item_width="5" pagination="" portf_list_orderby="" portf_list_order="" item_per_page="9" filterable="" categories=""  display_descriptions="" display_titles="" display_embedded_titles="" ]
             */
             $categories = $display_descriptions = $display_titles = $pagination = $display_embedded_titles = $filterable = "";
             extract($values);
             $portfolio_id = 'portfolio-' . str_replace("templateid_", "", $templateID) . '-' . $group_id . '';
             $categories = isset($categories) && is_array($categories) ? implode($categories, ",") : "";
             $template_output .= sprintf('[portfolio_box id="%s" item_width="%s" pagination="%s" portf_list_orderby="%s" portf_list_order="%s" item_per_page="%s" filterable="%s" categories="%s" display_descriptions="%s" display_titles="%s" display_embedded_titles="%s"]', $portfolio_id, $item_width, $pagination, $portf_list_orderby, $portf_list_order, $item_per_page, $filterable, $categories, $display_descriptions, $display_titles, $display_embedded_titles);
         } elseif ($content_type == "portfolio_carousel") {
             /*
             //[portfolio_carousel id="" heading="" heading_icon="" item_width="5" list_orderby="" list_order="" max_item="9" categories="" portfolio_ids=""  display_descriptions="" display_titles=""]
             */
             extract($values);
             $crop = isset($crop) ? $crop : "";
             $display_descriptions = isset($display_descriptions) ? $display_descriptions : "";
             $display_titles = isset($display_titles) ? $display_titles : "";
             $portfolio_carousel_id = 'portfolio-carousel-' . str_replace("templateid_", "", $templateID) . '-' . $group_id . '';
             $categories = isset($categories) && is_array($categories) ? implode($categories, ",") : "";
             $template_output .= sprintf('[portfolio_carousel id="%s" crop="%s" style="%s" heading="%s" heading_icon="%s" item_width="%s" list_orderby="%s" list_order="%s" max_item="%s" categories="%s" portfolio_ids="%s" display_descriptions="%s" display_titles="%s"]', $portfolio_carousel_id, $crop, $style, $heading, $heading_icon, $item_width, $list_orderby, $list_order, $max_item, $categories, "", $display_descriptions, $display_titles);
         } elseif ($content_type == "product_box") {
             /*
             //[product_box id="" item_width="5" pagination="" list_orderby="" list_order="" item_per_page="9" categories="" display_descriptions="" display_titles="" display_price="" ]
             */
             $heading = $crop = $categories = $display_descriptions = $display_titles = $display_price = $pagination = $with_borders = $with_effect = $no_top_border = $no_bottom_border = "";
             extract($values);
             $product_id = 'products-' . str_replace("templateid_", "", $templateID) . '-' . $group_id . '';
             $categories = isset($categories) && is_array($categories) ? implode($categories, ",") : "";
             $template_output .= sprintf('[product_box id="%s" item_width="%s" pagination="%s" list_orderby="%s" list_order="%s" item_per_page="%s" categories="%s"  display_descriptions="%s" display_titles="%s" display_price="%s" heading="%s" with_borders="%s" with_effect="%s" no_top_border="%s" no_bottom_border="%s"]', $product_id, $item_width, $pagination, $list_orderby, $list_order, $item_per_page, $categories, $display_descriptions, $display_titles, $display_price, esc_attr($heading), $with_borders, $with_effect, $no_top_border, $no_bottom_border);
         } elseif ($content_type == "product_carousel") {
             /*
             //[product_carousel id="" heading="" heading_icon="" item_width="5" list_orderby="" list_order="" max_item="9" categories="" product_ids=""]
             */
             extract($values);
             $crop = isset($crop) ? $crop : "";
             $product_carousel_id = 'product-carousel-' . str_replace("templateid_", "", $templateID) . '-' . $group_id . '';
             $categories = isset($categories) && is_array($categories) ? implode($categories, ",") : "";
             $template_output .= sprintf('[product_carousel id="%s" crop="%s" style="%s" heading="%s" heading_icon="%s" item_width="%s" list_orderby="%s" list_order="%s" max_item="%s" categories="%s" product_ids="%s"]', $product_carousel_id, $crop, $style, $heading, $heading_icon, $item_width, $list_orderby, $list_order, $max_item, $categories, "");
         } elseif ($content_type == "google_map") {
             /*
             //[google_maps map_id="" title="" height=""]
             	[location title="" lat="" lon=""]text[/location] 
             [/google_maps]  
             */
             $map_id = 'map-' . str_replace("templateid_", "", $templateID) . '-' . $group_id . '';
             //css for the map
             $css_output["css_codes"] = $css_output["css_codes"] . sprintf("#%s{height:%spx}", $map_id, $height);
             $coords_output = "";
             foreach ($list["geo"] as $key => $options) {
                 if (!empty($list["geo"][$key])) {
                     $geo = explode(",", $list["geo"][$key]);
                     $location_text = !empty($list["text"][$key]) ? $list["text"][$key] : "";
                     $location_title = !empty($list["title"][$key]) ? $list["title"][$key] : "";
                     $coords_output .= sprintf('[location title="%s" lat="%s" lon="%s"]%s[/location]', strip_tags($location_title), $geo[0], $geo[1], stripslashes($location_text));
                 }
             }
             $template_output .= !empty($coords_output) ? sprintf('[google_maps map_id="%s" height="%s" zoom="%s" title="%s" template_builder="true"]%s[/google_maps]', $map_id, $height, $zoom, strip_tags($module_title), $coords_output) : "";
         } elseif ($content_type == "contact_form") {
             /*
             //[contact_form title="" email="" text=""] 
             */
             if (empty($shortcode)) {
                 $template_output .= sprintf('[contact_form title="%s" email="%s"]%s[/contact_form] ', $title, $email, stripslashes($text));
             } else {
                 $template_output .= stripslashes($shortcode);
             }
         } elseif ($content_type == "banner_box") {
             /*
             //[banner_box id="" text_icon="" text_alignment="" button_text="" button_icon="" button_link="" button_size="" link_target=""]text[/banner_box]
             */
             $banner_id = 'banner-' . str_replace("templateid_", "", $templateID) . '-' . $group_id . '';
             $gradient = isset($gradient) ? $gradient : "";
             $border = isset($border) ? $border : "";
             extract($values);
             if (!empty($text)) {
                 $template_output .= sprintf('[banner id="%s" gradient="%s" border="%s" text_icon="%s" text_alignment="%s" button_text="%s" button_icon="%s" button_link="%s" button_size="%s" link_target="%s"]%s[/banner]', $banner_id, $gradient, $border, $text_icon, $text_alignment, strip_tags($button_text), $button_icon, $button_link, $button_size, $link_target, stripslashes($text));
             }
             $border = $gradient = "";
         } elseif ($content_type == "code_box") {
             /*
             //[code_box box_id="" heading=""]code_space[/code_box]
             */
             $box_id = 'code-box-' . str_replace("templateid_", "", $templateID) . '-' . $group_id . '';
             $template_output .= sprintf('[code_box box_id="%s" heading="%s"]%s[/code_box]', $box_id, strip_tags($heading), stripslashes($code_space));
         } elseif ($content_type == "sidebar_box") {
             /*
             //[sidebar_box sidebar_id="sidebar-for-footer-column-4" widget_box_width="4"]
             */
             if ($footer_started) {
                 $location = "footer";
             } else {
                 $location = "default";
             }
             $template_output .= sprintf('[sidebar_box sidebar_id="%s" widget_box_width="%s" location="%s"]', $sidebar_id, $widget_box_width, $location);
         } elseif ($content_type == "staff_box") {
             /*
             //[staff_box id="" item_width="5" list_orderby="" list_order="" ids=""]
             */
             $ids = $staff_box_id = $item_width = $list_orderby = $list_order = $style = $staff_ids = "";
             extract($values);
             $staff_box_id = 'staff-list-' . str_replace("templateid_", "", $templateID) . '-' . $group_id . '';
             $staff_ids = isset($ids) && is_array($ids) ? implode($ids, ",") : "";
             $template_output .= sprintf('[staff_box id="%s" item_width="%s" list_orderby="%s" list_order="%s" style="%s" ids="%s"]', $staff_box_id, $item_width, $list_orderby, $list_order, $style, $staff_ids);
         } elseif ($content_type == "testimonial_box") {
             /*
             //[testimonial_box id="" item_width="5" list_orderby="" list_order="" ids=""]
             */
             $ids = $testimonial_box_id = $item_width = $list_orderby = $list_order = $style = $testimonial_ids = "";
             extract($values);
             $testimonial_box_id = 'testimonials-' . str_replace("templateid_", "", $templateID) . '-' . $group_id . '';
             $testimonial_ids = isset($ids) && is_array($ids) ? implode($ids, ",") : "";
             $template_output .= sprintf('[testimonial_box id="%s" item_width="%s" list_orderby="%s" list_order="%s" style="%s" ids="%s"]', $testimonial_box_id, $item_width, $list_orderby, $list_order, $style, $testimonial_ids);
         } elseif ($content_type == "testimonial_carousel") {
             /*
             //[testimonial_carousel id="" heading="" heading_icon="" item_width="5" list_orderby="" list_order="" ids=""]
             */
             $ids = $testimonial_box_id = $heading = $heading_icon = $item_width = $list_orderby = $list_order = $testimonial_ids = $style = "";
             extract($values);
             $testimonial_box_id = 'testimonial-carousel-' . str_replace("templateid_", "", $templateID) . '-' . $group_id . '';
             $testimonial_ids = isset($ids) && is_array($ids) ? implode($ids, ",") : "";
             $template_output .= sprintf('[testimonial_carousel id="%s" heading="%s" heading_icon="%s" item_width="%s" list_orderby="%s" list_order="%s" ids="%s" style="%s"]', $testimonial_box_id, $heading, $heading_icon, $item_width, $list_orderby, $list_order, $testimonial_ids, $style);
         } elseif ($content_type == "woo_products_box") {
             /*
             //[product_category category="" per_page="12" columns="4" orderby="date" order="desc"]
             */
             $template_output .= sprintf('[product_category category="%s" per_page="%s" columns="%s" orderby="%s" order="%s"]', $categories, $item_per_page, $item_width, $list_orderby, $list_order);
         } elseif ($content_type == "layerslider_box") {
             /*
             //[layerslider id="1"]
             */
             $template_output .= sprintf('[layerslider id="%s"]', $slider_id);
         } elseif ($content_type == "revslider_box") {
             /*
             //[rev_slider aliasname]
             */
             $template_output .= sprintf('[rev_slider %s]', $slider_id);
         } elseif ($content_type == "space_box") {
             /*
             //[space_box id=""]
             */
             $space_id = 'space-' . str_replace("templateid_", "", $templateID) . '-' . $group_id . '';
             //css for the map
             $css_output["css_codes"] = $css_output["css_codes"] . sprintf("#%s{height:%spx}", $space_id, $height);
             $template_output .= !empty($height) ? sprintf('[space_box id="%s" height="%s"]', $space_id, $height) : "";
         } elseif ($content_type == "v_chained_icon_box") {
             /*
             //[v_icon_boxes id="" icon_align=""]
             					[v_icon_box icon="" title="" link="" link_target=""][/v_icon_box]
             [/v_icon_boxes]
             */
             $v_icon_box_id = 'v-icon-box-' . str_replace("templateid_", "", $templateID) . '-' . $group_id . '';
             $v_icon_box_output = "";
             foreach ($box_contents["icon"] as $key => $options) {
                 $v_icon_box_title = !empty($box_contents["caption"][$key]) ? htmlspecialchars($box_contents["caption"][$key]) : "";
                 $v_icon_box_text = !empty($box_contents["text"][$key]) ? $box_contents["text"][$key] : "";
                 $v_icon_box_icon = !empty($box_contents["icon"][$key]) ? htmlspecialchars($box_contents["icon"][$key]) : "";
                 $v_icon_box_link = !empty($box_contents["link"][$key]) ? htmlspecialchars($box_contents["link"][$key]) : "";
                 $v_icon_box_link_target = !empty($box_contents["link_target"][$key]) ? $box_contents["link_target"][$key] : "";
                 $v_icon_box_output .= !empty($v_icon_box_icon) ? '[v_icon_box icon="' . $v_icon_box_icon . '" title="' . $v_icon_box_title . '" link="' . $v_icon_box_link . '" link_target="' . $v_icon_box_link_target . '"]' . $v_icon_box_text . '[/v_icon_box]' : "";
             }
             $v_icon_box_output = '[v_icon_boxes id="' . $v_icon_box_id . '" icon_align="' . $media_alignment . '"]' . stripslashes($v_icon_box_output) . '[/v_icon_boxes]';
             //add to the template output
             $template_output .= $v_icon_box_output;
         } elseif ($content_type == "v_chained_image_box") {
             /*
             //[v_media_boxes id="" media_align="" media_stlye=""]
             					[v_media_box image="" title="" link="" link_target=""][/v_media_box]
             [/v_media_boxes]
             */
             $v_image_box_id = 'v-image-box-' . str_replace("templateid_", "", $templateID) . '-' . $group_id . '';
             $v_image_box_output = "";
             foreach ($box_contents["image"] as $key => $options) {
                 $v_image_box_title = !empty($box_contents["caption"][$key]) ? htmlspecialchars($box_contents["caption"][$key]) : "";
                 $v_image_box_text = !empty($box_contents["text"][$key]) ? $box_contents["text"][$key] : "";
                 $v_image_box_image = !empty($box_contents["image"][$key]) ? htmlspecialchars($box_contents["image"][$key]) : "";
                 $v_image_box_link = !empty($box_contents["link"][$key]) ? htmlspecialchars($box_contents["link"][$key]) : "";
                 $v_image_box_link_target = !empty($box_contents["link_target"][$key]) ? $box_contents["link_target"][$key] : "";
                 $v_image_box_output .= !empty($v_image_box_image) ? '[v_media_box image="' . $v_image_box_image . '" title="' . $v_image_box_title . '" link="' . $v_image_box_link . '" link_target="' . $v_image_box_link_target . '"]' . $v_image_box_text . '[/v_media_box]' : "";
             }
             $v_image_box_output = '[v_media_boxes id="' . $v_image_box_id . '" image_align="' . $media_alignment . '" image_style="' . $media_style . '" bw_filter="' . $bw_filter . '" ]' . stripslashes($v_image_box_output) . '[/v_media_boxes]';
             //add to the template output
             $template_output .= $v_image_box_output;
         } elseif ($content_type == "h_chained_image_box") {
             /*
             //[h_chained_contents id="" image_style="" bw_filter=""]
             					[h_content image="" title="" link="" link_target=""][/h_content]
             [/h_chained_contents]
             */
             $h_image_box_id = 'v-icon-box-' . str_replace("templateid_", "", $templateID) . '-' . $group_id . '';
             $h_image_box_output = "";
             foreach ($box_contents["image"] as $key => $options) {
                 $h_image_box_title = !empty($box_contents["caption"][$key]) ? htmlspecialchars($box_contents["caption"][$key]) : "";
                 $h_image_box_text = !empty($box_contents["text"][$key]) ? $box_contents["text"][$key] : "";
                 $h_image_box_image = !empty($box_contents["image"][$key]) ? htmlspecialchars($box_contents["image"][$key]) : "";
                 $h_image_box_link = !empty($box_contents["link"][$key]) ? htmlspecialchars($box_contents["link"][$key]) : "";
                 $h_image_box_link_target = !empty($box_contents["link_target"][$key]) ? $box_contents["link_target"][$key] : "";
                 $h_image_box_output .= !empty($h_image_box_image) ? '[h_content image="' . $h_image_box_image . '" title="' . $h_image_box_title . '" link="' . $h_image_box_link . '" link_target="' . $h_image_box_link_target . '"]' . $h_image_box_text . '[/h_content]' : "";
             }
             $h_image_box_output = '[h_chained_contents id="' . $h_image_box_id . '" image_style="' . $media_style . '" bw_filter="' . $bw_filter . '" ]' . stripslashes($h_image_box_output) . '[/h_chained_contents]';
             //add to the template output
             $template_output .= $h_image_box_output;
         } else {
             $template_output .= rt_generate_shortcode($template);
         }
         //close column holder for other elements than a column
         if (!$header_purpose && empty($columns_started) && $content_type != "column" && $content_type != "grid" && $content_type != "slider_box" && $content_type != "space_box") {
             $template_output .= "[/rt_columns]";
         }
     }
     return array('header' => $header_output, 'footer' => $footer_output, 'content' => $template_output, 'css' => $css_output, "template_options" => $template_options);
 }