/** * Save meta value * If field is cloneable, value is saved as a single entry in DB * Otherwise value is saved as multiple entries (for backward compatibility) * * TODO: A good way to ALWAYS save values in single entry in DB, while maintaining backward compatibility * * @param $new * @param $old * @param $post_id * @param $field */ static function save($new, $old, $post_id, $field) { if (!$field['clone']) { parent::save($new, $old, $post_id, $field); return; } if (empty($new)) { delete_post_meta($post_id, $field['id']); } else { update_post_meta($post_id, $field['id'], $new); } }
/** * Standard meta retrieval * * @param int $post_id * @param array $field * @param bool $saved * * @return mixed */ static function meta($post_id, $saved, $field) { $meta = parent::meta($post_id, $saved, $field); return empty($meta) ? array() : (array) $meta; }