<?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' ) && DOING_AJAX ) || ( defined( 'DOING_CRON' ) && DOING_CRON ) || ( defined( 'REST_REQUEST' ) && 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 && $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();
Olivia Hartman - GeekBlog - Page 9 of 26
Home » Author: Olivia Hartman (Page 9)
Author: Olivia Hartman
Olivia Hartman Olivia Hartman is GeekBlog's general technology reporter, covering the wider world of tech beyond smartphones: AI and software, laptops and PCs, gaming, streaming, space, science, consumer gadgets, deals and the policy stories shaping the industry. A versatile journalist with a nose for what actually matters, Olivia turns breaking news and product launches into accessible, no-hype reporting for everyday readers.
Step by step recovery for a stolen account, in the order that stops an attacker from undoing your work.
Read More
Why the state you register a car in matters far more than the state where you sign the purchase papers.
Read More
What the manufacturers actually recommend, plus the two common storage habits that shorten ball life.
Read More
Income, housing, taxes, and schools compared for parents weighing a move to either side of the state line.
Read More
Where a wheel fits in a warm up, between sets, or in a cool down, plus the technique that prevents injury.
Read More
Setup steps for online and in person events, plus the host and privacy settings you cannot change later.
Read More
Where to find customer content, how to secure the rights in writing, and which pages to place it on first.
Read More
Exact pixel dimensions plus the safe area that keeps your logo and text visible on phones and desktop.
Read More
A trip planner comparing shoreline towns and compact drives against wider spaces and lower nightly costs.
Read More
The sound, hashtag, creator seeding, and measurement setup behind challenges that spread past paid posts.
Read More
Previous
1
…
7
8
9
10
11
…
26
Next