<?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 8 of 26
Home » Author: Olivia Hartman (Page 8)
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.
Nvidia is buying Hugging Face for close to $13 billion, its second largest acquisition ever. Here is what the deal actually contains, and why regulators, and Hugging Face’s own developer community, are already nervous.
Read More Apple disclosed John Ternus’s compensation in an SEC filing on his first day as CEO. The headline number is $58 million for fiscal 2027, but three quarters of the equity only pays out if Apple’s shareholder return beats the rest of the S&P 500.
Read More
Finding the action button control, picking a destination, and confirming it renders well for phone users.
Read More
Requesting your archive, choosing a format and date range, and knowing what the download really holds.
Read More
What raising kids in Pennsylvania costs once local earned income tax and school property tax are counted.
Read More
Why the same models serve civilian and military uses, and the public rules that follow from that fact.
Read More
The housing gap and tax trade offs that decide this move for most parents with school age children.
Read More
The law behind the browser and search prompts, and what actually happens after you tap an option.
Read More
Where the username field lives, what Meta allows, and why old vanity links break after you switch.
Read More
What you get and what you give up when a Google product is labeled preview rather than fully released.
Read More
Previous
1
…
6
7
8
9
10
…
26
Next