Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bnecreative/587fd4164618d94ef4cb191e018a56cd to your computer and use it in GitHub Desktop.
Save bnecreative/587fd4164618d94ef4cb191e018a56cd to your computer and use it in GitHub Desktop.
BNE Testimonials - Setting a different Facebook API Key
<?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