WordPress.org

Ready to get started?Download WordPress

Plugin Directory

Add Admin JavaScript

Interface for easily defining additional JavaScript (inline and/or by URL) to be added to all administration pages.

Filters

The plugin exposes four filters for hooking. Typically, these customizations would be put into your active theme's functions.php file, or used by another plugin.

c2c_add_admin_js_files (filter)

The 'c2c_add_admin_js_files' hook allows you to programmatically add to or customize any referenced JavaScript files defined in the "Admin JavaScript Files" field.

Arguments:

  • $files (array): Array of JavaScript files

Example:

add_filter( 'c2c_add_admin_js_files', 'my_admin_js_files' );
function my_admin_js_files( $files ) {
    $files[] = 'http://ajax.googleapis.com/ajax/libs/yui/2.8.1/build/yuiloader/yuiloader-min.js';
    return $files;
}

c2c_add_admin_js_head (filter)

The 'c2c_add_admin_js_head' hook allows you to programmatically add to or customize any JavaScript to be put into the page head as defined in the "Admin JavaScript (in head)" field.

Arguments:

  • $js (string): JavaScript

Example:

add_filter( 'c2c_add_admin_js_head', 'my_add_head_js' );
function my_add_head_js( $js ) {
    $js .= "alert('Hello');";
    return $js;
}

c2c_add_admin_js_footer (filter)

The 'c2c_add_admin_js_footer' hook allows you to programmatically add to or customize any JavaScript to be put into the page head as defined in the "Admin JavaScript (in footer)" field.

Arguments:

  • $js (string): JavaScript

Example:

add_filter( 'c2c_add_admin_js_footer', 'my_add_footer_js' );
function my_add_footer_js( $js ) {
    $js .= "alert('Hello');";
    return $js;
}

c2c_add_admin_js_jq (filter)

The 'c2c_add_admin_js_jq' hook allows you to filter the jQuery JavaScript to be output in the footer of admin pages. The 'c2c_add_admin_js_jq' hook allows you to programmatically add to or customize any jQuery JS to be put into the page footer as defined in the "Admin jQuery JavaScript" field.

Arguments:

  • $js_jq (string): String of jQuery JavaScript

Example:

add_filter( 'c2c_add_admin_js_jq', 'my_add_jq' );
function my_add_jq( $js_jq ) {
    $js_jq .= "$('.hide_me').hide();";
    return $js_jq;
}

Requires: 3.5 or higher
Compatible up to: 3.8.3
Last Updated: 2014-1-3
Downloads: 5,404

Ratings

4 stars
4.7 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

0,1,0