From 8d13adc91eae30aa17631174878d843aa20b9586 Mon Sep 17 00:00:00 2001 From: Erin Morelli Date: Fri, 28 Apr 2017 17:40:11 -0400 Subject: [PATCH] Critical bug fix for brewery authentication in Labs (#60) --- README.md | 4 ++-- README.txt | 8 +++++++- em-beer-manager.php | 4 ++-- includes/admin/embm-admin-footer.php | 6 +++++- includes/admin/embm-admin-untappd.php | 15 ++++++++++++++- includes/admin/labs/embm-labs-untappd.php | 5 ++++- 6 files changed, 34 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ad32d90..9e27c8e 100644 --- a/README.md +++ b/README.md @@ -37,8 +37,8 @@ This plugin allows beer creators from home brewers to professional breweries to ## Latest Release ## -### [Version 3.0.4 - Critical Bug Fixes](https://github.com/ErinMorelli/em-beer-manager/releases/download/v3.0.4/em-beer-manager.3.0.4.zip) ### -* [FIXED] PHP compatibility issue with Untappd authentication +### [Version 3.0.5 - Critical Bug Fix](https://github.com/ErinMorelli/em-beer-manager/releases/download/v3.0.5/em-beer-manager.3.0.5.zip) ### +* [FIXED] Broken brewery account authentication for Labs diff --git a/README.txt b/README.txt index 31967e7..f24c6ab 100644 --- a/README.txt +++ b/README.txt @@ -4,7 +4,7 @@ Donate link: http://www.erinmorelli.com/projects/em-beer-manager/ Tags: beer, beers, brewery, untappd Requires at least: 3.0.1 Tested up to: 4.7.2 -Stable tag: 3.0.4 +Stable tag: 3.0.5 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -252,6 +252,9 @@ Try refreshing your permalinks by going to "Settings" -> "Permalinks" and clicki == Changelog == += 3.0.5 = +* [FIXED] Broken brewery account authentication for Labs + = 3.0.4 = * [FIXED] PHP compatibility issue with Untappd authentication @@ -388,6 +391,9 @@ Try refreshing your permalinks by going to "Settings" -> "Permalinks" and clicki == Upgrade Notice == += 3.0.5 = +Critical bug fixes related to Untappd brewery authentication + = 3.0.4 = Bug fixes related to Untappd authentication diff --git a/em-beer-manager.php b/em-beer-manager.php index b210ef0..48ee598 100644 --- a/em-beer-manager.php +++ b/em-beer-manager.php @@ -3,7 +3,7 @@ * Plugin Name: EM Beer Manager * Plugin URI: https://www.erinmorelli.com/projects/em-beer-manager * Description: Catalog and display your beers with WordPress. Integrates very simply with Untappd for individual beer check-ins. Great for everyone from home brewers to professional breweries! - * Version: 3.0.4 + * Version: 3.0.5 * Author: Erin Morelli * Author URI: https://www.erinmorelli.com/ * License: GPLv2 or later @@ -48,7 +48,7 @@ function EMBM_Plugin_load() { // Set current version - $embm_curr_version = '3.0.4'; + $embm_curr_version = '3.0.5'; // Define version key name if (!defined('EMBM_VERSION_KEY')) { diff --git a/includes/admin/embm-admin-footer.php b/includes/admin/embm-admin-footer.php index b56e9db..f0b9701 100644 --- a/includes/admin/embm-admin-footer.php +++ b/includes/admin/embm-admin-footer.php @@ -31,7 +31,11 @@

- + <?php _e('Donate', 'embm'); ?>

diff --git a/includes/admin/embm-admin-untappd.php b/includes/admin/embm-admin-untappd.php index 8cf5143..57101bd 100644 --- a/includes/admin/embm-admin-untappd.php +++ b/includes/admin/embm-admin-untappd.php @@ -22,6 +22,7 @@ // Set constants define('EMBM_UNTAPPD_RETURN_URL', 'options-general.php?page=embm-settings&embm-import-%s=%d#%s'); define('EMBM_UNTAPPD_API_URL', 'https://api.untappd.com/v4/%s?access_token='); +define('EMBM_UNTAPPD_RSS_URL', 'https://untappd.com/rss/brewery/'); // Set cache names $GLOBALS['EMBM_UNTAPPD_CACHE'] = array( @@ -321,7 +322,7 @@ function EMBM_Admin_Untappd_Checkins_xml($brewery_id, $refresh = false) // Get checkins info if it's not cached if (false === $xml_data || $refresh || $reload) { // Set Untappd brewery rss URL - $feed_url = 'https://untappd.com/rss/brewery/'.$brewery_id; + $feed_url = EMBM_UNTAPPD_RSS_URL.$brewery_id; // Extract Untappd xml feed data $res = EMBM_Admin_Untappd_request($feed_url, false); @@ -738,3 +739,15 @@ function EMBM_Admin_Untappd_Import_image($post_id, $beer) // Set as thumbnail for beer set_post_thumbnail($post_id, $attach_id); } + +/** + * Format URLs to use HTTPS instead of HTTP + * + * @param str $url The URL to be formatted + * + * @return str Formatted URL + */ +function EMBM_Admin_Untappd_https($url) +{ + return preg_replace('/^http:/i', 'https:', $url); +} \ No newline at end of file diff --git a/includes/admin/labs/embm-labs-untappd.php b/includes/admin/labs/embm-labs-untappd.php index e80bf97..df473ae 100644 --- a/includes/admin/labs/embm-labs-untappd.php +++ b/includes/admin/labs/embm-labs-untappd.php @@ -87,8 +87,11 @@ function EMBM_Admin_Labs_Api_error($res) return; } +// Get HTTPS user URL +$user_url = EMBM_Admin_Untappd_https($user->untappd_url); + // Get Untappd brewery ID -$brewery_id = EMBM_Admin_Untappd_id($user->untappd_url); +$brewery_id = EMBM_Admin_Untappd_id($user_url); if (!$brewery_id) { EMBM_Admin_Labs_Import_error(); return;