Advertisement
Guest User

Untitled

a guest
Jan 19th, 2015
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.61 KB | None | 0 0
  1. <?php
  2. /**
  3. * Adds header structures.
  4. *
  5. */
  6.  
  7. /****************************************************************************************/
  8.  
  9. add_action( 'travelify_title', 'travelify_add_meta', 5 );
  10. /**
  11. * Add meta tags.
  12. */
  13. function travelify_add_meta() {
  14. ?>
  15. <meta charset="<?php bloginfo( 'charset' ); ?>" />
  16. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  17. <?php
  18. }
  19.  
  20. /****************************************************************************************/
  21.  
  22. add_action( 'travelify_title', 'travelify_show_title', 10 );
  23. /**
  24. * Showing the title in the browser tab.
  25. *
  26. * @uses wp_title() Display the title on the browser tab.
  27. */
  28. function travelify_show_title() {
  29. ?>
  30. <title>
  31. <?php
  32. /**
  33. * Print the <title> tag based on what is being viewed.
  34. */
  35. wp_title( '|', true, 'right' );
  36. ?>
  37. </title>
  38. <?php
  39. }
  40.  
  41. add_filter( 'wp_title', 'travelify_filter_wp_title' );
  42. /**
  43. * Modifying the Title
  44. *
  45. * Function tied to the wp_title filter hook.
  46. * @uses filter wp_title
  47. */
  48. function travelify_filter_wp_title( $title ) {
  49. global $page, $paged;
  50.  
  51. // Get the Site Name
  52. $site_name = get_bloginfo( 'name' );
  53.  
  54. // Get the Site Description
  55. $site_description = get_bloginfo( 'description' );
  56.  
  57. $filtered_title = '';
  58.  
  59. // For Homepage or Frontpage
  60. if( is_home() || is_front_page() ) {
  61. $filtered_title .= $site_name;
  62. if ( !empty( $site_description ) ) {
  63. $filtered_title .= ' &#124; '. $site_description;
  64. }
  65. }
  66. elseif( is_feed() ) {
  67. $filtered_title = '';
  68. }
  69. else{
  70. $filtered_title = $title . $site_name;
  71. }
  72.  
  73. // Add a page number if necessary:
  74. if( $paged >= 2 || $page >= 2 ) {
  75. $filtered_title .= ' &#124; ' . sprintf( __( 'Page %s', 'travelify' ), max( $paged, $page ) );
  76. }
  77.  
  78. // Return the modified title
  79. return $filtered_title;
  80. }
  81.  
  82. /****************************************************************************************/
  83.  
  84. add_action( 'travelify_links', 'travelify_add_links', 10 );
  85. /**
  86. * Adding link to stylesheet file
  87. *
  88. * @uses get_stylesheet_uri()
  89. */
  90. function travelify_add_links() {
  91. ?>
  92. <link rel="profile" href="http://gmpg.org/xfn/11" />
  93. <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
  94. <?php
  95. }
  96.  
  97. /****************************************************************************************/
  98.  
  99. // Load Favicon in Header Section
  100. add_action( 'travelify_links', 'travelify_favicon', 15 );
  101. // Load Favicon in Admin Section
  102. add_action( 'admin_head', 'travelify_favicon' );
  103. /**
  104. * Get the favicon Image from theme options
  105. * display favicon
  106. *
  107. * @uses set_transient and delete_transient
  108. */
  109. function travelify_favicon() {
  110.  
  111. $travelify_favicon = '';
  112. if( ( !$travelify_favicon = get_transient( 'travelify_favicon' ) ) ) {
  113. global $travelify_theme_options_settings;
  114. $options = $travelify_theme_options_settings;
  115.  
  116. if ( "0" == $options[ 'disable_favicon' ] ) {
  117. if ( !empty( $options[ 'favicon' ] ) ) {
  118. $travelify_favicon .= '<link rel="shortcut icon" href="'.esc_url( $options[ 'favicon' ] ).'" type="image/x-icon" />';
  119. }
  120. }
  121.  
  122. set_transient( 'travelify_favicon', $travelify_favicon, 86940 );
  123. }
  124. echo $travelify_favicon ;
  125. }
  126.  
  127. /****************************************************************************************/
  128.  
  129. // Load webpageicon in Header Section
  130. add_action( 'travelify_links', 'travelify_webpageicon', 20 );
  131. /**
  132. * Get the webpageicon Image from theme options
  133. * display webpageicon
  134. *
  135. * @uses set_transient and delete_transient
  136. */
  137. function travelify_webpageicon() {
  138.  
  139. $travelify_webpageicon = '';
  140. if( ( !$travelify_webpageicon = get_transient( 'travelify_webpageicon' ) ) ) {
  141. global $travelify_theme_options_settings;
  142. $options = $travelify_theme_options_settings;
  143.  
  144. if ( "0" == $options[ 'disable_webpageicon' ] ) {
  145. if ( !empty( $options[ 'webpageicon' ] ) ) {
  146. $travelify_webpageicon .= '<link rel="apple-touch-icon-precomposed" href="'.esc_url( $options[ 'webpageicon' ] ).'" />';
  147. }
  148. }
  149.  
  150. set_transient( 'travelify_webpageicon', $travelify_webpageicon, 86940 );
  151. }
  152. echo $travelify_webpageicon ;
  153. }
  154.  
  155. /****************************************************************************************/
  156.  
  157. add_action( 'travelify_header', 'travelify_headerdetails', 10 );
  158. /**
  159. * Shows Header Part Content
  160. *
  161. * Shows the site logo, title, description, searchbar, social icons etc.
  162. */
  163. function travelify_headerdetails() {
  164. ?>
  165. <?php
  166. global $travelify_theme_options_settings;
  167. $options = $travelify_theme_options_settings;
  168.  
  169. $elements = array();
  170. $elements = array( $options[ 'social_facebook' ],
  171. $options[ 'social_twitter' ],
  172. $options[ 'social_googleplus' ],
  173. $options[ 'social_linkedin' ],
  174. $options[ 'social_pinterest' ],
  175. $options[ 'social_youtube' ],
  176. $options[ 'social_vimeo' ],
  177. $options[ 'social_flickr' ],
  178. $options[ 'social_tumblr' ],
  179. $options[ 'social_instagram' ],
  180. $options[ 'social_rss' ]
  181. );
  182.  
  183. $flag = 0;
  184. if( !empty( $elements ) ) {
  185. foreach( $elements as $option) {
  186. if( !empty( $option ) ) {
  187. $flag = 1;
  188. }
  189. else {
  190. $flag = 0;
  191. }
  192. if( 1 == $flag ) {
  193. break;
  194. }
  195. }
  196. }
  197. ?>
  198.  
  199. <div class="container clearfix">
  200. <div class="hgroup-wrap clearfix">
  201. <section class="hgroup-right">
  202. <?php travelify_socialnetworks( $flag ); ?>
  203. </section><!-- .hgroup-right -->
  204. <hgroup id="site-logo" class="clearfix">
  205. <?php
  206. if( $options[ 'header_show' ] != 'disable-both' && $options[ 'header_show' ] == 'header-text' ) {
  207. ?>
  208. <h1 id="site-title">
  209. <a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
  210. <?php bloginfo( 'name' ); ?>
  211. </a>
  212. </h1>
  213. <h2 id="site-description"><?php bloginfo( 'description' ); ?></h2>
  214. <?php
  215. }
  216. elseif( $options[ 'header_show' ] != 'disable-both' && $options[ 'header_show' ] == 'header-logo' ) {
  217. ?>
  218. <h1 id="site-title">
  219. <a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
  220. <img src="<?php echo $options[ 'header_logo' ]; ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>">
  221. </a>
  222. </h1>
  223. <?php
  224. }
  225. ?>
  226.  
  227. </hgroup><!-- #site-logo -->
  228.  
  229. </div><!-- .hgroup-wrap -->
  230. </div><!-- .container -->
  231. <?php $header_image = get_header_image();
  232. if( !empty( $header_image ) ) :?>
  233. <img src="<?php echo esc_url( $header_image ); ?>" class="header-image" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>">
  234. <?php endif; ?>
  235. <?php
  236. if ( has_nav_menu( 'primary' ) ) {
  237. $args = array(
  238. 'theme_location' => 'primary',
  239. 'container' => '',
  240. 'items_wrap' => '<ul class="root">%3$s</ul>'
  241. );
  242. echo '<nav id="main-nav" class="clearfix">
  243. <div class="container clearfix">';
  244. wp_nav_menu( $args );
  245. echo '</div><!-- .container -->
  246. </nav><!-- #main-nav -->';
  247. }
  248. else {
  249. echo '<nav id="main-nav" class="clearfix">
  250. <div class="container clearfix">';
  251. wp_page_menu( array( 'menu_class' => 'root' ) );
  252. echo '</div><!-- .container -->
  253. </nav><!-- #main-nav -->';
  254. }
  255. ?>
  256. <?php
  257. if( is_home() || is_front_page() ) {
  258. if( "0" == $options[ 'disable_slider' ] ) {
  259. if( function_exists( 'travelify_pass_cycle_parameters' ) )
  260. travelify_pass_cycle_parameters();
  261. if( function_exists( 'travelify_featured_post_slider' ) )
  262. travelify_featured_post_slider();
  263. }
  264. }
  265. else {
  266. if( ( '' != travelify_header_title() ) || function_exists( 'bcn_display_list' ) ) {
  267. ?>
  268. <div class="page-title-wrap">
  269. <div class="container clearfix">
  270. <?php
  271. if( function_exists( 'travelify_breadcrumb' ) )
  272. travelify_breadcrumb();
  273. ?>
  274. <h3 class="page-title"><?php echo travelify_header_title(); ?></h3><!-- .page-title -->
  275. </div>
  276. </div>
  277. <?php
  278. }
  279. }
  280. }
  281.  
  282. /****************************************************************************************/
  283.  
  284. if ( ! function_exists( 'travelify_socialnetworks' ) ) :
  285. /**
  286. * This function for social links display on header
  287. *
  288. * Get links through Theme Options
  289. */
  290. function travelify_socialnetworks( $flag ) {
  291.  
  292. global $travelify_theme_options_settings;
  293. $options = $travelify_theme_options_settings;
  294.  
  295. $travelify_socialnetworks = '';
  296. if ( ( !$travelify_socialnetworks = get_transient( 'travelify_socialnetworks' ) ) && ( 1 == $flag ) ) {
  297.  
  298. $travelify_socialnetworks .='
  299. <div class="social-icons clearfix">
  300. <ul>';
  301.  
  302. $social_links = array();
  303. $social_links = array( 'Facebook' => 'social_facebook',
  304. 'Twitter' => 'social_twitter',
  305. 'Google-Plus' => 'social_googleplus',
  306. 'Pinterest' => 'social_pinterest',
  307. 'YouTube' => 'social_youtube',
  308. 'Vimeo' => 'social_vimeo',
  309. 'LinkedIn' => 'social_linkedin',
  310. 'Flickr' => 'social_flickr',
  311. 'Tumblr' => 'social_tumblr',
  312. 'Instagram' => 'social_instagram',
  313. 'RSS' => 'social_rss'
  314. );
  315.  
  316. foreach( $social_links as $key => $value ) {
  317. if ( !empty( $options[ $value ] ) ) {
  318. $travelify_socialnetworks .=
  319. '<li class="'.strtolower($key).'"><a href="'.esc_url( $options[ $value ] ).'" title="'.sprintf( esc_attr__( '%1$s on %2$s', 'travelify' ), get_bloginfo( 'name' ), $key ).'" target="_blank"></a></li>';
  320. }
  321. }
  322.  
  323. $travelify_socialnetworks .='
  324. </ul>
  325. </div><!-- .social-icons -->';
  326.  
  327. set_transient( 'travelify_socialnetworks', $travelify_socialnetworks, 86940 );
  328. }
  329. echo $travelify_socialnetworks;
  330. }
  331. endif;
  332.  
  333.  
  334. /****************************************************************************************/
  335.  
  336. if ( ! function_exists( 'travelify_featured_post_slider' ) ) :
  337. /**
  338. * display featured post slider
  339. *
  340. */
  341. function travelify_featured_post_slider() {
  342. global $post;
  343.  
  344. global $travelify_theme_options_settings;
  345. $options = $travelify_theme_options_settings;
  346.  
  347. $travelify_featured_post_slider = '';
  348. if (!empty( $options[ 'featured_post_slider' ] ) ) {
  349. $travelify_featured_post_slider .= '
  350. <section class="featured-slider"><div class="slider-cycle">';
  351. $get_featured_posts = new WP_Query( array(
  352. 'posts_per_page' => $options[ 'slider_quantity' ],
  353. 'post_type' => array( 'post', 'page' ),
  354. 'post__in' => $options[ 'featured_post_slider' ],
  355. 'orderby' => 'post__in',
  356. 'suppress_filters' => false,
  357. 'ignore_sticky_posts' => 1 // ignore sticky posts
  358. ));
  359. $i=0; while ( $get_featured_posts->have_posts()) : $get_featured_posts->the_post(); $i++;
  360. $title_attribute = apply_filters( 'the_title', get_the_title( $post->ID ) );
  361. $excerpt = get_the_excerpt();
  362. if ( 1 == $i ) { $classes = "slides displayblock"; } else { $classes = "slides displaynone"; }
  363. $travelify_featured_post_slider .= '
  364. <div class="'.$classes.'">';
  365. if( has_post_thumbnail() ) {
  366.  
  367. $travelify_featured_post_slider .= '<figure><a href="' . get_permalink() . '" title="'.the_title('','',false).'">';
  368.  
  369. $travelify_featured_post_slider .= get_the_post_thumbnail( $post->ID, 'slider', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'pngfix' ) ).'</a></figure>';
  370. }
  371. if( $title_attribute != '' || $excerpt !='' ) {
  372. $travelify_featured_post_slider .= '
  373. <article class="featured-text">';
  374. if( $title_attribute !='' ) {
  375. $travelify_featured_post_slider .= '<div class="featured-title"><a href="' . get_permalink() . '" title="'.the_title('','',false).'">'. get_the_title() . '</a></div><!-- .featured-title -->';
  376. }
  377. if( $excerpt !='' ) {
  378. $travelify_featured_post_slider .= '<div class="featured-content">'.$excerpt.'</div><!-- .featured-content -->';
  379. }
  380. $travelify_featured_post_slider .= '
  381. </article><!-- .featured-text -->';
  382. }
  383. $travelify_featured_post_slider .= '
  384. </div><!-- .slides -->';
  385. endwhile; wp_reset_query();
  386. $travelify_featured_post_slider .= '</div>
  387. <nav id="controllers" class="clearfix">
  388. </nav><!-- #controllers --></section><!-- .featured-slider -->';
  389. }
  390. echo $travelify_featured_post_slider;
  391. }
  392. endif;
  393.  
  394. /****************************************************************************************/
  395.  
  396. if ( ! function_exists( 'travelify_breadcrumb' ) ) :
  397. /**
  398. * Display breadcrumb on header.
  399. *
  400. * If the page is home or front page, slider is displayed.
  401. * In other pages, breadcrumb will display if breadcrumb NavXT plugin exists.
  402. */
  403. function travelify_breadcrumb() {
  404. if( function_exists( 'bcn_display_list' ) ) {
  405. echo '<div class="breadcrumb">
  406. <ul>';
  407. bcn_display_list();
  408. echo '</ul>
  409. </div> <!-- .breadcrumb -->';
  410. }
  411.  
  412. }
  413. endif;
  414.  
  415. /****************************************************************************************/
  416.  
  417. if ( ! function_exists( 'travelify_header_title' ) ) :
  418. /**
  419. * Show the title in header
  420. */
  421. function travelify_header_title() {
  422. if( is_archive() ) {
  423. $travelify_header_title = single_cat_title( '', FALSE );
  424. }
  425. elseif( is_search() ) {
  426. $travelify_header_title = __( 'Search Results', 'travelify' );
  427. }
  428. elseif( is_page_template() ) {
  429. $travelify_header_title = get_the_title();
  430. }
  431. else {
  432. $travelify_header_title = '';
  433. }
  434.  
  435. return $travelify_header_title;
  436.  
  437. }
  438. endif;
  439. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement