Support » Fixing WordPress » header.php clean-up

  • Johnny Bravo

    (@herbiehysteria)


    hi , just a quickie, overtime ive kinda clogged my header.php file n need to clean it, 2 years ago i was messin wiv fb og tags n i think the code is redundant cos i use shareholic plugin nw that does all that. the goiogle custom search code should stay. i also upgraded my menus to dynamic menus so i think the ‘exclude’ code is redundant too. cn u pls do a quick clean up?

    <?php
    /**
     * @package WordPress
     * @subpackage Default_Theme
     */
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="https://www.facebook.com/2008/fbml">
    
    <head profile="http://gmpg.org/xfn/11">
    <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
    
    <title><?php wp_title('&laquo;', true, 'right'); ?> <?php bloginfo('name'); ?></title>
    
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
    <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
    <link rel="icon" href="<?php bloginfo('siteurl'); ?>/favicon.ico" type="image/x-icon" />
    <link rel="shortcut icon" href="<?php bloginfo('template_directory'); ?>/favicon.ico" type="image/x-icon" />
    <!--[if IE 6]>
    <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url'); ?>/iestyle.css" />
    <![endif]-->
    <style type="text/css" media="screen">
    
    <?php
    global $post;
    $current_page_id = $post->ID;
    // Checks to see whether it needs a sidebar or not
    if ( empty($withcomments) && !is_single() ) {
    ?>
    	#page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbg-<?php bloginfo('text_direction'); ?>.jpg") repeat-y top; border: none; }
    <?php } else { /* No sidebar */?>
    	#page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbgwide.jpg") repeat-y top; border: none; }
    <?php } ?>
    <?php if ( $current_page_id == 2748 ){?>
    	#menu-item-2757 a {
    		background: url(http://www.artbyherbie.com/wp-content/themes/indezinerpaperwall/images/menu_link_bg.gif) repeat-x center;
    		color: #64431E;
    	}
    <?php } ?>
    </style>
    
    <?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
    
    <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <meta property="og:title" content="<?php the_title(); ?>"/>
    <meta property="og:type" content="<?php if (is_singular()) { echo "article"; } else { echo "website";} ?>"/>
    
    <!-- Put the following javascript before the closing </head> tag. -->
    <script type="text/javascript">
      (function() {
        var cx = '017502216997493018940:WMX205779490';
        var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true;
        gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
            '//www.google.com/cse/cse.js?cx=' + cx;
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s);
      })();
    </script>
    
    <?php if (have_posts()):while(have_posts()):the_post(); endwhile; endif;?>
    
    <!-- if page is content page -->
    <?php if (is_single()) { ?>
    <meta property="og:url" content="<?php the_permalink() ?>"/>
    <meta property="og:title" content="<?php single_post_title(''); ?>" />
    <meta property="og:description" content="<?php echo esc_attr( wp_trim_words( strip_tags( strip_shortcodes( $post->post_content ) ), 55 ) ); ?>" />
    <meta property="og:type" content="article" />
    <meta property="og:image" content="<?php if (function_exists('wp_get_attachment_thumb_url')) {echo wp_get_attachment_thumb_url(get_post_thumbnail_id($post->ID)); }?>" />  
    
    <!-- if page is others -->
    <?php } else { ?>
    <meta property="og:site_name" content="<?php bloginfo('name'); ?>" />
    <meta property="og:description" content="<?php bloginfo('description'); ?>" />
    <meta property="og:type" content="website" />
    <meta property="og:image" content="http://www.artbyherbie.com/wp-content/uploads/2012/12/app75x75.png" /> <?php } ?>
    <?php wp_head(); ?>
    </head>
    <body <?php body_class(); ?>>
    <div id="fb-root"></div>
    <script>
      window.fbAsyncInit = function() {
        FB.init({appId: '157766117692061', status: true, cookie: true,
                 xfbml: true});
      };
      (function() {
        var e = document.createElement('script'); e.async = true;
        e.src = document.location.protocol +
          '//connect.facebook.net/en_US/all.js';
        document.getElementById('fb-root').appendChild(e);
      }());
    </script>
    <div id="main_container">
    
    <div id="header" role="banner">
    
    	       	<div class="logo">
    
                </div>
    
    </div>
    
    <div class="center_content">
    	<div class="center_content_top">
        	<div class="center_content_bottom">
    
    		<?php
    		function do_the_menu (){
    			wp_page_menu('show_home=1&exclude=6,8, 10, 12, 14, 16, 32, 73, 75, 385, 389, 392, 398, 400, 404, 407, 509, 620, 651, 747, 765, 1037, 1038, 1039, 1040, 1112, 1644, 1826, 2544&menu_class=menu');
    		}
    		//first check if wp_nav_menu has been declared
    		if (function_exists('wp_nav_menu')){
    			//if it has been declared then use it
    			wp_nav_menu( array( 'sort_column' => 'menu_order',
    								'theme_location' => 'primary',
    								'menu' => 'main',
    								'menu_class' => 'sf-menu',
    								'fallback_cb' => 'do_the_menu',
    								'container_class' => 'menu'
    							  )
    						);
    		}else{
    			//if wp_nav_menu doesnt exist we use wp_page_menu
    			do_the_menu();
    		}
    		?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘header.php clean-up’ is closed to new replies.