| | |
| | | |
| | | use JVBase\managers\queue\{Executor, Operation, Progress, Result}; |
| | | use JVBase\managers\UploadManager; |
| | | use JVBase\meta\MetaManager; |
| | | use JVBase\meta\Meta; |
| | | use Exception; |
| | | use JVBase\utility\Features; |
| | | |
| | |
| | | } |
| | | |
| | | if (!empty($gallery_attachment_ids)) { |
| | | $meta = new MetaManager($newPostID, 'post'); |
| | | $meta = Meta::forPost($newPostID); |
| | | $fields = jvbGetFields($content, 'post'); |
| | | foreach($fields as $name => $config) { |
| | | if ($config['type'] === 'gallery') { |
| | | $meta->updateValue($name, implode(',', $gallery_attachment_ids)); |
| | | $meta->set($name, implode(',', $gallery_attachment_ids)); |
| | | break; |
| | | } |
| | | } |
| | |
| | | return; |
| | | } |
| | | |
| | | $existing = $meta->getValue($data['field_name']); |
| | | $existing = $meta->get($data['field_name']); |
| | | $existingIds = !empty($existing) ? explode(',', $existing) : []; |
| | | $allIds = array_unique(array_merge($existingIds, $attachmentIds)); |
| | | |
| | | $meta->updateValue($data['field_name'], implode(',', $allIds)); |
| | | $meta->set($data['field_name'], implode(',', $allIds)); |
| | | } |
| | | |
| | | private function updateFieldValue(array $data, array $results): void |
| | |
| | | return; |
| | | } |
| | | |
| | | $existing = $meta->getValue($data['field_name']); |
| | | $existing = $meta->get($data['field_name']); |
| | | $existingIds = !empty($existing) ? explode(',', $existing) : []; |
| | | $allIds = array_unique(array_merge($existingIds, $attachmentIds)); |
| | | |
| | | $meta->updateValue($data['field_name'], implode(',', $allIds)); |
| | | $meta->set($data['field_name'], implode(',', $allIds)); |
| | | } |
| | | |
| | | private function getMetaManager(array $data): ?MetaManager |
| | | private function getMetaManager(array $data): ?Meta |
| | | { |
| | | if (!empty($data['post_id'])) { |
| | | return new MetaManager($data['post_id'], 'post'); |
| | | return Meta::forPost($data['post_id']); |
| | | } |
| | | if (!empty($data['term_id'])) { |
| | | return new MetaManager($data['term_id'], 'term'); |
| | | return Meta::forTerm($data['term_id']); |
| | | } |
| | | if (!empty($data['user'])) { |
| | | $link = (int)get_user_meta($data['user'], BASE . 'link', true); |
| | | if ($link) { |
| | | return new MetaManager($link, 'post'); |
| | | return Meta::forPost($link); |
| | | } |
| | | } |
| | | return null; |
| | |
| | | if (str_starts_with($mimeType, 'image/')) { |
| | | set_post_thumbnail($postId, $attachmentId); |
| | | } elseif (str_starts_with($mimeType, 'video/')) { |
| | | $meta = new MetaManager($postId, 'post'); |
| | | $meta->updateValue('video', $attachmentId); |
| | | $meta = Meta::forPost($postId); |
| | | $meta->set('video', $attachmentId); |
| | | } else { |
| | | $meta = new MetaManager($postId, 'post'); |
| | | $existing = $meta->getValue('documents'); |
| | | $meta = Meta::forPost($postId); |
| | | $existing = $meta->get('documents'); |
| | | $existingIds = !empty($existing) ? explode(',', $existing) : []; |
| | | $existingIds[] = $attachmentId; |
| | | $meta->updateValue('documents', implode(',', $existingIds)); |
| | | $meta->set('documents', implode(',', $existingIds)); |
| | | } |
| | | } |
| | | |