[wp-hackers] a newbie question on wp_enqueue_scripts and an action or a filter

Chip Bennett chip at chipbennett.net
Fri Jun 15 04:42:37 UTC 2012


Those are two different files being enqueued:

twentyeleven/style.css

and

twentyeleven/css/style.css

Are you not intending to enqueue both of these files? (Note: the first one
is probably hard-coded in header.php, rather than enqueued via callback.)

Chip

On Thu, Jun 14, 2012 at 11:31 PM, Vid Luther <vid at zippykid.com> wrote:

> Hi everyone,
>  Here's what I'm trying to do.
>
> I want to append the "version" parameter I send to wp_enqueue_scripts based
> on some external factors. Using the example in the code for
> wp_enqueue_scripts as inspiration, I whipped the following snippet up.
>
> function theme_styles() {
>
>   $cssfile = get_stylesheet_directory() . "/style.css";
>   if (file_exists($cssfile)) {
>       $version = filectime($cssfile);
>
>       // Register the style like this for a theme:
>       // (First the unique name for the style (custom-style) then the src,
>       // then dependencies and ver no. and media type)
>       wp_register_style('dd', get_template_directory_uri() .
> '/css/style.css', array(), $version, 'all');
>
>       // enqueing:
>       wp_enqueue_style('dd');
>   }
> }
>
> add_action('wp_print_styles', 'theme_styles');
>
> The action runs without any errors, but the problem is that I end up with
> two lines for style.css, one with the auto version I want, and the other
> without.
>
> The bad one:
> <link rel="stylesheet" type="text/css" media="all" href="
> http://wordpress.zippykid.dev/wp-content/themes/twentyeleven/style.css" />
>
> The good one:
> <link rel='stylesheet' id='dd-css'  href='
>
> http://wordpress.zippykid.dev/wp-content/themes/twentyeleven/css/style.css?ver=1339616402
> '
> type='text/css' media='all' />
>
> My question is.. how do I add the version to the first call of style.css,
> and then not load it again?
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list