| | |
| | | { |
| | | $data = $request->get_params(); |
| | | $args = []; |
| | | $registrar = Registrar::getInstance($data['content']??''); |
| | | |
| | | foreach ($data as $key => $value) { |
| | | switch ($key) { |
| | | case 'depends_on': |
| | |
| | | case 'item_id': |
| | | if (is_numeric($value)) { |
| | | $args['item_id'] = absint($value); |
| | | if (!array_key_exists('post_id', $args)) { |
| | | $args['post_id'] = absint($value); |
| | | if ($registrar) { |
| | | switch ($registrar->getType()) { |
| | | case 'post': |
| | | $args['post_id'] = absint($value); |
| | | break; |
| | | case 'term': |
| | | $args['term_id'] = absint($value); |
| | | break; |
| | | case 'user': |
| | | $args['user_id'] = absint($value); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | // Post Type/Taxonomy |
| | | case 'content': |
| | | $key = str_replace('-', '_', $key); |
| | | if ($value === 'options' || array_key_exists($value, Registrar::getRegistered('post')) || Registrar::getInstance($key)->hasFeature('is_content')??false) { |
| | | $value = str_replace('-', '_', $value); |
| | | if ($value === 'options' || $registrar) { |
| | | $args['content'] = $value; |
| | | } |
| | | break; |
| | |
| | | |
| | | // Update with comma-separated string |
| | | $meta->set($data['field_name'], implode(',', $all_ids)); |
| | | $meta->save(); |
| | | } |
| | | |
| | | /** |