Skip to content

Instantly share code, notes, and snippets.

@aldolat
Last active August 29, 2015 14:16
Show Gist options
  • Select an option

  • Save aldolat/42791cc9064ceeea7944 to your computer and use it in GitHub Desktop.

Select an option

Save aldolat/42791cc9064ceeea7944 to your computer and use it in GitHub Desktop.
Load a custom javascript in a WordPress admin page
<?php
/**
* Load the Javascript file.
* The file will be loaded only in the widgets admin page.
*
* @since 1.25
*/
function pis_load_scripts( $hook ) {
if( $hook != 'widgets.php' ) {
return;
}
wp_enqueue_script( 'pis-js', plugins_url( 'js/pis.js', __FILE__ ), array( 'jquery', 'jquery-ui-accordion' ), PIS_VERSION, false );
}
add_action( 'admin_enqueue_scripts', 'pis_load_scripts' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment