Skip to content

Commit

Permalink
Update plugin: gravityperks.
Browse files Browse the repository at this point in the history
Old Version: 2.3.8
New Version: 2.3.14

See #3474.
  • Loading branch information
boonebgorges committed Dec 26, 2024
1 parent 014d738 commit f90d3f6
Show file tree
Hide file tree
Showing 23 changed files with 144 additions and 221 deletions.
2 changes: 1 addition & 1 deletion wp-content/plugins/gravityperks/admin/manage_perks.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ class="documentation">' . __( 'Docs', 'gravityperks' ) . '</a>';
$actions['deactivate'] = '<a href="' . $perk->get_link_for( 'deactivate' ) . '" class="deactivate">' . __( 'Deactivate', 'gravityperks' ) . '</a>';
}

if ( $perk->has_method( 'settings', '' ) ) {
if ( $perk->method_is_overridden( 'settings' ) ) {
$actions['settings'] = sprintf( '<a class="thickbox settings" title="Gravity Perks Settings" href="%s">%s</a>', $perk->get_link_for( 'settings' ), __( 'Settings', 'gravityperks' ) );
}
} else {
Expand Down
24 changes: 24 additions & 0 deletions wp-content/plugins/gravityperks/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@

# Changelog

## 2.3.14 | December 10, 2024

- Added support for displaying perk icons/banners in updates list.

## 2.3.13 | November 27, 2024

- Updated requirement checking logic to be simpler and to not load translations too early.

## 2.3.12 | September 19, 2024

- Improved support for non-generic perk objects.

## 2.3.11 | September 11, 2024

- Added automated upgrade path from GP Google Sheets to GC Google Sheets.

## 2.3.10 | September 5, 2024

- Fixed issue where GC Google Sheets was getting detected as a perk due to its backwards compatibility class which could then cause errors in Gravity Perks.

## 2.3.9 | August 14, 2024

- Fixed issue where notices in perk global settings were misaligned.

## 2.3.8 | June 26, 2024

- Fixed issue where the plugin updater API response for perks included the changelog property, which could prevent plugin updates from showing up in some situations.
Expand Down
6 changes: 3 additions & 3 deletions wp-content/plugins/gravityperks/gravityperks.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Gravity Perks
* Plugin URI: https://gravitywiz.com/
* Description: Effortlessly install and manage small functionality enhancements (aka "perks") for Gravity Forms.
* Version: 2.3.8
* Version: 2.3.14
* Author: Gravity Wiz
* Author URI: https://gravitywiz.com/
* License: GPL2
Expand All @@ -12,7 +12,7 @@
* Update URI: https://gravitywiz.com/updates/gravityperks
*/

define( 'GRAVITY_PERKS_VERSION', '2.3.8' );
define( 'GRAVITY_PERKS_VERSION', '2.3.14' );

/**
* Include the perk model as early as possible to when Perk plugins are loaded, they can safely extend
Expand Down Expand Up @@ -215,7 +215,7 @@ public static function define_constants() {
define( 'GW_URL', GW_PROTOCOL . '://' . GW_DOMAIN );

if ( ! defined( 'GWAPI_URL' ) ) {
define( 'GWAPI_URL', GW_URL . '/gwapi/v3/' ); // @used storefront_api.php
define( 'GWAPI_URL', GW_URL . '/gwapi/v4/' ); // @used storefront_api.php
}

define( 'GW_UPGRADE_URL', GW_URL . '/upgrade/' );
Expand Down
75 changes: 75 additions & 0 deletions wp-content/plugins/gravityperks/includes/class-gwapi.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class GWAPI {
private $license_key;
private $product;
private $author;
private $gcgs_upgrade_successful = false;
private $should_activate_gcgs = false;

private $_product_update_data = array(
'loaded' => false,
Expand Down Expand Up @@ -164,9 +166,58 @@ private function hook() {
add_filter( 'plugins_api', array( $this, 'products_plugins_api_filter' ), 100, 3 );
add_filter( 'http_request_host_is_external', array( $this, 'allow_gwiz_external_redirects' ), 15, 3 );
add_filter( 'upgrader_package_options', array( $this, 'upgrader_package_options_filter' ) );
add_filter( 'upgrader_post_install', array( $this, 'gpgs_to_gcgs_upgrader_post_install' ), 10, 3 );
add_action( 'upgrader_process_complete', array( $this, 'gpgs_to_gcgs_upgrader_process_complete' ), 10, 2 );

}

public function gpgs_to_gcgs_upgrader_post_install( $response, $hook_extra, $result ) {
if ( rgar( $hook_extra, 'plugin' ) !== 'gp-google-sheets/gp-google-sheets.php' ) {
return $response;
}

if ( is_plugin_active( 'gp-google-sheets/gp-google-sheets.php' ) ) {
// Unhook Action Scheduler during this request to prevent errors.
if ( class_exists( 'ActionScheduler_QueueRunner' ) ) {
remove_action( 'shutdown', array( ActionScheduler_QueueRunner::instance(), 'maybe_dispatch_async_request' ) );
}

deactivate_plugins( 'gp-google-sheets/gp-google-sheets.php' );

/*
* I don't know the technical reasoning behind this, but if we try activating GCGS here, it doesn't
* end up getting activated. To work around this, we set a property and do it later during
* upgrader_process_complete.
*/
$this->should_activate_gcgs = true;
}

