$record Raw post record. * @return array */ public function post( array $record ): array { return array( 'id' => (int) ( $record['id'] ?? 0 ), 'post_type' => sanitize_text_field( (string) ( $record['post_type'] ?? 'post' ) ), 'post_title' => sanitize_text_field( (string) ( $record['post_title'] ?? '' ) ), 'post_content' => (string) ( $record['post_content'] ?? '' ), 'post_excerpt' => sanitize_text_field( (string) ( $record['post_excerpt'] ?? '' ) ), 'post_status' => sanitize_text_field( (string) ( $record['post_status'] ?? 'draft' ) ), 'post_name' => sanitize_text_field( (string) ( $record['post_name'] ?? '' ) ), 'post_parent' => (int) ( $record['post_parent'] ?? 0 ), 'menu_order' => (int) ( $record['menu_order'] ?? 0 ), 'meta' => $this->arrayValue( $record['meta'] ?? array() ), ); } /** * @param array $record Raw term record. * @return array */ public function term( array $record ): array { return array( 'id' => (int) ( $record['id'] ?? 0 ), 'taxonomy' => sanitize_text_field( (string) ( $record['taxonomy'] ?? '' ) ), 'name' => sanitize_text_field( (string) ( $record['name'] ?? '' ) ), 'slug' => sanitize_text_field( (string) ( $record['slug'] ?? '' ) ), 'description' => (string) ( $record['description'] ?? '' ), 'parent' => (int) ( $record['parent'] ?? 0 ), 'meta' => $this->arrayValue( $record['meta'] ?? array() ), ); } /** * @param array $record Raw media record. * @return array */ public function media( array $record ): array { return array( 'id' => (int) ( $record['id'] ?? 0 ), 'post_title' => sanitize_text_field( (string) ( $record['post_title'] ?? '' ) ), 'post_mime_type' => sanitize_text_field( (string) ( $record['post_mime_type'] ?? '' ) ), 'source_url' => esc_url_raw( (string) ( $record['source_url'] ?? '' ) ), 'metadata' => $this->arrayValue( $record['metadata'] ?? array() ), 'meta' => $this->arrayValue( $record['meta'] ?? array() ), ); } /** * @param mixed $value Value to normalize. * @return array */ private function arrayValue( $value ): array { return is_array( $value ) ? $value : array(); } }