Skip to content

Commit 77e3b9e

Browse files
committed
Allow async ping delay to be filtered, increase default to 10 seconds.
1 parent 44748e1 commit 77e3b9e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

inc/namespace.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,17 @@ function async_ping_indexnow( $post ) {
449449

450450
$post_id = $post->ID;
451451

452+
/**
453+
* Filter the delay (in seconds) before the asynchronous ping runs.
454+
*
455+
* @param int $delay The delay in seconds. Default is 10 seconds.
456+
*/
457+
$delay = apply_filters( 'simple_search_submission_async_wait', 10, $post );
458+
459+
// Revert delay to default if it isn't numeric.
460+
$delay = is_numeric( $delay ) ? (int) $delay : 10;
461+
452462
if ( ! wp_next_scheduled( 'simple_search_submission_async_ping', array( $post_id ) ) ) {
453-
wp_schedule_single_event( time() + 5, 'simple_search_submission_async_ping', array( $post_id ) );
463+
wp_schedule_single_event( time() + $delay, 'simple_search_submission_async_ping', array( $post_id ) );
454464
}
455465
}

0 commit comments

Comments
 (0)