*/ if ( ! class_exists( 'Acme_Coming_Soon_Api' ) ) { /** * Acme_Coming_Soon_Api * * @package Acme_Coming_Soon * @since 1.0.0 */ class Acme_Coming_Soon_Api extends WP_Rest_Controller { /** * Rest route namespace. * * @var Acme_Coming_Soon_Api */ public $namespace = 'acme-coming-soon/'; /** * Rest route version. * * @var Acme_Coming_Soon_Api */ public $version = 'v1'; /** * Whether the controller supports batching. * * @since 1.0.0 * @var array */ protected $allow_batch = array( 'v1' => true ); /** * Table name. * * @var string */ public $type; /** * Constructor * * @since 1.0.0 */ public function __construct() {} /** * Initialize the class and set up actions. * * @access public * @return void */ public function run() { /*Custom Rest Routes*/ add_action( 'rest_api_init', array( $this, 'register_routes' ) ); } /** * Gets an instance of this object. * Prevents duplicate instances which avoid artefacts and improves performance. * * @static * @access public * @return object * @since 1.0.0 */ public static function get_instance() { // Store the instance locally to avoid private static replication. static $instance = null; // Only run these methods if they haven't been ran previously. if ( null === $instance ) { $instance = new self(); } // Always return the instance. return $instance; } /** * Throw error on object clone * * The whole idea of the singleton design pattern is that there is a single * object therefore, we don't want the object to be cloned. * * @access public * @return void * @since 1.0.0 */ public function __clone() { // Cloning instances of the class is forbidden. _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'acme-coming-soon' ), '1.0.0' ); } /** * Disable unserializing of the class * * @access public * @return void * @since 1.0.0 */ public function __wakeup() { // Unserializing instances of the class is forbidden. _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'acme-coming-soon' ), '1.0.0' ); } } }