Skip to content

Commit

Permalink
add hook for pro and lite dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
BeycanDeveloper committed Apr 4, 2024
1 parent a812885 commit 21baa5e
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions cryptocurrency-payments-for-paid-memberships-pro.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/**
* Plugin Name: CryptoPay Gateway for Paid Memberships Pro
* Requires Plugins: paid-memberships-pro
* Requires Plugins: paid-memberships-pro, cryptopay-wc-lite
* Version: 1.0.6
* Plugin URI: https://beycanpress.com/cryptopay/
* Description: Adds CryptoPay as a gateway option for Paid Memberships Pro.
Expand All @@ -24,7 +24,7 @@
* Requires at least: 5.0
* Tested up to: 6.5.0
* Requires PHP: 8.1
*/
*/

require_once __DIR__ . '/vendor/autoload.php';

Expand All @@ -37,6 +37,13 @@
define('PMPRO_CRYPTOPAY_VERSION', '1.0.6');
define('PMPRO_CRYPTOPAY_URL', plugin_dir_url(__FILE__));

add_filter('wp_plugin_dependencies_slug', function ($slug) {
if ('cryptopay-wc-lite' === $slug && class_exists(Loader::class)) {
$slug = 'cryptopay';
}
return $slug;
});

register_activation_hook(PMPRO_CRYPTOPAY_FILE, function (): void {
if (class_exists(Loader::class)) {
require_once __DIR__ . '/classes/pro/class.pmpro_transaction_model.php';
Expand Down Expand Up @@ -100,6 +107,7 @@ function pmpro_cryptopay_check_discount_code(object &$level, ?string $discountCo
pmpro_cryptopay_addModels();

add_action('plugins_loaded', function (): void {

pmpro_cryptopay_addModels();

load_plugin_textdomain('pmpro-cryptopay', false, basename(__DIR__) . '/languages');
Expand Down Expand Up @@ -140,7 +148,7 @@ function justShowForCryptoPay() {
parent.next().hide();
parent.next().next().hide();
}

if (jQuery('#gateway').val() == 'cryptopay' || jQuery('#gateway').val() == 'cryptopay_lite') {
justShowForCryptoPay();
}
Expand All @@ -164,9 +172,9 @@ function justShowForCryptoPay() {
} else {
add_action('admin_notices', function (): void {
?>
<div class="notice notice-error">
<p><?php echo sprintf(esc_html__('CryptoPay Gateway for Paid Memberships Pro: This plugin is an extra feature plugin so it cannot do anything on its own. It needs CryptoPay to work. You can buy CryptoPay by %s.', 'pmpro-cryptopay'), '<a href="https://beycanpress.com/cryptopay/?utm_source=wp_org_plugins&utm_medium=pmpro" target="_blank">' . esc_html__('clicking here', 'pmpro-cryptopay') . '</a>'); ?></p>
</div>
<div class="notice notice-error">
<p><?php echo sprintf(esc_html__('CryptoPay Gateway for Paid Memberships Pro: This plugin is an extra feature plugin so it cannot do anything on its own. It needs CryptoPay to work. You can buy CryptoPay by %s.', 'pmpro-cryptopay'), '<a href="https://beycanpress.com/cryptopay/?utm_source=wp_org_plugins&utm_medium=pmpro" target="_blank">' . esc_html__('clicking here', 'pmpro-cryptopay') . '</a>'); ?></p>
</div>
<?php
});
}
Expand Down

0 comments on commit 21baa5e

Please sign in to comment.