Media API

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:

  1. handle - The Id name of the stylesheet.
  2. src - The filename of the stylesheet.
  3. deps - The id names of other stylesheets this stylesheet is dependent upon (Can be an array).
  4. ver - Optionally add a version number to prevent your stylesheet from caching.
  5. 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:

  1. 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:

  1. handle - The Id name of the script.
  2. src - The filename of the script.
  3. deps - The id names of other scripts this script is dependent upon (Can be an array).
  4. ver - Optionally add a version number to prevent your stylesheet from caching.
  5. 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:

  1. 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.

  1. July 9th, 2009 at 1:59 am

    [...] off WP FrameworkDirectory StructureDownloading and ActivatingFuture Proofing your CustomizationsMedia APIOn using custom-functions.phpTheme Options APIWidgets [...]

Download WP Framework

Discuss WP Framework

Stop by the forums and get help with your customizations!

    It Seem There Is Something Wrong With BBLD Configuration, Please Check It.

WP Framework on Twitter!

Follow WP Framework and stay in the loop on WP Framework happenings!