Skip to content

Commit

Permalink
Fix Auto Updater to only Upgrade Facebook-for-WooCommerce
Browse files Browse the repository at this point in the history
Summary: Since facebook-for-wordpress and facebook-for-woocommerce exist in the same repository, auto-upgrader will install facebook-for-wordpress when it upgrade facebook-for-woocommerce.

Reviewed By: dmitridr

Differential Revision: D6708834

fbshipit-source-id: 82bf7da
  • Loading branch information
mengyingdu authored and facebook-github-bot committed Jan 12, 2018
1 parent ab380ec commit 7fd1459
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
*** Facebook for WooCommerce Changelog ***

2018-01-11 version 1.7.5
* Fix auto-updater to upgrade facebook-for-woocommerce only.

2018-01-05 version 1.7.4
* Fix purchase event not firing for some payment types.
* Provide functionality to refresh API token when invalid.
Expand Down
2 changes: 1 addition & 1 deletion facebook-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Description: Grow your business on Facebook! Use this official plugin to help sell more of your products using Facebook. After completing the setup, you'll be ready to create ads that promote your products and you can also create a shop section on your Page where customers can browse your products on Facebook.
* Author: Facebook
* Author URI: https://www.facebook.com/
* Version: 1.7.4
* Version: 1.7.5
* Woo: 2127297:0ea4fe4c2d7ca6338f8a322fb3e4e187
* Text Domain: facebook-for-woocommerce
*/
Expand Down
30 changes: 27 additions & 3 deletions includes/fb-github-plugin-updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,13 @@ public function setTransient($transient) {
$shouldUpdate = version_compare(
substr($this->githubAPIResult->tag_name, 1),
$transient->checked[$this->slug]);

// Only process download url if shouldUpdate
if ($shouldUpdate == 1) {
$package = $this->githubAPIResult->zipball_url;
$package = $this->get_asset_download_url($this->githubAPIResult->assets);
if (!$package) {
return $transient;
}
$obj = new stdClass();
$obj->slug = $this->slug;
$obj->new_version = $this->githubAPIResult->tag_name;
Expand Down Expand Up @@ -132,7 +137,8 @@ public function setPluginInfo($false, $action, $response) {
$response->homepage = $this->pluginData["PluginURI"];

// This is our release download zip file
$downloadLink = $this->githubAPIResult->zipball_url;
$downloadLink =
$this->get_asset_download_url($this->githubAPIResult->assets);
$response->download_link = $downloadLink;
// Create tabs in the lightbox
$response->sections = array(
Expand Down Expand Up @@ -172,8 +178,26 @@ private static function getAPIResultBody($text) {
$text = trim($text, "\n");
$lines = explode("\n", $text);
$lines = array_filter($lines, 'strlen');
return implode("<br>", $lines);
$woo_changelog = array_filter($lines, function($line) {
return !is_numeric(strpos($line, 'WordPress'));
});
$woo_changelog = implode("<br>", $woo_changelog);
return $woo_changelog;
}

public function get_asset_download_url($assets) {
$assets = json_decode(json_encode($assets), true);
array_filter($assets, function($asset) {
return strpos($asset["browser_download_url"],
"facebook-for-woocommerce-v") !== false;
});
if (!empty($assets)) {
$valid_asset = reset($assets);
return $valid_asset["browser_download_url"];
}
return false;
}

}

endif;
2 changes: 1 addition & 1 deletion includes/fbutils.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class WC_Facebookcommerce_Utils {

const FB_RETAILER_ID_PREFIX = 'wc_post_id_';
const PLUGIN_VERSION = '1.7.4'; // Change it in `facebook-for-*.php` also
const PLUGIN_VERSION = '1.7.5'; // Change it in `facebook-for-*.php` also
public static $ems = null;
public static $fbgraph = null;
/**
Expand Down

0 comments on commit 7fd1459

Please sign in to comment.