| | |
| | | <?php |
| | | |
| | | namespace JVBase\rest\routes; |
| | | |
| | | use JVBase\JVB; |
| | |
| | | |
| | | $this->timelineUniqueFields = $this->getTimelineUniqueFields($content); |
| | | } |
| | | |
| | | public function getTimelineUniqueFields(string $content):array |
| | | { |
| | | $content = jvbNoBase($content); |
| | |
| | | error_log('Received data: '.print_r($data, true)); |
| | | $user_id = $data['user']; |
| | | |
| | | |
| | | if (!isset($data['posts']) || !is_array($data['posts'])) { |
| | | if (!$this->userCheck($user_id)) { |
| | | return new WP_REST_Response([ |
| | | 'success' => false, |
| | | 'message' =>'Invalid request format' |
| | | 'success' => true, |
| | | 'message' => 'You for real?' |
| | | ]); |
| | | } |
| | | |
| | | if (!array_key_exists('posts', $data) || !is_array($data['posts'])) { |
| | | return new WP_REST_Response([ |
| | | 'success' => true, |
| | | 'message' => 'No posts found' |
| | | ]); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * @param WP_Post $post the wordpress post object |
| | | * @param WP_Post $post the post object |
| | | * |
| | | * @return array |
| | | */ |
| | |
| | | |
| | | return $data; |
| | | } |
| | | |
| | | protected function extractImages(array $fields = []):array |
| | | { |
| | | //Extract images |
| | |
| | | $item['fields']['timeline'] = $subFields; |
| | | $item['images'] = $item['images'] + $images; |
| | | |
| | | |
| | | return $item; |
| | | } |
| | | |