Changeset 3414040
- Timestamp:
- 12/08/2025 09:39:36 AM (4 months ago)
- Location:
- ai-builder
- Files:
-
- 2 added
- 4 edited
- 47 copied
-
tags/2.3.9 (copied) (copied from ai-builder/trunk)
-
tags/2.3.9/admin/menu.php (copied) (copied from ai-builder/trunk/admin/menu.php)
-
tags/2.3.9/admin/pages/agent-chat.php (copied) (copied from ai-builder/trunk/admin/pages/agent-chat.php)
-
tags/2.3.9/admin/pages/credits.php (copied) (copied from ai-builder/trunk/admin/pages/credits.php)
-
tags/2.3.9/admin/pages/multi-page.php (copied) (copied from ai-builder/trunk/admin/pages/multi-page.php)
-
tags/2.3.9/admin/pages/settings.php (copied) (copied from ai-builder/trunk/admin/pages/settings.php)
-
tags/2.3.9/admin/pages/translation-settings.php (copied) (copied from ai-builder/trunk/admin/pages/translation-settings.php)
-
tags/2.3.9/admin/pages/tuto.php (copied) (copied from ai-builder/trunk/admin/pages/tuto.php)
-
tags/2.3.9/aibui-builder.php (copied) (copied from ai-builder/trunk/aibui-builder.php) (3 diffs)
-
tags/2.3.9/assets/css/account.css (copied) (copied from ai-builder/trunk/assets/css/account.css)
-
tags/2.3.9/assets/css/credits.css (copied) (copied from ai-builder/trunk/assets/css/credits.css)
-
tags/2.3.9/assets/css/language-switcher.css (copied) (copied from ai-builder/trunk/assets/css/language-switcher.css)
-
tags/2.3.9/assets/css/multi-page.css (copied) (copied from ai-builder/trunk/assets/css/multi-page.css)
-
tags/2.3.9/assets/css/translation.css (copied) (copied from ai-builder/trunk/assets/css/translation.css)
-
tags/2.3.9/assets/js/account.js (copied) (copied from ai-builder/trunk/assets/js/account.js)
-
tags/2.3.9/assets/js/agent-chat.js (copied) (copied from ai-builder/trunk/assets/js/agent-chat.js)
-
tags/2.3.9/assets/js/build/index.asset.php (copied) (copied from ai-builder/trunk/assets/js/build/index.asset.php)
-
tags/2.3.9/assets/js/build/index.js (copied) (copied from ai-builder/trunk/assets/js/build/index.js)
-
tags/2.3.9/assets/js/chat-widget.js (copied) (copied from ai-builder/trunk/assets/js/chat-widget.js)
-
tags/2.3.9/assets/js/credits.js (copied) (copied from ai-builder/trunk/assets/js/credits.js)
-
tags/2.3.9/assets/js/language-switcher-block.js (copied) (copied from ai-builder/trunk/assets/js/language-switcher-block.js)
-
tags/2.3.9/assets/js/multi-page-apply.js (copied) (copied from ai-builder/trunk/assets/js/multi-page-apply.js)
-
tags/2.3.9/assets/js/multi-page.js (copied) (copied from ai-builder/trunk/assets/js/multi-page.js) (1 diff)
-
tags/2.3.9/assets/js/pattern-translation.js (copied) (copied from ai-builder/trunk/assets/js/pattern-translation.js)
-
tags/2.3.9/assets/js/settings.js (copied) (copied from ai-builder/trunk/assets/js/settings.js)
-
tags/2.3.9/assets/js/src/editor-blocks/ai-block/ai-block.js (copied) (copied from ai-builder/trunk/assets/js/src/editor-blocks/ai-block/ai-block.js)
-
tags/2.3.9/assets/js/src/editor-blocks/image-ai-blocks/image-ai-controls.js (copied) (copied from ai-builder/trunk/assets/js/src/editor-blocks/image-ai-blocks/image-ai-controls.js)
-
tags/2.3.9/assets/js/src/editor-blocks/text-ai-blocks/text-ai-controls.js (copied) (copied from ai-builder/trunk/assets/js/src/editor-blocks/text-ai-blocks/text-ai-controls.js)
-
tags/2.3.9/assets/js/translation.js (copied) (copied from ai-builder/trunk/assets/js/translation.js)
-
tags/2.3.9/composer.json (copied) (copied from ai-builder/trunk/composer.json)
-
tags/2.3.9/composer.lock (copied) (copied from ai-builder/trunk/composer.lock)
-
tags/2.3.9/debug-language.log (copied) (copied from ai-builder/trunk/debug-language.log)
-
tags/2.3.9/debug-template-part.log (copied) (copied from ai-builder/trunk/debug-template-part.log)
-
tags/2.3.9/debug-unescape.log (copied) (copied from ai-builder/trunk/debug-unescape.log)
-
tags/2.3.9/includes/class-agent-chat-handler.php (copied) (copied from ai-builder/trunk/includes/class-agent-chat-handler.php)
-
tags/2.3.9/includes/class-agent-discovery-service.php (copied) (copied from ai-builder/trunk/includes/class-agent-discovery-service.php)
-
tags/2.3.9/includes/class-agent-execution-service.php (copied) (copied from ai-builder/trunk/includes/class-agent-execution-service.php)
-
tags/2.3.9/includes/class-agent-security-service.php (copied) (copied from ai-builder/trunk/includes/class-agent-security-service.php)
-
tags/2.3.9/includes/class-ajax-handler.php (copied) (copied from ai-builder/trunk/includes/class-ajax-handler.php) (5 diffs)
-
tags/2.3.9/includes/class-css-handler.php (copied) (copied from ai-builder/trunk/includes/class-css-handler.php)
-
tags/2.3.9/includes/class-generations-storage.php (added)
-
tags/2.3.9/includes/class-translation-handler.php (copied) (copied from ai-builder/trunk/includes/class-translation-handler.php)
-
tags/2.3.9/includes/class-translation-manager.php (copied) (copied from ai-builder/trunk/includes/class-translation-manager.php)
-
tags/2.3.9/includes/class-translation-settings.php (copied) (copied from ai-builder/trunk/includes/class-translation-settings.php)
-
tags/2.3.9/includes/class-translation-switcher.php (copied) (copied from ai-builder/trunk/includes/class-translation-switcher.php)
-
tags/2.3.9/package-lock.json (copied) (copied from ai-builder/trunk/package-lock.json)
-
tags/2.3.9/readme.txt (copied) (copied from ai-builder/trunk/readme.txt) (1 diff)
-
tags/2.3.9/templates (copied) (copied from ai-builder/trunk/templates)
-
trunk/aibui-builder.php (modified) (3 diffs)
-
trunk/assets/js/multi-page.js (modified) (1 diff)
-
trunk/includes/class-ajax-handler.php (modified) (5 diffs)
-
trunk/includes/class-generations-storage.php (added)
-
trunk/readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
ai-builder/tags/2.3.9/aibui-builder.php
r3413458 r3414040 4 4 * Plugin URI: https://website-ai-builder.com/ 5 5 * Description: This plugin is used to build your website with AI. 6 * Version: 2.3. 86 * Version: 2.3.9 7 7 * Author: enkic 8 8 * Author URI: https://enkicorbin.fr/ … … 18 18 19 19 // Définir la version du plugin 20 define('AIBUI_VERSION', '2.3. 8');20 define('AIBUI_VERSION', '2.3.9'); 21 21 22 22 // Simple CSS minifier (safe whitespace/comment removal) … … 1120 1120 // Initialiser le gestionnaire AJAX 1121 1121 new AIBUI_Ajax_Handler(); 1122 1123 // ------------------------------- 1124 // Multi-Page Generator: Cleanup cron and migration 1125 // ------------------------------- 1126 function aibui_cleanup_old_generations() { 1127 require_once plugin_dir_path(__FILE__) . 'includes/class-generations-storage.php'; 1128 $storage = new AIBUI_Generations_Storage(); 1129 $deleted_count = $storage->cleanup_old(30); // Delete applied generations older than 30 days 1130 1131 if (defined('WP_DEBUG') && WP_DEBUG) { 1132 error_log("[AI Builder] Cleaned up {$deleted_count} old generation files"); 1133 } 1134 } 1135 add_action('aibui_daily_cleanup', 'aibui_cleanup_old_generations'); 1136 1137 // Schedule daily cleanup if not already scheduled 1138 if (!wp_next_scheduled('aibui_daily_cleanup')) { 1139 wp_schedule_event(time(), 'daily', 'aibui_daily_cleanup'); 1140 } 1141 1142 // Migrate old wp_options data to files (one-time migration on activation/update) 1143 function aibui_migrate_generations_to_files() { 1144 // Check if migration already done 1145 if (get_option('aibui_generations_migrated_to_files', false)) { 1146 return; 1147 } 1148 1149 require_once plugin_dir_path(__FILE__) . 'includes/class-generations-storage.php'; 1150 $storage = new AIBUI_Generations_Storage(); 1151 $migrated_count = $storage->migrate_from_options(); 1152 1153 if ($migrated_count > 0) { 1154 // Mark migration as done 1155 update_option('aibui_generations_migrated_to_files', true, false); 1156 1157 if (defined('WP_DEBUG') && WP_DEBUG) { 1158 error_log("[AI Builder] Migrated {$migrated_count} generations from wp_options to files"); 1159 } 1160 } 1161 } 1162 // Run migration on admin init (only once) 1163 add_action('admin_init', function() { 1164 static $migration_done = false; 1165 if (!$migration_done && current_user_can('manage_options')) { 1166 aibui_migrate_generations_to_files(); 1167 $migration_done = true; 1168 } 1169 }, 5); -
ai-builder/tags/2.3.9/assets/js/multi-page.js
r3413458 r3414040 186 186 187 187 totalCostElement.textContent = `${totalCost} credits`; 188 console.log(`Updating cost: ${pageCount} pages × 75 = ${totalCost} credits`);189 188 } 190 189 -
ai-builder/tags/2.3.9/includes/class-ajax-handler.php
r3400578 r3414040 516 516 517 517 // ----------------------------- 518 // Multi-Page: Generations store 518 // Multi-Page: Generations store (using JSON files) 519 519 // ----------------------------- 520 private function get_generations_option() 521 { 522 $stored = get_option('aibui_multi_page_generations', array()); 523 if (!is_array($stored)) { 524 $stored = array(); 525 } 526 return $stored; 527 } 528 529 private function persist_generations_option($generations) 530 { 531 if (!is_array($generations)) $generations = array(); 532 update_option('aibui_multi_page_generations', $generations, false); 520 private function get_storage() 521 { 522 static $storage = null; 523 if ($storage === null) { 524 require_once plugin_dir_path(__FILE__) . 'class-generations-storage.php'; 525 $storage = new AIBUI_Generations_Storage(); 526 } 527 return $storage; 533 528 } 534 529 … … 553 548 } 554 549 555 $id = isset($payload['id']) && is_string($payload['id']) ? $payload['id'] : wp_generate_uuid4(); 556 $now = current_time('mysql'); 557 558 $item = array( 559 'id' => $id, 560 'title' => sanitize_text_field($payload['title'] ?? ''), 561 'metaDesc' => sanitize_textarea_field($payload['metaDesc'] ?? ''), 562 'cssContent' => wp_kses_post($payload['cssContent'] ?? ''), 563 'blocksJson' => isset($payload['blocksJson']) ? $payload['blocksJson'] : array(), 564 'status' => 'Pending review', 565 'createdAt' => $now, 566 'applied' => false, 567 'pageId' => 0, 568 ); 569 570 $generations = $this->get_generations_option(); 571 $generations[$id] = $item; 572 $this->persist_generations_option($generations); 573 574 wp_send_json_success($item); 550 $storage = $this->get_storage(); 551 $result = $storage->save($payload); 552 553 if (is_wp_error($result)) { 554 wp_send_json_error($result->get_error_message()); 555 } 556 557 wp_send_json_success($result); 575 558 } 576 559 … … 588 571 wp_send_json_error('Insufficient permissions'); 589 572 } 590 $generations = $this->get_generations_option(); 591 // Return newest first 592 $items = array_values($generations); 593 usort($items, function($a, $b) { 594 return strcmp($b['createdAt'] ?? '', $a['createdAt'] ?? ''); 595 }); 573 574 $storage = $this->get_storage(); 575 $items = $storage->get_all(); 576 596 577 wp_send_json_success($items); 597 578 } … … 611 592 } 612 593 $id = sanitize_text_field(wp_unslash($_POST['id'])); 613 $generations = $this->get_generations_option(); 614 if (!isset($generations[$id])) { 615 wp_send_json_error('Not found'); 616 } 617 wp_send_json_success($generations[$id]); 594 595 $storage = $this->get_storage(); 596 $result = $storage->get($id); 597 598 if (is_wp_error($result)) { 599 wp_send_json_error($result->get_error_message()); 600 } 601 602 wp_send_json_success($result); 618 603 } 619 604 … … 634 619 $page_id = isset($_POST['page_id']) ? intval($_POST['page_id']) : 0; 635 620 636 $generations = $this->get_generations_option(); 637 if (!isset($generations[$id])) { 638 wp_send_json_error('Not found'); 639 } 640 $generations[$id]['applied'] = true; 641 if ($page_id > 0) { 642 $generations[$id]['pageId'] = $page_id; 643 } 644 $generations[$id]['status'] = 'Applied'; 645 $this->persist_generations_option($generations); 646 647 wp_send_json_success($generations[$id]); 621 $storage = $this->get_storage(); 622 $result = $storage->mark_applied($id, $page_id); 623 624 if (is_wp_error($result)) { 625 wp_send_json_error($result->get_error_message()); 626 } 627 628 wp_send_json_success($result); 648 629 } 649 630 -
ai-builder/tags/2.3.9/readme.txt
r3413458 r3414040 5 5 Tested up to: 6.9 6 6 Requires PHP: 7.4 7 Stable tag: 2.3. 87 Stable tag: 2.3.9 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html -
ai-builder/trunk/aibui-builder.php
r3413458 r3414040 4 4 * Plugin URI: https://website-ai-builder.com/ 5 5 * Description: This plugin is used to build your website with AI. 6 * Version: 2.3. 86 * Version: 2.3.9 7 7 * Author: enkic 8 8 * Author URI: https://enkicorbin.fr/ … … 18 18 19 19 // Définir la version du plugin 20 define('AIBUI_VERSION', '2.3. 8');20 define('AIBUI_VERSION', '2.3.9'); 21 21 22 22 // Simple CSS minifier (safe whitespace/comment removal) … … 1120 1120 // Initialiser le gestionnaire AJAX 1121 1121 new AIBUI_Ajax_Handler(); 1122 1123 // ------------------------------- 1124 // Multi-Page Generator: Cleanup cron and migration 1125 // ------------------------------- 1126 function aibui_cleanup_old_generations() { 1127 require_once plugin_dir_path(__FILE__) . 'includes/class-generations-storage.php'; 1128 $storage = new AIBUI_Generations_Storage(); 1129 $deleted_count = $storage->cleanup_old(30); // Delete applied generations older than 30 days 1130 1131 if (defined('WP_DEBUG') && WP_DEBUG) { 1132 error_log("[AI Builder] Cleaned up {$deleted_count} old generation files"); 1133 } 1134 } 1135 add_action('aibui_daily_cleanup', 'aibui_cleanup_old_generations'); 1136 1137 // Schedule daily cleanup if not already scheduled 1138 if (!wp_next_scheduled('aibui_daily_cleanup')) { 1139 wp_schedule_event(time(), 'daily', 'aibui_daily_cleanup'); 1140 } 1141 1142 // Migrate old wp_options data to files (one-time migration on activation/update) 1143 function aibui_migrate_generations_to_files() { 1144 // Check if migration already done 1145 if (get_option('aibui_generations_migrated_to_files', false)) { 1146 return; 1147 } 1148 1149 require_once plugin_dir_path(__FILE__) . 'includes/class-generations-storage.php'; 1150 $storage = new AIBUI_Generations_Storage(); 1151 $migrated_count = $storage->migrate_from_options(); 1152 1153 if ($migrated_count > 0) { 1154 // Mark migration as done 1155 update_option('aibui_generations_migrated_to_files', true, false); 1156 1157 if (defined('WP_DEBUG') && WP_DEBUG) { 1158 error_log("[AI Builder] Migrated {$migrated_count} generations from wp_options to files"); 1159 } 1160 } 1161 } 1162 // Run migration on admin init (only once) 1163 add_action('admin_init', function() { 1164 static $migration_done = false; 1165 if (!$migration_done && current_user_can('manage_options')) { 1166 aibui_migrate_generations_to_files(); 1167 $migration_done = true; 1168 } 1169 }, 5); -
ai-builder/trunk/assets/js/multi-page.js
r3413458 r3414040 186 186 187 187 totalCostElement.textContent = `${totalCost} credits`; 188 console.log(`Updating cost: ${pageCount} pages × 75 = ${totalCost} credits`);189 188 } 190 189 -
ai-builder/trunk/includes/class-ajax-handler.php
r3400578 r3414040 516 516 517 517 // ----------------------------- 518 // Multi-Page: Generations store 518 // Multi-Page: Generations store (using JSON files) 519 519 // ----------------------------- 520 private function get_generations_option() 521 { 522 $stored = get_option('aibui_multi_page_generations', array()); 523 if (!is_array($stored)) { 524 $stored = array(); 525 } 526 return $stored; 527 } 528 529 private function persist_generations_option($generations) 530 { 531 if (!is_array($generations)) $generations = array(); 532 update_option('aibui_multi_page_generations', $generations, false); 520 private function get_storage() 521 { 522 static $storage = null; 523 if ($storage === null) { 524 require_once plugin_dir_path(__FILE__) . 'class-generations-storage.php'; 525 $storage = new AIBUI_Generations_Storage(); 526 } 527 return $storage; 533 528 } 534 529 … … 553 548 } 554 549 555 $id = isset($payload['id']) && is_string($payload['id']) ? $payload['id'] : wp_generate_uuid4(); 556 $now = current_time('mysql'); 557 558 $item = array( 559 'id' => $id, 560 'title' => sanitize_text_field($payload['title'] ?? ''), 561 'metaDesc' => sanitize_textarea_field($payload['metaDesc'] ?? ''), 562 'cssContent' => wp_kses_post($payload['cssContent'] ?? ''), 563 'blocksJson' => isset($payload['blocksJson']) ? $payload['blocksJson'] : array(), 564 'status' => 'Pending review', 565 'createdAt' => $now, 566 'applied' => false, 567 'pageId' => 0, 568 ); 569 570 $generations = $this->get_generations_option(); 571 $generations[$id] = $item; 572 $this->persist_generations_option($generations); 573 574 wp_send_json_success($item); 550 $storage = $this->get_storage(); 551 $result = $storage->save($payload); 552 553 if (is_wp_error($result)) { 554 wp_send_json_error($result->get_error_message()); 555 } 556 557 wp_send_json_success($result); 575 558 } 576 559 … … 588 571 wp_send_json_error('Insufficient permissions'); 589 572 } 590 $generations = $this->get_generations_option(); 591 // Return newest first 592 $items = array_values($generations); 593 usort($items, function($a, $b) { 594 return strcmp($b['createdAt'] ?? '', $a['createdAt'] ?? ''); 595 }); 573 574 $storage = $this->get_storage(); 575 $items = $storage->get_all(); 576 596 577 wp_send_json_success($items); 597 578 } … … 611 592 } 612 593 $id = sanitize_text_field(wp_unslash($_POST['id'])); 613 $generations = $this->get_generations_option(); 614 if (!isset($generations[$id])) { 615 wp_send_json_error('Not found'); 616 } 617 wp_send_json_success($generations[$id]); 594 595 $storage = $this->get_storage(); 596 $result = $storage->get($id); 597 598 if (is_wp_error($result)) { 599 wp_send_json_error($result->get_error_message()); 600 } 601 602 wp_send_json_success($result); 618 603 } 619 604 … … 634 619 $page_id = isset($_POST['page_id']) ? intval($_POST['page_id']) : 0; 635 620 636 $generations = $this->get_generations_option(); 637 if (!isset($generations[$id])) { 638 wp_send_json_error('Not found'); 639 } 640 $generations[$id]['applied'] = true; 641 if ($page_id > 0) { 642 $generations[$id]['pageId'] = $page_id; 643 } 644 $generations[$id]['status'] = 'Applied'; 645 $this->persist_generations_option($generations); 646 647 wp_send_json_success($generations[$id]); 621 $storage = $this->get_storage(); 622 $result = $storage->mark_applied($id, $page_id); 623 624 if (is_wp_error($result)) { 625 wp_send_json_error($result->get_error_message()); 626 } 627 628 wp_send_json_success($result); 648 629 } 649 630 -
ai-builder/trunk/readme.txt
r3413458 r3414040 5 5 Tested up to: 6.9 6 6 Requires PHP: 7.4 7 Stable tag: 2.3. 87 Stable tag: 2.3.9 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset
for help on using the changeset viewer.