PluginProbe
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More / 2.1.1
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More v2.1.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
better-payment / includes / Admin.php

Admin.php in Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More 2.1.1, at includes/Admin.php

329 lines 11.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Better_Payment\Lite;
4
5 use Better_Payment\Lite\Admin\Settings;
6 use Better_Payment\Lite\Admin\ReactAdmin;
7 use Better_Payment\Lite\Admin\Elementor\Widget;
8 use Better_Payment\Lite\Admin\Menu;
9 use Better_Payment\Lite\Classes\Helper;
10 use Better_Payment\Lite\Classes\Export;
11 use Better_Payment\Lite\Classes\Import;
12 use PriyoMukul\WPNotice\Notices;
13 use PriyoMukul\WPNotice\Utils\CacheBank;
14 use PriyoMukul\WPNotice\Utils\NoticeRemover;
15
16 /**
17 * Exit if accessed directly
18 */
19 if (!defined('ABSPATH')) {
20 exit;
21 }
22
23 /**
24 * The admin class
25 *
26 * @since 0.0.1
27 */
28 class Admin extends Controller{
29
30 // Check if pro is enabled
31 protected $pro_enabled;
32
33 private static $cache_bank = null;
34
35 /**
36 * Initialize the class
37 *
38 * @since 0.0.1
39 */
40 public function __construct() {
41
42 }
43
44 public function init(){
45 $this->pro_enabled = apply_filters('better_payment/pro_enabled', false);
46
47 new ReactAdmin();
48 // new Settings();
49
50 // Add plugin action links - works with or without Elementor
51 add_filter('plugin_action_links', array($this, 'plugin_actions_links'), 10, 2);
52
53 if ( ! $this->pro_enabled ) {
54 $this->admin_notice();
55 $this->start_plugin_tracking();
56 }
57
58 add_action('in_admin_header', array( $this, 'hide_admin_notices' ));
59 }
60
61 /**
62 * Add settings page link on plugins page
63 *
64 * @param array $links
65 * @param string $file
66 *
67 * @return array
68 * @since 0.0.1
69 */
70 public function plugin_actions_links($links, $file) {
71 $better_payment_plugin = plugin_basename(BETTER_PAYMENT_FILE);
72
73 if ($file == $better_payment_plugin && current_user_can('manage_options')) {
74 $links[] = sprintf('<a href="%s">%s</a>', admin_url("admin.php?page=better-payment-admin&tab=settings"), __('Settings', 'better-payment'));
75
76 if ( ! $this->pro_enabled ) {
77 $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>');
78 }
79 }
80
81 return $links;
82 }
83
84 public function admin_notice() {
85 require_once BETTER_PAYMENT_PATH . '/vendor/autoload.php';
86
87 self::$cache_bank = CacheBank::get_instance();
88
89 NoticeRemover::get_instance('1.0.0');
90 NoticeRemover::get_instance('1.0.0', '\WPDeveloper\BetterDocs\Dependencies\PriyoMukul\WPNotice\Notices');
91
92 $notices = new Notices( [
93 'id' => 'better-payment',
94 'storage_key' => 'notices',
95 'lifetime' => 3,
96 'stylesheet_url' => esc_url_raw( BETTER_PAYMENT_URL . '/assets/css/admin.min.css' ),
97 'styles' => esc_url_raw( BETTER_PAYMENT_URL . '/assets/css/admin.min.css' ),
98 'priority' => 9
99 ] );
100
101 $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?';
102 $_review_notice = [
103 'thumbnail' => plugins_url( 'assets/img/logo.svg', BETTER_PAYMENT_BASENAME ),
104 'html' => '<p>' . $review_notice . '</p>',
105 'links' => [
106 'later' => array(
107 'link' => '//wordpress.org/support/plugin/better-payment/reviews/#new-post',
108 'target' => '_blank',
109 'label' => 'Ok, you deserve it!',
110 'icon_class' => 'dashicons dashicons-external',
111 'attributes' => [
112 'target' => '_blank',
113 ],
114 ),
115 'allready' => array(
116 'label' => 'I already did',
117 'icon_class' => 'dashicons dashicons-smiley',
118 'attributes' => [
119 'data-dismiss' => true
120 ],
121 ),
122 'maybe_later' => array(
123 'label' => 'Maybe Later',
124 'icon_class' => 'dashicons dashicons-calendar-alt',
125 'attributes' => [
126 'data-later' => true
127 ],
128 ),
129 'support' => array(
130 'link' => 'https://wpdeveloper.com/support',
131 'label' => 'I need help',
132 'icon_class' => 'dashicons dashicons-sos',
133 'attributes' => [
134 'target' => '_blank',
135 ],
136 ),
137 'never_show_again' => array(
138 'label' => 'Never show again',
139 'icon_class' => 'dashicons dashicons-dismiss',
140 'attributes' => [
141 'data-dismiss' => true
142 ],
143 )
144 ]
145 ];
146
147 $notices->add(
148 'review',
149 $_review_notice,
150 [
151 'start' => $notices->strtotime( '+7 day' ),
152 'recurrence' => 30,
153 'refresh' => BETTER_PAYMENT_VERSION,
154 'dismissible' => true,
155 ]
156 );
157
158 /**
159 * Halloween Notice
160 */
161 // $crown_icon = BETTER_PAYMENT_URL . '/assets/img/crown.svg';
162 // $halloween_notice_message = "<p>🎃 Manage Payment forms better with Better Payment PRO and grab a <strong>flat 25% OFF</strong> this Halloween.</p><a style='display: inline-flex;column-gap:5px;' class='button button-primary' href='https://betterpayment.co/#pricing-plan' target='_blank'><img style='width:15px;' src='{$crown_icon}'/>Upgrade to PRO</a>";
163
164 // $halloween_notice = [
165 // 'thumbnail' => plugins_url( 'assets/img/logo.svg', BETTER_PAYMENT_BASENAME ),
166 // 'html' => $halloween_notice_message,
167 // ];
168
169 // $notices->add(
170 // 'halloween_notice',
171 // $halloween_notice,
172 // [
173 // 'start' => $notices->time(),
174 // // 'start' => $notices->strtotime( '+7 day' ),
175 // // 'recurrence' => 30,
176 // 'expire' => $notices->strtotime( '+10 days' ),
177 // 'refresh' => BETTER_PAYMENT_VERSION,
178 // 'dismissible' => true,
179 // 'screens' => [ 'dashboard' ],
180 // ]
181 // );
182
183 /**
184 * Black Friday Notice
185 */
186 $purchase_url = 'https://betterpayment.co/bfcm2025-admin-notice';
187 $black_friday_notice_message = "<p><strong>Black Friday Mega Sale:</strong> Streamline Transactions With Fast, Optimized Payment Forms For Elementor Sites – Now <strong>Up to $200 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</a> <button class='wpsp-notice-action-dismiss dismiss-btn' data-dismiss='true' target='_blank'>I’ll Grab It Later</button></div>";
188
189 $black_friday_notice = [
190 'thumbnail' => plugins_url( 'assets/img/logo.svg', BETTER_PAYMENT_BASENAME ),
191 'html' => $black_friday_notice_message,
192 ];
193
194 $notices->add(
195 'black_friday_notice1',
196 $black_friday_notice,
197 [
198 'start' => $notices->time(),
199 'expire' => strtotime( '11:59:59pm 4th December, 2025' ),
200 'refresh' => BETTER_PAYMENT_VERSION,
201 'dismissible' => true,
202 'screens' => [ 'dashboard' ],
203 ]
204 );
205
206 /**
207 * Holiday Notice
208 */
209 $purchase_url = '//betterpayment.co/holiday2025-admin-notice';
210 $holiday_notice_message = "<p><strong>Season’s Best Deal:</strong> Streamline transactions with fast, optimized payment forms for Elementor sites - <strong>Up to 25% 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</a> <button class='wpsp-notice-action-dismiss dismiss-btn' data-dismiss='true' target='_blank'>I’ll Grab It Later</button></div>";
211
212 $holiday_notice = [
213 'thumbnail' => plugins_url( 'assets/img/logo.svg', BETTER_PAYMENT_BASENAME ),
214 'html' => $holiday_notice_message,
215 ];
216
217 $notices->add(
218 'bp_holiday_notice',
219 $holiday_notice,
220 [
221 'start' => strtotime( '12:00:00am 15th December, 2025' ),
222 'expire' => strtotime( '11:59:59pm 7th January, 2026' ),
223 'refresh' => BETTER_PAYMENT_VERSION,
224 'dismissible' => true,
225 'screens' => [ 'dashboard' ],
226 ]
227 );
228
229 /**
230 * February Offer Notice
231 */
232 $purchase_url = '//betterpayment.co/feb2026-admin-notice';
233 $february_notice_message = "<p>Streamline transactions with fast, optimized payment forms for Elementor sites - Now <strong>Flat 20% 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</a> <button class='wpsp-notice-action-dismiss dismiss-btn' data-dismiss='true' target='_blank'>I’ll Grab It Later</button></div>";
234
235 $friday_notice = [
236 'thumbnail' => plugins_url( 'assets/img/logo.svg', BETTER_PAYMENT_BASENAME ),
237 'html' => $february_notice_message,
238 ];
239
240 $notices->add(
241 'bp_february_notice',
242 $friday_notice,
243 [
244 'start' => strtotime( '12:00:00am 10th February, 2026' ),
245 'expire' => strtotime( '11:59:59pm 7th March, 2026' ),
246 'refresh' => BETTER_PAYMENT_VERSION,
247 'dismissible' => true,
248 'screens' => [ 'dashboard' ],
249 ]
250 );
251
252 /**
253 * Spring Offer Notice
254 */
255 $purchase_url = '//betterpayment.co/spring2026-admin-notice';
256 $spring_notice_message = "<p>🌸 <strong>Spring Savings:</strong> Streamline transactions with fast, optimized payment forms on your Elementor sites – now <strong>Flat 25% 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'>Maybe Later</button></div>";
257
258 $spring_notice = [
259 'thumbnail' => plugins_url( 'assets/img/logo.svg', BETTER_PAYMENT_BASENAME ),
260 'html' => $spring_notice_message,
261 ];
262
263 $notices->add(
264 'bp_spring_notice',
265 $spring_notice,
266 [
267 'start' => $notices->time(),
268 'expire' => strtotime( '11:59:59pm 10th May, 2026' ),
269 'refresh' => BETTER_PAYMENT_VERSION,
270 'dismissible' => true,
271 'screens' => [ 'dashboard' ],
272 ]
273 );
274
275 self::$cache_bank->create_account( $notices );
276 self::$cache_bank->calculate_deposits( $notices );
277 }
278
279 public function hide_admin_notices(){
280 $current_screen = get_current_screen();
281
282 if ($current_screen && str_contains( $current_screen->id, 'better-payment' ) ) {
283 remove_all_actions('user_admin_notices');
284 remove_all_actions('admin_notices');
285 remove_all_actions('all_admin_notices');
286 remove_all_actions('network_admin_notices');
287
288 // To show notice in better payment settings page we have to use 'better_payment_admin_notices' action hook
289 add_action( 'admin_notices', function () {
290 do_action( 'better_payment_admin_notices' );
291 } );
292 }
293 }
294
295 /**
296 * Dispatch and bind actions
297 *
298 * @return void
299 * @since 0.0.1
300 */
301 public static function dispatch_actions( ) {
302 $menuObj = new Menu();
303 $menuObj->init();
304
305 $bpElementorWidgetObj = new Widget();
306
307 $bpImportObj = new Import();
308
309 $bpExportObj = new Export();
310
311 $helperObj = new Helper();
312
313 // Handle select2 ajax search
314 add_action('wp_ajax_better_payment_select2_search_post', [$bpElementorWidgetObj, 'select2_ajax_posts_filter_autocomplete']);
315
316 add_action('wp_ajax_better_payment_select2_get_title', [$bpElementorWidgetObj, 'select2_ajax_get_posts_value_titles']);
317
318 // Elements
319 add_action('elementor/controls/controls_registered',[$bpElementorWidgetObj, 'register_controls']);
320
321 //Page: Transactions
322 add_action('admin_post_better-payment-transactions-import',[$bpImportObj, 'import_transactions']);
323 add_action('wp_ajax_better-payment-transactions-export',[$bpExportObj, 'export_transactions']);
324
325 // Elementor categories
326 add_action('elementor/elements/categories_registered', [$helperObj, 'register_widget_categories']);
327 }
328 }
329