PluginProbe
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More / 2.2.0
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More v2.2.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 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.2.0, at includes/Admin.php

235 lines 7.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 * Summer Offer Notice
160 */
161 $purchase_url = '//betterpayment.co/summer2026-admin-notice';
162 $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>";
163
164 $summer_notice = [
165 'thumbnail' => plugins_url( 'assets/img/logo.svg', BETTER_PAYMENT_BASENAME ),
166 'html' => $summer_notice_message,
167 ];
168
169 $notices->add(
170 'bp_summer_notice',
171 $summer_notice,
172 [
173 'start' => $notices->time(),
174 'expire' => strtotime( '11:59:59pm 25th June, 2026' ),
175 'refresh' => BETTER_PAYMENT_VERSION,
176 'dismissible' => true,
177 'screens' => [ 'dashboard' ],
178 ]
179 );
180
181 self::$cache_bank->create_account( $notices );
182 self::$cache_bank->calculate_deposits( $notices );
183 }
184
185 public function hide_admin_notices(){
186 $current_screen = get_current_screen();
187
188 if ($current_screen && (false !== strpos( $current_screen->id, 'better-payment' ) || false !== strpos( $current_screen->id, 'bp-campaign' )) ) {
189 remove_all_actions('user_admin_notices');
190 remove_all_actions('admin_notices');
191 remove_all_actions('all_admin_notices');
192 remove_all_actions('network_admin_notices');
193
194 // To show notice in better payment settings page we have to use 'better_payment_admin_notices' action hook
195 add_action( 'admin_notices', function () {
196 do_action( 'better_payment_admin_notices' );
197 } );
198 }
199 }
200
201 /**
202 * Dispatch and bind actions
203 *
204 * @return void
205 * @since 0.0.1
206 */
207 public static function dispatch_actions( ) {
208 $menuObj = new Menu();
209 $menuObj->init();
210
211 $bpElementorWidgetObj = new Widget();
212
213 $bpImportObj = new Import();
214
215 $bpExportObj = new Export();
216
217 $helperObj = new Helper();
218
219 // Handle select2 ajax search
220 add_action('wp_ajax_better_payment_select2_search_post', [$bpElementorWidgetObj, 'select2_ajax_posts_filter_autocomplete']);
221
222 add_action('wp_ajax_better_payment_select2_get_title', [$bpElementorWidgetObj, 'select2_ajax_get_posts_value_titles']);
223
224 // Elements
225 add_action('elementor/controls/controls_registered',[$bpElementorWidgetObj, 'register_controls']);
226
227 //Page: Transactions
228 add_action('admin_post_better-payment-transactions-import',[$bpImportObj, 'import_transactions']);
229 add_action('wp_ajax_better-payment-transactions-export',[$bpExportObj, 'export_transactions']);
230
231 // Elementor categories
232 add_action('elementor/elements/categories_registered', [$helperObj, 'register_widget_categories']);
233 }
234 }
235