Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

How can apply_filters be used to create a filter hook in wordpress

function add_filter($name, $callback) {
    global $filters;
    $filters[$name][] = $callback;
}

function apply_filters($name, $value) {
    global $filters;
    if(array_key_exists($name, $filters)) {
        foreach($filters[$name] as $callback) {
            $value = $callback($value);
        }
    }
    return $value;
}
 
PREVIOUS NEXT
Tagged: #How #create #filter #hook #wordpress
ADD COMMENT
Topic
Name
5+2 =