# timetics/1.0.2/base/custom-endpoint.php

Timetics – Appointment Booking Calendar &amp; Scheduling, version 1.0.2. 52 lines.

- Page: https://pluginprobe.com/plugins/timetics/1.0.2/code/base/custom-endpoint.php
- Raw: https://pluginprobe.com/plugins/timetics/1.0.2/raw/base/custom-endpoint.php
- Modified: 2023-04-04T11:35:18+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/timetics/1.0.2/code/base/custom-endpoint.php#L10-L20`.

```php
<?php
/**
 * Register Custom Endpoint
 *
 * @package Timetics
 */
namespace Timetics\Base;
use Timetics\Utils\Singleton;

class Custom_Endpoint {
    use Singleton;

    /**
     * Initialize
     *
     * @return  void
     */
    public function init() {
        add_action( 'init', [$this, 'register'] );
    }

    /**
     * Register all custom endpoints
     *
     * @return  void
     */
    public function register() {
        $endpoints = $this->get_endpoints();

        foreach ( $endpoints as $endpoint ) {
            add_rewrite_endpoint( $endpoint, EP_ALL );
        }

        // Flush rewrite rules after register all custom endpoints.
        flush_rewrite_rules( true );
    }

    /**
     * Get all endpoints
     *
     * @return  array
     */
    public function get_endpoints() {
        /**
         * All endpoints that have to be register
         */
        return [
            'timetics-integration',
        ];
    }
};

```
