Skip to content

Commit

Permalink
Fix disabling notification button (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndeet authored Apr 8, 2024
1 parent 24d174c commit ba09957
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 34 deletions.
15 changes: 9 additions & 6 deletions btcpay-greenfield-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
* Author URI: https://btcpayserver.org
* Text Domain: btcpay-greenfield-for-woocommerce
* Domain Path: /languages
* Version: 2.6.1
* Version: 2.6.2
* Requires PHP: 8.0
* Tested up to: 6.4
* Tested up to: 6.5
* Requires at least: 5.9
* WC requires at least: 6.0
* WC tested up to: 8.6
* WC tested up to: 8.7
*/

use BTCPayServer\WC\Admin\Notice;
Expand All @@ -26,7 +26,7 @@

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

define( 'BTCPAYSERVER_VERSION', '2.6.1' );
define( 'BTCPAYSERVER_VERSION', '2.6.2' );
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 @@ -99,7 +99,8 @@ public function includes(): void {
* Add scripts to admin pages.
*/
public function enqueueAdminScripts(): void {
wp_enqueue_script('btcpaygf-notifications', plugin_dir_url(__FILE__) . 'assets/js/backend/notifications.js', ['jquery'], null, true);
wp_register_script('btcpaygf-notifications', plugin_dir_url(__FILE__) . 'assets/js/backend/notifications.js', ['jquery'], BTCPAYSERVER_VERSION);
wp_enqueue_script('btcpaygf-notifications');
wp_localize_script('btcpaygf-notifications', 'BTCPayNotifications', [
'ajax_url' => admin_url('admin-ajax.php'),
'nonce' => wp_create_nonce('btcpaygf-notifications-nonce')
Expand Down Expand Up @@ -324,7 +325,9 @@ public function processAjaxModalBlocksCheckout() {
* Handles the AJAX callback to dismiss review notification.
*/
public function processAjaxNotification() {
check_ajax_referer('btcpaygf-notifications-nonce', 'nonce');
if ( ! check_ajax_referer( 'btcpaygf-notifications-nonce', 'nonce' ) ) {
wp_die( 'Unauthorized!', '', [ 'response' => 401 ] );
}

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

Expand Down
36 changes: 18 additions & 18 deletions languages/btcpay-greenfield-for-woocommerce.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# This file is distributed under the same license as the BTCPay For Woocommerce V2 plugin.
msgid ""
msgstr ""
"Project-Id-Version: BTCPay For Woocommerce V2 2.6.0\n"
"Project-Id-Version: BTCPay For Woocommerce V2 2.6.2\n"
"Report-Msgid-Bugs-To: https://woocommerce.com/my-account/create-a-ticket/\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-04-04T15:31:42+00:00\n"
"POT-Creation-Date: 2024-04-08T22:04:43+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.9.0\n"
"language-team: LANGUAGE <EMAIL@ADDRESS>\n"
Expand All @@ -35,69 +35,69 @@ msgstr ""
msgid "https://btcpayserver.org"
msgstr ""

#: btcpay-greenfield-for-woocommerce.php:137
#: btcpay-greenfield-for-woocommerce.php:138
msgid "Plugin not configured yet, please %1$sconfigure the plugin here%2$s"
msgstr ""

#: btcpay-greenfield-for-woocommerce.php:155
#: btcpay-greenfield-for-woocommerce.php:156
msgid "Your PHP version is %s but BTCPay Greenfield Payment plugin requires version 8.0+."
msgstr ""

#: btcpay-greenfield-for-woocommerce.php:161
#: btcpay-greenfield-for-woocommerce.php:162
msgid "WooCommerce seems to be not installed. Make sure you do before you activate BTCPayServer Payment Gateway."
msgstr ""

#: btcpay-greenfield-for-woocommerce.php:167
#: btcpay-greenfield-for-woocommerce.php:168
msgid "The PHP cURL extension is not installed. Make sure it is available otherwise this plugin will not work."
msgstr ""

#: btcpay-greenfield-for-woocommerce.php:177
#: btcpay-greenfield-for-woocommerce.php:178
msgid "Seems you have the old BTCPay for WooCommerce plugin installed. While it should work it is strongly recommended to not run both versions but rely on the maintained version (BTCPay Greenfield for WooCommerce)."
msgstr ""

#: btcpay-greenfield-for-woocommerce.php:188
#: btcpay-greenfield-for-woocommerce.php:189
msgid "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"
msgstr ""

#: btcpay-greenfield-for-woocommerce.php:443
#: btcpay-greenfield-for-woocommerce.php:446
msgid "Settings"
msgstr ""

#: btcpay-greenfield-for-woocommerce.php:445
#: btcpay-greenfield-for-woocommerce.php:448
msgid "Debug log"
msgstr ""

#: btcpay-greenfield-for-woocommerce.php:447
#: btcpay-greenfield-for-woocommerce.php:450
msgid "Docs"
msgstr ""

#: btcpay-greenfield-for-woocommerce.php:449
#: btcpay-greenfield-for-woocommerce.php:452
msgid "Support Chat"
msgstr ""

#: btcpay-greenfield-for-woocommerce.php:489
#: btcpay-greenfield-for-woocommerce.php:492
msgid "Error on verifiying redirected API wey with stored BTCPay Server url. Aborting API wizard. Please try again or do a manual setup."
msgstr ""

#: btcpay-greenfield-for-woocommerce.php:511
#: btcpay-greenfield-for-woocommerce.php:514
msgid "Successfully received api key and store id from BTCPay Server API. Please finish setup by saving this settings form."
msgstr ""

#: btcpay-greenfield-for-woocommerce.php:515
#: btcpay-greenfield-for-woocommerce.php:518
#: src/Admin/GlobalSettings.php:374
msgid "Successfully registered a new webhook on BTCPay Server."
msgstr ""

#: btcpay-greenfield-for-woocommerce.php:519
#: btcpay-greenfield-for-woocommerce.php:522
#: src/Admin/GlobalSettings.php:378
msgid "Could not register a new webhook on the store."
msgstr ""

#: btcpay-greenfield-for-woocommerce.php:528
#: btcpay-greenfield-for-woocommerce.php:531
msgid "Please make sure you only select one store on the BTCPay API authorization page."
msgstr ""

#: btcpay-greenfield-for-woocommerce.php:533
#: btcpay-greenfield-for-woocommerce.php:536
msgid "Error processing the data from BTCPay. Please try again."
msgstr ""

Expand Down
11 changes: 7 additions & 4 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Contributors: ndeet, kukks, nicolasdorier
Donate link: https://btcpayserver.org/donate/
Tags: Bitcoin, Lightning Network, BTCPay Server, WooCommerce, payment gateway
Requires at least: 5.2
Tested up to: 6.4
Tested up to: 6.5
Requires PHP: 8.0
Stable tag: 2.6.1
Stable tag: 2.6.2
License: MIT
License URI: https://github.com/btcpayserver/woocommerce-greenfield-plugin/blob/master/license.txt

Expand Down Expand Up @@ -111,10 +111,13 @@ You'll find extensive documentation and answers to many of your questions on [BT
6. On BTCPay Server you have extensive reporting and accounting features.

== Upgrade Notice ==
= 2.6.1 =
* Minor changes, just update.
= 2.6.2 =
* Notifications fix, buttons should now work.

== Changelog ==
= 2.6.2 :: 2024-04-09 =
* Fix: Dismissing the review notification forever, finally.

= 2.6.1 :: 2024-04-04 =
* Fix: Error when processing full amount refunds.
* Fix: Show warning when bcmath extension is missing.
Expand Down
14 changes: 8 additions & 6 deletions resources/js/backend/notifications.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
jQuery(document).ready(function($) {
jQuery(document).on('click', '.btcpay-review-notice button.btcpay-review-dismiss', function() {
jQuery(document).on('click', '.btcpay-review-notice button.btcpay-review-dismiss', function(e) {
e.preventDefault();
$.ajax({
url: BTCPayNotifications.ajax_url,
type: 'post',
data: {
action: 'btcpaygf_notifications',
nonce: BTCPayNotifications.nonce
},
success : function(data) {
window.location.reload(true);
success: function(data) {
jQuery('.btcpay-review-notice').remove();
}
});
});
jQuery(document).on('click', '.btcpay-review-notice button.btcpay-review-dismiss-forever', function() {
jQuery(document).on('click', '.btcpay-review-notice button.btcpay-review-dismiss-forever', function(e) {
e.preventDefault();
$.ajax({
url: BTCPayNotifications.ajax_url,
type: 'post',
Expand All @@ -21,8 +23,8 @@ jQuery(document).ready(function($) {
nonce: BTCPayNotifications.nonce,
dismiss_forever: true
},
success : function(data) {
window.location.reload(true);
success: function(data) {
jQuery('.btcpay-review-notice').remove();
}
});
});
Expand Down

0 comments on commit ba09957

Please sign in to comment.