add_filter does not work as expected

Question

I have a wordpress plugin where i included this (with some changes)

$fep_files = array(
    'first' => 'first.php',
    'second' => 'second.php'
);

$fep_files = apply_filters('include_files', $fep_files );

foreach ( $fep_files as $fep_file )
require_once ( $fep_file );
unset ( $fep_files );

Now i added in my theme’s function.php

function fep_remove ( $fep_files )
{
    if ( isset ( $fep_files['first'] ) ) {
        unset ( $fep_files['first'] );
            }
        //die($fep_files); //to check it fires
    return $fep_files;
}

add_filter( 'include_files', 'fep_remove' );

It should remove first.php but it does not. i am wrong some where, but where?
Is there any better way to include files where user can include/exclude any files if needed?

0
Shamim Hasan 4 months 2020-12-21T03:10:20-05:00 0 Answers 9 views 0

Leave an answer

Browse
Browse