PageRenderTime 55ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/themes/ifeature/cyberchimps/hooks/header-hooks.php

https://github.com/Bochet/festival_lgbt
PHP | 314 lines | 238 code | 43 blank | 33 comment | 33 complexity | 0d31677616bdaedc42231aca1f315400 MD5 | raw file
Possible License(s): GPL-2.0, AGPL-1.0, LGPL-2.1
  1. <?php
  2. /**
  3. * Title: Header Hooks
  4. *
  5. * Description: Defines actions/hooks for header content.
  6. *
  7. * Please do not edit this file. This file is part of the Cyber Chimps Framework and all modifications
  8. * should be made in a child theme.
  9. *
  10. * @category Cyber Chimps Framework
  11. * @package Framework
  12. * @since 1.0
  13. * @author CyberChimps
  14. * @license http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later)
  15. * @link http://www.cyberchimps.com/
  16. */
  17. function cyberchimps_header_section_order() {
  18. //get the defaults from the themes function file and turn the key into the value in a new array to mirror what happens within the theme when their are options saved in the database
  19. $defaults = array();
  20. $default = apply_filters( 'header_drag_and_drop_default', array( 'cyberchimps_header_content' => __( 'Logo + Icons', 'cyberchimps' ) ) );
  21. foreach( $default as $key => $val ){
  22. $defaults[] = $key;
  23. }
  24. // call the database results and if they don't exist then call the defaults from above
  25. $header_section = cyberchimps_get_option( 'header_section_order', $defaults );
  26. $header_section = ( $header_section == '' ) ? array( 'cyberchimps_header_content' ) : $header_section;
  27. if ( is_array( $header_section ) ) {
  28. foreach( $header_section as $func ) {
  29. do_action($func);
  30. }
  31. }
  32. }
  33. add_action('cyberchimps_header', 'cyberchimps_header_section_order');
  34. // Logo/Icons header element.
  35. function cyberchimps_logo_icons() { ?>
  36. <header id="cc-header" class="row-fluid">
  37. <div class="span7">
  38. <?php if (function_exists('cyberchimps_header_logo') ) {
  39. cyberchimps_header_logo();
  40. } ?>
  41. </div>
  42. <div id="register" class="span5">
  43. <?php if (function_exists('cyberchimps_header_social_icons') ) {
  44. cyberchimps_header_social_icons();
  45. } ?>
  46. </div>
  47. </header>
  48. <?php }
  49. add_action('cyberchimps_header_content', 'cyberchimps_logo_icons');
  50. // Logo/Search header element.
  51. function cyberchimps_logo_searchform() { ?>
  52. <header id="cc-header" class="row-fluid">
  53. <div class="span7">
  54. <?php if (function_exists('cyberchimps_header_logo') ) {
  55. cyberchimps_header_logo();
  56. } ?>
  57. </div>
  58. <div id="search" class="span5">
  59. <?php
  60. get_search_form( true );
  61. ?>
  62. </div>
  63. </header>
  64. <?php }
  65. add_action('cyberchimps_logo_search', 'cyberchimps_logo_searchform');
  66. // Description/Icons header element.
  67. function cyberchimps_description_icons() { ?>
  68. <header id="cc-header" class="row-fluid">
  69. <div class="span7">
  70. <h1 class="site-description"><?php bloginfo( 'description' ); ?></h1>
  71. </div>
  72. <div id ="register" class="span5">
  73. <?php if (function_exists('cyberchimps_header_social_icons') ) {
  74. cyberchimps_header_social_icons();
  75. } ?>
  76. </div>
  77. </header>
  78. <?php }
  79. add_action('cyberchimps_description_icons', 'cyberchimps_description_icons');
  80. // Logo and Contact
  81. function cyberchimps_sitename_contact() {?>
  82. <header id="cc-header" class="row-fluid">
  83. <div class="span7">
  84. <?php if (function_exists('cyberchimps_header_logo') ) {
  85. cyberchimps_header_logo();
  86. } ?>
  87. </div>
  88. <div id ="register" class="span5">
  89. <?php if (function_exists('cyberchimps_contact_info') ) {
  90. echo cyberchimps_contact_info();
  91. } ?>
  92. </div>
  93. </header>
  94. <?php }
  95. add_action('cyberchimps_sitename_contact', 'cyberchimps_sitename_contact');
  96. // Logo and Description
  97. function cyberchimps_logo_description() {?>
  98. <header id="cc-header" class="row-fluid">
  99. <div class="span7">
  100. <?php if (function_exists('cyberchimps_header_logo') ) {
  101. cyberchimps_header_logo();
  102. } ?>
  103. </div>
  104. <div id ="description" class="span5">
  105. <?php if (function_exists('cyberchimps_description') ) {
  106. echo cyberchimps_description();
  107. } ?>
  108. </div>
  109. </header>
  110. <?php }
  111. add_action( 'cyberchimps_logo_description', 'cyberchimps_logo_description' );
  112. // Defines action for header elelment "Logo"
  113. function cyberchimps_logo() {?>
  114. <header id="cc-header" class="row-fluid">
  115. <div class="span7">
  116. <?php if (function_exists('cyberchimps_header_logo') ) {
  117. cyberchimps_header_logo();
  118. } ?>
  119. </div>
  120. </header>
  121. <?php }
  122. add_action( 'cyberchimps_logo', 'cyberchimps_logo' );
  123. // Header left content (sitename or logo)
  124. function cyberchimps_header_logo() {
  125. $url = ( cyberchimps_get_option( 'custom_logo_url_link' ) != '' ) ? cyberchimps_get_option( 'custom_logo_url_link' ) : home_url();
  126. if ( cyberchimps_get_option('custom_logo') == '1') {
  127. $logo = cyberchimps_get_option('custom_logo_uploader');
  128. ?>
  129. <div id="logo">
  130. <a href="<?php echo $url; ?>" title="<?php echo get_bloginfo( 'name' ); ?>"><img src="<?php echo stripslashes($logo); ?>" alt="logo"></a>
  131. </div>
  132. <?php } else {
  133. if ( function_exists('cyberchimps_header_site_title') ) {
  134. cyberchimps_header_site_title();
  135. }
  136. }
  137. }
  138. function cyberchimps_header_site_title() { ?>
  139. <hgroup>
  140. <h1 class="site-title"><a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
  141. </hgroup>
  142. <?php }
  143. // Social icons
  144. function cyberchimps_header_social_icons() {
  145. $folder = ( cyberchimps_get_option( 'theme_backgrounds', 'default' ) ) ? cyberchimps_get_option( 'theme_backgrounds', 'default' ) : 'default';
  146. // Set path of social image folder.
  147. $social_image = get_template_directory_uri() . '/cyberchimps/lib/images/social/' . $folder;
  148. $twitter_display = cyberchimps_get_option( 'social_twitter', 'checked' );
  149. $facebook_display = cyberchimps_get_option( 'social_facebook', 'checked' );
  150. $google_display = cyberchimps_get_option( 'social_google', 'checked' );
  151. $flickr_display = cyberchimps_get_option('social_flickr');
  152. $pinterest_display = cyberchimps_get_option('social_pinterest');
  153. $linkedin_display = cyberchimps_get_option('social_linkedin');
  154. $youtube_display = cyberchimps_get_option('social_youtube');
  155. $googlemaps_display = cyberchimps_get_option('social_googlemaps');
  156. $email_display = cyberchimps_get_option('social_email');
  157. $rss_display = cyberchimps_get_option('social_rss');
  158. $output = '';
  159. if ( !empty($twitter_display) ) {
  160. $twitter_url = cyberchimps_get_option('twitter_url');
  161. $output .= '<a href="'.esc_attr($twitter_url).'" target="_blank"><img src="' . $social_image . '/twitter.png" alt="Twitter" /></a>';
  162. }
  163. if ( !empty($facebook_display) ) {
  164. $facebook_url = cyberchimps_get_option('facebook_url');
  165. $output .= '<a href="'.esc_attr($facebook_url).'" target="_blank"><img src="' . $social_image . '/facebook.png" alt="Facebook" /></a>';
  166. }
  167. if ( !empty($google_display) ) {
  168. $google_url = cyberchimps_get_option('google_url');
  169. $output .= '<a href="'.esc_attr($google_url).'" target="_blank"><img src="' . $social_image . '/gplus.png" alt="Google" /></a>';
  170. }
  171. if ( !empty($flickr_display) ) {
  172. $flickr_url = cyberchimps_get_option('flickr_url');
  173. $output .= '<a href="'.esc_attr($flickr_url).'" target="_blank"><img src="' . $social_image . '/flickr.png" alt="Flickr" /></a>';
  174. }
  175. if ( !empty($pinterest_display) ) {
  176. $pinterest_url = cyberchimps_get_option('pinterest_url');
  177. $output .= '<a href="'.esc_attr($pinterest_url).'" target="_blank"><img src="' . $social_image . '/pinterest.png" alt="Pinterest" /></a>';
  178. }
  179. if ( !empty($linkedin_display) ) {
  180. $linkedin_url = cyberchimps_get_option('linkedin_url');
  181. $output .= '<a href="'.esc_attr($linkedin_url).'" target="_blank"><img src="' . $social_image . '/linkedin.png" alt="LinkedIn" /></a>';
  182. }
  183. if ( !empty($youtube_display) ) {
  184. $youtube_url = cyberchimps_get_option('youtube_url');
  185. $output .= '<a href="'.esc_attr($youtube_url).'" target="_blank"><img src="' . $social_image . '/youtube.png" alt="YouTube" /></a>';
  186. }
  187. if ( !empty($googlemaps_display) ) {
  188. $googlemaps_url = cyberchimps_get_option('googlemaps_url');
  189. $output .= '<a href="'.esc_attr($googlemaps_url).'" target="_blank"><img src="' . $social_image . '/googlemaps.png" alt="Google Maps" /></a>';
  190. }
  191. if ( !empty($email_display) ) {
  192. $email_url = cyberchimps_get_option('email_url');
  193. $output .= '<a href="mailto:'.esc_attr($email_url).'"><img src="' . $social_image . '/email.png" alt="Email" /></a>';
  194. }
  195. if ( !empty($rss_display) ) {
  196. //bloginfo('rss2_url')
  197. $rss_url = cyberchimps_get_option('rss_url');
  198. $output .= '<a href="'.esc_attr($rss_url).'" target="_blank"><img src="' . $social_image . '/rss.png" alt="RSS" /></a>';
  199. }
  200. ?>
  201. <div id="social">
  202. <div class="icons">
  203. <?php echo $output; ?>
  204. </div>
  205. </div>
  206. <?php }
  207. // Custom HTML header element.
  208. function cyberchimps_custom_header_element_content() { ?>
  209. <header id="cc-header" class="row-fluid">
  210. <div class="span7">
  211. <?php echo stripslashes( cyberchimps_get_option( 'custom_header_element' ) ); ?>
  212. </div>
  213. </header>
  214. <?php }
  215. // Sitename/Register
  216. function cyberchimps_logo_register_content() {
  217. global $current_user; ?>
  218. <header id="cc-header" class="row-fluid">
  219. <div class="span7">
  220. <?php if (function_exists('cyberchimps_header_logo') ) {
  221. cyberchimps_header_logo();
  222. } ?>
  223. </div>
  224. <div id ="register" class="span5">
  225. <div class="register">
  226. <?php if(!is_user_logged_in()) :?>
  227. <?php wp_loginout(); ?> <?php wp_meta(); ?> |<?php wp_register(); ?>
  228. <?php else :?>
  229. Welcome back <strong><?php global $current_user; get_currentuserinfo(); echo ($current_user->user_login); ?></strong> | <?php wp_loginout(); ?>
  230. <?php endif;?>
  231. </div>
  232. </div>
  233. </header>
  234. <?php }
  235. add_action( 'cyberchimps_sitename_register', 'cyberchimps_logo_register_content' );
  236. // Full-Width Logo
  237. function cyberchimps_banner_content() {
  238. // Getting banner options
  239. $banner = cyberchimps_get_option( 'header_banner_image' );
  240. $default = get_template_directory_uri() . apply_filters( 'cyberchimps_banner_img', '/cyberchimps/lib/images/banner.jpg' );
  241. $url = cyberchimps_get_option( 'header_banner_url' );
  242. ?>
  243. <header id="cc-header" class="row-fluid">
  244. <div id="banner">
  245. <?php if ($banner != ""):?>
  246. <a href="<?php echo $url; ?>"><img src="<?php echo $banner; ?>" alt="logo"></a>
  247. <?php endif; ?>
  248. <?php if ($banner == ""):?>
  249. <a href="<?php echo $url; ?>"><img src="<?php echo $default; ?>" alt="logo"></a>
  250. <?php endif; ?>
  251. </div>
  252. </header>
  253. <?php
  254. }
  255. add_action( 'cyberchimps_banner', 'cyberchimps_banner_content' );
  256. //contact info
  257. function cyberchimps_contact_info() {
  258. $contact = apply_filters( 'cyberchimps_header_contact', cyberchimps_get_option( 'contact_details' ) ); ?>
  259. <div class="contact_details">
  260. <?php echo $contact; ?>
  261. </div>
  262. <?php }
  263. //description
  264. function cyberchimps_description() {
  265. $description = get_bloginfo( 'description' );?>
  266. <div class="blog-description">
  267. <p><?php echo $description; ?></p>
  268. </div>
  269. <?php
  270. }
  271. ?>