Commit 7d783975 authored by Erick Hitter's avatar Erick Hitter
Browse files

Also create table when event-list endpoint is called

parent a6484b9f
......@@ -58,9 +58,7 @@ class Events_Store extends Singleton {
add_filter( 'schedule_event', '__return_false' );
// In limited circumstances, try creating the table
if ( is_admin() ) {
add_action( 'shutdown', array( $this, 'prepare_table' ) );
}
add_action( 'shutdown', array( $this, 'maybe_create_table_on_shutdown' ) );
}
}
......@@ -118,6 +116,18 @@ class Events_Store extends Singleton {
restore_current_blog();
}
/**
* For certain requests, create the table on shutdown
* Does not include front-end requests
*/
public function maybe_create_table_on_shutdown() {
if ( ! is_admin() && ! is_rest_endpoint_request( 'list' ) ) {
return;
}
$this->prepare_table();
}
/**
* Create table in non-setup contexts, with some protections
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment