Guest User

Untitled

a guest
Oct 21st, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.14 KB | None | 0 0
  1. <?php
  2. global $wp_version;
  3. if (version_compare($wp_version,"3.0","<")) { /*provides the current WordPress version in standard format*/
  4.     add_action('admin_init', 'setup_meta_boxes', 1); /*for versions < 3.0*/
  5. } else {
  6.     add_action('add_meta_boxes', 'setup_meta_boxes'); /*for versions >=3.0*/
  7. }
  8.  
  9. function setup_meta_boxes() {
  10.     add_meta_box('case-study-color-sceme', 'Color Scheme', 'render_html', 'work', 'normal', 'default');
  11. }
  12.  
  13. function render_html($post, $params) {
  14.     echo '<p>Test metabox content</p>';
  15. }
  16.  
  17.     // Use nonce for verification
  18.     wp_nonce_field( plugin_basename(__FILE__), 'color-scheme-meta' );
  19. }
  20.  
  21. /* Do something with the data entered */
  22. add_action('save_post', 'saveMyData');
  23.  
  24. function saveMyData( $post_id ) {
  25.     // verify if this is an auto save routine. If it is, our form has not been submitted, so we dont want to do anything
  26.     if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return $post_id;
  27.  
  28.     if ( !wp_verify_nonce( $_POST['color-scheme-meta'], plugin_basenamemyName = $_POST['myname'];
  29.  $myAge = $_POST['myage'];
  30.  
  31.  /*Now you can $myName and $myAge to a custom table or to meta options using add_post_meta()*/
  32. }
  33. ?>
Add Comment
Please, Sign In to add comment