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

Emil Uzelac emil at themeid.com
Wed Aug 1 07:54:42 UTC 2012


Hi Wayne,

I would direct this in ticket, -vs asking here, but here it is:

Linked codex isn't really up to date and what he/she was referring to ins't
Theme's style.css it would be something like this:

    /**
     * A safe way of adding JavaScripts to a WordPress generated page.
     */
    if (!is_admin())
        add_action('wp_enqueue_scripts', 'my_theme_js');

    if (!function_exists('my_theme_js')) {

        function my_theme_js() {
			// JS at the bottom for faster page loading.
            wp_enqueue_script('my_theme-scripts',
get_template_directory_uri() . '/js/my_theme-scripts.js',
array('jquery'), '1.2.0', true);
			wp_enqueue_script('my_theme-plugins', get_template_directory_uri()
. '/js/my_theme-plugins.js', array('jquery'), '1.1.0', true);
        }

    }


Thanks,
Emil

On Wed, Aug 1, 2012 at 2: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, using
> wp_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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wordpress.org/pipermail/theme-reviewers/attachments/20120801/f784ed11/attachment-0001.htm>


More information about the theme-reviewers mailing list