RW_Meta_Box::is_saved PHP Method

is_saved() public method

This helps saving empty value in meta fields (text, check box, etc.) and set the correct default values.
public is_saved ( ) : boolean
return boolean
    public function is_saved()
    {
        $post = get_post();
        foreach ($this->fields as $field) {
            if (empty($field['id'])) {
                continue;
            }
            $value = RWMB_Field::call($field, 'raw_meta', $post->ID);
            if (!$field['multiple'] && '' !== $value || $field['multiple'] && array() !== $value) {
                return true;
            }
        }
        return false;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Check if current meta box is saved.
  * This variable is used inside group field to show child fields.
  *
  * @param RW_Meta_Box $obj Meta Box object
  */
 public function set_saved(RW_Meta_Box $obj)
 {
     self::$saved = $obj->is_saved();
 }