<?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();
malware - GeekBlog
Home » Posts Tagged "malware"
Browsing: malware DoubleTrouble is an Android banking trojan handed out through Discord channels. It records your screen, logs keystrokes and blocks banking apps. Here is how it works and how to check your phone.