Example #1
0
 public function save($post_id)
 {
     /*
      * We need to verify this came from the our screen and with proper authorization,
      * because save_post can be triggered at other times.
      * */
     // Check if our nonce is set.
     if (!isset($_POST['_meta_box_nonce'])) {
         return $post_id;
     }
     $nonce = $_POST['_meta_box_nonce'];
     // Verify that the nonce is valid.
     if (!wp_verify_nonce($nonce, '_meta_box_nonce')) {
         return $post_id;
     }
     // If this is an autosave, our form has not been submitted,
     // so we don't want to do anything.
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return $post_id;
     }
     // Check the user's permissions.
     if ('page' == $_POST['post_type']) {
         if (!current_user_can('edit_page', $post_id)) {
             return $post_id;
         }
     } else {
         if (!current_user_can('edit_post', $post_id)) {
             return $post_id;
         }
     }
     // OK, its safe for us to save the data now.
     if (in_array(get_post_type($post_id), $this->screen)) {
         // Sanitize the user input.
         $output = vivid_framework_validate_inputs($_POST[$this->id], $this->fields);
         // Update the meta field.
         update_post_meta($post_id, $this->id, $output);
     }
 }
function vivid_framework_sanitize_options($input)
{
    global $theme_options;
    $output = vivid_framework_validate_inputs($input, $theme_options);
    return $output;
}