Enqueue files for my multisite setup
-
I’m putting css and javascript files in a created directory inside a created directory inside wp-content and my enqueue code is going in an mu-plugin. Due to how I have set-up my multisite this location is much more ideal for me.
What will be the best replacement for get_template_directory_uri() and get_stylsheet_directory_uri() to get these files? I have come up with a few that all work but would like to check if they are using good practices or if any of them are not good ideas, here are three CSS examples:
using content_url that includes __File__:
function test_enqueue() { wp_enqueue_style( 'test', content_url( '/uw/test.css' , __FILE__ ) ); } add_action( 'wp_enqueue_scripts', 'test_enqueue' );
using network_site_url() that includes __File__:
function test_enqueue() { wp_enqueue_style( 'test', network_site_url( 'wp-content/uw/test.css' , __FILE__ ) ); } add_action( 'wp_enqueue_scripts', 'test_enqueue' );
using get_template_directory_uri() but then to back out:
function test_enqueue() { wp_enqueue_style( 'test', get_template_directory_uri() . '/../../uw/test.css'); } add_action( 'wp_enqueue_scripts', 'test_enqueue' );
Thanks in advance.
- The topic ‘Enqueue files for my multisite setup’ is closed to new replies.