Twenty Eleven: use callback in functions.php to enqueue scripts and styles rather than putting them directly in header.php template file. Props obenland, see #23772.

git-svn-id: http://core.svn.wordpress.org/trunk@23720 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Lance Willett 2013-03-15 18:24:04 +00:00
parent 24e099bb3e
commit dd99d5ce94
2 changed files with 21 additions and 7 deletions

View File

@ -326,6 +326,27 @@ function twentyeleven_admin_header_image() { ?>
<?php } <?php }
endif; // twentyeleven_admin_header_image endif; // twentyeleven_admin_header_image
/**
* Enqueue scripts and styles.
*
* Hooked on priority 0 to make sure they are enqueued prior to dependent
* scripts/styles. This is only necessary because they were previously enqueued
* prior to wp_head() running, and we want to provide maximum
* backwards compatibility.
*
* @since Twenty Eleven 1.6
*/
function twentyeleven_scripts() {
wp_enqueue_style( 'twentyeleven', get_stylesheet_uri() );
/* We add some JavaScript to pages with the comment form
* to support sites with threaded comments (when in use).
*/
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
wp_enqueue_script( 'comment-reply' );
}
add_action( 'wp_enqueue_scripts', 'twentyeleven_scripts', 0 );
/** /**
* Sets the post excerpt length to 40 words. * Sets the post excerpt length to 40 words.
* *

View File

@ -26,18 +26,11 @@
<meta name="viewport" content="width=device-width" /> <meta name="viewport" content="width=device-width" />
<title><?php wp_title( '|', true, 'right' ); ?></title> <title><?php wp_title( '|', true, 'right' ); ?></title>
<link rel="profile" href="http://gmpg.org/xfn/11" /> <link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" /> <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script> <script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script>
<![endif]--> <![endif]-->
<?php <?php
/* We add some JavaScript to pages with the comment form
* to support sites with threaded comments (when in use).
*/
if ( is_singular() && get_option( 'thread_comments' ) )
wp_enqueue_script( 'comment-reply' );
/* Always have wp_head() just before the closing </head> /* Always have wp_head() just before the closing </head>
* tag of your theme, or you will break many plugins, which * tag of your theme, or you will break many plugins, which
* generally use this hook to add elements to <head> such * generally use this hook to add elements to <head> such