[theme-reviewers] Hooking wp_enqueue_script( 'comment-reply' ) into wp_head

Chip Bennett chip at chipbennett.net
Thu Apr 21 18:44:48 UTC 2011


One more for today:

Most Themes drop the wp_enqueue_script( 'comment-reply' ) code directly into
the document head, but it *can* be hooked into wp_head, if given the correct
priority.

I *think* wp_enqueue_styles fires at priority 1 in wp_head. Regardless,
passing priority 0 to the enqueue function *does* work. e.g.:

function oenology_enqueue_comment_reply() {
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
{
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_head', 'oenology_enqueue_comment_reply', 0 );


Notice that I've also added a comments_open() to the conditional.

Any comments/ideas/suggestions?

Chip
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wordpress.org/pipermail/theme-reviewers/attachments/20110421/a1bf977b/attachment.htm>


More information about the theme-reviewers mailing list