Skip to content

Commit 0592e08

Browse files
committed
Allow developers to ping on non-production environments.
1 parent c1b9685 commit 0592e08

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

inc/namespace.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,25 @@ function ping_indexnow( $post ) {
333333
),
334334
);
335335

336-
if ( wp_get_environment_type() !== 'production' ) {
336+
if (
337+
wp_get_environment_type() !== 'production'
338+
/**
339+
* Filter whether to bypass pings in non-production environments.
340+
*
341+
* By default, only production environments (determined by the return value
342+
* of `wp_get_environment_type()`) will ping IndexNow. Other environments
343+
* will log the request to indicate the URLs that would have been pinged.
344+
*
345+
* Returning false on this filter will result in the request being sent
346+
* to IndexNow on non-production values.
347+
*
348+
* @param bool $bypass Whether to bypass pings on non-production environments.
349+
* Default is true.
350+
* @param \WP_Post $post The post object
351+
* @param string[] $url_list The list of URLs to be pinged
352+
*/
353+
&& apply_filters( 'pwcc/index-now/bypass-non-production-environment', true, $post, $url_list )
354+
) {
337355
// In development, log the request for debugging.
338356
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log, WordPress.PHP.DevelopmentFunctions.error_log_print_r
339357
error_log( 'IndexNow ping request: ' . print_r( $request, true ) );

0 commit comments

Comments
 (0)