Skip to content

Commit

Permalink
Merge pull request #15 from lots0logs/patch-1
Browse files Browse the repository at this point in the history
Fix fatal error during activation callback
  • Loading branch information
moon0326 authored Oct 11, 2022
2 parents a8ab035 + f0d3eb0 commit a776071
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions wp-openapi.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ public function enqueueScritps() {
register_activation_hook(
__FILE__,
function () use ( $wpOpenAPI ) {
$wpOpenAPI->registerRoutes();
flush_rewrite_rules();
define( 'WP_OPENAPI_ACTIVATION', true );
}
);

Expand All @@ -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' ) );
Expand Down

0 comments on commit a776071

Please sign in to comment.