From d56335491315e413e826459db0a77afd6648c507 Mon Sep 17 00:00:00 2001 From: Benedict Eastaugh Date: Sun, 22 Jan 2012 23:40:49 +0000 Subject: [PATCH] Call wp_enqueue_script from within an action. As of WP 3.3 this is the preferred usage. Thanks to Henry C. Gernhardt, III and Martin Lormes for reporting this issue. --- changelog.txt | 8 ++++++++ functions.php | 5 +---- library/helpers/template_helper.php | 23 ++++++++++++++++++++++- style.css | 2 +- style.dev.css | 2 +- 5 files changed, 33 insertions(+), 7 deletions(-) diff --git a/changelog.txt b/changelog.txt index b7769aa..5fd0650 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,13 @@ # Changelog +### Version 3.1.3 + +#### Bug fixes + + * `wp_enqueue_script` is now only called from within actions, as per a change + in WordPress 3.3. + + ### Version 3.1.2 #### Bug fixes diff --git a/functions.php b/functions.php index eb1085b..d1b44d3 100644 --- a/functions.php +++ b/functions.php @@ -174,10 +174,7 @@ add_action('admin_head', 'maybe_wipe_tarski_options'); } else { // JavaScript - wp_enqueue_script('tarski', - tarski_asset_path('app/js/tarski.js'), - array('jquery'), theme_version()); - wp_enqueue_script('comment-reply'); + add_action('wp_enqueue_scripts', 'tarski_enqueue_scripts'); } // Header diff --git a/library/helpers/template_helper.php b/library/helpers/template_helper.php index fc6ba0b..14ecc34 100644 --- a/library/helpers/template_helper.php +++ b/library/helpers/template_helper.php @@ -156,6 +156,28 @@ function tarski_meta() { _tarski_asset_output('asset_meta', $meta); } +/** + * Enqueue Tarski's own JavaScript and the comment reply script. + * + * @since 3.1.3 + * + * @uses wp_enqueue_script + * @uses tarski_asset_path + * @uses theme_version + * + * @see tarski_meta + * @see tarski_stylesheets + * + * @return void + */ +function tarski_enqueue_scripts() { + wp_enqueue_script('tarski', + tarski_asset_path('app/js/tarski.js'), + array('jquery'), theme_version()); + + wp_enqueue_script('comment-reply'); +} + /** * Generate links to the various Tarski stylesheets. * @@ -167,7 +189,6 @@ function tarski_meta() { * @uses _tarski_asset_output * * @see tarski_meta - * @see tarski_javascript * * @return void * diff --git a/style.css b/style.css index ee6d151..dd3107f 100644 --- a/style.css +++ b/style.css @@ -5,7 +5,7 @@ Description: An elegant, flexible theme developed by