PluginProbe
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More / 2.3.4
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More v2.3.4
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 1.0.5 1.0.6 All 66 releases
better-payment / includes / Admin.php

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

240 lines 7.8 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 }
56
57 // Usage tracking is NOT registered here any more. It is wired from
58 // Better_Payment::init_plugin() for admin *and* cron requests, because
59 // WP-Cron runs as a non-admin request and this gate hid the tracker's
60 // do_tracking() callback from its own scheduled event. See the note
61 // there. The Pro gate now lives in Helper::start_plugin_tracking().
62
63 add_action('in_admin_header', array( $this, 'hide_admin_notices' ));
64 }
65
66 /**
67 * Add settings page link on plugins page
68 *
69 * @param array $links
70 * @param string $file
71 *
72 * @return array
73 * @since 0.0.1
74 */
75 public function plugin_actions_links($links, $file) {
76 $better_payment_plugin = plugin_basename(BETTER_PAYMENT_FILE);
77
78 if ($file == $better_payment_plugin && current_user_can('manage_options')) {
79 $links[] = sprintf('<a href="%s">%s</a>', admin_url("admin.php?page=better-payment-admin&tab=settings"), __('Settings', 'better-payment'));
80
81 if ( ! $this->pro_enabled ) {
82 $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>');
83 }
84 }
85
86 return $links;
87 }
88
89 public function admin_notice() {
90 require_once BETTER_PAYMENT_PATH . '/vendor/autoload.php';
91
92 self::$cache_bank = CacheBank::get_instance();
93
94 NoticeRemover::get_instance('1.0.0');
95 NoticeRemover::get_instance('1.0.0', '\WPDeveloper\BetterDocs\Dependencies\PriyoMukul\WPNotice\Notices');
96
97 $notices = new Notices( [
98 'id' => 'better-payment',
99 'storage_key' => 'notices',
100 'lifetime' => 3,
101 'stylesheet_url' => esc_url_raw( BETTER_PAYMENT_URL . '/assets/css/admin.min.css' ),
102 'styles' => esc_url_raw( BETTER_PAYMENT_URL . '/assets/css/admin.min.css' ),
103 'priority' => 9
104 ] );
105
106 $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?';
107 $_review_notice = [
108 'thumbnail' => plugins_url( 'assets/img/logo.svg', BETTER_PAYMENT_BASENAME ),
109 'html' => '<p>' . $review_notice . '</p>',
110 'links' => [
111 'later' => array(
112 'link' => '//wordpress.org/support/plugin/better-payment/reviews/#new-post',
113 'target' => '_blank',
114 'label' => 'Ok, you deserve it!',
115 'icon_class' => 'dashicons dashicons-external',
116 'attributes' => [
117 'target' => '_blank',
118 ],
119 ),
120 'allready' => array(
121 'label' => 'I already did',
122 'icon_class' => 'dashicons dashicons-smiley',
123 'attributes' => [
124 'data-dismiss' => true
125 ],
126 ),
127 'maybe_later' => array(
128 'label' => 'Maybe Later',
129 'icon_class' => 'dashicons dashicons-calendar-alt',
130 'attributes' => [
131 'data-later' => true
132 ],
133 ),
134 'support' => array(
135 'link' => 'https://wpdeveloper.com/support',
136 'label' => 'I need help',
137 'icon_class' => 'dashicons dashicons-sos',
138 'attributes' => [
139 'target' => '_blank',
140 ],
141 ),
142 'never_show_again' => array(
143 'label' => 'Never show again',
144 'icon_class' => 'dashicons dashicons-dismiss',
145 'attributes' => [
146 'data-dismiss' => true
147 ],
148 )
149 ]
150 ];
151
152 $notices->add(
153 'review',
154 $_review_notice,
155 [
156 'start' => $notices->strtotime( '+7 day' ),
157 'recurrence' => 30,
158 'refresh' => BETTER_PAYMENT_VERSION,
159 'dismissible' => true,
160 ]
161 );
162
163 /**
164 * Summer Offer Notice
165 */
166 $purchase_url = '//betterpayment.co/summer2026-admin-notice';
167 $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>";
168
169 $summer_notice = [
170 'thumbnail' => plugins_url( 'assets/img/logo.svg', BETTER_PAYMENT_BASENAME ),
171 'html' => $summer_notice_message,
172 ];
173
174 $notices->add(
175 'bp_summer_notice',
176 $summer_notice,
177 [
178 'start' => $notices->time(),
179 'expire' => strtotime( '11:59:59pm 25th June, 2026' ),
180 'refresh' => BETTER_PAYMENT_VERSION,
181 'dismissible' => true,
182 'screens' => [ 'dashboard' ],
183 ]
184 );
185
186 self::$cache_bank->create_account( $notices );
187 self::$cache_bank->calculate_deposits( $notices );
188 }
189
190 public function hide_admin_notices(){
191 $current_screen = get_current_screen();
192
193 if ($current_screen && (false !== strpos( $current_screen->id, 'better-payment' ) || false !== strpos( $current_screen->id, 'bp-campaign' )) ) {
194 remove_all_actions('user_admin_notices');
195 remove_all_actions('admin_notices');
196 remove_all_actions('all_admin_notices');
197 remove_all_actions('network_admin_notices');
198
199 // To show notice in better payment settings page we have to use 'better_payment_admin_notices' action hook
200 add_action( 'admin_notices', function () {
201 do_action( 'better_payment_admin_notices' );
202 } );
203 }
204 }
205
206 /**
207 * Dispatch and bind actions
208 *
209 * @return void
210 * @since 0.0.1
211 */
212 public static function dispatch_actions( ) {
213 $menuObj = new Menu();
214 $menuObj->init();
215
216 $bpElementorWidgetObj = new Widget();
217
218 $bpImportObj = new Import();
219
220 $bpExportObj = new Export();
221
222 $helperObj = new Helper();
223
224 // Handle select2 ajax search
225 add_action('wp_ajax_better_payment_select2_search_post', [$bpElementorWidgetObj, 'select2_ajax_posts_filter_autocomplete']);
226
227 add_action('wp_ajax_better_payment_select2_get_title', [$bpElementorWidgetObj, 'select2_ajax_get_posts_value_titles']);
228
229 // Elements
230 add_action('elementor/controls/controls_registered',[$bpElementorWidgetObj, 'register_controls']);
231
232 //Page: Transactions
233 add_action('admin_post_better-payment-transactions-import',[$bpImportObj, 'import_transactions']);
234 add_action('wp_ajax_better-payment-transactions-export',[$bpExportObj, 'export_transactions']);
235
236 // Elementor categories
237 add_action('elementor/elements/categories_registered', [$helperObj, 'register_widget_categories']);
238 }
239 }
240