Files
eveAI/integrations/Wordpress/eveai_sync/eveai_sync.php
Josako 9e14824249 - 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
2024-09-11 16:31:13 +02:00

65 lines
2.0 KiB
PHP

<?php
/**
* Plugin Name: EveAI Sync
* Plugin URI: https://askeveai.com/
* Description: Synchronizes WordPress content with EveAI API.
* Version: 1.0.16
* Author: Josako, Pieter Laroy
* Author URI: https://askeveai.com/about/
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: eveai-sync
* Domain Path: /languages
*/
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly
}
// Define plugin constants
define('EVEAI_SYNC_VERSION', '1.0.0');
define('EVEAI_SYNC_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('EVEAI_SYNC_PLUGIN_URL', plugin_dir_url(__FILE__));
// Include the main plugin class
require_once EVEAI_SYNC_PLUGIN_DIR . 'includes/class-eveai-sync.php';
// Initialize the plugin
function eveai_sync_init() {
$plugin = new EveAI_Sync();
$plugin->init();
}
add_action('plugins_loaded', 'eveai_sync_init');
// Set up activation and deactivation hooks
register_activation_hook(__FILE__, 'eveai_sync_activation');
register_deactivation_hook(__FILE__, 'eveai_sync_deactivation');
function eveai_sync_activation() {
// Other activation tasks...
}
function eveai_sync_deactivation() {
// Other deactivation tasks...
}
// Clean up meta when a post is permanently deleted
function eveai_delete_post_meta($post_id) {
delete_post_meta($post_id, '_eveai_document_id');
delete_post_meta($post_id, '_eveai_document_version_id');
}
add_action('before_delete_post', 'eveai_delete_post_meta');
// Display sync info in post
function eveai_display_sync_info($post) {
$document_id = get_post_meta($post->ID, '_eveai_document_id', true);
$document_version_id = get_post_meta($post->ID, '_eveai_document_version_id', true);
echo '<div class="misc-pub-section">';
echo '<h4>EveAI Sync Info:</h4>';
echo 'Document ID: ' . ($document_id ? esc_html($document_id) : 'Not set') . '<br>';
echo 'Document Version ID: ' . ($document_version_id ? esc_html($document_version_id) : 'Not set');
echo '</div>';
}
add_action('post_submitbox_misc_actions', 'eveai_display_sync_info');