PluginProbe
Timetics – Appointment Booking Calendar & Scheduling / 1.0.60
Timetics – Appointment Booking Calendar & Scheduling v1.0.60
1.0.61 1.0.60 1.0.59 1.0.58 1.0.57 1.0.56 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 All 62 releases
timetics / base / custom-endpoint.php

custom-endpoint.php in Timetics – Appointment Booking Calendar & Scheduling 1.0.60, at base/custom-endpoint.php

67 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Register Custom Endpoint
4 *
5 * @package Timetics
6 */
7 namespace Timetics\Base;
8
9 defined( 'ABSPATH' ) || exit;
10
11 use Timetics\Utils\Singleton;
12
13 class Custom_Endpoint {
14 use Singleton;
15
16 /**
17 * Initialize
18 *
19 * @return void
20 */
21 public function init() {
22 add_action( 'init', [$this, 'register'] );
23 add_action( 'init', [$this, 'maybe_flush_rules'], 99 );
24 }
25
26 /**
27 * Register all custom endpoints
28 *
29 * @return void
30 */
31 public function register() {
32 $endpoints = $this->get_endpoints();
33
34 foreach ( $endpoints as $endpoint ) {
35 add_rewrite_endpoint( $endpoint, EP_ALL );
36 }
37 }
38
39 /**
40 * Flush rewrite rules once per plugin version (after upgrade or fresh install).
41 *
42 * @return void
43 */
44 public function maybe_flush_rules() {
45 $stored = get_option( 'timetics_rewrite_version' );
46
47 if ( defined( 'TIMETICS_VERSION' ) && $stored !== TIMETICS_VERSION ) {
48 flush_rewrite_rules( false );
49 update_option( 'timetics_rewrite_version', TIMETICS_VERSION, false );
50 }
51 }
52
53 /**
54 * Get all endpoints
55 *
56 * @return array
57 */
58 public function get_endpoints() {
59 /**
60 * All endpoints that have to be register
61 */
62 return [
63 'timetics-integration',
64 ];
65 }
66 };
67