&lt;?php
/**
 * Plugin Name: GeekBlog: Query Param Hygiene
 * Description: Usuwa parametr wordfence_syncAttackData i podobne smieci z generowanych linkow paginacji, przekierowuje zasmiecone adresy paginacji na czyste, oznacza reszte jako noindex i blokuje je w robots.txt. Dodane 2026-09-21.
 * Version: 1.0
 * Author: GeekBlog
 */

defined( 'ABSPATH' ) || exit;

class GB_Query_Param_Hygiene {

	public static function junk() {
		return array(
			'wordfence_syncAttackData',
			'wordfence_lh',
			'wordfence_logHuman',
			'wfwaf-authcookie',
		);
	}

	public static function init() {
		add_filter( 'get_pagenum_link', array( __CLASS__, 'clean' ), 99 );
		add_filter( 'paginate_links', array( __CLASS__, 'clean' ), 99 );
		add_filter( 'rank_math/frontend/canonical', array( __CLASS__, 'clean' ), 99 );
		add_action( 'template_redirect', array( __CLASS__, 'guard' ), 1 );
		add_filter( 'robots_txt', array( __CLASS__, 'robots' ), 20 );
	}

	public static function clean( $url ) {
		if ( ! is_string( $url ) || false === strpos( $url, '?' ) ) {
			return $url;
		}
		return remove_query_arg( self::junk(), $url );
	}

	public static function has_junk() {
		foreach ( self::junk() as $key ) {
			if ( isset( $_GET[ $key ] ) ) {
				return true;
			}
		}
		return false;
	}

	public static function guard() {

		if ( is_admin() || is_user_logged_in() ) {
			return;
		}

		if ( ( defined( 'DOING_AJAX' ) &amp;&amp; DOING_AJAX ) || ( defined( 'DOING_CRON' ) &amp;&amp; DOING_CRON ) || ( defined( 'REST_REQUEST' ) &amp;&amp; REST_REQUEST ) ) {
			return;
		}

		if ( ! self::has_junk() ) {
			return;
		}

		$uri = isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : '';

		// Adresy paginacji z doklejonym parametrem to czysty smiec po crawlerze.
		// Wordfence odpala swoj sync tylko na biezacym adresie, wiec paginacje mozna bezpiecznie
		// sprowadzic jednym 301 do czystego adresu. Reszta dostaje tylko noindex, zeby nie
		// psuc wlasciwego mechanizmu Wordfence na stronie glownej i wpisach.
		if ( false !== strpos( $uri, '/page/' ) || is_paged() ) {

			$clean = remove_query_arg( self::junk(), home_url( $uri ) );

			if ( $clean &amp;&amp; $clean !== home_url( $uri ) ) {
				wp_safe_redirect( $clean, 301 );
				exit;
			}
		}

		if ( ! headers_sent() ) {
			header( 'X-Robots-Tag: noindex, nofollow', true );
		}
	}

	public static function robots( $output ) {

		$rules = "\n# Smieci po crawlerach i wtyczkach: nie indeksujemy i nie crawlujemy.\n";

		foreach ( self::junk() as $key ) {
			$rules .= 'Disallow: /*' . $key . "\n";
		}

		return $output . $rules;
	}
}

