Since: 1.5
Author: Gijs Jorissen
 /**
  * Hooks into the save hook for the user meta
  *
  * @author 	Gijs Jorissen
  * @since 	1.5
  *
  */
 function save_user($user_id)
 {
     // Verify nonce
     if (!(isset($_POST['cuztom_nonce']) && wp_verify_nonce($_POST['cuztom_nonce'], 'cuztom_meta'))) {
         return;
     }
     $values = isset($_POST['cuztom']) ? $_POST['cuztom'] : array();
     if (!empty($values)) {
         parent::save($user_id, $values);
     }
 }
 /**
  * Constructs the class with important vars and method calls
  *
  * @param 	string 			$id
  * @param 	string 			$title
  * @param 	string 			$slug
  * @param 	array 			$data
  *
  * @since 	0.2
  *
  */
 function __construct($id, $title, $slug, $data = array(), $post_type = null)
 {
     if (!empty($slug)) {
         parent::__construct($title);
         $this->id = Cuztom::uglify($id);
         $this->slug = $slug;
         $this->data = $data;
         $this->post_type = $post_type;
         $this->option_values = get_option($this->id);
         $this->callback = array(&$this, 'callback');
         // Build the meta box and field array
         $this->data = $this->build($data);
         // Add to array for uninstall
         global $nm_uninstall;
         $nm_uninstall['options'][] = $this->id;
         add_action('admin_init', array(&$this, 'register_settings'));
         add_action('admin_menu', array(&$this, 'add_submenu_page'));
     }
 }
 /**
  * Hooks into the save hook for the newly registered Post Type
  *
  * @author 	Gijs Jorissen
  * @since 	0.1
  *
  */
 function save_post($post_id)
 {
     // Deny the wordpress autosave function
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE || defined('DOING_AJAX') && DOING_AJAX) {
         return;
     }
     // Verify nonce
     if (!(isset($_POST['cuztom_nonce']) && wp_verify_nonce($_POST['cuztom_nonce'], 'cuztom_meta'))) {
         return;
     }
     // Is the post from the given post type?
     if (!in_array(get_post_type($post_id), array_merge($this->post_types, array('revision')))) {
         return;
     }
     // Is the current user capable to edit this post
     foreach ($this->post_types as $post_type) {
         if (!current_user_can(get_post_type_object($post_type)->cap->edit_post, $post_id)) {
             return;
         }
     }
     $values = isset($_POST['cuztom']) ? $_POST['cuztom'] : array();
     if (!empty($values)) {
         parent::save($post_id, $values);
     }
 }
Example #4
0
 function callback($user, $data = array())
 {
     echo '<h3>' . $this->title . '</h3>';
     parent::callback($user, $data);
 }