PageRenderTime 54ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/Website-Sample/trackiex/wp-content/themes/uncode/partials/headers.php

https://bitbucket.org/trackiexa/trackiex
PHP | 276 lines | 217 code | 53 blank | 6 comment | 98 complexity | 6fbf62504aa6971b1fd7883458edca63 MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause, MIT, LGPL-3.0, GPL-3.0, GPL-2.0
  1. <?php
  2. /*****************
  3. *
  4. * HEADER BUILDER
  5. *
  6. ******************/
  7. if (!class_exists('unheader')) {
  8. class unheader
  9. {
  10. public $html, $poster_id, $show_title;
  11. function __construct($args, $page_title = '', $subheading = '')
  12. {
  13. global $onepage;
  14. $poster_id = false;
  15. $limit_width = $limit_content_width = $content_html = $content_width = $header_title = $header_title_custom = $header_title_font = $header_title_size = $header_title_height = $header_title_spacing = $header_title_weight = $header_title_italic = $header_title_transform = $header_background = $header_container_background = $header_title = $header_parallax = $header_kburns = $header_parallax_class = $height_style = $data_height = $header_background_video = $back_mime = $back_mime_css = $header_background_selfvideo = $header_overlay_color = $header_overlay_color_alpha = $header_overlay_pattern = $header_container_overlay_color = $header_container_overlay_color_alpha = $header_container_overlay_pattern = $header_align = $header_scroll_opacity = $header_scrolldown = $header_no_padding = $header_no_padding_mobile = '';
  16. if (isset($args['_uncode_header_full_width'][0]) && $args['_uncode_header_full_width'][0] !== '') {
  17. if ($args['_uncode_header_full_width'][0] === 'limit') $limit_width = ' limit-width';
  18. } else {
  19. $header_width = ot_get_option( '_uncode_header_full');
  20. if ($header_width === 'off') $limit_width = ' limit-width';
  21. }
  22. if (isset($args['_uncode_header_content_width'][0]) && $args['_uncode_header_content_width'][0] !== 'on') {
  23. $limit_content_width = ' limit-width';
  24. }
  25. if (isset($args['_uncode_header_custom_width'][0])) {
  26. if ($args['_uncode_header_custom_width'][0] != '100') $content_width = ' style="max-width: ' . $args['_uncode_header_custom_width'][0] . '%;"';
  27. }
  28. if ($onepage) {
  29. if (isset($args['_uncode_scroll_header_name'][0]) && $args['_uncode_scroll_header_name'][0] !== '') {
  30. $onepage_header_name = esc_attr($args['_uncode_scroll_header_name'][0]);
  31. $onepage_header_name = ' data-label="'. $onepage_header_name .'" data-name="'. sanitize_title($onepage_header_name).'"';
  32. }
  33. else $onepage_header_name = '';
  34. } else {
  35. $onepage_header_name = '';
  36. }
  37. /** style **/
  38. if (isset($args['_uncode_header_height'][0]) && $args['_uncode_header_height'][0] !== '')
  39. {
  40. $height = $args['_uncode_header_height'][0];
  41. if ($height[1] == '%')
  42. {
  43. $data_height = ' data-height="' . $height[0] . '"';
  44. }
  45. if ($height[1] == 'px')
  46. {
  47. $data_height = ' data-height="fixed"';
  48. $height_style .= 'height: ' . $height[0] . $height[1] . ';';
  49. }
  50. }
  51. if (isset($args['_uncode_header_min_height'][0]) && $args['_uncode_header_min_height'][0] !== '') {
  52. $min_height = intval(preg_replace('/[^0-9]+/', '', $args['_uncode_header_min_height'][0]), 10);
  53. $height_style .= 'min-height: ' . $min_height . 'px;';
  54. }
  55. if ($height_style !== '') $height_style = ' style="'.$height_style.'"';
  56. $header_style = (isset($args['_uncode_header_style'])) ? $args['_uncode_header_style'][0] : 'light';
  57. $header_align = (isset($args['_uncode_header_align'])) ? $args['_uncode_header_align'][0] : 'center';
  58. if (isset($args['_uncode_header_title'])) $header_title = $args['_uncode_header_title'][0];
  59. if (isset($args['_uncode_header_title_custom'])) $header_title_custom = $args['_uncode_header_title_custom'][0];
  60. if (isset($args['_uncode_header_title_font'])) $header_title_font = $args['_uncode_header_title_font'][0];
  61. if (isset($args['_uncode_header_title_size'])) $header_title_size = $args['_uncode_header_title_size'][0];
  62. if (isset($args['_uncode_header_title_height'])) $header_title_height = $args['_uncode_header_title_height'][0];
  63. if (isset($args['_uncode_header_title_spacing'])) $header_title_spacing = $args['_uncode_header_title_spacing'][0];
  64. if (isset($args['_uncode_header_title_weight'])) $header_title_weight = $args['_uncode_header_title_weight'][0];
  65. if (isset($args['_uncode_header_title_italic'])) $header_title_italic = $args['_uncode_header_title_italic'][0];
  66. if (isset($args['_uncode_header_title_transform'])) $header_title_transform = $args['_uncode_header_title_transform'][0];
  67. if (isset($args['_uncode_header_overlay_pattern'])) $header_overlay_pattern = $args['_uncode_header_overlay_pattern'][0];
  68. if (isset($args['_uncode_header_background'])) $header_background = $args['_uncode_header_background'][0];
  69. if (isset($args['_uncode_header_overlay_color'])) $header_overlay_color = $args['_uncode_header_overlay_color'][0];
  70. if (isset($args['_uncode_header_overlay_color_alpha'])) $header_overlay_color_alpha = $args['_uncode_header_overlay_color_alpha'][0];
  71. if (isset($args['_uncode_header_scroll_opacity'])) $header_scroll_opacity = $args['_uncode_header_scroll_opacity'][0];
  72. if (isset($args['_uncode_header_scrolldown'])) $header_scrolldown = $args['_uncode_header_scrolldown'][0];
  73. if (isset($args['_uncode_menu_no_padding'])) $header_no_padding = $args['_uncode_menu_no_padding'][0];
  74. if (isset($args['_uncode_menu_no_padding_mobile'])) $header_no_padding_mobile = $args['_uncode_menu_no_padding_mobile'][0];
  75. $item_style = ' style-' . $header_style;
  76. if ($header_scrolldown === 'on') {
  77. $header_scroll_html = '<div class="header-scrolldown'.$item_style.'"><i class="fa fa-angle-down"></i></div>';
  78. } else $header_scroll_html = '';
  79. if ($header_no_padding === 'on') $header_no_padding = 'remove-menu-padding ';
  80. else $header_no_padding = '';
  81. if ($header_no_padding_mobile === 'on') $header_no_padding .= 'remove-menu-padding-mobile ';
  82. $this->html = '';
  83. $header_type = (isset($args['_uncode_header_type'][0])) ? $args['_uncode_header_type'][0] : 'none';
  84. switch ($header_type)
  85. {
  86. case 'header_basic':
  87. $div_data = array();
  88. $title_classes = array();
  89. $data_size = '';
  90. $header_parallax = (isset($args['_uncode_header_parallax'][0]) && $args['_uncode_header_parallax'][0] == 'on') ? ' header-parallax' : '';
  91. $header_kburns = (isset($args['_uncode_header_kburns'][0]) && $args['_uncode_header_kburns'][0] == 'on') ? ' with-kburns' : '';
  92. $header_position = (isset($args['_uncode_header_position'][0])) ? ' ' . $args['_uncode_header_position'][0] : '';
  93. $header_background_array = uncode_get_back_html($header_background, $header_overlay_color, $header_overlay_color_alpha, $header_overlay_pattern, $item_style, 'header');
  94. $this->poster_id = $header_background_array['poster_id'];
  95. $text_animation = (isset($args['_uncode_header_text_animation'][0]) && $args['_uncode_header_text_animation'][0] != '') ? ' blocks-animation ' . $args['_uncode_header_text_animation'][0] : '';
  96. if (isset($args['_uncode_header_animation_speed'][0]) && $args['_uncode_header_animation_speed'][0] != '') $div_data['data-speed'] = $args['_uncode_header_animation_speed'][0];
  97. if (isset($args['_uncode_header_animation_delay'][0]) && $args['_uncode_header_animation_delay'][0] != '') $div_data['data-delay'] = $args['_uncode_header_animation_delay'][0];
  98. if ($header_title_font !== '') $title_classes[] = $header_title_font;
  99. if ($header_title_size !== '') $title_classes[] = $header_title_size;
  100. if ($header_title_height !== '') $title_classes[] = $header_title_height;
  101. if ($header_title_spacing !== '') $title_classes[] = $header_title_spacing;
  102. if ($header_title_weight !== '') $title_classes[] = 'font-weight-' . $header_title_weight;
  103. if ($header_title_transform !== '') $title_classes[] = 'text-' . $header_title_transform;
  104. $page_title = ($header_title_italic === 'on') ? $page_title = '<i>' . $page_title . '</i>' : $page_title;
  105. if ($header_background_array['content_html'] === '') {
  106. if ($header_title !== 'off') {
  107. $content_html .= apply_filters( 'uncode_before_header_title', '' );
  108. if ($header_title_custom !== 'on') {
  109. $content_html .= '<h1 class="header-title '.implode(' ', $title_classes).'"'.$data_size.'><span>' . $page_title . '</span></h1>';
  110. } else {
  111. if (isset($args['_uncode_header_text'][0]))
  112. {
  113. $content = '<h1 class="header-title '.implode(' ', $title_classes).'"'.$data_size.'><span>';
  114. $title = trim($args['_uncode_header_text'][0]);
  115. $title_lines = explode("\n", $title);
  116. $lines_counter = count($title_lines);
  117. if ($lines_counter > 1) {
  118. foreach ($title_lines as $key => $value) {
  119. $value = trim($value);
  120. $content .= $value;
  121. if ($value !== '' && ($lines_counter - 1 !== $key)) $content .= '</span><span>';
  122. }
  123. } else {
  124. $content .= $title;
  125. }
  126. $content .= '</span></h1>';
  127. $content_html .= do_shortcode($content);
  128. }
  129. }
  130. $get_post_type = get_post_type();
  131. if ($get_post_type === 'post' && is_single()) $content_html .= uncode_post_info();
  132. if ($get_post_type === 'portfolio' && is_single()) $content_html .= uncode_portfolio_info();
  133. $content_html .= apply_filters( 'uncode_after_header_title', '' );
  134. }
  135. } else {
  136. $this->show_title = 'yes';
  137. $content_html .= $header_background_array['content_html'];
  138. }
  139. $this->html.= '<div class="'.$header_no_padding . 'header-basic' . $limit_width . $item_style . '">
  140. <div class="background-element header-wrapper'.($header_scroll_opacity === 'on' ? ' header-scroll-opacity' : '') . (($onepage) ? ' onepage-section' : '') . $header_parallax . $header_kburns . $header_background_array['back_color'] . (($header_background_array['content_html'] === '' || $header_background_array['content_only_text']) ? ' header-only-text' : '') .'"' . $onepage_header_name . $data_height . $height_style. '>
  141. ' . (isset($header_background_array['back_html']) ? $header_background_array['back_html'] : '');
  142. $div_data_attributes = array_map(function ($v, $k) { return $k . '="' . $v . '"'; }, $div_data, array_keys($div_data));
  143. if ($content_html !== '')
  144. $this->html .= '<div class="header-main-container'.$limit_content_width . ($header_background_array['is_carousel'] ? ' header-carousel' :'' ). '">
  145. <div class="header-content' . $header_position . ' header-align-' . $header_align . '">
  146. <div class="header-content-inner' . $text_animation . '"' . $content_width . ' '.implode(' ', $div_data_attributes).'>
  147. '.$content_html.'
  148. </div>
  149. </div>
  150. </div>';
  151. $this->html.= $header_scroll_html .
  152. '</div>
  153. </div>';
  154. break;
  155. case 'header_uncodeblock':
  156. $this->html .= '<div class="'.$header_no_padding . 'header-wrapper header-uncode-block'. ($header_scroll_opacity === 'on' ? ' header-scroll-opacity' : '') . '">
  157. ' . (isset($header_background_array['back_html']) ? $header_background_array['back_html'] : '');
  158. $uncodeblock_id = (isset($args['_uncode_blocks_list']) && $args['_uncode_blocks_list'][0] !== '') ? $args['_uncode_blocks_list'][0] : '';
  159. if ($uncodeblock_id !== '') $uncodeblock_id = apply_filters( 'wpml_object_id', $uncodeblock_id, 'post' );
  160. $uncode_block = ($uncodeblock_id !== '') ? get_post_field('post_content', $uncodeblock_id) : '';
  161. $uncode_block = str_replace('[vc_row ', '[vc_row is_header="yes" ', $uncode_block);
  162. $uncode_block = str_replace('[uncode_slider', '[uncode_slider is_header="yes"', $uncode_block);
  163. if ($subheading !== '') $subheading = ' subheading="'.$subheading.'"';
  164. $regex = '/\[vc_custom_heading(.*?)\](.*?)\[\/vc_custom_heading\]/';
  165. preg_match_all($regex, $uncode_block, $matches, PREG_SET_ORDER);
  166. $regex_attr = '/ auto_text=\"yes\"/';
  167. foreach ($matches as $key => $value) {
  168. preg_match($regex_attr, $value[1], $matches_attr);
  169. if (isset($matches_attr[0]) && $matches_attr[0]!=='') {
  170. $replacement = '[vc_custom_heading is_header="yes" ' . $value[1] . $subheading . ']' . $page_title . '[/vc_custom_heading]';
  171. $uncode_block = str_replace($value[0], $replacement, $uncode_block);
  172. }
  173. }
  174. $featured_id = isset($header_background['background-image']) ? $header_background['background-image'] : '';
  175. if ($featured_id !== '') {
  176. $regex = '/\[vc_row(.*?)\]/';
  177. $regex_attr = '/(.*?)=\"(.*?)\"/';
  178. preg_match_all($regex, $uncode_block, $matches, PREG_SET_ORDER);
  179. foreach ($matches as $key => $value) {
  180. $media_found = false;
  181. if (isset($value[1])) {
  182. preg_match_all($regex_attr, trim($value[1]), $matches_attr, PREG_SET_ORDER);
  183. foreach ($matches_attr as $key_attr => $value_attr) {
  184. if (trim($value_attr[1]) === 'back_image_auto') {
  185. if ($value_attr[2] === 'yes') $media_found = true;
  186. }
  187. }
  188. }
  189. if ($media_found) {
  190. $replacement = '[vc_row' . $value[1] . ' back_image="'.$featured_id.'"]';
  191. $uncode_block = str_replace($value[0], $replacement, $uncode_block);
  192. }
  193. }
  194. }
  195. $this->html.= $uncode_block;
  196. $this->html.= $header_scroll_html;
  197. $this->html.= '</div>';
  198. break;
  199. case 'header_revslider':
  200. $this->html.= '<div class="' . $header_no_padding . 'header-wrapper header-revslider">
  201. ' . (isset($header_background_array['back_html']) ? $header_background_array['back_html'] : '') . '
  202. <div class="header-main-container">';
  203. $revslider_id = (isset($args['_uncode_revslider_list']) && $args['_uncode_revslider_list'][0] != '') ? $args['_uncode_revslider_list'][0] : '';
  204. $this->html.= do_shortcode('[rev_slider ' . $revslider_id . ']');
  205. if (function_exists('qtranxf_getLanguage')) $this->html = __($this->html);
  206. $this->html.= '</div>';
  207. $this->html.= '</div>';
  208. break;
  209. case 'header_layerslider':
  210. $this->html.= '<div class="' . $header_no_padding . 'header-wrapper">
  211. ' . (isset($header_background_array['back_html']) ? $header_background_array['back_html'] : '') . '
  212. <div class="header-main-container">';
  213. $layerslider_id = (isset($args['_uncode_layerslider_list']) && $args['_uncode_layerslider_list'][0] != '') ? $args['_uncode_layerslider_list'][0] : '';
  214. $this->html.= do_shortcode('[layerslider id="' . $layerslider_id . '"]');
  215. if (function_exists('qtranxf_getLanguage')) $this->html = __($this->html);
  216. $this->html.= '</div>';
  217. $this->html.= '</div>';
  218. break;
  219. }
  220. }
  221. }
  222. }
  223. ?>