public static function add_filter($rule, $callback)
{
$method = 'filter_' . $rule;
if (method_exists(__CLASS__, $method) || isset(self::$filter_methods[$rule])) {
throw new Exception("Filter rule '{$rule}' already exists.");
}
self::$filter_methods[$rule] = $callback;
return true;
}