Created
May 10, 2013 04:57
-
-
Save erikccoder/5552470 to your computer and use it in GitHub Desktop.
wordpress add meta box in edit post page.
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
/** | |
add custome meta box. | |
* Calls the class on the post edit screen | |
*/ | |
function call_someClass() | |
{ | |
return new someClass(); | |
} | |
if ( is_admin() ) | |
add_action( 'load-post.php', 'call_someClass' ); | |
/** | |
* The Class | |
*/ | |
class someClass | |
{ | |
const LANG = 'some_textdomain'; | |
public function __construct() | |
{ | |
add_action( 'add_meta_boxes', array( &$this, 'add_some_meta_box' ) ); | |
} | |
/** | |
* Adds the meta box container | |
*/ | |
public function add_some_meta_box() | |
{ | |
add_meta_box( | |
'some_meta_box_name' | |
,__( 'Some Meta Box Headline', self::LANG ) | |
,array( &$this, 'render_meta_box_content' ) | |
,'page' | |
,'advanced' | |
,'high' | |
); | |
} | |
/** | |
* Render Meta Box content | |
*/ | |
public function render_meta_box_content() | |
{ | |
echo '<h1>TEST OUTPUT - this gets rendered inside the meta box.</h1>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment