From fbf995de9a8f17479dfd9a6bad4e4a3a84beeeaa Mon Sep 17 00:00:00 2001 From: Allen McKenzie Date: Thu, 17 Mar 2022 13:13:01 -0700 Subject: [PATCH] Fixed declared default constants to have unique 4 letter prefixes. --- README.md | 6 ++++- business-matchup.php | 2 +- includes/classes/class-api.php | 44 +++++++++++++++++----------------- readme.txt | 6 ++++- 4 files changed, 33 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index f4ea945..ab4847f 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ **Requires at least:** 5.8 **Tested up to:** 5.9 **Requires PHP:** 7.0 -**Stable tag:** 0.1.0 +**Stable tag:** 0.1.2 **License:** GPLv3 or later **License URI:** https://www.gnu.org/licenses/gpl-3.0.html @@ -68,6 +68,10 @@ Getting a Yelp API Key: Here is the Changelog +### 0.1.2 ### + +Fixed declared default constants to have unique 4 letter prefixes. + ### 0.1.1 ### Fixed declared default constants to have unique prefixes. Instead of API_KEY this plugin uses the prefix BM_ to make this BM_API_KEY diff --git a/business-matchup.php b/business-matchup.php index 4db4def..35dccee 100644 --- a/business-matchup.php +++ b/business-matchup.php @@ -3,7 +3,7 @@ * Plugin Name: Business Matchup * Plugin URI: https://github.com/allen-mckenzie/business-matchup * Description: Create custom polls using Yelp and Straw Polls to let your followers vote for which business they think is the best. - * Version: 0.1.1 + * Version: 0.1.2 * Requires at least: 5.5 * Requires PHP: 7.0 * Author: Allen McKenzie diff --git a/includes/classes/class-api.php b/includes/classes/class-api.php index d93bf46..31de5c1 100644 --- a/includes/classes/class-api.php +++ b/includes/classes/class-api.php @@ -7,25 +7,25 @@ * * @param string $businessMatchupYelpAPI contains the Yelp API Key. * @param string $strawAPI contains the StrawPoll API Key. - * @param string BM_API_KEY contains the Yelp API Key. - * @param string BM_STRAWPOLL_API_KEY contains the StrawPoll API Key. - * @param string BM_API_HOST contains the URL base for the Yelp API. - * @param string BM_SEARCH_PATH specifies the Yelp API Endpoint for searches. - * @param string BM_BUSINESS_PATH specifies the Yelp API Endoint for business data. - * @param string BM_DEFAULT_TERM specifies the term to use when one isn't provided. - * @param string BM_DEFAULT_LOCATION specifies the location to use when one isn't provided. - * @param string BM_SEARCH_LIMIT limits the number of business to search for to only the first 3. + * @param string BIZM_API_KEY contains the Yelp API Key. + * @param string BIZM_STRAWPOLL_API_KEY contains the StrawPoll API Key. + * @param string BIZM_API_HOST contains the URL base for the Yelp API. + * @param string BIZM_SEARCH_PATH specifies the Yelp API Endpoint for searches. + * @param string BIZM_BUSINESS_PATH specifies the Yelp API Endoint for business data. + * @param string BIZM_DEFAULT_TERM specifies the term to use when one isn't provided. + * @param string BIZM_DEFAULT_LOCATION specifies the location to use when one isn't provided. + * @param string BIZM_SEARCH_LIMIT limits the number of business to search for to only the first 3. */ $businessMatchupYelpAPI = get_option( 'business_matchup_yelp_api' ); $strawAPI = get_option( 'business_matchup_straw_poll_api' ); - define( 'BM_API_KEY', $businessMatchupYelpAPI ); - define( 'BM_STRAWPOLL_API_KEY', $strawAPI ); - define( 'BM_API_HOST', 'https://api.yelp.com' ); - define( 'BM_SEARCH_PATH','/v3/businesses/search' ); - define( 'BM_BUSINESS_PATH', '/v3/businesses/' ); - define( 'BM_DEFAULT_TERM', 'dinner' ); - define( 'BM_DEFAULT_LOCATION','San Francisco, CA' ); - define( 'BM_SEARCH_LIMIT', 3 ); + define( 'BIZM_API_KEY', $businessMatchupYelpAPI ); + define( 'BIZM_STRAWPOLL_API_KEY', $strawAPI ); + define( 'BIZM_API_HOST', 'https://api.yelp.com' ); + define( 'BIZM_SEARCH_PATH','/v3/businesses/search' ); + define( 'BIZM_BUSINESS_PATH', '/v3/businesses/' ); + define( 'BIZM_DEFAULT_TERM', 'dinner' ); + define( 'BIZM_DEFAULT_LOCATION','San Francisco, CA' ); + define( 'BIZM_SEARCH_LIMIT', 3 ); /** * Business_Matchup_API class @@ -49,7 +49,7 @@ class Business_Matchup_API { function doAPI( $api_url, $path, $url_params = array() ) { $query = http_build_query( $url_params ); $api_url = $api_url."".$path."?".$query; - $api_key = BM_API_KEY; + $api_key = BIZM_API_KEY; if( $api_key === '' ) { return; } @@ -79,8 +79,8 @@ function search( $term, $businessLocation ) { $url_params = array(); $url_params['term'] = $term; $url_params['location'] = $businessLocation; - $url_params['limit'] = BM_SEARCH_LIMIT; - $result = $this->doAPI(BM_API_HOST, BM_SEARCH_PATH, $url_params); + $url_params['limit'] = BIZM_SEARCH_LIMIT; + $result = $this->doAPI(BIZM_API_HOST, BIZM_SEARCH_PATH, $url_params); return $result; } @@ -94,8 +94,8 @@ function search( $term, $businessLocation ) { * @return array response output from the Business_Matchup_API for the given call. */ function get_business( $business_id ) { - $business_path = BM_BUSINESS_PATH . urlencode($business_id); - return $this->doAPI(BM_API_HOST, $business_path); + $business_path = BIZM_BUSINESS_PATH . urlencode($business_id); + return $this->doAPI(BIZM_API_HOST, $business_path); } /** @@ -129,7 +129,7 @@ public function createPoll( $poll_json ) { $headers = array( 'user-agent' => '', 'Content-Type' => 'application/json', - 'X-API-KEY' => BM_STRAWPOLL_API_KEY + 'X-API-KEY' => BIZM_STRAWPOLL_API_KEY ); $args = array( 'method' => 'POST', diff --git a/readme.txt b/readme.txt index f387bd2..adb98c0 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Tags: Yelp, Polls, Community Engagement Requires at least: 5.8 Tested up to: 5.9 Requires PHP: 7.0 -Stable tag: 0.1.0 +Stable tag: 0.1.2 License: GPLv3 or later License URI: https://www.gnu.org/licenses/gpl-3.0.html @@ -73,6 +73,10 @@ This is an upgrade notice Here is the Changelog +=== 0.1.2 === + +Fixed declared default constants to have unique 4 letter prefixes. + === 0.1.1 === Fixed declared default constants to have unique prefixes. Instead of API_KEY this plugin uses the prefix BM_ to make this BM_API_KEY