GB_Query_Param_Hygiene::init();
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://geekblog.net/news-sitemap.xsl"?>
<!-- Google News sitemap generated by News Sitemap Generator 1.0.0 on 2026-09-21T14:53:02+00:00 -->
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
	<url>
		<loc>https://geekblog.net/mobile/gemini-vs-google-assistant/</loc>
		<news:news>
			<news:publication>
				<news:name>geekblog.net</news:name>
				<news:language>en</news:language>
			</news:publication>
			<news:publication_date>2026-09-21T07:30:49+00:00</news:publication_date>
			<news:title>Gemini vs Google Assistant: What You Actually Lost on September 4</news:title>
		</news:news>
		<image:image>
			<image:loc>https://geekblog.net/wp-content/uploads/2026/09/woman-speaking-voice-command-smartphone-scaled.jpg</image:loc>
			<image:title>Gemini vs Google Assistant: What You Actually Lost on September 4</image:title>
		</image:image>
	</url>
	<url>
		<loc>https://geekblog.net/tech-news/elon-musk-airstream-trailer-memphis-xai-colossus/</loc>
		<news:news>
			<news:publication>
				<news:name>geekblog.net</news:name>
				<news:language>en</news:language>
			</news:publication>
			<news:publication_date>2026-09-20T18:00:00+00:00</news:publication_date>
			<news:title>Elon Musk Calls His Airstream a Palace. The Neighbors Are Suing Over What It Is Parked Next To.</news:title>
		</news:news>
		<image:image>
			<image:loc>https://geekblog.net/wp-content/uploads/2026/09/elon-musk-airstream-trailer-memphis-xai-data-center-scaled.jpg</image:loc>
			<image:title>Elon Musk Calls His Airstream a Palace. The Neighbors Are Suing Over What It Is Parked Next To.</image:title>
		</image:image>
	</url>
	<url>
		<loc>https://geekblog.net/smartwatch/apple-watch-series-12-audio-intelligence-iphone-16-requirement-2026/</loc>
		<news:news>
			<news:publication>
				<news:name>geekblog.net</news:name>
				<news:language>en</news:language>
			</news:publication>
			<news:publication_date>2026-09-20T17:07:07+00:00</news:publication_date>
			<news:title>Apple Watch Series 12’s New Audio Intelligence Needs an iPhone 16, Not Just the New Watch</news:title>
		</news:news>
		<image:image>
			<image:loc>https://geekblog.net/wp-content/uploads/2026/09/apple-watch-audio-intelligence-wrist-scaled.jpg</image:loc>
			<image:title>Apple Watch Series 12’s New Audio Intelligence Needs an iPhone 16, Not Just the New Watch</image:title>
		</image:image>
	</url>
	<url>
		<loc>https://geekblog.net/tech-news/king-charles-dumfries-house-ai-safety-summit/</loc>
		<news:news>
			<news:publication>
				<news:name>geekblog.net</news:name>
				<news:language>en</news:language>
			</news:publication>
			<news:publication_date>2026-09-20T17:00:00+00:00</news:publication_date>
			<news:title>King Charles Got the AI Bosses to Scotland. OpenAI Sent Its CFO.</news:title>
		</news:news>
		<image:image>
			<image:loc>https://geekblog.net/wp-content/uploads/2026/09/king-charles-ai-summit-dumfries-house-scotland-scaled.jpg</image:loc>
			<image:title>King Charles Got the AI Bosses to Scotland. OpenAI Sent Its CFO.</image:title>
		</image:image>
	</url>
	<url>
		<loc>https://geekblog.net/tech-news/hinton-congress-one-year-ai-regulation-deadline/</loc>
		<news:news>
			<news:publication>
				<news:name>geekblog.net</news:name>
				<news:language>en</news:language>
			</news:publication>
			<news:publication_date>2026-09-20T16:00:00+00:00</news:publication_date>
			<news:title>The Godfather of AI Gave Congress One Year. Every AI Bill on the Table Dies in January.</news:title>
		</news:news>
		<image:image>
			<image:loc>https://geekblog.net/wp-content/uploads/2026/09/hinton-congress-one-year-ai-regulation-us-capitol-building-scaled.jpg</image:loc>
			<image:title>The Godfather of AI Gave Congress One Year. Every AI Bill on the Table Dies in January.</image:title>
		</image:image>
	</url>
	<url>
		<loc>https://geekblog.net/gaming/sony-ps6-handheld-project-canis-540p-leak/</loc>
		<news:news>
			<news:publication>
				<news:name>geekblog.net</news:name>
				<news:language>en</news:language>
			</news:publication>
			<news:publication_date>2026-09-20T15:45:57+00:00</news:publication_date>
			<news:title>Sony’s PS6 Handheld Just Leaked, and It Renders Games at Only 540p</news:title>
		</news:news>
		<image:image>
			<image:loc>https://geekblog.net/wp-content/uploads/2026/09/pexels-photo-34482311-scaled.jpeg</image:loc>
			<image:title>Sony’s PS6 Handheld Just Leaked, and It Renders Games at Only 540p</image:title>
		</image:image>
	</url>
	<url>
		<loc>https://geekblog.net/tech-news/novo-nordisk-anthropic-claude-science-drug-discovery/</loc>
		<news:news>
			<news:publication>
				<news:name>geekblog.net</news:name>
				<news:language>en</news:language>
			</news:publication>
			<news:publication_date>2026-09-20T15:15:00+00:00</news:publication_date>
			<news:title>Ozempic’s Maker Just Put Claude in the Lab. Nine Out of Ten Drugs Still Fail.</news:title>
		</news:news>
		<image:image>
			<image:loc>https://geekblog.net/wp-content/uploads/2026/09/novo-nordisk-anthropic-claude-science-drug-discovery-laboratory.jpg</image:loc>
			<image:title>Ozempic’s Maker Just Put Claude in the Lab. Nine Out of Ten Drugs Still Fail.</image:title>
		</image:image>
	</url>
	<url>
		<loc>https://geekblog.net/smartwatch/best-smartwatch-for-running-2026/</loc>
		<news:news>
			<news:publication>
				<news:name>geekblog.net</news:name>
				<news:language>en</news:language>
			</news:publication>
			<news:publication_date>2026-09-20T14:16:41+00:00</news:publication_date>
			<news:title>Best Smartwatch for Running in 2026: GPS Accuracy and Battery Life Compared</news:title>
		</news:news>
		<image:image>
			<image:loc>https://geekblog.net/wp-content/uploads/2026/09/best-smartwatch-for-running-hero-2026-scaled.jpg</image:loc>
			<image:title>Best Smartwatch for Running in 2026: GPS Accuracy and Battery Life Compared</image:title>
		</image:image>
	</url>
	<url>
		<loc>https://geekblog.net/tech-news/microsoft-stock-1000-dollars-ten-years-ago-return/</loc>
		<news:news>
			<news:publication>
				<news:name>geekblog.net</news:name>
				<news:language>en</news:language>
			</news:publication>
			<news:publication_date>2026-09-19T18:00:00+00:00</news:publication_date>
			<news:title>$1,000 in Microsoft Ten Years Ago Is Worth About $8,900 Today. The Hard Part Was Holding It.</news:title>
		</news:news>
		<image:image>
			<image:loc>https://geekblog.net/wp-content/uploads/2026/09/microsoft-stock-10-year-return-market-chart-laptop-scaled.jpg</image:loc>
			<image:title>$1,000 in Microsoft Ten Years Ago Is Worth About $8,900 Today. The Hard Part Was Holding It.</image:title>
		</image:image>
	</url>
	<url>
		<loc>https://geekblog.net/smartwatch/smartwatches-losing-software-support-2026/</loc>
		<news:news>
			<news:publication>
				<news:name>geekblog.net</news:name>
				<news:language>en</news:language>
			</news:publication>
			<news:publication_date>2026-09-19T17:08:11+00:00</news:publication_date>
			<news:title>Five Apple Watches Just Lost watchOS 27, and Your Pixel or Galaxy Watch Could Be Next</news:title>
		</news:news>
		<image:image>
			<image:loc>https://geekblog.net/wp-content/uploads/2026/09/smartwatch-software-support-cutoff-2026-scaled.jpeg</image:loc>
			<image:title>Five Apple Watches Just Lost watchOS 27, and Your Pixel or Galaxy Watch Could Be Next</image:title>
		</image:image>
	</url>
	<url>
		<loc>https://geekblog.net/tech-news/emulate-deepmind-world-models-seed-round-valuation/</loc>
		<news:news>
			<news:publication>
				<news:name>geekblog.net</news:name>
				<news:language>en</news:language>
			</news:publication>
			<news:publication_date>2026-09-19T17:00:00+00:00</news:publication_date>
			<news:title>A One-Month-Old AI Company With No Website Is Worth Almost $4 Billion. Here Is What It Is Building.</news:title>
		</news:news>
		<image:image>
			<image:loc>https://geekblog.net/wp-content/uploads/2026/09/emulate-world-models-robotic-mechanism-scaled.jpg</image:loc>
			<image:title>A One-Month-Old AI Company With No Website Is Worth Almost $4 Billion. Here Is What It Is Building.</image:title>
		</image:image>
	</url>
	<url>
		<loc>https://geekblog.net/tech-news/nyc-throne-labs-smart-public-restrooms-10-minute-timer/</loc>
		<news:news>
			<news:publication>
				<news:name>geekblog.net</news:name>
				<news:language>en</news:language>
			</news:publication>
			<news:publication_date>2026-09-19T16:00:00+00:00</news:publication_date>
			<news:title>New York Spent $4 Million on Smart Public Toilets. The Door Opens on Its Own After 10 Minutes.</news:title>
		</news:news>
		<image:image>
			<image:loc>https://geekblog.net/wp-content/uploads/2026/09/nyc-public-restrooms-throne-labs-street-toilets-scaled.jpg</image:loc>
			<image:title>New York Spent $4 Million on Smart Public Toilets. The Door Opens on Its Own After 10 Minutes.</image:title>
		</image:image>
	</url>
	<url>
		<loc>https://geekblog.net/gaming/riot-vanguard-anti-boost-296416-accounts-banned/</loc>
		<news:news>
			<news:publication>
				<news:name>geekblog.net</news:name>
				<news:language>en</news:language>
			</news:publication>
			<news:publication_date>2026-09-19T15:44:52+00:00</news:publication_date>
			<news:title>Riot Just Banned 296,416 Accounts for Rank Manipulation, and Popular Streamers Got Caught in the Sweep</news:title>
		</news:news>
		<image:image>
			<image:loc>https://geekblog.net/wp-content/uploads/2026/09/rg-com-vanguard-antiboosting-article-scaled.png</image:loc>
			<image:title>Riot Just Banned 296,416 Accounts for Rank Manipulation, and Popular Streamers Got Caught in the Sweep</image:title>
		</image:image>
	</url>
	<url>
		<loc>https://geekblog.net/tech-news/claude-money-anthropic-bank-account-access/</loc>
		<news:news>
			<news:publication>
				<news:name>geekblog.net</news:name>
				<news:language>en</news:language>
			</news:publication>
			<news:publication_date>2026-09-19T15:15:00+00:00</news:publication_date>
			<news:title>Anthropic Wants Claude Inside Your Bank Account. Here Is What It Would Actually See.</news:title>
		</news:news>
		<image:image>
			<image:loc>https://geekblog.net/wp-content/uploads/2026/09/claude-money-linked-bank-account-smartphone-payment-scaled.jpg</image:loc>
			<image:title>Anthropic Wants Claude Inside Your Bank Account. Here Is What It Would Actually See.</image:title>
		</image:image>
	</url>
</urlset>
