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 +14 -2 1.0.56 → 1.0.64 View file →
@@ -19,8 +19,9 @@
19 19 * @return void
20 20 */
21 21 public function init() {
22 22 add_action( 'init', [$this, 'register'] );
23 + add_action( 'init', [$this, 'maybe_flush_rules'], 99 );
23 24 }
24 25
25 26 /**
26 27 * Register all custom endpoints
@@ -32,11 +33,22 @@
32 33
33 34 foreach ( $endpoints as $endpoint ) {
34 35 add_rewrite_endpoint( $endpoint, EP_ALL );
35 36 }
37 + }
36 38
37 - // Flush rewrite rules after register all custom endpoints.
38 - 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 + }
39 51 }
40 52
41 53 /**
42 54 * Get all endpoints