Advertisement
AJDesigns

Interface Wordpress Theme How to Customize the Header

Dec 16th, 2014
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 14.72 KB | None | 0 0
  1. <?php
  2. //////////////////////////////////////////     
  3. //ADD CUSTOM HEADER //////////////////////
  4. /////////////////////////////////////////
  5.  
  6.  
  7. //but first remove the original version
  8.  
  9.  
  10. function remove_interface_header_details()
  11. {
  12.     remove_action('interface_header', 'interface_headercontent_details', 10);
  13. }
  14. add_action('interface_header', 'remove_interface_header_details', 9);
  15.  
  16. /**
  17.  
  18. * Shows Header content details
  19.  
  20. *
  21.  
  22. * Shows the site logo, title, description, searchbar, social icons and many more
  23.  
  24. */
  25. add_action('interface_header', 'my_interface_headercontent_details', 10);
  26. function my_interface_headercontent_details()
  27. {
  28.    
  29. ?>
  30.  
  31. <?php
  32.    
  33.     global $interface_theme_setting_value;
  34.    
  35.     $options = $interface_theme_setting_value;
  36.    
  37.    
  38.    
  39.     $elements = array();
  40.    
  41.     $elements = array(
  42.         $options['social_facebook'],
  43.        
  44.         $options['social_twitter'],
  45.        
  46.         $options['social_googleplus'],
  47.        
  48.         $options['social_pinterest'],
  49.        
  50.         $options['social_youtube'],
  51.        
  52.         $options['social_vimeo'],
  53.        
  54.         $options['social_linkedin'],
  55.        
  56.         $options['social_flickr'],
  57.        
  58.         $options['social_tumblr'],
  59.        
  60.         $options['social_rss']
  61.        
  62.     );
  63.    
  64.    
  65.    
  66.     $set_flags = 0;
  67.    
  68.     if (!empty($elements)) {
  69.        
  70.         foreach ($elements as $option) {
  71.            
  72.             if (!empty($option)) {
  73.                
  74.                 $set_flags = 1;
  75.                
  76.             }
  77.            
  78.             else {
  79.                
  80.                 $set_flags = 0;
  81.                
  82.             }
  83.            
  84.             if (1 == $set_flags) {
  85.                
  86.                 break;
  87.                
  88.             }
  89.            
  90.         }
  91.        
  92.     }
  93. ?>
  94.  
  95. <?php
  96.     if (!function_exists('interface_footer_infoblog')): /**
  97.    
  98.     * This function for social links display on header
  99.    
  100.     *
  101.    
  102.     * Get links through Theme Options
  103.    
  104.     */
  105.         function interface_footer_infoblog($set_flags, $place = '')
  106.         {
  107.            
  108.            
  109.            
  110.             global $interface_theme_setting_value;
  111.            
  112.             $options = $interface_theme_setting_value;
  113.            
  114.             $interface_footer_infoblog = '';
  115.            
  116.             $place = '';
  117.            
  118.             if ($set_flags || (!empty($options['social_phone']) || !empty($options['social_email']) || !empty($options['social_location']))) {
  119.                
  120.                 $interface_footer_infoblog .= '<div class="info-bar">
  121.  
  122.         <div class="container clearfix">';
  123.                
  124.                 if (!empty($options['social_phone']) || !empty($options['social_email']) || !empty($options['social_location'])) {
  125.                    
  126.                     $interface_footer_infoblog .= '<div class="info clearfix">
  127.  
  128.                                             <ul>';
  129.                    
  130.                     if (!empty($options['social_phone'])) {
  131.                        
  132.                        
  133.                        
  134.                         $interface_footer_infoblog .= '<li class=' . '"phone-number"' . '><a title=' . __('" Call Us "') . ' ' . 'href=' . '"tel:';
  135.                        
  136.                         $interface_footer_infoblog .= preg_replace("/[^() 0-9+-]/", '', $options['social_phone']);
  137.                        
  138.                        
  139.                        
  140.                         $interface_footer_infoblog .= '">';
  141.                        
  142.                         $interface_footer_infoblog .= preg_replace("/[^() 0-9+-]/", '', $options['social_phone']);
  143.                        
  144.                         $interface_footer_infoblog .= '</a></li>';
  145.                        
  146.                        
  147.                        
  148.                     }
  149.                     if (!empty($options['social_email'])) {
  150.                        
  151.                        
  152.                        
  153.                        
  154.                        
  155.                         $interface_footer_infoblog .= '<li class=' . '"email"' . '><a title=' . __('" Mail Us "') . ' ' . 'href=' . '"mailto:';
  156.                        
  157.                         $interface_footer_infoblog .= is_email($options['social_email']);
  158.                        
  159.                         $interface_footer_infoblog .= '">';
  160.                        
  161.                         $interface_footer_infoblog .= is_email($options['social_email']);
  162.                        
  163.                         $interface_footer_infoblog .= '</a></li>';
  164.                        
  165.                        
  166.                        
  167.                     }
  168.                     if (!empty($options['social_location'])) {
  169.                        
  170.                        
  171.                        
  172.                         $interface_footer_infoblog .= '<li class=' . '"address"' . '>';
  173.                        
  174.                         $interface_footer_infoblog .= esc_attr($options['social_location']);
  175.                        
  176.                         $interface_footer_infoblog .= '</li>';
  177.                        
  178.                     }
  179.                    
  180.                     $interface_footer_infoblog .= '</ul>
  181.  
  182.         </div><!-- .info -->';
  183.                    
  184.                 }
  185.                
  186.             }
  187.            
  188.             else if ($place == "header" && $set_flags == 1)
  189.                 $interface_footer_infoblog .= '<div class="info-bar">
  190.  
  191.         <div class="container clearfix">';
  192.            
  193.            
  194.            
  195.             echo $interface_footer_infoblog;
  196.            
  197.         }
  198.     endif;
  199.    
  200.    
  201.    
  202.     if (1 != $options['disable_top']) {
  203.        
  204.         interface_footer_infoblog($set_flags, "header");
  205.        
  206.         /****************************************************************************************/
  207.        
  208.     }
  209.    
  210.     if (!function_exists('interface_socialnetworks')): /**
  211.    
  212.     * This function for social links display on header
  213.    
  214.     *
  215.    
  216.     * Get links through Theme Options
  217.    
  218.     */
  219.         function interface_socialnetworks($set_flags)
  220.         {
  221.            
  222.            
  223.            
  224.             global $interface_theme_setting_value;
  225.            
  226.             $options = $interface_theme_setting_value;
  227.            
  228.             $interface_socialnetworks = '';
  229.            
  230.             if ((1 != $set_flags) || (1 == $set_flags)) {
  231.                
  232.                 $social_links = array();
  233.                
  234.                 $social_links_name = array();
  235.                
  236.                 $social_links_name = array(
  237.                     __('Facebook', 'interface'), // __ double underscore gets the value for translation
  238.                    
  239.                     __('Twitter', 'interface'),
  240.                    
  241.                     __('Google Plus', 'interface'),
  242.                    
  243.                     __('Pinterest', 'interface'),
  244.                    
  245.                     __('Youtube', 'interface'),
  246.                    
  247.                     __('Vimeo', 'interface'),
  248.                    
  249.                     __('LinkedIn', 'interface'),
  250.                    
  251.                     __('Flickr', 'interface'),
  252.                    
  253.                     __('Tumblr', 'interface'),
  254.                    
  255.                     __('RSS', 'interface')
  256.                    
  257.                 );
  258.                
  259.                 $social_links = array(
  260.                     'Facebook' => 'social_facebook',
  261.                    
  262.                     'Twitter' => 'social_twitter',
  263.                    
  264.                     'Google-Plus' => 'social_googleplus',
  265.                    
  266.                     'Pinterest' => 'social_pinterest',
  267.                    
  268.                     'You-tube' => 'social_youtube',
  269.                    
  270.                     'Vimeo' => 'social_vimeo',
  271.                    
  272.                     'linkedin' => 'social_linkedin',
  273.                    
  274.                     'Flickr' => 'social_flickr',
  275.                    
  276.                     'Tumblr' => 'social_tumblr',
  277.                    
  278.                     'RSS' => 'social_rss'
  279.                    
  280.                 );
  281.                
  282.                
  283.                
  284.                
  285.                
  286.                
  287.                
  288.                
  289.                
  290.                 $i = 0;
  291.                
  292.                 $a = '';
  293.                
  294.                 foreach ($social_links as $key => $value) {
  295.                    
  296.                     if (!empty($options[$value])) {
  297.                        
  298.                         $a .= '<li class="' . strtolower($key) . '"><a href="' . esc_url($options[$value]) . '" title="' . sprintf(esc_attr__('%1$s on %2$s', 'interface'), get_bloginfo('name'), $social_links_name[$i]) . '" target="_blank">' . '</a></li>';
  299.                        
  300.                     }
  301.                    
  302.                     $i++;
  303.                    
  304.                 }
  305.                
  306.                
  307.                
  308.                 if ($i > 0) {
  309.                    
  310.                     $interface_socialnetworks .= '<div class="social-profiles clearfix">
  311.  
  312.                     <ul>';
  313.                    
  314.                     $interface_socialnetworks .= $a;
  315.                    
  316.                    
  317.                    
  318.                    
  319.                    
  320.                     $interface_socialnetworks .= '
  321.  
  322.                 </ul>
  323.  
  324.                 </div><!-- .social-profiles -->';
  325.                    
  326.                 }
  327.                
  328.                
  329.                
  330.             }
  331.            
  332.             echo $interface_socialnetworks;
  333.            
  334.            
  335.            
  336.         }
  337.     endif;
  338.    
  339.     if (1 != $options['disable_top']) {
  340.        
  341.         interface_socialnetworks($set_flags);
  342.        
  343.     }
  344.    
  345.     /****************************************************************************************/
  346. ?>
  347.  
  348. <?php
  349.     if (1 != $options['disable_top'] && ($set_flags == 1 || (!empty($options['social_phone']) || !empty($options['social_email']) || !empty($options['social_location'])))) {
  350. ?>
  351.  
  352. </div>
  353.  
  354. <!-- .container -->
  355.  
  356. </div>
  357.  
  358. <!-- .info-bar -->
  359.  
  360. <?php
  361.     }
  362. ?>
  363.  
  364. <?php
  365.     $header_image = get_header_image();
  366.    
  367.     if (!empty($header_image)):
  368. ?>
  369.  
  370. <a href="<?php
  371.         echo esc_url(home_url('/'));
  372. ?>"><img src="<?php
  373.         echo esc_url($header_image);
  374. ?>" class="header-image" width="<?php
  375.         echo get_custom_header()->width;
  376. ?>" height="<?php
  377.         echo get_custom_header()->height;
  378. ?>" alt="<?php
  379.         echo esc_attr(get_bloginfo('name', 'display'));
  380. ?>"> </a>
  381.  
  382. <?php
  383.     endif;
  384. ?>
  385.  
  386. <div class="hgroup-wrap">
  387.  
  388.   <div class="container clearfix">
  389.  
  390.     <section id="site-logo" class="clearfix">
  391.  
  392.       <?php
  393.    
  394.     if ($options['header_show'] != 'disable-both' && $options['header_show'] == 'header-text') {
  395.        
  396. ?>
  397.  
  398.       <h1 id="site-title"> <a href="<?php
  399.         echo esc_url(home_url('/'));
  400. ?>" title="<?php
  401.         echo esc_attr(get_bloginfo('name', 'display'));
  402. ?>" rel="home">
  403.  
  404.         <?php
  405.         bloginfo('name');
  406. ?>
  407.  
  408.         </a> </h1>
  409.  
  410.       <h2 id="site-description">
  411.  
  412.         <?php
  413.         bloginfo('description');
  414. ?>
  415.  
  416.       </h2>
  417.  
  418.       <?php
  419.        
  420.     }
  421.    
  422.     elseif ($options['header_show'] != 'disable-both' && $options['header_show'] == 'header-logo') {
  423.        
  424. ?>
  425.  
  426.       <h1 id="site-title"> <a href="<?php
  427.         echo esc_url(home_url('/'));
  428. ?>" title="<?php
  429.         echo esc_attr(get_bloginfo('name', 'display'));
  430. ?>" rel="home"> <img src="<?php
  431.         echo $options['header_logo'];
  432. ?>" alt="<?php
  433.         echo esc_attr(get_bloginfo('name', 'display'));
  434. ?>"> </a> </h1>
  435.  
  436.       <?php
  437.        
  438.     }
  439.    
  440. ?>
  441.  
  442.     </section>
  443.  
  444.     <!-- #site-logo -->
  445.  
  446.     <button class="menu-toggle">Responsive Menu</button>
  447.  
  448.     <section class="hgroup-right">
  449.  
  450.       <?php
  451.    
  452.     if (has_nav_menu('primary')) { // if there is nav menu then content displayed from nav menu else from pages
  453.        
  454.         $args = array(
  455.            
  456.             'theme_location' => 'primary',
  457.            
  458.             'container' => '',
  459.            
  460.             'items_wrap' => '<ul class="nav-menu">%3$s</ul>'
  461.            
  462.            
  463.            
  464.         );
  465.        
  466.         echo '<nav id="access" class="clearfix">';
  467.        
  468.        
  469.        
  470.         wp_nav_menu($args); //extract the content from apperance-> nav menu
  471.        
  472.         echo '</nav><!-- #access -->';
  473.        
  474.     }
  475.    
  476.     else { // extract the content from page menu only
  477.        
  478.         echo '<nav id="access" class="clearfix">';
  479.        
  480.         wp_page_menu(array(
  481.             'menu_class' => 'nav-menu'
  482.         ));
  483.        
  484.         echo '</nav><!-- #access -->';
  485.        
  486.     }
  487.    
  488. ?>
  489.  
  490.       <div class="search-toggle"></div>
  491.  
  492.       <!-- .search-toggle -->
  493.  
  494.       <div id="search-box" class="hide">
  495.  
  496.         <?php
  497.     get_search_form();
  498. ?>
  499.  
  500.         <span class="arrow"></span> </div>
  501.  
  502.       <!-- #search-box -->
  503.  
  504.     </section>
  505.  
  506.     <!-- .hgroup-right -->
  507.  
  508.   </div>
  509.  
  510.   <!-- .container -->
  511.  
  512. </div>
  513.  
  514. <!-- .hgroup-wrap -->
  515.  
  516.  
  517.  
  518. <?php
  519.    
  520.     if ('above-slider' == $options['slogan_position'] && (is_home() || is_front_page()))
  521.         if (function_exists('interface_home_slogan'))
  522.             interface_home_slogan();
  523.    
  524.    
  525.    
  526.     if (is_home() || is_front_page()) {
  527.        
  528.         if ("0" == $options['disable_slider']) {
  529.            
  530.             if (function_exists('interface_pass_slider_effect_cycle_parameters'))
  531.                 interface_pass_slider_effect_cycle_parameters();
  532.            
  533.             if (function_exists('interface_featured_sliders'))
  534.                 interface_featured_sliders();
  535.            
  536.         }
  537.        
  538.     }
  539.    
  540.     else {
  541.        
  542.         if (('' != interface_header_title()) || function_exists('bcn_display_list')) {
  543.            
  544. ?>
  545.        
  546.  
  547. <div class="page-title-wrap">
  548.  
  549.   <div class="container clearfix">
  550.  
  551.     <?php
  552.            
  553.             if (function_exists('interface_breadcrumb'))
  554.                 interface_breadcrumb();
  555.            
  556. ?>
  557.  
  558.     <h1 class="page-title"><?php
  559.             echo interface_header_title();
  560. ?></h1>
  561.  
  562.     <!-- .page-title -->
  563.  
  564.   </div>
  565.  
  566. </div>
  567.  
  568. <?php
  569.            
  570.         }
  571.        
  572.     }
  573.    
  574.     if ('below-slider' == $options['slogan_position'] && (is_home() || is_front_page()))
  575.         if (function_exists('interface_home_slogan'))
  576.             interface_home_slogan();
  577.    
  578.    
  579.    
  580. }
  581.  
  582.  
  583. ///////////////////////////////////////////////////////////////////////////////////
  584. //END CUSTOMIZED THEME HEADER ////////////////////////////////////////////////////
  585. /////////////////////////////////////////////////////////////////////////////////
  586. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement