Last active
October 4, 2022 21:45
-
-
Save bnecreative/587fd4164618d94ef4cb191e018a56cd to your computer and use it in GitHub Desktop.
BNE Testimonials - Setting a different Facebook API Key
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // Don't copy this line | |
/* | |
* BNE Testimonials API Keys | |
* | |
* This filter allows adjusting an API key used outside of the shortcode | |
* and settings admin page. | |
* | |
* Example usage would be if you were using a mixed API shortcode and needed | |
* to set a different key outside of Settings based on the listing ID or you | |
* needed the key to be dynamic based on a custom field of the page. | |
* | |
* $key string current API key from shortcode or settings page | |
* $source string Current API source | |
* $id string Current API id | |
* | |
* @returns $key | |
* | |
*/ | |
function bne_testimonials_api_custom_keys( $key, $source, $id ) { | |
// Facebook Example | |
if( 'facebook' == $source ) { | |
// Optional: Only apply to this Facebook page ID | |
if( 'enter_facebook_page_id_here' == $id ) { | |
$key = 'enter_new_facebook_key_here'; | |
} | |
// Additional Facebook Page: Only apply to this Facebook page ID | |
if( 'enter_facebook_page_id_here' == $id ) { | |
$key = 'enter_new_facebook_key_here'; | |
} | |
} | |
// Yelp Example | |
if( 'yelp' == $source ) { | |
$key = 'enter_new_yelp_api_key_here'; | |
} | |
// Must return $key | |
return $key; | |
} | |
add_filter( 'bne_testimonials_api_key', 'bne_testimonials_api_custom_keys', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment