- Adapt Sync Wordpress Component to Catalog introduction

- Small bug fixes
This commit is contained in:
Josako
2024-10-17 10:31:13 +02:00
parent 7f12c8b355
commit 74cc7ae95e
12 changed files with 94 additions and 30 deletions

View File

@@ -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