Never creates self filters before. In my plugin I have variable as array. I want another users can change this array without plugin modification. I'm trying this code in my plugin.php
:
<?php
/*
Plugin Name: Test plugin
*/
$arr = [
'val',
'val2',
'val3'
];
$arr = apply_filters( 'my_hook', $arr );
print_r( $arr );
In my function.php
I puts this code:
add_filter( 'my_hook', 'modify', 10, 1 );
function modify( $arr ) {
unset($arr[0]);
return $arr;
}
I expecting output without first element, but it outputs original array with 3 values;
What's wrong with it?
Post a Comment