From b989307db1db9b106b0b697b934b77dfe73cdb6c Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Fri, 15 Mar 2013 18:24:45 +0000 Subject: [PATCH] Twenty Ten: use callback in functions.php to enqueue scripts and styles rather than putting them directly in header.php template file. Props obenland, fixes #23772. git-svn-id: https://develop.svn.wordpress.org/trunk@23721 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-content/themes/twentyten/functions.php | 21 +++++++++++++++++++++ wp-content/themes/twentyten/header.php | 7 ------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/wp-content/themes/twentyten/functions.php b/wp-content/themes/twentyten/functions.php index 3e8fd3bd26..77d7b0a11a 100644 --- a/wp-content/themes/twentyten/functions.php +++ b/wp-content/themes/twentyten/functions.php @@ -215,6 +215,27 @@ function twentyten_admin_header_style() { } endif; +/** + * 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 Ten 1.6 + */ +function twentyten_scripts() { + wp_enqueue_style( 'twentyten', 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', 'twentyten_scripts', 0 ); + /** * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link. * diff --git a/wp-content/themes/twentyten/header.php b/wp-content/themes/twentyten/header.php index 41eaea52f1..f45c34b02b 100644 --- a/wp-content/themes/twentyten/header.php +++ b/wp-content/themes/twentyten/header.php @@ -14,15 +14,8 @@ <?php wp_title( '|', true, 'right' ); ?> - * tag of your theme, or you will break many plugins, which * generally use this hook to add elements to such