Last active
September 21, 2019 07:12
-
-
Save janzikmund/5c9a55e1a1f739934762175b59154e28 to your computer and use it in GitHub Desktop.
WordPress version enqueued styles and scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// theme | |
add_action( 'wp_enqueue_scripts', function() { | |
if ( ! is_admin() ) { | |
$version = wp_get_theme()->get( 'Version' ); | |
wp_enqueue_style( 'child-theme', trailingslashit( get_stylesheet_directory_uri() ) . 'style.css', [], $version, 'all' ); | |
} | |
}); | |
// plugin | |
add_action( 'wp_enqueue_scripts', function() { | |
wp_enqueue_style( 'plugin-name', plugin_dir_url( __FILE__ ) . 'assets/style.css' , [], get_plugin_data( __FILE__ )['Version'], 'all' ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment