get_rest_namespaces() as $namespace => $controllers) { foreach ($controllers as $controller_name => $controller_class) { $controller_class_name = "WPFunnels\\Rest\\Controllers\\".$controller_class; if ( ! class_exists( $controller_class_name ) ) { continue; } $this->controllers[ $namespace ][ $controller_name ] = new $controller_class_name(); $this->controllers[ $namespace ][ $controller_name ]->register_routes(); } } } /** * Get API namespaces - new namespaces should be registered here. * * @return array List of Namespaces and Main controller classes. */ protected function get_rest_namespaces() { return [ 'wpfunnels/v1' => $this->get_controllers(), ]; } /** * List of controllers in the wc/v1 namespace. * * @return array */ protected function get_controllers() { return apply_filters( 'wpfunnels/rest_api_controllers', array( 'mcp_settings' => 'McpSettingsController', 'settings' => 'SettingsController', // The React settings screen (?page=wpfunnels#/settings). 'settings_page' => 'SettingsPageController', 'templates_library' => 'TemplateLibraryController', 'order_bump' => 'OrderBumpController', 'funnel_control' => 'FunnelController', // Funnel listing screen (?page=wpfunnels#/funnels). 'funnel_list' => 'FunnelListController', 'offer' => 'OfferController', 'step_control' => 'StepController', 'remote_funnel' => 'RemoteFunnelsController', 'products' => 'ProductsController', 'gutenberg' => 'GutenbergCSSController', 'checkout' => 'CheckoutController', 'importexport' => 'ImportExportController', 'report' => 'DashboardController', 'plugin_installer' => 'PluginInstallerController', 'setup_wizard' => 'SetupWizardController', 'store_checkout' => 'StoreCheckoutController', /* * Two different controllers answer to automations, and WPFunnels Pro * overwrites the 'automation' key with its own CRM controller (see * wpfunnels_add_analytics_controller in wpfnl-pro.php). Keeping this * one under its own key means both register instead of the Pro one * silently replacing it — which is what left the wpfnl/v1 namespace * with no routes at all whenever Pro was active. */ 'automation' => 'WpfnlAutomationController', 'automation_canvas_crud' => 'WpfnlAutomationController', 'ai_chat' => 'AiChatController', 'ai_generate' => 'SingleShotAiController', )); } /** * Return the path to the package. * * @return string */ public static function get_path() { return dirname(__DIR__); } }