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

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

- Page: https://pluginprobe.com/plugins/wpfunnels/3.13.1/code/includes/core/rest-api/class-server.php
- Raw: https://pluginprobe.com/plugins/wpfunnels/3.13.1/raw/includes/core/rest-api/class-server.php
- Modified: 2026-09-15T04:31:16+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.1/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',
			'templates_library'     => 'TemplateLibraryController',
			'order_bump'            => 'OrderBumpController',
			'funnel_control'        => 'FunnelController',
			'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',
            'automation'            => 'WpfnlAutomationController',
            'ai_chat'               => 'AiChatController',
            'ai_generate'           => 'SingleShotAiController',
        ));
    }

    /**
     * Return the path to the package.
     *
     * @return string
     */
    public static function get_path()
    {
        return dirname(__DIR__);
    }
}

```
