Skip to content

Commit

Permalink
Make notification dismissable forever + check if bcmath extension is …
Browse files Browse the repository at this point in the history
…installed and show a warning (#47)

* Show warning if bcmath extension is missing.

* Allow users to dismiss review notification forever.

* Sats-Mode avoid fatal error by not allowing user to activate when dependency not met.

* Prepare release 2.6.1.
  • Loading branch information
ndeet authored Apr 4, 2024
1 parent 7c9c521 commit 24d174c
Show file tree
Hide file tree
Showing 7 changed files with 197 additions and 135 deletions.
6 changes: 6 additions & 0 deletions assets/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@
.btcpay-connection-error {
color: red;
}
.btcpay-review-dismiss {
margin-left: 20px;
}
.btcpay-review-dismiss-forever {
margin-left: 10px;
}
28 changes: 20 additions & 8 deletions btcpay-greenfield-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Author URI: https://btcpayserver.org
* Text Domain: btcpay-greenfield-for-woocommerce
* Domain Path: /languages
* Version: 2.6.0
* Version: 2.6.1
* Requires PHP: 8.0
* Tested up to: 6.4
* Requires at least: 5.9
Expand All @@ -26,7 +26,7 @@

defined( 'ABSPATH' ) || exit();

define( 'BTCPAYSERVER_VERSION', '2.6.0' );
define( 'BTCPAYSERVER_VERSION', '2.6.1' );
define( 'BTCPAYSERVER_VERSION_KEY', 'btcpay_gf_version' );
define( 'BTCPAYSERVER_PLUGIN_FILE_PATH', plugin_dir_path( __FILE__ ) );
define( 'BTCPAYSERVER_PLUGIN_URL', plugin_dir_url(__FILE__ ) );
Expand Down Expand Up @@ -183,14 +183,18 @@ public function legacyPluginNotification() {
* Shows a notice on the admin dashboard to periodically ask for a review.
*/
public function submitReviewNotification() {
if (!get_transient('btcpaygf_review_dismissed')) {
if (!get_option('btcpay_gf_review_dismissed_forever') && !get_transient('btcpay_gf_review_dismissed')) {
$reviewMessage = sprintf(
__( 'Thank you for using BTCPay for WooCommerce! If you like the plugin, we would love if you %1$sleave us a review%2$s.', 'btcpay-greenfield-for-woocommerce' ),
__( 'Thank you for using BTCPay for WooCommerce! If you like the plugin, we would love if you %1$sleave us a review%2$s. %3$sRemind me later%4$s %5$sStop reminding me forever!%6$s', 'btcpay-greenfield-for-woocommerce' ),
'<a href="https://wordpress.org/support/plugin/btcpay-greenfield-for-woocommerce/reviews/?filter=5#new-post" target="_blank">',
'</a>'
'</a>',
'<button class="btcpay-review-dismiss">',
'</button>',
'<button class="btcpay-review-dismiss-forever">',
'</button>'
);

Notice::addNotice('info', $reviewMessage, true, 'btcpay-review-notice');
Notice::addNotice('info', $reviewMessage, false, 'btcpay-review-notice');
}
}

Expand Down Expand Up @@ -321,8 +325,16 @@ public function processAjaxModalBlocksCheckout() {
*/
public function processAjaxNotification() {
check_ajax_referer('btcpaygf-notifications-nonce', 'nonce');
// Dismiss review notice for 30 days.
set_transient('btcpaygf_review_dismissed', true, DAY_IN_SECONDS * 30);

$dismissForever = filter_var($_POST['dismiss_forever'], FILTER_VALIDATE_BOOL);

if ($dismissForever) {
update_option('btcpay_gf_review_dismissed_forever', true);
} else {
// Dismiss review notice for 30 days.
set_transient('btcpay_gf_review_dismissed', true, DAY_IN_SECONDS * 30);
}

wp_send_json_success();
}

Expand Down
31 changes: 31 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
= 2.3.1 :: 2023-10-20 =
* Fix: Ensure refunds text does not exceed API field limit.

= 2.3.0 :: 2023-09-06 =
* Support for high performance order storage (HPOS)

Note: This is opt-in but brings performance improvements. Follow instructions [here](https://github.com/woocommerce/woocommerce/wiki/High-Performance-Order-Storage-Upgrade-Recipe-Book#how-to-enable-hpos) if you want to use it.

= 2.2.3 :: 2023-08-22 =
* Automatically create webhook after redirect.

= 2.2.2 :: 2023-08-22 =
* Fix edgecase JS error on payment method selection.

= 2.2.1 :: 2023-08-17 =
* Add tooltip with webhook callback information

= 2.2.0 :: 2023-08-17 =
* Refactor settings UI and allow manual webhook secret entry. This allows 3rd party integrators limit their API keys scope and not include the webhook permission.

= 2.1.0 :: 2023-04-03 =
* New feature: Modal / Overlay checkout mode (no redirect to BTCPay Server)

= 2.0.0 :: 2023-03-20 =
* New feature: Add support for refunds.

Note: If you are upgrading from a version < 2.0 and you want to use refunds (via pull payments) you need to create a new API key with the "Create non-approved pull payments" which is available from BTCPay Server version 1.7.6.
See this link for more information: https://docs.btcpayserver.org/WooCommerce/#create-a-new-api-key

If you do NOT use refunds. You do NOT need to do anything, your existing API key and setup will continue to work as before.

= 1.1.5 :: 2023-03-08 =
* Fix: fix error when plugins override delete_transient function not returning boolean value

Expand Down
Loading

0 comments on commit 24d174c

Please sign in to comment.