PluginProbe
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More / 2.4.1
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More v2.4.1
2.4.1 2.4.0 2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.2 2.2.1 2.2.0 2.1.2 2.1.1 trunk 0.0.1 0.0.2 0.0.3 0.0.4 0.0.5 0.0.6 0.0.7 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 All 68 releases
← All changes | includes/Admin.php +161 -24 0.0.5 → 2.4.1 View file →
@@ -1,14 +1,16 @@
1 1 <?php
2 2
3 3 namespace Better_Payment\Lite;
4 4
5 -use Better_Payment\Lite\Admin\Better_Payment_Settings;
6 -use Better_Payment\Lite\Admin\Elementor\Better_Payment_Widget;
5 +use Better_Payment\Lite\Admin\ReactAdmin;
7 6 use Better_Payment\Lite\Admin\Elementor\Widget;
8 -use Better_Payment\Lite\Admin\Menu;
9 -use Better_Payment\Lite\Classes\Better_Payment_Helper;
7 +use Better_Payment\Lite\Classes\Helper;
10 8 use Better_Payment\Lite\Classes\Export;
9 +use Better_Payment\Lite\Classes\Import;
10 +use PriyoMukul\WPNotice\Notices;
11 +use PriyoMukul\WPNotice\Utils\CacheBank;
12 +use PriyoMukul\WPNotice\Utils\NoticeRemover;
11 13
12 14 /**
13 15 * Exit if accessed directly
14 16 */
@@ -17,16 +19,21 @@
17 19 }
18 20
19 21 /**
20 22 * The admin class
21 - *
23 + *
22 24 * @since 0.0.1
23 25 */
24 26 class Admin extends Controller{
25 27
28 + // Check if pro is enabled
29 + protected $pro_enabled;
30 +
31 + private static $cache_bank = null;
32 +
26 33 /**
27 34 * Initialize the class
28 - *
35 + *
29 36 * @since 0.0.1
30 37 */
31 38 public function __construct() {
32 39
@@ -32,41 +39,168 @@
32 39
33 40 }
34 41
35 42 public function init(){
36 - if ( defined( 'ELEMENTOR_VERSION' ) ) {
37 - new Better_Payment_Settings();
43 + $this->pro_enabled = apply_filters('better_payment/pro_enabled', false);
44 +
45 + new ReactAdmin();
46 +
47 + // Add plugin action links - works with or without Elementor
48 + add_filter('plugin_action_links', array($this, 'plugin_actions_links'), 10, 2);
49 +
50 + if ( ! $this->pro_enabled ) {
51 + $this->admin_notice();
38 52 }
39 53
40 - if (!did_action('elementor/loaded')) {
41 - $notice = new Better_Payment_Helper();
42 - $notice->elementor_not_loaded();
43 - }
54 + // Usage tracking is NOT registered here any more. It is wired from
55 + // Better_Payment::init_plugin() for admin *and* cron requests, because
56 + // WP-Cron runs as a non-admin request and this gate hid the tracker's
57 + // do_tracking() callback from its own scheduled event. See the note
58 + // there. The Pro gate now lives in Helper::start_plugin_tracking().
44 59
45 - if (did_action('elementor/loaded')) {
46 - add_filter('plugin_action_links', array($this, 'plugin_actions_links'), 10, 2);
47 - }
60 + add_action('in_admin_header', array( $this, 'hide_admin_notices' ));
48 61 }
49 62
50 63 /**
51 64 * Add settings page link on plugins page
52 - *
65 + *
53 66 * @param array $links
54 67 * @param string $file
55 - *
68 + *
56 69 * @return array
57 70 * @since 0.0.1
58 71 */
59 72 public function plugin_actions_links($links, $file) {
60 - $better_payment_plugin = plugin_basename(__FILE__);
73 + $better_payment_plugin = plugin_basename(BETTER_PAYMENT_FILE);
61 74
62 75 if ($file == $better_payment_plugin && current_user_can('manage_options')) {
63 - $links[] = sprintf('<a href="%s">%s</a>', admin_url("admin.php?page=better-payment-settings"), __('Settings', 'better-payment'));
76 + $links[] = sprintf('<a href="%s">%s</a>', admin_url("admin.php?page=better-payment-admin&tab=settings"), __('Settings', 'better-payment'));
77 +
78 + if ( ! $this->pro_enabled ) {
79 + $links[] = sprintf('<a href="https://wpdeveloper.com/in/upgrade-better-payment-pro" target="_blank" style="color: #7561F8; font-weight: bold;">' . __('Go Pro', 'better-payment') . '</a>');
80 + }
64 81 }
65 82
66 83 return $links;
67 84 }
68 85
86 + public function admin_notice() {
87 + require_once BETTER_PAYMENT_PATH . '/vendor/autoload.php';
88 +
89 + self::$cache_bank = CacheBank::get_instance();
90 +
91 + NoticeRemover::get_instance('1.0.0');
92 + NoticeRemover::get_instance('1.0.0', '\WPDeveloper\BetterDocs\Dependencies\PriyoMukul\WPNotice\Notices');
93 +
94 + $notices = new Notices( [
95 + 'id' => 'better-payment',
96 + 'storage_key' => 'notices',
97 + 'lifetime' => 3,
98 + 'stylesheet_url' => esc_url_raw( BETTER_PAYMENT_URL . '/assets/css/admin.min.css' ),
99 + 'styles' => esc_url_raw( BETTER_PAYMENT_URL . '/assets/css/admin.min.css' ),
100 + 'priority' => 9
101 + ] );
102 +
103 + $review_notice = 'We hope you\'re enjoying Better Payment! Could you please do us a BIG favor and give it a 5-star rating on WordPress to help us spread the word and boost our motivation?';
104 + $_review_notice = [
105 + 'thumbnail' => plugins_url( 'assets/img/logo.svg', BETTER_PAYMENT_BASENAME ),
106 + 'html' => '<p>' . $review_notice . '</p>',
107 + 'links' => [
108 + 'later' => array(
109 + 'link' => '//wordpress.org/support/plugin/better-payment/reviews/#new-post',
110 + 'target' => '_blank',
111 + 'label' => 'Ok, you deserve it!',
112 + 'icon_class' => 'dashicons dashicons-external',
113 + 'attributes' => [
114 + 'target' => '_blank',
115 + ],
116 + ),
117 + 'allready' => array(
118 + 'label' => 'I already did',
119 + 'icon_class' => 'dashicons dashicons-smiley',
120 + 'attributes' => [
121 + 'data-dismiss' => true
122 + ],
123 + ),
124 + 'maybe_later' => array(
125 + 'label' => 'Maybe Later',
126 + 'icon_class' => 'dashicons dashicons-calendar-alt',
127 + 'attributes' => [
128 + 'data-later' => true
129 + ],
130 + ),
131 + 'support' => array(
132 + 'link' => 'https://wpdeveloper.com/support',
133 + 'label' => 'I need help',
134 + 'icon_class' => 'dashicons dashicons-sos',
135 + 'attributes' => [
136 + 'target' => '_blank',
137 + ],
138 + ),
139 + 'never_show_again' => array(
140 + 'label' => 'Never show again',
141 + 'icon_class' => 'dashicons dashicons-dismiss',
142 + 'attributes' => [
143 + 'data-dismiss' => true
144 + ],
145 + )
146 + ]
147 + ];
148 +
149 + $notices->add(
150 + 'review',
151 + $_review_notice,
152 + [
153 + 'start' => $notices->strtotime( '+7 day' ),
154 + 'recurrence' => 30,
155 + 'refresh' => BETTER_PAYMENT_VERSION,
156 + 'dismissible' => true,
157 + ]
158 + );
159 +
160 + /**
161 + * Summer Offer Notice
162 + */
163 + $purchase_url = '//betterpayment.co/summer2026-admin-notice';
164 + $summer_notice_message = "<p>🏖️ <strong>Summer Savings:</strong> Streamline transactions with fast, optimized payment forms on your WordPress sites – now <strong>up to $150 OFF!</strong> </p><div class='wpsp-notice-action-button' style='display: inline-flex;column-gap:5px;'><a class='button button-primary' href='{$purchase_url}' target='_blank'>Upgrade To Pro Now</a> <button class='wpsp-notice-action-dismiss dismiss-btn' data-dismiss='true' target='_blank'>I Don't Want Any Discount</button></div>";
165 +
166 + $summer_notice = [
167 + 'thumbnail' => plugins_url( 'assets/img/logo.svg', BETTER_PAYMENT_BASENAME ),
168 + 'html' => $summer_notice_message,
169 + ];
170 +
171 + $notices->add(
172 + 'bp_summer_notice',
173 + $summer_notice,
174 + [
175 + 'start' => $notices->time(),
176 + 'expire' => strtotime( '11:59:59pm 25th June, 2026' ),
177 + 'refresh' => BETTER_PAYMENT_VERSION,
178 + 'dismissible' => true,
179 + 'screens' => [ 'dashboard' ],
180 + ]
181 + );
182 +
183 + self::$cache_bank->create_account( $notices );
184 + self::$cache_bank->calculate_deposits( $notices );
185 + }
186 +
187 + public function hide_admin_notices(){
188 + $current_screen = get_current_screen();
189 +
190 + if ($current_screen && (false !== strpos( $current_screen->id, 'better-payment' ) || false !== strpos( $current_screen->id, 'bp-campaign' )) ) {
191 + remove_all_actions('user_admin_notices');
192 + remove_all_actions('admin_notices');
193 + remove_all_actions('all_admin_notices');
194 + remove_all_actions('network_admin_notices');
195 +
196 + // To show notice in better payment settings page we have to use 'better_payment_admin_notices' action hook
197 + add_action( 'admin_notices', function () {
198 + do_action( 'better_payment_admin_notices' );
199 + } );
200 + }
201 + }
202 +
69 203 /**
70 204 * Dispatch and bind actions
71 205 *
72 206 * @return void
@@ -72,25 +206,28 @@
72 206 * @return void
73 207 * @since 0.0.1
74 208 */
75 209 public static function dispatch_actions( ) {
76 - $menuObj = new Menu();
77 - $menuObj->init();
78 -
79 210 $bpElementorWidgetObj = new Widget();
80 211
212 + $bpImportObj = new Import();
213 +
81 214 $bpExportObj = new Export();
82 215
216 + $helperObj = new Helper();
217 +
83 218 // Handle select2 ajax search
84 219 add_action('wp_ajax_better_payment_select2_search_post', [$bpElementorWidgetObj, 'select2_ajax_posts_filter_autocomplete']);
85 - add_action('wp_ajax_nopriv_better_payment_select2_search_post', [$bpElementorWidgetObj, 'select2_ajax_posts_filter_autocomplete']);
86 220
87 221 add_action('wp_ajax_better_payment_select2_get_title', [$bpElementorWidgetObj, 'select2_ajax_get_posts_value_titles']);
88 - add_action('wp_ajax_nopriv_better_payment_select2_get_title', [$bpElementorWidgetObj, 'select2_ajax_get_posts_value_titles']);
89 222
90 223 // Elements
91 224 add_action('elementor/controls/controls_registered',[$bpElementorWidgetObj, 'register_controls']);
92 225
93 226 //Page: Transactions
227 + add_action('admin_post_better-payment-transactions-import',[$bpImportObj, 'import_transactions']);
94 228 add_action('wp_ajax_better-payment-transactions-export',[$bpExportObj, 'export_transactions']);
229 +
230 + // Elementor categories
231 + add_action('elementor/elements/categories_registered', [$helperObj, 'register_widget_categories']);
95 232 }
96 233 }