wordpress callback admin hooks :: 2018-04-29 01:09:23


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Enqueue a script in the WordPress admin
* edit.php, tools.php, themes.php, upload.php, options.php,
* options-{$subhook}.php, media-new.php,plugins.php, users.php
* @param int $hook Hook suffix for the current admin page.
*/
function detectScript($hook){
echo $hook;
}
//$cb1 = 'detectScript';
//$cb2 = ['ClassName', 'someStaticMethod'];
//$cb3 = [$object, 'somePublicMethod'];

// Autoloading will be invoked to load the class "ClassName" if it's not
// yet defined, and PHP will check that the class has a method
// "someStaticMethod". Note that is_callable() will NOT verify that the
// method can safely be executed in static context.
//$returnValue = call_user_func($cb1, $arg1, $arg2);

function x_enqueue_admin_edit_php( $hook ) {
if (is_callable("detectScript")) :
$cb1 = "detectScript";
switch ($hook) :
case "edit.php":
call_user_func($cb1,$hook);
break;
case "options.php":
call_user_func($cb1,$hook);
break;
case "tools.php":
call_user_func($cb1,$hook);
break;
case "themes.php":
call_user_func($cb1,$hook);
break;
case "upload.php":
call_user_func($cb1,$hook);
break;
case "media-new.php":
call_user_func($cb1,$hook);
break;
case "customize.php":
call_user_func($cb1,$hook);
break;
case "nav-menus.php":
call_user_func($cb1,$hook);
break;
case "users.php":
call_user_func($cb1,$hook);
break;
case "plugins.php":
call_user_func($cb1,$hook);
break;
default:
return;
break;
endswitch;
endif;
}add_action("admin_enqueue_scripts","x_enqueue_admin_edit_php",99,1 );

»