Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- global $wp_version;
- if (version_compare($wp_version,"3.0","<")) { /*provides the current WordPress version in standard format*/
- add_action('admin_init', 'setup_meta_boxes', 1); /*for versions < 3.0*/
- } else {
- add_action('add_meta_boxes', 'setup_meta_boxes'); /*for versions >=3.0*/
- }
- function setup_meta_boxes() {
- add_meta_box('case-study-color-sceme', 'Color Scheme', 'render_html', 'work', 'normal', 'default');
- }
- function render_html($post, $params) {
- echo '<p>Test metabox content</p>';
- }
- // Use nonce for verification
- wp_nonce_field( plugin_basename(__FILE__), 'color-scheme-meta' );
- }
- /* Do something with the data entered */
- add_action('save_post', 'saveMyData');
- function saveMyData( $post_id ) {
- // verify if this is an auto save routine. If it is, our form has not been submitted, so we dont want to do anything
- if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return $post_id;
- if ( !wp_verify_nonce( $_POST['color-scheme-meta'], plugin_basenamemyName = $_POST['myname'];
- $myAge = $_POST['myage'];
- /*Now you can $myName and $myAge to a custom table or to meta options using add_post_meta()*/
- }
- ?>
Add Comment
Please, Sign In to add comment