开发者

Wordpress Plugin add_meta_box to functions.php instead of inside plugin class

I'm using a Wordpress plugin that adds a metabox to the post page via

add_meta_box( 'WPInsights', 'Insights', array(&开发者_运维知识库$this,'draw_insights'), 'post', 'normal', 'high' );

I want to add a meta box the same way through my functions.php file, but it says the first argument is supposed to be a valid callback (I assume it is referring to the use of &$this because WPInsights is a class and draw_insights() is a function inside that class.

How can I write an add_meta_box function for my functions.php file that uses the WPInsights class?


Hook into the action add_meta_boxes like this:

add_action('add_meta_boxes', array(get_class(), 'draw_insights'));


I believe that the add_meta_box function does not function the same say the add_action function. The add_action reference states that it takes a callback but the add_meta_box function states that it takes a string that it uses as a callback. While the argument is named 'callback' it does not state that it will take any php callback as the add_action one does.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