Skip to content

en Hooks

Torsten Landsiedel edited this page Apr 13, 2017 · 11 revisions

Language: en, de

Hooks allow to the user to extend the functional extent of a WordPress-Plugins. The following Hooks are deposited in Antispam Bee and can be addressed or controlled via code:

antispam_bee_patterns

Extension of RegExp rules or regular expressions. This allows you to specify custom antispam rules that are adapted to the current type of spam at any time. Conclusion: Faster response with less spam. Nevertheless, we would be glad if you report this spam or if you pull the extension here on the GitHub repository.

Type: Array

Example:

function antispam_bee_patterns() {
    add_filter( 'antispam_bee_patterns', 'antispam_bee_add_custom_patterns' );
}
add_action( 'init', 'antispam_bee_patterns' );
 
// Determine individual filters (author, host, body, ip, email). Separate multiple regular expressions with |
function antispam_bee_add_custom_patterns($patterns) {
	
	// Autoren filtern
	$patterns[] = array(
		'author' => 'Autor1|Autor2|Autor3'
	);

	// Filter URL (example filters example.de.cool and example.de with and without www.)
	$patterns[] = array(
		'host' => '^(www\.)?example\.de\.cool$|^(www\.)?example\.de$'
	);

	// Filter comment content (example treats 3 or more links in the comment as spam)
	$patterns[] = array(
		'body' => '(.*(http|https|ftp|ftps)\:\/\/){3,}'
	);

	// Filter IP address (example filters 192.168.XXX.XXX)
	$patterns[] = array(
		'ip' => '^(192\.)(168\.)(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.)([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$'
	);

	// Filter e-mail address (example treats .xx or .xxx as spam)
	$patterns[] = array(
		'email' => '(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.(xx|xxx)+$)'
	);

	return $patterns;
}

antispam_bee_notification_subject

With this plugin filter the subject of the notification mails can be defined according to your own wishes.

Type: String

ab_get_allowed_translate_languages

This filter can be used to change the languages in the dropdown for the feature Allow comments only in certain language.

Type: Array

Example: Add Afrikaans to the list of languages

add_filter( 'ab_get_allowed_translate_languages', function( $languages ) {
  $languages['af'] => 'Afrikaans';
  return $languages;
});

Jumping marks