admin_print_footer_scripts

最后更新于:2021-11-25 19:45:29

do_action( ‘admin_print_footer_scripts’ )

Prints any scripts and data queued for the footer.

源文件

文件: gc-admin/admin-footer.php

View on Trac

function admin_footer_js(){
	//you should check to make sure this is the page your want to alter first, check if this your custom post edtit page
	// for example .gc-admin/edit.php?post_type=my-cpt would be your custom post table list page.
	if(!isset($_GET['post_type']) || false === strpos($_GET['post_type'],'my-cpt') ){
  		return false;
  	}
	//get_current_screen() can result in fatal error on some admin pages, hence I use it after a basic check above
        $screen = get_current_screen();  
        if ( 'edit' != $screen->base && '' != $screen->action ){
		return;
	}
      	//now we can sure this is our page.
	echo "<script type='text/javascript'>n";
	echo 'var pluginUrl = ' . gc_json_encode( GC_PLUGIN_URL . '/my_plugin/' ) . ';';
	echo "n</script>";
}
add_action( 'admin_print_footer_scripts', 'admin_footer_js' );