| | |
| | | use Exception; |
| | | use JVBase\managers\Cache; |
| | | use JVBase\managers\Errors; |
| | | use wpdb; |
| | | |
| | | if (!defined('ABSPATH')) { |
| | | exit; |
| | |
| | | */ |
| | | class Storage |
| | | { |
| | | protected \wpdb $wpdb; |
| | | protected wpdb $wpdb; |
| | | |
| | | public function __construct() |
| | | { |
| | |
| | | 'item_id' => $item->id, |
| | | 'object_type' => $item->objectType, |
| | | 'fields' => array_keys($dirty) |
| | | ], 'error'); |
| | | ]); |
| | | return false; |
| | | } |
| | | } |
| | |
| | | $config = $item->getFieldConfig($name); |
| | | if ($config && ($config['type'] ?? '') === 'taxonomy' && !isset($config['taxonomy_type'])) { |
| | | $taxonomy = jvbCheckBase($config['taxonomy']); |
| | | wp_set_object_terms($item->id, [], $taxonomy, false); |
| | | wp_set_object_terms($item->id, [], $taxonomy); |
| | | return true; |
| | | } |
| | | |
| | |
| | | $results[$meta->item()->id ?? 'options'] = false; |
| | | } |
| | | |
| | | Errors::getInstance()->log('meta_storage', 'Bulk save failed: ' . $e->getMessage(), [], 'error'); |
| | | Errors::getInstance()->log('meta_storage', 'Bulk save failed: ' . $e->getMessage()); |
| | | |
| | | return $results; |
| | | } |
| | |
| | | $taxonomy = jvbCheckBase($field->config['taxonomy']); |
| | | $value = $field->value; |
| | | if (empty(trim((string)$value))) { |
| | | wp_set_object_terms($item->id, [], $taxonomy, false); |
| | | wp_set_object_terms($item->id, [], $taxonomy); |
| | | return true; |
| | | } |
| | | |
| | | $termIds = array_map('intval', array_filter(explode(',', $value))); |
| | | $result = wp_set_object_terms($item->id, $termIds, $taxonomy, false); |
| | | $result = wp_set_object_terms($item->id, $termIds, $taxonomy); |
| | | |
| | | return !is_wp_error($result); |
| | | } |
| | |
| | | ? [] |
| | | : array_map('intval', array_filter(explode(',', $update['value']))); |
| | | |
| | | wp_set_object_terms($update['object_id'], $termIds, $update['taxonomy'], false); |
| | | wp_set_object_terms($update['object_id'], $termIds, $update['taxonomy']); |
| | | } |
| | | } |
| | | |