Verified Commit c140650c authored by Erick Hitter's avatar Erick Hitter
Browse files

Set internal events on more-appropriate hooks, particularly one that doesn't...

Set internal events on more-appropriate hooks, particularly one that doesn't run for all front-end requests

Hooking on `rest_api_init` may be a problem, but since this plugin is predicated on the REST API, it seems equally foolish _not_ to.

Fixes #16
parent 6460e969
......@@ -53,7 +53,8 @@ class Internal_Events extends Singleton {
);
// Register hooks
add_action( 'wp_loaded', array( $this, 'schedule_internal_events' ) );
add_action( 'admin_init', array( $this, 'schedule_internal_events' ) );
add_action( 'rest_api_init', array( $this, 'schedule_internal_events' ) );
add_filter( 'cron_schedules', array( $this, 'register_internal_events_schedules' ) );
foreach ( $this->internal_jobs as $internal_job ) {
......
......@@ -37,6 +37,17 @@ class REST_API_Tests extends \WP_UnitTestCase {
public function test_get_items() {
$ev = Utils::create_test_event();
// Don't test internal events with this test
$internal_events = array(
'a8c_cron_control_force_publish_missed_schedules',
'a8c_cron_control_confirm_scheduled_posts',
'a8c_cron_control_delete_cron_option',
'a8c_cron_control_purge_completed_events',
);
foreach ( $internal_events as $internal_event ) {
wp_clear_scheduled_hook( $internal_event );
}
$request = new \WP_REST_Request( 'POST', '/' . \Automattic\WP\Cron_Control\REST_API::API_NAMESPACE . '/' . \Automattic\WP\Cron_Control\REST_API::ENDPOINT_LIST );
$request->set_body( wp_json_encode( array( 'secret' => \WP_CRON_CONTROL_SECRET, ) ) );
$request->set_header( 'content-type', 'application/json' );
......
Supports Markdown
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