Skip to content

Commit

Permalink
configured for wp.org
Browse files Browse the repository at this point in the history
  • Loading branch information
BeycanDeveloper committed Apr 27, 2024
1 parent 89ce82c commit e2b9265
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
13 changes: 10 additions & 3 deletions classes/DokanCryptoPayWithdrawal.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function __construct(string $title, string $key)
add_filter('dokan_withdraw_method_additional_info', [$this, 'addWithdrawMethodAdditionalInfo'], 10, 2);

// Actions
// This a WordPress page detection
if (isset($_GET['page']) && 'dokan' == $_GET['page']) {
add_action('admin_print_footer_scripts', [$this, 'withdrawDetails'], 99);
}
Expand Down Expand Up @@ -251,7 +252,7 @@ public function saveSettings(array $dokanSettings, string $storeId): array
$dokanSettings['payment'][$this->key] = array_map('sanitize_text_field', $postData['settings'][$this->key]);
$network = json_decode($dokanSettings['payment'][$this->key]['network']);
$network->currencies = [json_decode($dokanSettings['payment'][$this->key]['currency'])];
$dokanSettings['payment'][$this->key]['network'] = json_encode($network);
$dokanSettings['payment'][$this->key]['network'] = wp_json_encode($network);
$dokanSettings['payment'][$this->key]['user_id'] = dokan_get_current_user_id();
}
}
Expand Down Expand Up @@ -371,8 +372,14 @@ function getCustomPaymentDetails(details, method, data) {
anotherDetails = '';
}
details = status == 'pending' ? anotherDetails + `
<button title="<?php echo esc_attr(sprintf(__('Pay with %s', 'dokan-cryptopay'), $this->title)) ?>" class="button button-small pay-with-cryptopay" data-key="<?php echo esc_attr($this->key); ?>" data-details='${JSON.stringify(data[method])}'>
<?php echo esc_html(sprintf(__('Pay with %s', 'dokan-cryptopay'), $this->title)) ?>
<button title="<?php
/* translators: %s: payment method title */
echo esc_attr(sprintf(__('Pay with %s', 'dokan-cryptopay'), $this->title))
?>" class="button button-small pay-with-cryptopay" data-key="<?php echo esc_attr($this->key); ?>" data-details='${JSON.stringify(data[method])}'>
<?php
// translators: %s: payment method title
echo esc_html(sprintf(__('Pay with %s', 'dokan-cryptopay'), $this->title))
?>
</button>
` : anotherDetails;
}
Expand Down
7 changes: 5 additions & 2 deletions cryptopay-withdrawal-for-dokan.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@
if (!function_exists('dokan')) {
add_action('admin_notices', function (): void {
$class = 'notice notice-error';
// translators: %s: Dokan plugin URL
$message = sprintf(esc_html__('CryptoPay Withdrawal for Dokan: This plugin is an extra feature plugin so it cannot do anything on its own. It needs Dokan to work. You can buy download Dokan by %s.', 'dokan-cryptopay'), '<a href="https://wordpress.org/plugins/dokan-lite/" target="_blank">' . esc_html__('clicking here', 'dokan-cryptopay') . '</a>');
printf('<div class="%1$s"><p>%2$s</p></div>', esc_attr($class), $message);
printf('<div class="%1$s"><p>%2$s</p></div>', esc_attr($class), wp_kses_post($message));
});
return;
}
Expand All @@ -61,6 +62,7 @@
$gateway = new DokanCryptoPayWithdrawal(esc_html__('CryptoPay Lite', 'dokan-cryptopay'), 'dokan_cryptopay_lite');
}

// This a WordPress page detection
if (isset($_GET['page']) && 'dokan' === $_GET['page']) {
add_action('admin_enqueue_scripts', function (): void {
wp_enqueue_script('dokan-cryptopay', plugin_dir_url(__FILE__) . 'assets/js/main.js', ['jquery', 'wp-i18n'], DOKAN_CRYPTOPAY_VERSION, true);
Expand Down Expand Up @@ -97,8 +99,9 @@
} else {
add_action('admin_notices', function (): void {
$class = 'notice notice-error';
// translators: %s: CryptoPay plugin URL
$message = sprintf(esc_html__('CryptoPay Withdrawal for Dokan: 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.', 'dokan-cryptopay'), '<a href="https://beycanpress.com/product/cryptopay-all-in-one-cryptocurrency-payments-for-wordpress/?utm_source=wp_org_addons&utm_medium=dokan" target="_blank">' . esc_html__('clicking here', 'dokan-cryptopay') . '</a>');
printf('<div class="%1$s"><p>%2$s</p></div>', esc_attr($class), $message);
printf('<div class="%1$s"><p>%2$s</p></div>', esc_attr($class), wp_kses_post($message));
});
}
});
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
=== Cryptocurrency Payment Withdrawal Method for Dokan by CryptoPay ===
Contributors: BeycanPress
Tags: Bitcoin, Ethereum, Binance Smart Chain, Blockchain, Networks, Cryptocurrency, Payments, Gateway, WordPress, Dokan
Tags: Bitcoin, Ethereum, Cryptocurrency, Payments, Dokan
Requires at least: 5.0
Tested up to: 6.5.0
Requires PHP: 8.1
Expand Down

0 comments on commit e2b9265

Please sign in to comment.