PluginProbe
Timetics – Appointment Booking Calendar & Scheduling / 1.0.64
Timetics – Appointment Booking Calendar & Scheduling v1.0.64
1.0.64 1.0.62 1.0.63 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 All 65 releases
← All changes | base/custom-endpoint.php +17 -2 1.0.16 → 1.0.64 View file →
@@ -4,8 +4,11 @@
4 4 *
5 5 * @package Timetics
6 6 */
7 7 namespace Timetics\Base;
8 +
9 +defined( 'ABSPATH' ) || exit;
10 +
8 11 use Timetics\Utils\Singleton;
9 12
10 13 class Custom_Endpoint {
11 14 use Singleton;
@@ -16,8 +19,9 @@
16 19 * @return void
17 20 */
18 21 public function init() {
19 22 add_action( 'init', [$this, 'register'] );
23 + add_action( 'init', [$this, 'maybe_flush_rules'], 99 );
20 24 }
21 25
22 26 /**
23 27 * Register all custom endpoints
@@ -29,11 +33,22 @@
29 33
30 34 foreach ( $endpoints as $endpoint ) {
31 35 add_rewrite_endpoint( $endpoint, EP_ALL );
32 36 }
37 + }
33 38
34 - // Flush rewrite rules after register all custom endpoints.
35 - flush_rewrite_rules( true );
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 + }
36 51 }
37 52
38 53 /**
39 54 * Get all endpoints