Plugin packaging and docs
This commit is contained in:
190
plugins/wordpress/source/igny8-wp-bridge/igny8-bridge.php
Normal file
190
plugins/wordpress/source/igny8-wp-bridge/igny8-bridge.php
Normal file
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: IGNY8 WordPress Bridge
|
||||
* Plugin URI: https://igny8.com/igny8-wp-bridge
|
||||
* Description: Lightweight bridge plugin that connects WordPress to IGNY8 API for one-way content publishing.
|
||||
* Version: 1.1.1
|
||||
* Author: IGNY8
|
||||
* Author URI: https://igny8.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.1.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-logger.php'; // Load logger first
|
||||
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-updater.php';
|
||||
// Webhooks removed - using API key authentication only
|
||||
|
||||
// Webhook logs (used in admin and frontend)
|
||||
require_once IGNY8_BRIDGE_PLUGIN_DIR . 'includes/class-igny8-webhook-logs.php';
|
||||
|
||||
// Template functions and loader (for frontend content display)
|
||||
require_once IGNY8_BRIDGE_PLUGIN_DIR . 'includes/template-functions.php';
|
||||
require_once IGNY8_BRIDGE_PLUGIN_DIR . 'includes/class-igny8-template-loader.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';
|
||||
}
|
||||
|
||||
// IGNY8 to WordPress publishing (one-way only)
|
||||
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 auto-updater
|
||||
if (class_exists('Igny8_Updater')) {
|
||||
new Igny8_Updater(
|
||||
IGNY8_BRIDGE_PLUGIN_FILE,
|
||||
IGNY8_BRIDGE_VERSION,
|
||||
'https://api.igny8.com/api/plugins/'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
// Set default post status option
|
||||
if (!get_option('igny8_default_post_status')) {
|
||||
add_option('igny8_default_post_status', 'draft');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugin deactivation
|
||||
*/
|
||||
public function deactivate() {
|
||||
// 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