[theme-reviewers] Is wp_enqueue style/script necessary?

Emil Uzelac emil at themeid.com
Wed Aug 1 08:08:28 UTC 2012


Sorry, but that's incorrect. It's plugins responsibility to check whether
Theme uses jQuery or not and if it does plugin will usually not load
anything, that's proper way of doing this. And as far as the importance,
well no, if Theme is using an additional stylesheets it needs to
be enqueued as well. Kindly see:
http://codex.wordpress.org/Theme_Review#Including_Stylesheets_and_Scripts


   - Themes are *required* to enqueue all stylesheets and scripts, using
   wp_enqueue_style()<http://codex.wordpress.org/Function_Reference/wp_enqueue_style>
   /wp_enqueue_script()<http://codex.wordpress.org/Function_Reference/wp_enqueue_script>,
   and hooked into an appropriate hook via callback function, rather than
   hard-coding stylesheet/script links or tags in the template.
      - Themes are *required* to use the Theme-specific hook for
      admin-enqueued scripts/stylesheets, e.g.
      admin_print_scripts-appearance_page_$menu_slug
      - Themes are *recommended* to hook stylesheet and script enqueue
      callbacks into `wp_enqueue_scripts`
      - Themes may *optionally* link the default stylesheet (style.css)
      directly in the document head, or viawp_enqueue_style()
   - Themes are *required* to use core-bundled scripts, if using such
   scripts


and this is for WPORG Themes only :)

Emil

On Wed, Aug 1, 2012 at 3:01 AM, Fahd Murtaza <fahdim at gmail.com> wrote:

> Hello Wayne
>
> This is important. For example you want to include jQuery or you are
> writing a theme that includes jQuery in it, then you should use
> usingwp_enqueue_style()/wp_enqueue_script()  to ensure that your code
> is compatible with any future wordpress plugins that you use.
>
> These functions ensure that if there are two  wp_enqueue_script()
> used for same script twice or more, wordpress is smart enough to add
> them only once. I have found the  wp_enqueue_script() to be more
> useful than the wp_enqueue_style() as plugins can load additional
> scripts, which might conflict with what you're adding in your theme.
>
> For example, think of a plugin adding a different version of jQuery or
> even worse, adding it twice.
>
> Regards
> Fahd Murtaza
>
> Regards
> Fahd Murtaza
> +96893678199
> www.fahdmurtaza.com
>
>
>
> On Wed, Aug 1, 2012 at 11:43 AM, CONNOR Wayne and Jill <wayne at dubbo.org>
> wrote:
> >
> > I got this comment on last submission of my slidingdoor theme:
> >
> > Themes are REQUIRED to enqueue all stylesheets and scripts,
> usingwp_enqueue_style()/wp_enqueue_script(), and hooked into an appropriate
> hook via callback function, rather than hard-coding stylesheet/script links
> or tags in the template.
> >
> >
> > I've been to
> http://codex.wordpress.org/Function_Reference/wp_enqueue_script and I
> don't actually understand what it's saying. I don't want to get my head
> around it if I don't have to!
> >
> >
> > Is it talking about my inclusion of say mootools in my header.php?
> >
> > <script type="text/javascript" src="<?php echo $url;
> ?>/imagemenu/mootools.js"></script>
> >
> > Do I need to do this differently?
> >
> >
> >
> > It does say on the function reference page "The safe and recommended
> method of adding JavaScript to a WordPress generated page is by using
> wp_enqueue_script(). "
> >
> > 'recommended' is not 'you must'.
> >
> > I've checked out the twentyeleven theme and it has this in header:
> >
> > <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo(
> 'stylesheet_url' ); ?>" />
> >
> > that seems to be a direct including of a stylesheet not using
> wp_enque_style.
> >
> > So some guidance would be appreciated.
> >
> > Thanks,
> > Wayne
> >
> >
> >
> >
> > _______________________________________________
> > 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/20120801/104d0416/attachment.htm>


More information about the theme-reviewers mailing list