$this->gcgs_upgrade_successful = true;

return $response;
}

public function gpgs_to_gcgs_upgrader_process_complete( $upgrader, $hook_extra ) {
if ( rgar( $hook_extra, 'action' ) !== 'update' || rgar( $hook_extra, 'type' ) !== 'plugin' ) {
return;
}

if ( ! is_array( rgar( $hook_extra, 'plugins' ) ) || ! in_array( 'gp-google-sheets/gp-google-sheets.php', $hook_extra['plugins'], true ) ) {
return;
}

if ( ! $this->gcgs_upgrade_successful ) {
return;
}

$upgrader->skin->feedback( __( '<strong>Important Note!</strong> GP Google Sheets has been converted to GC Google Sheets', 'gravityperks' ) );

if ( $this->should_activate_gcgs ) {
activate_plugin( 'gc-google-sheets/gc-google-sheets.php' );
$upgrader->skin->feedback( __( 'GC Google Sheets has been activated.', 'gravityperks' ) );
}
}

public function upgrader_package_options_filter( $options ) {

if ( ! isset( $options['package'] ) || ! is_string( $options['package'] ) ) {
Expand Down Expand Up @@ -258,6 +309,30 @@ public function process_get_products( $response ) {

$perk->download_link = $perk->package;

// If GC Google Sheets is not installed, convert GCGS to be GPGS to provide an upgrade path.
if ( $plugin_file === 'gc-google-sheets/gc-google-sheets.php' && ! class_exists( 'GC_Google_Sheets' ) ) {
$plugin_file = 'gp-google-sheets/gp-google-sheets.php';
$perk->slug = 'gp-google-sheets';
$perk->plugin = 'gp-google-sheets';
$perk->plugin_file = 'gp-google-sheets/gp-google-sheets.php';
}

if ( isset( $perk->icons ) ) {
$icons = maybe_unserialize( $perk->icons );

if ( is_array( $icons ) && ! empty( $icons ) ) {
$perk->icons = $icons;
}
}

if ( isset( $perk->banners ) ) {
$banners = maybe_unserialize( $perk->banners );

if ( is_array( $banners ) && ! empty( $banners ) ) {
$perk->banners = $banners;
}
}

$perks[ $plugin_file ] = $perk;

}
Expand Down
33 changes: 15 additions & 18 deletions wp-content/plugins/gravityperks/languages/gravityperks.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# This file is distributed under the GPL2.
msgid ""
msgstr ""
"Project-Id-Version: Gravity Perks 2.3.8\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/cloned-perk-UQYEIKyG-\n"
"Project-Id-Version: Gravity Perks 2.3.14\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/cloned-perk-CG4kBhQP3j\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2024-06-27T15:25:54+00:00\n"
"POT-Creation-Date: 2024-12-10T02:52:14+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.10.0\n"
"X-Domain: gravityperks\n"
Expand Down Expand Up @@ -342,34 +342,31 @@ msgstr ""
msgid "Does this page look strange? Your PHP version is out-of-date. <strong>Please upgrade.</strong>"
msgstr ""

#: model/perk.php:95
msgid "The file for this perk does not exist."
#: includes/class-gwapi.php:213
msgid "<strong>Important Note!</strong> GP Google Sheets has been converted to GC Google Sheets"
msgstr ""

#: model/perk.php:120
msgid "There is no class for this perk."
#: includes/class-gwapi.php:217
msgid "GC Google Sheets has been activated."
msgstr ""

#. translators: placeholder is required WordPress plugin name
#: model/perk.php:342
msgid "Required WordPress plugin is missing: %s."
#: model/perk.php:95
msgid "The file for this perk does not exist."
msgstr ""

#. translators: placeholder is required WordPress plugin name, second placeholder is required version
#: model/perk.php:348
msgid "Required WordPress plugin is missing: %1$s (%2$s)."
#: model/perk.php:120
msgid "There is no class for this perk."
msgstr ""

#. translators: placeholders are plugin name, current plugin version, plugin name, and required version respectively
#: model/perk.php:356
msgid "Current %1$s version (%2$s) does not meet minimum %1$s version requirement (%3$s)."
#: model/perk.php:136
msgid "%s is not a perk."
msgstr ""

#. translators: placeholder is perk name
#: model/perk.php:418
#: model/perk.php:371
msgid "Uh-oh! <strong>%s</strong> needs your attention."
msgstr ""

#: model/perk.php:799
#: model/perk.php:748
msgid "There was an issue deleting this perk. The perk directory was not available."
msgstr ""
43 changes: 0 additions & 43 deletions wp-content/plugins/gravityperks/model/class-gp-feed-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ public function pre_init() {

parent::pre_init();

// Since pre_init() is called from the __construct() and checking for add-on-specific requirements will call the
// constructor again, we can't check for requirements in pre_init(). Recursion is coming for us all.
if ( ! has_filter( 'init', array( $this, 'disable_init_when_requirements_unmet' ) ) ) {
add_action( 'init', array( $this, 'disable_init_when_requirements_unmet' ), 1 );
}

/**
* Exporting happens prior to init, hence the need to add these hooks during pre_init.
*
Expand All @@ -56,16 +50,6 @@ public function pre_init() {

}

/**
* Prevent plugin from initializing if requirements are not met.
*/
public function disable_init_when_requirements_unmet() {
if ( ! $this->check_requirements() ) {
$priority = GravityPerks::is_gf_version_gte( '2.5-beta-2' ) ? 15 : 10;
remove_action( 'init', array( $this, 'init' ), $priority );
}
}

public function init() {

parent::init();
Expand All @@ -80,33 +64,6 @@ public function init() {

}

public function check_requirements() {

$requirements = $this->minimum_requirements();
$min_gf_version = rgars( $requirements, 'gravityforms/version' );

if ( $min_gf_version ) {
$this->_min_gravityforms_version = $min_gf_version;
}

return $this->perk->check_requirements();

}

public function meets_minimum_requirements() {

$callable = version_compare( PHP_VERSION, '8.0', '>=' ) ? parent::class . '::meets_minimum_requirements' : 'parent::meets_minimum_requirements';

$min = is_callable( $callable ) ? parent::meets_minimum_requirements() : array();

return array_merge_recursive( $min, $this->perk->check_gf_requirements_plugins_array() );

}

public function minimum_requirements() {
return array();
}

public function log( $message, $is_error = false ) {
if ( $is_error ) {
$this->log_error( $message );
Expand Down
78 changes: 1 addition & 77 deletions wp-content/plugins/gravityperks/model/class-gp-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,67 +23,14 @@ public static function get_instance() {

public static function includes() { }

/**
* @var array Array to track Perks that are initializing. This is a key piece in preventing recursion caused by
* GFAddOn::meets_minimum_requirements() when Add-ons are required by Perks. Without this, get_instance() will
* recurse as we call GP_Plugin::check_requirements() in __construct().
*
* @see GFAddOn::meets_minimum_requirements()
* @see GP_Plugin::check_requirements()
* @see GP_Plugin::__construct
*/
static $initializing_perks = array();

public function __construct( $perk = null ) {

if ( ! $this->perk ) {
$this->perk = $perk ? $perk : new GP_Perk( $this->_path, $this );
}

if ( isset( self::$initializing_perks[ $this->_slug ] ) ) {
return $this;
}

/* Set flag to prevent potential recursion from GP_Plugin::check_requirements(). */
self::$initializing_perks[ $this->_slug ] = true;

/**
* While GP_Plugin::check_requirements() runs a risk of recursion, we check it here so we can prevent pre_init()
* from running on Perks that have not met all requirements.
*/
if ( $this->check_requirements() ) {
parent::__construct();
} else {
if ( ! has_filter( 'init', array( $this, 'disable_init' ) ) ) {
add_action( 'init', array( $this, 'disable_init' ), 1 );
}

/**
* GFAddOn::failed_requirements_init() is called in GFAddOn::init_admin() which is bypassed thanks to our
* requirements checker.
*
* That said, it's still useful to call failed_requirements_init() when running GF 2.5 or higher as
* regular WP notifications are suppressed on Gravity Forms pages.
*
* @see GFAddOn::init_admin()
* @see GFAddOn::failed_requirements_init()
*/
if (
method_exists( $this, 'failed_requirements_init' )
&& version_compare( GFForms::$version, '2.5-beta-1', '>=' )
) {
$this->failed_requirements_init();
}
}

}
parent::__construct();

/**
* Prevent plugin from initializing. Use in tandem with GP_Plugin::check_requirements().
*/
public function disable_init() {
remove_action( 'init', array( $this, 'init' ), 10 ); /* GF <=2.4 */
remove_action( 'init', array( $this, 'init' ), 15 );
}

public function init() {
Expand All @@ -101,30 +48,7 @@ public function init() {
}

public function check_requirements() {

$requirements = $this->minimum_requirements();
$min_gf_version = rgars( $requirements, 'gravityforms/version' );

if ( $min_gf_version ) {
$this->_min_gravityforms_version = $min_gf_version;
}

return $this->perk->check_requirements();

}

public function meets_minimum_requirements() {

$callable = version_compare( PHP_VERSION, '8.0', '>=' ) ? parent::class . '::meets_minimum_requirements' : 'parent::meets_minimum_requirements';

$min = is_callable( $callable ) ? parent::meets_minimum_requirements() : array();

return array_merge_recursive( $min, $this->perk->check_gf_requirements_plugins_array() );

}

public function minimum_requirements() {
return array();
}

public function log( $message, $is_error = false ) {
Expand Down
Loading

0 comments on commit f90d3f6

Please sign in to comment.