PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.2.4
ShopBuilder – WooCommerce Builder For Elementor v3.2.4
3.4.2 3.4.1 3.4.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 All 63 releases
shopbuilder / app / AI / AIinit.php

AIinit.php in ShopBuilder – WooCommerce Builder For Elementor 3.2.4, at app/AI/AIinit.php

75 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * AI Initialization Class.
4 *
5 * Handles AI-related module setup, including meta boxes, assets, and AJAX actions.
6 *
7 * @package RadiusTheme\SB
8 */
9
10 namespace RadiusTheme\SB\AI;
11
12 use RadiusTheme\SB\AI\Ajax\AjaxAI;
13 use RadiusTheme\SB\AI\DB\CreateTableForAi;
14 use RadiusTheme\SB\Traits\SingletonTrait;
15
16 defined( 'ABSPATH' ) || exit();
17
18 /**
19 * Initializes AI module components.
20 */
21 class AIinit {
22 /**
23 * Use Singleton trait.
24 */
25 use SingletonTrait;
26
27 /**
28 * @var array|false
29 */
30 private $ai_data;
31 /**
32 * Class constructor.
33 */
34 public function __construct() {
35 $this->ai_data = AIFns::activated_ai_data();
36 $this->initialize();
37 $this->metabox_and_assets();
38 $this->embedding();
39 if ( $this->ai_data ) {
40 $this->ajax_action();
41 }
42 }
43
44 /**
45 * @return void
46 */
47 public function initialize() {
48 add_action( 'init', [ CreateTableForAi::instance(), 'create_ai_embeddings_table' ] );
49 add_action( 'init', [ AiController::instance(), 'start_cron' ] );
50 add_action( 'rtsb_embedding_cron_run', [ AiController::instance(), 'process_batch' ] );
51 }
52 /**
53 * @return void
54 */
55 public function embedding() {
56 add_action( 'save_post_product', [ AiController::instance(), 'handle_product_save' ], 10, 2 );
57 }
58 /**
59 * Registers meta boxes and enqueues admin assets.
60 */
61 public function metabox_and_assets() {
62 add_action( 'admin_enqueue_scripts', [ MetaBoxScripts::instance(), 'admin_enqueue_scripts' ] );
63 add_action( 'edit_form_after_title', [ MetaBoxScripts::instance(), 'render_meta_box' ] );
64 }
65
66 /**
67 * Registers AJAX actions for AI operations.
68 */
69 public function ajax_action() {
70 add_action( 'wp_ajax_rtsb_ai_generate_product_content', [ AjaxAI::instance(), 'generate_product_content' ] );
71 add_action( 'wp_ajax_rtsb_ai_semantic_search_suggestions', [ AjaxAI::instance(), 'semantic_search_suggestions' ] );
72 add_action( 'wp_ajax_nopriv_rtsb_ai_semantic_search_suggestions', [ AjaxAI::instance(), 'semantic_search_suggestions' ] );
73 }
74 }
75