Guest User

Untitled

a guest
Feb 11th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.27 KB | None | 0 0
  1. function nectar_slider_display($config_arr){
  2. global $nectar_disable_nectar_slider;
  3.  
  4. if($nectar_disable_nectar_slider == true) {
  5. echo __('Nectar Slider Post Type Disabled - please reanble in the Salient options panel > General Settings > Toggle Theme Features tab.', NECTAR_THEME_NAME);
  6. return false;
  7. }
  8.  
  9. global $post;
  10. global $options;
  11. global $real_fs;
  12.  
  13. $midnight_parallax = null;
  14. $midnight_regular = null;
  15.  
  16. //disable parallax for full page
  17. $page_full_screen_rows = (isset($post->ID)) ? get_post_meta($post->ID, '_nectar_full_screen_rows', true) : '';
  18. if($page_full_screen_rows == "on")
  19. $config_arr['parallax'] = 'false';
  20.  
  21. $animate_in_effect = (!empty($options['header-animate-in-effect'])) ? $options['header-animate-in-effect'] : 'none';
  22.  
  23. //adding parallax wrapper if selected
  24. if($config_arr['parallax'] == 'true') {
  25.  
  26. if( stripos( $post->post_content, '[nectar_slider') !== FALSE && stripos( $post->post_content, '[nectar_slider') === 0 && $real_fs == 0) { $first_section = 'first-section'; $real_fs = 1; } else { $first_section = ''; }
  27.  
  28. $midnight_parallax = 'data-midnight="nectar-slider"';
  29. $midnight_regular = null;
  30.  
  31. $slider = '<div style="height: '.$config_arr['slider_height'].'px" '.$midnight_parallax.' class="parallax_slider_outer '.$first_section.'">';
  32.  
  33. } else { $slider = ''; }
  34.  
  35. $boxed = (!empty($options['boxed_layout']) && $options['boxed_layout'] == '1') ? '1' : '0';
  36. if($config_arr['full_width'] == 'true' && $boxed != '1') { $fullwidth = 'true'; }
  37. else if($config_arr['full_width'] == 'true' && $boxed == '1') { $fullwidth = 'boxed-full-width'; }
  38. else { $fullwidth = 'false'; }
  39.  
  40. if($config_arr['parallax'] != 'true') {
  41. if( stripos( $post->post_content, '[nectar_slider') !== FALSE && stripos( $post->post_content, '[nectar_slider') === 0 && $real_fs == 0) { $first_section = 'first-section'; $real_fs = 1; $midnight_parallax = null; $midnight_regular = 'data-midnight="nectar-slider"'; } else { $first_section = ''; }
  42. } else {
  43. $midnight_parallax = null;
  44. $midnight_regular = null;
  45. $first_section = '';
  46. }
  47.  
  48. $text_overrides = null;
  49. if(!empty($config_arr['tablet_header_font_size'])) {
  50. $text_overrides .= ' data-tho="'.$config_arr['tablet_header_font_size'].'"';
  51. }
  52. if(!empty($config_arr['tablet_caption_font_size'])) {
  53. $text_overrides .= ' data-tco="'.$config_arr['tablet_caption_font_size'].'"';
  54. }
  55. if(!empty($config_arr['phone_header_font_size'])) {
  56. $text_overrides .= ' data-pho="'.$config_arr['phone_header_font_size'].'"';
  57. }
  58. if(!empty($config_arr['phone_caption_font_size'])) {
  59. $text_overrides .= ' data-pco="'.$config_arr['phone_caption_font_size'].'"';
  60. }
  61.  
  62. $slider .= '<div style="height: '.$config_arr['slider_height'].'px" '.$midnight_regular.' data-transition="'.$config_arr['slider_transition'].'" data-overall_style="'.$config_arr['overall_style'].'" data-flexible-height="'.$config_arr['flexible_slider_height'].'" data-animate-in-effect="'.$animate_in_effect.'" data-fullscreen="'.$config_arr['fullscreen'].'" data-button-sizing="'.$config_arr['button_sizing'].'" data-button-styling="'.$config_arr['slider_button_styling'].'" data-autorotate="'.$config_arr['autorotate'].'" data-parallax="'.$config_arr['parallax'].'" data-full-width="'.$fullwidth.'" class="nectar-slider-wrap '.$first_section.'" id="ns-id-'.uniqid().'">
  63. <div style="height: '.$config_arr['slider_height'].'px" class="swiper-container" '.$text_overrides.' data-loop="'.$config_arr['loop'].'" data-height="'. $config_arr["slider_height"] .'" data-min-height="'.$config_arr['min_slider_height'].'" data-arrows="' . $config_arr["arrow_navigation"].'" data-bullets="'.$config_arr["bullet_navigation"].'" data-bullet_style="'.$config_arr["bullet_navigation_style"].'" data-desktop-swipe="'. $config_arr["desktop_swipe"].'" data-settings="">
  64. <div class="swiper-wrapper">';
  65.  
  66. $slide_count = 0;
  67.  
  68. //get slider location by slug instead of raw name
  69. $slider_terms = get_term_by('name',$config_arr['location'],'slider-locations');
  70.  
  71. //loop through and get all the slides in selected location
  72. $slides = new WP_Query( array( 'post_type' => 'nectar_slider', 'tax_query' => array( array( 'taxonomy' => 'slider-locations', 'field' => 'slug', 'terms' => $slider_terms->slug ) ), 'posts_per_page' => -1, 'order' => 'ASC', 'orderby' => 'menu_order' ) );
  73.  
  74. if( $slides->have_posts() ) : while( $slides->have_posts() ) : $slides->the_post();
  75.  
  76. global $post;
  77.  
  78. $background_type = get_post_meta($post->ID, '_nectar_slider_bg_type', true);
  79. $background_alignment = get_post_meta($post->ID, '_nectar_slider_slide_bg_alignment', true);
  80.  
  81. $slide_title = get_post_meta($post->ID, '_nectar_slider_heading', true);
  82.  
  83. $slide_description = get_post_meta($post->ID, '_nectar_slider_caption', true);
  84. $slide_description_wrapped = '<span>'.$slide_description.'</span>';
  85. $slide_description_bg = get_post_meta($post->ID, '_nectar_slider_caption_background', true);
  86. $caption_bg = ( $slide_description_bg == 'on') ? 'class="transparent-bg"' : '';
  87.  
  88. $down_arrow = get_post_meta($post->ID, '_nectar_slider_down_arrow', true);
  89.  
  90. $poster = get_post_meta($post->ID, '_nectar_slider_preview_image', true);
  91. $poster_markup = (!empty($poster)) ? 'poster="'.$poster.'"' : null ;
  92.  
  93. $x_pos = get_post_meta($post->ID, '_nectar_slide_xpos_alignment', true);
  94. $y_pos = get_post_meta($post->ID, '_nectar_slide_ypos_alignment', true);
  95.  
  96. $link_type = get_post_meta($post->ID, '_nectar_slider_link_type', true);
  97.  
  98. $full_slide_link = get_post_meta($post->ID, '_nectar_slider_entire_link', true);
  99.  
  100. $button_1_text = get_post_meta($post->ID, '_nectar_slider_button', true);
  101. $button_1_link = get_post_meta($post->ID, '_nectar_slider_button_url', true);
  102. $button_1_style = get_post_meta($post->ID, '_nectar_slider_button_style', true);
  103. $button_1_color = get_post_meta($post->ID, '_nectar_slider_button_color', true);
  104.  
  105. $button_2_text = get_post_meta($post->ID, '_nectar_slider_button_2', true);
  106. $button_2_link = get_post_meta($post->ID, '_nectar_slider_button_url_2', true);
  107. $button_2_style = get_post_meta($post->ID, '_nectar_slider_button_style_2', true);
  108. $button_2_color = get_post_meta($post->ID, '_nectar_slider_button_color_2', true);
  109.  
  110. $video_mp4 = get_post_meta($post->ID, '_nectar_media_upload_mp4', true);
  111. $video_webm = get_post_meta($post->ID, '_nectar_media_upload_webm', true);
  112. $video_ogv = get_post_meta($post->ID, '_nectar_media_upload_ogv', true);
  113. $video_texture = get_post_meta($post->ID, '_nectar_slider_video_texture', true);
  114.  
  115. $slide_image = get_post_meta($post->ID, '_nectar_slider_image', true);
  116. $img_bg = null;
  117.  
  118. $slide_color = get_post_meta($post->ID, '_nectar_slider_slide_font_color', true);
  119.  
  120. $custom_class = get_post_meta($post->ID, '_nectar_slider_slide_custom_class', true);
  121. $custom_css_class = (!empty($custom_class)) ? ' '.$custom_class : null;
  122.  
  123. if($background_type == 'image_bg') { $bg_img_markup = 'style="background-image: url('. nectar_ssl_check($slide_image).');"'; } else { $bg_img_markup = null;}
  124.  
  125. (!empty($x_pos)) ? $x_pos_markup = $x_pos : $x_pos_markup = 'center';
  126. (!empty($y_pos)) ? $y_pos_markup = $y_pos : $y_pos_markup = 'middle';
  127.  
  128.  
  129. $slider .= '<div class="swiper-slide'.$custom_css_class.'" data-bg-alignment="'.$background_alignment.'" data-color-scheme="'. $slide_color .'" data-x-pos="'.$x_pos_markup.'" data-y-pos="'.$y_pos_markup.'">
  130. ';
  131.  
  132. if($background_type == 'image_bg') $slider .='<div class="image-bg" '.$bg_img_markup.'> &nbsp; </div>';
  133.  
  134. if(!empty($slide_title) || !empty($slide_description) || !empty($button_1_text) || !empty($button_2_text)) {
  135.  
  136. $slider .= '<div class="container">
  137. <div class="content">';
  138.  
  139. if(!empty($slide_title)) { $slider .= '<h2>'.$slide_title.'</h2>'; }
  140. if(!empty($slide_description)) { $slider .= '<p '. $caption_bg.' >'. $slide_description_wrapped.'</p>'; }
  141.  
  142.  
  143. if($link_type == 'button_links' && !empty($button_1_text) || $link_type == 'button_links' && !empty($button_2_text)) {
  144. $slider .= '<div class="buttons">';
  145.  
  146. if(!empty($button_1_text)) {
  147.  
  148. $button_1_link = !empty($button_1_link) ? $button_1_link : '#';
  149.  
  150. //check button link to see if it's a video or googlemap
  151. $link_extra = null;
  152.  
  153. if(strpos($button_1_link, 'youtube.com/watch') !== false) $link_extra = 'pp ';
  154. if(strpos($button_1_link, 'vimeo.com/') !== false) $link_extra = 'pp ';
  155. if(strpos($button_1_link, 'maps.google.com/maps') !== false) $link_extra = 'map-popup ';
  156.  
  157. //wrapper for tilt button
  158. $button_wrap_begin = ($button_1_style == 'solid_color_2') ? "<div class='button-wrap'>": null;
  159. $button_wrap_end = ($button_1_style == 'solid_color_2') ? "</div>": null;
  160.  
  161. $slider .=
  162. '<div class="button '.$button_1_style.'">
  163. '.$button_wrap_begin .' <a class="'.$link_extra .$button_1_color .'" href="'.$button_1_link.'">'.$button_1_text.'</a>'. $button_wrap_end.'
  164. </div>';
  165. }
  166.  
  167.  
  168. if(!empty($button_2_text)) {
  169.  
  170. $button_2_link = !empty($button_2_link) ? $button_2_link : '#';
  171.  
  172. //check button link to see if it's a video or googlemap
  173. $link_extra = null;
  174.  
  175. if(strpos($button_2_link, 'youtube.com/watch') !== false) $link_extra = 'pp ';
  176. if(strpos($button_2_link, 'vimeo.com/') !== false) $link_extra = 'pp ';
  177. if(strpos($button_2_link, 'maps.google.com/maps') !== false) $link_extra = 'map-popup ';
  178.  
  179. $slider .=
  180. '<div class="button '.$button_2_style.'">
  181. <a class="'.$link_extra . $button_2_color .'" href="'.$button_2_link.'">'.$button_2_text.'</a>
  182. </div>';
  183. }
  184.  
  185. $slider .= '</div>';
  186. }
  187.  
  188. $slider .= '</div>
  189. </div><!--/container-->';
  190.  
  191. }
  192.  
  193. if(!empty($down_arrow) && $down_arrow == 'on') {
  194.  
  195. $header_down_arrow_style = (!empty($options['header-down-arrow-style'])) ? $options['header-down-arrow-style'] : 'default';
  196. $theme_button_styling = (!empty($options['button-styling'])) ? $options['button-styling'] : 'default';
  197.  
  198. if($header_down_arrow_style == 'scroll-animation' || $theme_button_styling == 'slightly_rounded' || $theme_button_styling == 'slightly_rounded_shadow') {
  199. $slider .= '<a href="#" class="slider-down-arrow no-border"><svg class="nectar-scroll-icon" viewBox="0 0 30 45" enable-background="new 0 0 30 45">
  200. <path class="nectar-scroll-icon-path" fill="none" stroke="#ffffff" stroke-width="2" stroke-miterlimit="10" d="M15,1.118c12.352,0,13.967,12.88,13.967,12.88v18.76 c0,0-1.514,11.204-13.967,11.204S0.931,32.966,0.931,32.966V14.05C0.931,14.05,2.648,1.118,15,1.118z"></path>
  201. </svg></a>';
  202. } else {
  203.  
  204. $slider .= '<a href="#" class="slider-down-arrow"><i class="icon-salient-down-arrow icon-default-style"> <span class="ie-fix"></span> </i></a>';
  205. }
  206. }
  207.  
  208.  
  209. $active_texture = ($video_texture == 'on') ? 'active_texture' : '';
  210. $slider .= '<div class="video-texture '.$active_texture.'"> <span class="ie-fix"></span> </div>';
  211.  
  212. if($background_type == 'video_bg') {
  213.  
  214. $slider .= '
  215.  
  216. <div class="mobile-video-image" style="background-image: url('.$poster.')"> <span class="ie-fix"></span> </div>
  217. <div class="video-wrap">
  218.  
  219.  
  220. <video class="slider-video" width="1800" height="700" preload="auto" loop>';
  221.  
  222. if(!empty($video_webm)) { $slider .= '<source type="video/webm" src="'.$video_webm.'">'; }
  223. if(!empty($video_mp4)) { $slider .= '<source type="video/mp4" src="'.$video_mp4.'">'; }
  224. if(!empty($video_ogv)) { $slider .= '<source type="video/ogg" src="'. $video_ogv.'">'; }
  225.  
  226. $slider .='</video>
  227.  
  228.  
  229. </div>';
  230.  
  231. }
  232.  
  233. if($link_type == 'full_slide_link' && !empty($full_slide_link)) {
  234. $slider .= '<a href="'. $full_slide_link.'" class="entire-slide-link"> <span class="ie-fix"></span> </a>';
  235. }
  236.  
  237. $slider .= '</div><!--/swiper-slide-->';
  238.  
  239. $slide_count ++;
  240.  
  241. endwhile; endif;
  242.  
  243. wp_reset_postdata();
  244.  
  245. $slider .= '</div>';
  246.  
  247. if($config_arr['arrow_navigation'] == 'true' && $slide_count > 1 && $config_arr['slider_button_styling'] != 'btn_with_preview' && $config_arr['overall_style'] != 'directional') {
  248.  
  249. $slider .= '<a href="" class="slider-prev"><i class="icon-salient-left-arrow"></i> <div class="slide-count"> <span class="slide-current">1</span> <i class="icon-salient-right-line"></i> <span class="slide-total"></span> </div> </a>
  250. <a href="" class="slider-next"><i class="icon-salient-right-arrow"></i> <div class="slide-count"> <span class="slide-current">1</span> <i class="icon-salient-right-line"></i> <span class="slide-total"></span> </div> </a>';
  251. }
  252.  
  253. else if($config_arr['arrow_navigation'] == 'true' && $slide_count > 1 && $config_arr['slider_button_styling'] == 'btn_with_preview' || $config_arr['overall_style'] == 'directional') {
  254. $slider .= '<a href="" class="slider-prev"><i class="icon-angle-left"></i> </a>
  255. <a href="" class="slider-next"><i class="icon-angle-right"></i> </a>';
  256. }
  257.  
  258. if($config_arr['bullet_navigation'] == 'true' && $slide_count > 1){
  259. $slider .= '<div class="slider-pagination"></div>';
  260. }
  261.  
  262. $loading_animation = (!empty($options['loading-image-animation']) && !empty($options['loading-image'])) ? $options['loading-image-animation'] : null;
  263. $default_loader = (empty($options['loading-image']) && !empty($options['theme-skin']) && $options['theme-skin'] == 'ascend') ? '<span class="default-loading-icon spin"></span>' : null;
  264. $default_loader_class = (empty($options['loading-image']) && !empty($options['theme-skin']) && $options['theme-skin'] == 'ascend') ? 'default-loader' : null;
  265. $slider .= '<div class="nectar-slider-loading '.$default_loader_class.'"> <span class="loading-icon '.$loading_animation.'"> '.$default_loader.' </span> </div> </div>
  266.  
  267. </div>';
  268.  
  269. if($config_arr['parallax'] == 'true') { $slider .= '</div>'; }
  270.  
  271. return $slider;
  272.  
  273. }
Advertisement
Add Comment
Please, Sign In to add comment