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