get_option() filtering and getting out of recursion

Usually I remove the filter, then add it back on afterwards;

function _my_custom_option( $option )
{
    remove_filter( 'pre_option_name', '_my_custom_option' );

    // do what you like with $option

    add_filter( 'pre_option_name', '_my_custom_option' );
    return $option;
}
add_filter( 'pre_option_name', '_my_custom_option' );

Leave a Comment