Make WordPress Core

Ticket #9015: more-functions.php-patch.diff

File more-functions.php-patch.diff, 3.5 KB (added by ptahdunbar, 15 years ago)

Use the API for CSS and JS, wrapped the header background image into a function

  • wp-content/themes/twentyten/functions.php

     
    66// Your Changeable header business starts here
    77// No CSS, just IMG call
    88define( 'HEADER_TEXTCOLOR', '');
    9 define( 'HEADER_IMAGE', '%s/images/header-1.jpg'); // %s is theme dir uri
     9define( 'HEADER_IMAGE', '%s/images/header-1.jpg' ); // %s is theme dir uri
    1010define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width',  940 ) );
    1111define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height',  198 ) );
    1212define( 'NO_HEADER_TEXT', true );
     
    6565}
    6666add_filter( 'excerpt_more', 'twentyten_new_excerpt_more' );
    6767
     68// Enqueue the CSS stylesheets
     69function twentyten_enqueue_styles() {
     70        if ( !is_admin() ) {
     71                wp_enqueue_style( 'twentyten_style', get_bloginfo( 'stylesheet_url' ) );
     72                wp_enqueue_style( 'twentyten_print', get_stylesheet_directory_uri() . '/print.css', null, false, 'print' );
     73        }
     74}
     75add_action( 'init', 'twentyten_enqueue_styles' );
    6876
     77
     78// Enqueues the javascript for comment replys
     79function twentyten_enqueue_scripts() {
     80        if ( is_singular() and get_site_option('thread_comments') )
     81                wp_print_scripts( 'comment-reply' );
     82}
     83add_action( 'wp_head', 'twentyten_enqueue_scripts' );
     84
     85// Displays the post thumbnail image on singular pages. All other pages get the header image.
     86function twentyten_header_image() {
     87        global $post;
     88        if ( is_singular() && has_post_thumbnail( $post->ID ) ) {
     89                echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );
     90        } else { ?>
     91                <img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
     92                <?php
     93        }
     94}
     95
    6996// Template for comments and pingbacks
    7097function twentyten_list_comment( $comment, $args, $depth ) {
    7198        $GLOBALS['comment'] = $comment; ?>
  • wp-content/themes/twentyten/header.php

     
    2020        <meta http-equiv="content-type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
    2121
    2222        <link rel="profile" href="http://gmpg.org/xfn/11" />
    23         <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo('stylesheet_url'); ?>" />
    24         <link rel="stylesheet" type="text/css" media="print" href="<?php bloginfo('stylesheet_directory'); ?>/print.css" />
    25 
    26         <?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
    27 
     23       
    2824        <?php wp_head(); ?>
    2925
    3026        <link rel="alternate" type="application/rss+xml" href="<?php bloginfo( 'rss2_url' ); ?>" title="<?php printf( esc_attr__( '%s latest posts', 'twentyten' ), esc_html( get_bloginfo('name') ) ); ?>" />
     
    4238                                <div id="site-title"><span><a href="<?php echo home_url('/'); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></span></div>
    4339                                <div id="site-description"><?php bloginfo( 'description' ); ?></div>
    4440
    45                                 <?php
    46                                 if ( is_singular() && has_post_thumbnail( $post->ID ) ) {
    47                                         echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );
    48                                 } else { ?>
    49                                         <img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
    50                                 <?php } ?>
     41                                <?php twentyten_header_image(); ?>
    5142                        </div><!-- #branding -->
    5243
    5344                        <div id="access">