In this guide, you’ll learn how to include CSS stylesheets and JavaScript files into your theme using WP Framework’s Media API.
Including Stylesheets
function my_stylesheets() {
framework_add_stylesheet( 'master', 'master.css' );
}
add_action( 'framework_init', 'my_stylesheets' );
framework_add_stylesheet() expects the first two parameters. Here’s a list of all available parameters:
handle– The Id name of the stylesheet.src– The filename of the stylesheet.deps– The id names of other stylesheets this stylesheet is dependent upon (Can be an array).ver– Optionally add a version number to prevent your stylesheet from caching.media– ’screen’, ‘print’, ‘projection’, ‘aural’, ‘braille’, ‘tty’, ‘tv’, ‘all’.
Removing Stylesheets
function remove_stylesheets() {
framework_remove_stylesheet( 'master' );
}
add_action( 'framework_init', 'remove_stylesheets' );
framework_remove_stylesheet() expects only one parameter:
handle– The Id name of the stylesheet.
Remember that framework_remove_stylesheet() will only work if it’s called after the stylesheet has been added.
Including JavaScripts
function my_scripts() {
framework_add_script( 'screen', 'screen.js', 'jquery' );
}
add_action( 'framework_init', 'my_scripts' );
framework_add_script() expects the first two parameters. Here’s a list of all available parameters:
handle– The Id name of the script.src– The filename of the script.deps– The id names of other scripts this script is dependent upon (Can be an array).ver– Optionally add a version number to prevent your stylesheet from caching.in_footer– Whether to include the script in the footer instead of the header.
Removing JavaScripts
function remove_scripts() {
framework_remove_script( 'screen' );
}
add_action( 'framework_init', 'remove_scripts' );
framework_remove_script() expects only one parameter:
handle– The Id name of the script.
Remember that framework_remove_script() will only work if it’s called after the script has been added.
1 Trackback
You can ping this entry via the Trackback URL.
[...] off WP FrameworkDirectory StructureDownloading and ActivatingFuture Proofing your CustomizationsMedia APIOn using custom-functions.phpTheme Options APIWidgets [...]