function new_section($params = array()) { $defaults = array('class' => 'main_color', 'bg' => '', 'close' => true, 'open' => true, 'open_structure' => true, 'open_color_wrap' => true, 'data' => '', "style" => '', 'id' => ""); extract(array_merge($defaults, $params)); $post_class = ""; $output = ""; if ($id) { $id = "id='{$id}'"; } //close old if ($close) { if (cadr_section_class('wrap')) { //$output .= '</div></div></div></div></div></div>'; $output .= '</div></div></div></div></div></div></div>'; } else { $output .= '</div></div></div></div>'; } } //start new if ($open) { global $post; if (isset($post->ID)) { $ID = $post->ID; $config['real_ID'] = $ID; } else { $post = get_post(); $ID = $post->ID; } $post_class = "post-entry-" . $ID; if ($open_color_wrap) { $output .= "<div {$id} class='{$class}' {$bg} {$data} {$style}>"; } if ($open_structure) { $main_class = cadr_section_class('main'); $output .= "<div class='wrap container'>"; $output .= "<div class='content row'>"; //$output .= "<div class='post-entry post-entry-type-page {$post_class}'>"; $output .= "<div class='main {$main_class}'>"; } } return $output; }
/** * Render the widget in frontend * * @param array $args * @param array $instance * @return string */ function get_widget($args, $instance) { extract(wp_parse_args($instance, array('link' => '', 'link_target' => '', 'caption_title' => '', 'caption_text' => '', 'size' => '', 'size_option' => '1', 'width' => '', 'interval' => '5000'))); if (is_admin()) { return "<center><i class='icon-youtube-play icon-4x'></i></center>"; } $output = ""; $class = ""; if ($size_option == '1') { if (cadr_section_class('wrap')) { $output .= "</div></div></div></div></div></div></div></div></div></div>"; } else { $output .= "</div></div></div></div></div></div>"; } } $use_width = ''; if ($size_option == '0') { //check how large the slider is and change the classname accordingly global $_wp_additional_image_sizes; $_wp_additional_image_sizes = get_registered_image_sizes(array('thumbnail', 'logo', 'widget', 'slider_thumb'), true); $width = 1500; if (isset($_wp_additional_image_sizes[$size]['width'])) { $width = $_wp_additional_image_sizes[$size]['width']; } else { if ($size = get_option($size . '_size_w')) { $width = $size; } } if ($width < 600) { $class = " small-width-slider"; } if ($width < 305) { $class = " super-small-width-slider"; } //$use_width = "style='width:{$width}px'"; $use_width = ""; } //$size = $size_option == '1'?'full':$size; $id = "carousel-slide-" . rand(); $output .= "\n <div id='{$id}' class='carousel slide slideshow-{$size} {$class}' {$use_width}>\n <!-- Indicators -->\n <ol class='carousel-indicators'>\n "; $i = 0; foreach ($slides as $key => $value) { $active = $i == 0 ? "class='active'" : ''; $use_link_target = isset($link_target[$key]) && !empty($link_target[$key]) ? "target='" . $link_target[$key] . "'" : ''; //$use_link = isset($link[$key]) && is_array($link[$key])?get_url($link[$key]):'#'; $output .= "<li data-target='#{$id}' data-slide-to='{$i}' {$use_link_target} {$active}></li>"; $i++; } $output .= "\n </ol>\n\n <!-- Wrapper for slides -->\n <div class='carousel-inner'>\n "; $i = 0; //print_r($size); foreach ($slides as $key => $value) { $active = $i == 0 ? "active" : ''; $use_image = ""; if (isset($image[$key]) && is_array($image[$key])) { $img = wp_get_attachment_image_src($image[$key]['id'], $size); $img_title = isset($caption_title[$key]) && !empty($caption_title[$key]) ? "{$caption_title[$key]}" : ""; $use_image = "<img src='{$img[0]}' alt='{$img_title}' width='{$img[1]}' height='{$img[2]}' />"; } //$use_image = isset($image[$key]['url']) && !empty($image[$key]['url'])?"<img alt='' src='".$image[$key]['url']."' />":''; $use_caption_title = isset($caption_title[$key]) && !empty($caption_title[$key]) ? "<h3>{$caption_title[$key]}</h3>" : ""; $use_caption_text = isset($caption_text[$key]) && !empty($caption_text[$key]) ? "<p>{$caption_text[$key]}</p>" : ""; $output .= "\n <div class='item {$active}'>\n {$use_image}\n <div class='carousel-caption'>\n {$use_caption_title}\n {$use_caption_text}\n </div>\n </div>\n "; $i++; } $output .= "\n </div>\n\n <!-- Controls -->\n <a class='left carousel-control' href='#{$id}' data-slide='prev'>\n <span class='icon-prev'></span>\n </a>\n <a class='right carousel-control' href='#{$id}' data-slide='next'>\n <span class='icon-next'></span>\n </a>\n </div> \n "; $use_interval = $interval == 'false' ? 'false' : $interval * 1000; $output .= "\n <script>\n !function (\$) {\n \$(function(){\n \$('#{$id}').carousel({interval: {$use_interval} });\n });\n }(window.jQuery)\n </script>\n "; if ($size_option == '1') { $output .= new_section(array('open_structure' => true, 'open_color_wrap' => false, 'close' => false, 'id' => "after_full_slider")); $output .= "<div><div>"; ?> <script type="text/javascript"> jQuery( document ).ready(function(){ jQuery('.slideshow-full_width').css({'width':jQuery( 'body' ).width()}); }); </script> <?php } return $output; }