- Furter refinement of the API, adding functionality for refreshing documents and returning Token expiration time when retrieving token
- Implementation of a first version of a Wordpress plugin - Adding api service to nginx.conf
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
class EveAI_Bulk_Sync {
|
||||
private $api;
|
||||
private $post_handler;
|
||||
|
||||
public function __construct($api, $post_handler) {
|
||||
$this->api = $api;
|
||||
$this->post_handler = $post_handler;
|
||||
}
|
||||
|
||||
public function init_bulk_sync() {
|
||||
$posts = get_posts(array(
|
||||
'post_type' => array('post', 'page'),
|
||||
'post_status' => 'publish',
|
||||
'posts_per_page' => -1,
|
||||
));
|
||||
|
||||
$sync_results = array();
|
||||
|
||||
foreach ($posts as $post) {
|
||||
$evie_id = get_post_meta($post->ID, '_eveai_document_id', true);
|
||||
$evie_version_id = get_post_meta($post->ID, '_eveai_document_version_id', true);
|
||||
$is_update = ($evie_id && $evie_version_id);
|
||||
|
||||
$result = $this->post_handler->sync_post($post->ID, $is_update);
|
||||
$sync_results[] = array(
|
||||
'id' => $post->ID,
|
||||
'title' => $post->post_title,
|
||||
'type' => $post->post_type,
|
||||
'status' => $result ? 'success' : 'failed'
|
||||
);
|
||||
}
|
||||
|
||||
return $sync_results;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user