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 functions.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?
function.php
but the file in the theme isfunctions.php
with a "s". – Kaperto Dec 24 '19 at 8:50globals
, in this case it's the only way to solve my problem? – user3013494 Dec 24 '19 at 13:23