Created
July 30, 2011 09:37
-
-
Save thefuxia/1115365 to your computer and use it in GitHub Desktop.
Callback Demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php # -*- coding: utf-8 -*- | |
/* | |
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.'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment