Skip to content

Instantly share code, notes, and snippets.

@kadavre
Last active December 25, 2015 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kadavre/6921193 to your computer and use it in GitHub Desktop.
Save kadavre/6921193 to your computer and use it in GitHub Desktop.
Never ever simply hook into 'admin_head' to add your script: not only you will be adding it to every admin pages (the Dashboard, Comments, etc…) but also to every other plugin pages. Seriously, half of the support question I've had with Who Sees Ads were because of WP-ContactForm adding its crappy javascript everywhere it could, including my plu…
$mypage = add_management_page( 'myplugin', 'myplugin', 9, __FILE__, 'myplugin_admin_page' );
add_action( "admin_print_scripts-$mypage", 'myplugin_admin_head' );
function myplugin_admin_head() {
// what your plugin needs in its <head>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment