Skip to content

Commit 195c68e

Browse files
committed
Allow async ping delay to be filtered, increase default to 10 seconds.
1 parent de8b6e1 commit 195c68e

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
@@ -424,7 +424,17 @@ function async_ping_indexnow( $post ) {
424424

425425
$post_id = $post->ID;
426426

427+
/**
428+
* Filter the delay (in seconds) before the asynchronous ping runs.
429+
*
430+
* @param int $delay The delay in seconds. Default is 10 seconds.
431+
*/
432+
$delay = apply_filters( 'simple_search_submission_async_wait', 10, $post );
433+
434+
// Revert delay to default if it isn't numeric.
435+
$delay = is_numeric( $delay ) ? (int) $delay : 10;
436+
427437
if ( ! wp_next_scheduled( 'simple_search_submission_async_ping', array( $post_id ) ) ) {
428-
wp_schedule_single_event( time() + 5, 'simple_search_submission_async_ping', array( $post_id ) );
438+
wp_schedule_single_event( time() + $delay, 'simple_search_submission_async_ping', array( $post_id ) );
429439
}
430440
}

0 commit comments

Comments
 (0)