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 / better-payment.php

better-payment.php in Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More 2.1.1, at better-payment.php

207 lines 5.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Plugin Name: Better Payment
5 * Description: Better Payment allows you to automate payment transactions to manage donations, make payments, sell products, and more on your Elementor and Gutenberg website.
6 * Plugin URI: https://wpdeveloper.com/
7 * Author: WPDeveloper
8 * Version: 2.1.1
9 * Requires at least: 6.0
10 * Requires PHP: 7.4
11 * Author URI: https://wpdeveloper.com/
12 * Text Domain: better-payment
13 * Domain Path: /languages
14 */
15
16 if (!defined('ABSPATH')) {
17 exit;
18 } // Exit if accessed directly
19
20 require_once __DIR__ . '/vendor/autoload.php';
21
22 /**
23 * The plugin main class
24 *
25 * @since 0.0.1
26 */
27 final class Better_Payment {
28
29 use Better_Payment\Lite\Traits\Helper;
30
31 /**
32 * Plugin version
33 *
34 * @var string
35 * @since 0.0.1
36 */
37 const version = '2.1.1';
38
39 /**
40 * Class construcotr
41 *
42 * @since 0.0.1
43 */
44 private function __construct() {
45 $this->define_constants();
46
47 register_activation_hook(__FILE__, [$this, 'activate']);
48
49 add_action('plugins_loaded', [$this, 'init_plugin']);
50 }
51
52 /**
53 * Initialize a singleton instance
54 *
55 * @return \Better_Payment
56 * @since 0.0.1
57 */
58 public static function init() {
59 static $instance = false;
60
61 if (!$instance) {
62 $instance = new self();
63 }
64
65 return $instance;
66 }
67
68 /**
69 * Define the required plugin constants
70 *
71 * @return void
72 * @since 0.0.1
73 */
74 public function define_constants() {
75 define('BETTER_PAYMENT_VERSION', self::version);
76 define('BETTER_PAYMENT_FILE', __FILE__);
77 define('BETTER_PAYMENT_BASENAME', plugin_basename(__FILE__));
78 define('BETTER_PAYMENT_PATH', __DIR__);
79 define('BETTER_PAYMENT_URL', plugins_url('', BETTER_PAYMENT_FILE));
80 define('BETTER_PAYMENT_ASSETS', BETTER_PAYMENT_URL . '/assets');
81 define('BETTER_PAYMENT_ASSETS_PATH', BETTER_PAYMENT_PATH . '/assets');
82 define('BETTER_PAYMENT_DEV_ASSETS', BETTER_PAYMENT_URL . '/bpbuild');
83 define('BETTER_PAYMENT_DEV_ASSETS_PATH', BETTER_PAYMENT_PATH . '/bpbuild');
84 define('BETTER_PAYMENT_INCLUDES_PATH', BETTER_PAYMENT_PATH . '/includes');
85 define('BETTER_PAYMENT_ADMIN_PATH', BETTER_PAYMENT_INCLUDES_PATH . '/Admin');
86 define('BETTER_PAYMENT_ADMIN_VIEWS_PATH', BETTER_PAYMENT_ADMIN_PATH . '/views');
87 }
88
89 /**
90 * Do stuff upon plugin activation
91 *
92 * @return void
93 * @since 0.0.1
94 */
95 public function activate() {
96 $installer = new Better_Payment\Lite\Installer();
97 $installer->run();
98
99 if (get_option('better_payment_plugin_installed_fresh') !== 'yes' && get_option('better_payment_plugin_installed_time_fresh') === false) {
100 update_option('better_payment_plugin_installed_fresh', 'yes');
101
102 $now = time();
103 update_option('better_payment_plugin_installed_time_fresh', $now);
104 update_option('better_payment_progress_bar_dismissed_expiry_date', $now + 7 * DAY_IN_SECONDS);
105 }
106 }
107
108 /**
109 * Initialize the plugin
110 *
111 * @return void
112 * @since 0.0.1
113 */
114 public function init_plugin() {
115 new Better_Payment\Lite\Assets();
116
117 if (defined('DOING_AJAX') && DOING_AJAX) {
118 new Better_Payment\Lite\Ajax();
119 }
120
121 if (is_admin()) {
122 $adminObj = new Better_Payment\Lite\Admin();
123 $adminObj->init();
124
125 if ( !$this->bp_section_dismissed() ) {
126 add_action('save_post', array($this, 'bp_widget_usage_on_save'), 10, 1);
127 }
128 } else {
129 new Better_Payment\Lite\Frontend();
130 }
131
132 new Better_Payment\Lite\API();
133
134 // Initialize Gutenberg blocks
135 Better_Payment\Lite\Blocks\BlockManager::get_instance();
136 Better_Payment\Lite\Blocks\StyleHandler::init();
137
138 // Initialize Block Actions for payment processing (runs before Elementor Actions)
139 new Better_Payment\Lite\Blocks\BlockActions();
140
141 if (defined('ELEMENTOR_VERSION')) {
142 new Better_Payment\Lite\Classes\Actions();
143 $el_integration = new Better_Payment\Lite\Admin\Elementor\EL_Integration();
144 $el_integration->init();
145
146 Better_Payment\Lite\Admin\Settings::save_default_settings();
147 }
148 }
149 }
150
151 /**
152 * Initializes the main plugin
153 *
154 * @return \Better_Payment
155 * @since 0.0.1
156 */
157
158 Better_Payment::init();
159
160 /**
161 * Plugin migrator
162 *
163 * @since 0.0.2
164 */
165 function better_payment_migrator() {
166 Better_Payment\Lite\Classes\Migrator::migrator();
167 }
168
169
170 /**
171 * On wp load
172 *
173 * @return void
174 * @since 0.0.1
175 */
176 add_action('wp_loaded', function () {
177 if (get_option('better_payment_version') != BETTER_PAYMENT_VERSION) {
178 better_payment_migrator();
179 update_option('better_payment_version', BETTER_PAYMENT_VERSION);
180 }
181
182 $setup_wizard = get_option('better_payment_setup_wizard');
183
184 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
185 $is_from_better_payment = (isset( $_POST['form_data'] ) && isset( $_POST['form_data'][0] ) && isset( $_POST['form_data'][0]['name'] ) && strpos( $_POST['form_data'][0]['name'], 'better_payment_' ) !== false) || (isset( $_POST['is_tracking'] ) && $_POST['is_tracking'] === 'true') || (isset( $_POST['action'] ) && $_POST['action'] === 'save_setup_wizard_data');
186
187 if ( ! $is_from_better_payment ) {
188 return;
189 }
190 }
191
192 if ($setup_wizard == 'redirect') {
193 Better_Payment\Lite\Admin\Setup_Wizard::redirect();
194 }
195
196 if ($setup_wizard == 'init') {
197 new Better_Payment\Lite\Admin\Setup_Wizard();
198 }
199 });
200
201 /**
202 * Dispatch actions
203 *
204 * @since 0.0.1
205 */
206 \Better_Payment\Lite\Admin::dispatch_actions();
207