How to pass variables to custom filter from multiple functions

I think from your code

add_action( 'wp_footer', 'purewpns_googlefont_loader' );

Function purewpns_googlefont_loader maybe typo mistake.


You use the action wp_footer and added empty array which obviously print empty array.


Okay. You can use:

googlefont_filter_callback( $font );

Except

$fonts = apply_filters( 'googlefont_loader', $fonts );

In function googlefont_loader()

And add filter in function googlefont_filter_callback like:

function googlefont_filter_callback( $fonts=array() ) {
return apply_filters( 'googlefont_loader', $fonts );
}

Now you’ll be able to access fonts from both short code.

E.g.

add_filter( 'googlefont_loader' function( $fonts ) {
 var_dump( $fonts);
return $fonts;
});

But it affect on both short code. You can introduce another individual filters for each shortcode.