1 month with fiddling: A few accumulated questions regarding Wordpress and Sage

Hi, people.

I just want to make it clear that I’m not a sneaky (at least I hope not :blush:) forum users jumping straight to forum questions without even trying or searching first. I assure you I’ve been working a lot on my own, helping other people and done an effort learning both Wordpress, Git, Sage and got to know Gulp and its clear benefits.

Some of these question are more like “confirmations” and to show how I did it and “hopefully” I’ve done’em wrong so I can learn more from Sage and its best practises. So let’s make a better internet :smile:

  1. I’ve put Google Analytics straight into the header file. Is this the correct way to do it? Of course I know about the main.js, but since GA JS mostly is inline, I suspect there is another way to do it.

  2. Is the script enqueue system in Sage the same as in WP in general or is there changes made?

  3. Regarding third party plugins not from Bower: is it common practise to add them as vendored in the manifest.json and then enqueue them like this?

    wp_enqueue_style(‘owl_carousel’, asset_path(‘styles/owl.carousel.css’), false, null);
    wp_enqueue_style(‘owl_carousel2’, asset_path(‘styles/owl.theme.css’), false, null);
    wp_enqueue_style(‘owl_carousel3’, asset_path(‘styles/owl.transitions.css’), false, null);

(poor example, since owl is bower, but nevertheless).

  1. There are built-in conditionals for sidebar in lib/config.php. Should the same be done for (for instance) conditional on where a image carousel should appear or not? If not, where should the conditional logic be put?
    I could try to just copy display_sidebar() function into display_image_carousel(), but I’m not just sure how this stuff propagate.

  2. Where should additional CDN’s be included?

  3. I wonder what exactly makes the jquery.mmenu (bower) automatically added in the main.scss when sass-mq and jeet isn’t (these are also bower). Just wonder what the engine behind this is.

  4. Where should small settings like new setlocale be put? I need to get correct date from the server. Of course I know I can put in “anywhere”, but obviously I want to do it the best way :smile:

And a specific thought about CPT:
I have a CPT (which is as MU plugin) named “stores”. Would the correct file naming and developing process be like this?

  1. Copy single.php in root and name is single-stores.php (this will be inside a store, viewing a store)
  2. In single-stores.php then include templates/content-stores.php?

Now; what about the page looping through and listing all the CPT stores (ACF)? Should this be an own template like template-stores.php in root folder?

Sorry, but I have some difficulties gettin wrapping my head around this and get it under my skin. It’s probably the easiest problem in the world, but when I try to optimize my theme and get the most out of it, it would be far better to get the solution and best practise from someone I know is better than me.

Can anyone break it down?

So bear with me on this :slight_smile:


This is fine. Keep doing what you are doing or use soil.

AFAIK we haven’t done anything different as far as enqueuing. You will need to use the asset_path method to grab the revved filename when enqueuing however.

Vendor them in the manifest.json (here is an example) and then dequeue the original assets. If you want to help with documentation of this feature definitely chime in over here.

You can modify the asset_path to prepend your CDN url and then have your CDN proxy your wordpress install as an origin. I would definitely like to see this feature in soil or something. @QWp6t time to write some SLOC.

All of the dependencies are collected and ordered by http://use-asset-builder.austinpray.com. If that bower module defines a “main” property, asset-builder puts it in the correct order and feeds it to gulp.

1 Like

Great, Austin. Thanks. Helped a lot :smile: