[theme-reviewers] Hooking wp_enqueue_script( 'comment-reply' ) into wp_head
Chip Bennett
chip at chipbennett.net
Thu Apr 21 19:07:40 UTC 2011
I think(?) this is an edge/special-use case, because one hook,
wp_enqueue_scripts, fires inside of another hook, wp_head (if I'm
understanding things properly), and we have to hook into the process both
*before* wp_enqueue_scripts fires, but *after* the query is set up (so that
we have access to the query conditional tags).
Looking at the action hook
list<http://codex.wordpress.org/Plugin_API/Action_Reference>,
perhaps hooking into get_header or template_redirect would work (if such use
would be valid)?
I'm of course open to any better alternatives?
Chip
On Thu, Apr 21, 2011 at 1:57 PM, Edward Caissie <edward.caissie at gmail.com>wrote:
> The only thing that comes to mind is if any add_action requires the highest
> priority to be used "correctly" then perhaps it should be submitted as a
> core requirement (optional in settings?) ... just a thought; otherwise your
> function example looks fine.
>
>
> Cais.
>
> On Thu, Apr 21, 2011 at 2:44 PM, Chip Bennett <chip at chipbennett.net>wrote:
>
>> 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
>>
>> _______________________________________________
>> theme-reviewers mailing list
>> theme-reviewers at lists.wordpress.org
>> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>>
>>
>
> _______________________________________________
> theme-reviewers mailing list
> theme-reviewers at lists.wordpress.org
> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wordpress.org/pipermail/theme-reviewers/attachments/20110421/fb8aafc6/attachment.htm>
More information about the theme-reviewers
mailing list