load_dependencies(); $this->define_admin_hooks(); $this->define_public_hooks(); $this->define_rest_hooks(); } /** * Load the required dependencies for this plugin. */ private function load_dependencies() { require_once AIDD_PLUGIN_DIR . 'includes/class-ai-domain-data-loader.php'; require_once AIDD_PLUGIN_DIR . 'includes/class-ai-domain-data-admin.php'; require_once AIDD_PLUGIN_DIR . 'includes/class-ai-domain-data-validator.php'; require_once AIDD_PLUGIN_DIR . 'includes/class-ai-domain-data-generator.php'; require_once AIDD_PLUGIN_DIR . 'includes/class-ai-domain-data-rest-api.php'; $this->loader = new AIDD_Loader(); } /** * Register all of the hooks related to the admin area functionality. */ private function define_admin_hooks() { $admin = new AIDD_Admin(); $this->loader->add_action( 'admin_menu', $admin, 'add_admin_menu' ); $this->loader->add_action( 'admin_init', $admin, 'register_settings' ); $this->loader->add_action( 'admin_enqueue_scripts', $admin, 'enqueue_styles' ); } /** * Register all of the hooks related to the public-facing functionality. */ private function define_public_hooks() { // Public hooks can be added here if needed. } /** * Register all of the hooks related to the REST API. */ private function define_rest_hooks() { $rest_api = new AIDD_REST_API(); $this->loader->add_action( 'rest_api_init', $rest_api, 'register_routes' ); $this->loader->add_action( 'init', $rest_api, 'add_rewrite_rule' ); $this->loader->add_action( 'template_redirect', $rest_api, 'handle_well_known_request' ); $this->loader->add_filter( 'rest_pre_serve_request', $rest_api, 'add_cors_headers', 10, 4 ); } /** * Run the loader to execute all of the hooks with WordPress. */ public function run() { $this->loader->run(); } }