Skip to content

Commit

Permalink
Fixed declared default constants to have unique 4 letter prefixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
allen-mckenzie committed Mar 17, 2022
1 parent 5738e7b commit fbf995d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 25 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion business-matchup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 22 additions & 22 deletions includes/classes/class-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}

Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -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',
Expand Down
6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fbf995d

Please sign in to comment.