[theme-reviewers] wp_enqueue_script
Otto
otto at ottodestruct.com
Wed Sep 15 17:23:34 UTC 2010
I would recommend against use of template_redirect for this. The
correct action hook to use is wp_enqueue_scripts, and it even says so
right in the code.
/**
* Wrapper for do_action('wp_enqueue_scripts')
*
* Allows plugins to queue scripts for the front end using wp_enqueue_script().
* Runs first in wp_head() where all is_home(), is_page(), etc.
functions are available.
*
* @since 2.8
*/
function wp_enqueue_scripts() {
do_action('wp_enqueue_scripts');
}
-Otto
On Wed, Sep 15, 2010 at 11:01 AM, Edward Caissie
<edward.caissie at gmail.com> wrote:
> Just a thought ...
>
> IF 'template_redirect' is being co-opted into this role, could not a new
> more appropriately named hook be considered, perhaps something along the
> lines of: 'pre_frontend' ... which may lead to a potential 'post_frontend'
> as well? Even something prefixed with 'before_' and 'after_' would be great.
>
> I'm just thinking something that has a slightly more intuitive name
> convention rather than relying on an in-depth recognition of hook/action
> priority sequences.
>
>
> Cais.
>
> On Wed, Sep 15, 2010 at 11:35 AM, Andrew Nacin <wp at andrewnacin.com> wrote:
>>
>>
>> On Wed, Sep 15, 2010 at 11:31 AM, Austin Matzko <austin at pressedcode.com>
>> wrote:
>>>
>>> On Wed, Sep 15, 2010 at 10:21 AM, Chip Bennett <chip at chipbennett.net>
>>> wrote:
>>> > But, what we really need is what the official best-practice suggestion
>>> > will
>>> > be, for the purposes of the Guidelines. We need to ensure that all
>>> > reviewers
>>> > will be making consistent suggestions with respect to
>>> > wp_enqueue_script()
>>> > within functions.php.
>>>
>>> It's really a range depending on what you're trying to do: before init
>>> is too early; default wp_head is too late.
>>>
>>> I would strongly recommend that front-end scripts not be enqueued in
>>> the admin, so that means checking that is_admin() returns false if a
>>> front-end conditional "tag" like is_singular() isn't already used.
>>
>> The point is, before init is too early, but on init means it'll show up in
>> the admin.
>> Hence template_redirect is a good option, as that is enough to ensure it
>> only
>> gets enqueued for the frontend, with no is_admin() check required.
>> _______________________________________________
>> 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
>
>
More information about the theme-reviewers
mailing list