I am trying to pass multi-dimensional array using add_filter
. I am able to pass single values like this:
add_filter('example_filter', 'my_example_filter_1' );
function my_example_filter_1( $array ){
$array[]='tax1';
return $array;
}
add_filter('example_filter', 'my_example_filter_2' );
function my_example_filter_2( $array ){
$array[]='tax2';
return $array;
}
add_filter('example_filter', 'my_example_filter_3' );
function my_example_filter_3( $array ){
$array[]='tax3';
return $array;
}
print_r( apply_filters( 'example_filter', array()) );
But if the array is of the following format, I am unable to achieve it.
function wte_fixed_starting_dates_license()
{
$wp_travel_engine = get_option( 'wp_travel_engine_license' );
$wte_fixed_departure_license_key = isset( $wp_travel_engine['wte_fixed_departure_dates_license_key'] ) ? esc_attr( $wp_travel_engine['wte_fixed_departure_dates_license_key'] ):'';// setup the updater
$array =
array(
'version' => '1.0.0', // current version number
'license' => $wte_fixed_departure_license_key, // license key (used get_option above to retrieve from DB)
'item_id' => WTE_FIXED_DEPARTURE_ITEM_ID, // id of this product in EDD
'author' => 'WP Travel Engine', // author of this plugin
'url' => home_url()
);
return $array;
}
add_filter( 'wp_travel_engine_licenses', 'wte_fixed_starting_dates_license' );
I am passing another array using the same filter like this:
function wte_authorize_net_license($array)
{
$wp_travel_engine = get_option( 'wp_travel_engine_license' );
$wte_authorize_net_license_key = isset( $wp_travel_engine['wte_authorize_net_dates_license_key'] ) ? esc_attr( $wp_travel_engine['wte_authorize_net_dates_license_key'] ):'';// setup the updater
$array =
array(
'version' => '1.0.0', // current version number
'license' => $wte_authorize_net_license_key, // license key (used get_option above to retrieve from DB)
'item_id' => WTE_FIXED_DEPARTURE_ITEM_ID, // id of this product in EDD
'author' => 'WP Travel Engine', // author of this plugin
'url' => home_url()
);
return $array;
}
add_filter( 'wp_travel_engine_licenses', 'wte_authorize_net_license' );
If I pass multiple arrays like this then I only get the later value in the array like this.
Array ( [version] => 1.0.0 [license] => [item_id] => 79 [author] => WP Travel Engine [url] => http://localhost/wordpress )
There should be two version, two license and other parameters as well when I print the array, right? Or am I missing something?
Any help would be highly appreciable. Thanks!