wp plugin loaded
This commit is contained in:
183
igny8-wp-integration-plugin/igny8-bridge.php
Normal file
183
igny8-wp-integration-plugin/igny8-bridge.php
Normal file
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: IGNY8 WordPress Bridge
|
||||
* Plugin URI: https://github.com/your-repo/igny8-ai-os
|
||||
* Description: Lightweight bridge plugin that connects WordPress to IGNY8 API. Syncs posts, taxonomies, and site data bidirectionally.
|
||||
* Version: 1.0.0
|
||||
* Author: Your Name
|
||||
* Author URI: https://yourwebsite.com
|
||||
* License: GPL v2 or later
|
||||
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* Text Domain: igny8-bridge
|
||||
* Domain Path: /languages
|
||||
* Requires at least: 5.0
|
||||
* Requires PHP: 7.4
|
||||
*
|
||||
* @package Igny8Bridge
|
||||
*/
|
||||
|
||||
// Prevent direct access
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Define plugin constants
|
||||
define('IGNY8_BRIDGE_VERSION', '1.0.0');
|
||||
define('IGNY8_BRIDGE_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
||||
define('IGNY8_BRIDGE_PLUGIN_URL', plugin_dir_url(__FILE__));
|
||||
define('IGNY8_BRIDGE_PLUGIN_FILE', __FILE__);
|
||||
define('IGNY8_BRIDGE_PLUGIN_BASENAME', plugin_basename(__FILE__));
|
||||
|
||||
/**
|
||||
* Main plugin class
|
||||
*/
|
||||
class Igny8Bridge {
|
||||
|
||||
/**
|
||||
* Single instance of the class
|
||||
*
|
||||
* @var Igny8Bridge
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Get single instance
|
||||
*
|
||||
* @return Igny8Bridge
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if (null === self::$instance) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
private function __construct() {
|
||||
$this->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize plugin
|
||||
*/
|
||||
private function init() {
|
||||
// Load core files
|
||||
$this->load_dependencies();
|
||||
|
||||
// Initialize hooks
|
||||
add_action('plugins_loaded', array($this, 'load_plugin_textdomain'));
|
||||
add_action('init', array($this, 'init_plugin'));
|
||||
|
||||
// Activation/Deactivation hooks
|
||||
register_activation_hook(__FILE__, array($this, 'activate'));
|
||||
register_deactivation_hook(__FILE__, array($this, 'deactivate'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Load plugin dependencies
|
||||
*/
|
||||
private function load_dependencies() {
|
||||
// Core classes
|
||||
require_once IGNY8_BRIDGE_PLUGIN_DIR . 'includes/functions.php';
|
||||
require_once IGNY8_BRIDGE_PLUGIN_DIR . 'includes/class-igny8-api.php';
|
||||
require_once IGNY8_BRIDGE_PLUGIN_DIR . 'includes/class-igny8-site.php';
|
||||
require_once IGNY8_BRIDGE_PLUGIN_DIR . 'includes/class-igny8-rest-api.php';
|
||||
require_once IGNY8_BRIDGE_PLUGIN_DIR . 'includes/class-igny8-webhooks.php';
|
||||
require_once IGNY8_BRIDGE_PLUGIN_DIR . 'includes/class-igny8-link-queue.php';
|
||||
require_once IGNY8_BRIDGE_PLUGIN_DIR . 'includes/class-igny8-webhook-logs.php';
|
||||
|
||||
// Admin classes (only in admin)
|
||||
if (is_admin()) {
|
||||
require_once IGNY8_BRIDGE_PLUGIN_DIR . 'admin/class-admin.php';
|
||||
require_once IGNY8_BRIDGE_PLUGIN_DIR . 'admin/class-admin-columns.php';
|
||||
require_once IGNY8_BRIDGE_PLUGIN_DIR . 'admin/class-post-meta-boxes.php';
|
||||
}
|
||||
|
||||
// Sync handlers
|
||||
require_once IGNY8_BRIDGE_PLUGIN_DIR . 'sync/hooks.php';
|
||||
require_once IGNY8_BRIDGE_PLUGIN_DIR . 'sync/post-sync.php';
|
||||
require_once IGNY8_BRIDGE_PLUGIN_DIR . 'sync/taxonomy-sync.php';
|
||||
require_once IGNY8_BRIDGE_PLUGIN_DIR . 'sync/igny8-to-wp.php';
|
||||
|
||||
// Data collection
|
||||
require_once IGNY8_BRIDGE_PLUGIN_DIR . 'data/site-collection.php';
|
||||
require_once IGNY8_BRIDGE_PLUGIN_DIR . 'data/semantic-mapping.php';
|
||||
require_once IGNY8_BRIDGE_PLUGIN_DIR . 'data/link-graph.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Load plugin textdomain
|
||||
*/
|
||||
public function load_plugin_textdomain() {
|
||||
load_plugin_textdomain(
|
||||
'igny8-bridge',
|
||||
false,
|
||||
dirname(IGNY8_BRIDGE_PLUGIN_BASENAME) . '/languages'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize plugin functionality
|
||||
*/
|
||||
public function init_plugin() {
|
||||
// Register post meta fields
|
||||
igny8_register_post_meta();
|
||||
|
||||
// Register taxonomies
|
||||
igny8_register_taxonomies();
|
||||
|
||||
// Initialize admin (if in admin)
|
||||
if (is_admin()) {
|
||||
Igny8Admin::get_instance();
|
||||
}
|
||||
|
||||
// Initialize sync handlers
|
||||
if (class_exists('Igny8WordPressSync')) {
|
||||
new Igny8WordPressSync();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugin activation
|
||||
*/
|
||||
public function activate() {
|
||||
// Register post meta and taxonomies
|
||||
igny8_register_post_meta();
|
||||
igny8_register_taxonomies();
|
||||
|
||||
// Flush rewrite rules
|
||||
flush_rewrite_rules();
|
||||
|
||||
// Set default options
|
||||
if (!get_option('igny8_bridge_version')) {
|
||||
add_option('igny8_bridge_version', IGNY8_BRIDGE_VERSION);
|
||||
}
|
||||
|
||||
// Schedule cron jobs
|
||||
igny8_schedule_cron_jobs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugin deactivation
|
||||
*/
|
||||
public function deactivate() {
|
||||
// Unschedule cron jobs
|
||||
igny8_unschedule_cron_jobs();
|
||||
|
||||
// Flush rewrite rules
|
||||
flush_rewrite_rules();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize plugin
|
||||
*/
|
||||
function igny8_bridge_init() {
|
||||
return Igny8Bridge::get_instance();
|
||||
}
|
||||
|
||||
// Start the plugin
|
||||
igny8_bridge_init();
|
||||
|
||||
Reference in New Issue
Block a user