Skip to content

Commit

Permalink
Merge pull request #37 from ndeet/b241
Browse files Browse the repository at this point in the history
Minor release features
  • Loading branch information
ndeet authored Jan 22, 2024
2 parents 1acca63 + 94b4ed0 commit 013d0e1
Show file tree
Hide file tree
Showing 18 changed files with 183 additions and 76 deletions.
Binary file modified .wordpress-org/banner-1544x500.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .wordpress-org/banner-772x250.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .wordpress-org/screenshot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .wordpress-org/screenshot-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .wordpress-org/screenshot-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .wordpress-org/screenshot-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .wordpress-org/screenshot-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .wordpress-org/screenshot-6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 39 additions & 3 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.4.0
* Version: 2.4.1
* Requires PHP: 7.4
* Tested up to: 6.4
* Requires at least: 5.2
* WC requires at least: 6.0
* WC tested up to: 8.4
* WC tested up to: 8.5
*/

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

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

define( 'BTCPAYSERVER_VERSION', '2.4.0' );
define( 'BTCPAYSERVER_VERSION', '2.4.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 All @@ -41,7 +41,9 @@ public function __construct() {

add_action('woocommerce_thankyou_btcpaygf_default', ['BTCPayServerWCPlugin', 'orderStatusThankYouPage'], 10, 1);
add_action( 'wp_ajax_btcpaygf_modal_checkout', [$this, 'processAjaxModalCheckout'] );
add_action( 'wp_ajax_btcpaygf_notifications', [$this, 'processAjaxNotification'] );
add_action( 'wp_ajax_nopriv_btcpaygf_modal_checkout', [$this, 'processAjaxModalCheckout'] );
add_action( 'admin_enqueue_scripts', [$this, 'enqueueAdminScripts'] );

// Run the updates.
\BTCPayServer\WC\Helper\UpdateManager::processUpdates();
Expand All @@ -61,6 +63,7 @@ function ($settings) {
$this->dependenciesNotification();
$this->legacyPluginNotification();
$this->notConfiguredNotification();
$this->submitReviewNotification();
}
}

Expand Down Expand Up @@ -90,6 +93,17 @@ 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_localize_script('btcpaygf-notifications', 'BTCPayNotifications', [
'ajax_url' => admin_url('admin-ajax.php'),
'nonce' => wp_create_nonce('btcpaygf-notifications-nonce')
]);
}

public static function initPaymentGateways($gateways): array {
// We always load the default gateway that covers all payment methods available on BTCPayServer.
$gateways[] = DefaultGateway::class;
Expand Down Expand Up @@ -163,6 +177,21 @@ 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')) {
$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' ),
'<a href="https://wordpress.org/support/plugin/btcpay-greenfield-for-woocommerce/reviews/?filter=5#new-post" target="_blank">',
'</a>'
);

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

/**
* Handles the AJAX callback from the GlobalSettings form. Unfortunately with namespaces it seems to not work
* to have this method on the GlobalSettings class. So keeping it here for the time being.
Expand Down Expand Up @@ -232,6 +261,13 @@ public function processAjaxModalCheckout() {
}
}

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);
wp_send_json_success();
}

public static function orderStatusThankYouPage($order_id)
{
if (!$order = wc_get_order($order_id)) {
Expand Down
Loading

0 comments on commit 013d0e1

Please sign in to comment.