PluginProbe
WP Easy Pay – Payment and Donation Form Builder for Square / beta
WP Easy Pay – Payment and Donation Form Builder for Square vbeta
4.5.4 4.5.3 4.5.1 4.5.0 1.0 1.2 1.3 1.3.1 1.8 2.0 2.2 2.3.4 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 All 65 releases
wp-easy-pay / wp-easy-pay.php

wp-easy-pay.php in WP Easy Pay – Payment and Donation Form Builder for Square beta, at wp-easy-pay.php

320 lines 14.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * WP EASY PAY
5 * PHP version 7
6 * Plugin Name: WP Easy Pay (beta)
7 * Plugin URI: https://wpexperts.io/products/
8 * Description: Easily collect payments for Simple Payment or donations online
9 * without coding it yourself or hiring a developer. Skip setting up a complex shopping cart system.
10 * Author: Wpexperts
11 * Author URI: https://apiexperts.io
12 * Version: 3.0.3
13 * Text Domain: wp_easy_pay
14 * License: GPLv2 or later
15 *
16 * @category Wordpress_Plugin
17 * @package WP_Easy_Pay
18 * @author Author <contact@apiexperts.io>
19 * @license https://opensource.org/licenses/MIT MIT License
20 * @link http://wpeasypay.com/
21 */
22 if ( !defined( 'ABSPATH' ) ) {
23 exit;
24 }
25 define( 'WPEP_ROOT_URL', plugin_dir_url( __FILE__ ) );
26 define( 'WPEP_ROOT_PATH', plugin_dir_path( __FILE__ ) );
27 add_action( 'wp_head', 'add_viewport_meta_tag', '1' );
28 function add_viewport_meta_tag()
29 {
30 echo '<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />' ;
31 }
32
33
34 if ( !function_exists( 'wepp_fs' ) ) {
35 // Create a helper function for easy SDK access.
36 function wepp_fs()
37 {
38 global $wepp_fs ;
39
40 if ( !isset( $wepp_fs ) ) {
41 // Include Freemius SDK.
42 require_once WPEP_ROOT_PATH . 'freemius/start.php';
43 $wepp_fs = fs_dynamic_init( array(
44 'id' => '1920',
45 'slug' => 'wp-easy-pay',
46 'type' => 'plugin',
47 'public_key' => 'pk_4c854593bf607fd795264061bbf57',
48 'is_premium' => false,
49 'is_premium_only' => true,
50 'has_addons' => false,
51 'has_paid_plans' => true,
52 'menu' => array(
53 'slug' => 'wpep-button',
54 'override_exact' => true,
55 'first-path' => 'edit.php?post_type=wp_easy_pay&page=wpep-settings',
56 'parent' => array(
57 'slug' => 'plugins.php',
58 ),
59 ),
60 'is_live' => true,
61 ) );
62 }
63
64 return $wepp_fs;
65 }
66
67 // Init Freemius.
68 wepp_fs();
69 // Signal that SDK was initiated.
70 do_action( 'wepp_fs_loaded' );
71 function wepp_fs_settings_url()
72 {
73 $plans = array( "wpep_business", "wpep_premium", "wpep_basic" );
74
75 if ( isset( wepp_fs()->get_plan()->name ) && wepp_fs()->get_plan()->name == 'wpep_free' ) {
76 return admin_url( 'admin.php?page=wpep-settings' );
77 } else {
78
79 if ( isset( wepp_fs()->get_plan()->name ) && in_array( wepp_fs()->get_plan()->name, $plans ) ) {
80 //if old version execute old redirect else redirect to new version
81 $old_plugin_token_details = get_option( 'wpep_live_token_details', false );
82 $switch_to_new = get_option( 'wpep_switch_to_new', false );
83 if ( $old_plugin_token_details !== false ) {
84 if ( $switch_to_new == 'off' || $switch_to_new === false ) {
85 return admin_url( 'edit.php?post_type=wpep-button&page=wpep-settings' );
86 }
87 }
88 return admin_url( 'edit.php?post_type=wp_easy_pay&page=wpep-settings' );
89 }
90
91 }
92
93 }
94
95 wepp_fs()->add_filter( 'connect_url', 'wepp_fs_settings_url' );
96 //wepp_fs()->add_filter( 'after_skip_url', 'wepp_fs_settings_url' );
97 wepp_fs()->add_filter( 'after_connect_url', 'wepp_fs_settings_url' );
98 //wepp_fs()->add_filter( 'after_pending_connect_url', 'wepp_fs_settings_url' );
99 }
100
101
102 if ( !wepp_fs()->is_plan( 'wpep_basic', true ) && !wepp_fs()->is_plan( 'wpep_business', true ) && !wepp_fs()->is_plan( 'wpep_premium', true ) ) {
103 define( "WPEP_SQUARE_PLUGIN_NAME", 'WP_EASY_PAY' );
104 define( "WPEP_SQUARE_APP_NAME", 'WP_EASY_PAY_SQUARE_APP' );
105 define( "WPEP_MIDDLE_SERVER_URL", 'https://connect.apiexperts.io' );
106 define( "WPEP_SQUARE_APP_ID", 'sq0idp-k0r5c0MNIBIkTd5pXmV-tg' );
107 require_once __DIR__ . '/wpep_free_plugin_setup.php';
108 require_once WPEP_ROOT_PATH . 'modules/payments/square_authorization.php';
109 require_once WPEP_ROOT_PATH . 'modules/payments/square_payments_free.php';
110 require_once WPEP_ROOT_PATH . 'modules/render_forms/form_render_shortcode_free.php';
111 add_action( 'admin_enqueue_scripts', 'wpep_include_stylesheets' );
112 add_action( 'admin_enqueue_scripts', 'wpep_include_scripts_easy_pay_type_only' );
113 add_action( 'plugins_loaded', 'migrate_old_version_to_free_version_fields' );
114 function migrate_old_version_to_free_version_fields()
115 {
116 //migrating data
117 $saved_form_type = get_option( 'wpep_button_type', false );
118 $wpep_free_form_type = get_option( 'wpep_free_form_type', false );
119 if ( !empty($saved_form_type) and empty($wpep_free_form_type) ) {
120 update_option( 'wpep_free_form_type', $saved_form_type );
121 }
122 $saved_form_button = get_option( 'wpep_button_text', false );
123 $wpep_free_btn_text = get_option( 'wpep_free_btn_text', false );
124 if ( !empty($saved_form_button) and empty($wpep_free_btn_text) ) {
125 update_option( 'wpep_free_btn_text', $saved_form_button );
126 }
127 $saved_form_amount = get_option( 'wpep_amount', false );
128 $wpep_free_amount = get_option( 'wpep_free_amount', false );
129 if ( !empty($saved_form_amount) and empty($wpep_free_amount) ) {
130 update_option( 'wpep_free_amount', $saved_form_amount );
131 }
132 $wpep_pay_suc_url = get_option( 'wpep_pay_suc_url', false );
133 $wpep_free_success_url = get_option( 'wpep_free_success_url', false );
134 if ( !empty($wpep_pay_suc_url) and empty($wpep_free_success_url) ) {
135 update_option( 'wpep_free_success_url', $wpep_pay_suc_url );
136 }
137 $wpep_donation_organization_name = get_option( 'wpep_donation_organization_name', false );
138 $wpep_free_org_name = get_option( 'wpep_free_org_name', false );
139 if ( !empty($wpep_donation_organization_name) and empty($wpep_free_org_name) ) {
140 update_option( 'wpep_free_org_name', $wpep_donation_organization_name );
141 }
142 $wpep_donation_user_amount = get_option( 'wpep_donation_user_amount', false );
143 $wpep_free_user_set_amount = get_option( 'wpep_free_user_set_amount', false );
144 if ( !empty($wpep_donation_user_amount) and empty($wpep_free_user_set_amount) ) {
145 update_option( 'wpep_free_user_set_amount', $wpep_donation_user_amount );
146 }
147 $wpep_square_mode_live = get_option( 'wpep_square_mode_live', false );
148 $wpep_square_payment_mode_global = get_option( 'wpep_square_payment_mode_global', false );
149 if ( !empty($wpep_square_mode_live) and empty($wpep_square_payment_mode_global) ) {
150 update_option( 'wpep_square_payment_mode_global', $wpep_square_mode_live );
151 }
152 $wpep_notification_email = get_option( 'wpep_notification_email', false );
153 $wpep_free_notify_email = get_option( 'wpep_free_notify_email', false );
154 if ( !empty($wpep_notification_email) and empty($wpep_free_notify_email) ) {
155 update_option( 'wpep_free_notify_email', $wpep_notification_email );
156 }
157 $wpep_live_token = get_option( 'wpep_live_token' );
158 $wpep_live_token_upgraded = get_option( 'wpep_live_token_upgraded', false );
159 if ( !empty($wpep_live_token) and empty($wpep_live_token_upgraded) ) {
160 update_option( 'wpep_live_token_upgraded', $wpep_live_token );
161 }
162 $wpep_square_currency = get_option( 'wpep_square_currency' );
163 $wpep_square_currency_new = get_option( 'wpep_square_currency_new', false );
164 if ( !empty($wpep_square_currency) and empty($wpep_square_currency_new) ) {
165 update_option( 'wpep_square_currency_new', $wpep_square_currency );
166 }
167 $wpep_live_locationid = get_option( 'wpep_live_locationid' );
168 $wpep_square_location_id = get_option( 'wpep_square_location_id', false );
169 if ( !empty($wpep_live_locationid) and empty($wpep_square_location_id) ) {
170 update_option( 'wpep_square_location_id', $wpep_live_locationid );
171 }
172 }
173
174 function wpep_include_stylesheets()
175 {
176 if ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'wpep_payment_form' || isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'wpep-settings' || isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] == 'wpep_free_reports' ) {
177 wp_enqueue_style( 'wpep_backend_style_free', WPEP_ROOT_URL . 'assets/backend/css/wpep_backend_styles.css', '3.0.0' );
178 }
179 }
180
181 function wpep_include_scripts_easy_pay_type_only()
182 {
183
184 if ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'wpep_payment_form' || isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'wpep-settings' ) {
185 wp_enqueue_script(
186 'wpep_backend_script_free',
187 WPEP_ROOT_URL . 'assets/backend/js/wpep_backend_scripts_free.js',
188 array(),
189 '3.0.0',
190 true
191 );
192 wp_enqueue_script(
193 'wpep_jscolor_script',
194 WPEP_ROOT_URL . 'assets/backend/js/jscolor.js',
195 array(),
196 '1.0',
197 true
198 );
199 }
200
201 }
202
203 } else {
204 $switch_to_new = get_option( 'wpep_switch_to_new', false );
205 $old_plugin_access_token = get_option( 'wpep_live_token', false );
206 $old_plugin_token_details = get_option( 'wpep_live_token_details', false );
207
208 if ( $switch_to_new == "on" && $old_plugin_token_details == false || $switch_to_new == false && $old_plugin_token_details == false || $switch_to_new == "on" && $old_plugin_token_details !== false || $switch_to_new == 'off' && $old_plugin_token_details == false ) {
209 require_once WPEP_ROOT_PATH . 'wpep_setup.php';
210 require_once WPEP_ROOT_PATH . 'premium-files/modules/payments/square_authorization.php';
211 require_once WPEP_ROOT_PATH . 'premium-files/modules/payments/square_payments.php';
212 require_once WPEP_ROOT_PATH . 'premium-files/modules/render_forms/form_render_shortcode.php';
213 require_once WPEP_ROOT_PATH . 'premium-files/modules/payments/subscriptions_cron_job.php';
214 require_once WPEP_ROOT_PATH . 'premium-files/modules/admin_notices/ssl_notice.php';
215 require_once WPEP_ROOT_PATH . 'premium-files/modules/admin_notices/square_oauth_notice.php';
216 /* Old Subscriptions Handler */
217 require_once WPEP_ROOT_PATH . 'premium-files/wp-easy-pay-premium/premium-files/includes/wpep-subscription-renew-class.php';
218 new WPSP_Subscription_Renew();
219 add_action( 'wp_ajax_wpep_subscription_action_update', 'wpep_subscription_status_update' );
220 add_action( 'wp_ajax_nopriv_wpep_subscription_action_update', 'wpep_subscription_status_update' );
221 if ( isset( $_REQUEST['post'] ) ) {
222 $post_type = get_post_type( $_REQUEST['post'] );
223 }
224 if ( isset( $_REQUEST['post_type'] ) ) {
225 $post_type = $_REQUEST['post_type'];
226 }
227
228 if ( isset( $post_type ) ) {
229
230 if ( $post_type == 'wp_easy_pay' ) {
231 add_action( 'edit_form_after_editor', 'wpep_render_add_form_ui' );
232 add_action( 'admin_enqueue_scripts', 'wpep_include_scripts_easy_pay_type_only' );
233 add_action( 'admin_enqueue_scripts', 'wpep_include_stylesheets' );
234 }
235
236 if ( $post_type == 'wpep_reports' ) {
237 add_action( 'admin_enqueue_scripts', 'wpep_include_stylesheets' );
238 }
239
240 if ( $post_type == 'wpep_subscriptions' ) {
241 add_action( 'admin_enqueue_scripts', 'wpep_include_stylesheets' );
242 add_action( 'admin_enqueue_scripts', 'wpep_include_scripts_subscription_type_only' );
243 }
244
245 if ( $post_type == 'wpep-payment' ) {
246 // add_action( 'admin_enqueue_scripts', 'wpep_include_stylesheets' );
247 }
248 }
249
250 function wpep_include_stylesheets()
251 {
252 wp_enqueue_style(
253 'wpep_backend_style',
254 WPEP_ROOT_URL . 'premium-files/assets/backend/css/wpep_backend_styles.css',
255 array(),
256 '1.0.0'
257 );
258 }
259
260 function wpep_include_scripts_easy_pay_type_only()
261 {
262 wp_enqueue_script(
263 'wpep_form-builder',
264 WPEP_ROOT_URL . 'premium-files/assets/backend/js/form-builder.min.js',
265 array(),
266 '3.0.0',
267 true
268 );
269 wp_enqueue_script(
270 'wpep_backend_scripts_multiinput',
271 WPEP_ROOT_URL . 'premium-files/assets/backend/js/wpep_backend_scripts_multiinput.js',
272 array(),
273 '3.0.0',
274 true
275 );
276 wp_enqueue_script(
277 'wpep_backend_script',
278 WPEP_ROOT_URL . 'premium-files/assets/backend/js/wpep_backend_scripts.js',
279 array(),
280 '3.0.0',
281 true
282 );
283 wp_enqueue_script(
284 'wpep_jscolor_script',
285 WPEP_ROOT_URL . 'premium-files/assets/backend/js/jscolor.js',
286 array(),
287 '1.0',
288 true
289 );
290 }
291
292 function wpep_include_scripts_subscription_type_only()
293 {
294 wp_enqueue_script(
295 'wpep_backend_subscription_script',
296 WPEP_ROOT_URL . 'premium-files/assets/backend/js/wpep_subscription_actions.js',
297 array(),
298 '3.0.0',
299 true
300 );
301 }
302
303 function wpep_render_add_form_ui()
304 {
305 require_once 'premium-files/views/backend/form_builder_settings/add_payment_form_custom_fields.php';
306 }
307
308 define( "WPEP_SQUARE_PLUGIN_NAME", 'WP_EASY_PAY' );
309 define( "WPEP_SQUARE_APP_NAME", 'WP_EASY_PAY_SQUARE_APP' );
310 define( "WPEP_MIDDLE_SERVER_URL", 'https://connect.apiexperts.io' );
311 define( "WPEP_SQUARE_APP_ID", 'sq0idp-k0r5c0MNIBIkTd5pXmV-tg' );
312 }
313
314 if ( $old_plugin_token_details !== false ) {
315 if ( $switch_to_new == 'off' || $switch_to_new === false ) {
316 require_once WPEP_ROOT_PATH . 'premium-files/wp-easy-pay-premium/wp-easy-pay.php';
317 }
318 }
319 }
320