$host, 'key' => $key, 'keyLocation' => $key_location, 'urlList' => [ $url ], ] ); foreach ( self::ENDPOINTS as $endpoint ) { wp_remote_post( $endpoint, [ 'body' => $body, 'headers' => [ 'Content-Type' => 'application/json' ], 'timeout' => 10, 'blocking' => false, // Fire and forget ] ); } } /** * Batch ping multiple URLs (e.g., on regeneration). */ public static function ping_batch( array $urls, array $settings ): void { $key = $settings['indexnow_key'] ?? ''; if ( empty( $key ) || empty( $urls ) ) { return; } $host = wp_parse_url( home_url(), PHP_URL_HOST ); $key_location = home_url( '/' . $key . '.txt' ); // IndexNow max 10000 per batch $batches = array_chunk( $urls, 10000 ); foreach ( $batches as $batch ) { $body = wp_json_encode( [ 'host' => $host, 'key' => $key, 'keyLocation' => $key_location, 'urlList' => $batch, ] ); foreach ( self::ENDPOINTS as $endpoint ) { wp_remote_post( $endpoint, [ 'body' => $body, 'headers' => [ 'Content-Type' => 'application/json' ], 'timeout' => 15, 'blocking' => false, ] ); } } } }