diff --git a/wp-openapi.php b/wp-openapi.php index 40812e4..a38052e 100644 --- a/wp-openapi.php +++ b/wp-openapi.php @@ -197,8 +197,7 @@ public function enqueueScritps() { register_activation_hook( __FILE__, function () use ( $wpOpenAPI ) { - $wpOpenAPI->registerRoutes(); - flush_rewrite_rules(); + define( 'WP_OPENAPI_ACTIVATION', true ); } ); @@ -209,6 +208,10 @@ function () use ( $wpOpenAPI ) { 'init', function() use ( $wpOpenAPI ) { $wpOpenAPI->registerRoutes(); + + if ( defined( 'WP_OPENAPI_ACTIVATION' ) ) { + flush_rewrite_rules(); + } } ); add_action( 'rest_api_init', array( $wpOpenAPI, 'registerRestAPIEndpoint' ) );