do_action('admin_enqueue_scripts', $hook_suffix);
do_action("admin_print_styles-$hook_suffix");
Laying aside the obvious difference in base action ( admin_enqueue_scripts
vs admin_print_scripts
), what is the syntactical difference between these two?
I know that for the second, the corresponding add_action()
call is like so:
function wpse99999_enqueue_admin_scripts( 'appearance_page_pagename' ) {
// wp_enqueue_script() call here
}
add_action( 'admin_print_styles-appearance_page_pagename', wpse99999_enqueue_admin_scripts );
But how would the first look? How is the $hook_suffix
passed here? Perhaps it is passed as a parameter to the callback?
function wpse99999_enqueue_admin_scripts( 'appearance_page_pagename' ) {
// wp_enqueue_script() call here
}
add_action( 'admin_enqueue_scripts', 'wpse99999_enqueue_admin_scripts' );
Or is it returned by the callback?
function wpse99999_enqueue_admin_scripts() {
// wp_enqueue_script() call here
return 'appearance_page_pagename';
}
add_action( 'admin_enqueue_scripts', 'wpse99999_enqueue_admin_scripts' );
Or is it something else entirely?
For â¦
⦠the callback gets the hook suffix as first parameter. Since it is an action you don’t have to return anything. You can use it in a rather flexible callback function:
This will be called just on one page.
add_action()
calls or more callback functions to do similar things.