Skip to content

Commit

Permalink
Critical bug fix for brewery authentication in Labs (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
ErinMorelli committed Apr 28, 2017
1 parent cc1b764 commit 8d13adc
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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



Expand Down
8 changes: 7 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

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

Expand Down
4 changes: 2 additions & 2 deletions em-beer-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')) {
Expand Down
6 changes: 5 additions & 1 deletion includes/admin/embm-admin-footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
<?php _e('If you like this plugin, please consider donating to support future development. Thank you!', 'embm'); ?>
</p>
<p>
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&amp;business=erin%40erinmorelli%2ecom&amp;lc=US&amp;item_name=EM%20Beer%20Manager&amp;item_number=embm%2dplugin%2dsupport&amp;currency_code=USD&amp;bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted" title="<?php _e('Donate', 'embm'); ?>" target="_blank">
<a
href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&amp;business=98VZ8XS4D4VBY&amp;lc=US&amp;item_name=EM%20Beer%20Manager&amp;item_number=embm%2dplugin%2dsupport&amp;currency_code=USD&amp;bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted&amp;return=http%3A%2F%2Fwww.erinmorelli.com%2Fthanks-paypal%2F"
title="<?php _e('Donate', 'embm'); ?>"
target="_blank"
>
<img src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" alt="<?php _e('Donate', 'embm'); ?>" border="0" />
</a>
</p>
Expand Down
15 changes: 14 additions & 1 deletion includes/admin/embm-admin-untappd.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
5 changes: 4 additions & 1 deletion includes/admin/labs/embm-labs-untappd.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8d13adc

Please sign in to comment.