Files
igny8/plugins/wordpress/source/igny8-wp-bridge/includes/class-igny8-site.php
2026-01-09 22:45:30 +00:00

119 lines
3.0 KiB
PHP

<?php
/**
* Site Integration Class
*
* Manages site data collection and semantic mapping
* Follows WORDPRESS-PLUGIN-INTEGRATION.md guidelines
*
* @package Igny8Bridge
*/
// Prevent direct access
if (!defined('ABSPATH')) {
exit;
}
/**
* Igny8SiteIntegration Class
*/
class Igny8SiteIntegration {
/**
* API instance
*
* @var Igny8API
*/
private $api;
/**
* Site ID
*
* @var int
*/
private $site_id;
/**
* Constructor
*
* @param int $site_id IGNY8 site ID
*/
public function __construct($site_id) {
$this->api = new Igny8API();
$this->site_id = $site_id;
}
/**
* Full site scan and semantic mapping
*
* @return array Result array
*/
public function full_site_scan() {
// Collect all data
$site_data = igny8_collect_site_data();
// Send to IGNY8
$response = $this->api->post("/system/sites/{$this->site_id}/import/", array(
'site_data' => $site_data,
'import_type' => 'full_scan'
));
if ($response['success']) {
// Map to semantic strategy
$mapping = igny8_map_site_to_semantic_strategy($this->site_id, $site_data);
return array(
'success' => true,
'import_id' => $response['data']['import_id'] ?? null,
'semantic_map' => $mapping['data'] ?? null,
'summary' => array(
'posts' => count($site_data['posts']),
'taxonomies' => count($site_data['taxonomies']),
'products' => count($site_data['products'] ?? array()),
'product_attributes' => count($site_data['product_attributes'] ?? array())
)
);
}
return array('success' => false, 'error' => $response['error'] ?? 'Unknown error');
}
/**
* Get semantic strategy recommendations
*
* @return array|false Recommendations or false on failure
*/
public function get_recommendations() {
$response = $this->api->get("/planner/sites/{$this->site_id}/recommendations/");
if ($response['success']) {
return $response['data'];
}
return false;
}
/**
* Apply restructuring recommendations
*
* @param array $recommendations Recommendations array
* @return bool True on success
*/
public function apply_restructuring($recommendations) {
$response = $this->api->post("/planner/sites/{$this->site_id}/restructure/", array(
'recommendations' => $recommendations
));
return $response['success'];
}
/**
* Sync incremental site data
*
* @return array|false Sync result or false on failure
*/
public function sync_incremental() {
return igny8_sync_incremental_site_data($this->site_id);
}
}