这些参数的含义相同,只是命名不一致。两者都接受对函数的调用。这甚至可以是相同的功能。
这里是一个简单的插件演示。Download
/*
Plugin Name: Callback Demo
Description: Demonstrating how a meta box and a menu page can take the same callback function.
Version: 1.0
Required: 3.1
Author: Thomas Scholz
Author URI: http://toscho.de
License: GPL
Plugin URI: http://wordpress.stackexchange.com/q/24481/
*/
! defined( \'ABSPATH\' ) and exit;
add_action( \'admin_menu\', \'wpse_24481_demo\' );
/**
* Adds a menu page and a meta box with the same callback function.
*
* @return void
*/
function wpse_24481_demo()
{
$title = \'Callback Demo\';
$callback = \'wpse_24481_callback\';
add_menu_page( $title, $title, \'edit_posts\', \'callback-demo\', $callback );
add_meta_box( \'callback-demo\', $title, $callback, \'post\' );
}
/**
* Prints the content.
*
* @return void
*/
function wpse_24481_callback()
{
print \'Here may be dragons.\';
}
。
结果
“页面”菜单
<小时>
meta框