- Adapt Sync Wordpress Component to Catalog introduction
- Small bug fixes
This commit is contained in:
@@ -51,6 +51,10 @@ No additional configuration is needed; the plugin will automatically detect the
|
||||
|
||||
## Versions
|
||||
|
||||
### 1.1.1 - Add Reinitialisation functionality
|
||||
|
||||
### 1.1.0 - Add Catalog Functionality
|
||||
|
||||
### 1.0.x - Bugfixing Releases
|
||||
|
||||
### 1.0.0 - Initial Release
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Plugin Name: EveAI Sync
|
||||
* Plugin URI: https://askeveai.com/
|
||||
* Description: Synchronizes WordPress content with EveAI API.
|
||||
* Version: 1.0.16
|
||||
* Version: 1.1.1
|
||||
* Author: Josako, Pieter Laroy
|
||||
* Author URI: https://askeveai.com/about/
|
||||
* License: GPL v2 or later
|
||||
@@ -17,7 +17,7 @@ if (!defined('ABSPATH')) {
|
||||
}
|
||||
|
||||
// Define plugin constants
|
||||
define('EVEAI_SYNC_VERSION', '1.0.0');
|
||||
define('EVEAI_SYNC_VERSION', '1.1.1');
|
||||
define('EVEAI_SYNC_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
||||
define('EVEAI_SYNC_PLUGIN_URL', plugin_dir_url(__FILE__));
|
||||
|
||||
@@ -50,6 +50,30 @@ function eveai_delete_post_meta($post_id) {
|
||||
}
|
||||
add_action('before_delete_post', 'eveai_delete_post_meta');
|
||||
|
||||
// Clean metadata from Wordpress site
|
||||
function eveai_reinitialize_site() {
|
||||
check_ajax_referer('eveai_reinitialize_site', 'nonce');
|
||||
|
||||
if (!current_user_can('manage_options')) {
|
||||
wp_send_json_error('You do not have permission to perform this action.');
|
||||
return;
|
||||
}
|
||||
|
||||
global $wpdb;
|
||||
|
||||
// Remove all EveAI-related post meta
|
||||
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key LIKE '_eveai_%'");
|
||||
|
||||
// Remove all EveAI-related options
|
||||
delete_option('eveai_last_sync_time');
|
||||
delete_option('eveai_sync_status');
|
||||
|
||||
// Optionally, you might want to clear any custom tables if you have any
|
||||
|
||||
wp_send_json_success('Site reinitialized. All EveAI metadata has been removed.');
|
||||
}
|
||||
add_action('wp_ajax_eveai_reinitialize_site', 'eveai_reinitialize_site');
|
||||
|
||||
// Display sync info in post
|
||||
function eveai_display_sync_info($post) {
|
||||
$document_id = get_post_meta($post->ID, '_eveai_document_id', true);
|
||||
|
||||
@@ -16,6 +16,7 @@ class EveAI_Admin {
|
||||
register_setting('eveai_settings', 'eveai_excluded_categories');
|
||||
register_setting('eveai_settings', 'eveai_access_token');
|
||||
register_setting('eveai_settings', 'eveai_token_expiry');
|
||||
register_setting('eveai_settings', 'eveai_catalog_id');
|
||||
}
|
||||
|
||||
public function add_admin_menu() {
|
||||
@@ -50,6 +51,10 @@ class EveAI_Admin {
|
||||
<th scope="row">API Key</th>
|
||||
<td><input type="text" name="eveai_api_key" value="<?php echo esc_attr(get_option('eveai_api_key')); ?>" style="width: 100%;" /></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th scope="row">Catalog ID</th>
|
||||
<td><input type="text" name="eveai_catalog_id" value="<?php echo esc_attr(get_option('eveai_catalog_id')); ?>" style="width: 100%;" /></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th scope="row">Default Language</th>
|
||||
<td><input type="text" name="eveai_default_language" value="<?php echo esc_attr(get_option('eveai_default_language', 'en')); ?>" style="width: 100%;" /></td>
|
||||
@@ -71,6 +76,11 @@ class EveAI_Admin {
|
||||
<?php wp_nonce_field('eveai_bulk_sync', 'eveai_bulk_sync_nonce'); ?>
|
||||
<input type="submit" name="eveai_bulk_sync" class="button button-primary" value="Start Bulk Sync">
|
||||
</form>
|
||||
|
||||
<h2>Reinitialize Site</h2>
|
||||
<p>Click the button below to remove all EveAI metadata from your site. This will reset the sync status for all posts and pages.</p>
|
||||
<button id="eveai-reinitialize" class="button button-secondary">Reinitialize Site</button>
|
||||
|
||||
<div id="eveai-sync-results" style="margin-top: 20px;"></div>
|
||||
</div>
|
||||
<script>
|
||||
@@ -105,6 +115,29 @@ class EveAI_Admin {
|
||||
});
|
||||
}
|
||||
});
|
||||
$('#eveai-reinitialize').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
if (confirm('Are you sure you want to reinitialize? This will remove all EveAI metadata from your site.')) {
|
||||
$.ajax({
|
||||
url: ajaxurl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'eveai_reinitialize_site',
|
||||
nonce: '<?php echo wp_create_nonce('eveai_reinitialize_site'); ?>'
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
alert(response.data);
|
||||
} else {
|
||||
alert('Error: ' + response.data);
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
alert('An error occurred. Please try again.');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
|
||||
@@ -13,6 +13,7 @@ class EveAI_API {
|
||||
$this->api_key = get_option('eveai_api_key');
|
||||
$this->access_token = get_option('eveai_access_token');
|
||||
$this->token_expiry = get_option('eveai_token_expiry', 0);
|
||||
$this->catalog_id = get_option('eveai_catalog_id');
|
||||
}
|
||||
|
||||
private function ensure_valid_token() {
|
||||
@@ -111,6 +112,7 @@ class EveAI_API {
|
||||
}
|
||||
|
||||
public function add_url($data) {
|
||||
$data['catalog_id'] = get_option('eveai_catalog_id'); // Include catalog_id
|
||||
return $this->make_request('POST', '/api/v1/documents/add_url', $data);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user