• Resolved waddell

    (@waddell)


    I am helping admin a website that is a part of the WoW gaming community. The newest idea is to have rotating header images based on the date, that line up with the ongoing in-game event. I have written the php needed to find the date and echo the location of the image, but I am having a problem replacing the current theme’s code for the header. When I do replace it, I get a syntax error and just don’t understand. Here’s what it looks like before, if someone can give me an idea on what I need to replace or change I would appreciate the help.

    header.php

    <!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" <?php language_attributes(); ?>>
    
    <head profile="http://gmpg.org/xfn/11">
    <script src="http://www.wowhead.com/widgets/power.js"></script>
    <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
    
    <title>
    		<?php if ( is_home() ) { ?><?php bloginfo('description'); ?> | <?php bloginfo('name'); ?><?php } ?>
    		<?php if ( is_search() ) { ?><?php echo $s; ?> | <?php bloginfo('name'); ?><?php } ?>
    		<?php if ( is_single() ) { ?><?php wp_title(''); ?> | <?php bloginfo('name'); ?><?php } ?>
    		<?php if ( is_page() ) { ?><?php wp_title(''); ?> | <?php bloginfo('name'); ?><?php } ?>
    		<?php if ( is_category() ) { ?><?php _e('Archive', 'elegant-grunge') ?> <?php single_cat_title(); ?> | <?php bloginfo('name'); ?><?php } ?>
    		<?php if ( is_month() ) { ?><?php _e('Archive', 'elegant-grunge') ?> <?php the_time('F'); ?> | <?php bloginfo('name'); ?><?php } ?>
    		<?php if ( is_tag() ) { ?><?php single_tag_title();?> | <?php bloginfo('name'); ?><?php } ?>
    </title>
    
    <?php elegant_grunge_the_favicon() ?>
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
    
    <?php if ( get_option('header_image') ) : ?>
    <style type="text/css">
    #header div {
    	background: url(<?php echo get_option('header_image'); ?>) no-repeat center top;
    	width: 100%;
    	height: 100%;
    	display: block;
    }
    #header * {
            display: none;
    }
    </style>
    <?php endif; ?>
    
    <!--[if IE]>
    <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_directory'); ?>/ie.css" />
    <style type="text/css">
    #footer #subscribe a {
    	background:none;
    	filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='<?php bloginfo('template_url')?>/images/rss.png');
    }
    <?php if ( get_option('header_image') ) : ?>
    #header div {
    	background: none;
    	filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='<?php echo get_option('header_image')?>');
    }
    <?php endif; ?>
    </style>
    <![endif]-->
    
    <link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />
    <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
    
    <?php echo get_option("extra_header") ?>
    
    <?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
    
    <?php wp_head(); ?>
    
    </head>
    
    <?php
    if ( !defined('EG_BODY_CLASS') && get_option('page_setup') != 'right-sidebar' )
    	define('EG_BODY_CLASS', get_option('page_setup'));
    ?>
    
    <body <?php if ( defined('EG_BODY_CLASS') ) echo 'class="'.EG_BODY_CLASS.'"'; ?>>
    
    <div id="page">
    
    <div id="menu">
    	<ul>
    		<li class="page_item <?php if ( is_home() ) { ?>current_page_item<?php } ?>"><a href="<?php bloginfo('url'); ?>"><?php _e('Home', 'elegant-grunge') ?></a></li>
    		<?php wp_list_pages('title_li=&depth=1'); ?>
    	</ul>
    	<div class="clear"></div>
    </div>
    
    <div id="header-wrap">
    <div id="header">
    	<div>
    		<h1><a href="<?php bloginfo('home') ?>"><?php bloginfo('name'); ?></a></h1>
    		<span id="blog-description"><?php bloginfo('description'); ?></span>
    	</div>
    </div>
    </div>
    
    <!-- end header -->

    header_dates.php

    <?php
    /* Date format: 07.08 (month.day)
    
    01.01		New Year's Day
    02.11 - 02.16	Love is in the Air
    02.12 - 03.03	Lunar Festival
    04.04 - 04.10	Noble Garden
    05.01 - 05.07	Children's Week
    06.21 - 07.05	Midsummer Fire Festival
    09.19		Pirates' Day
    09.20 - 10.03	Brewfest
    09.27 - 10.03	Harvest Festival
    10.18 - 11.02	Hallow's End
    12.15 - 01.02	Feast of Winter Veil
    12.31		New Year's Eve
    */
    
    $d=date("m.d");
    
    switch($d)
    {
        case '01.01'; //New Year's Day
    	echo 'wp-content/themes/elegant-grunge/images/header_newyear.jpg';
        break;
    
        case '02.11'; //Love is in the Air
    	echo 'wp-content/themes/elegant-grunge/images/header_valentines.jpg';
        break;
    
        case '02.12'; //Lunar Festival & Love is in the Air
        case '02.13';
        case '02.14';
        case '02.15';
        case '02.16';
    	echo 'wp-content/themes/elegant-grunge/images/header_lunar.jpg';
        break;
    
        case '02.17'; //Lunar Festival
        case '02.18';
        case '02.19';
        case '02.20';
        case '02.21';
        case '02.22';
        case '02.23';
        case '02.24';
        case '02.25';
        case '02.26';
        case '02.27';
        case '02.28';
        case '02.29';
        case '03.01';
        case '03.02';
        case '03.03';
    	echo 'wp-content/themes/elegant-grunge/images/header_lunar.jpg';
        break;
    
        case '04.04'; //Noble Garden
        case '04.05';
        case '04.06';
        case '04.07';
        case '04.08';
        case '04.09';
        case '04.10';
    	echo 'wp-content/themes/elegant-grunge/images/header_noble.jpg';
        break;
    
        case '05.01'; //Children's Week
        case '05.02';
        case '05.03';
        case '05.04';
        case '05.05';
        case '05.06';
        case '05.07';
    	echo 'wp-content/themes/elegant-grunge/images/header_children.jpg';
        break;
    
        case '05.21'; //Midsummer Fire Festival
        case '05.22';
        case '05.23';
        case '05.24';
        case '05.25';
        case '05.26';
        case '05.27';
        case '05.28';
        case '05.29';
        case '05.30';
        case '06.01';
        case '06.02';
        case '06.03';
        case '06.04';
        case '06.05';
    	echo 'wp-content/themes/elegant-grunge/images/header_midsummer.jpg';
        break;
    
        case '09.19'; //Pirates Day
    	echo 'wp-content/themes/elegant-grunge/images/header_pirate.jpg';
        break;
    
        case '09.20'; //Brewfest
        case '09.21';
        case '09.22';
        case '09.23';
        case '09.24';
        case '09.25';
        case '09.26';
    	echo 'wp-content/themes/elegant-grunge/images/header_brewfest.jpg';
        break;
    
        case '09.27'; //Harvest Festival & Brewfest
        case '09.28';
        case '09.29';
        case '09.30';
        case '10.01';
        case '10.02';
        case '10.03';
    	echo 'wp-content/themes/elegant-grunge/images/header_harvest.jpg';
        break;
    
        case '10.18'; //Hallow's End
        case '10.19';
        case '10.20';
        case '10.21';
        case '10.22';
        case '10.23';
        case '10.24';
        case '10.25';
        case '10.26';
        case '10.27';
        case '10.28';
        case '10.29';
        case '10.30';
        case '10.31';
        case '11.01';
        case '11.02';
    	echo 'wp-content/themes/elegant-grunge/images/header_halloween.jpg';
        break;
    
        case '12.15'; //Feast of Winter Veil
        case '12.16';
        case '12.17';
        case '12.18';
        case '12.19';
        case '12.20';
        case '12.21';
        case '12.22';
        case '12.23';
        case '12.24';
        case '12.25';
        case '12.26';
        case '12.27';
        case '12.28';
        case '12.29';
        case '12.30';
        case '01.02';
    	echo 'wp-content/themes/elegant-grunge/images/header_winterveil.jpg';
        break;
    
        case '12.31'; //New Year's Eve
    	echo 'wp-content/themes/elegant-grunge/images/header_newyeareve.jpg';
        break;
    
        default; //Default Image
            echo 'wp-content/themes/elegant-grunge/images/header.jpg';
        break;
    }
    ?>

The topic ‘PHP Modification, need help’ is closed to new replies.