| @@ -1,9 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * Server |
| 4 | - * | |
| 5 | - * @package | |
| 4 | + * | |
| 5 | + * @package | |
| 6 | 6 | */ |
| 7 | 7 | namespace WPFunnels\Rest; |
| 8 | 8 | |
| 9 | 9 | class Server |
| @@ -52,8 +52,13 @@ | ||
| 52 | 52 | |
| 53 | 53 | foreach ($this->get_rest_namespaces() as $namespace => $controllers) { |
| 54 | 54 | foreach ($controllers as $controller_name => $controller_class) { |
| 55 | 55 | $controller_class_name = "WPFunnels\\Rest\\Controllers\\".$controller_class; |
| 56 | + | |
| 57 | + if ( ! class_exists( $controller_class_name ) ) { | |
| 58 | + continue; | |
| 59 | + } | |
| 60 | + | |
| 56 | 61 | $this->controllers[ $namespace ][ $controller_name ] = new $controller_class_name(); |
| 57 | 62 | $this->controllers[ $namespace ][ $controller_name ]->register_routes(); |
| 58 | 63 | } |
| 59 | 64 | } |
| @@ -79,18 +84,41 @@ | ||
| 79 | 84 | */ |
| 80 | 85 | protected function get_controllers() |
| 81 | 86 | { |
| 82 | 87 | return apply_filters( 'wpfunnels/rest_api_controllers', array( |
| 88 | + 'mcp_settings' => 'McpSettingsController', | |
| 83 | 89 | 'settings' => 'SettingsController', |
| 90 | + // The React settings screen (?page=wpfunnels#/settings). | |
| 91 | + 'settings_page' => 'SettingsPageController', | |
| 84 | 92 | 'templates_library' => 'TemplateLibraryController', |
| 85 | 93 | 'order_bump' => 'OrderBumpController', |
| 86 | 94 | 'funnel_control' => 'FunnelController', |
| 95 | + // Funnel listing screen (?page=wpfunnels#/funnels). | |
| 96 | + 'funnel_list' => 'FunnelListController', | |
| 97 | + 'offer' => 'OfferController', | |
| 87 | 98 | 'step_control' => 'StepController', |
| 88 | 99 | 'remote_funnel' => 'RemoteFunnelsController', |
| 89 | 100 | 'products' => 'ProductsController', |
| 90 | 101 | 'gutenberg' => 'GutenbergCSSController', |
| 91 | - 'checkout' => 'CheckoutController' | |
| 92 | - )); | |
| 102 | + 'checkout' => 'CheckoutController', | |
| 103 | + 'importexport' => 'ImportExportController', | |
| 104 | + 'report' => 'DashboardController', | |
| 105 | + 'plugin_installer' => 'PluginInstallerController', | |
| 106 | + 'setup_wizard' => 'SetupWizardController', | |
| 107 | + 'store_checkout' => 'StoreCheckoutController', | |
| 108 | + /* | |
| 109 | + * Two different controllers answer to automations, and WPFunnels Pro | |
| 110 | + * overwrites the 'automation' key with its own CRM controller (see | |
| 111 | + * wpfunnels_add_analytics_controller in wpfnl-pro.php). Keeping this | |
| 112 | + * one under its own key means both register instead of the Pro one | |
| 113 | + * silently replacing it — which is what left the wpfnl/v1 namespace | |
| 114 | + * with no routes at all whenever Pro was active. | |
| 115 | + */ | |
| 116 | + 'automation' => 'WpfnlAutomationController', | |
| 117 | + 'automation_canvas_crud' => 'WpfnlAutomationController', | |
| 118 | + 'ai_chat' => 'AiChatController', | |
| 119 | + 'ai_generate' => 'SingleShotAiController', | |
| 120 | + )); | |
| 93 | 121 | } |
| 94 | 122 | |
| 95 | 123 | /** |
| 96 | 124 | * Return the path to the package. |