@@ -65,23 +65,23 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @param $args |
67 | 67 | */ |
68 | - public function __construct( $args ) { |
|
68 | + public function __construct($args) { |
|
69 | 69 | |
70 | 70 | // Only for admins. |
71 | - if ( ! is_admin() ) { |
|
71 | + if ( ! is_admin()) { |
|
72 | 72 | return; |
73 | 73 | } |
74 | 74 | |
75 | 75 | // This plugin is en_US native. |
76 | 76 | $this->locale = get_locale(); |
77 | - if ( 'en_US' === $this->locale ) { |
|
77 | + if ('en_US' === $this->locale) { |
|
78 | 78 | return; |
79 | 79 | } |
80 | 80 | |
81 | - $this->init( $args ); |
|
81 | + $this->init($args); |
|
82 | 82 | |
83 | - if ( ! $this->hide_promo() ) { |
|
84 | - add_action( $this->hook, array( $this, 'promo' ) ); |
|
83 | + if ( ! $this->hide_promo()) { |
|
84 | + add_action($this->hook, array($this, 'promo')); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @param array $args |
94 | 94 | */ |
95 | - private function init( $args ) { |
|
96 | - foreach ( $args as $key => $arg ) { |
|
95 | + private function init($args) { |
|
96 | + foreach ($args as $key => $arg) { |
|
97 | 97 | $this->$key = $arg; |
98 | 98 | } |
99 | 99 | |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | * @return bool |
108 | 108 | */ |
109 | 109 | private function hide_promo() { |
110 | - $hide_promo = Give_Cache::get( 'give_i18n_give_promo_hide', true ); |
|
111 | - if ( ! $hide_promo ) { |
|
112 | - if ( filter_input( INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT ) === 1 ) { |
|
110 | + $hide_promo = Give_Cache::get('give_i18n_give_promo_hide', true); |
|
111 | + if ( ! $hide_promo) { |
|
112 | + if (filter_input(INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT) === 1) { |
|
113 | 113 | // No expiration time, so this would normally not expire, but it wouldn't be copied to other sites etc. |
114 | - Give_Cache::set( 'give_i18n_give_promo_hide', true, null, true ); |
|
114 | + Give_Cache::set('give_i18n_give_promo_hide', true, null, true); |
|
115 | 115 | $hide_promo = true; |
116 | 116 | } |
117 | 117 | } |
@@ -130,20 +130,20 @@ discard block |
||
130 | 130 | $message = false; |
131 | 131 | |
132 | 132 | // Using a translation less than 90% complete. |
133 | - if ( $this->translation_exists && $this->translation_loaded && $this->percent_translated < 90 ) { |
|
134 | - $message = __( 'As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give' ); |
|
135 | - } elseif ( ! $this->translation_loaded && $this->translation_exists ) { |
|
136 | - $message = __( 'You\'re using WordPress in %1$s. While %2$s has been %3$d%% translated to %1$s, it has not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give' ); |
|
137 | - } elseif ( ! $this->translation_exists ) { |
|
138 | - $message = __( 'You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give' ); |
|
133 | + if ($this->translation_exists && $this->translation_loaded && $this->percent_translated < 90) { |
|
134 | + $message = __('As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give'); |
|
135 | + } elseif ( ! $this->translation_loaded && $this->translation_exists) { |
|
136 | + $message = __('You\'re using WordPress in %1$s. While %2$s has been %3$d%% translated to %1$s, it has not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give'); |
|
137 | + } elseif ( ! $this->translation_exists) { |
|
138 | + $message = __('You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give'); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | // Links. |
142 | - $registration_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__( 'WordPress.org', 'give' ) ); |
|
143 | - $translations_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__( 'complete the translation', 'give' ) ); |
|
142 | + $registration_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__('WordPress.org', 'give')); |
|
143 | + $translations_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__('complete the translation', 'give')); |
|
144 | 144 | |
145 | 145 | // Message. |
146 | - $message = sprintf( $message, $this->locale_name, 'Give', $this->percent_translated, $registration_link, $translations_link ); |
|
146 | + $message = sprintf($message, $this->locale_name, 'Give', $this->percent_translated, $registration_link, $translations_link); |
|
147 | 147 | |
148 | 148 | return $message; |
149 | 149 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | $this->translation_details(); |
158 | 158 | $message = $this->promo_message(); |
159 | 159 | |
160 | - if ( $message ) { ?> |
|
160 | + if ($message) { ?> |
|
161 | 161 | |
162 | 162 | <style> |
163 | 163 | /* Banner specific styles */ |
@@ -220,12 +220,12 @@ discard block |
||
220 | 220 | <a href="https://wordpress.org/support/register.php" class="alignleft give-i18n-icon" style="margin:0" target="_blank"><span class="dashicons dashicons-translation" style="font-size: 110px; text-decoration: none;"></span></a> |
221 | 221 | |
222 | 222 | <div class="give-i18n-notice-content"> |
223 | - <a href="<?php echo esc_url( add_query_arg( array( 'remove_i18n_promo' => '1' ) ) ); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a> |
|
223 | + <a href="<?php echo esc_url(add_query_arg(array('remove_i18n_promo' => '1'))); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a> |
|
224 | 224 | |
225 | - <h2 style="margin: 10px 0;"><?php printf( esc_html__( 'Help Translate Give to %s', 'give' ), $this->locale_name ); ?></h2> |
|
225 | + <h2 style="margin: 10px 0;"><?php printf(esc_html__('Help Translate Give to %s', 'give'), $this->locale_name); ?></h2> |
|
226 | 226 | <p><?php echo $message; ?></p> |
227 | 227 | <p> |
228 | - <a href="https://wordpress.org/support/register.php" target="_blank"><?php _e( 'Register now »', 'give' ); ?></a> |
|
228 | + <a href="https://wordpress.org/support/register.php" target="_blank"><?php _e('Register now »', 'give'); ?></a> |
|
229 | 229 | </p> |
230 | 230 | </div> |
231 | 231 | </div> |
@@ -242,11 +242,11 @@ discard block |
||
242 | 242 | */ |
243 | 243 | private function find_or_initialize_translation_details() { |
244 | 244 | |
245 | - $set = Give_Cache::get( "give_i18n_give_{$this->locale}", true ); |
|
245 | + $set = Give_Cache::get("give_i18n_give_{$this->locale}", true); |
|
246 | 246 | |
247 | - if ( ! $set ) { |
|
247 | + if ( ! $set) { |
|
248 | 248 | $set = $this->retrieve_translation_details(); |
249 | - Give_Cache::set( "give_i18n_give_{$this->locale}", $set, DAY_IN_SECONDS, true ); |
|
249 | + Give_Cache::set("give_i18n_give_{$this->locale}", $set, DAY_IN_SECONDS, true); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | return $set; |
@@ -260,10 +260,10 @@ discard block |
||
260 | 260 | private function translation_details() { |
261 | 261 | $set = $this->find_or_initialize_translation_details(); |
262 | 262 | |
263 | - $this->translation_exists = ! is_null( $set ); |
|
264 | - $this->translation_loaded = is_textdomain_loaded( 'give' ); |
|
263 | + $this->translation_exists = ! is_null($set); |
|
264 | + $this->translation_loaded = is_textdomain_loaded('give'); |
|
265 | 265 | |
266 | - $this->parse_translation_set( $set ); |
|
266 | + $this->parse_translation_set($set); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
@@ -275,26 +275,26 @@ discard block |
||
275 | 275 | */ |
276 | 276 | private function retrieve_translation_details() { |
277 | 277 | |
278 | - $api_url = trailingslashit( $this->glotpress_url ); |
|
278 | + $api_url = trailingslashit($this->glotpress_url); |
|
279 | 279 | |
280 | - $resp = wp_remote_get( $api_url ); |
|
280 | + $resp = wp_remote_get($api_url); |
|
281 | 281 | |
282 | - if ( is_wp_error( $resp ) || wp_remote_retrieve_response_code( $resp ) === '404' ) { |
|
282 | + if (is_wp_error($resp) || wp_remote_retrieve_response_code($resp) === '404') { |
|
283 | 283 | return null; |
284 | 284 | } |
285 | 285 | |
286 | - $body = wp_remote_retrieve_body( $resp ); |
|
287 | - unset( $resp ); |
|
286 | + $body = wp_remote_retrieve_body($resp); |
|
287 | + unset($resp); |
|
288 | 288 | |
289 | - if ( $body ) { |
|
290 | - $body = json_decode( $body ); |
|
289 | + if ($body) { |
|
290 | + $body = json_decode($body); |
|
291 | 291 | |
292 | - foreach ( $body->translation_sets as $set ) { |
|
293 | - if ( ! property_exists( $set, 'wp_locale' ) ) { |
|
292 | + foreach ($body->translation_sets as $set) { |
|
293 | + if ( ! property_exists($set, 'wp_locale')) { |
|
294 | 294 | continue; |
295 | 295 | } |
296 | 296 | |
297 | - if ( $this->locale == $set->wp_locale ) { |
|
297 | + if ($this->locale == $set->wp_locale) { |
|
298 | 298 | return $set; |
299 | 299 | } |
300 | 300 | } |
@@ -310,8 +310,8 @@ discard block |
||
310 | 310 | * |
311 | 311 | * @access private |
312 | 312 | */ |
313 | - private function parse_translation_set( $set ) { |
|
314 | - if ( $this->translation_exists && is_object( $set ) ) { |
|
313 | + private function parse_translation_set($set) { |
|
314 | + if ($this->translation_exists && is_object($set)) { |
|
315 | 315 | $this->locale_name = $set->name; |
316 | 316 | $this->percent_translated = $set->percent_translated; |
317 | 317 | } else { |
@@ -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 | |
@@ -28,21 +28,21 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return void |
30 | 30 | */ |
31 | -function give_complete_purchase( $payment_id, $new_status, $old_status ) { |
|
31 | +function give_complete_purchase($payment_id, $new_status, $old_status) { |
|
32 | 32 | |
33 | 33 | // Make sure that payments are only completed once. |
34 | - if ( $old_status == 'publish' || $old_status == 'complete' ) { |
|
34 | + if ($old_status == 'publish' || $old_status == 'complete') { |
|
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
38 | 38 | // Make sure the payment completion is only processed when new status is complete. |
39 | - if ( $new_status != 'publish' && $new_status != 'complete' ) { |
|
39 | + if ($new_status != 'publish' && $new_status != 'complete') { |
|
40 | 40 | return; |
41 | 41 | } |
42 | 42 | |
43 | - $payment = new Give_Payment( $payment_id ); |
|
43 | + $payment = new Give_Payment($payment_id); |
|
44 | 44 | |
45 | - $creation_date = get_post_field( 'post_date', $payment_id, 'raw' ); |
|
45 | + $creation_date = get_post_field('post_date', $payment_id, 'raw'); |
|
46 | 46 | $payment_meta = $payment->payment_meta; |
47 | 47 | $completed_date = $payment->completed_date; |
48 | 48 | $user_info = $payment->user_info; |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @param int $payment_id The ID of the payment. |
60 | 60 | */ |
61 | - do_action( 'give_pre_complete_purchase', $payment_id ); |
|
61 | + do_action('give_pre_complete_purchase', $payment_id); |
|
62 | 62 | |
63 | 63 | // Ensure these actions only run once, ever. |
64 | - if ( empty( $completed_date ) ) { |
|
64 | + if (empty($completed_date)) { |
|
65 | 65 | |
66 | - give_record_sale_in_log( $form_id, $payment_id, $price_id, $creation_date ); |
|
66 | + give_record_sale_in_log($form_id, $payment_id, $price_id, $creation_date); |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Fires after logging donation record. |
@@ -74,29 +74,29 @@ discard block |
||
74 | 74 | * @param int $payment_id The ID number of the payment. |
75 | 75 | * @param array $payment_meta The payment meta. |
76 | 76 | */ |
77 | - do_action( 'give_complete_form_donation', $form_id, $payment_id, $payment_meta ); |
|
77 | + do_action('give_complete_form_donation', $form_id, $payment_id, $payment_meta); |
|
78 | 78 | |
79 | 79 | } |
80 | 80 | |
81 | 81 | // Increase the earnings for this form ID. |
82 | - give_increase_earnings( $form_id, $amount ); |
|
83 | - give_increase_purchase_count( $form_id ); |
|
82 | + give_increase_earnings($form_id, $amount); |
|
83 | + give_increase_purchase_count($form_id); |
|
84 | 84 | |
85 | 85 | // @todo: Refresh only range related stat cache |
86 | 86 | give_delete_donation_stats(); |
87 | 87 | |
88 | 88 | // Increase the donor's donation stats. |
89 | - $customer = new Give_Customer( $customer_id ); |
|
89 | + $customer = new Give_Customer($customer_id); |
|
90 | 90 | $customer->increase_purchase_count(); |
91 | - $customer->increase_value( $amount ); |
|
91 | + $customer->increase_value($amount); |
|
92 | 92 | |
93 | - give_increase_total_earnings( $amount ); |
|
93 | + give_increase_total_earnings($amount); |
|
94 | 94 | |
95 | 95 | // Ensure this action only runs once ever. |
96 | - if ( empty( $completed_date ) ) { |
|
96 | + if (empty($completed_date)) { |
|
97 | 97 | |
98 | 98 | // Save the completed date. |
99 | - $payment->completed_date = current_time( 'mysql' ); |
|
99 | + $payment->completed_date = current_time('mysql'); |
|
100 | 100 | $payment->save(); |
101 | 101 | |
102 | 102 | /** |
@@ -106,12 +106,12 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @param int $payment_id The ID of the payment. |
108 | 108 | */ |
109 | - do_action( 'give_complete_donation', $payment_id ); |
|
109 | + do_action('give_complete_donation', $payment_id); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | } |
113 | 113 | |
114 | -add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 ); |
|
114 | +add_action('give_update_payment_status', 'give_complete_purchase', 100, 3); |
|
115 | 115 | |
116 | 116 | |
117 | 117 | /** |
@@ -125,24 +125,24 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @return void |
127 | 127 | */ |
128 | -function give_record_status_change( $payment_id, $new_status, $old_status ) { |
|
128 | +function give_record_status_change($payment_id, $new_status, $old_status) { |
|
129 | 129 | |
130 | 130 | // Get the list of statuses so that status in the payment note can be translated. |
131 | 131 | $stati = give_get_payment_statuses(); |
132 | - $old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status; |
|
133 | - $new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status; |
|
132 | + $old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status; |
|
133 | + $new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status; |
|
134 | 134 | |
135 | 135 | // translators: 1: old status 2: new status. |
136 | 136 | $status_change = sprintf( |
137 | - esc_html__( 'Status changed from %1$s to %2$s.', 'give' ), |
|
137 | + esc_html__('Status changed from %1$s to %2$s.', 'give'), |
|
138 | 138 | $old_status, |
139 | 139 | $new_status |
140 | 140 | ); |
141 | 141 | |
142 | - give_insert_payment_note( $payment_id, $status_change ); |
|
142 | + give_insert_payment_note($payment_id, $status_change); |
|
143 | 143 | } |
144 | 144 | |
145 | -add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 ); |
|
145 | +add_action('give_update_payment_status', 'give_record_status_change', 100, 3); |
|
146 | 146 | |
147 | 147 | |
148 | 148 | /** |
@@ -158,25 +158,25 @@ discard block |
||
158 | 158 | * |
159 | 159 | * @return void |
160 | 160 | */ |
161 | -function give_update_old_payments_with_totals( $data ) { |
|
162 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) { |
|
161 | +function give_update_old_payments_with_totals($data) { |
|
162 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) { |
|
163 | 163 | return; |
164 | 164 | } |
165 | 165 | |
166 | - if ( get_option( 'give_payment_totals_upgraded' ) ) { |
|
166 | + if (get_option('give_payment_totals_upgraded')) { |
|
167 | 167 | return; |
168 | 168 | } |
169 | 169 | |
170 | - $payments = give_get_payments( array( |
|
170 | + $payments = give_get_payments(array( |
|
171 | 171 | 'offset' => 0, |
172 | - 'number' => - 1, |
|
172 | + 'number' => -1, |
|
173 | 173 | 'mode' => 'all', |
174 | - ) ); |
|
174 | + )); |
|
175 | 175 | |
176 | - if ( $payments ) { |
|
177 | - foreach ( $payments as $payment ) { |
|
176 | + if ($payments) { |
|
177 | + foreach ($payments as $payment) { |
|
178 | 178 | |
179 | - $payment = new Give_Payment( $payment->ID ); |
|
179 | + $payment = new Give_Payment($payment->ID); |
|
180 | 180 | $meta = $payment->get_meta(); |
181 | 181 | |
182 | 182 | $payment->total = $meta['amount']; |
@@ -185,10 +185,10 @@ discard block |
||
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
188 | - add_option( 'give_payment_totals_upgraded', 1 ); |
|
188 | + add_option('give_payment_totals_upgraded', 1); |
|
189 | 189 | } |
190 | 190 | |
191 | -add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' ); |
|
191 | +add_action('give_upgrade_payments', 'give_update_old_payments_with_totals'); |
|
192 | 192 | |
193 | 193 | /** |
194 | 194 | * Mark Abandoned Donations |
@@ -202,17 +202,17 @@ discard block |
||
202 | 202 | function give_mark_abandoned_donations() { |
203 | 203 | $args = array( |
204 | 204 | 'status' => 'pending', |
205 | - 'number' => - 1, |
|
205 | + 'number' => -1, |
|
206 | 206 | 'output' => 'give_payments', |
207 | 207 | ); |
208 | 208 | |
209 | - add_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
209 | + add_filter('posts_where', 'give_filter_where_older_than_week'); |
|
210 | 210 | |
211 | - $payments = give_get_payments( $args ); |
|
211 | + $payments = give_get_payments($args); |
|
212 | 212 | |
213 | - remove_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
213 | + remove_filter('posts_where', 'give_filter_where_older_than_week'); |
|
214 | 214 | |
215 | - if ( $payments ) { |
|
215 | + if ($payments) { |
|
216 | 216 | /** |
217 | 217 | * Filter payment gateways: Used to set payment gateways which can be skip while transferring pending payment to abandon. |
218 | 218 | * |
@@ -220,13 +220,13 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @param array $skip_payment_gateways Array of payment gateways |
222 | 222 | */ |
223 | - $skip_payment_gateways = apply_filters( 'give_mark_abandoned_donation_gateways', array( 'offline' ) ); |
|
223 | + $skip_payment_gateways = apply_filters('give_mark_abandoned_donation_gateways', array('offline')); |
|
224 | 224 | |
225 | - foreach ( $payments as $payment ) { |
|
226 | - $gateway = give_get_payment_gateway( $payment ); |
|
225 | + foreach ($payments as $payment) { |
|
226 | + $gateway = give_get_payment_gateway($payment); |
|
227 | 227 | |
228 | 228 | // Skip payment gateways. |
229 | - if ( in_array( $gateway, $skip_payment_gateways ) ) { |
|
229 | + if (in_array($gateway, $skip_payment_gateways)) { |
|
230 | 230 | continue; |
231 | 231 | } |
232 | 232 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | } |
237 | 237 | } |
238 | 238 | |
239 | -add_action( 'give_weekly_scheduled_events', 'give_mark_abandoned_donations' ); |
|
239 | +add_action('give_weekly_scheduled_events', 'give_mark_abandoned_donations'); |
|
240 | 240 | |
241 | 241 | |
242 | 242 | /** |
@@ -248,12 +248,12 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @return void |
250 | 250 | */ |
251 | -function give_refresh_thismonth_stat_transients( $payment_ID ) { |
|
251 | +function give_refresh_thismonth_stat_transients($payment_ID) { |
|
252 | 252 | // Monthly stats. |
253 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
253 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
254 | 254 | |
255 | 255 | // @todo: Refresh only range related stat cache |
256 | 256 | give_delete_donation_stats(); |
257 | 257 | } |
258 | 258 | |
259 | -add_action( 'save_post_give_payment', 'give_refresh_thismonth_stat_transients' ); |
|
259 | +add_action('save_post_give_payment', 'give_refresh_thismonth_stat_transients'); |
@@ -889,7 +889,7 @@ discard block |
||
889 | 889 | * @access public |
890 | 890 | * |
891 | 891 | * @param string $meta_key Metadata name. Default is empty. |
892 | - * @param mixed $meta_value Metadata value. |
|
892 | + * @param string $meta_value Metadata value. |
|
893 | 893 | * @param bool $unique Optional. Whether the same key should not be added. Default is false. |
894 | 894 | * |
895 | 895 | * @return bool False for failure. True for success. |
@@ -921,7 +921,7 @@ discard block |
||
921 | 921 | * @access public |
922 | 922 | * |
923 | 923 | * @param string $meta_key Metadata name. Default is empty. |
924 | - * @param mixed $meta_value Optional. Metadata value. Default is empty. |
|
924 | + * @param string $meta_value Optional. Metadata value. Default is empty. |
|
925 | 925 | * |
926 | 926 | * @return bool False for failure. True for success. |
927 | 927 | */ |
@@ -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 | |
@@ -144,32 +144,32 @@ discard block |
||
144 | 144 | * @param bool $_id_or_email |
145 | 145 | * @param bool $by_user_id |
146 | 146 | */ |
147 | - public function __construct( $_id_or_email = false, $by_user_id = false ) { |
|
147 | + public function __construct($_id_or_email = false, $by_user_id = false) { |
|
148 | 148 | |
149 | 149 | $this->db = new Give_DB_Customers; |
150 | 150 | |
151 | 151 | if ( |
152 | 152 | false === $_id_or_email |
153 | - || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) |
|
153 | + || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email)) |
|
154 | 154 | ) { |
155 | 155 | return false; |
156 | 156 | } |
157 | 157 | |
158 | - $by_user_id = is_bool( $by_user_id ) ? $by_user_id : false; |
|
158 | + $by_user_id = is_bool($by_user_id) ? $by_user_id : false; |
|
159 | 159 | |
160 | - if ( is_numeric( $_id_or_email ) ) { |
|
160 | + if (is_numeric($_id_or_email)) { |
|
161 | 161 | $field = $by_user_id ? 'user_id' : 'id'; |
162 | 162 | } else { |
163 | 163 | $field = 'email'; |
164 | 164 | } |
165 | 165 | |
166 | - $customer = $this->db->get_customer_by( $field, $_id_or_email ); |
|
166 | + $customer = $this->db->get_customer_by($field, $_id_or_email); |
|
167 | 167 | |
168 | - if ( empty( $customer ) || ! is_object( $customer ) ) { |
|
168 | + if (empty($customer) || ! is_object($customer)) { |
|
169 | 169 | return false; |
170 | 170 | } |
171 | 171 | |
172 | - $this->setup_customer( $customer ); |
|
172 | + $this->setup_customer($customer); |
|
173 | 173 | |
174 | 174 | } |
175 | 175 | |
@@ -185,15 +185,15 @@ discard block |
||
185 | 185 | * |
186 | 186 | * @return bool If the setup was successful or not. |
187 | 187 | */ |
188 | - private function setup_customer( $customer ) { |
|
188 | + private function setup_customer($customer) { |
|
189 | 189 | |
190 | - if ( ! is_object( $customer ) ) { |
|
190 | + if ( ! is_object($customer)) { |
|
191 | 191 | return false; |
192 | 192 | } |
193 | 193 | |
194 | - foreach ( $customer as $key => $value ) { |
|
194 | + foreach ($customer as $key => $value) { |
|
195 | 195 | |
196 | - switch ( $key ) { |
|
196 | + switch ($key) { |
|
197 | 197 | |
198 | 198 | case 'notes': |
199 | 199 | $this->$key = $this->get_notes(); |
@@ -207,11 +207,11 @@ discard block |
||
207 | 207 | } |
208 | 208 | |
209 | 209 | // Get donor's all email including primary email. |
210 | - $this->emails = (array) $this->get_meta( 'additional_email', false ); |
|
211 | - $this->emails = array( 'primary' => $this->email ) + $this->emails; |
|
210 | + $this->emails = (array) $this->get_meta('additional_email', false); |
|
211 | + $this->emails = array('primary' => $this->email) + $this->emails; |
|
212 | 212 | |
213 | 213 | // Customer ID and email are the only things that are necessary, make sure they exist. |
214 | - if ( ! empty( $this->id ) && ! empty( $this->email ) ) { |
|
214 | + if ( ! empty($this->id) && ! empty($this->email)) { |
|
215 | 215 | return true; |
216 | 216 | } |
217 | 217 | |
@@ -225,16 +225,16 @@ discard block |
||
225 | 225 | * @since 1.0 |
226 | 226 | * @access public |
227 | 227 | */ |
228 | - public function __get( $key ) { |
|
228 | + public function __get($key) { |
|
229 | 229 | |
230 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
230 | + if (method_exists($this, 'get_'.$key)) { |
|
231 | 231 | |
232 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
232 | + return call_user_func(array($this, 'get_'.$key)); |
|
233 | 233 | |
234 | 234 | } else { |
235 | 235 | |
236 | 236 | /* translators: %s: property key */ |
237 | - return new WP_Error( 'give-customer-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); |
|
237 | + return new WP_Error('give-customer-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key)); |
|
238 | 238 | |
239 | 239 | } |
240 | 240 | |
@@ -250,9 +250,9 @@ discard block |
||
250 | 250 | * |
251 | 251 | * @return bool|int False if not a valid creation, customer ID if user is found or valid creation. |
252 | 252 | */ |
253 | - public function create( $data = array() ) { |
|
253 | + public function create($data = array()) { |
|
254 | 254 | |
255 | - if ( $this->id != 0 || empty( $data ) ) { |
|
255 | + if ($this->id != 0 || empty($data)) { |
|
256 | 256 | return false; |
257 | 257 | } |
258 | 258 | |
@@ -260,15 +260,15 @@ discard block |
||
260 | 260 | 'payment_ids' => '', |
261 | 261 | ); |
262 | 262 | |
263 | - $args = wp_parse_args( $data, $defaults ); |
|
264 | - $args = $this->sanitize_columns( $args ); |
|
263 | + $args = wp_parse_args($data, $defaults); |
|
264 | + $args = $this->sanitize_columns($args); |
|
265 | 265 | |
266 | - if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) { |
|
266 | + if (empty($args['email']) || ! is_email($args['email'])) { |
|
267 | 267 | return false; |
268 | 268 | } |
269 | 269 | |
270 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
271 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
270 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
271 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -278,18 +278,18 @@ discard block |
||
278 | 278 | * |
279 | 279 | * @param array $args Customer attributes. |
280 | 280 | */ |
281 | - do_action( 'give_customer_pre_create', $args ); |
|
281 | + do_action('give_customer_pre_create', $args); |
|
282 | 282 | |
283 | 283 | $created = false; |
284 | 284 | |
285 | 285 | // The DB class 'add' implies an update if the customer being asked to be created already exists |
286 | - if ( $this->db->add( $data ) ) { |
|
286 | + if ($this->db->add($data)) { |
|
287 | 287 | |
288 | 288 | // We've successfully added/updated the customer, reset the class vars with the new data |
289 | - $customer = $this->db->get_customer_by( 'email', $args['email'] ); |
|
289 | + $customer = $this->db->get_customer_by('email', $args['email']); |
|
290 | 290 | |
291 | 291 | // Setup the customer data with the values from DB |
292 | - $this->setup_customer( $customer ); |
|
292 | + $this->setup_customer($customer); |
|
293 | 293 | |
294 | 294 | $created = $this->id; |
295 | 295 | } |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | * customer ID if user is found or valid creation. |
304 | 304 | * @param array $args Customer attributes. |
305 | 305 | */ |
306 | - do_action( 'give_customer_post_create', $created, $args ); |
|
306 | + do_action('give_customer_post_create', $created, $args); |
|
307 | 307 | |
308 | 308 | return $created; |
309 | 309 | |
@@ -319,13 +319,13 @@ discard block |
||
319 | 319 | * |
320 | 320 | * @return bool If the update was successful or not. |
321 | 321 | */ |
322 | - public function update( $data = array() ) { |
|
322 | + public function update($data = array()) { |
|
323 | 323 | |
324 | - if ( empty( $data ) ) { |
|
324 | + if (empty($data)) { |
|
325 | 325 | return false; |
326 | 326 | } |
327 | 327 | |
328 | - $data = $this->sanitize_columns( $data ); |
|
328 | + $data = $this->sanitize_columns($data); |
|
329 | 329 | |
330 | 330 | /** |
331 | 331 | * Fires before updating customers. |
@@ -335,14 +335,14 @@ discard block |
||
335 | 335 | * @param int $customer_id Customer id. |
336 | 336 | * @param array $data Customer attributes. |
337 | 337 | */ |
338 | - do_action( 'give_customer_pre_update', $this->id, $data ); |
|
338 | + do_action('give_customer_pre_update', $this->id, $data); |
|
339 | 339 | |
340 | 340 | $updated = false; |
341 | 341 | |
342 | - if ( $this->db->update( $this->id, $data ) ) { |
|
342 | + if ($this->db->update($this->id, $data)) { |
|
343 | 343 | |
344 | - $customer = $this->db->get_customer_by( 'id', $this->id ); |
|
345 | - $this->setup_customer( $customer ); |
|
344 | + $customer = $this->db->get_customer_by('id', $this->id); |
|
345 | + $this->setup_customer($customer); |
|
346 | 346 | |
347 | 347 | $updated = true; |
348 | 348 | } |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * @param int $customer_id Customer id. |
357 | 357 | * @param array $data Customer attributes. |
358 | 358 | */ |
359 | - do_action( 'give_customer_post_update', $updated, $this->id, $data ); |
|
359 | + do_action('give_customer_post_update', $updated, $this->id, $data); |
|
360 | 360 | |
361 | 361 | return $updated; |
362 | 362 | } |
@@ -374,27 +374,27 @@ discard block |
||
374 | 374 | * |
375 | 375 | * @return bool If the attachment was successfuly. |
376 | 376 | */ |
377 | - public function attach_payment( $payment_id = 0, $update_stats = true ) { |
|
377 | + public function attach_payment($payment_id = 0, $update_stats = true) { |
|
378 | 378 | |
379 | - if ( empty( $payment_id ) ) { |
|
379 | + if (empty($payment_id)) { |
|
380 | 380 | return false; |
381 | 381 | } |
382 | 382 | |
383 | - if ( empty( $this->payment_ids ) ) { |
|
383 | + if (empty($this->payment_ids)) { |
|
384 | 384 | |
385 | 385 | $new_payment_ids = $payment_id; |
386 | 386 | |
387 | 387 | } else { |
388 | 388 | |
389 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
389 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
390 | 390 | |
391 | - if ( in_array( $payment_id, $payment_ids ) ) { |
|
391 | + if (in_array($payment_id, $payment_ids)) { |
|
392 | 392 | $update_stats = false; |
393 | 393 | } |
394 | 394 | |
395 | 395 | $payment_ids[] = $payment_id; |
396 | 396 | |
397 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
397 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
398 | 398 | |
399 | 399 | } |
400 | 400 | |
@@ -406,20 +406,20 @@ discard block |
||
406 | 406 | * @param int $payment_id Payment id. |
407 | 407 | * @param int $customer_id Customer id. |
408 | 408 | */ |
409 | - do_action( 'give_customer_pre_attach_payment', $payment_id, $this->id ); |
|
409 | + do_action('give_customer_pre_attach_payment', $payment_id, $this->id); |
|
410 | 410 | |
411 | - $payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
411 | + $payment_added = $this->update(array('payment_ids' => $new_payment_ids)); |
|
412 | 412 | |
413 | - if ( $payment_added ) { |
|
413 | + if ($payment_added) { |
|
414 | 414 | |
415 | 415 | $this->payment_ids = $new_payment_ids; |
416 | 416 | |
417 | 417 | // We added this payment successfully, increment the stats |
418 | - if ( $update_stats ) { |
|
419 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
418 | + if ($update_stats) { |
|
419 | + $payment_amount = give_get_payment_amount($payment_id); |
|
420 | 420 | |
421 | - if ( ! empty( $payment_amount ) ) { |
|
422 | - $this->increase_value( $payment_amount ); |
|
421 | + if ( ! empty($payment_amount)) { |
|
422 | + $this->increase_value($payment_amount); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | $this->increase_purchase_count(); |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | * @param int $payment_id Payment id. |
436 | 436 | * @param int $customer_id Customer id. |
437 | 437 | */ |
438 | - do_action( 'give_customer_post_attach_payment', $payment_added, $payment_id, $this->id ); |
|
438 | + do_action('give_customer_post_attach_payment', $payment_added, $payment_id, $this->id); |
|
439 | 439 | |
440 | 440 | return $payment_added; |
441 | 441 | } |
@@ -453,33 +453,33 @@ discard block |
||
453 | 453 | * |
454 | 454 | * @return boolean If the removal was successful. |
455 | 455 | */ |
456 | - public function remove_payment( $payment_id = 0, $update_stats = true ) { |
|
456 | + public function remove_payment($payment_id = 0, $update_stats = true) { |
|
457 | 457 | |
458 | - if ( empty( $payment_id ) ) { |
|
458 | + if (empty($payment_id)) { |
|
459 | 459 | return false; |
460 | 460 | } |
461 | 461 | |
462 | - $payment = new Give_Payment( $payment_id ); |
|
462 | + $payment = new Give_Payment($payment_id); |
|
463 | 463 | |
464 | - if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) { |
|
464 | + if ('publish' !== $payment->status && 'revoked' !== $payment->status) { |
|
465 | 465 | $update_stats = false; |
466 | 466 | } |
467 | 467 | |
468 | 468 | $new_payment_ids = ''; |
469 | 469 | |
470 | - if ( ! empty( $this->payment_ids ) ) { |
|
470 | + if ( ! empty($this->payment_ids)) { |
|
471 | 471 | |
472 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
472 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
473 | 473 | |
474 | - $pos = array_search( $payment_id, $payment_ids ); |
|
475 | - if ( false === $pos ) { |
|
474 | + $pos = array_search($payment_id, $payment_ids); |
|
475 | + if (false === $pos) { |
|
476 | 476 | return false; |
477 | 477 | } |
478 | 478 | |
479 | - unset( $payment_ids[ $pos ] ); |
|
480 | - $payment_ids = array_filter( $payment_ids ); |
|
479 | + unset($payment_ids[$pos]); |
|
480 | + $payment_ids = array_filter($payment_ids); |
|
481 | 481 | |
482 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
482 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
483 | 483 | |
484 | 484 | } |
485 | 485 | |
@@ -491,20 +491,20 @@ discard block |
||
491 | 491 | * @param int $payment_id Payment id. |
492 | 492 | * @param int $customer_id Customer id. |
493 | 493 | */ |
494 | - do_action( 'give_customer_pre_remove_payment', $payment_id, $this->id ); |
|
494 | + do_action('give_customer_pre_remove_payment', $payment_id, $this->id); |
|
495 | 495 | |
496 | - $payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
496 | + $payment_removed = $this->update(array('payment_ids' => $new_payment_ids)); |
|
497 | 497 | |
498 | - if ( $payment_removed ) { |
|
498 | + if ($payment_removed) { |
|
499 | 499 | |
500 | 500 | $this->payment_ids = $new_payment_ids; |
501 | 501 | |
502 | - if ( $update_stats ) { |
|
502 | + if ($update_stats) { |
|
503 | 503 | // We removed this payment successfully, decrement the stats |
504 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
504 | + $payment_amount = give_get_payment_amount($payment_id); |
|
505 | 505 | |
506 | - if ( ! empty( $payment_amount ) ) { |
|
507 | - $this->decrease_value( $payment_amount ); |
|
506 | + if ( ! empty($payment_amount)) { |
|
507 | + $this->decrease_value($payment_amount); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | $this->decrease_purchase_count(); |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | * @param int $payment_id Payment id. |
521 | 521 | * @param int $customer_id Customer id. |
522 | 522 | */ |
523 | - do_action( 'give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id ); |
|
523 | + do_action('give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id); |
|
524 | 524 | |
525 | 525 | return $payment_removed; |
526 | 526 | |
@@ -536,10 +536,10 @@ discard block |
||
536 | 536 | * |
537 | 537 | * @return int The donation count. |
538 | 538 | */ |
539 | - public function increase_purchase_count( $count = 1 ) { |
|
539 | + public function increase_purchase_count($count = 1) { |
|
540 | 540 | |
541 | 541 | // Make sure it's numeric and not negative. |
542 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
542 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
543 | 543 | return false; |
544 | 544 | } |
545 | 545 | |
@@ -553,9 +553,9 @@ discard block |
||
553 | 553 | * @param int $count The number to increase by. |
554 | 554 | * @param int $customer_id Customer id. |
555 | 555 | */ |
556 | - do_action( 'give_customer_pre_increase_purchase_count', $count, $this->id ); |
|
556 | + do_action('give_customer_pre_increase_purchase_count', $count, $this->id); |
|
557 | 557 | |
558 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
558 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
559 | 559 | $this->purchase_count = $new_total; |
560 | 560 | } |
561 | 561 | |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | * @param int $count The number increased by. |
569 | 569 | * @param int $customer_id Customer id. |
570 | 570 | */ |
571 | - do_action( 'give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id ); |
|
571 | + do_action('give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id); |
|
572 | 572 | |
573 | 573 | return $this->purchase_count; |
574 | 574 | } |
@@ -583,16 +583,16 @@ discard block |
||
583 | 583 | * |
584 | 584 | * @return mixed If successful, the new count, otherwise false. |
585 | 585 | */ |
586 | - public function decrease_purchase_count( $count = 1 ) { |
|
586 | + public function decrease_purchase_count($count = 1) { |
|
587 | 587 | |
588 | 588 | // Make sure it's numeric and not negative |
589 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
589 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
590 | 590 | return false; |
591 | 591 | } |
592 | 592 | |
593 | 593 | $new_total = (int) $this->purchase_count - (int) $count; |
594 | 594 | |
595 | - if ( $new_total < 0 ) { |
|
595 | + if ($new_total < 0) { |
|
596 | 596 | $new_total = 0; |
597 | 597 | } |
598 | 598 | |
@@ -604,9 +604,9 @@ discard block |
||
604 | 604 | * @param int $count The number to decrease by. |
605 | 605 | * @param int $customer_id Customer id. |
606 | 606 | */ |
607 | - do_action( 'give_customer_pre_decrease_purchase_count', $count, $this->id ); |
|
607 | + do_action('give_customer_pre_decrease_purchase_count', $count, $this->id); |
|
608 | 608 | |
609 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
609 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
610 | 610 | $this->purchase_count = $new_total; |
611 | 611 | } |
612 | 612 | |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | * @param int $count The number decreased by. |
620 | 620 | * @param int $customer_id Customer id. |
621 | 621 | */ |
622 | - do_action( 'give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id ); |
|
622 | + do_action('give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id); |
|
623 | 623 | |
624 | 624 | return $this->purchase_count; |
625 | 625 | } |
@@ -634,9 +634,9 @@ discard block |
||
634 | 634 | * |
635 | 635 | * @return mixed If successful, the new value, otherwise false. |
636 | 636 | */ |
637 | - public function increase_value( $value = 0.00 ) { |
|
637 | + public function increase_value($value = 0.00) { |
|
638 | 638 | |
639 | - $new_value = floatval( $this->purchase_value ) + $value; |
|
639 | + $new_value = floatval($this->purchase_value) + $value; |
|
640 | 640 | |
641 | 641 | /** |
642 | 642 | * Fires before increasing customer lifetime value. |
@@ -646,9 +646,9 @@ discard block |
||
646 | 646 | * @param float $value The value to increase by. |
647 | 647 | * @param int $customer_id Customer id. |
648 | 648 | */ |
649 | - do_action( 'give_customer_pre_increase_value', $value, $this->id ); |
|
649 | + do_action('give_customer_pre_increase_value', $value, $this->id); |
|
650 | 650 | |
651 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
651 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
652 | 652 | $this->purchase_value = $new_value; |
653 | 653 | } |
654 | 654 | |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | * @param float $value The value increased by. |
662 | 662 | * @param int $customer_id Customer id. |
663 | 663 | */ |
664 | - do_action( 'give_customer_post_increase_value', $this->purchase_value, $value, $this->id ); |
|
664 | + do_action('give_customer_post_increase_value', $this->purchase_value, $value, $this->id); |
|
665 | 665 | |
666 | 666 | return $this->purchase_value; |
667 | 667 | } |
@@ -676,11 +676,11 @@ discard block |
||
676 | 676 | * |
677 | 677 | * @return mixed If successful, the new value, otherwise false. |
678 | 678 | */ |
679 | - public function decrease_value( $value = 0.00 ) { |
|
679 | + public function decrease_value($value = 0.00) { |
|
680 | 680 | |
681 | - $new_value = floatval( $this->purchase_value ) - $value; |
|
681 | + $new_value = floatval($this->purchase_value) - $value; |
|
682 | 682 | |
683 | - if ( $new_value < 0 ) { |
|
683 | + if ($new_value < 0) { |
|
684 | 684 | $new_value = 0.00; |
685 | 685 | } |
686 | 686 | |
@@ -692,9 +692,9 @@ discard block |
||
692 | 692 | * @param float $value The value to decrease by. |
693 | 693 | * @param int $customer_id Customer id. |
694 | 694 | */ |
695 | - do_action( 'give_customer_pre_decrease_value', $value, $this->id ); |
|
695 | + do_action('give_customer_pre_decrease_value', $value, $this->id); |
|
696 | 696 | |
697 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
697 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
698 | 698 | $this->purchase_value = $new_value; |
699 | 699 | } |
700 | 700 | |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | * @param float $value The value decreased by. |
708 | 708 | * @param int $customer_id Customer id. |
709 | 709 | */ |
710 | - do_action( 'give_customer_post_decrease_value', $this->purchase_value, $value, $this->id ); |
|
710 | + do_action('give_customer_post_decrease_value', $this->purchase_value, $value, $this->id); |
|
711 | 711 | |
712 | 712 | return $this->purchase_value; |
713 | 713 | } |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | * |
727 | 727 | * @return mixed If successful, the new donation stat value, otherwise false. |
728 | 728 | */ |
729 | - public function update_donation_value( $curr_amount, $new_amount ) { |
|
729 | + public function update_donation_value($curr_amount, $new_amount) { |
|
730 | 730 | /** |
731 | 731 | * Payment total difference value can be: |
732 | 732 | * zero (in case amount not change) |
@@ -736,15 +736,15 @@ discard block |
||
736 | 736 | $payment_total_diff = $new_amount - $curr_amount; |
737 | 737 | |
738 | 738 | // We do not need to update donation stat if donation did not change. |
739 | - if ( ! $payment_total_diff ) { |
|
739 | + if ( ! $payment_total_diff) { |
|
740 | 740 | return false; |
741 | 741 | } |
742 | 742 | |
743 | - if ( $payment_total_diff > 0 ) { |
|
744 | - $this->increase_value( $payment_total_diff ); |
|
743 | + if ($payment_total_diff > 0) { |
|
744 | + $this->increase_value($payment_total_diff); |
|
745 | 745 | } else { |
746 | 746 | // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
747 | - $this->decrease_value( - $payment_total_diff ); |
|
747 | + $this->decrease_value( -$payment_total_diff ); |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | return $this->purchase_value; |
@@ -761,15 +761,15 @@ discard block |
||
761 | 761 | * |
762 | 762 | * @return array The notes requested. |
763 | 763 | */ |
764 | - public function get_notes( $length = 20, $paged = 1 ) { |
|
764 | + public function get_notes($length = 20, $paged = 1) { |
|
765 | 765 | |
766 | - $length = is_numeric( $length ) ? $length : 20; |
|
767 | - $offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0; |
|
766 | + $length = is_numeric($length) ? $length : 20; |
|
767 | + $offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0; |
|
768 | 768 | |
769 | 769 | $all_notes = $this->get_raw_notes(); |
770 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
770 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
771 | 771 | |
772 | - $desired_notes = array_slice( $notes_array, $offset, $length ); |
|
772 | + $desired_notes = array_slice($notes_array, $offset, $length); |
|
773 | 773 | |
774 | 774 | return $desired_notes; |
775 | 775 | |
@@ -786,9 +786,9 @@ discard block |
||
786 | 786 | public function get_notes_count() { |
787 | 787 | |
788 | 788 | $all_notes = $this->get_raw_notes(); |
789 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
789 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
790 | 790 | |
791 | - return count( $notes_array ); |
|
791 | + return count($notes_array); |
|
792 | 792 | |
793 | 793 | } |
794 | 794 | |
@@ -802,22 +802,22 @@ discard block |
||
802 | 802 | * |
803 | 803 | * @return string|boolean The new note if added successfully, false otherwise. |
804 | 804 | */ |
805 | - public function add_note( $note = '' ) { |
|
805 | + public function add_note($note = '') { |
|
806 | 806 | |
807 | - $note = trim( $note ); |
|
808 | - if ( empty( $note ) ) { |
|
807 | + $note = trim($note); |
|
808 | + if (empty($note)) { |
|
809 | 809 | return false; |
810 | 810 | } |
811 | 811 | |
812 | 812 | $notes = $this->get_raw_notes(); |
813 | 813 | |
814 | - if ( empty( $notes ) ) { |
|
814 | + if (empty($notes)) { |
|
815 | 815 | $notes = ''; |
816 | 816 | } |
817 | 817 | |
818 | - $note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note; |
|
819 | - $new_note = apply_filters( 'give_customer_add_note_string', $note_string ); |
|
820 | - $notes .= "\n\n" . $new_note; |
|
818 | + $note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note; |
|
819 | + $new_note = apply_filters('give_customer_add_note_string', $note_string); |
|
820 | + $notes .= "\n\n".$new_note; |
|
821 | 821 | |
822 | 822 | /** |
823 | 823 | * Fires before customer note added. |
@@ -827,11 +827,11 @@ discard block |
||
827 | 827 | * @param string $new_note New note to add. |
828 | 828 | * @param int $customer_id Customer id. |
829 | 829 | */ |
830 | - do_action( 'give_customer_pre_add_note', $new_note, $this->id ); |
|
830 | + do_action('give_customer_pre_add_note', $new_note, $this->id); |
|
831 | 831 | |
832 | - $updated = $this->update( array( 'notes' => $notes ) ); |
|
832 | + $updated = $this->update(array('notes' => $notes)); |
|
833 | 833 | |
834 | - if ( $updated ) { |
|
834 | + if ($updated) { |
|
835 | 835 | $this->notes = $this->get_notes(); |
836 | 836 | } |
837 | 837 | |
@@ -844,7 +844,7 @@ discard block |
||
844 | 844 | * @param string $new_note New note added. |
845 | 845 | * @param int $customer_id Customer id. |
846 | 846 | */ |
847 | - do_action( 'give_customer_post_add_note', $this->notes, $new_note, $this->id ); |
|
847 | + do_action('give_customer_post_add_note', $this->notes, $new_note, $this->id); |
|
848 | 848 | |
849 | 849 | // Return the formatted note, so we can test, as well as update any displays |
850 | 850 | return $new_note; |
@@ -861,7 +861,7 @@ discard block |
||
861 | 861 | */ |
862 | 862 | private function get_raw_notes() { |
863 | 863 | |
864 | - $all_notes = $this->db->get_column( 'notes', $this->id ); |
|
864 | + $all_notes = $this->db->get_column('notes', $this->id); |
|
865 | 865 | |
866 | 866 | return $all_notes; |
867 | 867 | |
@@ -878,8 +878,8 @@ discard block |
||
878 | 878 | * |
879 | 879 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true. |
880 | 880 | */ |
881 | - public function get_meta( $meta_key = '', $single = true ) { |
|
882 | - return Give()->customer_meta->get_meta( $this->id, $meta_key, $single ); |
|
881 | + public function get_meta($meta_key = '', $single = true) { |
|
882 | + return Give()->customer_meta->get_meta($this->id, $meta_key, $single); |
|
883 | 883 | } |
884 | 884 | |
885 | 885 | /** |
@@ -894,8 +894,8 @@ discard block |
||
894 | 894 | * |
895 | 895 | * @return bool False for failure. True for success. |
896 | 896 | */ |
897 | - public function add_meta( $meta_key = '', $meta_value, $unique = false ) { |
|
898 | - return Give()->customer_meta->add_meta( $this->id, $meta_key, $meta_value, $unique ); |
|
897 | + public function add_meta($meta_key = '', $meta_value, $unique = false) { |
|
898 | + return Give()->customer_meta->add_meta($this->id, $meta_key, $meta_value, $unique); |
|
899 | 899 | } |
900 | 900 | |
901 | 901 | /** |
@@ -910,8 +910,8 @@ discard block |
||
910 | 910 | * |
911 | 911 | * @return bool False on failure, true if success. |
912 | 912 | */ |
913 | - public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) { |
|
914 | - return Give()->customer_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value ); |
|
913 | + public function update_meta($meta_key = '', $meta_value, $prev_value = '') { |
|
914 | + return Give()->customer_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value); |
|
915 | 915 | } |
916 | 916 | |
917 | 917 | /** |
@@ -925,8 +925,8 @@ discard block |
||
925 | 925 | * |
926 | 926 | * @return bool False for failure. True for success. |
927 | 927 | */ |
928 | - public function delete_meta( $meta_key = '', $meta_value = '' ) { |
|
929 | - return Give()->customer_meta->delete_meta( $this->id, $meta_key, $meta_value ); |
|
928 | + public function delete_meta($meta_key = '', $meta_value = '') { |
|
929 | + return Give()->customer_meta->delete_meta($this->id, $meta_key, $meta_value); |
|
930 | 930 | } |
931 | 931 | |
932 | 932 | /** |
@@ -939,51 +939,51 @@ discard block |
||
939 | 939 | * |
940 | 940 | * @return array The sanitized data, based off column defaults. |
941 | 941 | */ |
942 | - private function sanitize_columns( $data ) { |
|
942 | + private function sanitize_columns($data) { |
|
943 | 943 | |
944 | 944 | $columns = $this->db->get_columns(); |
945 | 945 | $default_values = $this->db->get_column_defaults(); |
946 | 946 | |
947 | - foreach ( $columns as $key => $type ) { |
|
947 | + foreach ($columns as $key => $type) { |
|
948 | 948 | |
949 | 949 | // Only sanitize data that we were provided |
950 | - if ( ! array_key_exists( $key, $data ) ) { |
|
950 | + if ( ! array_key_exists($key, $data)) { |
|
951 | 951 | continue; |
952 | 952 | } |
953 | 953 | |
954 | - switch ( $type ) { |
|
954 | + switch ($type) { |
|
955 | 955 | |
956 | 956 | case '%s': |
957 | - if ( 'email' == $key ) { |
|
958 | - $data[ $key ] = sanitize_email( $data[ $key ] ); |
|
959 | - } elseif ( 'notes' == $key ) { |
|
960 | - $data[ $key ] = strip_tags( $data[ $key ] ); |
|
957 | + if ('email' == $key) { |
|
958 | + $data[$key] = sanitize_email($data[$key]); |
|
959 | + } elseif ('notes' == $key) { |
|
960 | + $data[$key] = strip_tags($data[$key]); |
|
961 | 961 | } else { |
962 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
962 | + $data[$key] = sanitize_text_field($data[$key]); |
|
963 | 963 | } |
964 | 964 | break; |
965 | 965 | |
966 | 966 | case '%d': |
967 | - if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) { |
|
968 | - $data[ $key ] = $default_values[ $key ]; |
|
967 | + if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) { |
|
968 | + $data[$key] = $default_values[$key]; |
|
969 | 969 | } else { |
970 | - $data[ $key ] = absint( $data[ $key ] ); |
|
970 | + $data[$key] = absint($data[$key]); |
|
971 | 971 | } |
972 | 972 | break; |
973 | 973 | |
974 | 974 | case '%f': |
975 | 975 | // Convert what was given to a float |
976 | - $value = floatval( $data[ $key ] ); |
|
976 | + $value = floatval($data[$key]); |
|
977 | 977 | |
978 | - if ( ! is_float( $value ) ) { |
|
979 | - $data[ $key ] = $default_values[ $key ]; |
|
978 | + if ( ! is_float($value)) { |
|
979 | + $data[$key] = $default_values[$key]; |
|
980 | 980 | } else { |
981 | - $data[ $key ] = $value; |
|
981 | + $data[$key] = $value; |
|
982 | 982 | } |
983 | 983 | break; |
984 | 984 | |
985 | 985 | default: |
986 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
986 | + $data[$key] = sanitize_text_field($data[$key]); |
|
987 | 987 | break; |
988 | 988 | |
989 | 989 | } |
@@ -1003,33 +1003,33 @@ discard block |
||
1003 | 1003 | * |
1004 | 1004 | * @return bool If the email was added successfully |
1005 | 1005 | */ |
1006 | - public function add_email( $email = '', $primary = false ) { |
|
1007 | - if ( ! is_email( $email ) ) { |
|
1006 | + public function add_email($email = '', $primary = false) { |
|
1007 | + if ( ! is_email($email)) { |
|
1008 | 1008 | return false; |
1009 | 1009 | } |
1010 | - $existing = new Give_Customer( $email ); |
|
1010 | + $existing = new Give_Customer($email); |
|
1011 | 1011 | |
1012 | - if ( $existing->id > 0 ) { |
|
1012 | + if ($existing->id > 0) { |
|
1013 | 1013 | // Email address already belongs to another customer |
1014 | 1014 | return false; |
1015 | 1015 | } |
1016 | 1016 | |
1017 | - if ( email_exists( $email ) ) { |
|
1018 | - $user = get_user_by( 'email', $email ); |
|
1019 | - if ( $user->ID != $this->user_id ) { |
|
1017 | + if (email_exists($email)) { |
|
1018 | + $user = get_user_by('email', $email); |
|
1019 | + if ($user->ID != $this->user_id) { |
|
1020 | 1020 | return false; |
1021 | 1021 | } |
1022 | 1022 | } |
1023 | 1023 | |
1024 | - do_action( 'give_donor_pre_add_email', $email, $this->id, $this ); |
|
1024 | + do_action('give_donor_pre_add_email', $email, $this->id, $this); |
|
1025 | 1025 | |
1026 | 1026 | // Add is used to ensure duplicate emails are not added |
1027 | - $ret = (bool) $this->add_meta( 'additional_email', $email ); |
|
1027 | + $ret = (bool) $this->add_meta('additional_email', $email); |
|
1028 | 1028 | |
1029 | - do_action( 'give_donor_post_add_email', $email, $this->id, $this ); |
|
1029 | + do_action('give_donor_post_add_email', $email, $this->id, $this); |
|
1030 | 1030 | |
1031 | - if ( $ret && true === $primary ) { |
|
1032 | - $this->set_primary_email( $email ); |
|
1031 | + if ($ret && true === $primary) { |
|
1032 | + $this->set_primary_email($email); |
|
1033 | 1033 | } |
1034 | 1034 | |
1035 | 1035 | return $ret; |
@@ -1045,16 +1045,16 @@ discard block |
||
1045 | 1045 | * |
1046 | 1046 | * @return bool If the email was removed successfully |
1047 | 1047 | */ |
1048 | - public function remove_email( $email = '' ) { |
|
1049 | - if ( ! is_email( $email ) ) { |
|
1048 | + public function remove_email($email = '') { |
|
1049 | + if ( ! is_email($email)) { |
|
1050 | 1050 | return false; |
1051 | 1051 | } |
1052 | 1052 | |
1053 | - do_action( 'give_donor_pre_remove_email', $email, $this->id, $this ); |
|
1053 | + do_action('give_donor_pre_remove_email', $email, $this->id, $this); |
|
1054 | 1054 | |
1055 | - $ret = (bool) $this->delete_meta( 'additional_email', $email ); |
|
1055 | + $ret = (bool) $this->delete_meta('additional_email', $email); |
|
1056 | 1056 | |
1057 | - do_action( 'give_donor_post_remove_email', $email, $this->id, $this ); |
|
1057 | + do_action('give_donor_post_remove_email', $email, $this->id, $this); |
|
1058 | 1058 | |
1059 | 1059 | return $ret; |
1060 | 1060 | } |
@@ -1071,16 +1071,16 @@ discard block |
||
1071 | 1071 | * |
1072 | 1072 | * @return bool If the email was set as primary successfully |
1073 | 1073 | */ |
1074 | - public function set_primary_email( $new_primary_email = '' ) { |
|
1075 | - if ( ! is_email( $new_primary_email ) ) { |
|
1074 | + public function set_primary_email($new_primary_email = '') { |
|
1075 | + if ( ! is_email($new_primary_email)) { |
|
1076 | 1076 | return false; |
1077 | 1077 | } |
1078 | 1078 | |
1079 | - do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this ); |
|
1079 | + do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this); |
|
1080 | 1080 | |
1081 | - $existing = new Give_Customer( $new_primary_email ); |
|
1081 | + $existing = new Give_Customer($new_primary_email); |
|
1082 | 1082 | |
1083 | - if ( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) { |
|
1083 | + if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) { |
|
1084 | 1084 | // This email belongs to another customer |
1085 | 1085 | return false; |
1086 | 1086 | } |
@@ -1088,21 +1088,21 @@ discard block |
||
1088 | 1088 | $old_email = $this->email; |
1089 | 1089 | |
1090 | 1090 | // Update customer record with new email |
1091 | - $update = $this->update( array( 'email' => $new_primary_email ) ); |
|
1091 | + $update = $this->update(array('email' => $new_primary_email)); |
|
1092 | 1092 | |
1093 | 1093 | // Remove new primary from list of additional emails |
1094 | - $remove = $this->remove_email( $new_primary_email ); |
|
1094 | + $remove = $this->remove_email($new_primary_email); |
|
1095 | 1095 | |
1096 | 1096 | // Add old email to additional emails list |
1097 | - $add = $this->add_email( $old_email ); |
|
1097 | + $add = $this->add_email($old_email); |
|
1098 | 1098 | |
1099 | 1099 | $ret = $update && $remove && $add; |
1100 | 1100 | |
1101 | - if ( $ret ) { |
|
1101 | + if ($ret) { |
|
1102 | 1102 | $this->email = $new_primary_email; |
1103 | 1103 | } |
1104 | 1104 | |
1105 | - do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this ); |
|
1105 | + do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this); |
|
1106 | 1106 | |
1107 | 1107 | return $ret; |
1108 | 1108 | } |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | * @access public |
488 | 488 | * @since 1.7 |
489 | 489 | * |
490 | - * @return bool|void |
|
490 | + * @return false|null |
|
491 | 491 | */ |
492 | 492 | public function weekly_license_check() { |
493 | 493 | |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | * @access public |
541 | 541 | * @since 1.7 |
542 | 542 | * |
543 | - * @return bool|void |
|
543 | + * @return false|null |
|
544 | 544 | */ |
545 | 545 | public function weekly_subscription_check() { |
546 | 546 | |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | * @access private |
622 | 622 | * @since 1.7 |
623 | 623 | * |
624 | - * @return bool|void |
|
624 | + * @return false|null |
|
625 | 625 | */ |
626 | 626 | private function __single_subscription_check() { |
627 | 627 | // Do not fire if license key is not set. |
@@ -833,7 +833,7 @@ discard block |
||
833 | 833 | * @access private |
834 | 834 | * @since 1.7 |
835 | 835 | * |
836 | - * @return void|bool |
|
836 | + * @return false|null |
|
837 | 837 | */ |
838 | 838 | private function __remove_license_key_from_subscriptions() { |
839 | 839 | $subscriptions = get_option( 'give_subscriptions', array() ); |
@@ -932,7 +932,7 @@ discard block |
||
932 | 932 | * @param $plugin_data |
933 | 933 | * @param $status |
934 | 934 | * |
935 | - * @return bool |
|
935 | + * @return false|null |
|
936 | 936 | */ |
937 | 937 | public function plugin_page_notices( $plugin_file, $plugin_data, $status ) { |
938 | 938 | // Bailout. |
@@ -954,7 +954,7 @@ discard block |
||
954 | 954 | * |
955 | 955 | * @since 1.8.7 |
956 | 956 | * @access public |
957 | - * @return array |
|
957 | + * @return string |
|
958 | 958 | */ |
959 | 959 | public function license_state_message() { |
960 | 960 | $message_data = array(); |
@@ -10,11 +10,11 @@ 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 | |
17 | -if ( ! class_exists( 'Give_License' ) ) : |
|
17 | +if ( ! class_exists('Give_License')) : |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Give_License Class |
@@ -142,20 +142,20 @@ discard block |
||
142 | 142 | * @param string $_checkout_url |
143 | 143 | * @param string $_account_url |
144 | 144 | */ |
145 | - public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null ) { |
|
145 | + public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null) { |
|
146 | 146 | |
147 | 147 | $give_options = give_get_settings(); |
148 | 148 | |
149 | 149 | $this->file = $_file; |
150 | 150 | $this->item_name = $_item_name; |
151 | - $this->item_shortname = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) ); |
|
151 | + $this->item_shortname = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name))); |
|
152 | 152 | $this->version = $_version; |
153 | - $this->license = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : ''; |
|
154 | - $this->license_data = get_option( $this->item_shortname . '_license_active' ); |
|
153 | + $this->license = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : ''; |
|
154 | + $this->license_data = get_option($this->item_shortname.'_license_active'); |
|
155 | 155 | $this->author = $_author; |
156 | - $this->api_url = is_null( $_api_url ) ? $this->api_url : $_api_url; |
|
157 | - $this->checkout_url = is_null( $_checkout_url ) ? $this->checkout_url : $_checkout_url; |
|
158 | - $this->account_url = is_null( $_account_url ) ? $this->account_url : $_account_url; |
|
156 | + $this->api_url = is_null($_api_url) ? $this->api_url : $_api_url; |
|
157 | + $this->checkout_url = is_null($_checkout_url) ? $this->checkout_url : $_checkout_url; |
|
158 | + $this->account_url = is_null($_account_url) ? $this->account_url : $_account_url; |
|
159 | 159 | $this->auto_updater_obj = null; |
160 | 160 | |
161 | 161 | // Setup hooks |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | */ |
177 | 177 | private function includes() { |
178 | 178 | |
179 | - if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
179 | + if ( ! class_exists('EDD_SL_Plugin_Updater')) { |
|
180 | 180 | require_once 'admin/EDD_SL_Plugin_Updater.php'; |
181 | 181 | } |
182 | 182 | } |
@@ -194,30 +194,30 @@ discard block |
||
194 | 194 | private function hooks() { |
195 | 195 | |
196 | 196 | // Register settings |
197 | - add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 ); |
|
197 | + add_filter('give_settings_licenses', array($this, 'settings'), 1); |
|
198 | 198 | |
199 | 199 | // Activate license key on settings save |
200 | - add_action( 'admin_init', array( $this, 'activate_license' ) ); |
|
200 | + add_action('admin_init', array($this, 'activate_license')); |
|
201 | 201 | |
202 | 202 | // Deactivate license key |
203 | - add_action( 'admin_init', array( $this, 'deactivate_license' ) ); |
|
203 | + add_action('admin_init', array($this, 'deactivate_license')); |
|
204 | 204 | |
205 | 205 | // Updater |
206 | - add_action( 'admin_init', array( $this, 'auto_updater' ), 0 ); |
|
207 | - add_action( 'admin_notices', array( $this, 'notices' ) ); |
|
206 | + add_action('admin_init', array($this, 'auto_updater'), 0); |
|
207 | + add_action('admin_notices', array($this, 'notices')); |
|
208 | 208 | |
209 | 209 | // Check license weekly. |
210 | - add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_license_check' ) ); |
|
211 | - add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_license_check' ) ); |
|
210 | + add_action('give_weekly_scheduled_events', array($this, 'weekly_license_check')); |
|
211 | + add_action('give_validate_license_when_site_migrated', array($this, 'weekly_license_check')); |
|
212 | 212 | |
213 | 213 | // Check subscription weekly. |
214 | - add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_subscription_check' ) ); |
|
215 | - add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_subscription_check' ) ); |
|
214 | + add_action('give_weekly_scheduled_events', array($this, 'weekly_subscription_check')); |
|
215 | + add_action('give_validate_license_when_site_migrated', array($this, 'weekly_subscription_check')); |
|
216 | 216 | |
217 | 217 | // Show addon notice on plugin page. |
218 | - $plugin_name = explode( 'plugins/', $this->file ); |
|
219 | - $plugin_name = end( $plugin_name ); |
|
220 | - add_action( "after_plugin_row_{$plugin_name}", array( $this, 'plugin_page_notices' ), 10, 3 ); |
|
218 | + $plugin_name = explode('plugins/', $this->file); |
|
219 | + $plugin_name = end($plugin_name); |
|
220 | + add_action("after_plugin_row_{$plugin_name}", array($this, 'plugin_page_notices'), 10, 3); |
|
221 | 221 | |
222 | 222 | } |
223 | 223 | |
@@ -257,16 +257,16 @@ discard block |
||
257 | 257 | * |
258 | 258 | * @return array License settings. |
259 | 259 | */ |
260 | - public function settings( $settings ) { |
|
260 | + public function settings($settings) { |
|
261 | 261 | |
262 | 262 | $give_license_settings = array( |
263 | 263 | array( |
264 | 264 | 'name' => $this->item_name, |
265 | - 'id' => $this->item_shortname . '_license_key', |
|
265 | + 'id' => $this->item_shortname.'_license_key', |
|
266 | 266 | 'desc' => '', |
267 | 267 | 'type' => 'license_key', |
268 | 268 | 'options' => array( |
269 | - 'license' => get_option( $this->item_shortname . '_license_active' ), |
|
269 | + 'license' => get_option($this->item_shortname.'_license_active'), |
|
270 | 270 | 'shortname' => $this->item_shortname, |
271 | 271 | 'item_name' => $this->item_name, |
272 | 272 | 'api_url' => $this->api_url, |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | ), |
278 | 278 | ); |
279 | 279 | |
280 | - return array_merge( $settings, $give_license_settings ); |
|
280 | + return array_merge($settings, $give_license_settings); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | /** |
@@ -292,18 +292,18 @@ discard block |
||
292 | 292 | * |
293 | 293 | * @return array License settings content. |
294 | 294 | */ |
295 | - public function license_settings_content( $settings ) { |
|
295 | + public function license_settings_content($settings) { |
|
296 | 296 | |
297 | 297 | $give_license_settings = array( |
298 | 298 | array( |
299 | - 'name' => __( 'Add-on Licenses', 'give' ), |
|
299 | + 'name' => __('Add-on Licenses', 'give'), |
|
300 | 300 | 'desc' => '<hr>', |
301 | 301 | 'type' => 'give_title', |
302 | 302 | 'id' => 'give_title', |
303 | 303 | ), |
304 | 304 | ); |
305 | 305 | |
306 | - return array_merge( $settings, $give_license_settings ); |
|
306 | + return array_merge($settings, $give_license_settings); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -318,52 +318,52 @@ discard block |
||
318 | 318 | */ |
319 | 319 | public function activate_license() { |
320 | 320 | // Bailout: Check if license key set of not. |
321 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
321 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
322 | 322 | return; |
323 | 323 | } |
324 | 324 | |
325 | 325 | // Security check. |
326 | - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { |
|
327 | - wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
326 | + if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) { |
|
327 | + wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | // Check if user have correct permissions. |
331 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
331 | + if ( ! current_user_can('manage_give_settings')) { |
|
332 | 332 | return; |
333 | 333 | } |
334 | 334 | |
335 | 335 | // Allow third party addon developers to handle license activation. |
336 | - if ( $this->__is_third_party_addon() ) { |
|
337 | - do_action( 'give_activate_license', $this ); |
|
336 | + if ($this->__is_third_party_addon()) { |
|
337 | + do_action('give_activate_license', $this); |
|
338 | 338 | |
339 | 339 | return; |
340 | 340 | } |
341 | 341 | |
342 | 342 | // Delete previous license setting if a empty license key submitted. |
343 | - if ( empty( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
344 | - delete_option( $this->item_shortname . '_license_active' ); |
|
343 | + if (empty($_POST[$this->item_shortname.'_license_key'])) { |
|
344 | + delete_option($this->item_shortname.'_license_active'); |
|
345 | 345 | |
346 | 346 | return; |
347 | 347 | } |
348 | 348 | |
349 | 349 | // Do not simultaneously activate add-ons if the user want to deactivate a specific add-on. |
350 | - foreach ( $_POST as $key => $value ) { |
|
351 | - if ( false !== strpos( $key, 'license_key_deactivate' ) ) { |
|
350 | + foreach ($_POST as $key => $value) { |
|
351 | + if (false !== strpos($key, 'license_key_deactivate')) { |
|
352 | 352 | // Don't activate a key when deactivating a different key |
353 | 353 | return; |
354 | 354 | } |
355 | 355 | } |
356 | 356 | |
357 | 357 | // Check if plugin previously installed. |
358 | - if ( $this->is_valid_license() ) { |
|
358 | + if ($this->is_valid_license()) { |
|
359 | 359 | return; |
360 | 360 | } |
361 | 361 | |
362 | 362 | // Get license key. |
363 | - $license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] ); |
|
363 | + $license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']); |
|
364 | 364 | |
365 | 365 | // Bailout. |
366 | - if ( empty( $license ) ) { |
|
366 | + if (empty($license)) { |
|
367 | 367 | return; |
368 | 368 | } |
369 | 369 | |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | $api_params = array( |
375 | 375 | 'edd_action' => 'activate_license', // never change from "edd_" to "give_"! |
376 | 376 | 'license' => $license, |
377 | - 'item_name' => urlencode( $this->item_name ), |
|
377 | + 'item_name' => urlencode($this->item_name), |
|
378 | 378 | 'url' => home_url(), |
379 | 379 | ); |
380 | 380 | |
@@ -389,19 +389,19 @@ discard block |
||
389 | 389 | ); |
390 | 390 | |
391 | 391 | // Make sure there are no errors |
392 | - if ( is_wp_error( $response ) ) { |
|
392 | + if (is_wp_error($response)) { |
|
393 | 393 | return; |
394 | 394 | } |
395 | 395 | |
396 | 396 | // Tell WordPress to look for updates |
397 | - set_site_transient( 'update_plugins', null ); |
|
397 | + set_site_transient('update_plugins', null); |
|
398 | 398 | |
399 | 399 | // Decode license data |
400 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
401 | - update_option( $this->item_shortname . '_license_active', $license_data ); |
|
400 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
401 | + update_option($this->item_shortname.'_license_active', $license_data); |
|
402 | 402 | |
403 | 403 | // Add license key. |
404 | - give_update_option( "{$this->item_shortname}_license_key", $license ); |
|
404 | + give_update_option("{$this->item_shortname}_license_key", $license); |
|
405 | 405 | |
406 | 406 | // Check subscription for license key and store this to db (if any). |
407 | 407 | $this->__single_subscription_check(); |
@@ -419,33 +419,33 @@ discard block |
||
419 | 419 | */ |
420 | 420 | public function deactivate_license() { |
421 | 421 | |
422 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
422 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
423 | 423 | return; |
424 | 424 | } |
425 | 425 | |
426 | - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { |
|
427 | - wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
426 | + if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) { |
|
427 | + wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
428 | 428 | } |
429 | 429 | |
430 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
430 | + if ( ! current_user_can('manage_give_settings')) { |
|
431 | 431 | return; |
432 | 432 | } |
433 | 433 | |
434 | 434 | // Allow third party add-on developers to handle license deactivation. |
435 | - if ( $this->__is_third_party_addon() ) { |
|
436 | - do_action( 'give_deactivate_license', $this ); |
|
435 | + if ($this->__is_third_party_addon()) { |
|
436 | + do_action('give_deactivate_license', $this); |
|
437 | 437 | |
438 | 438 | return; |
439 | 439 | } |
440 | 440 | |
441 | 441 | // Run on deactivate button press |
442 | - if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) { |
|
442 | + if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) { |
|
443 | 443 | |
444 | 444 | // Data to send to the API |
445 | 445 | $api_params = array( |
446 | 446 | 'edd_action' => 'deactivate_license', // never change from "edd_" to "give_"! |
447 | 447 | 'license' => $this->license, |
448 | - 'item_name' => urlencode( $this->item_name ), |
|
448 | + 'item_name' => urlencode($this->item_name), |
|
449 | 449 | 'url' => home_url(), |
450 | 450 | ); |
451 | 451 | |
@@ -460,20 +460,20 @@ discard block |
||
460 | 460 | ); |
461 | 461 | |
462 | 462 | // Make sure there are no errors |
463 | - if ( is_wp_error( $response ) ) { |
|
463 | + if (is_wp_error($response)) { |
|
464 | 464 | return; |
465 | 465 | } |
466 | 466 | |
467 | 467 | // Decode the license data |
468 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
468 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
469 | 469 | |
470 | 470 | // Ensure deactivated successfully. |
471 | - if ( isset( $license_data->success ) ) { |
|
471 | + if (isset($license_data->success)) { |
|
472 | 472 | |
473 | 473 | // Remove license data. |
474 | - delete_option( $this->item_shortname . '_license_active' ); |
|
474 | + delete_option($this->item_shortname.'_license_active'); |
|
475 | 475 | |
476 | - give_delete_option( $this->item_shortname . '_license_key' ); |
|
476 | + give_delete_option($this->item_shortname.'_license_key'); |
|
477 | 477 | |
478 | 478 | // Remove license key from subscriptions if exist. |
479 | 479 | $this->__remove_license_key_from_subscriptions(); |
@@ -492,18 +492,18 @@ discard block |
||
492 | 492 | */ |
493 | 493 | public function weekly_license_check() { |
494 | 494 | |
495 | - if ( ! empty( $_POST['give_settings'] ) ) { |
|
495 | + if ( ! empty($_POST['give_settings'])) { |
|
496 | 496 | // Don't fire when saving settings |
497 | 497 | return false; |
498 | 498 | } |
499 | 499 | |
500 | - if ( empty( $this->license ) ) { |
|
500 | + if (empty($this->license)) { |
|
501 | 501 | return false; |
502 | 502 | } |
503 | 503 | |
504 | 504 | // Allow third party add-on developers to handle their license check. |
505 | - if ( $this->__is_third_party_addon() ) { |
|
506 | - do_action( 'give_weekly_license_check', $this ); |
|
505 | + if ($this->__is_third_party_addon()) { |
|
506 | + do_action('give_weekly_license_check', $this); |
|
507 | 507 | |
508 | 508 | return false; |
509 | 509 | } |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | $api_params = array( |
513 | 513 | 'edd_action' => 'check_license', |
514 | 514 | 'license' => $this->license, |
515 | - 'item_name' => urlencode( $this->item_name ), |
|
515 | + 'item_name' => urlencode($this->item_name), |
|
516 | 516 | 'url' => home_url(), |
517 | 517 | ); |
518 | 518 | |
@@ -527,12 +527,12 @@ discard block |
||
527 | 527 | ); |
528 | 528 | |
529 | 529 | // Make sure the response came back okay. |
530 | - if ( is_wp_error( $response ) ) { |
|
530 | + if (is_wp_error($response)) { |
|
531 | 531 | return false; |
532 | 532 | } |
533 | 533 | |
534 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
535 | - update_option( $this->item_shortname . '_license_active', $license_data ); |
|
534 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
535 | + update_option($this->item_shortname.'_license_active', $license_data); |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | /** |
@@ -545,24 +545,24 @@ discard block |
||
545 | 545 | */ |
546 | 546 | public function weekly_subscription_check() { |
547 | 547 | |
548 | - if ( ! empty( $_POST['give_settings'] ) ) { |
|
548 | + if ( ! empty($_POST['give_settings'])) { |
|
549 | 549 | // Don't fire when saving settings |
550 | 550 | return false; |
551 | 551 | } |
552 | 552 | |
553 | 553 | // Remove old subscription data. |
554 | - if ( absint( get_option( '_give_subscriptions_edit_last', true ) ) < current_time( 'timestamp', 1 ) ) { |
|
555 | - delete_option( 'give_subscriptions' ); |
|
556 | - update_option( '_give_subscriptions_edit_last', strtotime( '+ 1 day', current_time( 'timestamp', 1 ) ) ); |
|
554 | + if (absint(get_option('_give_subscriptions_edit_last', true)) < current_time('timestamp', 1)) { |
|
555 | + delete_option('give_subscriptions'); |
|
556 | + update_option('_give_subscriptions_edit_last', strtotime('+ 1 day', current_time('timestamp', 1))); |
|
557 | 557 | } |
558 | 558 | |
559 | - if ( empty( $this->license ) ) { |
|
559 | + if (empty($this->license)) { |
|
560 | 560 | return false; |
561 | 561 | } |
562 | 562 | |
563 | 563 | // Allow third party add-on developers to handle their subscription check. |
564 | - if ( $this->__is_third_party_addon() ) { |
|
565 | - do_action( 'give_weekly_subscription_check', $this ); |
|
564 | + if ($this->__is_third_party_addon()) { |
|
565 | + do_action('give_weekly_subscription_check', $this); |
|
566 | 566 | |
567 | 567 | return false; |
568 | 568 | } |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | // This is a custom feature to check subscriptions. |
578 | 578 | 'edd_action' => 'check_subscription', |
579 | 579 | 'license' => $this->license, |
580 | - 'item_name' => urlencode( $this->item_name ), |
|
580 | + 'item_name' => urlencode($this->item_name), |
|
581 | 581 | 'url' => home_url(), |
582 | 582 | ); |
583 | 583 | |
@@ -592,27 +592,27 @@ discard block |
||
592 | 592 | ); |
593 | 593 | |
594 | 594 | // Make sure the response came back okay. |
595 | - if ( is_wp_error( $response ) ) { |
|
595 | + if (is_wp_error($response)) { |
|
596 | 596 | return false; |
597 | 597 | } |
598 | 598 | |
599 | - $subscription_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
599 | + $subscription_data = json_decode(wp_remote_retrieve_body($response), true); |
|
600 | 600 | |
601 | - if ( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) { |
|
602 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
601 | + if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) { |
|
602 | + $subscriptions = get_option('give_subscriptions', array()); |
|
603 | 603 | |
604 | 604 | // Update subscription data only if subscription does not exist already. |
605 | - if ( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) { |
|
606 | - $subscriptions[ $subscription_data['id'] ] = $subscription_data; |
|
607 | - $subscriptions[ $subscription_data['id'] ]['licenses'] = array(); |
|
605 | + if ( ! array_key_exists($subscription_data['id'], $subscriptions)) { |
|
606 | + $subscriptions[$subscription_data['id']] = $subscription_data; |
|
607 | + $subscriptions[$subscription_data['id']]['licenses'] = array(); |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | // Store licenses for subscription. |
611 | - if ( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) { |
|
612 | - $subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license; |
|
611 | + if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) { |
|
612 | + $subscriptions[$subscription_data['id']]['licenses'][] = $this->license; |
|
613 | 613 | } |
614 | 614 | |
615 | - update_option( 'give_subscriptions', $subscriptions ); |
|
615 | + update_option('give_subscriptions', $subscriptions); |
|
616 | 616 | } |
617 | 617 | } |
618 | 618 | |
@@ -626,11 +626,11 @@ discard block |
||
626 | 626 | */ |
627 | 627 | private function __single_subscription_check() { |
628 | 628 | // Do not fire if license key is not set. |
629 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
629 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
630 | 630 | return false; |
631 | 631 | } |
632 | 632 | |
633 | - if ( empty( $this->license ) ) { |
|
633 | + if (empty($this->license)) { |
|
634 | 634 | return false; |
635 | 635 | } |
636 | 636 | |
@@ -641,7 +641,7 @@ discard block |
||
641 | 641 | // This is a custom feature to check subscriptions. |
642 | 642 | 'edd_action' => 'check_subscription', |
643 | 643 | 'license' => $this->license, |
644 | - 'item_name' => urlencode( $this->item_name ), |
|
644 | + 'item_name' => urlencode($this->item_name), |
|
645 | 645 | 'url' => home_url(), |
646 | 646 | ); |
647 | 647 | |
@@ -656,27 +656,27 @@ discard block |
||
656 | 656 | ); |
657 | 657 | |
658 | 658 | // Make sure the response came back okay. |
659 | - if ( is_wp_error( $response ) ) { |
|
659 | + if (is_wp_error($response)) { |
|
660 | 660 | return false; |
661 | 661 | } |
662 | 662 | |
663 | - $subscription_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
663 | + $subscription_data = json_decode(wp_remote_retrieve_body($response), true); |
|
664 | 664 | |
665 | - if ( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) { |
|
666 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
665 | + if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) { |
|
666 | + $subscriptions = get_option('give_subscriptions', array()); |
|
667 | 667 | |
668 | 668 | // Update subscription data only if subscription does not exist already. |
669 | - if ( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) { |
|
670 | - $subscriptions[ $subscription_data['id'] ] = $subscription_data; |
|
671 | - $subscriptions[ $subscription_data['id'] ]['licenses'] = array(); |
|
669 | + if ( ! array_key_exists($subscription_data['id'], $subscriptions)) { |
|
670 | + $subscriptions[$subscription_data['id']] = $subscription_data; |
|
671 | + $subscriptions[$subscription_data['id']]['licenses'] = array(); |
|
672 | 672 | } |
673 | 673 | |
674 | 674 | // Store licenses for subscription. |
675 | - if ( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) { |
|
676 | - $subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license; |
|
675 | + if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) { |
|
676 | + $subscriptions[$subscription_data['id']]['licenses'][] = $this->license; |
|
677 | 677 | } |
678 | 678 | |
679 | - update_option( 'give_subscriptions', $subscriptions ); |
|
679 | + update_option('give_subscriptions', $subscriptions); |
|
680 | 680 | } |
681 | 681 | } |
682 | 682 | |
@@ -690,12 +690,12 @@ discard block |
||
690 | 690 | */ |
691 | 691 | public function notices() { |
692 | 692 | |
693 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
693 | + if ( ! current_user_can('manage_give_settings')) { |
|
694 | 694 | return; |
695 | 695 | } |
696 | 696 | |
697 | 697 | // Do not show licenses notices on license tab. |
698 | - if ( 'licenses' === give_get_current_setting_tab() ) { |
|
698 | + if ('licenses' === give_get_current_setting_tab()) { |
|
699 | 699 | return; |
700 | 700 | } |
701 | 701 | |
@@ -704,93 +704,93 @@ discard block |
||
704 | 704 | static $addon_license_key_in_subscriptions; |
705 | 705 | |
706 | 706 | // Set default value. |
707 | - $addon_license_key_in_subscriptions = ! empty( $addon_license_key_in_subscriptions ) ? $addon_license_key_in_subscriptions : array(); |
|
707 | + $addon_license_key_in_subscriptions = ! empty($addon_license_key_in_subscriptions) ? $addon_license_key_in_subscriptions : array(); |
|
708 | 708 | $messages = array(); |
709 | 709 | |
710 | 710 | if ( |
711 | - empty( $this->license ) |
|
712 | - && ! $this->__is_notice_dismissed( 'general' ) |
|
713 | - && empty( $showed_invalid_message ) |
|
711 | + empty($this->license) |
|
712 | + && ! $this->__is_notice_dismissed('general') |
|
713 | + && empty($showed_invalid_message) |
|
714 | 714 | ) { |
715 | - $messages['general'] = sprintf( |
|
716 | - __( 'You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ), |
|
717 | - admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) |
|
715 | + $messages['general'] = sprintf( |
|
716 | + __('You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'), |
|
717 | + admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses') |
|
718 | 718 | ); |
719 | 719 | $showed_invalid_message = true; |
720 | 720 | |
721 | 721 | } |
722 | 722 | |
723 | 723 | // Get subscriptions. |
724 | - $subscriptions = get_option( 'give_subscriptions' ); |
|
724 | + $subscriptions = get_option('give_subscriptions'); |
|
725 | 725 | |
726 | 726 | // Show subscription messages. |
727 | - if ( ! empty( $subscriptions ) && ! $showed_subscriptions_message ) { |
|
727 | + if ( ! empty($subscriptions) && ! $showed_subscriptions_message) { |
|
728 | 728 | |
729 | - foreach ( $subscriptions as $subscription ) { |
|
729 | + foreach ($subscriptions as $subscription) { |
|
730 | 730 | // Subscription expires timestamp. |
731 | - $subscription_expires = strtotime( $subscription['expires'] ); |
|
731 | + $subscription_expires = strtotime($subscription['expires']); |
|
732 | 732 | |
733 | 733 | // Start showing subscriptions message before one week of renewal date. |
734 | - if ( strtotime( '- 7 days', $subscription_expires ) > current_time( 'timestamp', 1 ) ) { |
|
734 | + if (strtotime('- 7 days', $subscription_expires) > current_time('timestamp', 1)) { |
|
735 | 735 | continue; |
736 | 736 | } |
737 | 737 | |
738 | 738 | // Check if subscription message already exist in messages. |
739 | - if ( array_key_exists( $subscription['id'], $messages ) ) { |
|
739 | + if (array_key_exists($subscription['id'], $messages)) { |
|
740 | 740 | continue; |
741 | 741 | } |
742 | 742 | |
743 | - if ( ( ! $this->__is_notice_dismissed( $subscription['id'] ) && 'active' !== $subscription['status'] ) ) { |
|
743 | + if (( ! $this->__is_notice_dismissed($subscription['id']) && 'active' !== $subscription['status'])) { |
|
744 | 744 | |
745 | - if ( strtotime( $subscription['expires'] ) < current_time( 'timestamp', 1 ) ) {// Check if license already expired. |
|
746 | - $messages[ $subscription['id'] ] = sprintf( |
|
747 | - __( 'Your Give add-on license expired for payment <a href="%1$s" target="_blank">#%2$d</a>. <a href="%3$s" target="_blank">Click to renew an existing license</a> or <a href="%4$s">Click here if already renewed</a>.', 'give' ), |
|
748 | - urldecode( $subscription['invoice_url'] ), |
|
745 | + if (strtotime($subscription['expires']) < current_time('timestamp', 1)) {// Check if license already expired. |
|
746 | + $messages[$subscription['id']] = sprintf( |
|
747 | + __('Your Give add-on license expired for payment <a href="%1$s" target="_blank">#%2$d</a>. <a href="%3$s" target="_blank">Click to renew an existing license</a> or <a href="%4$s">Click here if already renewed</a>.', 'give'), |
|
748 | + urldecode($subscription['invoice_url']), |
|
749 | 749 | $subscription['payment_id'], |
750 | 750 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
751 | - esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) ) |
|
751 | + esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'])) |
|
752 | 752 | ); |
753 | 753 | } else { |
754 | - $messages[ $subscription['id'] ] = sprintf( |
|
755 | - __( 'Your Give add-on license will expire in %1$s for payment <a href="%2$s" target="_blank">#%3$d</a>. <a href="%4$s" target="_blank">Click to renew an existing license</a> or <a href="%5$s">Click here if already renewed</a>.', 'give' ), |
|
756 | - human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ), |
|
757 | - urldecode( $subscription['invoice_url'] ), |
|
754 | + $messages[$subscription['id']] = sprintf( |
|
755 | + __('Your Give add-on license will expire in %1$s for payment <a href="%2$s" target="_blank">#%3$d</a>. <a href="%4$s" target="_blank">Click to renew an existing license</a> or <a href="%5$s">Click here if already renewed</a>.', 'give'), |
|
756 | + human_time_diff(current_time('timestamp', 1), strtotime($subscription['expires'])), |
|
757 | + urldecode($subscription['invoice_url']), |
|
758 | 758 | $subscription['payment_id'], |
759 | 759 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
760 | - esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) ) |
|
760 | + esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'])) |
|
761 | 761 | ); |
762 | 762 | } |
763 | 763 | } |
764 | 764 | |
765 | 765 | // Stop validation for these license keys. |
766 | - $addon_license_key_in_subscriptions = array_merge( $addon_license_key_in_subscriptions, $subscription['licenses'] ); |
|
766 | + $addon_license_key_in_subscriptions = array_merge($addon_license_key_in_subscriptions, $subscription['licenses']); |
|
767 | 767 | }// End foreach(). |
768 | 768 | $showed_subscriptions_message = true; |
769 | 769 | }// End if(). |
770 | 770 | |
771 | 771 | // Show non subscription addon messages. |
772 | 772 | if ( |
773 | - ! in_array( $this->license, $addon_license_key_in_subscriptions ) |
|
774 | - && ! $this->__is_notice_dismissed( 'general' ) |
|
773 | + ! in_array($this->license, $addon_license_key_in_subscriptions) |
|
774 | + && ! $this->__is_notice_dismissed('general') |
|
775 | 775 | && ! $this->is_valid_license() |
776 | - && empty( $showed_invalid_message ) |
|
776 | + && empty($showed_invalid_message) |
|
777 | 777 | ) { |
778 | 778 | |
779 | - $messages['general'] = sprintf( |
|
780 | - __( 'You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ), |
|
781 | - admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) |
|
779 | + $messages['general'] = sprintf( |
|
780 | + __('You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'), |
|
781 | + admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses') |
|
782 | 782 | ); |
783 | 783 | $showed_invalid_message = true; |
784 | 784 | |
785 | 785 | } |
786 | 786 | |
787 | 787 | // Print messages. |
788 | - if ( ! empty( $messages ) ) { |
|
789 | - foreach ( $messages as $notice_id => $message ) { |
|
788 | + if ( ! empty($messages)) { |
|
789 | + foreach ($messages as $notice_id => $message) { |
|
790 | 790 | |
791 | 791 | echo sprintf( |
792 | 792 | '<div class="notice notice-error is-dismissible give-license-notice" data-dismiss-notice-shortly="%1$s"><p>%2$s</p></div>', |
793 | - esc_url( add_query_arg( '_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'] ) ), |
|
793 | + esc_url(add_query_arg('_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'])), |
|
794 | 794 | $message |
795 | 795 | ); |
796 | 796 | } |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | * @return bool |
807 | 807 | */ |
808 | 808 | public function is_valid_license() { |
809 | - if ( apply_filters( 'give_is_valid_license', ( is_object( $this->license_data ) && ! empty( $this->license_data ) && property_exists( $this->license_data, 'license' ) && 'valid' === $this->license_data->license ) ) ) { |
|
809 | + if (apply_filters('give_is_valid_license', (is_object($this->license_data) && ! empty($this->license_data) && property_exists($this->license_data, 'license') && 'valid' === $this->license_data->license))) { |
|
810 | 810 | return true; |
811 | 811 | } |
812 | 812 | |
@@ -822,7 +822,7 @@ discard block |
||
822 | 822 | * @return bool |
823 | 823 | */ |
824 | 824 | private function __is_third_party_addon() { |
825 | - return ( false === strpos( $this->api_url, 'givewp.com/' ) ); |
|
825 | + return (false === strpos($this->api_url, 'givewp.com/')); |
|
826 | 826 | } |
827 | 827 | |
828 | 828 | /** |
@@ -837,25 +837,25 @@ discard block |
||
837 | 837 | * @return void|bool |
838 | 838 | */ |
839 | 839 | private function __remove_license_key_from_subscriptions() { |
840 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
840 | + $subscriptions = get_option('give_subscriptions', array()); |
|
841 | 841 | |
842 | 842 | // Bailout. |
843 | - if ( empty( $this->license ) ) { |
|
843 | + if (empty($this->license)) { |
|
844 | 844 | return false; |
845 | 845 | } |
846 | 846 | |
847 | - if ( ! empty( $subscriptions ) ) { |
|
848 | - foreach ( $subscriptions as $subscription_id => $subscription ) { |
|
849 | - $license_index = array_search( $this->license, $subscription['licenses'] ); |
|
850 | - if ( false !== $license_index ) { |
|
847 | + if ( ! empty($subscriptions)) { |
|
848 | + foreach ($subscriptions as $subscription_id => $subscription) { |
|
849 | + $license_index = array_search($this->license, $subscription['licenses']); |
|
850 | + if (false !== $license_index) { |
|
851 | 851 | // Remove license key. |
852 | - unset( $subscriptions[ $subscription_id ]['licenses'][ $license_index ] ); |
|
852 | + unset($subscriptions[$subscription_id]['licenses'][$license_index]); |
|
853 | 853 | |
854 | 854 | // Rearrange license keys. |
855 | - $subscriptions[ $subscription_id ]['licenses'] = array_values( $subscriptions[ $subscription_id ]['licenses'] ); |
|
855 | + $subscriptions[$subscription_id]['licenses'] = array_values($subscriptions[$subscription_id]['licenses']); |
|
856 | 856 | |
857 | 857 | // Update subscription information. |
858 | - update_option( 'give_subscriptions', $subscriptions ); |
|
858 | + update_option('give_subscriptions', $subscriptions); |
|
859 | 859 | break; |
860 | 860 | } |
861 | 861 | } |
@@ -908,18 +908,18 @@ discard block |
||
908 | 908 | * |
909 | 909 | * @return bool |
910 | 910 | */ |
911 | - private function __is_notice_dismissed( $notice_id ) { |
|
911 | + private function __is_notice_dismissed($notice_id) { |
|
912 | 912 | $current_user = wp_get_current_user(); |
913 | 913 | $is_notice_dismissed = false; |
914 | 914 | |
915 | 915 | // Ge is notice dismissed permanently. |
916 | - $already_dismiss_notices = ( $already_dismiss_notices = get_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', true ) ) |
|
916 | + $already_dismiss_notices = ($already_dismiss_notices = get_user_meta($current_user->ID, '_give_hide_license_notices_permanently', true)) |
|
917 | 917 | ? $already_dismiss_notices |
918 | 918 | : array(); |
919 | 919 | |
920 | 920 | if ( |
921 | - in_array( $notice_id, $already_dismiss_notices ) |
|
922 | - || false !== Give_Cache::get( "_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}", true ) |
|
921 | + in_array($notice_id, $already_dismiss_notices) |
|
922 | + || false !== Give_Cache::get("_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}", true) |
|
923 | 923 | ) { |
924 | 924 | $is_notice_dismissed = true; |
925 | 925 | } |
@@ -935,17 +935,17 @@ discard block |
||
935 | 935 | * |
936 | 936 | * @return bool |
937 | 937 | */ |
938 | - public function plugin_page_notices( $plugin_file, $plugin_data, $status ) { |
|
938 | + public function plugin_page_notices($plugin_file, $plugin_data, $status) { |
|
939 | 939 | // Bailout. |
940 | - if ( $this->is_valid_license() ) { |
|
940 | + if ($this->is_valid_license()) { |
|
941 | 941 | return false; |
942 | 942 | } |
943 | 943 | |
944 | 944 | $update_notice_wrap = '<tr class="give-addon-notice-tr active"><td colspan="3" class="colspanchange"><div class="notice inline notice-warning notice-alt give-invalid-license"><p><span class="dashicons dashicons-info"></span> %s</p></div></td></tr>'; |
945 | 945 | $message = $this->license_state_message(); |
946 | 946 | |
947 | - if ( ! empty( $message['message'] ) ) { |
|
948 | - echo sprintf( $update_notice_wrap, $message['message'] ); |
|
947 | + if ( ! empty($message['message'])) { |
|
948 | + echo sprintf($update_notice_wrap, $message['message']); |
|
949 | 949 | } |
950 | 950 | } |
951 | 951 | |
@@ -960,11 +960,11 @@ discard block |
||
960 | 960 | public function license_state_message() { |
961 | 961 | $message_data = array(); |
962 | 962 | |
963 | - if ( ! $this->is_valid_license() ) { |
|
963 | + if ( ! $this->is_valid_license()) { |
|
964 | 964 | |
965 | 965 | $message_data['message'] = sprintf( |
966 | 966 | 'Please <a href="%1$s">activate your license</a> to receive updates and support for the %2$s add-on.', |
967 | - esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) ), |
|
967 | + esc_url(admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')), |
|
968 | 968 | $this->item_name |
969 | 969 | ); |
970 | 970 | } |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | * |
368 | 368 | * @since 1.0 |
369 | 369 | * |
370 | - * @param int|bool $form_id Form ID (default: false). |
|
370 | + * @param boolean $form_id Form ID (default: false). |
|
371 | 371 | * @param int $payment_id Payment ID. |
372 | 372 | * |
373 | 373 | * @return void |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | * @param int $year Year number. Default is null. |
692 | 692 | * @param int $hour Hour number. Default is null. |
693 | 693 | * |
694 | - * @return int $earnings Earnings |
|
694 | + * @return double $earnings Earnings |
|
695 | 695 | */ |
696 | 696 | function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
697 | 697 | |
@@ -997,7 +997,7 @@ discard block |
||
997 | 997 | * |
998 | 998 | * @param int $payment_id Payment ID. |
999 | 999 | * |
1000 | - * @return int $form_id Form ID. |
|
1000 | + * @return string $form_id Form ID. |
|
1001 | 1001 | */ |
1002 | 1002 | function give_get_payment_form_id( $payment_id ) { |
1003 | 1003 | $payment = new Give_Payment( $payment_id ); |
@@ -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 | * @return array $payments Payments retrieved from the database |
45 | 45 | */ |
46 | -function give_get_payments( $args = array() ) { |
|
46 | +function give_get_payments($args = array()) { |
|
47 | 47 | |
48 | 48 | // Fallback to post objects to ensure backwards compatibility. |
49 | - if ( ! isset( $args['output'] ) ) { |
|
49 | + if ( ! isset($args['output'])) { |
|
50 | 50 | $args['output'] = 'posts'; |
51 | 51 | } |
52 | 52 | |
53 | - $args = apply_filters( 'give_get_payments_args', $args ); |
|
54 | - $payments = new Give_Payments_Query( $args ); |
|
53 | + $args = apply_filters('give_get_payments_args', $args); |
|
54 | + $payments = new Give_Payments_Query($args); |
|
55 | 55 | |
56 | 56 | return $payments->get_payments(); |
57 | 57 | } |
@@ -66,48 +66,48 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return mixed |
68 | 68 | */ |
69 | -function give_get_payment_by( $field = '', $value = '' ) { |
|
69 | +function give_get_payment_by($field = '', $value = '') { |
|
70 | 70 | |
71 | - if ( empty( $field ) || empty( $value ) ) { |
|
71 | + if (empty($field) || empty($value)) { |
|
72 | 72 | return false; |
73 | 73 | } |
74 | 74 | |
75 | - switch ( strtolower( $field ) ) { |
|
75 | + switch (strtolower($field)) { |
|
76 | 76 | |
77 | 77 | case 'id': |
78 | - $payment = new Give_Payment( $value ); |
|
78 | + $payment = new Give_Payment($value); |
|
79 | 79 | $id = $payment->ID; |
80 | 80 | |
81 | - if ( empty( $id ) ) { |
|
81 | + if (empty($id)) { |
|
82 | 82 | return false; |
83 | 83 | } |
84 | 84 | |
85 | 85 | break; |
86 | 86 | |
87 | 87 | case 'key': |
88 | - $payment = give_get_payments( array( |
|
88 | + $payment = give_get_payments(array( |
|
89 | 89 | 'meta_key' => '_give_payment_purchase_key', |
90 | 90 | 'meta_value' => $value, |
91 | 91 | 'posts_per_page' => 1, |
92 | 92 | 'fields' => 'ids', |
93 | - ) ); |
|
93 | + )); |
|
94 | 94 | |
95 | - if ( $payment ) { |
|
96 | - $payment = new Give_Payment( $payment[0] ); |
|
95 | + if ($payment) { |
|
96 | + $payment = new Give_Payment($payment[0]); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | break; |
100 | 100 | |
101 | 101 | case 'payment_number': |
102 | - $payment = give_get_payments( array( |
|
102 | + $payment = give_get_payments(array( |
|
103 | 103 | 'meta_key' => '_give_payment_number', |
104 | 104 | 'meta_value' => $value, |
105 | 105 | 'posts_per_page' => 1, |
106 | 106 | 'fields' => 'ids', |
107 | - ) ); |
|
107 | + )); |
|
108 | 108 | |
109 | - if ( $payment ) { |
|
110 | - $payment = new Give_Payment( $payment[0] ); |
|
109 | + if ($payment) { |
|
110 | + $payment = new Give_Payment($payment[0]); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | break; |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | return false; |
117 | 117 | } |
118 | 118 | |
119 | - if ( $payment ) { |
|
119 | + if ($payment) { |
|
120 | 120 | return $payment; |
121 | 121 | } |
122 | 122 | |
@@ -132,23 +132,23 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @return int|bool Payment ID if payment is inserted, false otherwise. |
134 | 134 | */ |
135 | -function give_insert_payment( $payment_data = array() ) { |
|
135 | +function give_insert_payment($payment_data = array()) { |
|
136 | 136 | |
137 | - if ( empty( $payment_data ) ) { |
|
137 | + if (empty($payment_data)) { |
|
138 | 138 | return false; |
139 | 139 | } |
140 | 140 | |
141 | 141 | $payment = new Give_Payment(); |
142 | - $gateway = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : ''; |
|
143 | - $gateway = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway; |
|
144 | - $form_id = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0; |
|
145 | - $price_id = give_get_payment_meta_price_id( $payment_data ); |
|
146 | - $form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id ); |
|
142 | + $gateway = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : ''; |
|
143 | + $gateway = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway; |
|
144 | + $form_id = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0; |
|
145 | + $price_id = give_get_payment_meta_price_id($payment_data); |
|
146 | + $form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id); |
|
147 | 147 | |
148 | 148 | // Set properties. |
149 | 149 | $payment->total = $payment_data['price']; |
150 | - $payment->status = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending'; |
|
151 | - $payment->currency = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency(); |
|
150 | + $payment->status = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending'; |
|
151 | + $payment->currency = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency(); |
|
152 | 152 | $payment->user_info = $payment_data['user_info']; |
153 | 153 | $payment->gateway = $gateway; |
154 | 154 | $payment->form_title = $form_title; |
@@ -162,31 +162,31 @@ discard block |
||
162 | 162 | $payment->ip = give_get_ip(); |
163 | 163 | $payment->key = $payment_data['purchase_key']; |
164 | 164 | $payment->mode = give_is_test_mode() ? 'test' : 'live'; |
165 | - $payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : ''; |
|
165 | + $payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : ''; |
|
166 | 166 | |
167 | 167 | // Add the donation. |
168 | 168 | $args = array( |
169 | 169 | 'price' => $payment->total, |
170 | 170 | 'price_id' => $payment->price_id, |
171 | - 'fees' => isset( $payment_data['fees'] ) ? $payment_data['fees'] : array(), |
|
171 | + 'fees' => isset($payment_data['fees']) ? $payment_data['fees'] : array(), |
|
172 | 172 | ); |
173 | 173 | |
174 | - $payment->add_donation( $payment->form_id, $args ); |
|
174 | + $payment->add_donation($payment->form_id, $args); |
|
175 | 175 | |
176 | 176 | // Set date if present. |
177 | - if ( isset( $payment_data['post_date'] ) ) { |
|
177 | + if (isset($payment_data['post_date'])) { |
|
178 | 178 | $payment->date = $payment_data['post_date']; |
179 | 179 | } |
180 | 180 | |
181 | 181 | // Handle sequential payments. |
182 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
182 | + if (give_get_option('enable_sequential')) { |
|
183 | 183 | $number = give_get_next_payment_number(); |
184 | - $payment->number = give_format_payment_number( $number ); |
|
185 | - update_option( 'give_last_payment_number', $number ); |
|
184 | + $payment->number = give_format_payment_number($number); |
|
185 | + update_option('give_last_payment_number', $number); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | // Clear the user's donation cache. |
189 | - delete_transient( 'give_user_' . $payment_data['user_info']['id'] . '_purchases' ); |
|
189 | + delete_transient('give_user_'.$payment_data['user_info']['id'].'_purchases'); |
|
190 | 190 | |
191 | 191 | // Save payment. |
192 | 192 | $payment->save(); |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | * @param int $payment_id The payment ID. |
200 | 200 | * @param array $payment_data Arguments passed. |
201 | 201 | */ |
202 | - do_action( 'give_insert_payment', $payment->ID, $payment_data ); |
|
202 | + do_action('give_insert_payment', $payment->ID, $payment_data); |
|
203 | 203 | |
204 | 204 | // Return payment ID upon success. |
205 | - if ( ! empty( $payment->ID ) ) { |
|
205 | + if ( ! empty($payment->ID)) { |
|
206 | 206 | return $payment->ID; |
207 | 207 | } |
208 | 208 | |
@@ -218,10 +218,10 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @return bool|int |
220 | 220 | */ |
221 | -function give_create_payment( $payment_data ) { |
|
221 | +function give_create_payment($payment_data) { |
|
222 | 222 | |
223 | - $form_id = intval( $payment_data['post_data']['give-form-id'] ); |
|
224 | - $price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : ''; |
|
223 | + $form_id = intval($payment_data['post_data']['give-form-id']); |
|
224 | + $price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : ''; |
|
225 | 225 | |
226 | 226 | // Collect payment data. |
227 | 227 | $insert_payment_data = array( |
@@ -245,10 +245,10 @@ discard block |
||
245 | 245 | * |
246 | 246 | * @param array $insert_payment_data |
247 | 247 | */ |
248 | - $insert_payment_data = apply_filters( 'give_create_payment', $insert_payment_data ); |
|
248 | + $insert_payment_data = apply_filters('give_create_payment', $insert_payment_data); |
|
249 | 249 | |
250 | 250 | // Record the pending payment. |
251 | - return give_insert_payment( $insert_payment_data ); |
|
251 | + return give_insert_payment($insert_payment_data); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @return bool |
263 | 263 | */ |
264 | -function give_update_payment_status( $payment_id, $new_status = 'publish' ) { |
|
264 | +function give_update_payment_status($payment_id, $new_status = 'publish') { |
|
265 | 265 | |
266 | - $payment = new Give_Payment( $payment_id ); |
|
266 | + $payment = new Give_Payment($payment_id); |
|
267 | 267 | $payment->status = $new_status; |
268 | 268 | $updated = $payment->save(); |
269 | 269 | |
@@ -282,38 +282,38 @@ discard block |
||
282 | 282 | * |
283 | 283 | * @return void |
284 | 284 | */ |
285 | -function give_delete_purchase( $payment_id = 0, $update_customer = true ) { |
|
285 | +function give_delete_purchase($payment_id = 0, $update_customer = true) { |
|
286 | 286 | global $give_logs; |
287 | 287 | |
288 | - $payment = new Give_Payment( $payment_id ); |
|
289 | - $amount = give_get_payment_amount( $payment_id ); |
|
288 | + $payment = new Give_Payment($payment_id); |
|
289 | + $amount = give_get_payment_amount($payment_id); |
|
290 | 290 | $status = $payment->post_status; |
291 | - $customer_id = give_get_payment_customer_id( $payment_id ); |
|
292 | - $customer = new Give_Customer( $customer_id ); |
|
291 | + $customer_id = give_get_payment_customer_id($payment_id); |
|
292 | + $customer = new Give_Customer($customer_id); |
|
293 | 293 | |
294 | 294 | // Only undo donations that aren't these statuses. |
295 | - $dont_undo_statuses = apply_filters( 'give_undo_purchase_statuses', array( |
|
295 | + $dont_undo_statuses = apply_filters('give_undo_purchase_statuses', array( |
|
296 | 296 | 'pending', |
297 | 297 | 'cancelled', |
298 | - ) ); |
|
298 | + )); |
|
299 | 299 | |
300 | - if ( ! in_array( $status, $dont_undo_statuses ) ) { |
|
301 | - give_undo_purchase( false, $payment_id ); |
|
300 | + if ( ! in_array($status, $dont_undo_statuses)) { |
|
301 | + give_undo_purchase(false, $payment_id); |
|
302 | 302 | } |
303 | 303 | |
304 | - if ( $status == 'publish' ) { |
|
304 | + if ($status == 'publish') { |
|
305 | 305 | |
306 | 306 | // Only decrease earnings if they haven't already been decreased (or were never increased for this payment). |
307 | - give_decrease_total_earnings( $amount ); |
|
307 | + give_decrease_total_earnings($amount); |
|
308 | 308 | |
309 | 309 | // @todo: Refresh only range related stat cache |
310 | 310 | give_delete_donation_stats(); |
311 | 311 | |
312 | - if ( $customer->id && $update_customer ) { |
|
312 | + if ($customer->id && $update_customer) { |
|
313 | 313 | |
314 | 314 | // Decrement the stats for the donor. |
315 | 315 | $customer->decrease_purchase_count(); |
316 | - $customer->decrease_value( $amount ); |
|
316 | + $customer->decrease_value($amount); |
|
317 | 317 | |
318 | 318 | } |
319 | 319 | } |
@@ -325,17 +325,17 @@ discard block |
||
325 | 325 | * |
326 | 326 | * @param int $payment_id Payment ID. |
327 | 327 | */ |
328 | - do_action( 'give_payment_delete', $payment_id ); |
|
328 | + do_action('give_payment_delete', $payment_id); |
|
329 | 329 | |
330 | - if ( $customer->id && $update_customer ) { |
|
330 | + if ($customer->id && $update_customer) { |
|
331 | 331 | |
332 | 332 | // Remove the payment ID from the donor. |
333 | - $customer->remove_payment( $payment_id ); |
|
333 | + $customer->remove_payment($payment_id); |
|
334 | 334 | |
335 | 335 | } |
336 | 336 | |
337 | 337 | // Remove the payment. |
338 | - wp_delete_post( $payment_id, true ); |
|
338 | + wp_delete_post($payment_id, true); |
|
339 | 339 | |
340 | 340 | // Remove related sale log entries. |
341 | 341 | $give_logs->delete_logs( |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * |
357 | 357 | * @param int $payment_id Payment ID. |
358 | 358 | */ |
359 | - do_action( 'give_payment_deleted', $payment_id ); |
|
359 | + do_action('give_payment_deleted', $payment_id); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | /** |
@@ -372,25 +372,25 @@ discard block |
||
372 | 372 | * |
373 | 373 | * @return void |
374 | 374 | */ |
375 | -function give_undo_purchase( $form_id = false, $payment_id ) { |
|
375 | +function give_undo_purchase($form_id = false, $payment_id) { |
|
376 | 376 | |
377 | - if ( ! empty( $form_id ) ) { |
|
377 | + if ( ! empty($form_id)) { |
|
378 | 378 | $form_id = false; |
379 | - _give_deprected_argument( 'form_id', 'give_undo_purchase', '1.5' ); |
|
379 | + _give_deprected_argument('form_id', 'give_undo_purchase', '1.5'); |
|
380 | 380 | } |
381 | 381 | |
382 | - $payment = new Give_Payment( $payment_id ); |
|
382 | + $payment = new Give_Payment($payment_id); |
|
383 | 383 | |
384 | - $maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id ); |
|
385 | - if ( true === $maybe_decrease_earnings ) { |
|
384 | + $maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id); |
|
385 | + if (true === $maybe_decrease_earnings) { |
|
386 | 386 | // Decrease earnings. |
387 | - give_decrease_earnings( $payment->form_id, $payment->total ); |
|
387 | + give_decrease_earnings($payment->form_id, $payment->total); |
|
388 | 388 | } |
389 | 389 | |
390 | - $maybe_decrease_sales = apply_filters( 'give_decrease_donation_on_undo', true, $payment, $payment->form_id ); |
|
391 | - if ( true === $maybe_decrease_sales ) { |
|
390 | + $maybe_decrease_sales = apply_filters('give_decrease_donation_on_undo', true, $payment, $payment->form_id); |
|
391 | + if (true === $maybe_decrease_sales) { |
|
392 | 392 | // Decrease donation count. |
393 | - give_decrease_purchase_count( $payment->form_id ); |
|
393 | + give_decrease_purchase_count($payment->form_id); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | } |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | * |
408 | 408 | * @return object $stats Contains the number of payments per payment status. |
409 | 409 | */ |
410 | -function give_count_payments( $args = array() ) { |
|
410 | +function give_count_payments($args = array()) { |
|
411 | 411 | |
412 | 412 | global $wpdb; |
413 | 413 | |
@@ -419,18 +419,18 @@ discard block |
||
419 | 419 | 'form_id' => null, |
420 | 420 | ); |
421 | 421 | |
422 | - $args = wp_parse_args( $args, $defaults ); |
|
422 | + $args = wp_parse_args($args, $defaults); |
|
423 | 423 | |
424 | 424 | $select = 'SELECT p.post_status,count( * ) AS num_posts'; |
425 | 425 | $join = ''; |
426 | 426 | $where = "WHERE p.post_type = 'give_payment'"; |
427 | 427 | |
428 | 428 | // Count payments for a specific user. |
429 | - if ( ! empty( $args['user'] ) ) { |
|
429 | + if ( ! empty($args['user'])) { |
|
430 | 430 | |
431 | - if ( is_email( $args['user'] ) ) { |
|
431 | + if (is_email($args['user'])) { |
|
432 | 432 | $field = 'email'; |
433 | - } elseif ( is_numeric( $args['user'] ) ) { |
|
433 | + } elseif (is_numeric($args['user'])) { |
|
434 | 434 | $field = 'id'; |
435 | 435 | } else { |
436 | 436 | $field = ''; |
@@ -438,105 +438,105 @@ discard block |
||
438 | 438 | |
439 | 439 | $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
440 | 440 | |
441 | - if ( ! empty( $field ) ) { |
|
441 | + if ( ! empty($field)) { |
|
442 | 442 | $where .= " |
443 | 443 | AND m.meta_key = '_give_payment_user_{$field}' |
444 | 444 | AND m.meta_value = '{$args['user']}'"; |
445 | 445 | } |
446 | 446 | |
447 | 447 | // Count payments for a search. |
448 | - } elseif ( ! empty( $args['s'] ) ) { |
|
448 | + } elseif ( ! empty($args['s'])) { |
|
449 | 449 | |
450 | - if ( is_email( $args['s'] ) || strlen( $args['s'] ) == 32 ) { |
|
450 | + if (is_email($args['s']) || strlen($args['s']) == 32) { |
|
451 | 451 | |
452 | - if ( is_email( $args['s'] ) ) { |
|
452 | + if (is_email($args['s'])) { |
|
453 | 453 | $field = '_give_payment_user_email'; |
454 | 454 | } else { |
455 | 455 | $field = '_give_payment_purchase_key'; |
456 | 456 | } |
457 | 457 | |
458 | - $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
459 | - $where .= $wpdb->prepare( ' |
|
458 | + $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
459 | + $where .= $wpdb->prepare(' |
|
460 | 460 | AND m.meta_key = %s |
461 | 461 | AND m.meta_value = %s', |
462 | 462 | $field, |
463 | 463 | $args['s'] |
464 | 464 | ); |
465 | 465 | |
466 | - } elseif ( '#' == substr( $args['s'], 0, 1 ) ) { |
|
466 | + } elseif ('#' == substr($args['s'], 0, 1)) { |
|
467 | 467 | |
468 | - $search = str_replace( '#:', '', $args['s'] ); |
|
469 | - $search = str_replace( '#', '', $search ); |
|
468 | + $search = str_replace('#:', '', $args['s']); |
|
469 | + $search = str_replace('#', '', $search); |
|
470 | 470 | |
471 | 471 | $select = 'SELECT p2.post_status,count( * ) AS num_posts '; |
472 | 472 | $join = "LEFT JOIN $wpdb->postmeta m ON m.meta_key = '_give_log_payment_id' AND m.post_id = p.ID "; |
473 | 473 | $join .= "INNER JOIN $wpdb->posts p2 ON m.meta_value = p2.ID "; |
474 | 474 | $where = "WHERE p.post_type = 'give_log' "; |
475 | - $where .= $wpdb->prepare( 'AND p.post_parent = %d} ', $search ); |
|
475 | + $where .= $wpdb->prepare('AND p.post_parent = %d} ', $search); |
|
476 | 476 | |
477 | - } elseif ( is_numeric( $args['s'] ) ) { |
|
477 | + } elseif (is_numeric($args['s'])) { |
|
478 | 478 | |
479 | - $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
480 | - $where .= $wpdb->prepare( " |
|
479 | + $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
480 | + $where .= $wpdb->prepare(" |
|
481 | 481 | AND m.meta_key = '_give_payment_user_id' |
482 | 482 | AND m.meta_value = %d", |
483 | 483 | $args['s'] |
484 | 484 | ); |
485 | 485 | |
486 | 486 | } else { |
487 | - $search = $wpdb->esc_like( $args['s'] ); |
|
488 | - $search = '%' . $search . '%'; |
|
487 | + $search = $wpdb->esc_like($args['s']); |
|
488 | + $search = '%'.$search.'%'; |
|
489 | 489 | |
490 | - $where .= $wpdb->prepare( 'AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search ); |
|
490 | + $where .= $wpdb->prepare('AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search); |
|
491 | 491 | } |
492 | 492 | } |
493 | 493 | |
494 | - if ( ! empty( $args['form_id'] ) && is_numeric( $args['form_id'] ) ) { |
|
494 | + if ( ! empty($args['form_id']) && is_numeric($args['form_id'])) { |
|
495 | 495 | |
496 | - $where .= $wpdb->prepare( ' AND p.post_parent = %d', $args['form_id'] ); |
|
496 | + $where .= $wpdb->prepare(' AND p.post_parent = %d', $args['form_id']); |
|
497 | 497 | |
498 | 498 | } |
499 | 499 | // Limit payments count by date. |
500 | - if ( ! empty( $args['start-date'] ) && false !== strpos( $args['start-date'], '/' ) ) { |
|
500 | + if ( ! empty($args['start-date']) && false !== strpos($args['start-date'], '/')) { |
|
501 | 501 | |
502 | - $date_parts = explode( '/', $args['start-date'] ); |
|
503 | - $month = ! empty( $date_parts[0] ) && is_numeric( $date_parts[0] ) ? $date_parts[0] : 0; |
|
504 | - $day = ! empty( $date_parts[1] ) && is_numeric( $date_parts[1] ) ? $date_parts[1] : 0; |
|
505 | - $year = ! empty( $date_parts[2] ) && is_numeric( $date_parts[2] ) ? $date_parts[2] : 0; |
|
502 | + $date_parts = explode('/', $args['start-date']); |
|
503 | + $month = ! empty($date_parts[0]) && is_numeric($date_parts[0]) ? $date_parts[0] : 0; |
|
504 | + $day = ! empty($date_parts[1]) && is_numeric($date_parts[1]) ? $date_parts[1] : 0; |
|
505 | + $year = ! empty($date_parts[2]) && is_numeric($date_parts[2]) ? $date_parts[2] : 0; |
|
506 | 506 | |
507 | - $is_date = checkdate( $month, $day, $year ); |
|
508 | - if ( false !== $is_date ) { |
|
507 | + $is_date = checkdate($month, $day, $year); |
|
508 | + if (false !== $is_date) { |
|
509 | 509 | |
510 | - $date = new DateTime( $args['start-date'] ); |
|
511 | - $where .= $wpdb->prepare( " AND p.post_date >= '%s'", $date->format( 'Y-m-d' ) ); |
|
510 | + $date = new DateTime($args['start-date']); |
|
511 | + $where .= $wpdb->prepare(" AND p.post_date >= '%s'", $date->format('Y-m-d')); |
|
512 | 512 | |
513 | 513 | } |
514 | 514 | |
515 | 515 | // Fixes an issue with the payments list table counts when no end date is specified (partiy with stats class). |
516 | - if ( empty( $args['end-date'] ) ) { |
|
516 | + if (empty($args['end-date'])) { |
|
517 | 517 | $args['end-date'] = $args['start-date']; |
518 | 518 | } |
519 | 519 | } |
520 | 520 | |
521 | - if ( ! empty( $args['end-date'] ) && false !== strpos( $args['end-date'], '/' ) ) { |
|
521 | + if ( ! empty($args['end-date']) && false !== strpos($args['end-date'], '/')) { |
|
522 | 522 | |
523 | - $date_parts = explode( '/', $args['end-date'] ); |
|
523 | + $date_parts = explode('/', $args['end-date']); |
|
524 | 524 | |
525 | - $month = ! empty( $date_parts[0] ) ? $date_parts[0] : 0; |
|
526 | - $day = ! empty( $date_parts[1] ) ? $date_parts[1] : 0; |
|
527 | - $year = ! empty( $date_parts[2] ) ? $date_parts[2] : 0; |
|
525 | + $month = ! empty($date_parts[0]) ? $date_parts[0] : 0; |
|
526 | + $day = ! empty($date_parts[1]) ? $date_parts[1] : 0; |
|
527 | + $year = ! empty($date_parts[2]) ? $date_parts[2] : 0; |
|
528 | 528 | |
529 | - $is_date = checkdate( $month, $day, $year ); |
|
530 | - if ( false !== $is_date ) { |
|
529 | + $is_date = checkdate($month, $day, $year); |
|
530 | + if (false !== $is_date) { |
|
531 | 531 | |
532 | - $date = new DateTime( $args['end-date'] ); |
|
533 | - $where .= $wpdb->prepare( " AND p.post_date <= '%s'", $date->format( 'Y-m-d' ) ); |
|
532 | + $date = new DateTime($args['end-date']); |
|
533 | + $where .= $wpdb->prepare(" AND p.post_date <= '%s'", $date->format('Y-m-d')); |
|
534 | 534 | |
535 | 535 | } |
536 | 536 | } |
537 | 537 | |
538 | - $where = apply_filters( 'give_count_payments_where', $where ); |
|
539 | - $join = apply_filters( 'give_count_payments_join', $join ); |
|
538 | + $where = apply_filters('give_count_payments_where', $where); |
|
539 | + $join = apply_filters('give_count_payments_join', $join); |
|
540 | 540 | |
541 | 541 | $query = "$select |
542 | 542 | FROM $wpdb->posts p |
@@ -545,36 +545,36 @@ discard block |
||
545 | 545 | GROUP BY p.post_status |
546 | 546 | "; |
547 | 547 | |
548 | - $cache_key = md5( $query ); |
|
548 | + $cache_key = md5($query); |
|
549 | 549 | |
550 | - $count = wp_cache_get( $cache_key, 'counts' ); |
|
551 | - if ( false !== $count ) { |
|
550 | + $count = wp_cache_get($cache_key, 'counts'); |
|
551 | + if (false !== $count) { |
|
552 | 552 | return $count; |
553 | 553 | } |
554 | 554 | |
555 | - $count = $wpdb->get_results( $query, ARRAY_A ); |
|
555 | + $count = $wpdb->get_results($query, ARRAY_A); |
|
556 | 556 | |
557 | 557 | $stats = array(); |
558 | 558 | $statuses = get_post_stati(); |
559 | - if ( isset( $statuses['private'] ) && empty( $args['s'] ) ) { |
|
560 | - unset( $statuses['private'] ); |
|
559 | + if (isset($statuses['private']) && empty($args['s'])) { |
|
560 | + unset($statuses['private']); |
|
561 | 561 | } |
562 | 562 | |
563 | - foreach ( $statuses as $state ) { |
|
564 | - $stats[ $state ] = 0; |
|
563 | + foreach ($statuses as $state) { |
|
564 | + $stats[$state] = 0; |
|
565 | 565 | } |
566 | 566 | |
567 | - foreach ( (array) $count as $row ) { |
|
567 | + foreach ((array) $count as $row) { |
|
568 | 568 | |
569 | - if ( 'private' == $row['post_status'] && empty( $args['s'] ) ) { |
|
569 | + if ('private' == $row['post_status'] && empty($args['s'])) { |
|
570 | 570 | continue; |
571 | 571 | } |
572 | 572 | |
573 | - $stats[ $row['post_status'] ] = $row['num_posts']; |
|
573 | + $stats[$row['post_status']] = $row['num_posts']; |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | $stats = (object) $stats; |
577 | - wp_cache_set( $cache_key, $stats, 'counts' ); |
|
577 | + wp_cache_set($cache_key, $stats, 'counts'); |
|
578 | 578 | |
579 | 579 | return $stats; |
580 | 580 | } |
@@ -589,11 +589,11 @@ discard block |
||
589 | 589 | * |
590 | 590 | * @return bool $exists True if payment exists, false otherwise. |
591 | 591 | */ |
592 | -function give_check_for_existing_payment( $payment_id ) { |
|
592 | +function give_check_for_existing_payment($payment_id) { |
|
593 | 593 | $exists = false; |
594 | - $payment = new Give_Payment( $payment_id ); |
|
594 | + $payment = new Give_Payment($payment_id); |
|
595 | 595 | |
596 | - if ( $payment_id === $payment->ID && 'publish' === $payment->status ) { |
|
596 | + if ($payment_id === $payment->ID && 'publish' === $payment->status) { |
|
597 | 597 | $exists = true; |
598 | 598 | } |
599 | 599 | |
@@ -611,31 +611,31 @@ discard block |
||
611 | 611 | * |
612 | 612 | * @return bool|mixed True if payment status exists, false otherwise. |
613 | 613 | */ |
614 | -function give_get_payment_status( $payment, $return_label = false ) { |
|
614 | +function give_get_payment_status($payment, $return_label = false) { |
|
615 | 615 | |
616 | - if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) { |
|
616 | + if ( ! is_object($payment) || ! isset($payment->post_status)) { |
|
617 | 617 | return false; |
618 | 618 | } |
619 | 619 | |
620 | 620 | $statuses = give_get_payment_statuses(); |
621 | 621 | |
622 | - if ( ! is_array( $statuses ) || empty( $statuses ) ) { |
|
622 | + if ( ! is_array($statuses) || empty($statuses)) { |
|
623 | 623 | return false; |
624 | 624 | } |
625 | 625 | |
626 | 626 | // Get payment object if no already given. |
627 | - $payment = $payment instanceof Give_Payment ? $payment : new Give_Payment( $payment->ID ); |
|
627 | + $payment = $payment instanceof Give_Payment ? $payment : new Give_Payment($payment->ID); |
|
628 | 628 | |
629 | - if ( array_key_exists( $payment->status, $statuses ) ) { |
|
630 | - if ( true === $return_label ) { |
|
629 | + if (array_key_exists($payment->status, $statuses)) { |
|
630 | + if (true === $return_label) { |
|
631 | 631 | // Return translated status label. |
632 | - return $statuses[ $payment->status ]; |
|
632 | + return $statuses[$payment->status]; |
|
633 | 633 | } else { |
634 | 634 | // Account that our 'publish' status is labeled 'Complete' |
635 | 635 | $post_status = 'publish' == $payment->status ? 'Complete' : $payment->post_status; |
636 | 636 | |
637 | 637 | // Make sure we're matching cases, since they matter |
638 | - return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) ); |
|
638 | + return array_search(strtolower($post_status), array_map('strtolower', $statuses)); |
|
639 | 639 | } |
640 | 640 | } |
641 | 641 | |
@@ -651,18 +651,18 @@ discard block |
||
651 | 651 | */ |
652 | 652 | function give_get_payment_statuses() { |
653 | 653 | $payment_statuses = array( |
654 | - 'pending' => __( 'Pending', 'give' ), |
|
655 | - 'publish' => __( 'Complete', 'give' ), |
|
656 | - 'refunded' => __( 'Refunded', 'give' ), |
|
657 | - 'failed' => __( 'Failed', 'give' ), |
|
658 | - 'cancelled' => __( 'Cancelled', 'give' ), |
|
659 | - 'abandoned' => __( 'Abandoned', 'give' ), |
|
660 | - 'preapproval' => __( 'Pre-Approved', 'give' ), |
|
661 | - 'processing' => __( 'Processing', 'give' ), |
|
662 | - 'revoked' => __( 'Revoked', 'give' ), |
|
654 | + 'pending' => __('Pending', 'give'), |
|
655 | + 'publish' => __('Complete', 'give'), |
|
656 | + 'refunded' => __('Refunded', 'give'), |
|
657 | + 'failed' => __('Failed', 'give'), |
|
658 | + 'cancelled' => __('Cancelled', 'give'), |
|
659 | + 'abandoned' => __('Abandoned', 'give'), |
|
660 | + 'preapproval' => __('Pre-Approved', 'give'), |
|
661 | + 'processing' => __('Processing', 'give'), |
|
662 | + 'revoked' => __('Revoked', 'give'), |
|
663 | 663 | ); |
664 | 664 | |
665 | - return apply_filters( 'give_payment_statuses', $payment_statuses ); |
|
665 | + return apply_filters('give_payment_statuses', $payment_statuses); |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | /** |
@@ -675,10 +675,10 @@ discard block |
||
675 | 675 | * @return array $payment_status All the available payment statuses. |
676 | 676 | */ |
677 | 677 | function give_get_payment_status_keys() { |
678 | - $statuses = array_keys( give_get_payment_statuses() ); |
|
679 | - asort( $statuses ); |
|
678 | + $statuses = array_keys(give_get_payment_statuses()); |
|
679 | + asort($statuses); |
|
680 | 680 | |
681 | - return array_values( $statuses ); |
|
681 | + return array_values($statuses); |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | /** |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | * |
694 | 694 | * @return int $earnings Earnings |
695 | 695 | */ |
696 | -function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
|
696 | +function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) { |
|
697 | 697 | |
698 | 698 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead. |
699 | 699 | global $wpdb; |
@@ -703,41 +703,41 @@ discard block |
||
703 | 703 | 'nopaging' => true, |
704 | 704 | 'year' => $year, |
705 | 705 | 'monthnum' => $month_num, |
706 | - 'post_status' => array( 'publish' ), |
|
706 | + 'post_status' => array('publish'), |
|
707 | 707 | 'fields' => 'ids', |
708 | 708 | 'update_post_term_cache' => false, |
709 | 709 | ); |
710 | - if ( ! empty( $day ) ) { |
|
710 | + if ( ! empty($day)) { |
|
711 | 711 | $args['day'] = $day; |
712 | 712 | } |
713 | 713 | |
714 | - if ( ! empty( $hour ) ) { |
|
714 | + if ( ! empty($hour)) { |
|
715 | 715 | $args['hour'] = $hour; |
716 | 716 | } |
717 | 717 | |
718 | - $args = apply_filters( 'give_get_earnings_by_date_args', $args ); |
|
719 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
718 | + $args = apply_filters('give_get_earnings_by_date_args', $args); |
|
719 | + $key = Give_Cache::get_key('give_stats', $args); |
|
720 | 720 | |
721 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
721 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
722 | 722 | $earnings = false; |
723 | 723 | } else { |
724 | - $earnings = Give_Cache::get( $key ); |
|
724 | + $earnings = Give_Cache::get($key); |
|
725 | 725 | } |
726 | 726 | |
727 | - if ( false === $earnings ) { |
|
728 | - $sales = get_posts( $args ); |
|
727 | + if (false === $earnings) { |
|
728 | + $sales = get_posts($args); |
|
729 | 729 | $earnings = 0; |
730 | - if ( $sales ) { |
|
731 | - $sales = implode( ',', $sales ); |
|
730 | + if ($sales) { |
|
731 | + $sales = implode(',', $sales); |
|
732 | 732 | |
733 | - $earnings = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})" ); |
|
733 | + $earnings = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})"); |
|
734 | 734 | |
735 | 735 | } |
736 | 736 | // Cache the results for one hour. |
737 | - Give_Cache::set( $key, $earnings, HOUR_IN_SECONDS ); |
|
737 | + Give_Cache::set($key, $earnings, HOUR_IN_SECONDS); |
|
738 | 738 | } |
739 | 739 | |
740 | - return round( $earnings, 2 ); |
|
740 | + return round($earnings, 2); |
|
741 | 741 | } |
742 | 742 | |
743 | 743 | /** |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | * |
753 | 753 | * @return int $count Sales |
754 | 754 | */ |
755 | -function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) { |
|
755 | +function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) { |
|
756 | 756 | |
757 | 757 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead. |
758 | 758 | $args = array( |
@@ -760,14 +760,14 @@ discard block |
||
760 | 760 | 'nopaging' => true, |
761 | 761 | 'year' => $year, |
762 | 762 | 'fields' => 'ids', |
763 | - 'post_status' => array( 'publish' ), |
|
763 | + 'post_status' => array('publish'), |
|
764 | 764 | 'update_post_meta_cache' => false, |
765 | 765 | 'update_post_term_cache' => false, |
766 | 766 | ); |
767 | 767 | |
768 | - $show_free = apply_filters( 'give_sales_by_date_show_free', true, $args ); |
|
768 | + $show_free = apply_filters('give_sales_by_date_show_free', true, $args); |
|
769 | 769 | |
770 | - if ( false === $show_free ) { |
|
770 | + if (false === $show_free) { |
|
771 | 771 | $args['meta_query'] = array( |
772 | 772 | array( |
773 | 773 | 'key' => '_give_payment_total', |
@@ -778,33 +778,33 @@ discard block |
||
778 | 778 | ); |
779 | 779 | } |
780 | 780 | |
781 | - if ( ! empty( $month_num ) ) { |
|
781 | + if ( ! empty($month_num)) { |
|
782 | 782 | $args['monthnum'] = $month_num; |
783 | 783 | } |
784 | 784 | |
785 | - if ( ! empty( $day ) ) { |
|
785 | + if ( ! empty($day)) { |
|
786 | 786 | $args['day'] = $day; |
787 | 787 | } |
788 | 788 | |
789 | - if ( ! empty( $hour ) ) { |
|
789 | + if ( ! empty($hour)) { |
|
790 | 790 | $args['hour'] = $hour; |
791 | 791 | } |
792 | 792 | |
793 | - $args = apply_filters( 'give_get_sales_by_date_args', $args ); |
|
793 | + $args = apply_filters('give_get_sales_by_date_args', $args); |
|
794 | 794 | |
795 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
795 | + $key = Give_Cache::get_key('give_stats', $args); |
|
796 | 796 | |
797 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
797 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
798 | 798 | $count = false; |
799 | 799 | } else { |
800 | - $count = Give_Cache::get( $key ); |
|
800 | + $count = Give_Cache::get($key); |
|
801 | 801 | } |
802 | 802 | |
803 | - if ( false === $count ) { |
|
804 | - $sales = new WP_Query( $args ); |
|
803 | + if (false === $count) { |
|
804 | + $sales = new WP_Query($args); |
|
805 | 805 | $count = (int) $sales->post_count; |
806 | 806 | // Cache the results for one hour. |
807 | - Give_Cache::set( $key, $count, HOUR_IN_SECONDS ); |
|
807 | + Give_Cache::set($key, $count, HOUR_IN_SECONDS); |
|
808 | 808 | } |
809 | 809 | |
810 | 810 | return $count; |
@@ -819,19 +819,19 @@ discard block |
||
819 | 819 | * |
820 | 820 | * @return bool $ret True if complete, false otherwise. |
821 | 821 | */ |
822 | -function give_is_payment_complete( $payment_id ) { |
|
823 | - $payment = new Give_Payment( $payment_id ); |
|
822 | +function give_is_payment_complete($payment_id) { |
|
823 | + $payment = new Give_Payment($payment_id); |
|
824 | 824 | |
825 | 825 | $ret = false; |
826 | 826 | |
827 | - if ( $payment->ID > 0 ) { |
|
827 | + if ($payment->ID > 0) { |
|
828 | 828 | |
829 | - if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) { |
|
829 | + if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) { |
|
830 | 830 | $ret = true; |
831 | 831 | } |
832 | 832 | } |
833 | 833 | |
834 | - return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status ); |
|
834 | + return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status); |
|
835 | 835 | } |
836 | 836 | |
837 | 837 | /** |
@@ -857,49 +857,49 @@ discard block |
||
857 | 857 | * |
858 | 858 | * @return float $total Total earnings. |
859 | 859 | */ |
860 | -function give_get_total_earnings( $recalculate = false ) { |
|
860 | +function give_get_total_earnings($recalculate = false) { |
|
861 | 861 | |
862 | - $total = get_option( 'give_earnings_total', 0 ); |
|
862 | + $total = get_option('give_earnings_total', 0); |
|
863 | 863 | |
864 | 864 | // Calculate total earnings. |
865 | - if ( ! $total || $recalculate ) { |
|
865 | + if ( ! $total || $recalculate) { |
|
866 | 866 | global $wpdb; |
867 | 867 | |
868 | 868 | $total = (float) 0; |
869 | 869 | |
870 | - $args = apply_filters( 'give_get_total_earnings_args', array( |
|
870 | + $args = apply_filters('give_get_total_earnings_args', array( |
|
871 | 871 | 'offset' => 0, |
872 | - 'number' => - 1, |
|
873 | - 'status' => array( 'publish' ), |
|
872 | + 'number' => -1, |
|
873 | + 'status' => array('publish'), |
|
874 | 874 | 'fields' => 'ids', |
875 | - ) ); |
|
875 | + )); |
|
876 | 876 | |
877 | - $payments = give_get_payments( $args ); |
|
878 | - if ( $payments ) { |
|
877 | + $payments = give_get_payments($args); |
|
878 | + if ($payments) { |
|
879 | 879 | |
880 | 880 | /** |
881 | 881 | * If performing a donation, we need to skip the very last payment in the database, |
882 | 882 | * since it calls give_increase_total_earnings() on completion, |
883 | 883 | * which results in duplicated earnings for the very first donation. |
884 | 884 | */ |
885 | - if ( did_action( 'give_update_payment_status' ) ) { |
|
886 | - array_pop( $payments ); |
|
885 | + if (did_action('give_update_payment_status')) { |
|
886 | + array_pop($payments); |
|
887 | 887 | } |
888 | 888 | |
889 | - if ( ! empty( $payments ) ) { |
|
890 | - $payments = implode( ',', $payments ); |
|
891 | - $total += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})" ); |
|
889 | + if ( ! empty($payments)) { |
|
890 | + $payments = implode(',', $payments); |
|
891 | + $total += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})"); |
|
892 | 892 | } |
893 | 893 | } |
894 | 894 | |
895 | - update_option( 'give_earnings_total', $total, 'no' ); |
|
895 | + update_option('give_earnings_total', $total, 'no'); |
|
896 | 896 | } |
897 | 897 | |
898 | - if ( $total < 0 ) { |
|
898 | + if ($total < 0) { |
|
899 | 899 | $total = 0; // Don't ever show negative earnings. |
900 | 900 | } |
901 | 901 | |
902 | - return apply_filters( 'give_total_earnings', round( $total, give_currency_decimal_filter() ) ); |
|
902 | + return apply_filters('give_total_earnings', round($total, give_currency_decimal_filter())); |
|
903 | 903 | } |
904 | 904 | |
905 | 905 | /** |
@@ -912,10 +912,10 @@ discard block |
||
912 | 912 | * |
913 | 913 | * @return float $total Total earnings. |
914 | 914 | */ |
915 | -function give_increase_total_earnings( $amount = 0 ) { |
|
915 | +function give_increase_total_earnings($amount = 0) { |
|
916 | 916 | $total = give_get_total_earnings(); |
917 | 917 | $total += $amount; |
918 | - update_option( 'give_earnings_total', $total ); |
|
918 | + update_option('give_earnings_total', $total); |
|
919 | 919 | |
920 | 920 | return $total; |
921 | 921 | } |
@@ -929,13 +929,13 @@ discard block |
||
929 | 929 | * |
930 | 930 | * @return float $total Total earnings. |
931 | 931 | */ |
932 | -function give_decrease_total_earnings( $amount = 0 ) { |
|
932 | +function give_decrease_total_earnings($amount = 0) { |
|
933 | 933 | $total = give_get_total_earnings(); |
934 | 934 | $total -= $amount; |
935 | - if ( $total < 0 ) { |
|
935 | + if ($total < 0) { |
|
936 | 936 | $total = 0; |
937 | 937 | } |
938 | - update_option( 'give_earnings_total', $total ); |
|
938 | + update_option('give_earnings_total', $total); |
|
939 | 939 | |
940 | 940 | return $total; |
941 | 941 | } |
@@ -951,10 +951,10 @@ discard block |
||
951 | 951 | * |
952 | 952 | * @return mixed $meta Payment Meta. |
953 | 953 | */ |
954 | -function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) { |
|
955 | - $payment = new Give_Payment( $payment_id ); |
|
954 | +function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) { |
|
955 | + $payment = new Give_Payment($payment_id); |
|
956 | 956 | |
957 | - return $payment->get_meta( $meta_key, $single ); |
|
957 | + return $payment->get_meta($meta_key, $single); |
|
958 | 958 | } |
959 | 959 | |
960 | 960 | /** |
@@ -967,10 +967,10 @@ discard block |
||
967 | 967 | * |
968 | 968 | * @return mixed Meta ID if successful, false if unsuccessful. |
969 | 969 | */ |
970 | -function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
971 | - $payment = new Give_Payment( $payment_id ); |
|
970 | +function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') { |
|
971 | + $payment = new Give_Payment($payment_id); |
|
972 | 972 | |
973 | - return $payment->update_meta( $meta_key, $meta_value, $prev_value ); |
|
973 | + return $payment->update_meta($meta_key, $meta_value, $prev_value); |
|
974 | 974 | } |
975 | 975 | |
976 | 976 | /** |
@@ -982,8 +982,8 @@ discard block |
||
982 | 982 | * |
983 | 983 | * @return string $user_info User Info Meta Values. |
984 | 984 | */ |
985 | -function give_get_payment_meta_user_info( $payment_id ) { |
|
986 | - $payment = new Give_Payment( $payment_id ); |
|
985 | +function give_get_payment_meta_user_info($payment_id) { |
|
986 | + $payment = new Give_Payment($payment_id); |
|
987 | 987 | |
988 | 988 | return $payment->user_info; |
989 | 989 | } |
@@ -999,8 +999,8 @@ discard block |
||
999 | 999 | * |
1000 | 1000 | * @return int $form_id Form ID. |
1001 | 1001 | */ |
1002 | -function give_get_payment_form_id( $payment_id ) { |
|
1003 | - $payment = new Give_Payment( $payment_id ); |
|
1002 | +function give_get_payment_form_id($payment_id) { |
|
1003 | + $payment = new Give_Payment($payment_id); |
|
1004 | 1004 | |
1005 | 1005 | return $payment->form_id; |
1006 | 1006 | } |
@@ -1014,8 +1014,8 @@ discard block |
||
1014 | 1014 | * |
1015 | 1015 | * @return string $email User email. |
1016 | 1016 | */ |
1017 | -function give_get_payment_user_email( $payment_id ) { |
|
1018 | - $payment = new Give_Payment( $payment_id ); |
|
1017 | +function give_get_payment_user_email($payment_id) { |
|
1018 | + $payment = new Give_Payment($payment_id); |
|
1019 | 1019 | |
1020 | 1020 | return $payment->email; |
1021 | 1021 | } |
@@ -1029,11 +1029,11 @@ discard block |
||
1029 | 1029 | * |
1030 | 1030 | * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true) |
1031 | 1031 | */ |
1032 | -function give_is_guest_payment( $payment_id ) { |
|
1033 | - $payment_user_id = give_get_payment_user_id( $payment_id ); |
|
1034 | - $is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true; |
|
1032 | +function give_is_guest_payment($payment_id) { |
|
1033 | + $payment_user_id = give_get_payment_user_id($payment_id); |
|
1034 | + $is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true; |
|
1035 | 1035 | |
1036 | - return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id ); |
|
1036 | + return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id); |
|
1037 | 1037 | } |
1038 | 1038 | |
1039 | 1039 | /** |
@@ -1045,8 +1045,8 @@ discard block |
||
1045 | 1045 | * |
1046 | 1046 | * @return int $user_id User ID. |
1047 | 1047 | */ |
1048 | -function give_get_payment_user_id( $payment_id ) { |
|
1049 | - $payment = new Give_Payment( $payment_id ); |
|
1048 | +function give_get_payment_user_id($payment_id) { |
|
1049 | + $payment = new Give_Payment($payment_id); |
|
1050 | 1050 | |
1051 | 1051 | return $payment->user_id; |
1052 | 1052 | } |
@@ -1060,8 +1060,8 @@ discard block |
||
1060 | 1060 | * |
1061 | 1061 | * @return int $customer_id Customer ID. |
1062 | 1062 | */ |
1063 | -function give_get_payment_customer_id( $payment_id ) { |
|
1064 | - $payment = new Give_Payment( $payment_id ); |
|
1063 | +function give_get_payment_customer_id($payment_id) { |
|
1064 | + $payment = new Give_Payment($payment_id); |
|
1065 | 1065 | |
1066 | 1066 | return $payment->customer_id; |
1067 | 1067 | } |
@@ -1075,8 +1075,8 @@ discard block |
||
1075 | 1075 | * |
1076 | 1076 | * @return string $ip User IP. |
1077 | 1077 | */ |
1078 | -function give_get_payment_user_ip( $payment_id ) { |
|
1079 | - $payment = new Give_Payment( $payment_id ); |
|
1078 | +function give_get_payment_user_ip($payment_id) { |
|
1079 | + $payment = new Give_Payment($payment_id); |
|
1080 | 1080 | |
1081 | 1081 | return $payment->ip; |
1082 | 1082 | } |
@@ -1090,8 +1090,8 @@ discard block |
||
1090 | 1090 | * |
1091 | 1091 | * @return string $date The date the payment was completed. |
1092 | 1092 | */ |
1093 | -function give_get_payment_completed_date( $payment_id = 0 ) { |
|
1094 | - $payment = new Give_Payment( $payment_id ); |
|
1093 | +function give_get_payment_completed_date($payment_id = 0) { |
|
1094 | + $payment = new Give_Payment($payment_id); |
|
1095 | 1095 | |
1096 | 1096 | return $payment->completed_date; |
1097 | 1097 | } |
@@ -1105,8 +1105,8 @@ discard block |
||
1105 | 1105 | * |
1106 | 1106 | * @return string $gateway Gateway. |
1107 | 1107 | */ |
1108 | -function give_get_payment_gateway( $payment_id ) { |
|
1109 | - $payment = new Give_Payment( $payment_id ); |
|
1108 | +function give_get_payment_gateway($payment_id) { |
|
1109 | + $payment = new Give_Payment($payment_id); |
|
1110 | 1110 | |
1111 | 1111 | return $payment->gateway; |
1112 | 1112 | } |
@@ -1120,8 +1120,8 @@ discard block |
||
1120 | 1120 | * |
1121 | 1121 | * @return string $currency The currency code. |
1122 | 1122 | */ |
1123 | -function give_get_payment_currency_code( $payment_id = 0 ) { |
|
1124 | - $payment = new Give_Payment( $payment_id ); |
|
1123 | +function give_get_payment_currency_code($payment_id = 0) { |
|
1124 | + $payment = new Give_Payment($payment_id); |
|
1125 | 1125 | |
1126 | 1126 | return $payment->currency; |
1127 | 1127 | } |
@@ -1135,10 +1135,10 @@ discard block |
||
1135 | 1135 | * |
1136 | 1136 | * @return string $currency The currency name. |
1137 | 1137 | */ |
1138 | -function give_get_payment_currency( $payment_id = 0 ) { |
|
1139 | - $currency = give_get_payment_currency_code( $payment_id ); |
|
1138 | +function give_get_payment_currency($payment_id = 0) { |
|
1139 | + $currency = give_get_payment_currency_code($payment_id); |
|
1140 | 1140 | |
1141 | - return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id ); |
|
1141 | + return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id); |
|
1142 | 1142 | } |
1143 | 1143 | |
1144 | 1144 | /** |
@@ -1150,8 +1150,8 @@ discard block |
||
1150 | 1150 | * |
1151 | 1151 | * @return string $key Donation key. |
1152 | 1152 | */ |
1153 | -function give_get_payment_key( $payment_id = 0 ) { |
|
1154 | - $payment = new Give_Payment( $payment_id ); |
|
1153 | +function give_get_payment_key($payment_id = 0) { |
|
1154 | + $payment = new Give_Payment($payment_id); |
|
1155 | 1155 | |
1156 | 1156 | return $payment->key; |
1157 | 1157 | } |
@@ -1167,8 +1167,8 @@ discard block |
||
1167 | 1167 | * |
1168 | 1168 | * @return string $number Payment order number. |
1169 | 1169 | */ |
1170 | -function give_get_payment_number( $payment_id = 0 ) { |
|
1171 | - $payment = new Give_Payment( $payment_id ); |
|
1170 | +function give_get_payment_number($payment_id = 0) { |
|
1171 | + $payment = new Give_Payment($payment_id); |
|
1172 | 1172 | |
1173 | 1173 | return $payment->number; |
1174 | 1174 | } |
@@ -1182,23 +1182,23 @@ discard block |
||
1182 | 1182 | * |
1183 | 1183 | * @return string The formatted payment number. |
1184 | 1184 | */ |
1185 | -function give_format_payment_number( $number ) { |
|
1185 | +function give_format_payment_number($number) { |
|
1186 | 1186 | |
1187 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
1187 | + if ( ! give_get_option('enable_sequential')) { |
|
1188 | 1188 | return $number; |
1189 | 1189 | } |
1190 | 1190 | |
1191 | - if ( ! is_numeric( $number ) ) { |
|
1191 | + if ( ! is_numeric($number)) { |
|
1192 | 1192 | return $number; |
1193 | 1193 | } |
1194 | 1194 | |
1195 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
1196 | - $number = absint( $number ); |
|
1197 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
1195 | + $prefix = give_get_option('sequential_prefix'); |
|
1196 | + $number = absint($number); |
|
1197 | + $postfix = give_get_option('sequential_postfix'); |
|
1198 | 1198 | |
1199 | - $formatted_number = $prefix . $number . $postfix; |
|
1199 | + $formatted_number = $prefix.$number.$postfix; |
|
1200 | 1200 | |
1201 | - return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix ); |
|
1201 | + return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix); |
|
1202 | 1202 | } |
1203 | 1203 | |
1204 | 1204 | /** |
@@ -1211,17 +1211,17 @@ discard block |
||
1211 | 1211 | */ |
1212 | 1212 | function give_get_next_payment_number() { |
1213 | 1213 | |
1214 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
1214 | + if ( ! give_get_option('enable_sequential')) { |
|
1215 | 1215 | return false; |
1216 | 1216 | } |
1217 | 1217 | |
1218 | - $number = get_option( 'give_last_payment_number' ); |
|
1219 | - $start = give_get_option( 'sequential_start', 1 ); |
|
1218 | + $number = get_option('give_last_payment_number'); |
|
1219 | + $start = give_get_option('sequential_start', 1); |
|
1220 | 1220 | $increment_number = true; |
1221 | 1221 | |
1222 | - if ( false !== $number ) { |
|
1222 | + if (false !== $number) { |
|
1223 | 1223 | |
1224 | - if ( empty( $number ) ) { |
|
1224 | + if (empty($number)) { |
|
1225 | 1225 | |
1226 | 1226 | $number = $start; |
1227 | 1227 | $increment_number = false; |
@@ -1230,24 +1230,24 @@ discard block |
||
1230 | 1230 | } else { |
1231 | 1231 | |
1232 | 1232 | // This case handles the first addition of the new option, as well as if it get's deleted for any reason. |
1233 | - $payments = new Give_Payments_Query( array( |
|
1233 | + $payments = new Give_Payments_Query(array( |
|
1234 | 1234 | 'number' => 1, |
1235 | 1235 | 'order' => 'DESC', |
1236 | 1236 | 'orderby' => 'ID', |
1237 | 1237 | 'output' => 'posts', |
1238 | 1238 | 'fields' => 'ids', |
1239 | - ) ); |
|
1239 | + )); |
|
1240 | 1240 | $last_payment = $payments->get_payments(); |
1241 | 1241 | |
1242 | - if ( ! empty( $last_payment ) ) { |
|
1242 | + if ( ! empty($last_payment)) { |
|
1243 | 1243 | |
1244 | - $number = give_get_payment_number( $last_payment[0] ); |
|
1244 | + $number = give_get_payment_number($last_payment[0]); |
|
1245 | 1245 | |
1246 | 1246 | } |
1247 | 1247 | |
1248 | - if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) { |
|
1248 | + if ( ! empty($number) && $number !== (int) $last_payment[0]) { |
|
1249 | 1249 | |
1250 | - $number = give_remove_payment_prefix_postfix( $number ); |
|
1250 | + $number = give_remove_payment_prefix_postfix($number); |
|
1251 | 1251 | |
1252 | 1252 | } else { |
1253 | 1253 | |
@@ -1256,13 +1256,13 @@ discard block |
||
1256 | 1256 | } |
1257 | 1257 | } |
1258 | 1258 | |
1259 | - $increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number ); |
|
1259 | + $increment_number = apply_filters('give_increment_payment_number', $increment_number, $number); |
|
1260 | 1260 | |
1261 | - if ( $increment_number ) { |
|
1262 | - $number ++; |
|
1261 | + if ($increment_number) { |
|
1262 | + $number++; |
|
1263 | 1263 | } |
1264 | 1264 | |
1265 | - return apply_filters( 'give_get_next_payment_number', $number ); |
|
1265 | + return apply_filters('give_get_next_payment_number', $number); |
|
1266 | 1266 | } |
1267 | 1267 | |
1268 | 1268 | /** |
@@ -1274,25 +1274,25 @@ discard block |
||
1274 | 1274 | * |
1275 | 1275 | * @return string The new Payment number without prefix and postfix. |
1276 | 1276 | */ |
1277 | -function give_remove_payment_prefix_postfix( $number ) { |
|
1277 | +function give_remove_payment_prefix_postfix($number) { |
|
1278 | 1278 | |
1279 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
1280 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
1279 | + $prefix = give_get_option('sequential_prefix'); |
|
1280 | + $postfix = give_get_option('sequential_postfix'); |
|
1281 | 1281 | |
1282 | 1282 | // Remove prefix. |
1283 | - $number = preg_replace( '/' . $prefix . '/', '', $number, 1 ); |
|
1283 | + $number = preg_replace('/'.$prefix.'/', '', $number, 1); |
|
1284 | 1284 | |
1285 | 1285 | // Remove the postfix. |
1286 | - $length = strlen( $number ); |
|
1287 | - $postfix_pos = strrpos( $number, $postfix ); |
|
1288 | - if ( false !== $postfix_pos ) { |
|
1289 | - $number = substr_replace( $number, '', $postfix_pos, $length ); |
|
1286 | + $length = strlen($number); |
|
1287 | + $postfix_pos = strrpos($number, $postfix); |
|
1288 | + if (false !== $postfix_pos) { |
|
1289 | + $number = substr_replace($number, '', $postfix_pos, $length); |
|
1290 | 1290 | } |
1291 | 1291 | |
1292 | 1292 | // Ensure it's a whole number. |
1293 | - $number = intval( $number ); |
|
1293 | + $number = intval($number); |
|
1294 | 1294 | |
1295 | - return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix ); |
|
1295 | + return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix); |
|
1296 | 1296 | |
1297 | 1297 | } |
1298 | 1298 | |
@@ -1309,10 +1309,10 @@ discard block |
||
1309 | 1309 | * |
1310 | 1310 | * @return string $amount Fully formatted payment amount. |
1311 | 1311 | */ |
1312 | -function give_payment_amount( $payment_id = 0 ) { |
|
1313 | - $amount = give_get_payment_amount( $payment_id ); |
|
1312 | +function give_payment_amount($payment_id = 0) { |
|
1313 | + $amount = give_get_payment_amount($payment_id); |
|
1314 | 1314 | |
1315 | - return give_currency_filter( give_format_amount( $amount ), give_get_payment_currency_code( $payment_id ) ); |
|
1315 | + return give_currency_filter(give_format_amount($amount), give_get_payment_currency_code($payment_id)); |
|
1316 | 1316 | } |
1317 | 1317 | |
1318 | 1318 | /** |
@@ -1325,11 +1325,11 @@ discard block |
||
1325 | 1325 | * |
1326 | 1326 | * @return mixed|void |
1327 | 1327 | */ |
1328 | -function give_get_payment_amount( $payment_id ) { |
|
1328 | +function give_get_payment_amount($payment_id) { |
|
1329 | 1329 | |
1330 | - $payment = new Give_Payment( $payment_id ); |
|
1330 | + $payment = new Give_Payment($payment_id); |
|
1331 | 1331 | |
1332 | - return apply_filters( 'give_payment_amount', floatval( $payment->total ), $payment_id ); |
|
1332 | + return apply_filters('give_payment_amount', floatval($payment->total), $payment_id); |
|
1333 | 1333 | } |
1334 | 1334 | |
1335 | 1335 | /** |
@@ -1346,10 +1346,10 @@ discard block |
||
1346 | 1346 | * |
1347 | 1347 | * @return array Fully formatted payment subtotal. |
1348 | 1348 | */ |
1349 | -function give_payment_subtotal( $payment_id = 0 ) { |
|
1350 | - $subtotal = give_get_payment_subtotal( $payment_id ); |
|
1349 | +function give_payment_subtotal($payment_id = 0) { |
|
1350 | + $subtotal = give_get_payment_subtotal($payment_id); |
|
1351 | 1351 | |
1352 | - return give_currency_filter( give_format_amount( $subtotal ), give_get_payment_currency_code( $payment_id ) ); |
|
1352 | + return give_currency_filter(give_format_amount($subtotal), give_get_payment_currency_code($payment_id)); |
|
1353 | 1353 | } |
1354 | 1354 | |
1355 | 1355 | /** |
@@ -1363,8 +1363,8 @@ discard block |
||
1363 | 1363 | * |
1364 | 1364 | * @return float $subtotal Subtotal for payment (non formatted). |
1365 | 1365 | */ |
1366 | -function give_get_payment_subtotal( $payment_id = 0 ) { |
|
1367 | - $payment = new G_Payment( $payment_id ); |
|
1366 | +function give_get_payment_subtotal($payment_id = 0) { |
|
1367 | + $payment = new G_Payment($payment_id); |
|
1368 | 1368 | |
1369 | 1369 | return $payment->subtotal; |
1370 | 1370 | } |
@@ -1379,10 +1379,10 @@ discard block |
||
1379 | 1379 | * |
1380 | 1380 | * @return mixed array if payment fees found, false otherwise. |
1381 | 1381 | */ |
1382 | -function give_get_payment_fees( $payment_id = 0, $type = 'all' ) { |
|
1383 | - $payment = new Give_Payment( $payment_id ); |
|
1382 | +function give_get_payment_fees($payment_id = 0, $type = 'all') { |
|
1383 | + $payment = new Give_Payment($payment_id); |
|
1384 | 1384 | |
1385 | - return $payment->get_fees( $type ); |
|
1385 | + return $payment->get_fees($type); |
|
1386 | 1386 | } |
1387 | 1387 | |
1388 | 1388 | /** |
@@ -1394,8 +1394,8 @@ discard block |
||
1394 | 1394 | * |
1395 | 1395 | * @return string The donation ID. |
1396 | 1396 | */ |
1397 | -function give_get_payment_transaction_id( $payment_id = 0 ) { |
|
1398 | - $payment = new Give_Payment( $payment_id ); |
|
1397 | +function give_get_payment_transaction_id($payment_id = 0) { |
|
1398 | + $payment = new Give_Payment($payment_id); |
|
1399 | 1399 | |
1400 | 1400 | return $payment->transaction_id; |
1401 | 1401 | } |
@@ -1410,15 +1410,15 @@ discard block |
||
1410 | 1410 | * |
1411 | 1411 | * @return bool|mixed |
1412 | 1412 | */ |
1413 | -function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) { |
|
1413 | +function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') { |
|
1414 | 1414 | |
1415 | - if ( empty( $payment_id ) || empty( $transaction_id ) ) { |
|
1415 | + if (empty($payment_id) || empty($transaction_id)) { |
|
1416 | 1416 | return false; |
1417 | 1417 | } |
1418 | 1418 | |
1419 | - $transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
1419 | + $transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id); |
|
1420 | 1420 | |
1421 | - return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id ); |
|
1421 | + return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id); |
|
1422 | 1422 | } |
1423 | 1423 | |
1424 | 1424 | /** |
@@ -1431,12 +1431,12 @@ discard block |
||
1431 | 1431 | * |
1432 | 1432 | * @return int $purchase Donation ID. |
1433 | 1433 | */ |
1434 | -function give_get_purchase_id_by_key( $key ) { |
|
1434 | +function give_get_purchase_id_by_key($key) { |
|
1435 | 1435 | global $wpdb; |
1436 | 1436 | |
1437 | - $purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
1437 | + $purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key)); |
|
1438 | 1438 | |
1439 | - if ( $purchase != null ) { |
|
1439 | + if ($purchase != null) { |
|
1440 | 1440 | return $purchase; |
1441 | 1441 | } |
1442 | 1442 | |
@@ -1454,12 +1454,12 @@ discard block |
||
1454 | 1454 | * |
1455 | 1455 | * @return int $purchase Donation ID. |
1456 | 1456 | */ |
1457 | -function give_get_purchase_id_by_transaction_id( $key ) { |
|
1457 | +function give_get_purchase_id_by_transaction_id($key) { |
|
1458 | 1458 | global $wpdb; |
1459 | 1459 | |
1460 | - $purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) ); |
|
1460 | + $purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key)); |
|
1461 | 1461 | |
1462 | - if ( $purchase != null ) { |
|
1462 | + if ($purchase != null) { |
|
1463 | 1463 | return $purchase; |
1464 | 1464 | } |
1465 | 1465 | |
@@ -1476,19 +1476,19 @@ discard block |
||
1476 | 1476 | * |
1477 | 1477 | * @return array $notes Donation Notes |
1478 | 1478 | */ |
1479 | -function give_get_payment_notes( $payment_id = 0, $search = '' ) { |
|
1479 | +function give_get_payment_notes($payment_id = 0, $search = '') { |
|
1480 | 1480 | |
1481 | - if ( empty( $payment_id ) && empty( $search ) ) { |
|
1481 | + if (empty($payment_id) && empty($search)) { |
|
1482 | 1482 | return false; |
1483 | 1483 | } |
1484 | 1484 | |
1485 | - remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1486 | - remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 ); |
|
1485 | + remove_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1486 | + remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10); |
|
1487 | 1487 | |
1488 | - $notes = get_comments( array( 'post_id' => $payment_id, 'order' => 'ASC', 'search' => $search ) ); |
|
1488 | + $notes = get_comments(array('post_id' => $payment_id, 'order' => 'ASC', 'search' => $search)); |
|
1489 | 1489 | |
1490 | - add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1491 | - add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
1490 | + add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1491 | + add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
1492 | 1492 | |
1493 | 1493 | return $notes; |
1494 | 1494 | } |
@@ -1504,8 +1504,8 @@ discard block |
||
1504 | 1504 | * |
1505 | 1505 | * @return int The new note ID |
1506 | 1506 | */ |
1507 | -function give_insert_payment_note( $payment_id = 0, $note = '' ) { |
|
1508 | - if ( empty( $payment_id ) ) { |
|
1507 | +function give_insert_payment_note($payment_id = 0, $note = '') { |
|
1508 | + if (empty($payment_id)) { |
|
1509 | 1509 | return false; |
1510 | 1510 | } |
1511 | 1511 | |
@@ -1517,14 +1517,14 @@ discard block |
||
1517 | 1517 | * @param int $payment_id Payment ID. |
1518 | 1518 | * @param string $note The note. |
1519 | 1519 | */ |
1520 | - do_action( 'give_pre_insert_payment_note', $payment_id, $note ); |
|
1520 | + do_action('give_pre_insert_payment_note', $payment_id, $note); |
|
1521 | 1521 | |
1522 | - $note_id = wp_insert_comment( wp_filter_comment( array( |
|
1522 | + $note_id = wp_insert_comment(wp_filter_comment(array( |
|
1523 | 1523 | 'comment_post_ID' => $payment_id, |
1524 | 1524 | 'comment_content' => $note, |
1525 | 1525 | 'user_id' => is_admin() ? get_current_user_id() : 0, |
1526 | - 'comment_date' => current_time( 'mysql' ), |
|
1527 | - 'comment_date_gmt' => current_time( 'mysql', 1 ), |
|
1526 | + 'comment_date' => current_time('mysql'), |
|
1527 | + 'comment_date_gmt' => current_time('mysql', 1), |
|
1528 | 1528 | 'comment_approved' => 1, |
1529 | 1529 | 'comment_parent' => 0, |
1530 | 1530 | 'comment_author' => '', |
@@ -1533,7 +1533,7 @@ discard block |
||
1533 | 1533 | 'comment_author_email' => '', |
1534 | 1534 | 'comment_type' => 'give_payment_note', |
1535 | 1535 | |
1536 | - ) ) ); |
|
1536 | + ))); |
|
1537 | 1537 | |
1538 | 1538 | /** |
1539 | 1539 | * Fires after payment note inserted. |
@@ -1544,7 +1544,7 @@ discard block |
||
1544 | 1544 | * @param int $payment_id Payment ID. |
1545 | 1545 | * @param string $note The note. |
1546 | 1546 | */ |
1547 | - do_action( 'give_insert_payment_note', $note_id, $payment_id, $note ); |
|
1547 | + do_action('give_insert_payment_note', $note_id, $payment_id, $note); |
|
1548 | 1548 | |
1549 | 1549 | return $note_id; |
1550 | 1550 | } |
@@ -1559,8 +1559,8 @@ discard block |
||
1559 | 1559 | * |
1560 | 1560 | * @return bool True on success, false otherwise. |
1561 | 1561 | */ |
1562 | -function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) { |
|
1563 | - if ( empty( $comment_id ) ) { |
|
1562 | +function give_delete_payment_note($comment_id = 0, $payment_id = 0) { |
|
1563 | + if (empty($comment_id)) { |
|
1564 | 1564 | return false; |
1565 | 1565 | } |
1566 | 1566 | |
@@ -1572,9 +1572,9 @@ discard block |
||
1572 | 1572 | * @param int $comment_id Note ID. |
1573 | 1573 | * @param int $payment_id Payment ID. |
1574 | 1574 | */ |
1575 | - do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id ); |
|
1575 | + do_action('give_pre_delete_payment_note', $comment_id, $payment_id); |
|
1576 | 1576 | |
1577 | - $ret = wp_delete_comment( $comment_id, true ); |
|
1577 | + $ret = wp_delete_comment($comment_id, true); |
|
1578 | 1578 | |
1579 | 1579 | /** |
1580 | 1580 | * Fires after donation note deleted. |
@@ -1584,7 +1584,7 @@ discard block |
||
1584 | 1584 | * @param int $comment_id Note ID. |
1585 | 1585 | * @param int $payment_id Payment ID. |
1586 | 1586 | */ |
1587 | - do_action( 'give_post_delete_payment_note', $comment_id, $payment_id ); |
|
1587 | + do_action('give_post_delete_payment_note', $comment_id, $payment_id); |
|
1588 | 1588 | |
1589 | 1589 | return $ret; |
1590 | 1590 | } |
@@ -1599,34 +1599,34 @@ discard block |
||
1599 | 1599 | * |
1600 | 1600 | * @return string |
1601 | 1601 | */ |
1602 | -function give_get_payment_note_html( $note, $payment_id = 0 ) { |
|
1602 | +function give_get_payment_note_html($note, $payment_id = 0) { |
|
1603 | 1603 | |
1604 | - if ( is_numeric( $note ) ) { |
|
1605 | - $note = get_comment( $note ); |
|
1604 | + if (is_numeric($note)) { |
|
1605 | + $note = get_comment($note); |
|
1606 | 1606 | } |
1607 | 1607 | |
1608 | - if ( ! empty( $note->user_id ) ) { |
|
1609 | - $user = get_userdata( $note->user_id ); |
|
1608 | + if ( ! empty($note->user_id)) { |
|
1609 | + $user = get_userdata($note->user_id); |
|
1610 | 1610 | $user = $user->display_name; |
1611 | 1611 | } else { |
1612 | - $user = esc_html__( 'System', 'give' ); |
|
1612 | + $user = esc_html__('System', 'give'); |
|
1613 | 1613 | } |
1614 | 1614 | |
1615 | - $date_format = give_date_format() . ', ' . get_option( 'time_format' ); |
|
1615 | + $date_format = give_date_format().', '.get_option('time_format'); |
|
1616 | 1616 | |
1617 | - $delete_note_url = wp_nonce_url( add_query_arg( array( |
|
1617 | + $delete_note_url = wp_nonce_url(add_query_arg(array( |
|
1618 | 1618 | 'give-action' => 'delete_payment_note', |
1619 | 1619 | 'note_id' => $note->comment_ID, |
1620 | 1620 | 'payment_id' => $payment_id, |
1621 | - ) ), |
|
1622 | - 'give_delete_payment_note_' . $note->comment_ID |
|
1621 | + )), |
|
1622 | + 'give_delete_payment_note_'.$note->comment_ID |
|
1623 | 1623 | ); |
1624 | 1624 | |
1625 | - $note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">'; |
|
1625 | + $note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">'; |
|
1626 | 1626 | $note_html .= '<p>'; |
1627 | - $note_html .= '<strong>' . $user . '</strong> – <span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>'; |
|
1627 | + $note_html .= '<strong>'.$user.'</strong> – <span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>'; |
|
1628 | 1628 | $note_html .= $note->comment_content; |
1629 | - $note_html .= ' – <a href="' . esc_url( $delete_note_url ) . '" class="give-delete-payment-note" data-note-id="' . absint( $note->comment_ID ) . '" data-payment-id="' . absint( $payment_id ) . '" aria-label="' . esc_attr__( 'Delete this donation note.', 'give' ) . '">' . esc_html__( 'Delete', 'give' ) . '</a>'; |
|
1629 | + $note_html .= ' – <a href="'.esc_url($delete_note_url).'" class="give-delete-payment-note" data-note-id="'.absint($note->comment_ID).'" data-payment-id="'.absint($payment_id).'" aria-label="'.esc_attr__('Delete this donation note.', 'give').'">'.esc_html__('Delete', 'give').'</a>'; |
|
1630 | 1630 | $note_html .= '</p>'; |
1631 | 1631 | $note_html .= '</div>'; |
1632 | 1632 | |
@@ -1644,18 +1644,18 @@ discard block |
||
1644 | 1644 | * |
1645 | 1645 | * @return void |
1646 | 1646 | */ |
1647 | -function give_hide_payment_notes( $query ) { |
|
1648 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) { |
|
1649 | - $types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array(); |
|
1650 | - if ( ! is_array( $types ) ) { |
|
1651 | - $types = array( $types ); |
|
1647 | +function give_hide_payment_notes($query) { |
|
1648 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) { |
|
1649 | + $types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array(); |
|
1650 | + if ( ! is_array($types)) { |
|
1651 | + $types = array($types); |
|
1652 | 1652 | } |
1653 | 1653 | $types[] = 'give_payment_note'; |
1654 | 1654 | $query->query_vars['type__not_in'] = $types; |
1655 | 1655 | } |
1656 | 1656 | } |
1657 | 1657 | |
1658 | -add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1658 | +add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1659 | 1659 | |
1660 | 1660 | /** |
1661 | 1661 | * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets |
@@ -1667,15 +1667,15 @@ discard block |
||
1667 | 1667 | * |
1668 | 1668 | * @return array $clauses Updated comment clauses. |
1669 | 1669 | */ |
1670 | -function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) { |
|
1671 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) { |
|
1670 | +function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) { |
|
1671 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) { |
|
1672 | 1672 | $clauses['where'] .= ' AND comment_type != "give_payment_note"'; |
1673 | 1673 | } |
1674 | 1674 | |
1675 | 1675 | return $clauses; |
1676 | 1676 | } |
1677 | 1677 | |
1678 | -add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
1678 | +add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
1679 | 1679 | |
1680 | 1680 | |
1681 | 1681 | /** |
@@ -1688,15 +1688,15 @@ discard block |
||
1688 | 1688 | * |
1689 | 1689 | * @return string $where |
1690 | 1690 | */ |
1691 | -function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) { |
|
1691 | +function give_hide_payment_notes_from_feeds($where, $wp_comment_query) { |
|
1692 | 1692 | global $wpdb; |
1693 | 1693 | |
1694 | - $where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' ); |
|
1694 | + $where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note'); |
|
1695 | 1695 | |
1696 | 1696 | return $where; |
1697 | 1697 | } |
1698 | 1698 | |
1699 | -add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 ); |
|
1699 | +add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2); |
|
1700 | 1700 | |
1701 | 1701 | |
1702 | 1702 | /** |
@@ -1710,32 +1710,32 @@ discard block |
||
1710 | 1710 | * |
1711 | 1711 | * @return array Array of comment counts. |
1712 | 1712 | */ |
1713 | -function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) { |
|
1713 | +function give_remove_payment_notes_in_comment_counts($stats, $post_id) { |
|
1714 | 1714 | global $wpdb, $pagenow; |
1715 | 1715 | |
1716 | - if ( 'index.php' != $pagenow ) { |
|
1716 | + if ('index.php' != $pagenow) { |
|
1717 | 1717 | return $stats; |
1718 | 1718 | } |
1719 | 1719 | |
1720 | 1720 | $post_id = (int) $post_id; |
1721 | 1721 | |
1722 | - if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) { |
|
1722 | + if (apply_filters('give_count_payment_notes_in_comments', false)) { |
|
1723 | 1723 | return $stats; |
1724 | 1724 | } |
1725 | 1725 | |
1726 | - $stats = wp_cache_get( "comments-{$post_id}", 'counts' ); |
|
1726 | + $stats = wp_cache_get("comments-{$post_id}", 'counts'); |
|
1727 | 1727 | |
1728 | - if ( false !== $stats ) { |
|
1728 | + if (false !== $stats) { |
|
1729 | 1729 | return $stats; |
1730 | 1730 | } |
1731 | 1731 | |
1732 | 1732 | $where = 'WHERE comment_type != "give_payment_note"'; |
1733 | 1733 | |
1734 | - if ( $post_id > 0 ) { |
|
1735 | - $where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id ); |
|
1734 | + if ($post_id > 0) { |
|
1735 | + $where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id); |
|
1736 | 1736 | } |
1737 | 1737 | |
1738 | - $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
|
1738 | + $count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A); |
|
1739 | 1739 | |
1740 | 1740 | $total = 0; |
1741 | 1741 | $approved = array( |
@@ -1745,30 +1745,30 @@ discard block |
||
1745 | 1745 | 'trash' => 'trash', |
1746 | 1746 | 'post-trashed' => 'post-trashed', |
1747 | 1747 | ); |
1748 | - foreach ( (array) $count as $row ) { |
|
1748 | + foreach ((array) $count as $row) { |
|
1749 | 1749 | // Don't count post-trashed toward totals. |
1750 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) { |
|
1750 | + if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) { |
|
1751 | 1751 | $total += $row['num_comments']; |
1752 | 1752 | } |
1753 | - if ( isset( $approved[ $row['comment_approved'] ] ) ) { |
|
1754 | - $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments']; |
|
1753 | + if (isset($approved[$row['comment_approved']])) { |
|
1754 | + $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
1755 | 1755 | } |
1756 | 1756 | } |
1757 | 1757 | |
1758 | 1758 | $stats['total_comments'] = $total; |
1759 | - foreach ( $approved as $key ) { |
|
1760 | - if ( empty( $stats[ $key ] ) ) { |
|
1761 | - $stats[ $key ] = 0; |
|
1759 | + foreach ($approved as $key) { |
|
1760 | + if (empty($stats[$key])) { |
|
1761 | + $stats[$key] = 0; |
|
1762 | 1762 | } |
1763 | 1763 | } |
1764 | 1764 | |
1765 | 1765 | $stats = (object) $stats; |
1766 | - wp_cache_set( "comments-{$post_id}", $stats, 'counts' ); |
|
1766 | + wp_cache_set("comments-{$post_id}", $stats, 'counts'); |
|
1767 | 1767 | |
1768 | 1768 | return $stats; |
1769 | 1769 | } |
1770 | 1770 | |
1771 | -add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 ); |
|
1771 | +add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2); |
|
1772 | 1772 | |
1773 | 1773 | |
1774 | 1774 | /** |
@@ -1781,9 +1781,9 @@ discard block |
||
1781 | 1781 | * |
1782 | 1782 | * @return string $where Modified where clause. |
1783 | 1783 | */ |
1784 | -function give_filter_where_older_than_week( $where = '' ) { |
|
1784 | +function give_filter_where_older_than_week($where = '') { |
|
1785 | 1785 | // Payments older than one week. |
1786 | - $start = date( 'Y-m-d', strtotime( '-7 days' ) ); |
|
1786 | + $start = date('Y-m-d', strtotime('-7 days')); |
|
1787 | 1787 | $where .= " AND post_date <= '{$start}'"; |
1788 | 1788 | |
1789 | 1789 | return $where; |
@@ -1803,38 +1803,38 @@ discard block |
||
1803 | 1803 | * |
1804 | 1804 | * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title. |
1805 | 1805 | */ |
1806 | -function give_get_payment_form_title( $payment_meta, $only_level = false, $separator = '' ) { |
|
1806 | +function give_get_payment_form_title($payment_meta, $only_level = false, $separator = '') { |
|
1807 | 1807 | |
1808 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0; |
|
1809 | - $price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null; |
|
1810 | - $form_title = isset( $payment_meta['form_title'] ) ? $payment_meta['form_title'] : ''; |
|
1808 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0; |
|
1809 | + $price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null; |
|
1810 | + $form_title = isset($payment_meta['form_title']) ? $payment_meta['form_title'] : ''; |
|
1811 | 1811 | |
1812 | - if ( $only_level == true ) { |
|
1812 | + if ($only_level == true) { |
|
1813 | 1813 | $form_title = ''; |
1814 | 1814 | } |
1815 | 1815 | |
1816 | 1816 | //If multi-level, append to the form title. |
1817 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1817 | + if (give_has_variable_prices($form_id)) { |
|
1818 | 1818 | |
1819 | 1819 | //Only add separator if there is a form title. |
1820 | - if ( ! empty( $form_title ) ) { |
|
1821 | - $form_title .= ' ' . $separator . ' '; |
|
1820 | + if ( ! empty($form_title)) { |
|
1821 | + $form_title .= ' '.$separator.' '; |
|
1822 | 1822 | } |
1823 | 1823 | |
1824 | 1824 | $form_title .= '<span class="donation-level-text-wrap">'; |
1825 | 1825 | |
1826 | - if ( $price_id == 'custom' ) { |
|
1827 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
1828 | - $form_title .= ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' ); |
|
1826 | + if ($price_id == 'custom') { |
|
1827 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
1828 | + $form_title .= ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give'); |
|
1829 | 1829 | } else { |
1830 | - $form_title .= give_get_price_option_name( $form_id, $price_id ); |
|
1830 | + $form_title .= give_get_price_option_name($form_id, $price_id); |
|
1831 | 1831 | } |
1832 | 1832 | |
1833 | 1833 | $form_title .= '</span>'; |
1834 | 1834 | |
1835 | 1835 | } |
1836 | 1836 | |
1837 | - return apply_filters( 'give_get_payment_form_title', $form_title, $payment_meta ); |
|
1837 | + return apply_filters('give_get_payment_form_title', $form_title, $payment_meta); |
|
1838 | 1838 | |
1839 | 1839 | } |
1840 | 1840 | |
@@ -1848,20 +1848,20 @@ discard block |
||
1848 | 1848 | * |
1849 | 1849 | * @return string $price_id |
1850 | 1850 | */ |
1851 | -function give_get_price_id( $form_id, $price ) { |
|
1851 | +function give_get_price_id($form_id, $price) { |
|
1852 | 1852 | |
1853 | 1853 | $price_id = 0; |
1854 | 1854 | |
1855 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1855 | + if (give_has_variable_prices($form_id)) { |
|
1856 | 1856 | |
1857 | - $levels = maybe_unserialize( give_get_meta( $form_id, '_give_donation_levels', true ) ); |
|
1857 | + $levels = maybe_unserialize(give_get_meta($form_id, '_give_donation_levels', true)); |
|
1858 | 1858 | |
1859 | - foreach ( $levels as $level ) { |
|
1859 | + foreach ($levels as $level) { |
|
1860 | 1860 | |
1861 | - $level_amount = (float) give_sanitize_amount( $level['_give_amount'] ); |
|
1861 | + $level_amount = (float) give_sanitize_amount($level['_give_amount']); |
|
1862 | 1862 | |
1863 | 1863 | // Check that this indeed the recurring price. |
1864 | - if ( $level_amount == $price ) { |
|
1864 | + if ($level_amount == $price) { |
|
1865 | 1865 | |
1866 | 1866 | $price_id = $level['_give_id']['level_id']; |
1867 | 1867 | |
@@ -1886,10 +1886,10 @@ discard block |
||
1886 | 1886 | * |
1887 | 1887 | * @return string |
1888 | 1888 | */ |
1889 | -function give_get_form_dropdown( $args = array(), $echo = false ) { |
|
1890 | - $form_dropdown_html = Give()->html->forms_dropdown( $args ); |
|
1889 | +function give_get_form_dropdown($args = array(), $echo = false) { |
|
1890 | + $form_dropdown_html = Give()->html->forms_dropdown($args); |
|
1891 | 1891 | |
1892 | - if ( ! $echo ) { |
|
1892 | + if ( ! $echo) { |
|
1893 | 1893 | return $form_dropdown_html; |
1894 | 1894 | } |
1895 | 1895 | |
@@ -1906,17 +1906,17 @@ discard block |
||
1906 | 1906 | * |
1907 | 1907 | * @return string|bool |
1908 | 1908 | */ |
1909 | -function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) { |
|
1909 | +function give_get_form_variable_price_dropdown($args = array(), $echo = false) { |
|
1910 | 1910 | |
1911 | 1911 | // Check for give form id. |
1912 | - if ( empty( $args['id'] ) ) { |
|
1912 | + if (empty($args['id'])) { |
|
1913 | 1913 | return false; |
1914 | 1914 | } |
1915 | 1915 | |
1916 | - $form = new Give_Donate_Form( $args['id'] ); |
|
1916 | + $form = new Give_Donate_Form($args['id']); |
|
1917 | 1917 | |
1918 | 1918 | // Check if form has variable prices or not. |
1919 | - if ( ! $form->ID || ! $form->has_variable_prices() ) { |
|
1919 | + if ( ! $form->ID || ! $form->has_variable_prices()) { |
|
1920 | 1920 | return false; |
1921 | 1921 | } |
1922 | 1922 | |
@@ -1924,22 +1924,22 @@ discard block |
||
1924 | 1924 | $variable_price_options = array(); |
1925 | 1925 | |
1926 | 1926 | // Check if multi donation form support custom donation or not. |
1927 | - if ( $form->is_custom_price_mode() ) { |
|
1928 | - $variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' ); |
|
1927 | + if ($form->is_custom_price_mode()) { |
|
1928 | + $variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give'); |
|
1929 | 1929 | } |
1930 | 1930 | |
1931 | 1931 | // Get variable price and ID from variable price array. |
1932 | - foreach ( $variable_prices as $variable_price ) { |
|
1933 | - $variable_price_options[ $variable_price['_give_id']['level_id'] ] = ! empty( $variable_price['_give_text'] ) ? $variable_price['_give_text'] : give_currency_filter( give_format_amount( $variable_price['_give_amount'] ) ); |
|
1932 | + foreach ($variable_prices as $variable_price) { |
|
1933 | + $variable_price_options[$variable_price['_give_id']['level_id']] = ! empty($variable_price['_give_text']) ? $variable_price['_give_text'] : give_currency_filter(give_format_amount($variable_price['_give_amount'])); |
|
1934 | 1934 | } |
1935 | 1935 | |
1936 | 1936 | // Update options. |
1937 | - $args = array_merge( $args, array( 'options' => $variable_price_options ) ); |
|
1937 | + $args = array_merge($args, array('options' => $variable_price_options)); |
|
1938 | 1938 | |
1939 | 1939 | // Generate select html. |
1940 | - $form_dropdown_html = Give()->html->select( $args ); |
|
1940 | + $form_dropdown_html = Give()->html->select($args); |
|
1941 | 1941 | |
1942 | - if ( ! $echo ) { |
|
1942 | + if ( ! $echo) { |
|
1943 | 1943 | return $form_dropdown_html; |
1944 | 1944 | } |
1945 | 1945 | |
@@ -1958,16 +1958,16 @@ discard block |
||
1958 | 1958 | * |
1959 | 1959 | * @return string |
1960 | 1960 | */ |
1961 | -function give_get_payment_meta_price_id( $payment_meta ) { |
|
1961 | +function give_get_payment_meta_price_id($payment_meta) { |
|
1962 | 1962 | |
1963 | - if ( isset( $payment_meta['give_price_id'] ) ) { |
|
1963 | + if (isset($payment_meta['give_price_id'])) { |
|
1964 | 1964 | $price_id = $payment_meta['give_price_id']; |
1965 | - } elseif ( isset( $payment_meta['price_id'] ) ) { |
|
1965 | + } elseif (isset($payment_meta['price_id'])) { |
|
1966 | 1966 | $price_id = $payment_meta['price_id']; |
1967 | 1967 | } else { |
1968 | - $price_id = give_get_price_id( $payment_meta['give_form_id'], $payment_meta['price'] ); |
|
1968 | + $price_id = give_get_price_id($payment_meta['give_form_id'], $payment_meta['price']); |
|
1969 | 1969 | } |
1970 | 1970 | |
1971 | - return apply_filters( 'give_get_payment_meta_price_id', $price_id ); |
|
1971 | + return apply_filters('give_get_payment_meta_price_id', $price_id); |
|
1972 | 1972 | |
1973 | 1973 | } |
1974 | 1974 | \ 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 | |
@@ -74,57 +74,57 @@ discard block |
||
74 | 74 | public function __construct() { |
75 | 75 | |
76 | 76 | $this->use_php_sessions = $this->use_php_sessions(); |
77 | - $this->exp_option = give_get_option( 'session_lifetime' ); |
|
77 | + $this->exp_option = give_get_option('session_lifetime'); |
|
78 | 78 | |
79 | 79 | // PHP Sessions. |
80 | - if ( $this->use_php_sessions ) { |
|
80 | + if ($this->use_php_sessions) { |
|
81 | 81 | |
82 | - if ( is_multisite() ) { |
|
82 | + if (is_multisite()) { |
|
83 | 83 | |
84 | - $this->prefix = '_' . get_current_blog_id(); |
|
84 | + $this->prefix = '_'.get_current_blog_id(); |
|
85 | 85 | |
86 | 86 | } |
87 | 87 | |
88 | - add_action( 'init', array( $this, 'maybe_start_session' ), - 2 ); |
|
88 | + add_action('init', array($this, 'maybe_start_session'), - 2); |
|
89 | 89 | |
90 | 90 | } else { |
91 | 91 | |
92 | - if ( ! $this->should_start_session() ) { |
|
92 | + if ( ! $this->should_start_session()) { |
|
93 | 93 | return; |
94 | 94 | } |
95 | 95 | |
96 | 96 | // Use WP_Session. |
97 | - if ( ! defined( 'WP_SESSION_COOKIE' ) ) { |
|
98 | - define( 'WP_SESSION_COOKIE', 'give_wp_session' ); |
|
97 | + if ( ! defined('WP_SESSION_COOKIE')) { |
|
98 | + define('WP_SESSION_COOKIE', 'give_wp_session'); |
|
99 | 99 | } |
100 | 100 | |
101 | - if ( ! class_exists( 'Recursive_ArrayAccess' ) ) { |
|
102 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-recursive-arrayaccess.php'; |
|
101 | + if ( ! class_exists('Recursive_ArrayAccess')) { |
|
102 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-recursive-arrayaccess.php'; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | // Include utilities class |
106 | - if ( ! class_exists( 'WP_Session_Utils' ) ) { |
|
107 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session-utils.php'; |
|
106 | + if ( ! class_exists('WP_Session_Utils')) { |
|
107 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session-utils.php'; |
|
108 | 108 | } |
109 | - if ( ! class_exists( 'WP_Session' ) ) { |
|
110 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session.php'; |
|
111 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/wp-session.php'; |
|
109 | + if ( ! class_exists('WP_Session')) { |
|
110 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session.php'; |
|
111 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/wp-session.php'; |
|
112 | 112 | } |
113 | 113 | |
114 | - add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 ); |
|
115 | - add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 ); |
|
114 | + add_filter('wp_session_expiration_variant', array($this, 'set_expiration_variant_time'), 99999); |
|
115 | + add_filter('wp_session_expiration', array($this, 'set_expiration_time'), 99999); |
|
116 | 116 | |
117 | 117 | } |
118 | 118 | |
119 | 119 | // Init Session. |
120 | - if ( empty( $this->session ) && ! $this->use_php_sessions ) { |
|
121 | - add_action( 'plugins_loaded', array( $this, 'init' ), - 1 ); |
|
120 | + if (empty($this->session) && ! $this->use_php_sessions) { |
|
121 | + add_action('plugins_loaded', array($this, 'init'), - 1); |
|
122 | 122 | } else { |
123 | - add_action( 'init', array( $this, 'init' ), - 1 ); |
|
123 | + add_action('init', array($this, 'init'), - 1); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | // Set cookie on Donation Completion page. |
127 | - add_action( 'give_pre_process_donation', array( $this, 'set_session_cookies' ) ); |
|
127 | + add_action('give_pre_process_donation', array($this, 'set_session_cookies')); |
|
128 | 128 | |
129 | 129 | } |
130 | 130 | |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | */ |
141 | 141 | public function init() { |
142 | 142 | |
143 | - if ( $this->use_php_sessions ) { |
|
144 | - $this->session = isset( $_SESSION[ 'give' . $this->prefix ] ) && is_array( $_SESSION[ 'give' . $this->prefix ] ) ? $_SESSION[ 'give' . $this->prefix ] : array(); |
|
143 | + if ($this->use_php_sessions) { |
|
144 | + $this->session = isset($_SESSION['give'.$this->prefix]) && is_array($_SESSION['give'.$this->prefix]) ? $_SESSION['give'.$this->prefix] : array(); |
|
145 | 145 | } else { |
146 | 146 | $this->session = WP_Session::get_instance(); |
147 | 147 | } |
@@ -176,10 +176,10 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @return string Session variable. |
178 | 178 | */ |
179 | - public function get( $key ) { |
|
180 | - $key = sanitize_key( $key ); |
|
179 | + public function get($key) { |
|
180 | + $key = sanitize_key($key); |
|
181 | 181 | |
182 | - return isset( $this->session[ $key ] ) ? maybe_unserialize( $this->session[ $key ] ) : false; |
|
182 | + return isset($this->session[$key]) ? maybe_unserialize($this->session[$key]) : false; |
|
183 | 183 | |
184 | 184 | } |
185 | 185 | |
@@ -196,21 +196,21 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @return string Session variable. |
198 | 198 | */ |
199 | - public function set( $key, $value ) { |
|
199 | + public function set($key, $value) { |
|
200 | 200 | |
201 | - $key = sanitize_key( $key ); |
|
201 | + $key = sanitize_key($key); |
|
202 | 202 | |
203 | - if ( is_array( $value ) ) { |
|
204 | - $this->session[ $key ] = serialize( $value ); |
|
203 | + if (is_array($value)) { |
|
204 | + $this->session[$key] = serialize($value); |
|
205 | 205 | } else { |
206 | - $this->session[ $key ] = $value; |
|
206 | + $this->session[$key] = $value; |
|
207 | 207 | } |
208 | 208 | |
209 | - if ( $this->use_php_sessions ) { |
|
210 | - $_SESSION[ 'give' . $this->prefix ] = $this->session; |
|
209 | + if ($this->use_php_sessions) { |
|
210 | + $_SESSION['give'.$this->prefix] = $this->session; |
|
211 | 211 | } |
212 | 212 | |
213 | - return $this->session[ $key ]; |
|
213 | + return $this->session[$key]; |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | /** |
@@ -224,10 +224,10 @@ discard block |
||
224 | 224 | * @hook |
225 | 225 | */ |
226 | 226 | public function set_session_cookies() { |
227 | - if ( ! headers_sent() ) { |
|
228 | - $lifetime = current_time( 'timestamp' ) + $this->set_expiration_time(); |
|
229 | - @setcookie( session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
230 | - @setcookie( session_name() . '_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
227 | + if ( ! headers_sent()) { |
|
228 | + $lifetime = current_time('timestamp') + $this->set_expiration_time(); |
|
229 | + @setcookie(session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
230 | + @setcookie(session_name().'_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
231 | 231 | } |
232 | 232 | } |
233 | 233 | |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | */ |
244 | 244 | public function set_expiration_variant_time() { |
245 | 245 | |
246 | - return ( ! empty( $this->exp_option ) ? ( intval( $this->exp_option ) - 3600 ) : 30 * 60 * 23 ); |
|
246 | + return ( ! empty($this->exp_option) ? (intval($this->exp_option) - 3600) : 30 * 60 * 23); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | */ |
259 | 259 | public function set_expiration_time() { |
260 | 260 | |
261 | - return ( ! empty( $this->exp_option ) ? intval( $this->exp_option ) : 30 * 60 * 24 ); |
|
261 | + return ( ! empty($this->exp_option) ? intval($this->exp_option) : 30 * 60 * 24); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
@@ -276,21 +276,21 @@ discard block |
||
276 | 276 | $ret = false; |
277 | 277 | |
278 | 278 | // If the database variable is already set, no need to run auto detection. |
279 | - $give_use_php_sessions = (bool) get_option( 'give_use_php_sessions' ); |
|
279 | + $give_use_php_sessions = (bool) get_option('give_use_php_sessions'); |
|
280 | 280 | |
281 | - if ( ! $give_use_php_sessions ) { |
|
281 | + if ( ! $give_use_php_sessions) { |
|
282 | 282 | |
283 | 283 | // Attempt to detect if the server supports PHP sessions. |
284 | - if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) { |
|
284 | + if (function_exists('session_start') && ! ini_get('safe_mode')) { |
|
285 | 285 | |
286 | - $this->set( 'give_use_php_sessions', 1 ); |
|
286 | + $this->set('give_use_php_sessions', 1); |
|
287 | 287 | |
288 | - if ( $this->get( 'give_use_php_sessions' ) ) { |
|
288 | + if ($this->get('give_use_php_sessions')) { |
|
289 | 289 | |
290 | 290 | $ret = true; |
291 | 291 | |
292 | 292 | // Set the database option. |
293 | - update_option( 'give_use_php_sessions', true ); |
|
293 | + update_option('give_use_php_sessions', true); |
|
294 | 294 | |
295 | 295 | } |
296 | 296 | } |
@@ -300,13 +300,13 @@ discard block |
||
300 | 300 | } |
301 | 301 | |
302 | 302 | // Enable or disable PHP Sessions based on the GIVE_USE_PHP_SESSIONS constant. |
303 | - if ( defined( 'GIVE_USE_PHP_SESSIONS' ) && GIVE_USE_PHP_SESSIONS ) { |
|
303 | + if (defined('GIVE_USE_PHP_SESSIONS') && GIVE_USE_PHP_SESSIONS) { |
|
304 | 304 | $ret = true; |
305 | - } elseif ( defined( 'GIVE_USE_PHP_SESSIONS' ) && ! GIVE_USE_PHP_SESSIONS ) { |
|
305 | + } elseif (defined('GIVE_USE_PHP_SESSIONS') && ! GIVE_USE_PHP_SESSIONS) { |
|
306 | 306 | $ret = false; |
307 | 307 | } |
308 | 308 | |
309 | - return (bool) apply_filters( 'give_use_php_sessions', $ret ); |
|
309 | + return (bool) apply_filters('give_use_php_sessions', $ret); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | /** |
@@ -323,9 +323,9 @@ discard block |
||
323 | 323 | |
324 | 324 | $start_session = true; |
325 | 325 | |
326 | - if ( ! empty( $_SERVER['REQUEST_URI'] ) ) { |
|
326 | + if ( ! empty($_SERVER['REQUEST_URI'])) { |
|
327 | 327 | |
328 | - $blacklist = apply_filters( 'give_session_start_uri_blacklist', array( |
|
328 | + $blacklist = apply_filters('give_session_start_uri_blacklist', array( |
|
329 | 329 | 'feed', |
330 | 330 | 'feed', |
331 | 331 | 'feed/rss', |
@@ -333,21 +333,21 @@ discard block |
||
333 | 333 | 'feed/rdf', |
334 | 334 | 'feed/atom', |
335 | 335 | 'comments/feed/', |
336 | - ) ); |
|
337 | - $uri = ltrim( $_SERVER['REQUEST_URI'], '/' ); |
|
338 | - $uri = untrailingslashit( $uri ); |
|
339 | - if ( in_array( $uri, $blacklist ) ) { |
|
336 | + )); |
|
337 | + $uri = ltrim($_SERVER['REQUEST_URI'], '/'); |
|
338 | + $uri = untrailingslashit($uri); |
|
339 | + if (in_array($uri, $blacklist)) { |
|
340 | 340 | $start_session = false; |
341 | 341 | } |
342 | - if ( false !== strpos( $uri, 'feed=' ) ) { |
|
342 | + if (false !== strpos($uri, 'feed=')) { |
|
343 | 343 | $start_session = false; |
344 | 344 | } |
345 | - if ( is_admin() ) { |
|
345 | + if (is_admin()) { |
|
346 | 346 | $start_session = false; |
347 | 347 | } |
348 | 348 | } |
349 | 349 | |
350 | - return apply_filters( 'give_start_session', $start_session ); |
|
350 | + return apply_filters('give_start_session', $start_session); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | /** |
@@ -363,11 +363,11 @@ discard block |
||
363 | 363 | */ |
364 | 364 | public function maybe_start_session() { |
365 | 365 | |
366 | - if ( ! $this->should_start_session() ) { |
|
366 | + if ( ! $this->should_start_session()) { |
|
367 | 367 | return; |
368 | 368 | } |
369 | 369 | |
370 | - if ( ! session_id() && ! headers_sent() ) { |
|
370 | + if ( ! session_id() && ! headers_sent()) { |
|
371 | 371 | session_start(); |
372 | 372 | } |
373 | 373 | |
@@ -386,9 +386,9 @@ discard block |
||
386 | 386 | |
387 | 387 | $expiration = false; |
388 | 388 | |
389 | - if ( session_id() && isset( $_COOKIE[ session_name() . '_expiration' ] ) ) { |
|
389 | + if (session_id() && isset($_COOKIE[session_name().'_expiration'])) { |
|
390 | 390 | |
391 | - $expiration = date( 'D, d M Y h:i:s', intval( $_COOKIE[ session_name() . '_expiration' ] ) ); |
|
391 | + $expiration = date('D, d M Y h:i:s', intval($_COOKIE[session_name().'_expiration'])); |
|
392 | 392 | |
393 | 393 | } |
394 | 394 |
@@ -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,19 +23,19 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return array An array of updated action links. |
25 | 25 | */ |
26 | -function give_plugin_action_links( $actions ) { |
|
26 | +function give_plugin_action_links($actions) { |
|
27 | 27 | $new_actions = array( |
28 | 28 | 'settings' => sprintf( |
29 | 29 | '<a href="%1$s">%2$s</a>', |
30 | - admin_url( 'edit.php?post_type=give_forms&page=give-settings' ), |
|
31 | - __( 'Settings', 'give' ) |
|
30 | + admin_url('edit.php?post_type=give_forms&page=give-settings'), |
|
31 | + __('Settings', 'give') |
|
32 | 32 | ), |
33 | 33 | ); |
34 | 34 | |
35 | - return array_merge( $new_actions, $actions ); |
|
35 | + return array_merge($new_actions, $actions); |
|
36 | 36 | } |
37 | 37 | |
38 | -add_filter( 'plugin_action_links_' . GIVE_PLUGIN_BASENAME, 'give_plugin_action_links' ); |
|
38 | +add_filter('plugin_action_links_'.GIVE_PLUGIN_BASENAME, 'give_plugin_action_links'); |
|
39 | 39 | |
40 | 40 | |
41 | 41 | /** |
@@ -48,35 +48,35 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return array |
50 | 50 | */ |
51 | -function give_plugin_row_meta( $plugin_meta, $plugin_file ) { |
|
52 | - if ( $plugin_file != GIVE_PLUGIN_BASENAME ) { |
|
51 | +function give_plugin_row_meta($plugin_meta, $plugin_file) { |
|
52 | + if ($plugin_file != GIVE_PLUGIN_BASENAME) { |
|
53 | 53 | return $plugin_meta; |
54 | 54 | } |
55 | 55 | |
56 | 56 | $new_meta_links = array( |
57 | 57 | sprintf( |
58 | 58 | '<a href="%1$s" target="_blank">%2$s</a>', |
59 | - esc_url( add_query_arg( array( |
|
59 | + esc_url(add_query_arg(array( |
|
60 | 60 | 'utm_source' => 'plugins-page', |
61 | 61 | 'utm_medium' => 'plugin-row', |
62 | 62 | 'utm_campaign' => 'admin', |
63 | - ), 'https://givewp.com/documentation/' ) |
|
63 | + ), 'https://givewp.com/documentation/') |
|
64 | 64 | ), |
65 | - __( 'Documentation', 'give' ) |
|
65 | + __('Documentation', 'give') |
|
66 | 66 | ), |
67 | 67 | sprintf( |
68 | 68 | '<a href="%1$s" target="_blank">%2$s</a>', |
69 | - esc_url( add_query_arg( array( |
|
69 | + esc_url(add_query_arg(array( |
|
70 | 70 | 'utm_source' => 'plugins-page', |
71 | 71 | 'utm_medium' => 'plugin-row', |
72 | 72 | 'utm_campaign' => 'admin', |
73 | - ), 'https://givewp.com/addons/' ) |
|
73 | + ), 'https://givewp.com/addons/') |
|
74 | 74 | ), |
75 | - __( 'Add-ons', 'give' ) |
|
75 | + __('Add-ons', 'give') |
|
76 | 76 | ), |
77 | 77 | ); |
78 | 78 | |
79 | - return array_merge( $plugin_meta, $new_meta_links ); |
|
79 | + return array_merge($plugin_meta, $new_meta_links); |
|
80 | 80 | } |
81 | 81 | |
82 | -add_filter( 'plugin_row_meta', 'give_plugin_row_meta', 10, 2 ); |
|
82 | +add_filter('plugin_row_meta', 'give_plugin_row_meta', 10, 2); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -30,36 +30,36 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return bool|object List of all user donations |
32 | 32 | */ |
33 | -function give_get_users_purchases( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) { |
|
33 | +function give_get_users_purchases($user = 0, $number = 20, $pagination = false, $status = 'complete') { |
|
34 | 34 | |
35 | - if ( empty( $user ) ) { |
|
35 | + if (empty($user)) { |
|
36 | 36 | $user = get_current_user_id(); |
37 | 37 | } |
38 | 38 | |
39 | - if ( 0 === $user && ! Give()->email_access->token_exists ) { |
|
39 | + if (0 === $user && ! Give()->email_access->token_exists) { |
|
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | |
43 | 43 | $status = $status === 'complete' ? 'publish' : $status; |
44 | 44 | |
45 | - if ( $pagination ) { |
|
46 | - if ( get_query_var( 'paged' ) ) { |
|
47 | - $paged = get_query_var( 'paged' ); |
|
48 | - } elseif ( get_query_var( 'page' ) ) { |
|
49 | - $paged = get_query_var( 'page' ); |
|
45 | + if ($pagination) { |
|
46 | + if (get_query_var('paged')) { |
|
47 | + $paged = get_query_var('paged'); |
|
48 | + } elseif (get_query_var('page')) { |
|
49 | + $paged = get_query_var('page'); |
|
50 | 50 | } else { |
51 | 51 | $paged = 1; |
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | - $args = apply_filters( 'give_get_users_donations_args', array( |
|
55 | + $args = apply_filters('give_get_users_donations_args', array( |
|
56 | 56 | 'user' => $user, |
57 | 57 | 'number' => $number, |
58 | 58 | 'status' => $status, |
59 | 59 | 'orderby' => 'date', |
60 | - ) ); |
|
60 | + )); |
|
61 | 61 | |
62 | - if ( $pagination ) { |
|
62 | + if ($pagination) { |
|
63 | 63 | |
64 | 64 | $args['page'] = $paged; |
65 | 65 | |
@@ -69,20 +69,20 @@ discard block |
||
69 | 69 | |
70 | 70 | } |
71 | 71 | |
72 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
73 | - $customer = new Give_Customer( $user, $by_user_id ); |
|
72 | + $by_user_id = is_numeric($user) ? true : false; |
|
73 | + $customer = new Give_Customer($user, $by_user_id); |
|
74 | 74 | |
75 | - if ( ! empty( $customer->payment_ids ) ) { |
|
75 | + if ( ! empty($customer->payment_ids)) { |
|
76 | 76 | |
77 | - unset( $args['user'] ); |
|
78 | - $args['post__in'] = array_map( 'absint', explode( ',', $customer->payment_ids ) ); |
|
77 | + unset($args['user']); |
|
78 | + $args['post__in'] = array_map('absint', explode(',', $customer->payment_ids)); |
|
79 | 79 | |
80 | 80 | } |
81 | 81 | |
82 | - $purchases = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) ); |
|
82 | + $purchases = give_get_payments(apply_filters('give_get_users_donations_args', $args)); |
|
83 | 83 | |
84 | 84 | // No donations |
85 | - if ( ! $purchases ) { |
|
85 | + if ( ! $purchases) { |
|
86 | 86 | return false; |
87 | 87 | } |
88 | 88 | |
@@ -101,65 +101,65 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return bool|object List of unique forms donated by user |
103 | 103 | */ |
104 | -function give_get_users_completed_donations( $user = 0, $status = 'complete' ) { |
|
105 | - if ( empty( $user ) ) { |
|
104 | +function give_get_users_completed_donations($user = 0, $status = 'complete') { |
|
105 | + if (empty($user)) { |
|
106 | 106 | $user = get_current_user_id(); |
107 | 107 | } |
108 | 108 | |
109 | - if ( empty( $user ) ) { |
|
109 | + if (empty($user)) { |
|
110 | 110 | return false; |
111 | 111 | } |
112 | 112 | |
113 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
113 | + $by_user_id = is_numeric($user) ? true : false; |
|
114 | 114 | |
115 | - $customer = new Give_Customer( $user, $by_user_id ); |
|
115 | + $customer = new Give_Customer($user, $by_user_id); |
|
116 | 116 | |
117 | - if ( empty( $customer->payment_ids ) ) { |
|
117 | + if (empty($customer->payment_ids)) { |
|
118 | 118 | return false; |
119 | 119 | } |
120 | 120 | |
121 | 121 | // Get all the items donated |
122 | - $payment_ids = array_reverse( explode( ',', $customer->payment_ids ) ); |
|
123 | - $limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 ); |
|
124 | - if ( ! empty( $limit_payments ) ) { |
|
125 | - $payment_ids = array_slice( $payment_ids, 0, $limit_payments ); |
|
122 | + $payment_ids = array_reverse(explode(',', $customer->payment_ids)); |
|
123 | + $limit_payments = apply_filters('give_users_completed_donations_payments', 50); |
|
124 | + if ( ! empty($limit_payments)) { |
|
125 | + $payment_ids = array_slice($payment_ids, 0, $limit_payments); |
|
126 | 126 | } |
127 | 127 | $donation_data = array(); |
128 | - foreach ( $payment_ids as $payment_id ) { |
|
129 | - $donation_data[] = give_get_payment_meta( $payment_id ); |
|
128 | + foreach ($payment_ids as $payment_id) { |
|
129 | + $donation_data[] = give_get_payment_meta($payment_id); |
|
130 | 130 | } |
131 | 131 | |
132 | - if ( empty( $donation_data ) ) { |
|
132 | + if (empty($donation_data)) { |
|
133 | 133 | return false; |
134 | 134 | } |
135 | 135 | |
136 | 136 | // Grab only the post ids "form_id" of the forms donated on this order |
137 | 137 | $completed_donations_ids = array(); |
138 | - foreach ( $donation_data as $purchase_meta ) { |
|
139 | - $completed_donations_ids[] = isset( $purchase_meta['form_id'] ) ? $purchase_meta['form_id'] : ''; |
|
138 | + foreach ($donation_data as $purchase_meta) { |
|
139 | + $completed_donations_ids[] = isset($purchase_meta['form_id']) ? $purchase_meta['form_id'] : ''; |
|
140 | 140 | } |
141 | 141 | |
142 | - if ( empty( $completed_donations_ids ) ) { |
|
142 | + if (empty($completed_donations_ids)) { |
|
143 | 143 | return false; |
144 | 144 | } |
145 | 145 | |
146 | 146 | // Only include each donation once |
147 | - $form_ids = array_unique( $completed_donations_ids ); |
|
147 | + $form_ids = array_unique($completed_donations_ids); |
|
148 | 148 | |
149 | 149 | // Make sure we still have some products and a first item |
150 | - if ( empty( $form_ids ) || ! isset( $form_ids[0] ) ) { |
|
150 | + if (empty($form_ids) || ! isset($form_ids[0])) { |
|
151 | 151 | return false; |
152 | 152 | } |
153 | 153 | |
154 | - $post_type = get_post_type( $form_ids[0] ); |
|
154 | + $post_type = get_post_type($form_ids[0]); |
|
155 | 155 | |
156 | - $args = apply_filters( 'give_get_users_completed_donations_args', array( |
|
156 | + $args = apply_filters('give_get_users_completed_donations_args', array( |
|
157 | 157 | 'include' => $form_ids, |
158 | 158 | 'post_type' => $post_type, |
159 | - 'posts_per_page' => - 1, |
|
160 | - ) ); |
|
159 | + 'posts_per_page' => -1, |
|
160 | + )); |
|
161 | 161 | |
162 | - return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) ); |
|
162 | + return apply_filters('give_users_completed_donations_list', get_posts($args)); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
@@ -175,12 +175,12 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return bool True if has donated, false other wise. |
177 | 177 | */ |
178 | -function give_has_purchases( $user_id = null ) { |
|
179 | - if ( empty( $user_id ) ) { |
|
178 | +function give_has_purchases($user_id = null) { |
|
179 | + if (empty($user_id)) { |
|
180 | 180 | $user_id = get_current_user_id(); |
181 | 181 | } |
182 | 182 | |
183 | - if ( give_get_users_purchases( $user_id, 1 ) ) { |
|
183 | + if (give_get_users_purchases($user_id, 1)) { |
|
184 | 184 | return true; // User has at least one donation |
185 | 185 | } |
186 | 186 | |
@@ -200,27 +200,27 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return array |
202 | 202 | */ |
203 | -function give_get_purchase_stats_by_user( $user = '' ) { |
|
203 | +function give_get_purchase_stats_by_user($user = '') { |
|
204 | 204 | |
205 | - if ( is_email( $user ) ) { |
|
205 | + if (is_email($user)) { |
|
206 | 206 | |
207 | 207 | $field = 'email'; |
208 | 208 | |
209 | - } elseif ( is_numeric( $user ) ) { |
|
209 | + } elseif (is_numeric($user)) { |
|
210 | 210 | |
211 | 211 | $field = 'user_id'; |
212 | 212 | |
213 | 213 | } |
214 | 214 | |
215 | 215 | $stats = array(); |
216 | - $customer = Give()->customers->get_customer_by( $field, $user ); |
|
216 | + $customer = Give()->customers->get_customer_by($field, $user); |
|
217 | 217 | |
218 | - if ( $customer ) { |
|
218 | + if ($customer) { |
|
219 | 219 | |
220 | - $customer = new Give_Customer( $customer->id ); |
|
220 | + $customer = new Give_Customer($customer->id); |
|
221 | 221 | |
222 | - $stats['purchases'] = absint( $customer->purchase_count ); |
|
223 | - $stats['total_spent'] = give_sanitize_amount( $customer->purchase_value ); |
|
222 | + $stats['purchases'] = absint($customer->purchase_count); |
|
223 | + $stats['total_spent'] = give_sanitize_amount($customer->purchase_value); |
|
224 | 224 | |
225 | 225 | } |
226 | 226 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @since 1.7 |
231 | 231 | */ |
232 | - $stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user ); |
|
232 | + $stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user); |
|
233 | 233 | |
234 | 234 | return $stats; |
235 | 235 | } |
@@ -247,21 +247,21 @@ discard block |
||
247 | 247 | * |
248 | 248 | * @return int The total number of donations |
249 | 249 | */ |
250 | -function give_count_purchases_of_customer( $user = null ) { |
|
250 | +function give_count_purchases_of_customer($user = null) { |
|
251 | 251 | |
252 | 252 | // Logged in? |
253 | - if ( empty( $user ) ) { |
|
253 | + if (empty($user)) { |
|
254 | 254 | $user = get_current_user_id(); |
255 | 255 | } |
256 | 256 | |
257 | 257 | // Email access? |
258 | - if ( empty( $user ) && Give()->email_access->token_email ) { |
|
258 | + if (empty($user) && Give()->email_access->token_email) { |
|
259 | 259 | $user = Give()->email_access->token_email; |
260 | 260 | } |
261 | 261 | |
262 | - $stats = ! empty( $user ) ? give_get_purchase_stats_by_user( $user ) : false; |
|
262 | + $stats = ! empty($user) ? give_get_purchase_stats_by_user($user) : false; |
|
263 | 263 | |
264 | - return isset( $stats['purchases'] ) ? $stats['purchases'] : 0; |
|
264 | + return isset($stats['purchases']) ? $stats['purchases'] : 0; |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | /** |
@@ -274,9 +274,9 @@ discard block |
||
274 | 274 | * |
275 | 275 | * @return float The total amount the user has spent |
276 | 276 | */ |
277 | -function give_purchase_total_of_user( $user = null ) { |
|
277 | +function give_purchase_total_of_user($user = null) { |
|
278 | 278 | |
279 | - $stats = give_get_purchase_stats_by_user( $user ); |
|
279 | + $stats = give_get_purchase_stats_by_user($user); |
|
280 | 280 | |
281 | 281 | return $stats['total_spent']; |
282 | 282 | } |
@@ -292,40 +292,40 @@ discard block |
||
292 | 292 | * |
293 | 293 | * @return bool |
294 | 294 | */ |
295 | -function give_validate_username( $username, $form_id = 0 ) { |
|
295 | +function give_validate_username($username, $form_id = 0) { |
|
296 | 296 | $valid = true; |
297 | 297 | |
298 | 298 | // Validate username. |
299 | - if ( ! empty( $username ) ) { |
|
299 | + if ( ! empty($username)) { |
|
300 | 300 | |
301 | 301 | // Sanitize username. |
302 | - $sanitized_user_name = sanitize_user( $username, false ); |
|
302 | + $sanitized_user_name = sanitize_user($username, false); |
|
303 | 303 | |
304 | 304 | // We have an user name, check if it already exists. |
305 | - if ( username_exists( $username ) ) { |
|
305 | + if (username_exists($username)) { |
|
306 | 306 | // Username already registered. |
307 | - give_set_error( 'username_unavailable', __( 'Username already taken.', 'give' ) ); |
|
307 | + give_set_error('username_unavailable', __('Username already taken.', 'give')); |
|
308 | 308 | $valid = false; |
309 | 309 | |
310 | 310 | // Check if it's valid. |
311 | - } elseif ( $sanitized_user_name !== $username ) { |
|
311 | + } elseif ($sanitized_user_name !== $username) { |
|
312 | 312 | // Invalid username. |
313 | - if ( is_multisite() ) { |
|
314 | - give_set_error( 'username_invalid', __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) ); |
|
313 | + if (is_multisite()) { |
|
314 | + give_set_error('username_invalid', __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give')); |
|
315 | 315 | $valid = false; |
316 | 316 | } else { |
317 | - give_set_error( 'username_invalid', __( 'Invalid username.', 'give' ) ); |
|
317 | + give_set_error('username_invalid', __('Invalid username.', 'give')); |
|
318 | 318 | $valid = false; |
319 | 319 | } |
320 | 320 | } |
321 | 321 | } else { |
322 | 322 | // Username is empty. |
323 | - give_set_error( 'username_empty', __( 'Enter a username.', 'give' ) ); |
|
323 | + give_set_error('username_empty', __('Enter a username.', 'give')); |
|
324 | 324 | $valid = false; |
325 | 325 | |
326 | 326 | // Check if guest checkout is disable for form. |
327 | - if ( $form_id && give_logged_in_only( $form_id ) ) { |
|
328 | - give_set_error( 'registration_required', __( 'You must register or login to complete your donation.', 'give' ) ); |
|
327 | + if ($form_id && give_logged_in_only($form_id)) { |
|
328 | + give_set_error('registration_required', __('You must register or login to complete your donation.', 'give')); |
|
329 | 329 | $valid = false; |
330 | 330 | } |
331 | 331 | } |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | * @param string $username |
340 | 340 | * @param bool $form_id |
341 | 341 | */ |
342 | - $valid = (bool) apply_filters( 'give_validate_username', $valid, $username, $form_id ); |
|
342 | + $valid = (bool) apply_filters('give_validate_username', $valid, $username, $form_id); |
|
343 | 343 | |
344 | 344 | return $valid; |
345 | 345 | } |
@@ -355,22 +355,22 @@ discard block |
||
355 | 355 | * |
356 | 356 | * @return bool |
357 | 357 | */ |
358 | -function give_validate_user_email( $email, $registering_new_user = false ) { |
|
358 | +function give_validate_user_email($email, $registering_new_user = false) { |
|
359 | 359 | $valid = true; |
360 | 360 | |
361 | - if ( empty( $email ) ) { |
|
361 | + if (empty($email)) { |
|
362 | 362 | // No email. |
363 | - give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) ); |
|
363 | + give_set_error('email_empty', __('Enter an email.', 'give')); |
|
364 | 364 | $valid = false; |
365 | 365 | |
366 | - } elseif ( ! is_email( $email ) ) { |
|
366 | + } elseif ( ! is_email($email)) { |
|
367 | 367 | // Validate email. |
368 | - give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) ); |
|
368 | + give_set_error('email_invalid', __('Invalid email.', 'give')); |
|
369 | 369 | $valid = false; |
370 | 370 | |
371 | - } elseif ( $registering_new_user && email_exists( $email ) ) { |
|
371 | + } elseif ($registering_new_user && email_exists($email)) { |
|
372 | 372 | // Check if email exists. |
373 | - give_set_error( 'email_used', __( 'The email address provided is already active for another user.', 'give' ) ); |
|
373 | + give_set_error('email_used', __('The email address provided is already active for another user.', 'give')); |
|
374 | 374 | $valid = false; |
375 | 375 | } |
376 | 376 | |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * @param string $email |
384 | 384 | * @param bool $registering_new_user |
385 | 385 | */ |
386 | - $valid = (bool) apply_filters( 'give_validate_user_email', $valid, $email, $registering_new_user ); |
|
386 | + $valid = (bool) apply_filters('give_validate_user_email', $valid, $email, $registering_new_user); |
|
387 | 387 | |
388 | 388 | return $valid; |
389 | 389 | } |
@@ -399,25 +399,25 @@ discard block |
||
399 | 399 | * |
400 | 400 | * @return bool |
401 | 401 | */ |
402 | -function give_validate_user_password( $password = '', $confirm_password = '', $registering_new_user = false ) { |
|
402 | +function give_validate_user_password($password = '', $confirm_password = '', $registering_new_user = false) { |
|
403 | 403 | $valid = true; |
404 | 404 | |
405 | - if ( $password && $confirm_password ) { |
|
405 | + if ($password && $confirm_password) { |
|
406 | 406 | // Verify confirmation matches. |
407 | - if ( $password != $confirm_password ) { |
|
407 | + if ($password != $confirm_password) { |
|
408 | 408 | // Passwords do not match |
409 | - give_set_error( 'password_mismatch', __( 'Passwords don\'t match.', 'give' ) ); |
|
409 | + give_set_error('password_mismatch', __('Passwords don\'t match.', 'give')); |
|
410 | 410 | $valid = false; |
411 | 411 | } |
412 | - } elseif ( $registering_new_user ) { |
|
412 | + } elseif ($registering_new_user) { |
|
413 | 413 | // Password or confirmation missing. |
414 | - if ( ! $password ) { |
|
414 | + if ( ! $password) { |
|
415 | 415 | // The password is invalid. |
416 | - give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) ); |
|
416 | + give_set_error('password_empty', __('Enter a password.', 'give')); |
|
417 | 417 | $valid = false; |
418 | - } elseif ( ! $confirm_password ) { |
|
418 | + } elseif ( ! $confirm_password) { |
|
419 | 419 | // Confirmation password is invalid. |
420 | - give_set_error( 'confirmation_empty', __( 'Enter the password confirmation.', 'give' ) ); |
|
420 | + give_set_error('confirmation_empty', __('Enter the password confirmation.', 'give')); |
|
421 | 421 | $valid = false; |
422 | 422 | } |
423 | 423 | } |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | * @param string $confirm_password |
433 | 433 | * @param bool $registering_new_user |
434 | 434 | */ |
435 | - $valid = (bool) apply_filters( 'give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user ); |
|
435 | + $valid = (bool) apply_filters('give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user); |
|
436 | 436 | |
437 | 437 | return $valid; |
438 | 438 | } |
@@ -451,32 +451,32 @@ discard block |
||
451 | 451 | * |
452 | 452 | * @return void |
453 | 453 | */ |
454 | -function give_add_past_purchases_to_new_user( $user_id ) { |
|
454 | +function give_add_past_purchases_to_new_user($user_id) { |
|
455 | 455 | |
456 | - $email = get_the_author_meta( 'user_email', $user_id ); |
|
456 | + $email = get_the_author_meta('user_email', $user_id); |
|
457 | 457 | |
458 | - $payments = give_get_payments( array( 's' => $email ) ); |
|
458 | + $payments = give_get_payments(array('s' => $email)); |
|
459 | 459 | |
460 | - if ( $payments ) { |
|
461 | - foreach ( $payments as $payment ) { |
|
462 | - if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) { |
|
460 | + if ($payments) { |
|
461 | + foreach ($payments as $payment) { |
|
462 | + if (intval(give_get_payment_user_id($payment->ID)) > 0) { |
|
463 | 463 | continue; |
464 | 464 | } // This payment already associated with an account |
465 | 465 | |
466 | - $meta = give_get_payment_meta( $payment->ID ); |
|
467 | - $meta['user_info'] = maybe_unserialize( $meta['user_info'] ); |
|
466 | + $meta = give_get_payment_meta($payment->ID); |
|
467 | + $meta['user_info'] = maybe_unserialize($meta['user_info']); |
|
468 | 468 | $meta['user_info']['id'] = $user_id; |
469 | 469 | $meta['user_info'] = $meta['user_info']; |
470 | 470 | |
471 | 471 | // Store the updated user ID in the payment meta |
472 | - give_update_payment_meta( $payment->ID, '_give_payment_meta', $meta ); |
|
473 | - give_update_payment_meta( $payment->ID, '_give_payment_user_id', $user_id ); |
|
472 | + give_update_payment_meta($payment->ID, '_give_payment_meta', $meta); |
|
473 | + give_update_payment_meta($payment->ID, '_give_payment_user_id', $user_id); |
|
474 | 474 | } |
475 | 475 | } |
476 | 476 | |
477 | 477 | } |
478 | 478 | |
479 | -add_action( 'user_register', 'give_add_past_purchases_to_new_user' ); |
|
479 | +add_action('user_register', 'give_add_past_purchases_to_new_user'); |
|
480 | 480 | |
481 | 481 | |
482 | 482 | /** |
@@ -502,34 +502,34 @@ discard block |
||
502 | 502 | * |
503 | 503 | * @return array The donor's address, if any |
504 | 504 | */ |
505 | -function give_get_donor_address( $user_id = 0 ) { |
|
506 | - if ( empty( $user_id ) ) { |
|
505 | +function give_get_donor_address($user_id = 0) { |
|
506 | + if (empty($user_id)) { |
|
507 | 507 | $user_id = get_current_user_id(); |
508 | 508 | } |
509 | 509 | |
510 | - $address = get_user_meta( $user_id, '_give_user_address', true ); |
|
510 | + $address = get_user_meta($user_id, '_give_user_address', true); |
|
511 | 511 | |
512 | - if ( ! isset( $address['line1'] ) ) { |
|
512 | + if ( ! isset($address['line1'])) { |
|
513 | 513 | $address['line1'] = ''; |
514 | 514 | } |
515 | 515 | |
516 | - if ( ! isset( $address['line2'] ) ) { |
|
516 | + if ( ! isset($address['line2'])) { |
|
517 | 517 | $address['line2'] = ''; |
518 | 518 | } |
519 | 519 | |
520 | - if ( ! isset( $address['city'] ) ) { |
|
520 | + if ( ! isset($address['city'])) { |
|
521 | 521 | $address['city'] = ''; |
522 | 522 | } |
523 | 523 | |
524 | - if ( ! isset( $address['zip'] ) ) { |
|
524 | + if ( ! isset($address['zip'])) { |
|
525 | 525 | $address['zip'] = ''; |
526 | 526 | } |
527 | 527 | |
528 | - if ( ! isset( $address['country'] ) ) { |
|
528 | + if ( ! isset($address['country'])) { |
|
529 | 529 | $address['country'] = ''; |
530 | 530 | } |
531 | 531 | |
532 | - if ( ! isset( $address['state'] ) ) { |
|
532 | + if ( ! isset($address['state'])) { |
|
533 | 533 | $address['state'] = ''; |
534 | 534 | } |
535 | 535 | |
@@ -549,42 +549,42 @@ discard block |
||
549 | 549 | * |
550 | 550 | * @return void |
551 | 551 | */ |
552 | -function give_new_user_notification( $user_id = 0, $user_data = array() ) { |
|
552 | +function give_new_user_notification($user_id = 0, $user_data = array()) { |
|
553 | 553 | |
554 | - if ( empty( $user_id ) || empty( $user_data ) ) { |
|
554 | + if (empty($user_id) || empty($user_data)) { |
|
555 | 555 | return; |
556 | 556 | } |
557 | - $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
557 | + $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
558 | 558 | |
559 | 559 | /* translators: %s: site name */ |
560 | - $message = sprintf( esc_attr__( 'New user registration on your site %s:', 'give' ), $blogname ) . "\r\n\r\n"; |
|
560 | + $message = sprintf(esc_attr__('New user registration on your site %s:', 'give'), $blogname)."\r\n\r\n"; |
|
561 | 561 | /* translators: %s: user login */ |
562 | - $message .= sprintf( esc_attr__( 'Username: %s', 'give' ), $user_data['user_login'] ) . "\r\n\r\n"; |
|
562 | + $message .= sprintf(esc_attr__('Username: %s', 'give'), $user_data['user_login'])."\r\n\r\n"; |
|
563 | 563 | /* translators: %s: user email */ |
564 | - $message .= sprintf( esc_attr__( 'E-mail: %s', 'give' ), $user_data['user_email'] ) . "\r\n"; |
|
564 | + $message .= sprintf(esc_attr__('E-mail: %s', 'give'), $user_data['user_email'])."\r\n"; |
|
565 | 565 | |
566 | 566 | Give()->emails->send( |
567 | - get_option( 'admin_email' ), |
|
567 | + get_option('admin_email'), |
|
568 | 568 | sprintf( |
569 | 569 | /* translators: %s: site name */ |
570 | - esc_attr__( '[%s] New User Registration', 'give' ), |
|
570 | + esc_attr__('[%s] New User Registration', 'give'), |
|
571 | 571 | $blogname |
572 | 572 | ), |
573 | 573 | $message |
574 | 574 | ); |
575 | 575 | |
576 | 576 | /* translators: %s: user login */ |
577 | - $message = sprintf( esc_attr__( 'Username: %s', 'give' ), $user_data['user_login'] ) . "\r\n"; |
|
577 | + $message = sprintf(esc_attr__('Username: %s', 'give'), $user_data['user_login'])."\r\n"; |
|
578 | 578 | /* translators: %s: paswword */ |
579 | - $message .= sprintf( esc_attr__( 'Password: %s', 'give' ), esc_attr__( '[Password entered during donation]', 'give' ) ) . "\r\n"; |
|
579 | + $message .= sprintf(esc_attr__('Password: %s', 'give'), esc_attr__('[Password entered during donation]', 'give'))."\r\n"; |
|
580 | 580 | |
581 | - $message .= '<a href="' . wp_login_url() . '"> ' . esc_attr__( 'Click Here to Login »', 'give' ) . '</a>' . "\r\n"; |
|
581 | + $message .= '<a href="'.wp_login_url().'"> '.esc_attr__('Click Here to Login »', 'give').'</a>'."\r\n"; |
|
582 | 582 | |
583 | 583 | Give()->emails->send( |
584 | 584 | $user_data['user_email'], |
585 | 585 | sprintf( |
586 | 586 | /* translators: %s: site name */ |
587 | - esc_attr__( '[%s] Your username and password', 'give' ), |
|
587 | + esc_attr__('[%s] Your username and password', 'give'), |
|
588 | 588 | $blogname |
589 | 589 | ), |
590 | 590 | $message |
@@ -592,4 +592,4 @@ discard block |
||
592 | 592 | |
593 | 593 | } |
594 | 594 | |
595 | -add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 ); |
|
595 | +add_action('give_insert_user', 'give_new_user_notification', 10, 2); |
@@ -733,9 +733,9 @@ |
||
733 | 733 | <td class="give-docs-link" colspan="2"> |
734 | 734 | <?php |
735 | 735 | echo '<p class="give-docs-link"><a href="' . esc_url( $value['url'] ) |
736 | - . '" target="_blank">' |
|
737 | - . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] ) |
|
738 | - . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
|
736 | + . '" target="_blank">' |
|
737 | + . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] ) |
|
738 | + . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
|
739 | 739 | ?> |
740 | 740 | </td> |
741 | 741 | </tr><?php |
@@ -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; |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Admin_Settings' ) ) : |
|
16 | +if ( ! class_exists('Give_Admin_Settings')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Admin_Settings Class. |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @param array $settings Array of settings class object. |
74 | 74 | */ |
75 | - self::$settings = apply_filters( self::$setting_filter_prefix . '_get_settings_pages', array() ); |
|
75 | + self::$settings = apply_filters(self::$setting_filter_prefix.'_get_settings_pages', array()); |
|
76 | 76 | |
77 | 77 | return self::$settings; |
78 | 78 | } |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | public static function save() { |
87 | 87 | $current_tab = give_get_current_setting_tab(); |
88 | 88 | |
89 | - if ( empty( $_REQUEST['_give-save-settings'] ) || ! wp_verify_nonce( $_REQUEST['_give-save-settings'], 'give-save-settings' ) ) { |
|
90 | - echo '<div class="notice error"><p>' . __( 'Action failed. Please refresh the page and retry.', 'give' ) . '</p></div>'; |
|
89 | + if (empty($_REQUEST['_give-save-settings']) || ! wp_verify_nonce($_REQUEST['_give-save-settings'], 'give-save-settings')) { |
|
90 | + echo '<div class="notice error"><p>'.__('Action failed. Please refresh the page and retry.', 'give').'</p></div>'; |
|
91 | 91 | die(); |
92 | 92 | } |
93 | 93 | |
@@ -100,9 +100,9 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @since 1.8 |
102 | 102 | */ |
103 | - do_action( self::$setting_filter_prefix . '_save_' . $current_tab ); |
|
103 | + do_action(self::$setting_filter_prefix.'_save_'.$current_tab); |
|
104 | 104 | |
105 | - self::add_message( 'give-setting-updated', __( 'Your settings have been saved.', 'give' ) ); |
|
105 | + self::add_message('give-setting-updated', __('Your settings have been saved.', 'give')); |
|
106 | 106 | |
107 | 107 | /** |
108 | 108 | * Trigger Action. |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @since 1.8 |
115 | 115 | */ |
116 | - do_action( self::$setting_filter_prefix . '_saved' ); |
|
116 | + do_action(self::$setting_filter_prefix.'_saved'); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @return void |
128 | 128 | */ |
129 | - public static function add_message( $code, $message ) { |
|
130 | - self::$messages[ $code ] = $message; |
|
129 | + public static function add_message($code, $message) { |
|
130 | + self::$messages[$code] = $message; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return void |
142 | 142 | */ |
143 | - public static function add_error( $code, $message ) { |
|
144 | - self::$errors[ $code ] = $message; |
|
143 | + public static function add_error($code, $message) { |
|
144 | + self::$errors[$code] = $message; |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -154,18 +154,18 @@ discard block |
||
154 | 154 | $notice_html = ''; |
155 | 155 | $classes = 'give-notice settings-error notice is-dismissible'; |
156 | 156 | |
157 | - self::$errors = apply_filters( self::$setting_filter_prefix . '_error_notices', self::$errors ); |
|
158 | - self::$messages = apply_filters( self::$setting_filter_prefix . '_update_notices', self::$messages ); |
|
157 | + self::$errors = apply_filters(self::$setting_filter_prefix.'_error_notices', self::$errors); |
|
158 | + self::$messages = apply_filters(self::$setting_filter_prefix.'_update_notices', self::$messages); |
|
159 | 159 | |
160 | - if ( 0 < count( self::$errors ) ) { |
|
161 | - foreach ( self::$errors as $code => $message ) { |
|
162 | - $notice_html .= '<div id="setting-error-' . $code . '" class="' . $classes . ' error"><p><strong>' . $message . '</strong></p></div>'; |
|
160 | + if (0 < count(self::$errors)) { |
|
161 | + foreach (self::$errors as $code => $message) { |
|
162 | + $notice_html .= '<div id="setting-error-'.$code.'" class="'.$classes.' error"><p><strong>'.$message.'</strong></p></div>'; |
|
163 | 163 | } |
164 | 164 | } |
165 | 165 | |
166 | - if ( 0 < count( self::$messages ) ) { |
|
167 | - foreach ( self::$messages as $code => $message ) { |
|
168 | - $notice_html .= '<div id="setting-error-' . $code . '" class="' . $classes . ' updated"><p><strong>' . $message . '</strong></p></div>'; |
|
166 | + if (0 < count(self::$messages)) { |
|
167 | + foreach (self::$messages as $code => $message) { |
|
168 | + $notice_html .= '<div id="setting-error-'.$code.'" class="'.$classes.' updated"><p><strong>'.$message.'</strong></p></div>'; |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | self::$setting_filter_prefix = give_get_current_setting_page(); |
186 | 186 | |
187 | 187 | // Bailout: Exit if setting page is not defined. |
188 | - if ( empty( self::$setting_filter_prefix ) ) { |
|
188 | + if (empty(self::$setting_filter_prefix)) { |
|
189 | 189 | return false; |
190 | 190 | } |
191 | 191 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * |
199 | 199 | * @since 1.8 |
200 | 200 | */ |
201 | - do_action( self::$setting_filter_prefix . '_start' ); |
|
201 | + do_action(self::$setting_filter_prefix.'_start'); |
|
202 | 202 | |
203 | 203 | $current_tab = give_get_current_setting_tab(); |
204 | 204 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | self::get_settings_pages(); |
207 | 207 | |
208 | 208 | // Save settings if data has been posted. |
209 | - if ( ! empty( $_POST ) ) { |
|
209 | + if ( ! empty($_POST)) { |
|
210 | 210 | self::save(); |
211 | 211 | } |
212 | 212 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * |
220 | 220 | * @since 1.8 |
221 | 221 | */ |
222 | - $tabs = apply_filters( self::$setting_filter_prefix . '_tabs_array', array() ); |
|
222 | + $tabs = apply_filters(self::$setting_filter_prefix.'_tabs_array', array()); |
|
223 | 223 | |
224 | 224 | include 'views/html-admin-settings.php'; |
225 | 225 | |
@@ -237,25 +237,25 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return string|bool |
239 | 239 | */ |
240 | - public static function get_option( $option_name = '', $field_id = '', $default = false ) { |
|
240 | + public static function get_option($option_name = '', $field_id = '', $default = false) { |
|
241 | 241 | // Bailout. |
242 | - if ( empty( $option_name ) && empty( $field_id ) ) { |
|
242 | + if (empty($option_name) && empty($field_id)) { |
|
243 | 243 | return false; |
244 | 244 | } |
245 | 245 | |
246 | - if ( ! empty( $field_id ) && ! empty( $option_name ) ) { |
|
246 | + if ( ! empty($field_id) && ! empty($option_name)) { |
|
247 | 247 | // Get field value if any. |
248 | - $option_value = get_option( $option_name ); |
|
248 | + $option_value = get_option($option_name); |
|
249 | 249 | |
250 | - $option_value = ( is_array( $option_value ) && array_key_exists( $field_id, $option_value ) ) |
|
251 | - ? $option_value[ $field_id ] |
|
250 | + $option_value = (is_array($option_value) && array_key_exists($field_id, $option_value)) |
|
251 | + ? $option_value[$field_id] |
|
252 | 252 | : $default; |
253 | 253 | } else { |
254 | 254 | // If option name is empty but not field name then this means, setting is direct store to option table under there field name. |
255 | 255 | $option_name = ! $option_name ? $field_id : $option_name; |
256 | 256 | |
257 | 257 | // Get option value if any. |
258 | - $option_value = get_option( $option_name, $default ); |
|
258 | + $option_value = get_option($option_name, $default); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | return $option_value; |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * |
274 | 274 | * @return void |
275 | 275 | */ |
276 | - public static function output_fields( $options, $option_name = '' ) { |
|
276 | + public static function output_fields($options, $option_name = '') { |
|
277 | 277 | $current_tab = give_get_current_setting_tab(); |
278 | 278 | |
279 | 279 | // Field Default values. |
@@ -286,52 +286,52 @@ discard block |
||
286 | 286 | 'table_html' => true, |
287 | 287 | ); |
288 | 288 | |
289 | - foreach ( $options as $value ) { |
|
290 | - if ( ! isset( $value['type'] ) ) { |
|
289 | + foreach ($options as $value) { |
|
290 | + if ( ! isset($value['type'])) { |
|
291 | 291 | continue; |
292 | 292 | } |
293 | 293 | |
294 | 294 | // Set title. |
295 | - $defaults['title'] = isset( $value['name'] ) ? $value['name'] : ''; |
|
295 | + $defaults['title'] = isset($value['name']) ? $value['name'] : ''; |
|
296 | 296 | |
297 | 297 | // Set default setting. |
298 | - $value = wp_parse_args( $value, $defaults ); |
|
298 | + $value = wp_parse_args($value, $defaults); |
|
299 | 299 | |
300 | 300 | // Colorpicker field. |
301 | - $value['class'] = ( 'colorpicker' === $value['type'] ? trim( $value['class'] ) . ' give-colorpicker' : $value['class'] ); |
|
302 | - $value['type'] = ( 'colorpicker' === $value['type'] ? 'text' : $value['type'] ); |
|
301 | + $value['class'] = ('colorpicker' === $value['type'] ? trim($value['class']).' give-colorpicker' : $value['class']); |
|
302 | + $value['type'] = ('colorpicker' === $value['type'] ? 'text' : $value['type']); |
|
303 | 303 | |
304 | 304 | |
305 | 305 | // Custom attribute handling. |
306 | 306 | $custom_attributes = array(); |
307 | 307 | |
308 | - if ( ! empty( $value['attributes'] ) && is_array( $value['attributes'] ) ) { |
|
309 | - foreach ( $value['attributes'] as $attribute => $attribute_value ) { |
|
310 | - $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"'; |
|
308 | + if ( ! empty($value['attributes']) && is_array($value['attributes'])) { |
|
309 | + foreach ($value['attributes'] as $attribute => $attribute_value) { |
|
310 | + $custom_attributes[] = esc_attr($attribute).'="'.esc_attr($attribute_value).'"'; |
|
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
314 | 314 | // Description handling. |
315 | - $description = self::get_field_description( $value ); |
|
315 | + $description = self::get_field_description($value); |
|
316 | 316 | |
317 | 317 | // Switch based on type. |
318 | - switch ( $value['type'] ) { |
|
318 | + switch ($value['type']) { |
|
319 | 319 | |
320 | 320 | // Section Titles |
321 | 321 | case 'title': |
322 | - if ( ! empty( $value['title'] ) ) { |
|
323 | - echo '<div class="give-setting-tab-header give-setting-tab-header-' . $current_tab . '"><h2>' . self::get_field_title( $value ) . '</h2><hr></div>'; |
|
322 | + if ( ! empty($value['title'])) { |
|
323 | + echo '<div class="give-setting-tab-header give-setting-tab-header-'.$current_tab.'"><h2>'.self::get_field_title($value).'</h2><hr></div>'; |
|
324 | 324 | } |
325 | 325 | |
326 | - if ( ! empty( $value['desc'] ) ) { |
|
327 | - echo wpautop( wptexturize( wp_kses_post( $value['desc'] ) ) ); |
|
326 | + if ( ! empty($value['desc'])) { |
|
327 | + echo wpautop(wptexturize(wp_kses_post($value['desc']))); |
|
328 | 328 | } |
329 | 329 | |
330 | - if ( $value['table_html'] ) { |
|
331 | - echo '<table class="form-table give-setting-tab-body give-setting-tab-body-' . $current_tab . '">' . "\n\n"; |
|
330 | + if ($value['table_html']) { |
|
331 | + echo '<table class="form-table give-setting-tab-body give-setting-tab-body-'.$current_tab.'">'."\n\n"; |
|
332 | 332 | } |
333 | 333 | |
334 | - if ( ! empty( $value['id'] ) ) { |
|
334 | + if ( ! empty($value['id'])) { |
|
335 | 335 | |
336 | 336 | /** |
337 | 337 | * Trigger Action. |
@@ -340,14 +340,14 @@ discard block |
||
340 | 340 | * |
341 | 341 | * @since 1.8 |
342 | 342 | */ |
343 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) ); |
|
343 | + do_action('give_settings_'.sanitize_title($value['id'])); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | break; |
347 | 347 | |
348 | 348 | // Section Ends. |
349 | 349 | case 'sectionend': |
350 | - if ( ! empty( $value['id'] ) ) { |
|
350 | + if ( ! empty($value['id'])) { |
|
351 | 351 | |
352 | 352 | /** |
353 | 353 | * Trigger Action. |
@@ -356,14 +356,14 @@ discard block |
||
356 | 356 | * |
357 | 357 | * @since 1.8 |
358 | 358 | */ |
359 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_end' ); |
|
359 | + do_action('give_settings_'.sanitize_title($value['id']).'_end'); |
|
360 | 360 | } |
361 | 361 | |
362 | - if ( $value['table_html'] ) { |
|
362 | + if ($value['table_html']) { |
|
363 | 363 | echo '</table>'; |
364 | 364 | } |
365 | 365 | |
366 | - if ( ! empty( $value['id'] ) ) { |
|
366 | + if ( ! empty($value['id'])) { |
|
367 | 367 | |
368 | 368 | /** |
369 | 369 | * Trigger Action. |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | * |
373 | 373 | * @since 1.8 |
374 | 374 | */ |
375 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_after' ); |
|
375 | + do_action('give_settings_'.sanitize_title($value['id']).'_after'); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | break; |
@@ -385,22 +385,22 @@ discard block |
||
385 | 385 | case 'password' : |
386 | 386 | |
387 | 387 | $type = $value['type']; |
388 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
388 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
389 | 389 | |
390 | 390 | ?> |
391 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
391 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
392 | 392 | <th scope="row" class="titledesc"> |
393 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
393 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
394 | 394 | </th> |
395 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
395 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
396 | 396 | <input |
397 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
398 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
399 | - type="<?php echo esc_attr( $type ); ?>" |
|
400 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
401 | - value="<?php echo esc_attr( $option_value ); ?>" |
|
402 | - class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>" |
|
403 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
397 | + name="<?php echo esc_attr($value['id']); ?>" |
|
398 | + id="<?php echo esc_attr($value['id']); ?>" |
|
399 | + type="<?php echo esc_attr($type); ?>" |
|
400 | + style="<?php echo esc_attr($value['css']); ?>" |
|
401 | + value="<?php echo esc_attr($option_value); ?>" |
|
402 | + class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>" |
|
403 | + <?php echo implode(' ', $custom_attributes); ?> |
|
404 | 404 | /> <?php echo $description; ?> |
405 | 405 | </td> |
406 | 406 | </tr><?php |
@@ -409,23 +409,23 @@ discard block |
||
409 | 409 | // Textarea. |
410 | 410 | case 'textarea': |
411 | 411 | |
412 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
412 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
413 | 413 | |
414 | 414 | ?> |
415 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
415 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
416 | 416 | <th scope="row" class="titledesc"> |
417 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
417 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
418 | 418 | </th> |
419 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
419 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
420 | 420 | <textarea |
421 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
422 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
423 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
424 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
421 | + name="<?php echo esc_attr($value['id']); ?>" |
|
422 | + id="<?php echo esc_attr($value['id']); ?>" |
|
423 | + style="<?php echo esc_attr($value['css']); ?>" |
|
424 | + class="<?php echo esc_attr($value['class']); ?>" |
|
425 | 425 | rows="10" |
426 | 426 | cols="60" |
427 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
428 | - ><?php echo esc_textarea( $option_value ); ?></textarea> |
|
427 | + <?php echo implode(' ', $custom_attributes); ?> |
|
428 | + ><?php echo esc_textarea($option_value); ?></textarea> |
|
429 | 429 | <?php echo $description; ?> |
430 | 430 | </td> |
431 | 431 | </tr><?php |
@@ -435,35 +435,35 @@ discard block |
||
435 | 435 | case 'select' : |
436 | 436 | case 'multiselect' : |
437 | 437 | |
438 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
438 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
439 | 439 | |
440 | 440 | ?> |
441 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
441 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
442 | 442 | <th scope="row" class="titledesc"> |
443 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
443 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
444 | 444 | </th> |
445 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
445 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
446 | 446 | <select |
447 | - name="<?php echo esc_attr( $value['id'] ); ?><?php if ( $value['type'] == 'multiselect' ) { |
|
447 | + name="<?php echo esc_attr($value['id']); ?><?php if ($value['type'] == 'multiselect') { |
|
448 | 448 | echo '[]'; |
449 | 449 | } ?>" |
450 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
451 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
452 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
453 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
454 | - <?php echo ( 'multiselect' == $value['type'] ) ? 'multiple="multiple"' : ''; ?> |
|
450 | + id="<?php echo esc_attr($value['id']); ?>" |
|
451 | + style="<?php echo esc_attr($value['css']); ?>" |
|
452 | + class="<?php echo esc_attr($value['class']); ?>" |
|
453 | + <?php echo implode(' ', $custom_attributes); ?> |
|
454 | + <?php echo ('multiselect' == $value['type']) ? 'multiple="multiple"' : ''; ?> |
|
455 | 455 | > |
456 | 456 | |
457 | 457 | <?php |
458 | - if ( ! empty( $value['options'] ) ) { |
|
459 | - foreach ( $value['options'] as $key => $val ) { |
|
458 | + if ( ! empty($value['options'])) { |
|
459 | + foreach ($value['options'] as $key => $val) { |
|
460 | 460 | ?> |
461 | - <option value="<?php echo esc_attr( $key ); ?>" <?php |
|
461 | + <option value="<?php echo esc_attr($key); ?>" <?php |
|
462 | 462 | |
463 | - if ( is_array( $option_value ) ) { |
|
464 | - selected( in_array( $key, $option_value ), true ); |
|
463 | + if (is_array($option_value)) { |
|
464 | + selected(in_array($key, $option_value), true); |
|
465 | 465 | } else { |
466 | - selected( $option_value, $key ); |
|
466 | + selected($option_value, $key); |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | ?>><?php echo $val ?></option> |
@@ -479,28 +479,28 @@ discard block |
||
479 | 479 | |
480 | 480 | // Radio inputs. |
481 | 481 | case 'radio_inline' : |
482 | - $value['class'] = empty( $value['class'] ) ? 'give-radio-inline' : $value['class'] . ' give-radio-inline'; |
|
482 | + $value['class'] = empty($value['class']) ? 'give-radio-inline' : $value['class'].' give-radio-inline'; |
|
483 | 483 | case 'radio' : |
484 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
484 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
485 | 485 | ?> |
486 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
486 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
487 | 487 | <th scope="row" class="titledesc"> |
488 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
488 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
489 | 489 | </th> |
490 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>"> |
|
490 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>"> |
|
491 | 491 | <fieldset> |
492 | 492 | <ul> |
493 | 493 | <?php |
494 | - foreach ( $value['options'] as $key => $val ) { |
|
494 | + foreach ($value['options'] as $key => $val) { |
|
495 | 495 | ?> |
496 | 496 | <li> |
497 | 497 | <label><input |
498 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
498 | + name="<?php echo esc_attr($value['id']); ?>" |
|
499 | 499 | value="<?php echo $key; ?>" |
500 | 500 | type="radio" |
501 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
502 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
503 | - <?php checked( $key, $option_value ); ?> |
|
501 | + style="<?php echo esc_attr($value['css']); ?>" |
|
502 | + <?php echo implode(' ', $custom_attributes); ?> |
|
503 | + <?php checked($key, $option_value); ?> |
|
504 | 504 | /> <?php echo $val ?></label> |
505 | 505 | </li> |
506 | 506 | <?php |
@@ -514,21 +514,21 @@ discard block |
||
514 | 514 | |
515 | 515 | // Checkbox input. |
516 | 516 | case 'checkbox' : |
517 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
517 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
518 | 518 | ?> |
519 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
519 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
520 | 520 | <th scope="row" class="titledesc"> |
521 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
521 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
522 | 522 | </th> |
523 | 523 | <td class="give-forminp"> |
524 | 524 | <input |
525 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
526 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
525 | + name="<?php echo esc_attr($value['id']); ?>" |
|
526 | + id="<?php echo esc_attr($value['id']); ?>" |
|
527 | 527 | type="checkbox" |
528 | - class="<?php echo esc_attr( isset( $value['class'] ) ? $value['class'] : '' ); ?>" |
|
528 | + class="<?php echo esc_attr(isset($value['class']) ? $value['class'] : ''); ?>" |
|
529 | 529 | value="1" |
530 | - <?php checked( $option_value, 'on' ); ?> |
|
531 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
530 | + <?php checked($option_value, 'on'); ?> |
|
531 | + <?php echo implode(' ', $custom_attributes); ?> |
|
532 | 532 | /> |
533 | 533 | <?php echo $description; ?> |
534 | 534 | </td> |
@@ -538,28 +538,28 @@ discard block |
||
538 | 538 | |
539 | 539 | // Multi Checkbox input. |
540 | 540 | case 'multicheck' : |
541 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
542 | - $option_value = is_array( $option_value ) ? $option_value : array(); |
|
541 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
542 | + $option_value = is_array($option_value) ? $option_value : array(); |
|
543 | 543 | ?> |
544 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
544 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
545 | 545 | <th scope="row" class="titledesc"> |
546 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
546 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
547 | 547 | </th> |
548 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>"> |
|
548 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>"> |
|
549 | 549 | <fieldset> |
550 | 550 | <ul> |
551 | 551 | <?php |
552 | - foreach ( $value['options'] as $key => $val ) { |
|
552 | + foreach ($value['options'] as $key => $val) { |
|
553 | 553 | ?> |
554 | 554 | <li> |
555 | 555 | <label> |
556 | 556 | <input |
557 | - name="<?php echo esc_attr( $value['id'] ); ?>[]" |
|
557 | + name="<?php echo esc_attr($value['id']); ?>[]" |
|
558 | 558 | value="<?php echo $key; ?>" |
559 | 559 | type="checkbox" |
560 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
561 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
562 | - <?php if ( in_array( $key, $option_value ) ) { |
|
560 | + style="<?php echo esc_attr($value['css']); ?>" |
|
561 | + <?php echo implode(' ', $custom_attributes); ?> |
|
562 | + <?php if (in_array($key, $option_value)) { |
|
563 | 563 | echo 'checked="checked"'; |
564 | 564 | } ?> |
565 | 565 | /> <?php echo $val ?> |
@@ -577,25 +577,25 @@ discard block |
||
577 | 577 | |
578 | 578 | // File input field. |
579 | 579 | case 'file' : |
580 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
580 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
581 | 581 | ?> |
582 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
582 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
583 | 583 | <th scope="row" class="titledesc"> |
584 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
584 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
585 | 585 | </th> |
586 | 586 | <td class="give-forminp"> |
587 | 587 | <div class="give-field-wrap"> |
588 | 588 | <label for="<?php echo $value['id'] ?>"> |
589 | 589 | <input |
590 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
591 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
590 | + name="<?php echo esc_attr($value['id']); ?>" |
|
591 | + id="<?php echo esc_attr($value['id']); ?>" |
|
592 | 592 | type="text" |
593 | - class="give-input-field<?php echo esc_attr( isset( $value['class'] ) ? ' ' . $value['class'] : '' ); ?>" |
|
593 | + class="give-input-field<?php echo esc_attr(isset($value['class']) ? ' '.$value['class'] : ''); ?>" |
|
594 | 594 | value="<?php echo $option_value; ?>" |
595 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
596 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
595 | + style="<?php echo esc_attr($value['css']); ?>" |
|
596 | + <?php echo implode(' ', $custom_attributes); ?> |
|
597 | 597 | /> <input class="give-upload-button button" type="button" |
598 | - value="<?php echo esc_html__( 'Add or Upload File', 'give' ); ?>"> |
|
598 | + value="<?php echo esc_html__('Add or Upload File', 'give'); ?>"> |
|
599 | 599 | <?php echo $description ?> |
600 | 600 | <div class="give-image-thumb<?php echo ! $option_value ? ' give-hidden' : ''; ?>"> |
601 | 601 | <span class="give-delete-image-thumb dashicons dashicons-no-alt"></span> |
@@ -610,17 +610,17 @@ discard block |
||
610 | 610 | // WordPress Editor. |
611 | 611 | case 'wysiwyg' : |
612 | 612 | // Get option value. |
613 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
613 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
614 | 614 | |
615 | 615 | // Get editor settings. |
616 | - $editor_settings = ! empty( $value['options'] ) ? $value['options'] : array(); |
|
616 | + $editor_settings = ! empty($value['options']) ? $value['options'] : array(); |
|
617 | 617 | ?> |
618 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
618 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
619 | 619 | <th scope="row" class="titledesc"> |
620 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
620 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
621 | 621 | </th> |
622 | 622 | <td class="give-forminp"> |
623 | - <?php wp_editor( $option_value, $value['id'], $editor_settings ); ?> |
|
623 | + <?php wp_editor($option_value, $value['id'], $editor_settings); ?> |
|
624 | 624 | <?php echo $description; ?> |
625 | 625 | </td> |
626 | 626 | </tr><?php |
@@ -629,9 +629,9 @@ discard block |
||
629 | 629 | // Custom: System setting field. |
630 | 630 | case 'system_info' : |
631 | 631 | ?> |
632 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
632 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
633 | 633 | <th scope="row" class="titledesc"> |
634 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
634 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
635 | 635 | </th> |
636 | 636 | <td class="give-forminp"> |
637 | 637 | <?php give_system_info_callback(); ?> |
@@ -642,14 +642,14 @@ discard block |
||
642 | 642 | |
643 | 643 | // Custom: Default gateways setting field. |
644 | 644 | case 'default_gateway' : |
645 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
645 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
646 | 646 | ?> |
647 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
647 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
648 | 648 | <th scope="row" class="titledesc"> |
649 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
649 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
650 | 650 | </th> |
651 | 651 | <td class="give-forminp"> |
652 | - <?php give_default_gateway_callback( $value, $option_value ); ?> |
|
652 | + <?php give_default_gateway_callback($value, $option_value); ?> |
|
653 | 653 | <?php echo $description; ?> |
654 | 654 | </td> |
655 | 655 | </tr><?php |
@@ -657,14 +657,14 @@ discard block |
||
657 | 657 | |
658 | 658 | // Custom: Enable gateways setting field. |
659 | 659 | case 'enabled_gateways' : |
660 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
660 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
661 | 661 | ?> |
662 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
662 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
663 | 663 | <th scope="row" class="titledesc"> |
664 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
664 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
665 | 665 | </th> |
666 | 666 | <td class="give-forminp"> |
667 | - <?php give_enabled_gateways_callback( $value, $option_value ); ?> |
|
667 | + <?php give_enabled_gateways_callback($value, $option_value); ?> |
|
668 | 668 | <?php echo $description; ?> |
669 | 669 | </td> |
670 | 670 | </tr><?php |
@@ -673,9 +673,9 @@ discard block |
||
673 | 673 | // Custom: Email preview buttons field. |
674 | 674 | case 'email_preview_buttons' : |
675 | 675 | ?> |
676 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
676 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
677 | 677 | <th scope="row" class="titledesc"> |
678 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
678 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
679 | 679 | </th> |
680 | 680 | <td class="give-forminp"> |
681 | 681 | <?php give_email_preview_buttons_callback(); ?> |
@@ -692,22 +692,22 @@ discard block |
||
692 | 692 | |
693 | 693 | // Custom: Gateway API key. |
694 | 694 | case 'api_key' : |
695 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
696 | - $type = ! empty( $option_value ) ? 'password' : 'text'; |
|
695 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
696 | + $type = ! empty($option_value) ? 'password' : 'text'; |
|
697 | 697 | ?> |
698 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
698 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
699 | 699 | <th scope="row" class="titledesc"> |
700 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
700 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
701 | 701 | </th> |
702 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
702 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
703 | 703 | <input |
704 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
705 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
706 | - type="<?php echo esc_attr( $type ); ?>" |
|
707 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
708 | - value="<?php echo esc_attr( trim( $option_value ) ); ?>" |
|
709 | - class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>" |
|
710 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
704 | + name="<?php echo esc_attr($value['id']); ?>" |
|
705 | + id="<?php echo esc_attr($value['id']); ?>" |
|
706 | + type="<?php echo esc_attr($type); ?>" |
|
707 | + style="<?php echo esc_attr($value['css']); ?>" |
|
708 | + value="<?php echo esc_attr(trim($option_value)); ?>" |
|
709 | + class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>" |
|
710 | + <?php echo implode(' ', $custom_attributes); ?> |
|
711 | 711 | /> <?php echo $description; ?> |
712 | 712 | </td> |
713 | 713 | </tr><?php |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | // Custom: Log field. |
717 | 717 | case 'logs' : |
718 | 718 | |
719 | - include GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/logs.php'; |
|
719 | + include GIVE_PLUGIN_DIR.'includes/admin/tools/logs/logs.php'; |
|
720 | 720 | |
721 | 721 | // Get current section. |
722 | 722 | $current_section = $_GET['section'] = give_get_current_setting_section(); |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | * |
727 | 727 | * @since 1.0 |
728 | 728 | */ |
729 | - do_action( "give_logs_view_{$current_section}" ); |
|
729 | + do_action("give_logs_view_{$current_section}"); |
|
730 | 730 | |
731 | 731 | echo $description; |
732 | 732 | break; |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | // Custom: Data field. |
735 | 735 | case 'data' : |
736 | 736 | |
737 | - include GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-data.php'; |
|
737 | + include GIVE_PLUGIN_DIR.'includes/admin/tools/views/html-admin-page-data.php'; |
|
738 | 738 | |
739 | 739 | echo $description; |
740 | 740 | break; |
@@ -742,12 +742,12 @@ discard block |
||
742 | 742 | // Custom: Give Docs Link field type. |
743 | 743 | case 'give_docs_link' : |
744 | 744 | ?> |
745 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
745 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
746 | 746 | <td class="give-docs-link" colspan="2"> |
747 | 747 | <?php |
748 | - echo '<p class="give-docs-link"><a href="' . esc_url( $value['url'] ) |
|
748 | + echo '<p class="give-docs-link"><a href="'.esc_url($value['url']) |
|
749 | 749 | . '" target="_blank">' |
750 | - . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] ) |
|
750 | + . sprintf(esc_html__('Need Help? See docs on "%s"', 'give'), $value['title']) |
|
751 | 751 | . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
752 | 752 | ?> |
753 | 753 | </td> |
@@ -758,8 +758,8 @@ discard block |
||
758 | 758 | // You can add or handle your custom field action. |
759 | 759 | default: |
760 | 760 | // Get option value. |
761 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
762 | - do_action( 'give_admin_field_' . $value['type'], $value, $option_value ); |
|
761 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
762 | + do_action('give_admin_field_'.$value['type'], $value, $option_value); |
|
763 | 763 | break; |
764 | 764 | } |
765 | 765 | } |
@@ -775,15 +775,15 @@ discard block |
||
775 | 775 | * |
776 | 776 | * @return string The HTML description of the field. |
777 | 777 | */ |
778 | - public static function get_field_description( $value ) { |
|
778 | + public static function get_field_description($value) { |
|
779 | 779 | $description = ''; |
780 | 780 | |
781 | 781 | // Support for both 'description' and 'desc' args. |
782 | - $description_key = isset( $value['description'] ) ? 'description' : 'desc'; |
|
783 | - $value = ( isset( $value[ $description_key ] ) && ! empty( $value[ $description_key ] ) ) ? $value[ $description_key ] : ''; |
|
782 | + $description_key = isset($value['description']) ? 'description' : 'desc'; |
|
783 | + $value = (isset($value[$description_key]) && ! empty($value[$description_key])) ? $value[$description_key] : ''; |
|
784 | 784 | |
785 | - if ( ! empty( $value ) ) { |
|
786 | - $description = '<p class="give-field-description">' . wp_kses_post( $value ) . '</p>'; |
|
785 | + if ( ! empty($value)) { |
|
786 | + $description = '<p class="give-field-description">'.wp_kses_post($value).'</p>'; |
|
787 | 787 | } |
788 | 788 | |
789 | 789 | return $description; |
@@ -800,11 +800,11 @@ discard block |
||
800 | 800 | * |
801 | 801 | * @return array The description and tip as a 2 element array |
802 | 802 | */ |
803 | - public static function get_field_title( $value ) { |
|
804 | - $title = esc_html( $value['title'] ); |
|
803 | + public static function get_field_title($value) { |
|
804 | + $title = esc_html($value['title']); |
|
805 | 805 | |
806 | 806 | // If html tag detected then allow them to print. |
807 | - if ( strip_tags( $title ) ) { |
|
807 | + if (strip_tags($title)) { |
|
808 | 808 | $title = $value['title']; |
809 | 809 | } |
810 | 810 | |
@@ -823,8 +823,8 @@ discard block |
||
823 | 823 | * |
824 | 824 | * @return bool |
825 | 825 | */ |
826 | - public static function save_fields( $options, $option_name = '' ) { |
|
827 | - if ( empty( $_POST ) ) { |
|
826 | + public static function save_fields($options, $option_name = '') { |
|
827 | + if (empty($_POST)) { |
|
828 | 828 | return false; |
829 | 829 | } |
830 | 830 | |
@@ -832,37 +832,37 @@ discard block |
||
832 | 832 | $update_options = array(); |
833 | 833 | |
834 | 834 | // Loop options and get values to save. |
835 | - foreach ( $options as $option ) { |
|
836 | - if ( ! isset( $option['id'] ) || ! isset( $option['type'] ) ) { |
|
835 | + foreach ($options as $option) { |
|
836 | + if ( ! isset($option['id']) || ! isset($option['type'])) { |
|
837 | 837 | continue; |
838 | 838 | } |
839 | 839 | |
840 | 840 | // Get posted value. |
841 | - if ( strstr( $option['id'], '[' ) ) { |
|
842 | - parse_str( $option['id'], $option_name_array ); |
|
843 | - $field_option_name = current( array_keys( $option_name_array ) ); |
|
844 | - $setting_name = key( $option_name_array[ $field_option_name ] ); |
|
845 | - $raw_value = isset( $_POST[ $field_option_name ][ $setting_name ] ) ? wp_unslash( $_POST[ $field_option_name ][ $setting_name ] ) : null; |
|
841 | + if (strstr($option['id'], '[')) { |
|
842 | + parse_str($option['id'], $option_name_array); |
|
843 | + $field_option_name = current(array_keys($option_name_array)); |
|
844 | + $setting_name = key($option_name_array[$field_option_name]); |
|
845 | + $raw_value = isset($_POST[$field_option_name][$setting_name]) ? wp_unslash($_POST[$field_option_name][$setting_name]) : null; |
|
846 | 846 | } else { |
847 | 847 | $field_option_name = $option['id']; |
848 | 848 | $setting_name = ''; |
849 | - $raw_value = isset( $_POST[ $option['id'] ] ) ? wp_unslash( $_POST[ $option['id'] ] ) : null; |
|
849 | + $raw_value = isset($_POST[$option['id']]) ? wp_unslash($_POST[$option['id']]) : null; |
|
850 | 850 | } |
851 | 851 | |
852 | 852 | // Format the value based on option type. |
853 | - switch ( $option['type'] ) { |
|
853 | + switch ($option['type']) { |
|
854 | 854 | case 'checkbox' : |
855 | - $value = is_null( $raw_value ) ? '' : 'on'; |
|
855 | + $value = is_null($raw_value) ? '' : 'on'; |
|
856 | 856 | break; |
857 | 857 | case 'wysiwyg' : |
858 | 858 | case 'textarea' : |
859 | - $value = wp_kses_post( trim( $raw_value ) ); |
|
859 | + $value = wp_kses_post(trim($raw_value)); |
|
860 | 860 | break; |
861 | 861 | case 'multiselect' : |
862 | - $value = array_filter( array_map( 'give_clean', (array) $raw_value ) ); |
|
862 | + $value = array_filter(array_map('give_clean', (array) $raw_value)); |
|
863 | 863 | break; |
864 | 864 | default : |
865 | - $value = give_clean( $raw_value ); |
|
865 | + $value = give_clean($raw_value); |
|
866 | 866 | break; |
867 | 867 | } |
868 | 868 | |
@@ -871,37 +871,37 @@ discard block |
||
871 | 871 | * |
872 | 872 | * @since 1.8 |
873 | 873 | */ |
874 | - $value = apply_filters( 'give_admin_settings_sanitize_option', $value, $option, $raw_value ); |
|
874 | + $value = apply_filters('give_admin_settings_sanitize_option', $value, $option, $raw_value); |
|
875 | 875 | |
876 | 876 | /** |
877 | 877 | * Sanitize the value of an option by option name. |
878 | 878 | * |
879 | 879 | * @since 1.8 |
880 | 880 | */ |
881 | - $value = apply_filters( "give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value ); |
|
881 | + $value = apply_filters("give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value); |
|
882 | 882 | |
883 | - if ( is_null( $value ) ) { |
|
883 | + if (is_null($value)) { |
|
884 | 884 | continue; |
885 | 885 | } |
886 | 886 | |
887 | 887 | // Check if option is an array and handle that differently to single values. |
888 | - if ( $field_option_name && $setting_name ) { |
|
889 | - if ( ! isset( $update_options[ $field_option_name ] ) ) { |
|
890 | - $update_options[ $field_option_name ] = get_option( $field_option_name, array() ); |
|
888 | + if ($field_option_name && $setting_name) { |
|
889 | + if ( ! isset($update_options[$field_option_name])) { |
|
890 | + $update_options[$field_option_name] = get_option($field_option_name, array()); |
|
891 | 891 | } |
892 | - if ( ! is_array( $update_options[ $field_option_name ] ) ) { |
|
893 | - $update_options[ $field_option_name ] = array(); |
|
892 | + if ( ! is_array($update_options[$field_option_name])) { |
|
893 | + $update_options[$field_option_name] = array(); |
|
894 | 894 | } |
895 | - $update_options[ $field_option_name ][ $setting_name ] = $value; |
|
895 | + $update_options[$field_option_name][$setting_name] = $value; |
|
896 | 896 | } else { |
897 | - $update_options[ $field_option_name ] = $value; |
|
897 | + $update_options[$field_option_name] = $value; |
|
898 | 898 | } |
899 | 899 | } |
900 | 900 | |
901 | 901 | // Save all options in our array or there own option name i.e. option id. |
902 | - if ( empty( $option_name ) ) { |
|
903 | - foreach ( $update_options as $name => $value ) { |
|
904 | - update_option( $name, $value ); |
|
902 | + if (empty($option_name)) { |
|
903 | + foreach ($update_options as $name => $value) { |
|
904 | + update_option($name, $value); |
|
905 | 905 | |
906 | 906 | /** |
907 | 907 | * Trigger action. |
@@ -910,13 +910,13 @@ discard block |
||
910 | 910 | * |
911 | 911 | * @since 1.8 |
912 | 912 | */ |
913 | - do_action( "give_save_option_{$name}", $value, $name ); |
|
913 | + do_action("give_save_option_{$name}", $value, $name); |
|
914 | 914 | } |
915 | 915 | } else { |
916 | - $old_options = ( $old_options = get_option( $option_name ) ) ? $old_options : array(); |
|
917 | - $update_options = array_merge( $old_options, $update_options ); |
|
916 | + $old_options = ($old_options = get_option($option_name)) ? $old_options : array(); |
|
917 | + $update_options = array_merge($old_options, $update_options); |
|
918 | 918 | |
919 | - update_option( $option_name, $update_options ); |
|
919 | + update_option($option_name, $update_options); |
|
920 | 920 | |
921 | 921 | /** |
922 | 922 | * Trigger action. |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | * |
926 | 926 | * @since 1.8 |
927 | 927 | */ |
928 | - do_action( "give_save_settings_{$option_name}", $update_options, $option_name ); |
|
928 | + do_action("give_save_settings_{$option_name}", $update_options, $option_name); |
|
929 | 929 | } |
930 | 930 | |
931 | 931 | return true; |