protected static add_filter ( string $hook, string $method = null, integer $priority = 10, $params = null, string $class = null ) | ||
$hook | string | Filter name |
$method | string | Method name on current class, or priority (as an int) |
$priority | integer | Specify the order in which the functions associated with a particular action are executed (default: 10) |
$class | string | Internal use only |
protected static function add_filter($hook, $method = null, $priority = 10, $params = null, $class = null)
{
if ($method === null) {
$method = $hook;
} elseif (is_int($method)) {
$priority = $method;
$method = $hook;
}
if ($class === null) {
$class = get_called_class();
}
if (!method_exists($class, $method)) {
throw new InvalidArgumentException('Method does not exist');
}
if ($params === null) {
$ref = new ReflectionMethod($class, $method);
$params = $ref->getNumberOfParameters();
}
return add_filter($hook, array($class, $method), $priority, $params);
}