PageRenderTime 47ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/themes/salient/nectar/nectar-vc-addons/vc_templates/full_width_section.php

https://bitbucket.org/babinkochana/triptrills
PHP | 199 lines | 142 code | 50 blank | 7 comment | 56 complexity | 8ac899827c248e1cfc9c44f6c8856866 MD5 | raw file
Possible License(s): MIT, Apache-2.0, GPL-3.0, 0BSD, GPL-2.0
  1. <?php
  2. extract(shortcode_atts(array(
  3. "type" => 'full_width_background',
  4. 'image_url'=> '',
  5. 'bg_pos'=> '',
  6. 'bg_repeat' => '',
  7. 'parallax_bg' => '',
  8. 'background_color'=> '',
  9. 'exclude_row_header_color_inherit' => '',
  10. 'text_align'=> '',
  11. 'vertically_center_columns' => '',
  12. 'video_bg'=> '',
  13. 'enable_video_color_overlay'=> '',
  14. 'video_overlay_color'=> '',
  15. 'video_webm'=> '',
  16. 'video_mp4'=> '',
  17. 'video_ogv'=> '',
  18. 'video_image'=> '',
  19. "top_padding" => "40",
  20. "bottom_padding" => "40",
  21. 'text_color' => 'light',
  22. 'custom_text_color' => '',
  23. 'row_name' => '',
  24. 'full_screen_row_position' => 'middle',
  25. 'class' => ''),
  26. $atts));
  27. wp_enqueue_style( 'js_composer_front' );
  28. wp_enqueue_script( 'wpb_composer_front_js' );
  29. wp_enqueue_style('js_composer_custom_css');
  30. $style = null;
  31. $etxra_class = null;
  32. $bg_props = null;
  33. $using_image_class = null;
  34. $using_bg_color_class = null;
  35. $using_custom_text_color = null;
  36. if(!empty($image_url)) {
  37. if(!preg_match('/^\d+$/',$image_url)){
  38. $bg_props .= 'background-image: url('. $image_url . '); ';
  39. $bg_props .= 'background-position: '. $bg_pos .'; ';
  40. } else {
  41. $bg_image_src = wp_get_attachment_image_src($image_url, 'full');
  42. $bg_props .= 'background-image: url('. $bg_image_src[0]. '); ';
  43. $bg_props .= 'background-position: '. $bg_pos .'; ';
  44. }
  45. //for pattern bgs
  46. if(strtolower($bg_repeat) == 'repeat'){
  47. $bg_props .= 'background-repeat: '. strtolower($bg_repeat) .'; ';
  48. $etxra_class = 'no-cover';
  49. } else {
  50. $bg_props .= 'background-repeat: '. strtolower($bg_repeat) .'; ';
  51. $etxra_class = null;
  52. }
  53. $using_image_class = 'using-image';
  54. }
  55. if(!empty($background_color)) {
  56. $bg_props .= 'background-color: '. $background_color.'; ';
  57. if($exclude_row_header_color_inherit != 'true') $using_bg_color_class = 'using-bg-color';
  58. }
  59. if(strtolower($parallax_bg) == 'true'){
  60. $parallax_class = 'parallax_section';
  61. } else {
  62. $parallax_class = 'standard_section';
  63. }
  64. if(strtolower($vertically_center_columns) == 'true'){
  65. $vertically_center_class = 'vertically-align-columns';
  66. } else {
  67. $vertically_center_class = null;
  68. }
  69. global $post;
  70. $page_full_screen_rows = (isset($post->ID)) ? get_post_meta($post->ID, '_nectar_full_screen_rows', true) : '';
  71. if($page_full_screen_rows != 'on') {
  72. $style .= 'padding-top: '. $top_padding .'px; ';
  73. $style .= 'padding-bottom: '. $bottom_padding .'px; ';
  74. }
  75. if(!empty($custom_text_color)) {
  76. $style .= 'color: '. $custom_text_color .'; ';
  77. $using_custom_text_color = 'data-using-ctc="true"';
  78. }
  79. //main class
  80. if($type == 'in_container') {
  81. $main_class = "";
  82. } else if($type == 'full_width_background'){
  83. $main_class = "full-width-section ";
  84. } else if($type == 'full_width_content'){
  85. $main_class = "full-width-content ";
  86. }
  87. //remove in container possibility when using fullpage.js
  88. if($page_full_screen_rows == 'on' && $type == 'in_container') $main_class = "full-width-section ";
  89. echo'<div id="'.uniqid("fws_").'" class="wpb_row vc_row-fluid '. $main_class . $parallax_class . ' ' . $vertically_center_class . ' ' . $class . ' " '.$using_custom_text_color.' style="'.$style.'">';
  90. if($page_full_screen_rows == 'on') echo '<div class="full-page-inner-wrap-outer"><div class="full-page-inner-wrap" data-name="'.$row_name.'" data-content-pos="'.$full_screen_row_position.'"><div class="full-page-inner">';
  91. //row bg
  92. echo '<div class="row-bg-wrap"> <div class="row-bg '.$using_image_class . ' ' . $using_bg_color_class . ' '. $etxra_class.'" style="'.$bg_props.'"></div> </div>';
  93. //video bg
  94. if($video_bg) {
  95. if ( floatval(get_bloginfo('version')) >= "3.6" ) {
  96. wp_enqueue_script('wp-mediaelement');
  97. wp_enqueue_style('wp-mediaelement');
  98. } else {
  99. //register media element for WordPress 3.5
  100. wp_register_script('wp-mediaelement', get_template_directory_uri() . '/js/mediaelement-and-player.min.js', array('jquery'), '1.0', TRUE);
  101. wp_register_style('wp-mediaelement', get_template_directory_uri() . '/css/mediaelementplayer.min.css');
  102. wp_enqueue_script('wp-mediaelement');
  103. wp_enqueue_style('wp-mediaelement');
  104. }
  105. //parse video image
  106. if(strpos($video_image, "http://") !== false){
  107. $video_image_src = $video_image;
  108. } else {
  109. $video_image_src = wp_get_attachment_image_src($video_image, 'full');
  110. $video_image_src = $video_image_src[0];
  111. }
  112. $poster_markup = (!empty($video_image)) ? 'poster="'.$video_image_src.'"' : null ;
  113. $video_markup = null;
  114. if($enable_video_color_overlay != 'true') $video_overlay_color = null;
  115. $video_markup .= '<div class="video-color-overlay" data-color="'.$video_overlay_color.'"></div>';
  116. $video_markup .= '
  117. <div class="mobile-video-image" style="background-image: url('.$video_image_src.')"></div>
  118. <div class="nectar-video-wrap">
  119. <video class="nectar-video-bg" width="1800" height="700" '.$poster_markup.' controls="controls" preload="auto" loop autoplay>';
  120. if(!empty($video_webm)) { $video_markup .= '<source type="video/webm" src="'.$video_webm.'">'; }
  121. if(!empty($video_mp4)) { $video_markup .= '<source type="video/mp4" src="'.$video_mp4.'">'; }
  122. if(!empty($video_ogv)) { $video_markup .= '<source type="video/ogg" src="'. $video_ogv.'">'; }
  123. $video_markup .='</video>
  124. </div>';
  125. echo $video_markup;
  126. }
  127. $extra_container_div = null;
  128. $extra_container_div_closing = null;
  129. if($page_full_screen_rows == 'on' && $main_class == "full-width-section ") {
  130. $extra_container_div = '<div class="container">';
  131. $extra_container_div_closing = '</div>';
  132. $pattern = get_shortcode_regex();
  133. if ( preg_match_all( '/'. $pattern .'/s', $content, $matches ) && array_key_exists( 0, $matches )) {
  134. if($matches[0][0]){
  135. if( strpos($matches[0][0],'nectar_slider') !== false && strpos($matches[0][0],'full_width="true"') !== false
  136. || strpos($matches[0][0],' type="full_width_content"') !== false && strpos($matches[0][0],'nectar_slider') !== false && strpos($matches[0][0],'[vc_column width="1/1"') !== false ) {
  137. $extra_container_div = null;
  138. $extra_container_div_closing = null;
  139. }
  140. }
  141. }
  142. }
  143. echo $extra_container_div.'<div class="col span_12 '.strtolower($text_color).' ' .$text_align.'">'.do_shortcode($content).'</div></div>'.$extra_container_div_closing;
  144. if($page_full_screen_rows == 'on') echo '</div></div></div><!--inner-wrap-->';
  145. ?>