add_options_page() doesn't return correct hookname with function omitted
|Reported by:||KingBYU||Owned by:|
When calling add_options_page() without a function name, the hook name returned doesn't correspond to any hook name that will be called.
The codex docs say that the $function parameter of add_options_page() is optional, and if omitted, then the file specified with the $file parameter should instead be included.
I changed the example code that Ozh provided to look like the following:
$options_page = dirname(plugin_basename(__FILE__)).'/js_example_opts.php'; $mypage = add_options_page('Load JS Example', 'Load JS Example', 8, $options_page); add_action( "admin_print_scripts-$mypage", 'ozh_loadjs_admin_head' ); error_log("added action: admin_print_scripts-$mypage");
In my error log, I found the message:
added action: admin_print_scripts-settings_page_load-js-example/js_example_opts
However, the action/hook that is actually being called when the page loads is:
The action tag created is different than the action tag that is called. (Again, if the function name method is used, the action tags correspond perfectly).
Fix the get_plugin_page_hookname() function usage (perhaps in the caller) in source:/trunk/wp-admin/includes/plugin.php to return a correct hookname.
Thank you very much.