Skip to content

Commit

Permalink
Test for WooCommerce Subscriptions in upgrade instead of extension.
Browse files Browse the repository at this point in the history
  • Loading branch information
rvdsteege committed Sep 19, 2022
1 parent ac0b8e0 commit 4a4a689
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
19 changes: 0 additions & 19 deletions src/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,6 @@ public function setup() {

add_action( 'admin_init', [ __CLASS__, 'admin_init' ], 15 );

/**
* On admin initialize we mark the upgrades as executable. This needs to run before
* the `wp-pay/core` admin init install routine (priority 5).
*
* @link https://github.com/wp-pay/core/blob/2.2.0/src/Admin/Install.php#L65
*/
add_action( 'admin_init', [ $this, 'admin_init_upgrades_executable' ], 4 );

add_filter( 'woocommerce_payment_gateways', [ __CLASS__, 'payment_gateways' ] );

add_filter( 'woocommerce_thankyou_order_received_text', [ __CLASS__, 'woocommerce_thankyou_order_received_text' ], 20, 2 );
Expand Down Expand Up @@ -130,17 +122,6 @@ public static function init() {
self::register_settings();
}

/**
* Upgrades are only executable when no Restrict Content Pro upgrade is needed.
*
* @return void
*/
public function admin_init_upgrades_executable() {
$executable = function_exists( '\wcs_get_subscription' );

$this->get_upgrades()->set_executable( $executable );
}

/**
* Add the gateways to WooCommerce.
*
Expand Down
5 changes: 5 additions & 0 deletions src/Upgrade420.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ class Upgrade420 extends Upgrade {
public function __construct() {
parent::__construct( '4.2.0' );

// Check for WooCommerce Subscriptions.
if ( ! function_exists( '\wcs_get_subscription' ) ) {
return;
}

if ( \defined( '\WP_CLI' ) && \WP_CLI ) {
$this->cli_init();
}
Expand Down

0 comments on commit 4a4a689

Please sign in to comment.