geno/wp-content/plugins/cartflows/admin-core/api/api-init.php

95 lines
1.5 KiB
PHP
Raw Permalink Normal View History

2024-02-01 17:24:18 +05:30
<?php
/**
* CartFlows Admin Menu.
*
* @package CartFlows
*/
namespace CartflowsAdmin\AdminCore\Api;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class Admin_Menu.
*/
class ApiInit {
/**
* Instance
*
* @access private
* @var object Class object.
* @since 1.0.0
*/
private static $instance;
/**
* Initiator
*
* @since 1.0.0
* @return object initialized object of class.
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Instance
*
* @access private
* @var string Class object.
* @since 1.0.0
*/
private $menu_slug;
/**
* Constructor
*
* @since 1.0.0
*/
public function __construct() {
$this->menu_slug = 'cartflows';
$this->initialize_hooks();
}
/**
* Init Hooks.
*
* @since 1.0.0
* @return void
*/
public function initialize_hooks() {
// REST API extensions init.
add_action( 'rest_api_init', array( $this, 'register_routes' ) );
}
/**
* Register API routes.
*/
public function register_routes() {
$controllers = array(
'CartflowsAdmin\AdminCore\Api\Flows',
'CartflowsAdmin\AdminCore\Api\FlowData',
'CartflowsAdmin\AdminCore\Api\StepData',
'CartflowsAdmin\AdminCore\Api\CommonSettings',
'CartflowsAdmin\AdminCore\Api\HomePage',
'CartflowsAdmin\AdminCore\Api\Product\ProductData',
);
foreach ( $controllers as $controller ) {
$controller::get_instance()->register_routes();
}
}
}
ApiInit::get_instance();