@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_Gateways' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_Gateways')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_Gateways. |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function __construct() { |
29 | 29 | $this->id = 'gateways'; |
30 | - $this->label = esc_html__( 'Payment Gateways', 'give' ); |
|
30 | + $this->label = esc_html__('Payment Gateways', 'give'); |
|
31 | 31 | |
32 | 32 | $this->default_tab = 'gateways-settings'; |
33 | 33 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $settings = array(); |
45 | 45 | $current_section = give_get_current_setting_section(); |
46 | 46 | |
47 | - switch ( $current_section ) { |
|
47 | + switch ($current_section) { |
|
48 | 48 | case 'paypal-standard': |
49 | 49 | $settings = array( |
50 | 50 | // Section 2: Paypal Standard. |
@@ -53,37 +53,37 @@ discard block |
||
53 | 53 | 'id' => 'give_title_gateway_settings_2', |
54 | 54 | ), |
55 | 55 | array( |
56 | - 'name' => esc_html__( 'PayPal Email', 'give' ), |
|
57 | - 'desc' => esc_html__( 'Enter your PayPal account\'s email.', 'give' ), |
|
56 | + 'name' => esc_html__('PayPal Email', 'give'), |
|
57 | + 'desc' => esc_html__('Enter your PayPal account\'s email.', 'give'), |
|
58 | 58 | 'id' => 'paypal_email', |
59 | 59 | 'type' => 'email', |
60 | 60 | ), |
61 | 61 | array( |
62 | - 'name' => esc_html__( 'PayPal Page Style', 'give' ), |
|
63 | - 'desc' => esc_html__( 'Enter the name of the page style to use, or leave blank to use the default.', 'give' ), |
|
62 | + 'name' => esc_html__('PayPal Page Style', 'give'), |
|
63 | + 'desc' => esc_html__('Enter the name of the page style to use, or leave blank to use the default.', 'give'), |
|
64 | 64 | 'id' => 'paypal_page_style', |
65 | 65 | 'type' => 'text', |
66 | 66 | ), |
67 | 67 | array( |
68 | - 'name' => esc_html__( 'PayPal Transaction Type', 'give' ), |
|
69 | - 'desc' => esc_html__( 'Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give' ), |
|
68 | + 'name' => esc_html__('PayPal Transaction Type', 'give'), |
|
69 | + 'desc' => esc_html__('Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give'), |
|
70 | 70 | 'id' => 'paypal_button_type', |
71 | 71 | 'type' => 'radio_inline', |
72 | 72 | 'options' => array( |
73 | - 'donation' => esc_html__( 'Donation', 'give' ), |
|
74 | - 'standard' => esc_html__( 'Standard Transaction', 'give' ) |
|
73 | + 'donation' => esc_html__('Donation', 'give'), |
|
74 | + 'standard' => esc_html__('Standard Transaction', 'give') |
|
75 | 75 | ), |
76 | 76 | 'default' => 'donation', |
77 | 77 | ), |
78 | 78 | array( |
79 | - 'name' => esc_html__( 'PayPal IPN Verification', 'give' ), |
|
80 | - 'desc' => esc_html__( 'If donations are not getting marked as complete, use a slightly less secure method of verifying donations.', 'give' ), |
|
79 | + 'name' => esc_html__('PayPal IPN Verification', 'give'), |
|
80 | + 'desc' => esc_html__('If donations are not getting marked as complete, use a slightly less secure method of verifying donations.', 'give'), |
|
81 | 81 | 'id' => 'paypal_verification', |
82 | 82 | 'type' => 'radio_inline', |
83 | 83 | 'default' => 'enabled', |
84 | 84 | 'options' => array( |
85 | - 'enabled' => __( 'Enabled', 'give' ), |
|
86 | - 'disabled' => __( 'Disabled', 'give' ), |
|
85 | + 'enabled' => __('Enabled', 'give'), |
|
86 | + 'disabled' => __('Disabled', 'give'), |
|
87 | 87 | ) |
88 | 88 | ), |
89 | 89 | array( |
@@ -101,19 +101,19 @@ discard block |
||
101 | 101 | 'id' => 'give_title_gateway_settings_3', |
102 | 102 | ), |
103 | 103 | array( |
104 | - 'name' => esc_html__( 'Collect Billing Details', 'give' ), |
|
105 | - 'desc' => esc_html__( 'Enable to request billing details for offline donations. Will appear above offline donation instructions. Can be enabled/disabled per form.', 'give' ), |
|
104 | + 'name' => esc_html__('Collect Billing Details', 'give'), |
|
105 | + 'desc' => esc_html__('Enable to request billing details for offline donations. Will appear above offline donation instructions. Can be enabled/disabled per form.', 'give'), |
|
106 | 106 | 'id' => 'give_offline_donation_enable_billing_fields', |
107 | 107 | 'type' => 'radio_inline', |
108 | 108 | 'default' => 'disabled', |
109 | 109 | 'options' => array( |
110 | - 'enabled' => __( 'Enabled', 'give' ), |
|
111 | - 'disabled' => __( 'Disabled', 'give' ) |
|
110 | + 'enabled' => __('Enabled', 'give'), |
|
111 | + 'disabled' => __('Disabled', 'give') |
|
112 | 112 | ) |
113 | 113 | ), |
114 | 114 | array( |
115 | - 'name' => esc_html__( 'Offline Donation Instructions', 'give' ), |
|
116 | - 'desc' => esc_html__( 'The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give' ), |
|
115 | + 'name' => esc_html__('Offline Donation Instructions', 'give'), |
|
116 | + 'desc' => esc_html__('The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give'), |
|
117 | 117 | 'id' => 'global_offline_donation_content', |
118 | 118 | 'default' => give_get_default_offline_donation_content(), |
119 | 119 | 'type' => 'wysiwyg', |
@@ -122,15 +122,15 @@ discard block |
||
122 | 122 | ) |
123 | 123 | ), |
124 | 124 | array( |
125 | - 'name' => esc_html__( 'Offline Donation Email Instructions Subject', 'give' ), |
|
126 | - 'desc' => esc_html__( 'Enter the subject line for the donation receipt email.', 'give' ), |
|
125 | + 'name' => esc_html__('Offline Donation Email Instructions Subject', 'give'), |
|
126 | + 'desc' => esc_html__('Enter the subject line for the donation receipt email.', 'give'), |
|
127 | 127 | 'id' => 'offline_donation_subject', |
128 | - 'default' => esc_attr__( '{donation} - Offline Donation Instructions', 'give' ), |
|
128 | + 'default' => esc_attr__('{donation} - Offline Donation Instructions', 'give'), |
|
129 | 129 | 'type' => 'text' |
130 | 130 | ), |
131 | 131 | array( |
132 | - 'name' => esc_html__( 'Offline Donation Email Instructions', 'give' ), |
|
133 | - 'desc' => esc_html__( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
132 | + 'name' => esc_html__('Offline Donation Email Instructions', 'give'), |
|
133 | + 'desc' => esc_html__('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
134 | 134 | 'id' => 'global_offline_donation_email', |
135 | 135 | 'default' => give_get_default_offline_donation_email_content(), |
136 | 136 | 'type' => 'wysiwyg', |
@@ -153,25 +153,25 @@ discard block |
||
153 | 153 | 'type' => 'title' |
154 | 154 | ), |
155 | 155 | array( |
156 | - 'name' => esc_html__( 'Test Mode', 'give' ), |
|
157 | - 'desc' => esc_html__( 'While in test mode no live donations are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give' ), |
|
156 | + 'name' => esc_html__('Test Mode', 'give'), |
|
157 | + 'desc' => esc_html__('While in test mode no live donations are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give'), |
|
158 | 158 | 'id' => 'test_mode', |
159 | 159 | 'type' => 'radio_inline', |
160 | 160 | 'default' => 'disabled', |
161 | 161 | 'options' => array( |
162 | - 'enabled' => __( 'Enabled', 'give' ), |
|
163 | - 'disabled' => __( 'Disabled', 'give' ), |
|
162 | + 'enabled' => __('Enabled', 'give'), |
|
163 | + 'disabled' => __('Disabled', 'give'), |
|
164 | 164 | ) |
165 | 165 | ), |
166 | 166 | array( |
167 | - 'name' => esc_html__( 'Enabled Gateways', 'give' ), |
|
168 | - 'desc' => esc_html__( 'Enable your payment gateway. Can be ordered by dragging.', 'give' ), |
|
167 | + 'name' => esc_html__('Enabled Gateways', 'give'), |
|
168 | + 'desc' => esc_html__('Enable your payment gateway. Can be ordered by dragging.', 'give'), |
|
169 | 169 | 'id' => 'gateways', |
170 | 170 | 'type' => 'enabled_gateways' |
171 | 171 | ), |
172 | 172 | array( |
173 | - 'name' => esc_html__( 'Default Gateway', 'give' ), |
|
174 | - 'desc' => esc_html__( 'The gateway that will be selected by default.', 'give' ), |
|
173 | + 'name' => esc_html__('Default Gateway', 'give'), |
|
174 | + 'desc' => esc_html__('The gateway that will be selected by default.', 'give'), |
|
175 | 175 | 'id' => 'default_gateway', |
176 | 176 | 'type' => 'default_gateway' |
177 | 177 | ), |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * Filter the payment gateways settings. |
188 | 188 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 |
189 | 189 | */ |
190 | - $settings = apply_filters( 'give_settings_gateways', $settings ); |
|
190 | + $settings = apply_filters('give_settings_gateways', $settings); |
|
191 | 191 | |
192 | 192 | /** |
193 | 193 | * Filter the settings. |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @param array $settings |
198 | 198 | */ |
199 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
199 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
200 | 200 | |
201 | 201 | // Output. |
202 | 202 | return $settings; |
@@ -210,12 +210,12 @@ discard block |
||
210 | 210 | */ |
211 | 211 | public function get_sections() { |
212 | 212 | $sections = array( |
213 | - 'gateways-settings' => esc_html__( 'Gateways', 'give' ), |
|
214 | - 'paypal-standard' => esc_html__( 'Paypal Standard', 'give' ), |
|
215 | - 'offline-donations' => esc_html__( 'Offline', 'give' ) |
|
213 | + 'gateways-settings' => esc_html__('Gateways', 'give'), |
|
214 | + 'paypal-standard' => esc_html__('Paypal Standard', 'give'), |
|
215 | + 'offline-donations' => esc_html__('Offline', 'give') |
|
216 | 216 | ); |
217 | 217 | |
218 | - return apply_filters( 'give_get_sections_' . $this->id, $sections ); |
|
218 | + return apply_filters('give_get_sections_'.$this->id, $sections); |
|
219 | 219 | } |
220 | 220 | } |
221 | 221 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | // Exit if accessed directly. |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -32,14 +32,14 @@ discard block |
||
32 | 32 | * 'testing' => false, // (required) Never leave as "true" in production!!! |
33 | 33 | * } |
34 | 34 | */ |
35 | - function __construct( $_banner_details ) { |
|
35 | + function __construct($_banner_details) { |
|
36 | 36 | $current_user = wp_get_current_user(); |
37 | 37 | |
38 | 38 | $this->plugin_activate_by = 0; |
39 | 39 | $this->banner_details = $_banner_details; |
40 | - $this->test_mode = ( $this->banner_details['testing'] == 'true' ) ? true : false; |
|
41 | - $this->nag_meta_key = 'give_addon_activation_ignore_' . sanitize_title( $this->banner_details['name'] ); |
|
42 | - $this->activate_by_meta_key = 'give_addon_' . sanitize_title( $this->banner_details['name'] ) . '_active_by_user'; |
|
40 | + $this->test_mode = ($this->banner_details['testing'] == 'true') ? true : false; |
|
41 | + $this->nag_meta_key = 'give_addon_activation_ignore_'.sanitize_title($this->banner_details['name']); |
|
42 | + $this->activate_by_meta_key = 'give_addon_'.sanitize_title($this->banner_details['name']).'_active_by_user'; |
|
43 | 43 | |
44 | 44 | //Get current user |
45 | 45 | $this->user_id = $current_user->ID; |
@@ -62,16 +62,16 @@ discard block |
||
62 | 62 | public function init() { |
63 | 63 | |
64 | 64 | //Testing? |
65 | - if ( $this->test_mode ) { |
|
66 | - delete_user_meta( $this->user_id, $this->nag_meta_key ); |
|
65 | + if ($this->test_mode) { |
|
66 | + delete_user_meta($this->user_id, $this->nag_meta_key); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | //Get the current page to add the notice to |
70 | - add_action( 'current_screen', array( $this, 'give_addon_notice_ignore' ) ); |
|
71 | - add_action( 'admin_notices', array( $this, 'give_addon_activation_admin_notice' ) ); |
|
70 | + add_action('current_screen', array($this, 'give_addon_notice_ignore')); |
|
71 | + add_action('admin_notices', array($this, 'give_addon_activation_admin_notice')); |
|
72 | 72 | |
73 | 73 | // File path of addon must be included in banner detail other addon activate meta will not delete. |
74 | - add_action( 'deactivate_' . $this->get_plugin_file_name(), array( $this, 'remove_addon_activate_meta' ) ); |
|
74 | + add_action('deactivate_'.$this->get_plugin_file_name(), array($this, 'remove_addon_activate_meta')); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | private function is_plugin_page() { |
86 | 86 | $screen = get_current_screen(); |
87 | 87 | |
88 | - return ( $screen->parent_file === 'plugins.php' ); |
|
88 | + return ($screen->parent_file === 'plugins.php'); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | |
@@ -98,12 +98,12 @@ discard block |
||
98 | 98 | public function give_addon_activation_admin_notice() { |
99 | 99 | |
100 | 100 | // Bailout. |
101 | - if ( ! $this->is_plugin_page() || $this->user_id !== $this->plugin_activate_by ) { |
|
101 | + if ( ! $this->is_plugin_page() || $this->user_id !== $this->plugin_activate_by) { |
|
102 | 102 | return; |
103 | 103 | } |
104 | 104 | |
105 | 105 | // If the user hasn't already dismissed the alert, output activation banner. |
106 | - if ( ! get_user_meta( $this->user_id, $this->nag_meta_key ) ) { |
|
106 | + if ( ! get_user_meta($this->user_id, $this->nag_meta_key)) { |
|
107 | 107 | |
108 | 108 | // Output inline styles here because there's no reason |
109 | 109 | // to enqueued them after the alert is dismissed. |
@@ -185,44 +185,44 @@ discard block |
||
185 | 185 | <h3><?php |
186 | 186 | printf( |
187 | 187 | /* translators: %s: Add-on name */ |
188 | - esc_html__( "Thank you for installing Give's %s Add-on!", 'give' ), |
|
189 | - '<span>' . $this->banner_details['name'] . '</span>' |
|
188 | + esc_html__("Thank you for installing Give's %s Add-on!", 'give'), |
|
189 | + '<span>'.$this->banner_details['name'].'</span>' |
|
190 | 190 | ); |
191 | 191 | ?></h3> |
192 | 192 | |
193 | 193 | <a href="<?php |
194 | 194 | //The Dismiss Button. |
195 | - $nag_admin_dismiss_url = 'plugins.php?' . $this->nag_meta_key . '=0'; |
|
196 | - echo admin_url( $nag_admin_dismiss_url ); ?>" class="dismiss"><span |
|
195 | + $nag_admin_dismiss_url = 'plugins.php?'.$this->nag_meta_key.'=0'; |
|
196 | + echo admin_url($nag_admin_dismiss_url); ?>" class="dismiss"><span |
|
197 | 197 | class="dashicons dashicons-dismiss"></span></a> |
198 | 198 | |
199 | 199 | <div class="alert-actions"> |
200 | 200 | |
201 | 201 | <?php //Point them to your settings page. |
202 | - if ( isset( $this->banner_details['settings_url'] ) ) { ?> |
|
202 | + if (isset($this->banner_details['settings_url'])) { ?> |
|
203 | 203 | <a href="<?php echo $this->banner_details['settings_url']; ?>"> |
204 | - <span class="dashicons dashicons-admin-settings"></span><?php esc_html_e( 'Go to Settings', 'give' ); ?> |
|
204 | + <span class="dashicons dashicons-admin-settings"></span><?php esc_html_e('Go to Settings', 'give'); ?> |
|
205 | 205 | </a> |
206 | 206 | <?php } ?> |
207 | 207 | |
208 | 208 | <?php |
209 | 209 | // Show them how to configure the Addon. |
210 | - if ( isset( $this->banner_details['documentation_url'] ) ) { ?> |
|
210 | + if (isset($this->banner_details['documentation_url'])) { ?> |
|
211 | 211 | <a href="<?php echo $this->banner_details['documentation_url'] ?>" target="_blank"> |
212 | 212 | <span class="dashicons dashicons-media-text"></span><?php |
213 | 213 | printf( |
214 | 214 | /* translators: %s: Add-on name */ |
215 | - esc_html__( 'Documentation: %s Add-on', 'give' ), |
|
215 | + esc_html__('Documentation: %s Add-on', 'give'), |
|
216 | 216 | $this->banner_details['name'] |
217 | 217 | ); |
218 | 218 | ?></a> |
219 | 219 | <?php } ?> |
220 | 220 | <?php |
221 | 221 | //Let them signup for plugin updates |
222 | - if ( isset( $this->banner_details['support_url'] ) ) { ?> |
|
222 | + if (isset($this->banner_details['support_url'])) { ?> |
|
223 | 223 | |
224 | 224 | <a href="<?php echo $this->banner_details['support_url'] ?>" target="_blank"> |
225 | - <span class="dashicons dashicons-sos"></span><?php esc_html_e( 'Get Support', 'give' ); ?> |
|
225 | + <span class="dashicons dashicons-sos"></span><?php esc_html_e('Get Support', 'give'); ?> |
|
226 | 226 | </a> |
227 | 227 | |
228 | 228 | <?php } ?> |
@@ -249,13 +249,13 @@ discard block |
||
249 | 249 | * If user clicks to ignore the notice, add that to their user meta the banner then checks whether this tag exists already or not. |
250 | 250 | * See here: http://codex.wordpress.org/Function_Reference/add_user_meta |
251 | 251 | */ |
252 | - if ( isset( $_GET[ $this->nag_meta_key ] ) && '0' == $_GET[ $this->nag_meta_key ] ) { |
|
252 | + if (isset($_GET[$this->nag_meta_key]) && '0' == $_GET[$this->nag_meta_key]) { |
|
253 | 253 | |
254 | 254 | //Get the global user |
255 | 255 | $current_user = wp_get_current_user(); |
256 | 256 | $user_id = $current_user->ID; |
257 | 257 | |
258 | - add_user_meta( $user_id, $this->nag_meta_key, 'true', true ); |
|
258 | + add_user_meta($user_id, $this->nag_meta_key, 'true', true); |
|
259 | 259 | } |
260 | 260 | } |
261 | 261 | |
@@ -266,11 +266,11 @@ discard block |
||
266 | 266 | * @access private |
267 | 267 | */ |
268 | 268 | private function add_addon_activate_meta() { |
269 | - $user_id = get_option( $this->activate_by_meta_key ); |
|
269 | + $user_id = get_option($this->activate_by_meta_key); |
|
270 | 270 | $this->plugin_activate_by = (int) $user_id; |
271 | 271 | |
272 | - if ( ! $user_id ) { |
|
273 | - add_option( $this->activate_by_meta_key, $this->user_id, '', 'no' ); |
|
272 | + if ( ! $user_id) { |
|
273 | + add_option($this->activate_by_meta_key, $this->user_id, '', 'no'); |
|
274 | 274 | $this->plugin_activate_by = (int) $this->user_id; |
275 | 275 | } |
276 | 276 | } |
@@ -283,10 +283,10 @@ discard block |
||
283 | 283 | * @access public |
284 | 284 | */ |
285 | 285 | public function remove_addon_activate_meta() { |
286 | - $user_id = get_option( $this->activate_by_meta_key ); |
|
286 | + $user_id = get_option($this->activate_by_meta_key); |
|
287 | 287 | |
288 | - if ( $user_id ) { |
|
289 | - delete_option( $this->activate_by_meta_key ); |
|
288 | + if ($user_id) { |
|
289 | + delete_option($this->activate_by_meta_key); |
|
290 | 290 | } |
291 | 291 | } |
292 | 292 | |
@@ -299,31 +299,31 @@ discard block |
||
299 | 299 | * @return mixed |
300 | 300 | */ |
301 | 301 | private function get_plugin_file_name() { |
302 | - $active_plugins = get_option( 'active_plugins' ); |
|
302 | + $active_plugins = get_option('active_plugins'); |
|
303 | 303 | $file_name = ''; |
304 | 304 | |
305 | 305 | try { |
306 | 306 | |
307 | 307 | // Check addon file path. |
308 | - if ( ! empty( $this->banner_details['file'] ) ) { |
|
309 | - $file_name = explode( '/', explode( '/plugins/', $this->banner_details['file'] )[1] )[0]; |
|
308 | + if ( ! empty($this->banner_details['file'])) { |
|
309 | + $file_name = explode('/', explode('/plugins/', $this->banner_details['file'])[1])[0]; |
|
310 | 310 | |
311 | - foreach ( $active_plugins as $plugin ) { |
|
312 | - if ( false !== strpos( $plugin, $file_name ) ) { |
|
311 | + foreach ($active_plugins as $plugin) { |
|
312 | + if (false !== strpos($plugin, $file_name)) { |
|
313 | 313 | $file_name = $plugin; |
314 | 314 | break; |
315 | 315 | } |
316 | 316 | } |
317 | 317 | } else { |
318 | - throw new Exception( __( "File path must be added of {$this->banner_details['name']} addon in banner details.", 'give' ) ); |
|
318 | + throw new Exception(__("File path must be added of {$this->banner_details['name']} addon in banner details.", 'give')); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | // Check plugin path calculated by addon file path. |
322 | - if ( empty( $file_name ) ) { |
|
323 | - throw new Exception( __( "Empty Addon plugin path for {$this->banner_details['name']} addon.", 'give' ) ); |
|
322 | + if (empty($file_name)) { |
|
323 | + throw new Exception(__("Empty Addon plugin path for {$this->banner_details['name']} addon.", 'give')); |
|
324 | 324 | } |
325 | 325 | |
326 | - } catch ( Exception $e ) { |
|
326 | + } catch (Exception $e) { |
|
327 | 327 | echo $e->getMessage(); |
328 | 328 | } |
329 | 329 |
@@ -261,10 +261,10 @@ |
||
261 | 261 | $admin_message .= '<strong>' . esc_attr__( 'Amount:', 'give' ) . '</strong> {price}' . "\n\n"; |
262 | 262 | |
263 | 263 | $admin_message .= sprintf( |
264 | - '<a href="%1$s">%2$s</a>', |
|
265 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment_id ), |
|
266 | - esc_html__( 'Click Here to View and/or Update Donation Details', 'give' ) |
|
267 | - ) . "\n\n"; |
|
264 | + '<a href="%1$s">%2$s</a>', |
|
265 | + admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment_id ), |
|
266 | + esc_html__( 'Click Here to View and/or Update Donation Details', 'give' ) |
|
267 | + ) . "\n\n"; |
|
268 | 268 | |
269 | 269 | $admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id ); |
270 | 270 | $admin_message = give_do_email_tags( $admin_message, $payment_id ); |
@@ -464,7 +464,7 @@ |
||
464 | 464 | * |
465 | 465 | * @param WP_Post $payment |
466 | 466 | * |
467 | - * @return mixed |
|
467 | + * @return false|null |
|
468 | 468 | */ |
469 | 469 | function give_offline_payment_receipt_after( $payment ) { |
470 | 470 | // Get payment object. |
@@ -18,17 +18,17 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return array |
20 | 20 | */ |
21 | -function give_offline_register_gateway( $gateways ) { |
|
21 | +function give_offline_register_gateway($gateways) { |
|
22 | 22 | // Format: ID => Name |
23 | 23 | $gateways['offline'] = array( |
24 | - 'admin_label' => esc_attr__( 'Offline Donation', 'give' ), |
|
25 | - 'checkout_label' => esc_attr__( 'Offline Donation', 'give' ) |
|
24 | + 'admin_label' => esc_attr__('Offline Donation', 'give'), |
|
25 | + 'checkout_label' => esc_attr__('Offline Donation', 'give') |
|
26 | 26 | ); |
27 | 27 | |
28 | 28 | return $gateways; |
29 | 29 | } |
30 | 30 | |
31 | -add_filter( 'give_payment_gateways', 'give_offline_register_gateway', 1 ); |
|
31 | +add_filter('give_payment_gateways', 'give_offline_register_gateway', 1); |
|
32 | 32 | |
33 | 33 | |
34 | 34 | /** |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return void |
42 | 42 | */ |
43 | -function give_offline_payment_cc_form( $form_id ) { |
|
43 | +function give_offline_payment_cc_form($form_id) { |
|
44 | 44 | // Get offline payment instruction. |
45 | - $offline_instructions = give_get_offline_payment_instruction( $form_id, true ); |
|
45 | + $offline_instructions = give_get_offline_payment_instruction($form_id, true); |
|
46 | 46 | |
47 | 47 | ob_start(); |
48 | 48 | |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @param int $form_id Give form id. |
55 | 55 | */ |
56 | - do_action( 'give_before_offline_info_fields', $form_id ); |
|
56 | + do_action('give_before_offline_info_fields', $form_id); |
|
57 | 57 | ?> |
58 | 58 | <fieldset id="give_offline_payment_info"> |
59 | - <?php echo stripslashes( $offline_instructions ); ?> |
|
59 | + <?php echo stripslashes($offline_instructions); ?> |
|
60 | 60 | </fieldset> |
61 | 61 | <?php |
62 | 62 | /** |
@@ -66,35 +66,35 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @param int $form_id Give form id. |
68 | 68 | */ |
69 | - do_action( 'give_after_offline_info_fields', $form_id ); |
|
69 | + do_action('give_after_offline_info_fields', $form_id); |
|
70 | 70 | |
71 | 71 | echo ob_get_clean(); |
72 | 72 | } |
73 | 73 | |
74 | -add_action( 'give_offline_cc_form', 'give_offline_payment_cc_form' ); |
|
74 | +add_action('give_offline_cc_form', 'give_offline_payment_cc_form'); |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Give Offline Billing Field |
78 | 78 | * |
79 | 79 | * @param $form_id |
80 | 80 | */ |
81 | -function give_offline_billing_fields( $form_id ) { |
|
81 | +function give_offline_billing_fields($form_id) { |
|
82 | 82 | //Enable Default CC fields (billing info) |
83 | - $post_offline_cc_fields = get_post_meta( $form_id, '_give_offline_donation_enable_billing_fields_single', true ); |
|
84 | - $post_offline_customize_option = get_post_meta( $form_id, '_give_customize_offline_donations', true ); |
|
83 | + $post_offline_cc_fields = get_post_meta($form_id, '_give_offline_donation_enable_billing_fields_single', true); |
|
84 | + $post_offline_customize_option = get_post_meta($form_id, '_give_customize_offline_donations', true); |
|
85 | 85 | |
86 | - $global_offline_cc_fields = give_get_option( 'give_offline_donation_enable_billing_fields' ); |
|
86 | + $global_offline_cc_fields = give_get_option('give_offline_donation_enable_billing_fields'); |
|
87 | 87 | |
88 | 88 | //Output CC Address fields if global option is on and user hasn't elected to customize this form's offline donation options |
89 | 89 | if ( |
90 | - ( give_is_setting_enabled( $post_offline_customize_option, 'global' ) && give_is_setting_enabled( $global_offline_cc_fields ) ) |
|
91 | - || ( give_is_setting_enabled( $post_offline_customize_option, 'enabled' ) && give_is_setting_enabled( $post_offline_cc_fields ) ) |
|
90 | + (give_is_setting_enabled($post_offline_customize_option, 'global') && give_is_setting_enabled($global_offline_cc_fields)) |
|
91 | + || (give_is_setting_enabled($post_offline_customize_option, 'enabled') && give_is_setting_enabled($post_offline_cc_fields)) |
|
92 | 92 | ) { |
93 | - give_default_cc_address_fields( $form_id ); |
|
93 | + give_default_cc_address_fields($form_id); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
97 | -add_action( 'give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1 ); |
|
97 | +add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1); |
|
98 | 98 | |
99 | 99 | /** |
100 | 100 | * Process the payment |
@@ -105,16 +105,16 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return void |
107 | 107 | */ |
108 | -function give_offline_process_payment( $purchase_data ) { |
|
108 | +function give_offline_process_payment($purchase_data) { |
|
109 | 109 | |
110 | - $purchase_summary = give_get_purchase_summary( $purchase_data ); |
|
110 | + $purchase_summary = give_get_purchase_summary($purchase_data); |
|
111 | 111 | |
112 | 112 | // setup the payment details |
113 | 113 | $payment_data = array( |
114 | 114 | 'price' => $purchase_data['price'], |
115 | 115 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
116 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
117 | - 'give_price_id' => isset( $purchase_data['post_data']['give-price-id'] ) ? $purchase_data['post_data']['give-price-id'] : '', |
|
116 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
117 | + 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', |
|
118 | 118 | 'date' => $purchase_data['date'], |
119 | 119 | 'user_email' => $purchase_data['user_email'], |
120 | 120 | 'purchase_key' => $purchase_data['purchase_key'], |
@@ -126,20 +126,20 @@ discard block |
||
126 | 126 | |
127 | 127 | |
128 | 128 | // record the pending payment |
129 | - $payment = give_insert_payment( $payment_data ); |
|
129 | + $payment = give_insert_payment($payment_data); |
|
130 | 130 | |
131 | - if ( $payment ) { |
|
132 | - give_offline_send_admin_notice( $payment ); |
|
133 | - give_offline_send_donor_instructions( $payment ); |
|
131 | + if ($payment) { |
|
132 | + give_offline_send_admin_notice($payment); |
|
133 | + give_offline_send_donor_instructions($payment); |
|
134 | 134 | give_send_to_success_page(); |
135 | 135 | } else { |
136 | 136 | // if errors are present, send the user back to the donation form so they can be corrected |
137 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
137 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | } |
141 | 141 | |
142 | -add_action( 'give_gateway_offline', 'give_offline_process_payment' ); |
|
142 | +add_action('give_gateway_offline', 'give_offline_process_payment'); |
|
143 | 143 | |
144 | 144 | |
145 | 145 | /** |
@@ -152,59 +152,59 @@ discard block |
||
152 | 152 | * @since 1.0 |
153 | 153 | * @return void |
154 | 154 | */ |
155 | -function give_offline_send_donor_instructions( $payment_id = 0 ) { |
|
155 | +function give_offline_send_donor_instructions($payment_id = 0) { |
|
156 | 156 | |
157 | - $payment_data = give_get_payment_meta( $payment_id ); |
|
158 | - $post_offline_customization_option = get_post_meta( $payment_data['form_id'], '_give_customize_offline_donations', true ); |
|
157 | + $payment_data = give_get_payment_meta($payment_id); |
|
158 | + $post_offline_customization_option = get_post_meta($payment_data['form_id'], '_give_customize_offline_donations', true); |
|
159 | 159 | |
160 | 160 | //Customize email content depending on whether the single form has been customized |
161 | - $email_content = give_get_option( 'global_offline_donation_email' ); |
|
161 | + $email_content = give_get_option('global_offline_donation_email'); |
|
162 | 162 | |
163 | - if ( give_is_setting_enabled( $post_offline_customization_option, 'enabled' ) ) { |
|
164 | - $email_content = get_post_meta( $payment_data['form_id'], '_give_offline_donation_email', true ); |
|
163 | + if (give_is_setting_enabled($post_offline_customization_option, 'enabled')) { |
|
164 | + $email_content = get_post_meta($payment_data['form_id'], '_give_offline_donation_email', true); |
|
165 | 165 | } |
166 | 166 | |
167 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
167 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
168 | 168 | |
169 | 169 | /** |
170 | 170 | * Filters the from name. |
171 | 171 | * |
172 | 172 | * @since 1.7 |
173 | 173 | */ |
174 | - $from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data ); |
|
174 | + $from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data); |
|
175 | 175 | |
176 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
176 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
177 | 177 | |
178 | 178 | /** |
179 | 179 | * Filters the from email. |
180 | 180 | * |
181 | 181 | * @since 1.7 |
182 | 182 | */ |
183 | - $from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data ); |
|
183 | + $from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data); |
|
184 | 184 | |
185 | - $to_email = give_get_payment_user_email( $payment_id ); |
|
185 | + $to_email = give_get_payment_user_email($payment_id); |
|
186 | 186 | |
187 | - $subject = give_get_option( 'offline_donation_subject', esc_html__( 'Offline Donation Instructions', 'give' ) ); |
|
188 | - if ( give_is_setting_enabled( $post_offline_customization_option, 'enabled' ) ) { |
|
189 | - $subject = get_post_meta( $payment_data['form_id'], '_give_offline_donation_subject', true ); |
|
187 | + $subject = give_get_option('offline_donation_subject', esc_html__('Offline Donation Instructions', 'give')); |
|
188 | + if (give_is_setting_enabled($post_offline_customization_option, 'enabled')) { |
|
189 | + $subject = get_post_meta($payment_data['form_id'], '_give_offline_donation_subject', true); |
|
190 | 190 | } |
191 | 191 | |
192 | - $subject = apply_filters( 'give_offline_donation_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
193 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
192 | + $subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id); |
|
193 | + $subject = give_do_email_tags($subject, $payment_id); |
|
194 | 194 | |
195 | - $attachments = apply_filters( 'give_offline_donation_attachments', array(), $payment_id, $payment_data ); |
|
196 | - $message = give_do_email_tags( $email_content, $payment_id ); |
|
195 | + $attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data); |
|
196 | + $message = give_do_email_tags($email_content, $payment_id); |
|
197 | 197 | |
198 | 198 | $emails = Give()->emails; |
199 | 199 | |
200 | - $emails->__set( 'from_name', $from_name ); |
|
201 | - $emails->__set( 'from_email', $from_email ); |
|
202 | - $emails->__set( 'heading', esc_html__( 'Offline Donation Instructions', 'give' ) ); |
|
200 | + $emails->__set('from_name', $from_name); |
|
201 | + $emails->__set('from_email', $from_email); |
|
202 | + $emails->__set('heading', esc_html__('Offline Donation Instructions', 'give')); |
|
203 | 203 | |
204 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data ); |
|
205 | - $emails->__set( 'headers', $headers ); |
|
204 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); |
|
205 | + $emails->__set('headers', $headers); |
|
206 | 206 | |
207 | - $emails->send( $to_email, $subject, $message, $attachments ); |
|
207 | + $emails->send($to_email, $subject, $message, $attachments); |
|
208 | 208 | |
209 | 209 | } |
210 | 210 | |
@@ -221,52 +221,52 @@ discard block |
||
221 | 221 | * @return void |
222 | 222 | * |
223 | 223 | */ |
224 | -function give_offline_send_admin_notice( $payment_id = 0 ) { |
|
224 | +function give_offline_send_admin_notice($payment_id = 0) { |
|
225 | 225 | |
226 | 226 | /* Send an email notification to the admin */ |
227 | 227 | $admin_email = give_get_admin_notice_emails(); |
228 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
228 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
229 | 229 | |
230 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) { |
|
231 | - $user_data = get_userdata( $user_info['id'] ); |
|
230 | + if (isset($user_info['id']) && $user_info['id'] > 0) { |
|
231 | + $user_data = get_userdata($user_info['id']); |
|
232 | 232 | $name = $user_data->display_name; |
233 | - } elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) { |
|
234 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
233 | + } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { |
|
234 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
235 | 235 | } else { |
236 | 236 | $name = $user_info['email']; |
237 | 237 | } |
238 | 238 | |
239 | - $amount = give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ); |
|
239 | + $amount = give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))); |
|
240 | 240 | |
241 | - $admin_subject = apply_filters( 'give_offline_admin_donation_notification_subject', esc_attr__( 'New Pending Donation', 'give' ), $payment_id ); |
|
241 | + $admin_subject = apply_filters('give_offline_admin_donation_notification_subject', esc_attr__('New Pending Donation', 'give'), $payment_id); |
|
242 | 242 | |
243 | - $admin_message = esc_attr__( 'Dear Admin,', 'give' ) . "\n\n"; |
|
244 | - $admin_message .= esc_attr__( 'An offline donation has been made on your website:', 'give' ) . ' ' . get_bloginfo( 'name' ) . ' '; |
|
245 | - $admin_message .= esc_attr__( 'Hooray! The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give' ) . "\n\n"; |
|
243 | + $admin_message = esc_attr__('Dear Admin,', 'give')."\n\n"; |
|
244 | + $admin_message .= esc_attr__('An offline donation has been made on your website:', 'give').' '.get_bloginfo('name').' '; |
|
245 | + $admin_message .= esc_attr__('Hooray! The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give')."\n\n"; |
|
246 | 246 | |
247 | 247 | |
248 | - $admin_message .= '<strong>' . esc_attr__( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n"; |
|
249 | - $admin_message .= '<strong>' . esc_attr__( 'Amount:', 'give' ) . '</strong> {amount}' . "\n\n"; |
|
248 | + $admin_message .= '<strong>'.esc_attr__('Donor:', 'give').'</strong> {fullname}'."\n"; |
|
249 | + $admin_message .= '<strong>'.esc_attr__('Amount:', 'give').'</strong> {amount}'."\n\n"; |
|
250 | 250 | |
251 | 251 | $admin_message .= sprintf( |
252 | 252 | '<a href="%1$s">%2$s</a>', |
253 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment_id ), |
|
254 | - esc_html__( 'Click Here to View and/or Update Donation Details', 'give' ) |
|
255 | - ) . "\n\n"; |
|
253 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$payment_id), |
|
254 | + esc_html__('Click Here to View and/or Update Donation Details', 'give') |
|
255 | + )."\n\n"; |
|
256 | 256 | |
257 | - $admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id ); |
|
258 | - $admin_message = give_do_email_tags( $admin_message, $payment_id ); |
|
257 | + $admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id); |
|
258 | + $admin_message = give_do_email_tags($admin_message, $payment_id); |
|
259 | 259 | |
260 | - $attachments = apply_filters( 'give_offline_admin_donation_notification_attachments', array(), $payment_id ); |
|
261 | - $admin_headers = apply_filters( 'give_offline_admin_donation_notification_headers', array(), $payment_id ); |
|
260 | + $attachments = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id); |
|
261 | + $admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id); |
|
262 | 262 | |
263 | 263 | //Send Email |
264 | 264 | $emails = Give()->emails; |
265 | - if ( ! empty( $admin_headers ) ) { |
|
266 | - $emails->__set( 'headers', $admin_headers ); |
|
265 | + if ( ! empty($admin_headers)) { |
|
266 | + $emails->__set('headers', $admin_headers); |
|
267 | 267 | } |
268 | 268 | |
269 | - $emails->send( $admin_email, $admin_subject, $admin_message, $attachments ); |
|
269 | + $emails->send($admin_email, $admin_subject, $admin_message, $attachments); |
|
270 | 270 | |
271 | 271 | } |
272 | 272 | |
@@ -278,15 +278,15 @@ discard block |
||
278 | 278 | * |
279 | 279 | * @return array |
280 | 280 | */ |
281 | -function give_offline_add_settings( $settings ) { |
|
281 | +function give_offline_add_settings($settings) { |
|
282 | 282 | |
283 | 283 | //Vars |
284 | 284 | $prefix = '_give_'; |
285 | 285 | |
286 | - $is_gateway_active = give_is_gateway_active( 'offline' ); |
|
286 | + $is_gateway_active = give_is_gateway_active('offline'); |
|
287 | 287 | |
288 | 288 | //this gateway isn't active |
289 | - if ( ! $is_gateway_active ) { |
|
289 | + if ( ! $is_gateway_active) { |
|
290 | 290 | //return settings and bounce |
291 | 291 | return $settings; |
292 | 292 | } |
@@ -295,34 +295,34 @@ discard block |
||
295 | 295 | $check_settings = array( |
296 | 296 | |
297 | 297 | array( |
298 | - 'name' => esc_attr__( 'Offline Donations', 'give' ), |
|
299 | - 'desc' => esc_attr__( 'Do you want to customize the donation instructions for this form?', 'give' ), |
|
300 | - 'id' => $prefix . 'customize_offline_donations', |
|
298 | + 'name' => esc_attr__('Offline Donations', 'give'), |
|
299 | + 'desc' => esc_attr__('Do you want to customize the donation instructions for this form?', 'give'), |
|
300 | + 'id' => $prefix.'customize_offline_donations', |
|
301 | 301 | 'type' => 'radio_inline', |
302 | 302 | 'default' => 'global', |
303 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
304 | - 'global' => esc_html__( 'Global Options', 'give' ), |
|
305 | - 'enabled' => esc_html__( 'Customize', 'give' ), |
|
306 | - 'disabled' => esc_html__( 'Disable', 'give' ), |
|
303 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
304 | + 'global' => esc_html__('Global Options', 'give'), |
|
305 | + 'enabled' => esc_html__('Customize', 'give'), |
|
306 | + 'disabled' => esc_html__('Disable', 'give'), |
|
307 | 307 | ) |
308 | 308 | ), |
309 | 309 | ), |
310 | 310 | array( |
311 | - 'name' => esc_attr__( 'Billing Fields', 'give' ), |
|
312 | - 'desc' => esc_attr__( 'This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give' ), |
|
313 | - 'id' => $prefix . 'offline_donation_enable_billing_fields_single', |
|
311 | + 'name' => esc_attr__('Billing Fields', 'give'), |
|
312 | + 'desc' => esc_attr__('This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give'), |
|
313 | + 'id' => $prefix.'offline_donation_enable_billing_fields_single', |
|
314 | 314 | 'row_classes' => 'give-subfield', |
315 | 315 | 'type' => 'radio_inline', |
316 | 316 | 'default' => 'disabled', |
317 | 317 | 'options' => array( |
318 | - 'enabled' => esc_html__( 'Enabled', 'give' ), |
|
319 | - 'disabled' => esc_html__( 'Disabled', 'give' ), |
|
318 | + 'enabled' => esc_html__('Enabled', 'give'), |
|
319 | + 'disabled' => esc_html__('Disabled', 'give'), |
|
320 | 320 | ), |
321 | 321 | ), |
322 | 322 | array( |
323 | - 'id' => $prefix . 'offline_checkout_notes', |
|
324 | - 'name' => esc_attr__( 'Donation Instructions', 'give' ), |
|
325 | - 'desc' => esc_attr__( 'Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
323 | + 'id' => $prefix.'offline_checkout_notes', |
|
324 | + 'name' => esc_attr__('Donation Instructions', 'give'), |
|
325 | + 'desc' => esc_attr__('Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
326 | 326 | 'default' => give_get_default_offline_donation_content(), |
327 | 327 | 'type' => 'wysiwyg', |
328 | 328 | 'row_classes' => 'give-subfield', |
@@ -331,17 +331,17 @@ discard block |
||
331 | 331 | ) |
332 | 332 | ), |
333 | 333 | array( |
334 | - 'id' => $prefix . 'offline_donation_subject', |
|
335 | - 'name' => esc_attr__( 'Email Subject', 'give' ), |
|
336 | - 'desc' => esc_attr__( 'Enter the subject line for the donation receipt email.', 'give' ), |
|
337 | - 'default' => esc_attr__( '{form_title} - Offline Donation Instructions', 'give' ), |
|
334 | + 'id' => $prefix.'offline_donation_subject', |
|
335 | + 'name' => esc_attr__('Email Subject', 'give'), |
|
336 | + 'desc' => esc_attr__('Enter the subject line for the donation receipt email.', 'give'), |
|
337 | + 'default' => esc_attr__('{form_title} - Offline Donation Instructions', 'give'), |
|
338 | 338 | 'row_classes' => 'give-subfield', |
339 | 339 | 'type' => 'text' |
340 | 340 | ), |
341 | 341 | array( |
342 | - 'id' => $prefix . 'offline_donation_email', |
|
343 | - 'name' => esc_attr__( 'Email Instructions', 'give' ), |
|
344 | - 'desc' => esc_attr__( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
342 | + 'id' => $prefix.'offline_donation_email', |
|
343 | + 'name' => esc_attr__('Email Instructions', 'give'), |
|
344 | + 'desc' => esc_attr__('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
345 | 345 | 'default' => give_get_default_offline_donation_email_content(), |
346 | 346 | 'type' => 'wysiwyg', |
347 | 347 | 'row_classes' => 'give-subfield', |
@@ -351,10 +351,10 @@ discard block |
||
351 | 351 | ) |
352 | 352 | ); |
353 | 353 | |
354 | - return array_merge( $settings, $check_settings ); |
|
354 | + return array_merge($settings, $check_settings); |
|
355 | 355 | } |
356 | 356 | |
357 | -add_filter( 'give_forms_offline_donations_metabox_fields', 'give_offline_add_settings' ); |
|
357 | +add_filter('give_forms_offline_donations_metabox_fields', 'give_offline_add_settings'); |
|
358 | 358 | |
359 | 359 | |
360 | 360 | /** |
@@ -366,32 +366,32 @@ discard block |
||
366 | 366 | */ |
367 | 367 | function give_get_default_offline_donation_content() { |
368 | 368 | |
369 | - $sitename = get_bloginfo( 'sitename' ); |
|
369 | + $sitename = get_bloginfo('sitename'); |
|
370 | 370 | |
371 | - $default_text = '<p>' . esc_attr__( 'In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>'; |
|
371 | + $default_text = '<p>'.esc_attr__('In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>'; |
|
372 | 372 | $default_text .= '<ol>'; |
373 | 373 | $default_text .= '<li>'; |
374 | 374 | $default_text .= sprintf( |
375 | 375 | /* translators: %s: site name */ |
376 | - esc_html__( 'Make a check payable to "%s"', 'give' ), |
|
376 | + esc_html__('Make a check payable to "%s"', 'give'), |
|
377 | 377 | $sitename |
378 | 378 | ); |
379 | 379 | $default_text .= '</li>'; |
380 | 380 | $default_text .= '<li>'; |
381 | 381 | $default_text .= sprintf( |
382 | 382 | /* translators: %s: site name */ |
383 | - esc_html__( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
383 | + esc_html__('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
384 | 384 | $sitename |
385 | 385 | ); |
386 | 386 | $default_text .= '</li>'; |
387 | - $default_text .= '<li>' . esc_html__( 'Please mail your check to:', 'give' ) . '</li>'; |
|
387 | + $default_text .= '<li>'.esc_html__('Please mail your check to:', 'give').'</li>'; |
|
388 | 388 | $default_text .= '</ol>'; |
389 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
389 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
390 | 390 | $default_text .= ' <em>123 G Street </em><br>'; |
391 | 391 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
392 | - $default_text .= '<p>' . esc_attr__( 'All contributions will be gratefully acknowledged and are tax deductible.', 'give' ) . '</p>'; |
|
392 | + $default_text .= '<p>'.esc_attr__('All contributions will be gratefully acknowledged and are tax deductible.', 'give').'</p>'; |
|
393 | 393 | |
394 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
394 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
395 | 395 | |
396 | 396 | } |
397 | 397 | |
@@ -404,34 +404,34 @@ discard block |
||
404 | 404 | */ |
405 | 405 | function give_get_default_offline_donation_email_content() { |
406 | 406 | |
407 | - $sitename = get_bloginfo( 'sitename' ); |
|
408 | - $default_text = '<p>' . esc_html__( 'Dear {name},', 'give' ) . '</p>'; |
|
409 | - $default_text .= '<p>' . esc_html__( 'Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give' ) . '</p>'; |
|
407 | + $sitename = get_bloginfo('sitename'); |
|
408 | + $default_text = '<p>'.esc_html__('Dear {name},', 'give').'</p>'; |
|
409 | + $default_text .= '<p>'.esc_html__('Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give').'</p>'; |
|
410 | 410 | $default_text .= '<ol>'; |
411 | 411 | $default_text .= '<li>'; |
412 | 412 | $default_text .= sprintf( |
413 | 413 | /* translators: %s: site name */ |
414 | - esc_html__( 'Make a check payable to "%s"', 'give' ), |
|
414 | + esc_html__('Make a check payable to "%s"', 'give'), |
|
415 | 415 | $sitename |
416 | 416 | ); |
417 | 417 | $default_text .= '</li>'; |
418 | 418 | $default_text .= '<li>'; |
419 | 419 | $default_text .= sprintf( |
420 | 420 | /* translators: %s: site name */ |
421 | - esc_html__( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
421 | + esc_html__('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
422 | 422 | $sitename |
423 | 423 | ); |
424 | 424 | $default_text .= '</li>'; |
425 | - $default_text .= '<li>' . esc_html__( 'Please mail your check to:', 'give' ) . '</li>'; |
|
425 | + $default_text .= '<li>'.esc_html__('Please mail your check to:', 'give').'</li>'; |
|
426 | 426 | $default_text .= '</ol>'; |
427 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
427 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
428 | 428 | $default_text .= ' <em>123 G Street </em><br>'; |
429 | 429 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
430 | - $default_text .= '<p>' . esc_html__( 'Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give' ) . '</p>'; |
|
431 | - $default_text .= '<p>' . esc_html__( 'Sincerely,', 'give' ) . '</p>'; |
|
432 | - $default_text .= '<p>' . $sitename . '</p>'; |
|
430 | + $default_text .= '<p>'.esc_html__('Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give').'</p>'; |
|
431 | + $default_text .= '<p>'.esc_html__('Sincerely,', 'give').'</p>'; |
|
432 | + $default_text .= '<p>'.$sitename.'</p>'; |
|
433 | 433 | |
434 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
434 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
435 | 435 | |
436 | 436 | } |
437 | 437 | |
@@ -445,17 +445,17 @@ discard block |
||
445 | 445 | * |
446 | 446 | * @return string |
447 | 447 | */ |
448 | -function give_offline_donation_receipt_status_notice( $notice, $id ) { |
|
449 | - $payment = new Give_Payment( $id ); |
|
448 | +function give_offline_donation_receipt_status_notice($notice, $id) { |
|
449 | + $payment = new Give_Payment($id); |
|
450 | 450 | |
451 | - if ( 'offline' !== $payment->gateway ) { |
|
451 | + if ('offline' !== $payment->gateway) { |
|
452 | 452 | return $notice; |
453 | 453 | } |
454 | 454 | |
455 | - return give_output_error( 'Payment Pending: Please follow the instructions below to complete your donation.', false, 'warning' ); |
|
455 | + return give_output_error('Payment Pending: Please follow the instructions below to complete your donation.', false, 'warning'); |
|
456 | 456 | } |
457 | 457 | |
458 | -add_filter( 'give_receipt_status_notice', 'give_offline_donation_receipt_status_notice', 10, 2 ); |
|
458 | +add_filter('give_receipt_status_notice', 'give_offline_donation_receipt_status_notice', 10, 2); |
|
459 | 459 | |
460 | 460 | /** |
461 | 461 | * Add offline payment instruction on payment receipt. |
@@ -466,26 +466,26 @@ discard block |
||
466 | 466 | * |
467 | 467 | * @return mixed |
468 | 468 | */ |
469 | -function give_offline_payment_receipt_after( $payment ) { |
|
469 | +function give_offline_payment_receipt_after($payment) { |
|
470 | 470 | // Get payment object. |
471 | - $payment = new Give_Payment( $payment->ID ); |
|
471 | + $payment = new Give_Payment($payment->ID); |
|
472 | 472 | |
473 | 473 | // Bailout. |
474 | - if ( 'offline' !== $payment->gateway ) { |
|
474 | + if ('offline' !== $payment->gateway) { |
|
475 | 475 | return false; |
476 | 476 | } |
477 | 477 | |
478 | 478 | ?> |
479 | 479 | <tr> |
480 | - <td scope="row"><strong><?php esc_html_e( 'Offline Payment Instruction:', 'give' ); ?></strong></td> |
|
480 | + <td scope="row"><strong><?php esc_html_e('Offline Payment Instruction:', 'give'); ?></strong></td> |
|
481 | 481 | <td> |
482 | - <?php echo give_get_offline_payment_instruction( $payment->form_id, true ); ?> |
|
482 | + <?php echo give_get_offline_payment_instruction($payment->form_id, true); ?> |
|
483 | 483 | </td> |
484 | 484 | </tr> |
485 | 485 | <?php |
486 | 486 | } |
487 | 487 | |
488 | -add_filter( 'give_payment_receipt_after', 'give_offline_payment_receipt_after' ); |
|
488 | +add_filter('give_payment_receipt_after', 'give_offline_payment_receipt_after'); |
|
489 | 489 | |
490 | 490 | /** |
491 | 491 | * Get offline payment instructions. |
@@ -497,27 +497,27 @@ discard block |
||
497 | 497 | * |
498 | 498 | * @return string |
499 | 499 | */ |
500 | -function give_get_offline_payment_instruction( $form_id, $wpautop = false ) { |
|
500 | +function give_get_offline_payment_instruction($form_id, $wpautop = false) { |
|
501 | 501 | // Bailout. |
502 | - if ( ! $form_id ) { |
|
502 | + if ( ! $form_id) { |
|
503 | 503 | return ''; |
504 | 504 | } |
505 | 505 | |
506 | - $post_offline_customization_option = get_post_meta( $form_id, '_give_customize_offline_donations', true ); |
|
507 | - $post_offline_instructions = get_post_meta( $form_id, '_give_offline_checkout_notes', true ); |
|
508 | - $global_offline_instruction = give_get_option( 'global_offline_donation_content' ); |
|
506 | + $post_offline_customization_option = get_post_meta($form_id, '_give_customize_offline_donations', true); |
|
507 | + $post_offline_instructions = get_post_meta($form_id, '_give_offline_checkout_notes', true); |
|
508 | + $global_offline_instruction = give_get_option('global_offline_donation_content'); |
|
509 | 509 | $offline_instructions = $global_offline_instruction; |
510 | 510 | |
511 | - if ( $post_offline_customization_option == 'yes' ) { |
|
511 | + if ($post_offline_customization_option == 'yes') { |
|
512 | 512 | $offline_instructions = $post_offline_instructions; |
513 | 513 | } |
514 | 514 | |
515 | - $settings_url = admin_url( 'post.php?post=' . $form_id . '&action=edit&message=1' ); |
|
515 | + $settings_url = admin_url('post.php?post='.$form_id.'&action=edit&message=1'); |
|
516 | 516 | |
517 | 517 | /* translators: %s: form settings url */ |
518 | - $offline_instructions = ! empty( $offline_instructions ) ? $offline_instructions : sprintf( __( 'Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give' ), $settings_url ); |
|
518 | + $offline_instructions = ! empty($offline_instructions) ? $offline_instructions : sprintf(__('Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give'), $settings_url); |
|
519 | 519 | |
520 | - return ( $wpautop ? wpautop( $offline_instructions ) : $offline_instructions ); |
|
520 | + return ($wpautop ? wpautop($offline_instructions) : $offline_instructions); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | |
@@ -531,16 +531,16 @@ discard block |
||
531 | 531 | * |
532 | 532 | * @return array |
533 | 533 | */ |
534 | -function give_filter_offline_gateway( $gateway_list, $form_id ) { |
|
535 | - if ( $form_id && ! give_is_setting_enabled( get_post_meta( $form_id, '_give_customize_offline_donations', true ), array( 'enabled', 'global' ) ) ) { |
|
536 | - unset( $gateway_list['offline'] ); |
|
534 | +function give_filter_offline_gateway($gateway_list, $form_id) { |
|
535 | + if ($form_id && ! give_is_setting_enabled(get_post_meta($form_id, '_give_customize_offline_donations', true), array('enabled', 'global'))) { |
|
536 | + unset($gateway_list['offline']); |
|
537 | 537 | } |
538 | 538 | |
539 | 539 | // Output. |
540 | 540 | return $gateway_list; |
541 | 541 | } |
542 | 542 | |
543 | -add_filter( 'give_enabled_payment_gateways', 'give_filter_offline_gateway', 10, 2 ); |
|
543 | +add_filter('give_enabled_payment_gateways', 'give_filter_offline_gateway', 10, 2); |
|
544 | 544 | |
545 | 545 | /** |
546 | 546 | * Set default gateway to global default payment gateway |
@@ -554,10 +554,10 @@ discard block |
||
554 | 554 | * |
555 | 555 | * @return void |
556 | 556 | */ |
557 | -function _give_customize_offline_donations_on_save_callback( $meta_key, $meta_value, $postid ) { |
|
558 | - if ( ( 'no' === $meta_value ) && ( 'offline' === get_post_meta( $postid, '_give_default_gateway', true ) ) ) { |
|
559 | - update_post_meta( $postid, '_give_default_gateway', 'global' ); |
|
557 | +function _give_customize_offline_donations_on_save_callback($meta_key, $meta_value, $postid) { |
|
558 | + if (('no' === $meta_value) && ('offline' === get_post_meta($postid, '_give_default_gateway', true))) { |
|
559 | + update_post_meta($postid, '_give_default_gateway', 'global'); |
|
560 | 560 | } |
561 | 561 | } |
562 | 562 | |
563 | -add_filter( 'give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3 ); |
|
563 | +add_filter('give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -26,28 +26,28 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return void |
28 | 28 | */ |
29 | -function give_set_settings_with_disable_prefix( $settings, $option_name ) { |
|
29 | +function give_set_settings_with_disable_prefix($settings, $option_name) { |
|
30 | 30 | // Get old setting names. |
31 | 31 | $old_settings = give_v18_renamed_core_settings(); |
32 | 32 | $update_setting = false; |
33 | 33 | |
34 | - foreach ( $settings as $key => $value ) { |
|
34 | + foreach ($settings as $key => $value) { |
|
35 | 35 | |
36 | 36 | // Check 1. Check if new option is really updated or not. |
37 | 37 | // Check 2. Continue if key is not renamed. |
38 | 38 | if ( |
39 | - ! isset( $_POST[ $key ] ) |
|
40 | - || false === ( $old_setting_name = array_search( $key, $old_settings ) ) |
|
39 | + ! isset($_POST[$key]) |
|
40 | + || false === ($old_setting_name = array_search($key, $old_settings)) |
|
41 | 41 | ) { |
42 | 42 | continue; |
43 | 43 | } |
44 | 44 | |
45 | 45 | // Set old setting. |
46 | - $settings[ $old_setting_name ] = 'on'; |
|
46 | + $settings[$old_setting_name] = 'on'; |
|
47 | 47 | |
48 | 48 | // Do not need to set old setting if new setting is not set. |
49 | - if ( give_is_setting_enabled( $value ) ) { |
|
50 | - unset( $settings[ $old_setting_name ] ); |
|
49 | + if (give_is_setting_enabled($value)) { |
|
50 | + unset($settings[$old_setting_name]); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | // Tell bot to update setting. |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | // Update setting if any old setting set. |
58 | - if ( $update_setting ) { |
|
59 | - update_option( $option_name, $settings ); |
|
58 | + if ($update_setting) { |
|
59 | + update_option($option_name, $settings); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | -add_filter( 'give_save_settings_give_settings', 'give_set_settings_with_disable_prefix', 10, 2 ); |
|
63 | +add_filter('give_save_settings_give_settings', 'give_set_settings_with_disable_prefix', 10, 2); |
@@ -37,7 +37,7 @@ |
||
37 | 37 | * |
38 | 38 | * Display admin bar when active |
39 | 39 | * |
40 | - * @return bool |
|
40 | + * @return false|null |
|
41 | 41 | */ |
42 | 42 | public function give_admin_bar_menu() { |
43 | 43 | global $wp_admin_bar; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function __setup_hooks() { |
45 | 45 | // Create the log post type |
46 | - add_action( 'init', array( $this, 'register_post_type' ), 1 ); |
|
46 | + add_action('init', array($this, 'register_post_type'), 1); |
|
47 | 47 | |
48 | 48 | // Create types taxonomy and default types |
49 | - add_action( 'init', array( $this, 'register_taxonomy' ), 1 ); |
|
49 | + add_action('init', array($this, 'register_taxonomy'), 1); |
|
50 | 50 | |
51 | - add_action( 'save_post_give_payment', array( $this, 'background_process_delete_cache') ); |
|
52 | - add_action( 'save_post_give_forms', array( $this, 'background_process_delete_cache') ); |
|
53 | - add_action( 'save_post_give_log', array( $this, 'background_process_delete_cache') ); |
|
54 | - add_action( 'give_delete_log_cache', array( $this, 'delete_cache') ); |
|
51 | + add_action('save_post_give_payment', array($this, 'background_process_delete_cache')); |
|
52 | + add_action('save_post_give_forms', array($this, 'background_process_delete_cache')); |
|
53 | + add_action('save_post_give_log', array($this, 'background_process_delete_cache')); |
|
54 | + add_action('give_delete_log_cache', array($this, 'delete_cache')); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | public function register_post_type() { |
68 | 68 | /* Logs post type */ |
69 | 69 | $log_args = array( |
70 | - 'labels' => array( 'name' => esc_html__( 'Logs', 'give' ) ), |
|
70 | + 'labels' => array('name' => esc_html__('Logs', 'give')), |
|
71 | 71 | 'public' => false, |
72 | 72 | 'exclude_from_search' => true, |
73 | 73 | 'publicly_queryable' => false, |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | 'query_var' => false, |
76 | 76 | 'rewrite' => false, |
77 | 77 | 'capability_type' => 'post', |
78 | - 'supports' => array( 'title', 'editor' ), |
|
78 | + 'supports' => array('title', 'editor'), |
|
79 | 79 | 'can_export' => true, |
80 | 80 | ); |
81 | 81 | |
82 | - register_post_type( 'give_log', $log_args ); |
|
82 | + register_post_type('give_log', $log_args); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @return void |
94 | 94 | */ |
95 | 95 | public function register_taxonomy() { |
96 | - register_taxonomy( 'give_log_type', 'give_log', array( 'public' => false ) ); |
|
96 | + register_taxonomy('give_log_type', 'give_log', array('public' => false)); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | 'api_request', |
114 | 114 | ); |
115 | 115 | |
116 | - return apply_filters( 'give_log_types', $terms ); |
|
116 | + return apply_filters('give_log_types', $terms); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return bool Whether log type is valid. |
130 | 130 | */ |
131 | - public function valid_type( $type ) { |
|
132 | - return in_array( $type, $this->log_types() ); |
|
131 | + public function valid_type($type) { |
|
132 | + return in_array($type, $this->log_types()); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return int Log ID. |
150 | 150 | */ |
151 | - public function add( $title = '', $message = '', $parent = 0, $type = null ) { |
|
151 | + public function add($title = '', $message = '', $parent = 0, $type = null) { |
|
152 | 152 | $log_data = array( |
153 | 153 | 'post_title' => $title, |
154 | 154 | 'post_content' => $message, |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | 'log_type' => $type, |
157 | 157 | ); |
158 | 158 | |
159 | - return $this->insert_log( $log_data ); |
|
159 | + return $this->insert_log($log_data); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -173,12 +173,12 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @return array An array of the connected logs. |
175 | 175 | */ |
176 | - public function get_logs( $object_id = 0, $type = null, $paged = null ) { |
|
177 | - return $this->get_connected_logs( array( |
|
176 | + public function get_logs($object_id = 0, $type = null, $paged = null) { |
|
177 | + return $this->get_connected_logs(array( |
|
178 | 178 | 'post_parent' => $object_id, |
179 | 179 | 'paged' => $paged, |
180 | 180 | 'log_type' => $type, |
181 | - ) ); |
|
181 | + )); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * |
193 | 193 | * @return int The ID of the newly created log item. |
194 | 194 | */ |
195 | - public function insert_log( $log_data = array(), $log_meta = array() ) { |
|
195 | + public function insert_log($log_data = array(), $log_meta = array()) { |
|
196 | 196 | $defaults = array( |
197 | 197 | 'post_type' => 'give_log', |
198 | 198 | 'post_status' => 'publish', |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | 'log_type' => false, |
202 | 202 | ); |
203 | 203 | |
204 | - $args = wp_parse_args( $log_data, $defaults ); |
|
204 | + $args = wp_parse_args($log_data, $defaults); |
|
205 | 205 | |
206 | 206 | /** |
207 | 207 | * Fires before inserting log entry. |
@@ -211,20 +211,20 @@ discard block |
||
211 | 211 | * @param array $log_data Log entry data. |
212 | 212 | * @param array $log_meta Log entry meta. |
213 | 213 | */ |
214 | - do_action( 'give_pre_insert_log', $log_data, $log_meta ); |
|
214 | + do_action('give_pre_insert_log', $log_data, $log_meta); |
|
215 | 215 | |
216 | 216 | // Store the log entry |
217 | - $log_id = wp_insert_post( $args ); |
|
217 | + $log_id = wp_insert_post($args); |
|
218 | 218 | |
219 | 219 | // Set the log type, if any |
220 | - if ( $log_data['log_type'] && $this->valid_type( $log_data['log_type'] ) ) { |
|
221 | - wp_set_object_terms( $log_id, $log_data['log_type'], 'give_log_type', false ); |
|
220 | + if ($log_data['log_type'] && $this->valid_type($log_data['log_type'])) { |
|
221 | + wp_set_object_terms($log_id, $log_data['log_type'], 'give_log_type', false); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | // Set log meta, if any |
225 | - if ( $log_id && ! empty( $log_meta ) ) { |
|
226 | - foreach ( (array) $log_meta as $key => $meta ) { |
|
227 | - update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta ); |
|
225 | + if ($log_id && ! empty($log_meta)) { |
|
226 | + foreach ((array) $log_meta as $key => $meta) { |
|
227 | + update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta); |
|
228 | 228 | } |
229 | 229 | } |
230 | 230 | |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * @param array $log_data Log entry data. |
238 | 238 | * @param array $log_meta Log entry meta. |
239 | 239 | */ |
240 | - do_action( 'give_post_insert_log', $log_id, $log_data, $log_meta ); |
|
240 | + do_action('give_post_insert_log', $log_id, $log_data, $log_meta); |
|
241 | 241 | |
242 | 242 | return $log_id; |
243 | 243 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return bool|null True if successful, false otherwise. |
255 | 255 | */ |
256 | - public function update_log( $log_data = array(), $log_meta = array() ) { |
|
256 | + public function update_log($log_data = array(), $log_meta = array()) { |
|
257 | 257 | |
258 | 258 | /** |
259 | 259 | * Fires before updating log entry. |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | * @param array $log_data Log entry data. |
264 | 264 | * @param array $log_meta Log entry meta. |
265 | 265 | */ |
266 | - do_action( 'give_pre_update_log', $log_data, $log_meta ); |
|
266 | + do_action('give_pre_update_log', $log_data, $log_meta); |
|
267 | 267 | |
268 | 268 | $defaults = array( |
269 | 269 | 'post_type' => 'give_log', |
@@ -271,15 +271,15 @@ discard block |
||
271 | 271 | 'post_parent' => 0, |
272 | 272 | ); |
273 | 273 | |
274 | - $args = wp_parse_args( $log_data, $defaults ); |
|
274 | + $args = wp_parse_args($log_data, $defaults); |
|
275 | 275 | |
276 | 276 | // Store the log entry |
277 | - $log_id = wp_update_post( $args ); |
|
277 | + $log_id = wp_update_post($args); |
|
278 | 278 | |
279 | - if ( $log_id && ! empty( $log_meta ) ) { |
|
280 | - foreach ( (array) $log_meta as $key => $meta ) { |
|
281 | - if ( ! empty( $meta ) ) { |
|
282 | - update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta ); |
|
279 | + if ($log_id && ! empty($log_meta)) { |
|
280 | + foreach ((array) $log_meta as $key => $meta) { |
|
281 | + if ( ! empty($meta)) { |
|
282 | + update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta); |
|
283 | 283 | } |
284 | 284 | } |
285 | 285 | } |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * @param array $log_data Log entry data. |
294 | 294 | * @param array $log_meta Log entry meta. |
295 | 295 | */ |
296 | - do_action( 'give_post_update_log', $log_id, $log_data, $log_meta ); |
|
296 | + do_action('give_post_update_log', $log_id, $log_data, $log_meta); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | /** |
@@ -308,19 +308,19 @@ discard block |
||
308 | 308 | * |
309 | 309 | * @return array|false Array if logs were found, false otherwise. |
310 | 310 | */ |
311 | - public function get_connected_logs( $args = array() ) { |
|
311 | + public function get_connected_logs($args = array()) { |
|
312 | 312 | |
313 | 313 | $defaults = array( |
314 | 314 | 'post_type' => 'give_log', |
315 | 315 | 'posts_per_page' => 20, |
316 | 316 | 'post_status' => 'publish', |
317 | - 'paged' => get_query_var( 'paged' ), |
|
317 | + 'paged' => get_query_var('paged'), |
|
318 | 318 | 'log_type' => false, |
319 | 319 | ); |
320 | 320 | |
321 | - $query_args = wp_parse_args( $args, $defaults ); |
|
321 | + $query_args = wp_parse_args($args, $defaults); |
|
322 | 322 | |
323 | - if ( $query_args['log_type'] && $this->valid_type( $query_args['log_type'] ) ) { |
|
323 | + if ($query_args['log_type'] && $this->valid_type($query_args['log_type'])) { |
|
324 | 324 | $query_args['tax_query'] = array( |
325 | 325 | array( |
326 | 326 | 'taxonomy' => 'give_log_type', |
@@ -330,9 +330,9 @@ discard block |
||
330 | 330 | ); |
331 | 331 | } |
332 | 332 | |
333 | - $logs = get_posts( $query_args ); |
|
333 | + $logs = get_posts($query_args); |
|
334 | 334 | |
335 | - if ( $logs ) { |
|
335 | + if ($logs) { |
|
336 | 336 | return $logs; |
337 | 337 | } |
338 | 338 | |
@@ -355,17 +355,17 @@ discard block |
||
355 | 355 | * |
356 | 356 | * @return int Log count. |
357 | 357 | */ |
358 | - public function get_log_count( $object_id = 0, $type = null, $meta_query = null, $date_query = null ) { |
|
358 | + public function get_log_count($object_id = 0, $type = null, $meta_query = null, $date_query = null) { |
|
359 | 359 | |
360 | 360 | $query_args = array( |
361 | 361 | 'post_parent' => $object_id, |
362 | 362 | 'post_type' => 'give_log', |
363 | - 'posts_per_page' => - 1, |
|
363 | + 'posts_per_page' => -1, |
|
364 | 364 | 'post_status' => 'publish', |
365 | 365 | 'fields' => 'ids', |
366 | 366 | ); |
367 | 367 | |
368 | - if ( ! empty( $type ) && $this->valid_type( $type ) ) { |
|
368 | + if ( ! empty($type) && $this->valid_type($type)) { |
|
369 | 369 | $query_args['tax_query'] = array( |
370 | 370 | array( |
371 | 371 | 'taxonomy' => 'give_log_type', |
@@ -375,25 +375,25 @@ discard block |
||
375 | 375 | ); |
376 | 376 | } |
377 | 377 | |
378 | - if ( ! empty( $meta_query ) ) { |
|
378 | + if ( ! empty($meta_query)) { |
|
379 | 379 | $query_args['meta_query'] = $meta_query; |
380 | 380 | } |
381 | 381 | |
382 | - if ( ! empty( $date_query ) ) { |
|
382 | + if ( ! empty($date_query)) { |
|
383 | 383 | $query_args['date_query'] = $date_query; |
384 | 384 | } |
385 | 385 | |
386 | 386 | |
387 | 387 | // Get cache key for current query. |
388 | - $cache_key = give_get_cache_key( 'get_log_count', $query_args ); |
|
388 | + $cache_key = give_get_cache_key('get_log_count', $query_args); |
|
389 | 389 | |
390 | 390 | // check if cache already exist or not. |
391 | - if( ! ( $logs_count = get_option( $cache_key ) ) ) { |
|
392 | - $logs = new WP_Query( $query_args ); |
|
391 | + if ( ! ($logs_count = get_option($cache_key))) { |
|
392 | + $logs = new WP_Query($query_args); |
|
393 | 393 | $logs_count = (int) $logs->post_count; |
394 | 394 | |
395 | 395 | // Cache results. |
396 | - add_option( $cache_key, $logs_count, '', 'no' ); |
|
396 | + add_option($cache_key, $logs_count, '', 'no'); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | return $logs_count; |
@@ -413,16 +413,16 @@ discard block |
||
413 | 413 | * |
414 | 414 | * @return void |
415 | 415 | */ |
416 | - public function delete_logs( $object_id = 0, $type = null, $meta_query = null ) { |
|
416 | + public function delete_logs($object_id = 0, $type = null, $meta_query = null) { |
|
417 | 417 | $query_args = array( |
418 | 418 | 'post_parent' => $object_id, |
419 | 419 | 'post_type' => 'give_log', |
420 | - 'posts_per_page' => - 1, |
|
420 | + 'posts_per_page' => -1, |
|
421 | 421 | 'post_status' => 'publish', |
422 | 422 | 'fields' => 'ids', |
423 | 423 | ); |
424 | 424 | |
425 | - if ( ! empty( $type ) && $this->valid_type( $type ) ) { |
|
425 | + if ( ! empty($type) && $this->valid_type($type)) { |
|
426 | 426 | $query_args['tax_query'] = array( |
427 | 427 | array( |
428 | 428 | 'taxonomy' => 'give_log_type', |
@@ -432,15 +432,15 @@ discard block |
||
432 | 432 | ); |
433 | 433 | } |
434 | 434 | |
435 | - if ( ! empty( $meta_query ) ) { |
|
435 | + if ( ! empty($meta_query)) { |
|
436 | 436 | $query_args['meta_query'] = $meta_query; |
437 | 437 | } |
438 | 438 | |
439 | - $logs = get_posts( $query_args ); |
|
439 | + $logs = get_posts($query_args); |
|
440 | 440 | |
441 | - if ( $logs ) { |
|
442 | - foreach ( $logs as $log ) { |
|
443 | - wp_delete_post( $log, true ); |
|
441 | + if ($logs) { |
|
442 | + foreach ($logs as $log) { |
|
443 | + wp_delete_post($log, true); |
|
444 | 444 | } |
445 | 445 | } |
446 | 446 | } |
@@ -453,8 +453,8 @@ discard block |
||
453 | 453 | * |
454 | 454 | * @param int $post_id |
455 | 455 | */ |
456 | - public function background_process_delete_cache( $post_id ) { |
|
457 | - wp_schedule_single_event( time(), 'give_delete_log_cache' ); |
|
456 | + public function background_process_delete_cache($post_id) { |
|
457 | + wp_schedule_single_event(time(), 'give_delete_log_cache'); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | /** |
@@ -476,14 +476,14 @@ discard block |
||
476 | 476 | ); |
477 | 477 | |
478 | 478 | // Bailout. |
479 | - if( empty( $cache_option_names ) ) { |
|
479 | + if (empty($cache_option_names)) { |
|
480 | 480 | return false; |
481 | 481 | } |
482 | 482 | |
483 | 483 | |
484 | 484 | // Delete log cache. |
485 | - foreach ( $cache_option_names as $option_name ) { |
|
486 | - delete_option( $option_name['option_name'] ); |
|
485 | + foreach ($cache_option_names as $option_name) { |
|
486 | + delete_option($option_name['option_name']); |
|
487 | 487 | } |
488 | 488 | } |
489 | 489 | } |
@@ -506,10 +506,10 @@ discard block |
||
506 | 506 | * |
507 | 507 | * @return int ID of the new log entry. |
508 | 508 | */ |
509 | -function give_record_log( $title = '', $message = '', $parent = 0, $type = null ) { |
|
509 | +function give_record_log($title = '', $message = '', $parent = 0, $type = null) { |
|
510 | 510 | /* @var Give_Logging $give_logs */ |
511 | 511 | global $give_logs; |
512 | - $log = $give_logs->add( $title, $message, $parent, $type ); |
|
512 | + $log = $give_logs->add($title, $message, $parent, $type); |
|
513 | 513 | |
514 | 514 | return $log; |
515 | 515 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return string $message Fully formatted message |
43 | 43 | */ |
44 | -function give_email_template_tags( $message, $payment_data, $payment_id, $admin_notice = false ) { |
|
45 | - return give_do_email_tags( $message, $payment_id ); |
|
44 | +function give_email_template_tags($message, $payment_data, $payment_id, $admin_notice = false) { |
|
45 | + return give_do_email_tags($message, $payment_id); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -56,42 +56,42 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @return string $message Fully formatted message |
58 | 58 | */ |
59 | -function give_email_preview_template_tags( $message ) { |
|
59 | +function give_email_preview_template_tags($message) { |
|
60 | 60 | |
61 | - $price = give_currency_filter( give_format_amount( 10.50 ) ); |
|
61 | + $price = give_currency_filter(give_format_amount(10.50)); |
|
62 | 62 | |
63 | 63 | $gateway = 'PayPal'; |
64 | 64 | |
65 | - $receipt_id = strtolower( md5( uniqid() ) ); |
|
65 | + $receipt_id = strtolower(md5(uniqid())); |
|
66 | 66 | |
67 | - $payment_id = rand( 1, 100 ); |
|
67 | + $payment_id = rand(1, 100); |
|
68 | 68 | |
69 | - $receipt_link_url = esc_url( add_query_arg( array( 'payment_key' => $receipt_id, 'give_action' => 'view_receipt' ), home_url() ) ); |
|
69 | + $receipt_link_url = esc_url(add_query_arg(array('payment_key' => $receipt_id, 'give_action' => 'view_receipt'), home_url())); |
|
70 | 70 | $receipt_link = sprintf( |
71 | 71 | '<a href="%1$s">%2$s</a>', |
72 | 72 | $receipt_link_url, |
73 | - esc_html__( 'View the receipt in your browser »', 'give' ) |
|
73 | + esc_html__('View the receipt in your browser »', 'give') |
|
74 | 74 | ); |
75 | 75 | |
76 | 76 | $user = wp_get_current_user(); |
77 | 77 | |
78 | - $message = str_replace( '{name}', $user->display_name, $message ); |
|
79 | - $message = str_replace( '{fullname}', $user->display_name, $message ); |
|
80 | - $message = str_replace( '{username}', $user->user_login, $message ); |
|
81 | - $message = str_replace( '{date}', date( give_date_format(), current_time( 'timestamp' ) ), $message ); |
|
82 | - $message = str_replace( '{amount}', $price, $message ); |
|
83 | - $message = str_replace( '{price}', $price, $message ); |
|
84 | - $message = str_replace( '{donation}', esc_html__( 'Sample Donation Form Title', 'give' ), $message ); |
|
85 | - $message = str_replace( '{form_title}', esc_html__( 'Sample Donation Form Title - Sample Donation Level', 'give' ), $message ); |
|
86 | - $message = str_replace( '{receipt_id}', $receipt_id, $message ); |
|
87 | - $message = str_replace( '{payment_method}', $gateway, $message ); |
|
88 | - $message = str_replace( '{sitename}', get_bloginfo( 'name' ), $message ); |
|
89 | - $message = str_replace( '{payment_id}', $payment_id, $message ); |
|
90 | - $message = str_replace( '{receipt_link}', $receipt_link, $message ); |
|
91 | - $message = str_replace( '{receipt_link_url}', $receipt_link_url, $message ); |
|
92 | - $message = str_replace( '{pdf_receipt}', '<a href="#">Download Receipt</a>', $message ); |
|
93 | - |
|
94 | - return wpautop( apply_filters( 'give_email_preview_template_tags', $message ) ); |
|
78 | + $message = str_replace('{name}', $user->display_name, $message); |
|
79 | + $message = str_replace('{fullname}', $user->display_name, $message); |
|
80 | + $message = str_replace('{username}', $user->user_login, $message); |
|
81 | + $message = str_replace('{date}', date(give_date_format(), current_time('timestamp')), $message); |
|
82 | + $message = str_replace('{amount}', $price, $message); |
|
83 | + $message = str_replace('{price}', $price, $message); |
|
84 | + $message = str_replace('{donation}', esc_html__('Sample Donation Form Title', 'give'), $message); |
|
85 | + $message = str_replace('{form_title}', esc_html__('Sample Donation Form Title - Sample Donation Level', 'give'), $message); |
|
86 | + $message = str_replace('{receipt_id}', $receipt_id, $message); |
|
87 | + $message = str_replace('{payment_method}', $gateway, $message); |
|
88 | + $message = str_replace('{sitename}', get_bloginfo('name'), $message); |
|
89 | + $message = str_replace('{payment_id}', $payment_id, $message); |
|
90 | + $message = str_replace('{receipt_link}', $receipt_link, $message); |
|
91 | + $message = str_replace('{receipt_link_url}', $receipt_link_url, $message); |
|
92 | + $message = str_replace('{pdf_receipt}', '<a href="#">Download Receipt</a>', $message); |
|
93 | + |
|
94 | + return wpautop(apply_filters('give_email_preview_template_tags', $message)); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -103,23 +103,23 @@ discard block |
||
103 | 103 | * @since 1.0 |
104 | 104 | * @return array|bool |
105 | 105 | */ |
106 | -function give_email_template_preview( $array ) { |
|
106 | +function give_email_template_preview($array) { |
|
107 | 107 | |
108 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
108 | + if ( ! current_user_can('manage_give_settings')) { |
|
109 | 109 | return false; |
110 | 110 | } |
111 | 111 | $custom_field = array( |
112 | - 'name' => esc_html__( 'Preview Email', 'give' ), |
|
113 | - 'desc' => esc_html__( 'Click the buttons to preview emails.', 'give' ), |
|
112 | + 'name' => esc_html__('Preview Email', 'give'), |
|
113 | + 'desc' => esc_html__('Click the buttons to preview emails.', 'give'), |
|
114 | 114 | 'id' => 'give_email_preview_buttons', |
115 | 115 | 'type' => 'email_preview_buttons' |
116 | 116 | ); |
117 | 117 | |
118 | - return give_settings_array_insert( $array, 'donation_subject', array( $custom_field ) ); |
|
118 | + return give_settings_array_insert($array, 'donation_subject', array($custom_field)); |
|
119 | 119 | |
120 | 120 | } |
121 | 121 | |
122 | -add_filter( 'give_settings_emails', 'give_email_template_preview' ); |
|
122 | +add_filter('give_settings_emails', 'give_email_template_preview'); |
|
123 | 123 | |
124 | 124 | /** |
125 | 125 | * Output Email Template Preview Buttons. |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | function give_email_preview_buttons_callback() { |
132 | 132 | ob_start(); |
133 | 133 | ?> |
134 | - <a href="<?php echo esc_url( add_query_arg( array( 'give_action' => 'preview_email' ), home_url() ) ); ?>" class="button-secondary" target="_blank"><?php esc_html_e( 'Preview Donation Receipt', 'give' ); ?></a> |
|
135 | - <a href="<?php echo wp_nonce_url( add_query_arg( array( |
|
134 | + <a href="<?php echo esc_url(add_query_arg(array('give_action' => 'preview_email'), home_url())); ?>" class="button-secondary" target="_blank"><?php esc_html_e('Preview Donation Receipt', 'give'); ?></a> |
|
135 | + <a href="<?php echo wp_nonce_url(add_query_arg(array( |
|
136 | 136 | 'give_action' => 'send_test_email', |
137 | 137 | 'give-message' => 'sent-test-email', |
138 | 138 | 'tag' => 'emails' |
139 | - ) ), 'give-test-email' ); ?>" aria-label="<?php esc_attr_e( 'Send demo donation receipt to the emails listed below.', 'give' ); ?>" class="button-secondary"><?php esc_html_e( 'Send Test Email', 'give' ); ?></a> |
|
139 | + )), 'give-test-email'); ?>" aria-label="<?php esc_attr_e('Send demo donation receipt to the emails listed below.', 'give'); ?>" class="button-secondary"><?php esc_html_e('Send Test Email', 'give'); ?></a> |
|
140 | 140 | <?php |
141 | 141 | echo ob_get_clean(); |
142 | 142 | } |
@@ -149,46 +149,46 @@ discard block |
||
149 | 149 | */ |
150 | 150 | function give_display_email_template_preview() { |
151 | 151 | |
152 | - if ( empty( $_GET['give_action'] ) ) { |
|
152 | + if (empty($_GET['give_action'])) { |
|
153 | 153 | return; |
154 | 154 | } |
155 | 155 | |
156 | - if ( 'preview_email' !== $_GET['give_action'] ) { |
|
156 | + if ('preview_email' !== $_GET['give_action']) { |
|
157 | 157 | return; |
158 | 158 | } |
159 | 159 | |
160 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
160 | + if ( ! current_user_can('manage_give_settings')) { |
|
161 | 161 | return; |
162 | 162 | } |
163 | 163 | |
164 | 164 | |
165 | - Give()->emails->heading = esc_html__( 'Donation Receipt', 'give' ); |
|
165 | + Give()->emails->heading = esc_html__('Donation Receipt', 'give'); |
|
166 | 166 | |
167 | - $payment_id = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : ''; |
|
167 | + $payment_id = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : ''; |
|
168 | 168 | |
169 | 169 | echo give_get_preview_email_header(); |
170 | 170 | |
171 | 171 | //Are we previewing an actual payment? |
172 | - if ( ! empty( $payment_id ) ) { |
|
172 | + if ( ! empty($payment_id)) { |
|
173 | 173 | |
174 | - $content = give_get_email_body_content( $payment_id ); |
|
174 | + $content = give_get_email_body_content($payment_id); |
|
175 | 175 | |
176 | - $preview_content = give_do_email_tags( $content, $payment_id ); |
|
176 | + $preview_content = give_do_email_tags($content, $payment_id); |
|
177 | 177 | |
178 | 178 | } else { |
179 | 179 | |
180 | 180 | //No payment ID, use sample preview content |
181 | - $preview_content = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) ); |
|
181 | + $preview_content = give_email_preview_template_tags(give_get_email_body_content(0, array())); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | |
185 | - echo Give()->emails->build_email( $preview_content ); |
|
185 | + echo Give()->emails->build_email($preview_content); |
|
186 | 186 | |
187 | 187 | exit; |
188 | 188 | |
189 | 189 | } |
190 | 190 | |
191 | -add_action( 'init', 'give_display_email_template_preview' ); |
|
191 | +add_action('init', 'give_display_email_template_preview'); |
|
192 | 192 | |
193 | 193 | /** |
194 | 194 | * Email Template Body. |
@@ -200,18 +200,18 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return string $email_body Body of the email |
202 | 202 | */ |
203 | -function give_get_email_body_content( $payment_id = 0, $payment_data = array() ) { |
|
203 | +function give_get_email_body_content($payment_id = 0, $payment_data = array()) { |
|
204 | 204 | |
205 | 205 | $default_email_body = give_get_default_donation_receipt_email(); |
206 | 206 | |
207 | - $email_content = give_get_option( 'donation_receipt' ); |
|
208 | - $email_content = isset( $email_content ) ? stripslashes( $email_content ) : $default_email_body; |
|
207 | + $email_content = give_get_option('donation_receipt'); |
|
208 | + $email_content = isset($email_content) ? stripslashes($email_content) : $default_email_body; |
|
209 | 209 | |
210 | - $email_body = wpautop( $email_content ); |
|
210 | + $email_body = wpautop($email_content); |
|
211 | 211 | |
212 | - $email_body = apply_filters( 'give_donation_receipt_' . Give()->emails->get_template(), $email_body, $payment_id, $payment_data ); |
|
212 | + $email_body = apply_filters('give_donation_receipt_'.Give()->emails->get_template(), $email_body, $payment_id, $payment_data); |
|
213 | 213 | |
214 | - return apply_filters( 'give_donation_receipt', $email_body, $payment_id, $payment_data ); |
|
214 | + return apply_filters('give_donation_receipt', $email_body, $payment_id, $payment_data); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -224,36 +224,36 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @return string $email_body Body of the email |
226 | 226 | */ |
227 | -function give_get_donation_notification_body_content( $payment_id = 0, $payment_data = array() ) { |
|
227 | +function give_get_donation_notification_body_content($payment_id = 0, $payment_data = array()) { |
|
228 | 228 | |
229 | - $user_info = maybe_unserialize( $payment_data['user_info'] ); |
|
230 | - $email = give_get_payment_user_email( $payment_id ); |
|
229 | + $user_info = maybe_unserialize($payment_data['user_info']); |
|
230 | + $email = give_get_payment_user_email($payment_id); |
|
231 | 231 | |
232 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) { |
|
233 | - $user_data = get_userdata( $user_info['id'] ); |
|
232 | + if (isset($user_info['id']) && $user_info['id'] > 0) { |
|
233 | + $user_data = get_userdata($user_info['id']); |
|
234 | 234 | $name = $user_data->display_name; |
235 | - } elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) { |
|
236 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
235 | + } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { |
|
236 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
237 | 237 | } else { |
238 | 238 | $name = $email; |
239 | 239 | } |
240 | 240 | |
241 | - $gateway = give_get_gateway_admin_label( get_post_meta( $payment_id, '_give_payment_gateway', true ) ); |
|
241 | + $gateway = give_get_gateway_admin_label(get_post_meta($payment_id, '_give_payment_gateway', true)); |
|
242 | 242 | |
243 | - $default_email_body = esc_html__( 'Hello', 'give' ) . "\n\n"; |
|
244 | - $default_email_body .= esc_html__( 'A donation has been made.', 'give' ) . "\n\n"; |
|
245 | - $default_email_body .= esc_html__( 'Donation:', 'give' ) . "\n\n"; |
|
246 | - $default_email_body .= esc_html__( 'Donor:', 'give' ) . ' ' . html_entity_decode( $name, ENT_COMPAT, 'UTF-8' ) . "\n"; |
|
247 | - $default_email_body .= esc_html__( 'Amount:', 'give' ) . ' ' . html_entity_decode( give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ), ENT_COMPAT, 'UTF-8' ) . "\n"; |
|
248 | - $default_email_body .= esc_html__( 'Payment Method:', 'give' ) . ' ' . $gateway . "\n\n"; |
|
249 | - $default_email_body .= esc_html__( 'Thank you', 'give' ); |
|
243 | + $default_email_body = esc_html__('Hello', 'give')."\n\n"; |
|
244 | + $default_email_body .= esc_html__('A donation has been made.', 'give')."\n\n"; |
|
245 | + $default_email_body .= esc_html__('Donation:', 'give')."\n\n"; |
|
246 | + $default_email_body .= esc_html__('Donor:', 'give').' '.html_entity_decode($name, ENT_COMPAT, 'UTF-8')."\n"; |
|
247 | + $default_email_body .= esc_html__('Amount:', 'give').' '.html_entity_decode(give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))), ENT_COMPAT, 'UTF-8')."\n"; |
|
248 | + $default_email_body .= esc_html__('Payment Method:', 'give').' '.$gateway."\n\n"; |
|
249 | + $default_email_body .= esc_html__('Thank you', 'give'); |
|
250 | 250 | |
251 | - $email = give_get_option( 'donation_notification' ); |
|
252 | - $email = isset( $email ) ? stripslashes( $email ) : $default_email_body; |
|
251 | + $email = give_get_option('donation_notification'); |
|
252 | + $email = isset($email) ? stripslashes($email) : $default_email_body; |
|
253 | 253 | |
254 | - $email_body = give_do_email_tags( $email, $payment_id ); |
|
254 | + $email_body = give_do_email_tags($email, $payment_id); |
|
255 | 255 | |
256 | - return apply_filters( 'give_donation_notification', wpautop( $email_body ), $payment_id, $payment_data ); |
|
256 | + return apply_filters('give_donation_notification', wpautop($email_body), $payment_id, $payment_data); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -266,19 +266,19 @@ discard block |
||
266 | 266 | * @since 1.0 |
267 | 267 | */ |
268 | 268 | function give_render_receipt_in_browser() { |
269 | - if ( ! isset( $_GET['payment_key'] ) ) { |
|
270 | - wp_die( esc_html__( 'Missing donation payment key.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
269 | + if ( ! isset($_GET['payment_key'])) { |
|
270 | + wp_die(esc_html__('Missing donation payment key.', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
271 | 271 | } |
272 | 272 | |
273 | - $key = urlencode( $_GET['payment_key'] ); |
|
273 | + $key = urlencode($_GET['payment_key']); |
|
274 | 274 | |
275 | 275 | ob_start(); |
276 | 276 | //Disallows caching of the page |
277 | - header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . " GMT" ); |
|
278 | - header( "Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1 |
|
279 | - header( "Cache-Control: post-check=0, pre-check=0", false ); |
|
280 | - header( "Pragma: no-cache" ); // HTTP/1.0 |
|
281 | - header( "Expires: Sat, 23 Oct 1977 05:00:00 PST" ); // Date in the past |
|
277 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
278 | + header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 |
|
279 | + header("Cache-Control: post-check=0, pre-check=0", false); |
|
280 | + header("Pragma: no-cache"); // HTTP/1.0 |
|
281 | + header("Expires: Sat, 23 Oct 1977 05:00:00 PST"); // Date in the past |
|
282 | 282 | ?> |
283 | 283 | <!DOCTYPE html> |
284 | 284 | <html lang="en"> |
@@ -289,10 +289,10 @@ discard block |
||
289 | 289 | * |
290 | 290 | * @since 1.0 |
291 | 291 | */ |
292 | - do_action( 'give_receipt_head' ); |
|
292 | + do_action('give_receipt_head'); |
|
293 | 293 | ?> |
294 | 294 | </head> |
295 | - <body class="<?php echo apply_filters( 'give_receipt_page_body_class', 'give_receipt_page' ); ?>"> |
|
295 | + <body class="<?php echo apply_filters('give_receipt_page_body_class', 'give_receipt_page'); ?>"> |
|
296 | 296 | |
297 | 297 | <div id="give_receipt_wrapper"> |
298 | 298 | <?php |
@@ -301,16 +301,16 @@ discard block |
||
301 | 301 | * |
302 | 302 | * @since 1.0 |
303 | 303 | */ |
304 | - do_action( 'give_render_receipt_in_browser_before' ); |
|
304 | + do_action('give_render_receipt_in_browser_before'); |
|
305 | 305 | |
306 | - echo do_shortcode( '[give_receipt payment_key=' . $key . ']' ); |
|
306 | + echo do_shortcode('[give_receipt payment_key='.$key.']'); |
|
307 | 307 | |
308 | 308 | /** |
309 | 309 | * Fires in the receipt template after the content. |
310 | 310 | * |
311 | 311 | * @since 1.0 |
312 | 312 | */ |
313 | - do_action( 'give_render_receipt_in_browser_after' ); |
|
313 | + do_action('give_render_receipt_in_browser_after'); |
|
314 | 314 | ?> |
315 | 315 | </div> |
316 | 316 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * |
321 | 321 | * @since 1.0 |
322 | 322 | */ |
323 | - do_action( 'give_receipt_footer' ); |
|
323 | + do_action('give_receipt_footer'); |
|
324 | 324 | ?> |
325 | 325 | </body> |
326 | 326 | </html> |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | die(); |
330 | 330 | } |
331 | 331 | |
332 | -add_action( 'give_view_receipt', 'give_render_receipt_in_browser' ); |
|
332 | +add_action('give_view_receipt', 'give_render_receipt_in_browser'); |
|
333 | 333 | |
334 | 334 | |
335 | 335 | /** |
@@ -344,29 +344,29 @@ discard block |
||
344 | 344 | |
345 | 345 | //Payment receipt switcher |
346 | 346 | $payment_count = give_count_payments()->publish; |
347 | - $payment_id = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : ''; |
|
347 | + $payment_id = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : ''; |
|
348 | 348 | |
349 | - if ( $payment_count <= 0 ) { |
|
349 | + if ($payment_count <= 0) { |
|
350 | 350 | return false; |
351 | 351 | } |
352 | 352 | |
353 | 353 | //Get payments. |
354 | - $payments = new Give_Payments_Query( array( |
|
354 | + $payments = new Give_Payments_Query(array( |
|
355 | 355 | 'number' => 100 |
356 | - ) ); |
|
356 | + )); |
|
357 | 357 | $payments = $payments->get_payments(); |
358 | 358 | $options = array(); |
359 | 359 | |
360 | 360 | //Provide nice human readable options. |
361 | - if ( $payments ) { |
|
362 | - $options[0] = esc_html__( '- Select a donation -', 'give' ); |
|
363 | - foreach ( $payments as $payment ) { |
|
361 | + if ($payments) { |
|
362 | + $options[0] = esc_html__('- Select a donation -', 'give'); |
|
363 | + foreach ($payments as $payment) { |
|
364 | 364 | |
365 | - $options[ $payment->ID ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title ); |
|
365 | + $options[$payment->ID] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title); |
|
366 | 366 | |
367 | 367 | } |
368 | 368 | } else { |
369 | - $options[0] = esc_html__( 'No donations found.', 'give' ); |
|
369 | + $options[0] = esc_html__('No donations found.', 'give'); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | //Start constructing HTML output. |
@@ -379,16 +379,16 @@ discard block |
||
379 | 379 | var selected_trans = transactions.options[transactions.selectedIndex]; |
380 | 380 | console.log(selected_trans); |
381 | 381 | if (selected_trans){ |
382 | - var url_string = "' . get_bloginfo( 'url' ) . '?give_action=preview_email&preview_id=" + selected_trans.value; |
|
382 | + var url_string = "' . get_bloginfo('url').'?give_action=preview_email&preview_id=" + selected_trans.value; |
|
383 | 383 | window.location = url_string; |
384 | 384 | } |
385 | 385 | } |
386 | 386 | </script>'; |
387 | 387 | |
388 | - $transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">' . esc_html__( 'Preview email with a donation:', 'give' ) . '</label>'; |
|
388 | + $transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">'.esc_html__('Preview email with a donation:', 'give').'</label>'; |
|
389 | 389 | |
390 | 390 | //The select field with 100 latest transactions |
391 | - $transaction_header .= Give()->html->select( array( |
|
391 | + $transaction_header .= Give()->html->select(array( |
|
392 | 392 | 'name' => 'preview_email_payment_id', |
393 | 393 | 'selected' => $payment_id, |
394 | 394 | 'id' => 'give_preview_email_payment_id', |
@@ -398,12 +398,12 @@ discard block |
||
398 | 398 | 'select_atts' => 'onchange="change_preview()">', |
399 | 399 | 'show_option_all' => false, |
400 | 400 | 'show_option_none' => false |
401 | - ) ); |
|
401 | + )); |
|
402 | 402 | |
403 | 403 | //Closing tag |
404 | 404 | $transaction_header .= '</div>'; |
405 | 405 | |
406 | - return apply_filters( 'give_preview_email_receipt_header', $transaction_header ); |
|
406 | + return apply_filters('give_preview_email_receipt_header', $transaction_header); |
|
407 | 407 | |
408 | 408 | } |
409 | 409 | |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | function give_receipt_head_content() { |
418 | 418 | |
419 | 419 | //Title. |
420 | - $output = '<title>' . esc_html__( 'Donation Receipt', 'give' ) . '</title>'; |
|
420 | + $output = '<title>'.esc_html__('Donation Receipt', 'give').'</title>'; |
|
421 | 421 | |
422 | 422 | //Meta. |
423 | 423 | $output .= '<meta charset="utf-8"/> |
@@ -431,10 +431,10 @@ discard block |
||
431 | 431 | <meta name="robots" content="noindex, nofollow"/>'; |
432 | 432 | |
433 | 433 | //CSS |
434 | - $output .= '<link rel="stylesheet" href="' . give_get_stylesheet_uri() . '?ver=' . GIVE_VERSION . '">'; |
|
434 | + $output .= '<link rel="stylesheet" href="'.give_get_stylesheet_uri().'?ver='.GIVE_VERSION.'">'; |
|
435 | 435 | |
436 | - echo apply_filters( 'give_receipt_head_content', $output ); |
|
436 | + echo apply_filters('give_receipt_head_content', $output); |
|
437 | 437 | |
438 | 438 | } |
439 | 439 | |
440 | -add_action( 'give_receipt_head', 'give_receipt_head_content' ); |
|
441 | 440 | \ No newline at end of file |
441 | +add_action('give_receipt_head', 'give_receipt_head_content'); |
|
442 | 442 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @since 1.0 |
32 | 32 | */ |
33 | - do_action( 'give_pre_process_donation' ); |
|
33 | + do_action('give_pre_process_donation'); |
|
34 | 34 | |
35 | 35 | // Validate the form $_POST data |
36 | 36 | $valid_data = give_purchase_form_validate_fields(); |
@@ -45,26 +45,26 @@ discard block |
||
45 | 45 | * @param bool|array $valid_data Validate fields. |
46 | 46 | * @param array $_POST Array of variables passed via the HTTP POST. |
47 | 47 | */ |
48 | - do_action( 'give_checkout_error_checks', $valid_data, $_POST ); |
|
48 | + do_action('give_checkout_error_checks', $valid_data, $_POST); |
|
49 | 49 | |
50 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
50 | + $is_ajax = isset($_POST['give_ajax']); |
|
51 | 51 | |
52 | 52 | // Process the login form |
53 | - if ( isset( $_POST['give_login_submit'] ) ) { |
|
53 | + if (isset($_POST['give_login_submit'])) { |
|
54 | 54 | give_process_form_login(); |
55 | 55 | } |
56 | 56 | |
57 | 57 | // Validate the user |
58 | - $user = give_get_purchase_form_user( $valid_data ); |
|
58 | + $user = give_get_purchase_form_user($valid_data); |
|
59 | 59 | |
60 | - if ( false === $valid_data || give_get_errors() || ! $user ) { |
|
61 | - if ( $is_ajax ) { |
|
60 | + if (false === $valid_data || give_get_errors() || ! $user) { |
|
61 | + if ($is_ajax) { |
|
62 | 62 | /** |
63 | 63 | * Fires when AJAX sends back errors from the donation form. |
64 | 64 | * |
65 | 65 | * @since 1.0 |
66 | 66 | */ |
67 | - do_action( 'give_ajax_donation_errors' ); |
|
67 | + do_action('give_ajax_donation_errors'); |
|
68 | 68 | give_die(); |
69 | 69 | } else { |
70 | 70 | return false; |
@@ -72,17 +72,17 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | // If AJAX send back success to proceed with form submission |
75 | - if ( $is_ajax ) { |
|
75 | + if ($is_ajax) { |
|
76 | 76 | echo 'success'; |
77 | 77 | give_die(); |
78 | 78 | } |
79 | 79 | |
80 | 80 | // After AJAX: Setup session if not using php_sessions |
81 | - if ( ! Give()->session->use_php_sessions() ) { |
|
81 | + if ( ! Give()->session->use_php_sessions()) { |
|
82 | 82 | // Double-check that set_cookie is publicly accessible; |
83 | 83 | // we're using a slightly modified class-wp-sessions.php |
84 | - $session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' ); |
|
85 | - if ( $session_reflection->isPublic() ) { |
|
84 | + $session_reflection = new ReflectionMethod('WP_Session', 'set_cookie'); |
|
85 | + if ($session_reflection->isPublic()) { |
|
86 | 86 | // Manually set the cookie. |
87 | 87 | Give()->session->init()->set_cookie(); |
88 | 88 | } |
@@ -97,18 +97,18 @@ discard block |
||
97 | 97 | 'address' => $user['address'], |
98 | 98 | ); |
99 | 99 | |
100 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
100 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
101 | 101 | |
102 | - $price = isset( $_POST['give-amount'] ) ? (float) apply_filters( 'give_donation_total', give_sanitize_amount( give_format_amount( $_POST['give-amount'] ) ) ) : '0.00'; |
|
103 | - $purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); |
|
102 | + $price = isset($_POST['give-amount']) ? (float) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00'; |
|
103 | + $purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); |
|
104 | 104 | |
105 | 105 | // Setup donation information |
106 | 106 | $purchase_data = array( |
107 | 107 | 'price' => $price, |
108 | 108 | 'purchase_key' => $purchase_key, |
109 | 109 | 'user_email' => $user['user_email'], |
110 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
111 | - 'user_info' => stripslashes_deep( $user_info ), |
|
110 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
111 | + 'user_info' => stripslashes_deep($user_info), |
|
112 | 112 | 'post_data' => $_POST, |
113 | 113 | 'gateway' => $valid_data['gateway'], |
114 | 114 | 'card_info' => $valid_data['cc_info'], |
@@ -128,10 +128,10 @@ discard block |
||
128 | 128 | * @param array $user_info Array containing basic user information. |
129 | 129 | * @param bool|array $valid_data Validate fields. |
130 | 130 | */ |
131 | - do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data ); |
|
131 | + do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data); |
|
132 | 132 | |
133 | 133 | // Sanity check for price |
134 | - if ( ! $purchase_data['price'] ) { |
|
134 | + if ( ! $purchase_data['price']) { |
|
135 | 135 | // Revert to manual |
136 | 136 | $purchase_data['gateway'] = 'manual'; |
137 | 137 | $_POST['give-gateway'] = 'manual'; |
@@ -142,27 +142,27 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @since 1.7 |
144 | 144 | */ |
145 | - $purchase_data = apply_filters( 'give_donation_data_before_gateway', $purchase_data, $valid_data ); |
|
145 | + $purchase_data = apply_filters('give_donation_data_before_gateway', $purchase_data, $valid_data); |
|
146 | 146 | |
147 | 147 | // Setup the data we're storing in the donation session |
148 | 148 | $session_data = $purchase_data; |
149 | 149 | |
150 | 150 | // Make sure credit card numbers are never stored in sessions |
151 | - unset( $session_data['card_info']['card_number'] ); |
|
152 | - unset( $session_data['post_data']['card_number'] ); |
|
151 | + unset($session_data['card_info']['card_number']); |
|
152 | + unset($session_data['post_data']['card_number']); |
|
153 | 153 | |
154 | 154 | // Used for showing data to non logged-in users after donation, and for other plugins needing donation data. |
155 | - give_set_purchase_session( $session_data ); |
|
155 | + give_set_purchase_session($session_data); |
|
156 | 156 | |
157 | 157 | // Send info to the gateway for payment processing |
158 | - give_send_to_gateway( $purchase_data['gateway'], $purchase_data ); |
|
158 | + give_send_to_gateway($purchase_data['gateway'], $purchase_data); |
|
159 | 159 | give_die(); |
160 | 160 | |
161 | 161 | } |
162 | 162 | |
163 | -add_action( 'give_purchase', 'give_process_purchase_form' ); |
|
164 | -add_action( 'wp_ajax_give_process_checkout', 'give_process_purchase_form' ); |
|
165 | -add_action( 'wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form' ); |
|
163 | +add_action('give_purchase', 'give_process_purchase_form'); |
|
164 | +add_action('wp_ajax_give_process_checkout', 'give_process_purchase_form'); |
|
165 | +add_action('wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form'); |
|
166 | 166 | |
167 | 167 | |
168 | 168 | /** |
@@ -175,26 +175,26 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return void |
177 | 177 | */ |
178 | -function give_checkout_check_existing_email( $valid_data, $post ) { |
|
178 | +function give_checkout_check_existing_email($valid_data, $post) { |
|
179 | 179 | |
180 | 180 | // Verify that the email address belongs to this customer |
181 | - if ( is_user_logged_in() ) { |
|
181 | + if (is_user_logged_in()) { |
|
182 | 182 | |
183 | 183 | $email = $valid_data['logged_in_user']['user_email']; |
184 | - $customer = new Give_Customer( get_current_user_id(), true ); |
|
184 | + $customer = new Give_Customer(get_current_user_id(), true); |
|
185 | 185 | |
186 | 186 | // If this email address is not registered with this customer, see if it belongs to any other customer |
187 | - if ( $email !== $customer->email && ( is_array( $customer->emails ) && ! in_array( $email, $customer->emails ) ) ) { |
|
188 | - $found_customer = new Give_Customer( $email ); |
|
187 | + if ($email !== $customer->email && (is_array($customer->emails) && ! in_array($email, $customer->emails))) { |
|
188 | + $found_customer = new Give_Customer($email); |
|
189 | 189 | |
190 | - if ( $found_customer->id > 0 ) { |
|
191 | - give_set_error( 'give-customer-email-exists', sprintf( esc_html__( 'The email address %s is already in use.', 'give' ), $email ) ); |
|
190 | + if ($found_customer->id > 0) { |
|
191 | + give_set_error('give-customer-email-exists', sprintf(esc_html__('The email address %s is already in use.', 'give'), $email)); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
197 | -add_action( 'give_checkout_error_checks', 'give_checkout_check_existing_email', 10, 2 ); |
|
197 | +add_action('give_checkout_error_checks', 'give_checkout_check_existing_email', 10, 2); |
|
198 | 198 | |
199 | 199 | /** |
200 | 200 | * Process the checkout login form |
@@ -205,37 +205,37 @@ discard block |
||
205 | 205 | */ |
206 | 206 | function give_process_form_login() { |
207 | 207 | |
208 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
208 | + $is_ajax = isset($_POST['give_ajax']); |
|
209 | 209 | |
210 | 210 | $user_data = give_purchase_form_validate_user_login(); |
211 | 211 | |
212 | - if ( give_get_errors() || $user_data['user_id'] < 1 ) { |
|
213 | - if ( $is_ajax ) { |
|
212 | + if (give_get_errors() || $user_data['user_id'] < 1) { |
|
213 | + if ($is_ajax) { |
|
214 | 214 | /** |
215 | 215 | * Fires when AJAX sends back errors from the donation form. |
216 | 216 | * |
217 | 217 | * @since 1.0 |
218 | 218 | */ |
219 | - do_action( 'give_ajax_donation_errors' ); |
|
219 | + do_action('give_ajax_donation_errors'); |
|
220 | 220 | give_die(); |
221 | 221 | } else { |
222 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
222 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
223 | 223 | exit; |
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
227 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] ); |
|
227 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']); |
|
228 | 228 | |
229 | - if ( $is_ajax ) { |
|
229 | + if ($is_ajax) { |
|
230 | 230 | echo 'success'; |
231 | 231 | give_die(); |
232 | 232 | } else { |
233 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
233 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | |
237 | -add_action( 'wp_ajax_give_process_checkout_login', 'give_process_form_login' ); |
|
238 | -add_action( 'wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login' ); |
|
237 | +add_action('wp_ajax_give_process_checkout_login', 'give_process_form_login'); |
|
238 | +add_action('wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login'); |
|
239 | 239 | |
240 | 240 | /** |
241 | 241 | * Donation Form Validate Fields |
@@ -247,45 +247,45 @@ discard block |
||
247 | 247 | function give_purchase_form_validate_fields() { |
248 | 248 | |
249 | 249 | // Check if there is $_POST |
250 | - if ( empty( $_POST ) ) { |
|
250 | + if (empty($_POST)) { |
|
251 | 251 | return false; |
252 | 252 | } |
253 | 253 | |
254 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
254 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
255 | 255 | |
256 | 256 | // Start an array to collect valid data |
257 | 257 | $valid_data = array( |
258 | 258 | 'gateway' => give_purchase_form_validate_gateway(), // Gateway fallback (amount is validated here) |
259 | - 'need_new_user' => false, // New user flag |
|
260 | - 'need_user_login' => false, // Login user flag |
|
261 | - 'logged_user_data' => array(), // Logged user collected data |
|
262 | - 'new_user_data' => array(), // New user collected data |
|
263 | - 'login_user_data' => array(), // Login user collected data |
|
264 | - 'guest_user_data' => array(), // Guest user collected data |
|
265 | - 'cc_info' => give_purchase_form_validate_cc(),// Credit card info |
|
259 | + 'need_new_user' => false, // New user flag |
|
260 | + 'need_user_login' => false, // Login user flag |
|
261 | + 'logged_user_data' => array(), // Logged user collected data |
|
262 | + 'new_user_data' => array(), // New user collected data |
|
263 | + 'login_user_data' => array(), // Login user collected data |
|
264 | + 'guest_user_data' => array(), // Guest user collected data |
|
265 | + 'cc_info' => give_purchase_form_validate_cc(), // Credit card info |
|
266 | 266 | ); |
267 | 267 | |
268 | 268 | // Validate Honeypot First |
269 | - if ( ! empty( $_POST['give-honeypot'] ) ) { |
|
270 | - give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) ); |
|
269 | + if ( ! empty($_POST['give-honeypot'])) { |
|
270 | + give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give')); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | // Validate agree to terms |
274 | - $terms_option = get_post_meta( $form_id, '_give_terms_option', true ); |
|
275 | - if ( isset( $terms_option ) && $terms_option === 'yes' ) { |
|
274 | + $terms_option = get_post_meta($form_id, '_give_terms_option', true); |
|
275 | + if (isset($terms_option) && $terms_option === 'yes') { |
|
276 | 276 | give_purchase_form_validate_agree_to_terms(); |
277 | 277 | } |
278 | 278 | |
279 | - if ( is_user_logged_in() ) { |
|
279 | + if (is_user_logged_in()) { |
|
280 | 280 | // Collect logged in user data |
281 | 281 | $valid_data['logged_in_user'] = give_purchase_form_validate_logged_in_user(); |
282 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) { |
|
282 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') { |
|
283 | 283 | // Set new user registration as required |
284 | 284 | $valid_data['need_new_user'] = true; |
285 | 285 | // Validate new user data |
286 | 286 | $valid_data['new_user_data'] = give_purchase_form_validate_new_user(); |
287 | 287 | // Check if login validation is needed |
288 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) { |
|
288 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') { |
|
289 | 289 | // Set user login as required |
290 | 290 | $valid_data['need_user_login'] = true; |
291 | 291 | // Validate users login info |
@@ -310,40 +310,40 @@ discard block |
||
310 | 310 | */ |
311 | 311 | function give_purchase_form_validate_gateway() { |
312 | 312 | |
313 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
314 | - $amount = isset( $_REQUEST['give-amount'] ) ? give_sanitize_amount( $_REQUEST['give-amount'] ) : 0; |
|
315 | - $gateway = give_get_default_gateway( $form_id ); |
|
313 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
314 | + $amount = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0; |
|
315 | + $gateway = give_get_default_gateway($form_id); |
|
316 | 316 | |
317 | 317 | // Check if a gateway value is present |
318 | - if ( ! empty( $_REQUEST['give-gateway'] ) ) { |
|
318 | + if ( ! empty($_REQUEST['give-gateway'])) { |
|
319 | 319 | |
320 | - $gateway = sanitize_text_field( $_REQUEST['give-gateway'] ); |
|
320 | + $gateway = sanitize_text_field($_REQUEST['give-gateway']); |
|
321 | 321 | |
322 | 322 | // Is amount being donated in LIVE mode 0.00? If so, error: |
323 | - if ( $amount == 0 && ! give_is_test_mode() ) { |
|
323 | + if ($amount == 0 && ! give_is_test_mode()) { |
|
324 | 324 | |
325 | - give_set_error( 'invalid_donation_amount', esc_html__( 'Please insert a valid donation amount.', 'give' ) ); |
|
325 | + give_set_error('invalid_donation_amount', esc_html__('Please insert a valid donation amount.', 'give')); |
|
326 | 326 | |
327 | 327 | } //Check for a minimum custom amount |
328 | - elseif ( ! give_verify_minimum_price() ) { |
|
328 | + elseif ( ! give_verify_minimum_price()) { |
|
329 | 329 | // translators: %s: minimum donation amount. |
330 | 330 | give_set_error( |
331 | 331 | 'invalid_donation_minimum', |
332 | 332 | sprintf( |
333 | - esc_html__( 'This form has a minimum donation amount of %s.', 'give' ), |
|
334 | - give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ) ) ) |
|
333 | + esc_html__('This form has a minimum donation amount of %s.', 'give'), |
|
334 | + give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id))) |
|
335 | 335 | ) |
336 | 336 | ); |
337 | 337 | |
338 | 338 | } //Is this test mode zero donation? Let it through but set to manual gateway. |
339 | - elseif ( $amount == 0 && give_is_test_mode() ) { |
|
339 | + elseif ($amount == 0 && give_is_test_mode()) { |
|
340 | 340 | |
341 | 341 | $gateway = 'manual'; |
342 | 342 | |
343 | 343 | } //Check if this gateway is active. |
344 | - elseif ( ! give_is_gateway_active( $gateway ) ) { |
|
344 | + elseif ( ! give_is_gateway_active($gateway)) { |
|
345 | 345 | |
346 | - give_set_error( 'invalid_gateway', esc_html__( 'The selected payment gateway is not enabled.', 'give' ) ); |
|
346 | + give_set_error('invalid_gateway', esc_html__('The selected payment gateway is not enabled.', 'give')); |
|
347 | 347 | |
348 | 348 | } |
349 | 349 | } |
@@ -361,23 +361,23 @@ discard block |
||
361 | 361 | */ |
362 | 362 | function give_verify_minimum_price() { |
363 | 363 | |
364 | - $amount = give_sanitize_amount( $_REQUEST['give-amount'] ); |
|
365 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
366 | - $price_id = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : 0; |
|
367 | - $variable_prices = give_has_variable_prices( $form_id ); |
|
364 | + $amount = give_sanitize_amount($_REQUEST['give-amount']); |
|
365 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
366 | + $price_id = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : 0; |
|
367 | + $variable_prices = give_has_variable_prices($form_id); |
|
368 | 368 | |
369 | - if ( $variable_prices && ! empty( $price_id ) ) { |
|
369 | + if ($variable_prices && ! empty($price_id)) { |
|
370 | 370 | |
371 | - $price_level_amount = give_get_price_option_amount( $form_id, $price_id ); |
|
371 | + $price_level_amount = give_get_price_option_amount($form_id, $price_id); |
|
372 | 372 | |
373 | - if ( $price_level_amount == $amount ) { |
|
373 | + if ($price_level_amount == $amount) { |
|
374 | 374 | return true; |
375 | 375 | } |
376 | 376 | } |
377 | 377 | |
378 | - $minimum = give_get_form_minimum_price( $form_id ); |
|
378 | + $minimum = give_get_form_minimum_price($form_id); |
|
379 | 379 | |
380 | - if ( $minimum > $amount ) { |
|
380 | + if ($minimum > $amount) { |
|
381 | 381 | return false; |
382 | 382 | } |
383 | 383 | |
@@ -393,9 +393,9 @@ discard block |
||
393 | 393 | */ |
394 | 394 | function give_purchase_form_validate_agree_to_terms() { |
395 | 395 | // Validate agree to terms. |
396 | - if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) { |
|
396 | + if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) { |
|
397 | 397 | // User did not agree. |
398 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', esc_html__( 'You must agree to the terms and conditions.', 'give' ) ) ); |
|
398 | + give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', esc_html__('You must agree to the terms and conditions.', 'give'))); |
|
399 | 399 | } |
400 | 400 | } |
401 | 401 | |
@@ -409,43 +409,43 @@ discard block |
||
409 | 409 | * |
410 | 410 | * @return array |
411 | 411 | */ |
412 | -function give_get_required_fields( $form_id ) { |
|
412 | +function give_get_required_fields($form_id) { |
|
413 | 413 | |
414 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
414 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
415 | 415 | |
416 | 416 | $required_fields = array( |
417 | 417 | 'give_email' => array( |
418 | 418 | 'error_id' => 'invalid_email', |
419 | - 'error_message' => esc_html__( 'Please enter a valid email address.', 'give' ), |
|
419 | + 'error_message' => esc_html__('Please enter a valid email address.', 'give'), |
|
420 | 420 | ), |
421 | 421 | 'give_first' => array( |
422 | 422 | 'error_id' => 'invalid_first_name', |
423 | - 'error_message' => esc_html__( 'Please enter your first name.', 'give' ), |
|
423 | + 'error_message' => esc_html__('Please enter your first name.', 'give'), |
|
424 | 424 | ), |
425 | 425 | ); |
426 | 426 | |
427 | - $require_address = give_require_billing_address( $payment_mode ); |
|
427 | + $require_address = give_require_billing_address($payment_mode); |
|
428 | 428 | |
429 | - if ( $require_address ) { |
|
430 | - $required_fields['card_address'] = array( |
|
429 | + if ($require_address) { |
|
430 | + $required_fields['card_address'] = array( |
|
431 | 431 | 'error_id' => 'invalid_card_address', |
432 | - 'error_message' => esc_html__( 'Please enter your primary billing address.', 'give' ), |
|
432 | + 'error_message' => esc_html__('Please enter your primary billing address.', 'give'), |
|
433 | 433 | ); |
434 | - $required_fields['card_zip'] = array( |
|
434 | + $required_fields['card_zip'] = array( |
|
435 | 435 | 'error_id' => 'invalid_zip_code', |
436 | - 'error_message' => esc_html__( 'Please enter your zip / postal code.', 'give' ), |
|
436 | + 'error_message' => esc_html__('Please enter your zip / postal code.', 'give'), |
|
437 | 437 | ); |
438 | - $required_fields['card_city'] = array( |
|
438 | + $required_fields['card_city'] = array( |
|
439 | 439 | 'error_id' => 'invalid_city', |
440 | - 'error_message' => esc_html__( 'Please enter your billing city.', 'give' ), |
|
440 | + 'error_message' => esc_html__('Please enter your billing city.', 'give'), |
|
441 | 441 | ); |
442 | 442 | $required_fields['billing_country'] = array( |
443 | 443 | 'error_id' => 'invalid_country', |
444 | - 'error_message' => esc_html__( 'Please select your billing country.', 'give' ), |
|
444 | + 'error_message' => esc_html__('Please select your billing country.', 'give'), |
|
445 | 445 | ); |
446 | - $required_fields['card_state'] = array( |
|
446 | + $required_fields['card_state'] = array( |
|
447 | 447 | 'error_id' => 'invalid_state', |
448 | - 'error_message' => esc_html__( 'Please enter billing state / province.', 'give' ), |
|
448 | + 'error_message' => esc_html__('Please enter billing state / province.', 'give'), |
|
449 | 449 | ); |
450 | 450 | } |
451 | 451 | |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | * |
455 | 455 | * @since 1.7 |
456 | 456 | */ |
457 | - $required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id ); |
|
457 | + $required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id); |
|
458 | 458 | |
459 | 459 | return $required_fields; |
460 | 460 | |
@@ -469,16 +469,16 @@ discard block |
||
469 | 469 | * |
470 | 470 | * @return mixed|void |
471 | 471 | */ |
472 | -function give_require_billing_address( $payment_mode ) { |
|
472 | +function give_require_billing_address($payment_mode) { |
|
473 | 473 | |
474 | 474 | $return = false; |
475 | 475 | |
476 | - if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { |
|
476 | + if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { |
|
477 | 477 | $return = true; |
478 | 478 | } |
479 | 479 | |
480 | 480 | // Let payment gateways and other extensions determine if address fields should be required. |
481 | - return apply_filters( 'give_require_billing_address', $return ); |
|
481 | + return apply_filters('give_require_billing_address', $return); |
|
482 | 482 | |
483 | 483 | } |
484 | 484 | |
@@ -492,42 +492,42 @@ discard block |
||
492 | 492 | function give_purchase_form_validate_logged_in_user() { |
493 | 493 | global $user_ID; |
494 | 494 | |
495 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
495 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
496 | 496 | |
497 | 497 | // Start empty array to collect valid user data. |
498 | 498 | $valid_user_data = array( |
499 | 499 | // Assume there will be errors. |
500 | - 'user_id' => - 1, |
|
500 | + 'user_id' => -1, |
|
501 | 501 | ); |
502 | 502 | |
503 | 503 | // Verify there is a user_ID. |
504 | - if ( $user_ID > 0 ) { |
|
504 | + if ($user_ID > 0) { |
|
505 | 505 | // Get the logged in user data. |
506 | - $user_data = get_userdata( $user_ID ); |
|
506 | + $user_data = get_userdata($user_ID); |
|
507 | 507 | |
508 | 508 | // Loop through required fields and show error messages. |
509 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
510 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
511 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
509 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
510 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
511 | + give_set_error($value['error_id'], $value['error_message']); |
|
512 | 512 | } |
513 | 513 | } |
514 | 514 | |
515 | 515 | // Verify data. |
516 | - if ( $user_data ) { |
|
516 | + if ($user_data) { |
|
517 | 517 | // Collected logged in user data. |
518 | 518 | $valid_user_data = array( |
519 | 519 | 'user_id' => $user_ID, |
520 | - 'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email, |
|
521 | - 'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name, |
|
522 | - 'user_last' => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name, |
|
520 | + 'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email, |
|
521 | + 'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name, |
|
522 | + 'user_last' => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name, |
|
523 | 523 | ); |
524 | 524 | |
525 | - if ( ! is_email( $valid_user_data['user_email'] ) ) { |
|
526 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
525 | + if ( ! is_email($valid_user_data['user_email'])) { |
|
526 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
527 | 527 | } |
528 | 528 | } else { |
529 | 529 | // Set invalid user error. |
530 | - give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) ); |
|
530 | + give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give')); |
|
531 | 531 | } |
532 | 532 | } |
533 | 533 | |
@@ -545,90 +545,90 @@ discard block |
||
545 | 545 | function give_purchase_form_validate_new_user() { |
546 | 546 | |
547 | 547 | $registering_new_user = false; |
548 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
548 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
549 | 549 | |
550 | 550 | // Start an empty array to collect valid user data. |
551 | 551 | $valid_user_data = array( |
552 | 552 | // Assume there will be errors. |
553 | - 'user_id' => - 1, |
|
553 | + 'user_id' => -1, |
|
554 | 554 | // Get first name. |
555 | - 'user_first' => isset( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : '', |
|
555 | + 'user_first' => isset($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : '', |
|
556 | 556 | // Get last name. |
557 | - 'user_last' => isset( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : '', |
|
557 | + 'user_last' => isset($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : '', |
|
558 | 558 | ); |
559 | 559 | |
560 | 560 | // Check the new user's credentials against existing ones. |
561 | - $user_login = isset( $_POST['give_user_login'] ) ? trim( $_POST['give_user_login'] ) : false; |
|
562 | - $user_email = isset( $_POST['give_email'] ) ? trim( $_POST['give_email'] ) : false; |
|
563 | - $user_pass = isset( $_POST['give_user_pass'] ) ? trim( $_POST['give_user_pass'] ) : false; |
|
564 | - $pass_confirm = isset( $_POST['give_user_pass_confirm'] ) ? trim( $_POST['give_user_pass_confirm'] ) : false; |
|
561 | + $user_login = isset($_POST['give_user_login']) ? trim($_POST['give_user_login']) : false; |
|
562 | + $user_email = isset($_POST['give_email']) ? trim($_POST['give_email']) : false; |
|
563 | + $user_pass = isset($_POST['give_user_pass']) ? trim($_POST['give_user_pass']) : false; |
|
564 | + $pass_confirm = isset($_POST['give_user_pass_confirm']) ? trim($_POST['give_user_pass_confirm']) : false; |
|
565 | 565 | |
566 | 566 | // Loop through required fields and show error messages. |
567 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
568 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
569 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
567 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
568 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
569 | + give_set_error($value['error_id'], $value['error_message']); |
|
570 | 570 | } |
571 | 571 | } |
572 | 572 | |
573 | 573 | // Check if we have an username to register. |
574 | - if ( $user_login && strlen( $user_login ) > 0 ) { |
|
574 | + if ($user_login && strlen($user_login) > 0) { |
|
575 | 575 | $registering_new_user = true; |
576 | 576 | |
577 | 577 | // We have an user name, check if it already exists. |
578 | - if ( username_exists( $user_login ) ) { |
|
578 | + if (username_exists($user_login)) { |
|
579 | 579 | // Username already registered. |
580 | - give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) ); |
|
580 | + give_set_error('username_unavailable', esc_html__('Username already taken.', 'give')); |
|
581 | 581 | // Check if it's valid. |
582 | - } elseif ( ! give_validate_username( $user_login ) ) { |
|
582 | + } elseif ( ! give_validate_username($user_login)) { |
|
583 | 583 | // Invalid username. |
584 | - if ( is_multisite() ) { |
|
585 | - give_set_error( 'username_invalid', esc_html__( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) ); |
|
584 | + if (is_multisite()) { |
|
585 | + give_set_error('username_invalid', esc_html__('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give')); |
|
586 | 586 | } else { |
587 | - give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) ); |
|
587 | + give_set_error('username_invalid', esc_html__('Invalid username.', 'give')); |
|
588 | 588 | } |
589 | 589 | } else { |
590 | 590 | // All the checks have run and it's good to go. |
591 | 591 | $valid_user_data['user_login'] = $user_login; |
592 | 592 | } |
593 | - } elseif ( give_logged_in_only( $form_id ) ) { |
|
594 | - give_set_error( 'registration_required', esc_html__( 'You must register or login to complete your donation.', 'give' ) ); |
|
593 | + } elseif (give_logged_in_only($form_id)) { |
|
594 | + give_set_error('registration_required', esc_html__('You must register or login to complete your donation.', 'give')); |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | // Check if we have an email to verify. |
598 | - if ( $user_email && strlen( $user_email ) > 0 ) { |
|
598 | + if ($user_email && strlen($user_email) > 0) { |
|
599 | 599 | // Validate email. |
600 | - if ( ! is_email( $user_email ) ) { |
|
601 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
600 | + if ( ! is_email($user_email)) { |
|
601 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
602 | 602 | // Check if email exists. |
603 | - } elseif ( email_exists( $user_email ) && $registering_new_user ) { |
|
604 | - give_set_error( 'email_used', esc_html__( 'The email already active for another user.', 'give' ) ); |
|
603 | + } elseif (email_exists($user_email) && $registering_new_user) { |
|
604 | + give_set_error('email_used', esc_html__('The email already active for another user.', 'give')); |
|
605 | 605 | } else { |
606 | 606 | // All the checks have run and it's good to go. |
607 | 607 | $valid_user_data['user_email'] = $user_email; |
608 | 608 | } |
609 | 609 | } else { |
610 | 610 | // No email. |
611 | - give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) ); |
|
611 | + give_set_error('email_empty', esc_html__('Enter an email.', 'give')); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | // Check password. |
615 | - if ( $user_pass && $pass_confirm ) { |
|
615 | + if ($user_pass && $pass_confirm) { |
|
616 | 616 | // Verify confirmation matches. |
617 | - if ( $user_pass != $pass_confirm ) { |
|
617 | + if ($user_pass != $pass_confirm) { |
|
618 | 618 | // Passwords do not match |
619 | - give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) ); |
|
619 | + give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give')); |
|
620 | 620 | } else { |
621 | 621 | // All is good to go. |
622 | 622 | $valid_user_data['user_pass'] = $user_pass; |
623 | 623 | } |
624 | 624 | } else { |
625 | 625 | // Password or confirmation missing. |
626 | - if ( ! $user_pass && $registering_new_user ) { |
|
626 | + if ( ! $user_pass && $registering_new_user) { |
|
627 | 627 | // The password is invalid. |
628 | - give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) ); |
|
629 | - } elseif ( ! $pass_confirm && $registering_new_user ) { |
|
628 | + give_set_error('password_empty', esc_html__('Enter a password.', 'give')); |
|
629 | + } elseif ( ! $pass_confirm && $registering_new_user) { |
|
630 | 630 | // Confirmation password is invalid. |
631 | - give_set_error( 'confirmation_empty', esc_html__( 'Enter the password confirmation.', 'give' ) ); |
|
631 | + give_set_error('confirmation_empty', esc_html__('Enter the password confirmation.', 'give')); |
|
632 | 632 | } |
633 | 633 | } |
634 | 634 | |
@@ -647,36 +647,36 @@ discard block |
||
647 | 647 | // Start an array to collect valid user data. |
648 | 648 | $valid_user_data = array( |
649 | 649 | // Assume there will be errors |
650 | - 'user_id' => - 1, |
|
650 | + 'user_id' => -1, |
|
651 | 651 | ); |
652 | 652 | |
653 | 653 | // Username. |
654 | - if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) { |
|
655 | - give_set_error( 'must_log_in', esc_html__( 'You must register or login to complete your donation.', 'give' ) ); |
|
654 | + if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') { |
|
655 | + give_set_error('must_log_in', esc_html__('You must register or login to complete your donation.', 'give')); |
|
656 | 656 | |
657 | 657 | return $valid_user_data; |
658 | 658 | } |
659 | 659 | |
660 | 660 | // Get the user by login. |
661 | - $user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) ); |
|
661 | + $user_data = get_user_by('login', strip_tags($_POST['give_user_login'])); |
|
662 | 662 | |
663 | 663 | // Check if user exists. |
664 | - if ( $user_data ) { |
|
664 | + if ($user_data) { |
|
665 | 665 | // Get password. |
666 | - $user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false; |
|
666 | + $user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false; |
|
667 | 667 | |
668 | 668 | // Check user_pass. |
669 | - if ( $user_pass ) { |
|
669 | + if ($user_pass) { |
|
670 | 670 | // Check if password is valid. |
671 | - if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { |
|
671 | + if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { |
|
672 | 672 | // Incorrect password. |
673 | 673 | give_set_error( |
674 | 674 | 'password_incorrect', |
675 | 675 | sprintf( |
676 | 676 | '%1$s <a href="%2$s">%3$s</a>', |
677 | - esc_html__( 'The password you entered is incorrect.', 'give' ), |
|
678 | - wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ), |
|
679 | - esc_html__( 'Reset Password', 'give' ) |
|
677 | + esc_html__('The password you entered is incorrect.', 'give'), |
|
678 | + wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"), |
|
679 | + esc_html__('Reset Password', 'give') |
|
680 | 680 | ) |
681 | 681 | ); |
682 | 682 | // All is correct. |
@@ -693,11 +693,11 @@ discard block |
||
693 | 693 | } |
694 | 694 | } else { |
695 | 695 | // Empty password. |
696 | - give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) ); |
|
696 | + give_set_error('password_empty', esc_html__('Enter a password.', 'give')); |
|
697 | 697 | } |
698 | 698 | } else { |
699 | 699 | // No username. |
700 | - give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) ); |
|
700 | + give_set_error('username_incorrect', esc_html__('The username you entered does not exist.', 'give')); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | return $valid_user_data; |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | */ |
713 | 713 | function give_purchase_form_validate_guest_user() { |
714 | 714 | |
715 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
715 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
716 | 716 | |
717 | 717 | // Start an array to collect valid user data. |
718 | 718 | $valid_user_data = array( |
@@ -721,38 +721,38 @@ discard block |
||
721 | 721 | ); |
722 | 722 | |
723 | 723 | // Show error message if user must be logged in. |
724 | - if ( give_logged_in_only( $form_id ) ) { |
|
725 | - give_set_error( 'logged_in_only', esc_html__( 'You must be logged in to donate.', 'give' ) ); |
|
724 | + if (give_logged_in_only($form_id)) { |
|
725 | + give_set_error('logged_in_only', esc_html__('You must be logged in to donate.', 'give')); |
|
726 | 726 | } |
727 | 727 | |
728 | 728 | // Get the guest email. |
729 | - $guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
729 | + $guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
730 | 730 | |
731 | 731 | // Check email. |
732 | - if ( $guest_email && strlen( $guest_email ) > 0 ) { |
|
732 | + if ($guest_email && strlen($guest_email) > 0) { |
|
733 | 733 | // Validate email. |
734 | - if ( ! is_email( $guest_email ) ) { |
|
734 | + if ( ! is_email($guest_email)) { |
|
735 | 735 | // Invalid email. |
736 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
736 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
737 | 737 | } else { |
738 | 738 | // All is good to go. |
739 | 739 | $valid_user_data['user_email'] = $guest_email; |
740 | 740 | |
741 | 741 | // Get user_id from donor if exist. |
742 | - $donor = new Give_Customer( $guest_email ); |
|
743 | - if ( $donor->id && $donor->user_id ) { |
|
742 | + $donor = new Give_Customer($guest_email); |
|
743 | + if ($donor->id && $donor->user_id) { |
|
744 | 744 | $valid_user_data['user_id'] = $donor->user_id; |
745 | 745 | } |
746 | 746 | } |
747 | 747 | } else { |
748 | 748 | // No email. |
749 | - give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) ); |
|
749 | + give_set_error('email_empty', esc_html__('Enter an email.', 'give')); |
|
750 | 750 | } |
751 | 751 | |
752 | 752 | // Loop through required fields and show error messages. |
753 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
754 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
755 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
753 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
754 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
755 | + give_set_error($value['error_id'], $value['error_message']); |
|
756 | 756 | } |
757 | 757 | } |
758 | 758 | |
@@ -768,36 +768,36 @@ discard block |
||
768 | 768 | * @since 1.0 |
769 | 769 | * @return integer |
770 | 770 | */ |
771 | -function give_register_and_login_new_user( $user_data = array() ) { |
|
771 | +function give_register_and_login_new_user($user_data = array()) { |
|
772 | 772 | // Verify the array. |
773 | - if ( empty( $user_data ) ) { |
|
774 | - return - 1; |
|
773 | + if (empty($user_data)) { |
|
774 | + return -1; |
|
775 | 775 | } |
776 | 776 | |
777 | - if ( give_get_errors() ) { |
|
778 | - return - 1; |
|
777 | + if (give_get_errors()) { |
|
778 | + return -1; |
|
779 | 779 | } |
780 | 780 | |
781 | - $user_args = apply_filters( 'give_insert_user_args', array( |
|
782 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '', |
|
783 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '', |
|
784 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '', |
|
785 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '', |
|
786 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '', |
|
787 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
788 | - 'role' => get_option( 'default_role' ), |
|
789 | - ), $user_data ); |
|
781 | + $user_args = apply_filters('give_insert_user_args', array( |
|
782 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', |
|
783 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', |
|
784 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', |
|
785 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', |
|
786 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', |
|
787 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
788 | + 'role' => get_option('default_role'), |
|
789 | + ), $user_data); |
|
790 | 790 | |
791 | 791 | // Insert new user. |
792 | - $user_id = wp_insert_user( $user_args ); |
|
792 | + $user_id = wp_insert_user($user_args); |
|
793 | 793 | |
794 | 794 | // Validate inserted user. |
795 | - if ( is_wp_error( $user_id ) ) { |
|
796 | - return - 1; |
|
795 | + if (is_wp_error($user_id)) { |
|
796 | + return -1; |
|
797 | 797 | } |
798 | 798 | |
799 | 799 | // Allow themes and plugins to filter the user data. |
800 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args ); |
|
800 | + $user_data = apply_filters('give_insert_user_data', $user_data, $user_args); |
|
801 | 801 | |
802 | 802 | /** |
803 | 803 | * Fires after inserting user. |
@@ -807,10 +807,10 @@ discard block |
||
807 | 807 | * @param int $user_id User id. |
808 | 808 | * @param array $user_data Array containing user data. |
809 | 809 | */ |
810 | - do_action( 'give_insert_user', $user_id, $user_data ); |
|
810 | + do_action('give_insert_user', $user_id, $user_data); |
|
811 | 811 | |
812 | 812 | // Login new user. |
813 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] ); |
|
813 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']); |
|
814 | 814 | |
815 | 815 | // Return user id. |
816 | 816 | return $user_id; |
@@ -825,27 +825,27 @@ discard block |
||
825 | 825 | * @since 1.0 |
826 | 826 | * @return array |
827 | 827 | */ |
828 | -function give_get_purchase_form_user( $valid_data = array() ) { |
|
828 | +function give_get_purchase_form_user($valid_data = array()) { |
|
829 | 829 | |
830 | 830 | // Initialize user. |
831 | 831 | $user = false; |
832 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
832 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
833 | 833 | |
834 | - if ( $is_ajax ) { |
|
834 | + if ($is_ajax) { |
|
835 | 835 | // Do not create or login the user during the ajax submission (check for errors only). |
836 | 836 | return true; |
837 | - } elseif ( is_user_logged_in() ) { |
|
837 | + } elseif (is_user_logged_in()) { |
|
838 | 838 | // Set the valid user as the logged in collected data. |
839 | 839 | $user = $valid_data['logged_in_user']; |
840 | - } elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) { |
|
840 | + } elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) { |
|
841 | 841 | // New user registration. |
842 | - if ( $valid_data['need_new_user'] === true ) { |
|
842 | + if ($valid_data['need_new_user'] === true) { |
|
843 | 843 | // Set user. |
844 | 844 | $user = $valid_data['new_user_data']; |
845 | 845 | // Register and login new user. |
846 | - $user['user_id'] = give_register_and_login_new_user( $user ); |
|
846 | + $user['user_id'] = give_register_and_login_new_user($user); |
|
847 | 847 | // User login |
848 | - } elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) { |
|
848 | + } elseif ($valid_data['need_user_login'] === true && ! $is_ajax) { |
|
849 | 849 | |
850 | 850 | /* |
851 | 851 | * The login form is now processed in the give_process_purchase_login() function. |
@@ -858,48 +858,48 @@ discard block |
||
858 | 858 | // Set user. |
859 | 859 | $user = $valid_data['login_user_data']; |
860 | 860 | // Login user. |
861 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] ); |
|
861 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); |
|
862 | 862 | } |
863 | 863 | } |
864 | 864 | |
865 | 865 | // Check guest checkout. |
866 | - if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) { |
|
866 | + if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) { |
|
867 | 867 | // Set user |
868 | 868 | $user = $valid_data['guest_user_data']; |
869 | 869 | } |
870 | 870 | |
871 | 871 | // Verify we have an user. |
872 | - if ( false === $user || empty( $user ) ) { |
|
872 | + if (false === $user || empty($user)) { |
|
873 | 873 | // Return false. |
874 | 874 | return false; |
875 | 875 | } |
876 | 876 | |
877 | 877 | // Get user first name. |
878 | - if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { |
|
879 | - $user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : ''; |
|
878 | + if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { |
|
879 | + $user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : ''; |
|
880 | 880 | } |
881 | 881 | |
882 | 882 | // Get user last name. |
883 | - if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { |
|
884 | - $user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : ''; |
|
883 | + if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { |
|
884 | + $user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : ''; |
|
885 | 885 | } |
886 | 886 | |
887 | 887 | // Get the user's billing address details. |
888 | 888 | $user['address'] = array(); |
889 | - $user['address']['line1'] = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false; |
|
890 | - $user['address']['line2'] = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false; |
|
891 | - $user['address']['city'] = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false; |
|
892 | - $user['address']['state'] = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false; |
|
893 | - $user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false; |
|
894 | - $user['address']['zip'] = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false; |
|
895 | - |
|
896 | - if ( empty( $user['address']['country'] ) ) { |
|
889 | + $user['address']['line1'] = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false; |
|
890 | + $user['address']['line2'] = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false; |
|
891 | + $user['address']['city'] = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false; |
|
892 | + $user['address']['state'] = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false; |
|
893 | + $user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false; |
|
894 | + $user['address']['zip'] = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false; |
|
895 | + |
|
896 | + if (empty($user['address']['country'])) { |
|
897 | 897 | $user['address'] = false; |
898 | 898 | } // Country will always be set if address fields are present. |
899 | 899 | |
900 | - if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) { |
|
900 | + if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) { |
|
901 | 901 | // Store the address in the user's meta so the donation form can be pre-populated with it on return purchases. |
902 | - update_user_meta( $user['user_id'], '_give_user_address', $user['address'] ); |
|
902 | + update_user_meta($user['user_id'], '_give_user_address', $user['address']); |
|
903 | 903 | } |
904 | 904 | |
905 | 905 | // Return valid user. |
@@ -918,16 +918,16 @@ discard block |
||
918 | 918 | $card_data = give_get_purchase_cc_info(); |
919 | 919 | |
920 | 920 | // Validate the card zip. |
921 | - if ( ! empty( $card_data['card_zip'] ) ) { |
|
922 | - if ( ! give_purchase_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { |
|
923 | - give_set_error( 'invalid_cc_zip', esc_html__( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) ); |
|
921 | + if ( ! empty($card_data['card_zip'])) { |
|
922 | + if ( ! give_purchase_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { |
|
923 | + give_set_error('invalid_cc_zip', esc_html__('The zip / postal code you entered for your billing address is invalid.', 'give')); |
|
924 | 924 | } |
925 | 925 | } |
926 | 926 | |
927 | 927 | // Ensure no spaces. |
928 | - if ( ! empty( $card_data['card_number'] ) ) { |
|
929 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs |
|
930 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces |
|
928 | + if ( ! empty($card_data['card_number'])) { |
|
929 | + $card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs |
|
930 | + $card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces |
|
931 | 931 | } |
932 | 932 | |
933 | 933 | // This should validate card numbers at some point too. |
@@ -943,17 +943,17 @@ discard block |
||
943 | 943 | */ |
944 | 944 | function give_get_purchase_cc_info() { |
945 | 945 | $cc_info = array(); |
946 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
947 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
948 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
949 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
950 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
951 | - $cc_info['card_address'] = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : ''; |
|
952 | - $cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : ''; |
|
953 | - $cc_info['card_city'] = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : ''; |
|
954 | - $cc_info['card_state'] = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : ''; |
|
955 | - $cc_info['card_country'] = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : ''; |
|
956 | - $cc_info['card_zip'] = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : ''; |
|
946 | + $cc_info['card_name'] = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : ''; |
|
947 | + $cc_info['card_number'] = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : ''; |
|
948 | + $cc_info['card_cvc'] = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : ''; |
|
949 | + $cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : ''; |
|
950 | + $cc_info['card_exp_year'] = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : ''; |
|
951 | + $cc_info['card_address'] = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : ''; |
|
952 | + $cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : ''; |
|
953 | + $cc_info['card_city'] = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : ''; |
|
954 | + $cc_info['card_state'] = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : ''; |
|
955 | + $cc_info['card_country'] = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : ''; |
|
956 | + $cc_info['card_zip'] = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : ''; |
|
957 | 957 | |
958 | 958 | // Return cc info |
959 | 959 | return $cc_info; |
@@ -969,14 +969,14 @@ discard block |
||
969 | 969 | * |
970 | 970 | * @return bool|mixed|void |
971 | 971 | */ |
972 | -function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
972 | +function give_purchase_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
973 | 973 | $ret = false; |
974 | 974 | |
975 | - if ( empty( $zip ) || empty( $country_code ) ) { |
|
975 | + if (empty($zip) || empty($country_code)) { |
|
976 | 976 | return $ret; |
977 | 977 | } |
978 | 978 | |
979 | - $country_code = strtoupper( $country_code ); |
|
979 | + $country_code = strtoupper($country_code); |
|
980 | 980 | |
981 | 981 | $zip_regex = array( |
982 | 982 | 'AD' => 'AD\d{3}', |
@@ -1136,11 +1136,11 @@ discard block |
||
1136 | 1136 | 'ZM' => '\d{5}', |
1137 | 1137 | ); |
1138 | 1138 | |
1139 | - if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) { |
|
1139 | + if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) { |
|
1140 | 1140 | $ret = true; |
1141 | 1141 | } |
1142 | 1142 | |
1143 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code ); |
|
1143 | + return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); |
|
1144 | 1144 | } |
1145 | 1145 | |
1146 | 1146 | |
@@ -1154,36 +1154,36 @@ discard block |
||
1154 | 1154 | * |
1155 | 1155 | * @return bool |
1156 | 1156 | */ |
1157 | -function give_validate_multi_donation_form_level( $valid_data, $data ) { |
|
1157 | +function give_validate_multi_donation_form_level($valid_data, $data) { |
|
1158 | 1158 | /* @var Give_Donate_Form $form */ |
1159 | - $form = new Give_Donate_Form( $data['give-form-id'] ); |
|
1159 | + $form = new Give_Donate_Form($data['give-form-id']); |
|
1160 | 1160 | |
1161 | 1161 | $donation_level_matched = false; |
1162 | 1162 | |
1163 | - if ( $form->is_multi_type_donation_form() ) { |
|
1163 | + if ($form->is_multi_type_donation_form()) { |
|
1164 | 1164 | |
1165 | 1165 | // Bailout. |
1166 | - if ( ! ( $variable_prices = $form->get_prices() ) ) { |
|
1166 | + if ( ! ($variable_prices = $form->get_prices())) { |
|
1167 | 1167 | return false; |
1168 | 1168 | } |
1169 | 1169 | |
1170 | 1170 | // Sanitize donation amount. |
1171 | - $data['give-amount'] = give_sanitize_amount( $data['give-amount'] ); |
|
1171 | + $data['give-amount'] = give_sanitize_amount($data['give-amount']); |
|
1172 | 1172 | |
1173 | 1173 | // Get number of decimals. |
1174 | 1174 | $default_decimals = give_get_price_decimals(); |
1175 | 1175 | |
1176 | - if ( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ) { |
|
1176 | + if ($data['give-amount'] === give_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']), $default_decimals)) { |
|
1177 | 1177 | return true; |
1178 | 1178 | } |
1179 | 1179 | |
1180 | 1180 | // Find correct donation level from all donation levels. |
1181 | - foreach ( $variable_prices as $variable_price ) { |
|
1181 | + foreach ($variable_prices as $variable_price) { |
|
1182 | 1182 | // Sanitize level amount. |
1183 | - $variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals ); |
|
1183 | + $variable_price['_give_amount'] = give_sanitize_amount($variable_price['_give_amount'], $default_decimals); |
|
1184 | 1184 | |
1185 | 1185 | // Set first match donation level ID. |
1186 | - if ( $data['give-amount'] === $variable_price['_give_amount'] ) { |
|
1186 | + if ($data['give-amount'] === $variable_price['_give_amount']) { |
|
1187 | 1187 | $_POST['give-price-id'] = $variable_price['_give_id']['level_id']; |
1188 | 1188 | $donation_level_matched = true; |
1189 | 1189 | break; |
@@ -1194,19 +1194,19 @@ discard block |
||
1194 | 1194 | // If yes then set price id to custom if amount is greater then custom minimum amount (if any). |
1195 | 1195 | if ( |
1196 | 1196 | ! $donation_level_matched |
1197 | - && ( 'yes' === get_post_meta( $data['give-form-id'], '_give_custom_amount', true ) ) |
|
1197 | + && ('yes' === get_post_meta($data['give-form-id'], '_give_custom_amount', true)) |
|
1198 | 1198 | ) { |
1199 | 1199 | // Sanitize custom minimum amount. |
1200 | - $custom_minimum_amount = give_sanitize_amount( get_post_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals ); |
|
1200 | + $custom_minimum_amount = give_sanitize_amount(get_post_meta($data['give-form-id'], '_give_custom_amount_minimum', true), $default_decimals); |
|
1201 | 1201 | |
1202 | - if ( $data['give-amount'] >= $custom_minimum_amount ) { |
|
1202 | + if ($data['give-amount'] >= $custom_minimum_amount) { |
|
1203 | 1203 | $_POST['give-price-id'] = 'custom'; |
1204 | 1204 | $donation_level_matched = true; |
1205 | 1205 | } |
1206 | 1206 | } |
1207 | 1207 | } |
1208 | 1208 | |
1209 | - return ( $donation_level_matched ? true : false ); |
|
1209 | + return ($donation_level_matched ? true : false); |
|
1210 | 1210 | } |
1211 | 1211 | |
1212 | -add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 ); |
|
1212 | +add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | public function __construct() { |
97 | 97 | |
98 | 98 | // get it started |
99 | - add_action( 'init', array( $this, 'init' ) ); |
|
99 | + add_action('init', array($this, 'init')); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -111,30 +111,30 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function init() { |
113 | 113 | |
114 | - $is_enabled = give_get_option( 'email_access' ); |
|
114 | + $is_enabled = give_get_option('email_access'); |
|
115 | 115 | |
116 | 116 | //Non-logged in users only |
117 | - if ( is_user_logged_in() || $is_enabled !== 'on' || is_admin() ) { |
|
117 | + if (is_user_logged_in() || $is_enabled !== 'on' || is_admin()) { |
|
118 | 118 | return; |
119 | 119 | } |
120 | 120 | |
121 | 121 | //Are db columns setup? |
122 | - $is_setup = give_get_option( 'email_access_installed' ); |
|
123 | - if ( empty( $is_setup ) ) { |
|
122 | + $is_setup = give_get_option('email_access_installed'); |
|
123 | + if (empty($is_setup)) { |
|
124 | 124 | $this->create_columns(); |
125 | 125 | } |
126 | 126 | |
127 | 127 | // Timeouts |
128 | - $this->verify_throttle = apply_filters( 'give_nl_verify_throttle', 300 ); |
|
129 | - $this->token_expiration = apply_filters( 'give_nl_token_expiration', 7200 ); |
|
128 | + $this->verify_throttle = apply_filters('give_nl_verify_throttle', 300); |
|
129 | + $this->token_expiration = apply_filters('give_nl_token_expiration', 7200); |
|
130 | 130 | |
131 | 131 | // Setup login |
132 | 132 | $this->check_for_token(); |
133 | 133 | |
134 | - if ( $this->token_exists ) { |
|
135 | - add_filter( 'give_can_view_receipt', '__return_true' ); |
|
136 | - add_filter( 'give_user_pending_verification', '__return_false' ); |
|
137 | - add_filter( 'give_get_users_donations_args', array( $this, 'users_donations_args' ) ); |
|
134 | + if ($this->token_exists) { |
|
135 | + add_filter('give_can_view_receipt', '__return_true'); |
|
136 | + add_filter('give_user_pending_verification', '__return_false'); |
|
137 | + add_filter('give_get_users_donations_args', array($this, 'users_donations_args')); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
@@ -148,25 +148,25 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return bool |
150 | 150 | */ |
151 | - public function can_send_email( $customer_id ) { |
|
151 | + public function can_send_email($customer_id) { |
|
152 | 152 | /* @var WPDB $wpdb */ |
153 | 153 | global $wpdb; |
154 | 154 | |
155 | 155 | // Prevent multiple emails within X minutes |
156 | - $throttle = date( 'Y-m-d H:i:s', time() - $this->verify_throttle ); |
|
156 | + $throttle = date('Y-m-d H:i:s', time() - $this->verify_throttle); |
|
157 | 157 | |
158 | 158 | // Does a user row exist? |
159 | 159 | $exists = (int) $wpdb->get_var( |
160 | - $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id ) |
|
160 | + $wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id) |
|
161 | 161 | ); |
162 | 162 | |
163 | - if ( 0 < $exists ) { |
|
163 | + if (0 < $exists) { |
|
164 | 164 | $row_id = (int) $wpdb->get_var( |
165 | - $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle ) |
|
165 | + $wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle) |
|
166 | 166 | ); |
167 | 167 | |
168 | - if ( $row_id < 1 ) { |
|
169 | - give_set_error( 'give_email_access_attempts_exhausted', esc_html__( 'Please wait a few minutes before requesting a new email access link.', 'give' ) ); |
|
168 | + if ($row_id < 1) { |
|
169 | + give_set_error('give_email_access_attempts_exhausted', esc_html__('Please wait a few minutes before requesting a new email access link.', 'give')); |
|
170 | 170 | |
171 | 171 | return false; |
172 | 172 | } |
@@ -186,34 +186,34 @@ discard block |
||
186 | 186 | * |
187 | 187 | * @return void |
188 | 188 | */ |
189 | - public function send_email( $customer_id, $email ) { |
|
189 | + public function send_email($customer_id, $email) { |
|
190 | 190 | |
191 | - $verify_key = wp_generate_password( 20, false ); |
|
191 | + $verify_key = wp_generate_password(20, false); |
|
192 | 192 | |
193 | 193 | // Generate a new verify key |
194 | - $this->set_verify_key( $customer_id, $email, $verify_key ); |
|
194 | + $this->set_verify_key($customer_id, $email, $verify_key); |
|
195 | 195 | |
196 | 196 | // Get the donation history page |
197 | - $page_id = give_get_option( 'history_page' ); |
|
197 | + $page_id = give_get_option('history_page'); |
|
198 | 198 | |
199 | - $access_url = add_query_arg( array( |
|
199 | + $access_url = add_query_arg(array( |
|
200 | 200 | 'give_nl' => $verify_key, |
201 | - ), get_permalink( $page_id ) ); |
|
201 | + ), get_permalink($page_id)); |
|
202 | 202 | |
203 | 203 | //Nice subject and message |
204 | - $subject = apply_filters( 'give_email_access_token_subject', sprintf( esc_html__( 'Your Access Link to %s', 'give' ), get_bloginfo( 'name' ) ) ); |
|
204 | + $subject = apply_filters('give_email_access_token_subject', sprintf(esc_html__('Your Access Link to %s', 'give'), get_bloginfo('name'))); |
|
205 | 205 | |
206 | - $message = esc_html__( 'You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give' ) . "\n\n"; |
|
207 | - $message .= '<a href="' . esc_url( $access_url ) . '" target="_blank">' . esc_html__( 'Access My Donation Details »', 'give' ) . '</a>' . "\n\n"; |
|
206 | + $message = esc_html__('You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give')."\n\n"; |
|
207 | + $message .= '<a href="'.esc_url($access_url).'" target="_blank">'.esc_html__('Access My Donation Details »', 'give').'</a>'."\n\n"; |
|
208 | 208 | $message .= "\n\n"; |
209 | - $message .= esc_html__( 'Sincerely,', 'give' ) . "\n"; |
|
210 | - $message .= get_bloginfo( 'name' ) . "\n"; |
|
209 | + $message .= esc_html__('Sincerely,', 'give')."\n"; |
|
210 | + $message .= get_bloginfo('name')."\n"; |
|
211 | 211 | |
212 | - $message = apply_filters( 'give_email_access_token_message', $message ); |
|
212 | + $message = apply_filters('give_email_access_token_message', $message); |
|
213 | 213 | |
214 | 214 | // Send the email |
215 | - Give()->emails->__set( 'heading', apply_filters( 'give_email_access_token_heading', esc_html__( 'Your Access Link', 'give' ) ) ); |
|
216 | - Give()->emails->send( $email, $subject, $message ); |
|
215 | + Give()->emails->__set('heading', apply_filters('give_email_access_token_heading', esc_html__('Your Access Link', 'give'))); |
|
216 | + Give()->emails->send($email, $subject, $message); |
|
217 | 217 | |
218 | 218 | } |
219 | 219 | |
@@ -227,24 +227,24 @@ discard block |
||
227 | 227 | */ |
228 | 228 | public function check_for_token() { |
229 | 229 | |
230 | - $token = isset( $_GET['give_nl'] ) ? $_GET['give_nl'] : ''; |
|
230 | + $token = isset($_GET['give_nl']) ? $_GET['give_nl'] : ''; |
|
231 | 231 | |
232 | 232 | // Check for cookie |
233 | - if ( empty( $token ) ) { |
|
234 | - $token = isset( $_COOKIE['give_nl'] ) ? $_COOKIE['give_nl'] : ''; |
|
233 | + if (empty($token)) { |
|
234 | + $token = isset($_COOKIE['give_nl']) ? $_COOKIE['give_nl'] : ''; |
|
235 | 235 | } |
236 | 236 | |
237 | - if ( ! empty( $token ) ) { |
|
238 | - if ( ! $this->is_valid_token( $token ) ) { |
|
239 | - if ( ! $this->is_valid_verify_key( $token ) ) { |
|
237 | + if ( ! empty($token)) { |
|
238 | + if ( ! $this->is_valid_token($token)) { |
|
239 | + if ( ! $this->is_valid_verify_key($token)) { |
|
240 | 240 | return; |
241 | 241 | } |
242 | 242 | } |
243 | 243 | |
244 | 244 | $this->token_exists = true; |
245 | 245 | // Set cookie |
246 | - $lifetime = current_time( 'timestamp' ) + Give()->session->set_expiration_time(); |
|
247 | - @setcookie( 'give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
246 | + $lifetime = current_time('timestamp') + Give()->session->set_expiration_time(); |
|
247 | + @setcookie('give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
@@ -258,18 +258,18 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @return bool |
260 | 260 | */ |
261 | - public function is_valid_token( $token ) { |
|
261 | + public function is_valid_token($token) { |
|
262 | 262 | |
263 | 263 | global $wpdb; |
264 | 264 | |
265 | 265 | // Make sure token isn't expired |
266 | - $expires = date( 'Y-m-d H:i:s', time() - $this->token_expiration ); |
|
266 | + $expires = date('Y-m-d H:i:s', time() - $this->token_expiration); |
|
267 | 267 | |
268 | 268 | $email = $wpdb->get_var( |
269 | - $wpdb->prepare( "SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires ) |
|
269 | + $wpdb->prepare("SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires) |
|
270 | 270 | ); |
271 | 271 | |
272 | - if ( ! empty( $email ) ) { |
|
272 | + if ( ! empty($email)) { |
|
273 | 273 | $this->token_email = $email; |
274 | 274 | $this->token = $token; |
275 | 275 | |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | } |
278 | 278 | |
279 | 279 | //Set error only if email access form isn't being submitted |
280 | - if ( ! isset( $_POST['give_email'] ) && ! isset( $_POST['_wpnonce'] ) ) { |
|
281 | - give_set_error( 'give_email_token_expired', apply_filters( 'give_email_token_expired_message', esc_html__( 'Your access token has expired. Please request a new one below:', 'give' ) ) ); |
|
280 | + if ( ! isset($_POST['give_email']) && ! isset($_POST['_wpnonce'])) { |
|
281 | + give_set_error('give_email_token_expired', apply_filters('give_email_token_expired_message', esc_html__('Your access token has expired. Please request a new one below:', 'give'))); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | return false; |
@@ -297,25 +297,25 @@ discard block |
||
297 | 297 | * |
298 | 298 | * @return void |
299 | 299 | */ |
300 | - public function set_verify_key( $customer_id, $email, $verify_key ) { |
|
300 | + public function set_verify_key($customer_id, $email, $verify_key) { |
|
301 | 301 | global $wpdb; |
302 | 302 | |
303 | - $now = date( 'Y-m-d H:i:s' ); |
|
303 | + $now = date('Y-m-d H:i:s'); |
|
304 | 304 | |
305 | 305 | // Insert or update? |
306 | 306 | $row_id = (int) $wpdb->get_var( |
307 | - $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id ) |
|
307 | + $wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id) |
|
308 | 308 | ); |
309 | 309 | |
310 | 310 | // Update |
311 | - if ( ! empty( $row_id ) ) { |
|
311 | + if ( ! empty($row_id)) { |
|
312 | 312 | $wpdb->query( |
313 | - $wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id ) |
|
313 | + $wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id) |
|
314 | 314 | ); |
315 | 315 | } // Insert |
316 | 316 | else { |
317 | 317 | $wpdb->query( |
318 | - $wpdb->prepare( "INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now ) |
|
318 | + $wpdb->prepare("INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now) |
|
319 | 319 | ); |
320 | 320 | } |
321 | 321 | } |
@@ -330,21 +330,21 @@ discard block |
||
330 | 330 | * |
331 | 331 | * @return bool |
332 | 332 | */ |
333 | - public function is_valid_verify_key( $token ) { |
|
333 | + public function is_valid_verify_key($token) { |
|
334 | 334 | /* @var WPDB $wpdb */ |
335 | 335 | global $wpdb; |
336 | 336 | |
337 | 337 | // See if the verify_key exists |
338 | 338 | $row = $wpdb->get_row( |
339 | - $wpdb->prepare( "SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token ) |
|
339 | + $wpdb->prepare("SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token) |
|
340 | 340 | ); |
341 | 341 | |
342 | - $now = date( 'Y-m-d H:i:s' ); |
|
342 | + $now = date('Y-m-d H:i:s'); |
|
343 | 343 | |
344 | 344 | // Set token |
345 | - if ( ! empty( $row ) ) { |
|
345 | + if ( ! empty($row)) { |
|
346 | 346 | $wpdb->query( |
347 | - $wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id ) |
|
347 | + $wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id) |
|
348 | 348 | ); |
349 | 349 | |
350 | 350 | $this->token_email = $row->email; |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * |
369 | 369 | * @return mixed |
370 | 370 | */ |
371 | - public function users_donations_args( $args ) { |
|
371 | + public function users_donations_args($args) { |
|
372 | 372 | $args['user'] = $this->token_email; |
373 | 373 | |
374 | 374 | return $args; |
@@ -389,11 +389,11 @@ discard block |
||
389 | 389 | global $wpdb; |
390 | 390 | |
391 | 391 | //Create columns in customers table |
392 | - $query = $wpdb->query( "ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`" ); |
|
392 | + $query = $wpdb->query("ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`"); |
|
393 | 393 | |
394 | 394 | //Columns added properly |
395 | - if ( $query ) { |
|
396 | - give_update_option( 'email_access_installed', 1 ); |
|
395 | + if ($query) { |
|
396 | + give_update_option('email_access_installed', 1); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return bool true if has variable prices, false otherwise |
25 | 25 | */ |
26 | -function give_has_variable_prices( $form_id = 0 ) { |
|
26 | +function give_has_variable_prices($form_id = 0) { |
|
27 | 27 | |
28 | - if ( empty( $form_id ) ) { |
|
28 | + if (empty($form_id)) { |
|
29 | 29 | return false; |
30 | 30 | } |
31 | 31 | |
32 | - $form = new Give_Donate_Form( $form_id ); |
|
32 | + $form = new Give_Donate_Form($form_id); |
|
33 | 33 | |
34 | 34 | return $form->has_variable_prices(); |
35 | 35 | } |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return array Variable prices |
46 | 46 | */ |
47 | -function give_get_variable_prices( $form_id = 0 ) { |
|
47 | +function give_get_variable_prices($form_id = 0) { |
|
48 | 48 | |
49 | - if ( empty( $form_id ) ) { |
|
49 | + if (empty($form_id)) { |
|
50 | 50 | return false; |
51 | 51 | } |
52 | 52 | |
53 | - $form = new Give_Donate_Form( $form_id ); |
|
53 | + $form = new Give_Donate_Form($form_id); |
|
54 | 54 | |
55 | 55 | return $form->prices; |
56 | 56 | |
@@ -67,13 +67,13 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return string $default_price |
69 | 69 | */ |
70 | -function give_get_default_multilevel_amount( $form_id ) { |
|
70 | +function give_get_default_multilevel_amount($form_id) { |
|
71 | 71 | $default_price = '1.00'; |
72 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
72 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
73 | 73 | |
74 | - foreach ( $prices as $price ) { |
|
74 | + foreach ($prices as $price) { |
|
75 | 75 | |
76 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
76 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
77 | 77 | $default_price = $price['_give_amount']; |
78 | 78 | } |
79 | 79 | |
@@ -94,19 +94,19 @@ discard block |
||
94 | 94 | * @return string $default_price |
95 | 95 | * @since 1.0 |
96 | 96 | */ |
97 | -function give_get_default_form_amount( $form_id ) { |
|
97 | +function give_get_default_form_amount($form_id) { |
|
98 | 98 | |
99 | - if ( give_has_variable_prices( $form_id ) ) { |
|
99 | + if (give_has_variable_prices($form_id)) { |
|
100 | 100 | |
101 | - $default_amount = give_get_default_multilevel_amount( $form_id ); |
|
101 | + $default_amount = give_get_default_multilevel_amount($form_id); |
|
102 | 102 | |
103 | 103 | } else { |
104 | 104 | |
105 | - $default_amount = get_post_meta( $form_id, '_give_set_price', true ); |
|
105 | + $default_amount = get_post_meta($form_id, '_give_set_price', true); |
|
106 | 106 | |
107 | 107 | } |
108 | 108 | |
109 | - return apply_filters( 'give_default_form_amount', $default_amount ); |
|
109 | + return apply_filters('give_default_form_amount', $default_amount); |
|
110 | 110 | |
111 | 111 | } |
112 | 112 | |
@@ -124,13 +124,13 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return bool |
126 | 126 | */ |
127 | -function give_is_custom_price_mode( $form_id = 0 ) { |
|
127 | +function give_is_custom_price_mode($form_id = 0) { |
|
128 | 128 | |
129 | - if ( empty( $form_id ) ) { |
|
129 | + if (empty($form_id)) { |
|
130 | 130 | return false; |
131 | 131 | } |
132 | 132 | |
133 | - $form = new Give_Donate_Form( $form_id ); |
|
133 | + $form = new Give_Donate_Form($form_id); |
|
134 | 134 | |
135 | 135 | return $form->is_custom_price_mode(); |
136 | 136 | } |
137 | 137 | \ No newline at end of file |