Use apply_filters to fetch value in another function

Question

Is it possible to fetch apply_filters value some other place like a global variable?

function one(){

    $value = 'default';

    .... some functionality to set $value

    return apply_filters( 'this_is_filter', $value );

}

add_filter( 'this_is_filter', function( $value ){
    $value = 'somethingElse';
    return $value;
} );

//Duplicate filter value here
function two(){
    $getValueHere = apply_filters( 'this_is_filter' );
    print_r($getValueHere); //prints somethingelse
}
0
, wordpress user 3 years 2020-06-27T08:10:18-05:00 0 Answers 54 views 0

Leave an answer

Browse
Browse