Jak można użyć aplikacji do utworzenia haczyka filtra w WordPress
$name = "Chris";
$name = apply_filters("change_name", $name);
echo $name;
SAMER SAEID
$name = "Chris";
$name = apply_filters("change_name", $name);
echo $name;
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;
}
add_filter(
"change_name",
function($name){ return "Steve";}
);