RW_Meta_Box::save_post PHP Method

save_post() public method

Save data from meta box
public save_post ( integer $post_id )
$post_id integer Post ID
    public function save_post($post_id)
    {
        if (!$this->validate()) {
            return;
        }
        $this->saved = true;
        // Make sure meta is added to the post, not a revision
        if ($the_post = wp_is_post_revision($post_id)) {
            $post_id = $the_post;
        }
        // Before save action
        do_action('rwmb_before_save_post', $post_id);
        do_action("rwmb_{$this->meta_box['id']}_before_save_post", $post_id);
        foreach ($this->fields as $field) {
            $single = $field['clone'] || !$field['multiple'];
            $old = RWMB_Field::call($field, 'raw_meta', $post_id);
            $new = isset($_POST[$field['id']]) ? $_POST[$field['id']] : ($single ? '' : array());
            // Allow field class change the value
            if ($field['clone']) {
                $new = RWMB_Clone::value($new, $old, $post_id, $field);
            } else {
                $new = RWMB_Field::call($field, 'value', $new, $old, $post_id);
                $new = RWMB_Field::filter('sanitize', $new, $field);
            }
            $new = RWMB_Field::filter('value', $new, $field, $old);
            // Call defined method to save meta value, if there's no methods, call common one
            RWMB_Field::call($field, 'save', $new, $old, $post_id);
        }
        // After save action
        do_action('rwmb_after_save_post', $post_id);
        do_action("rwmb_{$this->meta_box['id']}_after_save_post", $post_id);
    }