# wpfunnels/3.13.2/includes/core/rest-api/class-server.php

WPFunnels – Funnel Builder for WooCommerce with Checkout &amp; One Click Upsell, version 3.13.2. 133 lines.

- Page: https://pluginprobe.com/plugins/wpfunnels/3.13.2/code/includes/core/rest-api/class-server.php
- Raw: https://pluginprobe.com/plugins/wpfunnels/3.13.2/raw/includes/core/rest-api/class-server.php
- Modified: 2026-09-24T08:31:46+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wpfunnels/3.13.2/code/includes/core/rest-api/class-server.php#L10-L20`.

```php
<?php
/**
 * Server
 *
 * @package
 */
namespace WPFunnels\Rest;

class Server
{

    /**
     * The single instance of the class.
     *
     * @var object
     */
    protected static $instance = null;

    /**
     * REST API namespaces and endpoints.
     *
     * @var array
     */
    protected $controllers = [];

    /**
     * Get class instance.
     *
     * @return object Instance.
     */
    final public static function instance()
    {
        if (null === static::$instance) {
            static::$instance = new static();
        }
        return static::$instance;
    }

    /**
     * Hook into WordPress ready to init the REST API as needed.
     */
    public function init()
    {
        add_action('rest_api_init', [ $this, 'register_rest_routes' ], 10);
    }

    /**
     * Register REST API routes.
     */
    public function register_rest_routes()
    {

        foreach ($this->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__);
    }
}

```
