/**
* @param $object_type
* @param null $_null
* @param int $object_id
* @param string $meta_key
* @param string $meta_value
* @param bool $delete_all
*
* @return null
*/
public function delete_meta($object_type, $_null = null, $object_id = 0, $meta_key = '', $meta_value = '', $delete_all = false)
{
if (pods_tableless()) {
return $_null;
}
$object = $this->get_object($object_type, $object_id);
if (empty($object_id) || empty($object) || !isset($object['fields'][$meta_key])) {
return $_null;
}
// @todo handle $delete_all (delete the field values from all pod items)
if (!empty($meta_value) && in_array($object['fields'][$meta_key]['type'], PodsForm::tableless_field_types())) {
if (!is_object(self::$current_field_pod) || self::$current_field_pod->pod != $object['name']) {
self::$current_field_pod = pods($object['name'], $object_id);
} elseif (self::$current_field_pod->id() != $object_id) {
self::$current_field_pod->fetch($object_id);
}
$pod = self::$current_field_pod;
$pod->remove_from($meta_key, $meta_value);
} else {
if (!is_object(self::$current_field_pod) || self::$current_field_pod->pod != $object['name']) {
self::$current_field_pod = pods($object['name']);
}
$pod = self::$current_field_pod;
$pod->save(array($meta_key => null), null, $object_id);
}
return $_null;
}