| @@ -155,7 +155,7 @@ discard block | ||
| 155 | 155 | * | 
| 156 | 156 | * Used to redirect a user back to the donation form if there are errors present. | 
| 157 | 157 | * | 
| 158 | - * @param array|string $args | |
| 158 | + * @param string $args | |
| 159 | 159 | * | 
| 160 | 160 | * @access public | 
| 161 | 161 | * @since 1.0 | 
| @@ -301,7 +301,7 @@ discard block | ||
| 301 | 301 | * @since 1.0 | 
| 302 | 302 | * @since 1.8.16 Add security check | 
| 303 | 303 | * | 
| 304 | - * @return bool | |
| 304 | + * @return false|null | |
| 305 | 305 | */ | 
| 306 | 306 |  function give_listen_for_failed_payments() { | 
| 307 | 307 | |
| @@ -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,14 +23,14 @@ discard block | ||
| 23 | 23 | |
| 24 | 24 | global $typenow; | 
| 25 | 25 | |
| 26 | -	if ( $typenow != 'give_forms' ) { | |
| 26 | +	if ($typenow != 'give_forms') { | |
| 27 | 27 | return true; | 
| 28 | 28 | } | 
| 29 | 29 | |
| 30 | 30 | return false; | 
| 31 | 31 | } | 
| 32 | 32 | |
| 33 | -add_filter( 'give_shortcode_button_condition', 'give_shortcode_button_condition' ); | |
| 33 | +add_filter('give_shortcode_button_condition', 'give_shortcode_button_condition'); | |
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | /** | 
| @@ -40,11 +40,11 @@ discard block | ||
| 40 | 40 | * | 
| 41 | 41 | * @return int|false | 
| 42 | 42 | */ | 
| 43 | -function get_form_id_from_args( $args ) { | |
| 43 | +function get_form_id_from_args($args) { | |
| 44 | 44 | |
| 45 | -	if ( isset( $args['form_id'] ) && $args['form_id'] != 0 ) { | |
| 45 | +	if (isset($args['form_id']) && $args['form_id'] != 0) { | |
| 46 | 46 | |
| 47 | - return intval( $args['form_id'] ); | |
| 47 | + return intval($args['form_id']); | |
| 48 | 48 | } | 
| 49 | 49 | |
| 50 | 50 | return false; | 
| @@ -59,23 +59,23 @@ discard block | ||
| 59 | 59 | * | 
| 60 | 60 | * @return bool | 
| 61 | 61 | */ | 
| 62 | -function give_is_float_labels_enabled( $args ) { | |
| 62 | +function give_is_float_labels_enabled($args) { | |
| 63 | 63 | |
| 64 | 64 | $float_labels = ''; | 
| 65 | 65 | |
| 66 | -	if ( ! empty( $args['float_labels'] ) ) { | |
| 66 | +	if ( ! empty($args['float_labels'])) { | |
| 67 | 67 | $float_labels = $args['float_labels']; | 
| 68 | 68 | } | 
| 69 | 69 | |
| 70 | -	if ( empty( $float_labels ) ) { | |
| 71 | - $float_labels = give_get_meta( $args['form_id'], '_give_form_floating_labels', true ); | |
| 70 | +	if (empty($float_labels)) { | |
| 71 | + $float_labels = give_get_meta($args['form_id'], '_give_form_floating_labels', true); | |
| 72 | 72 | } | 
| 73 | 73 | |
| 74 | -	if ( empty( $float_labels ) || ( 'global' === $float_labels ) ) { | |
| 75 | - $float_labels = give_get_option( 'floatlabels', 'disabled' ); | |
| 74 | +	if (empty($float_labels) || ('global' === $float_labels)) { | |
| 75 | +		$float_labels = give_get_option('floatlabels', 'disabled'); | |
| 76 | 76 | } | 
| 77 | 77 | |
| 78 | - return give_is_setting_enabled( $float_labels ); | |
| 78 | + return give_is_setting_enabled($float_labels); | |
| 79 | 79 | } | 
| 80 | 80 | |
| 81 | 81 | /** | 
| @@ -91,7 +91,7 @@ discard block | ||
| 91 | 91 | |
| 92 | 92 | $can_checkout = true; | 
| 93 | 93 | |
| 94 | - return (bool) apply_filters( 'give_can_checkout', $can_checkout ); | |
| 94 | +	return (bool) apply_filters('give_can_checkout', $can_checkout); | |
| 95 | 95 | } | 
| 96 | 96 | |
| 97 | 97 | /** | 
| @@ -105,9 +105,9 @@ discard block | ||
| 105 | 105 |  function give_get_success_page_uri() { | 
| 106 | 106 | $give_options = give_get_settings(); | 
| 107 | 107 | |
| 108 | - $success_page = isset( $give_options['success_page'] ) ? get_permalink( absint( $give_options['success_page'] ) ) : get_bloginfo( 'url' ); | |
| 108 | +	$success_page = isset($give_options['success_page']) ? get_permalink(absint($give_options['success_page'])) : get_bloginfo('url'); | |
| 109 | 109 | |
| 110 | - return apply_filters( 'give_get_success_page_uri', $success_page ); | |
| 110 | +	return apply_filters('give_get_success_page_uri', $success_page); | |
| 111 | 111 | } | 
| 112 | 112 | |
| 113 | 113 | /** | 
| @@ -119,9 +119,9 @@ discard block | ||
| 119 | 119 | */ | 
| 120 | 120 |  function give_is_success_page() { | 
| 121 | 121 | $give_options = give_get_settings(); | 
| 122 | - $is_success_page = isset( $give_options['success_page'] ) ? is_page( $give_options['success_page'] ) : false; | |
| 122 | + $is_success_page = isset($give_options['success_page']) ? is_page($give_options['success_page']) : false; | |
| 123 | 123 | |
| 124 | - return apply_filters( 'give_is_success_page', $is_success_page ); | |
| 124 | +	return apply_filters('give_is_success_page', $is_success_page); | |
| 125 | 125 | } | 
| 126 | 126 | |
| 127 | 127 | /** | 
| @@ -135,17 +135,17 @@ discard block | ||
| 135 | 135 | * @since 1.0 | 
| 136 | 136 | * @return void | 
| 137 | 137 | */ | 
| 138 | -function give_send_to_success_page( $query_string = null ) { | |
| 138 | +function give_send_to_success_page($query_string = null) { | |
| 139 | 139 | |
| 140 | 140 | $redirect = give_get_success_page_uri(); | 
| 141 | 141 | |
| 142 | -	if ( $query_string ) { | |
| 142 | +	if ($query_string) { | |
| 143 | 143 | $redirect .= $query_string; | 
| 144 | 144 | } | 
| 145 | 145 | |
| 146 | - $gateway = isset( $_REQUEST['give-gateway'] ) ? $_REQUEST['give-gateway'] : ''; | |
| 146 | + $gateway = isset($_REQUEST['give-gateway']) ? $_REQUEST['give-gateway'] : ''; | |
| 147 | 147 | |
| 148 | - wp_redirect( apply_filters( 'give_success_page_redirect', $redirect, $gateway, $query_string ) ); | |
| 148 | +	wp_redirect(apply_filters('give_success_page_redirect', $redirect, $gateway, $query_string)); | |
| 149 | 149 | give_die(); | 
| 150 | 150 | } | 
| 151 | 151 | |
| @@ -161,19 +161,19 @@ discard block | ||
| 161 | 161 | * @since 1.0 | 
| 162 | 162 | * @return Void | 
| 163 | 163 | */ | 
| 164 | -function give_send_back_to_checkout( $args = array() ) { | |
| 164 | +function give_send_back_to_checkout($args = array()) { | |
| 165 | 165 | |
| 166 | - $url = isset( $_POST['give-current-url'] ) ? sanitize_text_field( $_POST['give-current-url'] ) : ''; | |
| 166 | + $url = isset($_POST['give-current-url']) ? sanitize_text_field($_POST['give-current-url']) : ''; | |
| 167 | 167 | $form_id = 0; | 
| 168 | 168 | |
| 169 | 169 | // Set the form_id. | 
| 170 | -	if ( isset( $_POST['give-form-id'] ) ) { | |
| 171 | - $form_id = sanitize_text_field( $_POST['give-form-id'] ); | |
| 170 | +	if (isset($_POST['give-form-id'])) { | |
| 171 | + $form_id = sanitize_text_field($_POST['give-form-id']); | |
| 172 | 172 | } | 
| 173 | 173 | |
| 174 | 174 | // Need a URL to continue. If none, redirect back to single form. | 
| 175 | -	if ( empty( $url ) ) { | |
| 176 | - wp_safe_redirect( get_permalink( $form_id ) ); | |
| 175 | +	if (empty($url)) { | |
| 176 | + wp_safe_redirect(get_permalink($form_id)); | |
| 177 | 177 | give_die(); | 
| 178 | 178 | } | 
| 179 | 179 | |
| @@ -182,41 +182,41 @@ discard block | ||
| 182 | 182 | ); | 
| 183 | 183 | |
| 184 | 184 | // Set the $level_id. | 
| 185 | -	if ( isset( $_POST['give-price-id'] ) ) { | |
| 186 | - $defaults['level-id'] = sanitize_text_field( $_POST['give-price-id'] ); | |
| 185 | +	if (isset($_POST['give-price-id'])) { | |
| 186 | + $defaults['level-id'] = sanitize_text_field($_POST['give-price-id']); | |
| 187 | 187 | } | 
| 188 | 188 | |
| 189 | 189 | // Check for backward compatibility. | 
| 190 | -	if ( is_string( $args ) ) { | |
| 191 | - $args = str_replace( '?', '', $args ); | |
| 190 | +	if (is_string($args)) { | |
| 191 | +		$args = str_replace('?', '', $args); | |
| 192 | 192 | } | 
| 193 | 193 | |
| 194 | - $args = wp_parse_args( $args, $defaults ); | |
| 194 | + $args = wp_parse_args($args, $defaults); | |
| 195 | 195 | |
| 196 | 196 | // Merge URL query with $args to maintain third-party URL parameters after redirect. | 
| 197 | - $url_data = wp_parse_url( $url ); | |
| 197 | + $url_data = wp_parse_url($url); | |
| 198 | 198 | |
| 199 | 199 | // Check if an array to prevent notices before parsing. | 
| 200 | -	if ( isset( $url_data['query'] ) && ! empty( $url_data['query'] ) ) { | |
| 201 | - parse_str( $url_data['query'], $query ); | |
| 200 | +	if (isset($url_data['query']) && ! empty($url_data['query'])) { | |
| 201 | + parse_str($url_data['query'], $query); | |
| 202 | 202 | |
| 203 | 203 | // Precaution: don't allow any CC info. | 
| 204 | - unset( $query['card_number'] ); | |
| 205 | - unset( $query['card_cvc'] ); | |
| 204 | + unset($query['card_number']); | |
| 205 | + unset($query['card_cvc']); | |
| 206 | 206 | |
| 207 | 207 |  	} else { | 
| 208 | 208 | // No $url_data so pass empty array. | 
| 209 | 209 | $query = array(); | 
| 210 | 210 | } | 
| 211 | 211 | |
| 212 | - $new_query = array_merge( $args, $query ); | |
| 213 | - $new_query_string = http_build_query( $new_query ); | |
| 212 | + $new_query = array_merge($args, $query); | |
| 213 | + $new_query_string = http_build_query($new_query); | |
| 214 | 214 | |
| 215 | 215 | // Assemble URL parts. | 
| 216 | - $redirect = home_url( '/' . $url_data['path'] . '?' . $new_query_string . '#give-form-' . $form_id . '-wrap' ); | |
| 216 | +	$redirect = home_url('/'.$url_data['path'].'?'.$new_query_string.'#give-form-'.$form_id.'-wrap'); | |
| 217 | 217 | |
| 218 | 218 | // Redirect them. | 
| 219 | - wp_safe_redirect( apply_filters( 'give_send_back_to_checkout', $redirect, $args ) ); | |
| 219 | +	wp_safe_redirect(apply_filters('give_send_back_to_checkout', $redirect, $args)); | |
| 220 | 220 | give_die(); | 
| 221 | 221 | |
| 222 | 222 | } | 
| @@ -232,16 +232,16 @@ discard block | ||
| 232 | 232 | * @since 1.0 | 
| 233 | 233 | * @return string | 
| 234 | 234 | */ | 
| 235 | -function give_get_success_page_url( $query_string = null ) { | |
| 235 | +function give_get_success_page_url($query_string = null) { | |
| 236 | 236 | |
| 237 | - $success_page = give_get_option( 'success_page', 0 ); | |
| 238 | - $success_page = get_permalink( $success_page ); | |
| 237 | +	$success_page = give_get_option('success_page', 0); | |
| 238 | + $success_page = get_permalink($success_page); | |
| 239 | 239 | |
| 240 | -	if ( $query_string ) { | |
| 240 | +	if ($query_string) { | |
| 241 | 241 | $success_page .= $query_string; | 
| 242 | 242 | } | 
| 243 | 243 | |
| 244 | - return apply_filters( 'give_success_page_url', $success_page ); | |
| 244 | +	return apply_filters('give_success_page_url', $success_page); | |
| 245 | 245 | |
| 246 | 246 | } | 
| 247 | 247 | |
| @@ -254,32 +254,31 @@ discard block | ||
| 254 | 254 | * | 
| 255 | 255 | * @return mixed Full URL to the Failed Donation Page, if present, home page if it doesn't exist. | 
| 256 | 256 | */ | 
| 257 | -function give_get_failed_transaction_uri( $extras = false ) { | |
| 257 | +function give_get_failed_transaction_uri($extras = false) { | |
| 258 | 258 | $give_options = give_get_settings(); | 
| 259 | 259 | |
| 260 | 260 | // Remove question mark. | 
| 261 | -	if ( 0 === strpos( $extras, '?' ) ) { | |
| 262 | - $extras = substr( $extras, 1 ); | |
| 261 | +	if (0 === strpos($extras, '?')) { | |
| 262 | + $extras = substr($extras, 1); | |
| 263 | 263 | } | 
| 264 | 264 | |
| 265 | - $extras_args = wp_parse_args( $extras ); | |
| 265 | + $extras_args = wp_parse_args($extras); | |
| 266 | 266 | |
| 267 | 267 | // Set nonce if payment id exist in extra params. | 
| 268 | -	if ( array_key_exists( 'payment-id', $extras_args ) ) { | |
| 269 | -		$extras_args['_wpnonce'] = wp_create_nonce( "give-failed-donation-{$extras_args['payment-id']}" ); | |
| 270 | - $extras = http_build_query( $extras_args ); | |
| 268 | +	if (array_key_exists('payment-id', $extras_args)) { | |
| 269 | +		$extras_args['_wpnonce'] = wp_create_nonce("give-failed-donation-{$extras_args['payment-id']}"); | |
| 270 | + $extras = http_build_query($extras_args); | |
| 271 | 271 | } | 
| 272 | 272 | |
| 273 | - $uri = ! empty( $give_options['failure_page'] ) ? | |
| 274 | - trailingslashit( get_permalink( $give_options['failure_page'] ) ) : | |
| 275 | - home_url(); | |
| 273 | + $uri = ! empty($give_options['failure_page']) ? | |
| 274 | + trailingslashit(get_permalink($give_options['failure_page'])) : home_url(); | |
| 276 | 275 | |
| 277 | 276 | |
| 278 | -	if ( $extras ) { | |
| 277 | +	if ($extras) { | |
| 279 | 278 |  		$uri .= "?{$extras}"; | 
| 280 | 279 | } | 
| 281 | 280 | |
| 282 | - return apply_filters( 'give_get_failed_transaction_uri', $uri ); | |
| 281 | +	return apply_filters('give_get_failed_transaction_uri', $uri); | |
| 283 | 282 | } | 
| 284 | 283 | |
| 285 | 284 | /** | 
| @@ -290,9 +289,9 @@ discard block | ||
| 290 | 289 | */ | 
| 291 | 290 |  function give_is_failed_transaction_page() { | 
| 292 | 291 | $give_options = give_get_settings(); | 
| 293 | - $ret = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false; | |
| 292 | + $ret = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false; | |
| 294 | 293 | |
| 295 | - return apply_filters( 'give_is_failure_page', $ret ); | |
| 294 | +	return apply_filters('give_is_failure_page', $ret); | |
| 296 | 295 | } | 
| 297 | 296 | |
| 298 | 297 | /** | 
| @@ -305,25 +304,25 @@ discard block | ||
| 305 | 304 | */ | 
| 306 | 305 |  function give_listen_for_failed_payments() { | 
| 307 | 306 | |
| 308 | - $failed_page = give_get_option( 'failure_page', 0 ); | |
| 309 | - $payment_id = ! empty( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : 0; | |
| 310 | - $nonce = ! empty( $_GET['_wpnonce'] ) ? give_clean( $_GET['_wpnonce'] ) : false; | |
| 307 | +	$failed_page = give_get_option('failure_page', 0); | |
| 308 | + $payment_id = ! empty($_GET['payment-id']) ? absint($_GET['payment-id']) : 0; | |
| 309 | + $nonce = ! empty($_GET['_wpnonce']) ? give_clean($_GET['_wpnonce']) : false; | |
| 311 | 310 | |
| 312 | 311 | // Bailout. | 
| 313 | -	if ( ! $failed_page || ! is_page( $failed_page ) || ! $payment_id || ! $nonce ) { | |
| 312 | +	if ( ! $failed_page || ! is_page($failed_page) || ! $payment_id || ! $nonce) { | |
| 314 | 313 | return false; | 
| 315 | 314 | } | 
| 316 | 315 | |
| 317 | 316 | // Security check. | 
| 318 | -	if ( ! wp_verify_nonce( $nonce, "give-failed-donation-{$payment_id}" ) ) { | |
| 319 | - wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ) ); | |
| 317 | +	if ( ! wp_verify_nonce($nonce, "give-failed-donation-{$payment_id}")) { | |
| 318 | +		wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give')); | |
| 320 | 319 | } | 
| 321 | 320 | |
| 322 | 321 | // Set payment status to failure | 
| 323 | - give_update_payment_status( $payment_id, 'failed' ); | |
| 322 | + give_update_payment_status($payment_id, 'failed'); | |
| 324 | 323 | } | 
| 325 | 324 | |
| 326 | -add_action( 'template_redirect', 'give_listen_for_failed_payments' ); | |
| 325 | +add_action('template_redirect', 'give_listen_for_failed_payments'); | |
| 327 | 326 | |
| 328 | 327 | /** | 
| 329 | 328 | * Retrieve the Donation History page URI | 
| @@ -336,9 +335,9 @@ discard block | ||
| 336 | 335 |  function give_get_history_page_uri() { | 
| 337 | 336 | $give_options = give_get_settings(); | 
| 338 | 337 | |
| 339 | - $history_page = isset( $give_options['history_page'] ) ? get_permalink( absint( $give_options['history_page'] ) ) : get_bloginfo( 'url' ); | |
| 338 | +	$history_page = isset($give_options['history_page']) ? get_permalink(absint($give_options['history_page'])) : get_bloginfo('url'); | |
| 340 | 339 | |
| 341 | - return apply_filters( 'give_get_history_page_uri', $history_page ); | |
| 340 | +	return apply_filters('give_get_history_page_uri', $history_page); | |
| 342 | 341 | } | 
| 343 | 342 | |
| 344 | 343 | /** | 
| @@ -351,11 +350,11 @@ discard block | ||
| 351 | 350 | * @since 1.0 | 
| 352 | 351 | * @return bool | 
| 353 | 352 | */ | 
| 354 | -function give_field_is_required( $field = '', $form_id ) { | |
| 353 | +function give_field_is_required($field = '', $form_id) { | |
| 355 | 354 | |
| 356 | - $required_fields = give_get_required_fields( $form_id ); | |
| 355 | + $required_fields = give_get_required_fields($form_id); | |
| 357 | 356 | |
| 358 | - return array_key_exists( $field, $required_fields ); | |
| 357 | + return array_key_exists($field, $required_fields); | |
| 359 | 358 | } | 
| 360 | 359 | |
| 361 | 360 | /** | 
| @@ -372,12 +371,12 @@ discard block | ||
| 372 | 371 | * | 
| 373 | 372 | * @return void | 
| 374 | 373 | */ | 
| 375 | -function give_record_donation_in_log( $give_form_id = 0, $payment_id, $price_id = false, $donation_date = null ) { | |
| 374 | +function give_record_donation_in_log($give_form_id = 0, $payment_id, $price_id = false, $donation_date = null) { | |
| 376 | 375 | $log_data = array( | 
| 377 | 376 | 'log_parent' => $payment_id, | 
| 378 | 377 | 'log_type' => 'sale', | 
| 379 | - 'log_date' => isset( $donation_date ) ? $donation_date : null, | |
| 380 | - 'log_date_gmt' => isset( $donation_date ) ? $donation_date : null, | |
| 378 | + 'log_date' => isset($donation_date) ? $donation_date : null, | |
| 379 | + 'log_date_gmt' => isset($donation_date) ? $donation_date : null, | |
| 381 | 380 | ); | 
| 382 | 381 | |
| 383 | 382 | $log_meta = array( | 
| @@ -385,7 +384,7 @@ discard block | ||
| 385 | 384 | 'price_id' => (int) $price_id, | 
| 386 | 385 | ); | 
| 387 | 386 | |
| 388 | - Give()->logs->insert_log( $log_data, $log_meta ); | |
| 387 | + Give()->logs->insert_log($log_data, $log_meta); | |
| 389 | 388 | } | 
| 390 | 389 | |
| 391 | 390 | |
| @@ -399,13 +398,13 @@ discard block | ||
| 399 | 398 | * | 
| 400 | 399 | * @return bool|int | 
| 401 | 400 | */ | 
| 402 | -function give_increase_donation_count( $form_id = 0, $quantity = 1 ) { | |
| 401 | +function give_increase_donation_count($form_id = 0, $quantity = 1) { | |
| 403 | 402 | $quantity = (int) $quantity; | 
| 404 | 403 | |
| 405 | 404 | /** @var \Give_Donate_Form $form */ | 
| 406 | - $form = new Give_Donate_Form( $form_id ); | |
| 405 | + $form = new Give_Donate_Form($form_id); | |
| 407 | 406 | |
| 408 | - return $form->increase_sales( $quantity ); | |
| 407 | + return $form->increase_sales($quantity); | |
| 409 | 408 | } | 
| 410 | 409 | |
| 411 | 410 | /** | 
| @@ -418,13 +417,13 @@ discard block | ||
| 418 | 417 | * | 
| 419 | 418 | * @return bool|int | 
| 420 | 419 | */ | 
| 421 | -function give_decrease_donation_count( $form_id = 0, $quantity = 1 ) { | |
| 420 | +function give_decrease_donation_count($form_id = 0, $quantity = 1) { | |
| 422 | 421 | $quantity = (int) $quantity; | 
| 423 | 422 | |
| 424 | 423 | /** @var \Give_Donate_Form $form */ | 
| 425 | - $form = new Give_Donate_Form( $form_id ); | |
| 424 | + $form = new Give_Donate_Form($form_id); | |
| 426 | 425 | |
| 427 | - return $form->decrease_sales( $quantity ); | |
| 426 | + return $form->decrease_sales($quantity); | |
| 428 | 427 | } | 
| 429 | 428 | |
| 430 | 429 | /** | 
| @@ -440,11 +439,11 @@ discard block | ||
| 440 | 439 | * | 
| 441 | 440 | * @return bool|int | 
| 442 | 441 | */ | 
| 443 | -function give_increase_earnings( $give_form_id = 0, $amount, $payment_id = 0 ) { | |
| 442 | +function give_increase_earnings($give_form_id = 0, $amount, $payment_id = 0) { | |
| 444 | 443 | /** @var \Give_Donate_Form $form */ | 
| 445 | - $form = new Give_Donate_Form( $give_form_id ); | |
| 444 | + $form = new Give_Donate_Form($give_form_id); | |
| 446 | 445 | |
| 447 | - return $form->increase_earnings( $amount, $payment_id ); | |
| 446 | + return $form->increase_earnings($amount, $payment_id); | |
| 448 | 447 | } | 
| 449 | 448 | |
| 450 | 449 | /** | 
| @@ -462,11 +461,11 @@ discard block | ||
| 462 | 461 | * | 
| 463 | 462 | * @return bool|int | 
| 464 | 463 | */ | 
| 465 | -function give_decrease_form_earnings( $form_id = 0, $amount, $payment_id = 0 ) { | |
| 464 | +function give_decrease_form_earnings($form_id = 0, $amount, $payment_id = 0) { | |
| 466 | 465 | /** @var \Give_Donate_Form $form */ | 
| 467 | - $form = new Give_Donate_Form( $form_id ); | |
| 466 | + $form = new Give_Donate_Form($form_id); | |
| 468 | 467 | |
| 469 | - return $form->decrease_earnings( $amount, $payment_id ); | |
| 468 | + return $form->decrease_earnings($amount, $payment_id); | |
| 470 | 469 | } | 
| 471 | 470 | |
| 472 | 471 | |
| @@ -479,15 +478,15 @@ discard block | ||
| 479 | 478 | * | 
| 480 | 479 | * @return int $earnings Earnings for a certain form | 
| 481 | 480 | */ | 
| 482 | -function give_get_form_earnings_stats( $form_id = 0 ) { | |
| 483 | - $give_form = new Give_Donate_Form( $form_id ); | |
| 481 | +function give_get_form_earnings_stats($form_id = 0) { | |
| 482 | + $give_form = new Give_Donate_Form($form_id); | |
| 484 | 483 | |
| 485 | 484 | /** | 
| 486 | 485 | * Filter the form earnings | 
| 487 | 486 | * | 
| 488 | 487 | * @since 1.8.17 | 
| 489 | 488 | */ | 
| 490 | - return apply_filters( 'give_get_form_earnings_stats', $give_form->earnings, $form_id, $give_form ); | |
| 489 | +	return apply_filters('give_get_form_earnings_stats', $give_form->earnings, $form_id, $give_form); | |
| 491 | 490 | } | 
| 492 | 491 | |
| 493 | 492 | |
| @@ -500,8 +499,8 @@ discard block | ||
| 500 | 499 | * | 
| 501 | 500 | * @return int $sales Amount of sales for a certain form | 
| 502 | 501 | */ | 
| 503 | -function give_get_form_sales_stats( $give_form_id = 0 ) { | |
| 504 | - $give_form = new Give_Donate_Form( $give_form_id ); | |
| 502 | +function give_get_form_sales_stats($give_form_id = 0) { | |
| 503 | + $give_form = new Give_Donate_Form($give_form_id); | |
| 505 | 504 | |
| 506 | 505 | return $give_form->sales; | 
| 507 | 506 | } | 
| @@ -516,16 +515,16 @@ discard block | ||
| 516 | 515 | * | 
| 517 | 516 | * @return float $sales Average monthly sales | 
| 518 | 517 | */ | 
| 519 | -function give_get_average_monthly_form_sales( $form_id = 0 ) { | |
| 520 | - $sales = give_get_form_sales_stats( $form_id ); | |
| 521 | - $release_date = get_post_field( 'post_date', $form_id ); | |
| 518 | +function give_get_average_monthly_form_sales($form_id = 0) { | |
| 519 | + $sales = give_get_form_sales_stats($form_id); | |
| 520 | +	$release_date = get_post_field('post_date', $form_id); | |
| 522 | 521 | |
| 523 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); | |
| 522 | +	$diff = abs(current_time('timestamp') - strtotime($release_date)); | |
| 524 | 523 | |
| 525 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication | |
| 524 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication | |
| 526 | 525 | |
| 527 | -	if ( $months > 0 ) { | |
| 528 | - $sales = ( $sales / $months ); | |
| 526 | +	if ($months > 0) { | |
| 527 | + $sales = ($sales / $months); | |
| 529 | 528 | } | 
| 530 | 529 | |
| 531 | 530 | return $sales; | 
| @@ -541,16 +540,16 @@ discard block | ||
| 541 | 540 | * | 
| 542 | 541 | * @return float $earnings Average monthly earnings | 
| 543 | 542 | */ | 
| 544 | -function give_get_average_monthly_form_earnings( $form_id = 0 ) { | |
| 545 | - $earnings = give_get_form_earnings_stats( $form_id ); | |
| 546 | - $release_date = get_post_field( 'post_date', $form_id ); | |
| 543 | +function give_get_average_monthly_form_earnings($form_id = 0) { | |
| 544 | + $earnings = give_get_form_earnings_stats($form_id); | |
| 545 | +	$release_date = get_post_field('post_date', $form_id); | |
| 547 | 546 | |
| 548 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); | |
| 547 | +	$diff = abs(current_time('timestamp') - strtotime($release_date)); | |
| 549 | 548 | |
| 550 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication | |
| 549 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication | |
| 551 | 550 | |
| 552 | -	if ( $months > 0 ) { | |
| 553 | - $earnings = ( $earnings / $months ); | |
| 551 | +	if ($months > 0) { | |
| 552 | + $earnings = ($earnings / $months); | |
| 554 | 553 | } | 
| 555 | 554 | |
| 556 | 555 | return $earnings < 0 ? 0 : $earnings; | 
| @@ -571,34 +570,34 @@ discard block | ||
| 571 | 570 | * | 
| 572 | 571 | * @return string $price_name Name of the price option | 
| 573 | 572 | */ | 
| 574 | -function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0, $use_fallback = true ) { | |
| 573 | +function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0, $use_fallback = true) { | |
| 575 | 574 | |
| 576 | - $prices = give_get_variable_prices( $form_id ); | |
| 575 | + $prices = give_get_variable_prices($form_id); | |
| 577 | 576 | $price_name = ''; | 
| 578 | 577 | |
| 579 | -	if ( false === $prices ) { | |
| 578 | +	if (false === $prices) { | |
| 580 | 579 | return $price_name; | 
| 581 | 580 | } | 
| 582 | 581 | |
| 583 | -	foreach ( $prices as $price ) { | |
| 582 | +	foreach ($prices as $price) { | |
| 584 | 583 | |
| 585 | -		if ( intval( $price['_give_id']['level_id'] ) === intval( $price_id ) ) { | |
| 584 | +		if (intval($price['_give_id']['level_id']) === intval($price_id)) { | |
| 586 | 585 | |
| 587 | - $price_text = isset( $price['_give_text'] ) ? $price['_give_text'] : ''; | |
| 586 | + $price_text = isset($price['_give_text']) ? $price['_give_text'] : ''; | |
| 588 | 587 | $price_fallback = $use_fallback ? | 
| 589 | 588 | give_currency_filter( | 
| 590 | 589 | give_format_amount( | 
| 591 | 590 | $price['_give_amount'], | 
| 592 | - array( 'sanitize' => false ) | |
| 591 | +						array('sanitize' => false) | |
| 593 | 592 | ), | 
| 594 | - array( 'decode_currency' => true ) | |
| 593 | +					array('decode_currency' => true) | |
| 595 | 594 | ) : ''; | 
| 596 | - $price_name = ! empty( $price_text ) ? $price_text : $price_fallback; | |
| 595 | + $price_name = ! empty($price_text) ? $price_text : $price_fallback; | |
| 597 | 596 | |
| 598 | 597 | } | 
| 599 | 598 | } | 
| 600 | 599 | |
| 601 | - return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id ); | |
| 600 | +	return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id); | |
| 602 | 601 | } | 
| 603 | 602 | |
| 604 | 603 | |
| @@ -612,25 +611,25 @@ discard block | ||
| 612 | 611 | * | 
| 613 | 612 | * @return string $range A fully formatted price range | 
| 614 | 613 | */ | 
| 615 | -function give_price_range( $form_id = 0, $formatted = true ) { | |
| 616 | - $low = give_get_lowest_price_option( $form_id ); | |
| 617 | - $high = give_get_highest_price_option( $form_id ); | |
| 618 | - $order_type = ! empty( $_REQUEST['order'] ) ? $_REQUEST['order'] : 'asc'; | |
| 614 | +function give_price_range($form_id = 0, $formatted = true) { | |
| 615 | + $low = give_get_lowest_price_option($form_id); | |
| 616 | + $high = give_get_highest_price_option($form_id); | |
| 617 | + $order_type = ! empty($_REQUEST['order']) ? $_REQUEST['order'] : 'asc'; | |
| 619 | 618 | |
| 620 | 619 | $range = sprintf( | 
| 621 | 620 | '<span class="give_price_range_%1$s">%2$s</span><span class="give_price_range_sep"> – </span><span class="give_price_range_%3$s">%4$s</span>', | 
| 622 | 621 | 'asc' === $order_type ? 'low' : 'high', | 
| 623 | - 'asc' === $order_type ? give_currency_filter( give_format_amount( $low, array( 'sanitize' => false ) ) ) : give_currency_filter( give_format_amount( $high, array( 'sanitize' => false ) ) ), | |
| 622 | +		'asc' === $order_type ? give_currency_filter(give_format_amount($low, array('sanitize' => false))) : give_currency_filter(give_format_amount($high, array('sanitize' => false))), | |
| 624 | 623 | 'asc' === $order_type ? 'high' : 'low', | 
| 625 | - 'asc' === $order_type ? give_currency_filter( give_format_amount( $high, array( 'sanitize' => false ) ) ) : give_currency_filter( give_format_amount( $low, array( 'sanitize' => false ) ) ) | |
| 624 | +		'asc' === $order_type ? give_currency_filter(give_format_amount($high, array('sanitize' => false))) : give_currency_filter(give_format_amount($low, array('sanitize' => false))) | |
| 626 | 625 | |
| 627 | 626 | ); | 
| 628 | 627 | |
| 629 | -	if ( ! $formatted ) { | |
| 630 | - $range = wp_strip_all_tags( $range ); | |
| 628 | +	if ( ! $formatted) { | |
| 629 | + $range = wp_strip_all_tags($range); | |
| 631 | 630 | } | 
| 632 | 631 | |
| 633 | - return apply_filters( 'give_price_range', $range, $form_id, $low, $high ); | |
| 632 | +	return apply_filters('give_price_range', $range, $form_id, $low, $high); | |
| 634 | 633 | } | 
| 635 | 634 | |
| 636 | 635 | |
| @@ -645,35 +644,35 @@ discard block | ||
| 645 | 644 | * | 
| 646 | 645 | * @return int ID of the lowest price | 
| 647 | 646 | */ | 
| 648 | -function give_get_lowest_price_id( $form_id = 0 ) { | |
| 647 | +function give_get_lowest_price_id($form_id = 0) { | |
| 649 | 648 | |
| 650 | -	if ( empty( $form_id ) ) { | |
| 649 | +	if (empty($form_id)) { | |
| 651 | 650 | $form_id = get_the_ID(); | 
| 652 | 651 | } | 
| 653 | 652 | |
| 654 | -	if ( ! give_has_variable_prices( $form_id ) ) { | |
| 655 | - return give_get_form_price( $form_id ); | |
| 653 | +	if ( ! give_has_variable_prices($form_id)) { | |
| 654 | + return give_get_form_price($form_id); | |
| 656 | 655 | } | 
| 657 | 656 | |
| 658 | - $prices = give_get_variable_prices( $form_id ); | |
| 657 | + $prices = give_get_variable_prices($form_id); | |
| 659 | 658 | |
| 660 | 659 | $min = $min_id = 0; | 
| 661 | 660 | |
| 662 | -	if ( ! empty( $prices ) ) { | |
| 661 | +	if ( ! empty($prices)) { | |
| 663 | 662 | |
| 664 | -		foreach ( $prices as $key => $price ) { | |
| 663 | +		foreach ($prices as $key => $price) { | |
| 665 | 664 | |
| 666 | -			if ( empty( $price['_give_amount'] ) ) { | |
| 665 | +			if (empty($price['_give_amount'])) { | |
| 667 | 666 | continue; | 
| 668 | 667 | } | 
| 669 | 668 | |
| 670 | -			if ( ! isset( $min ) ) { | |
| 669 | +			if ( ! isset($min)) { | |
| 671 | 670 | $min = $price['_give_amount']; | 
| 672 | 671 |  			} else { | 
| 673 | - $min = min( $min, $price['_give_amount'] ); | |
| 672 | + $min = min($min, $price['_give_amount']); | |
| 674 | 673 | } | 
| 675 | 674 | |
| 676 | -			if ( $price['_give_amount'] == $min ) { | |
| 675 | +			if ($price['_give_amount'] == $min) { | |
| 677 | 676 | $min_id = $price['_give_id']['level_id']; | 
| 678 | 677 | } | 
| 679 | 678 | } | 
| @@ -691,22 +690,22 @@ discard block | ||
| 691 | 690 | * | 
| 692 | 691 | * @return float Amount of the lowest price | 
| 693 | 692 | */ | 
| 694 | -function give_get_lowest_price_option( $form_id = 0 ) { | |
| 695 | -	if ( empty( $form_id ) ) { | |
| 693 | +function give_get_lowest_price_option($form_id = 0) { | |
| 694 | +	if (empty($form_id)) { | |
| 696 | 695 | $form_id = get_the_ID(); | 
| 697 | 696 | } | 
| 698 | 697 | |
| 699 | -	if ( ! give_has_variable_prices( $form_id ) ) { | |
| 700 | - return give_get_form_price( $form_id ); | |
| 698 | +	if ( ! give_has_variable_prices($form_id)) { | |
| 699 | + return give_get_form_price($form_id); | |
| 701 | 700 | } | 
| 702 | 701 | |
| 703 | -	if ( ! ( $low = get_post_meta( $form_id, '_give_levels_minimum_amount', true ) ) ) { | |
| 702 | +	if ( ! ($low = get_post_meta($form_id, '_give_levels_minimum_amount', true))) { | |
| 704 | 703 | // Backward compatibility. | 
| 705 | - $prices = wp_list_pluck( give_get_variable_prices( $form_id ), '_give_amount' ); | |
| 706 | - $low = ! empty( $prices ) ? min( $prices ) : 0; | |
| 704 | + $prices = wp_list_pluck(give_get_variable_prices($form_id), '_give_amount'); | |
| 705 | + $low = ! empty($prices) ? min($prices) : 0; | |
| 707 | 706 | } | 
| 708 | 707 | |
| 709 | - return give_maybe_sanitize_amount( $low ); | |
| 708 | + return give_maybe_sanitize_amount($low); | |
| 710 | 709 | } | 
| 711 | 710 | |
| 712 | 711 | /** | 
| @@ -718,23 +717,23 @@ discard block | ||
| 718 | 717 | * | 
| 719 | 718 | * @return float Amount of the highest price | 
| 720 | 719 | */ | 
| 721 | -function give_get_highest_price_option( $form_id = 0 ) { | |
| 720 | +function give_get_highest_price_option($form_id = 0) { | |
| 722 | 721 | |
| 723 | -	if ( empty( $form_id ) ) { | |
| 722 | +	if (empty($form_id)) { | |
| 724 | 723 | $form_id = get_the_ID(); | 
| 725 | 724 | } | 
| 726 | 725 | |
| 727 | -	if ( ! give_has_variable_prices( $form_id ) ) { | |
| 728 | - return give_get_form_price( $form_id ); | |
| 726 | +	if ( ! give_has_variable_prices($form_id)) { | |
| 727 | + return give_get_form_price($form_id); | |
| 729 | 728 | } | 
| 730 | 729 | |
| 731 | -	if ( ! ( $high = get_post_meta( $form_id, '_give_levels_maximum_amount', true ) ) ) { | |
| 730 | +	if ( ! ($high = get_post_meta($form_id, '_give_levels_maximum_amount', true))) { | |
| 732 | 731 | // Backward compatibility. | 
| 733 | - $prices = wp_list_pluck( give_get_variable_prices( $form_id ), '_give_amount' ); | |
| 734 | - $high = ! empty( $prices ) ? max( $prices ) : 0; | |
| 732 | + $prices = wp_list_pluck(give_get_variable_prices($form_id), '_give_amount'); | |
| 733 | + $high = ! empty($prices) ? max($prices) : 0; | |
| 735 | 734 | } | 
| 736 | 735 | |
| 737 | - return give_maybe_sanitize_amount( $high ); | |
| 736 | + return give_maybe_sanitize_amount($high); | |
| 738 | 737 | } | 
| 739 | 738 | |
| 740 | 739 | /** | 
| @@ -746,15 +745,15 @@ discard block | ||
| 746 | 745 | * | 
| 747 | 746 | * @return mixed string|int Price of the form | 
| 748 | 747 | */ | 
| 749 | -function give_get_form_price( $form_id = 0 ) { | |
| 748 | +function give_get_form_price($form_id = 0) { | |
| 750 | 749 | |
| 751 | -	if ( empty( $form_id ) ) { | |
| 750 | +	if (empty($form_id)) { | |
| 752 | 751 | return false; | 
| 753 | 752 | } | 
| 754 | 753 | |
| 755 | - $form = new Give_Donate_Form( $form_id ); | |
| 754 | + $form = new Give_Donate_Form($form_id); | |
| 756 | 755 | |
| 757 | - return $form->__get( 'price' ); | |
| 756 | +	return $form->__get('price'); | |
| 758 | 757 | } | 
| 759 | 758 | |
| 760 | 759 | /** | 
| @@ -766,13 +765,13 @@ discard block | ||
| 766 | 765 | * | 
| 767 | 766 | * @return mixed string|int Minimum price of the form | 
| 768 | 767 | */ | 
| 769 | -function give_get_form_minimum_price( $form_id = 0 ) { | |
| 768 | +function give_get_form_minimum_price($form_id = 0) { | |
| 770 | 769 | |
| 771 | -	if ( empty( $form_id ) ) { | |
| 770 | +	if (empty($form_id)) { | |
| 772 | 771 | return false; | 
| 773 | 772 | } | 
| 774 | 773 | |
| 775 | - $form = new Give_Donate_Form( $form_id ); | |
| 774 | + $form = new Give_Donate_Form($form_id); | |
| 776 | 775 | |
| 777 | 776 | return $form->get_minimum_price(); | 
| 778 | 777 | |
| @@ -787,13 +786,13 @@ discard block | ||
| 787 | 786 | * | 
| 788 | 787 | * @return bool|float | 
| 789 | 788 | */ | 
| 790 | -function give_get_form_maximum_price( $form_id = 0 ) { | |
| 789 | +function give_get_form_maximum_price($form_id = 0) { | |
| 791 | 790 | |
| 792 | -	if ( empty( $form_id ) ) { | |
| 791 | +	if (empty($form_id)) { | |
| 793 | 792 | return false; | 
| 794 | 793 | } | 
| 795 | 794 | |
| 796 | - $form = new Give_Donate_Form( $form_id ); | |
| 795 | + $form = new Give_Donate_Form($form_id); | |
| 797 | 796 | |
| 798 | 797 | return $form->get_maximum_price(); | 
| 799 | 798 | } | 
| @@ -809,48 +808,48 @@ discard block | ||
| 809 | 808 | * | 
| 810 | 809 | * @return int $formatted_price | 
| 811 | 810 | */ | 
| 812 | -function give_price( $form_id = 0, $echo = true, $price_id = false ) { | |
| 811 | +function give_price($form_id = 0, $echo = true, $price_id = false) { | |
| 813 | 812 | $price = 0; | 
| 814 | 813 | |
| 815 | -	if ( empty( $form_id ) ) { | |
| 814 | +	if (empty($form_id)) { | |
| 816 | 815 | $form_id = get_the_ID(); | 
| 817 | 816 | } | 
| 818 | 817 | |
| 819 | -	if ( give_has_variable_prices( $form_id ) ) { | |
| 818 | +	if (give_has_variable_prices($form_id)) { | |
| 820 | 819 | |
| 821 | - $prices = give_get_variable_prices( $form_id ); | |
| 820 | + $prices = give_get_variable_prices($form_id); | |
| 822 | 821 | |
| 823 | -		if ( false !== $price_id ) { | |
| 822 | +		if (false !== $price_id) { | |
| 824 | 823 | |
| 825 | 824 | // loop through multi-prices to see which is default | 
| 826 | -			foreach ( $prices as $price ) { | |
| 825 | +			foreach ($prices as $price) { | |
| 827 | 826 | // this is the default price | 
| 828 | -				if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { | |
| 827 | +				if (isset($price['_give_default']) && $price['_give_default'] === 'default') { | |
| 829 | 828 | $price = (float) $price['_give_amount']; | 
| 830 | 829 | }; | 
| 831 | 830 | } | 
| 832 | 831 |  		} else { | 
| 833 | 832 | |
| 834 | - $price = give_get_lowest_price_option( $form_id ); | |
| 833 | + $price = give_get_lowest_price_option($form_id); | |
| 835 | 834 | } | 
| 836 | 835 |  	} else { | 
| 837 | 836 | |
| 838 | - $price = give_get_form_price( $form_id ); | |
| 837 | + $price = give_get_form_price($form_id); | |
| 839 | 838 | } | 
| 840 | 839 | |
| 841 | - $price = apply_filters( 'give_form_price', give_maybe_sanitize_amount( $price ), $form_id ); | |
| 842 | - $formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>'; | |
| 843 | - $formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price ); | |
| 840 | +	$price           = apply_filters('give_form_price', give_maybe_sanitize_amount($price), $form_id); | |
| 841 | + $formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>'; | |
| 842 | +	$formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price); | |
| 844 | 843 | |
| 845 | -	if ( $echo ) { | |
| 844 | +	if ($echo) { | |
| 846 | 845 | echo $formatted_price; | 
| 847 | 846 |  	} else { | 
| 848 | 847 | return $formatted_price; | 
| 849 | 848 | } | 
| 850 | 849 | } | 
| 851 | 850 | |
| 852 | -add_filter( 'give_form_price', 'give_format_amount', 10 ); | |
| 853 | -add_filter( 'give_form_price', 'give_currency_filter', 20 ); | |
| 851 | +add_filter('give_form_price', 'give_format_amount', 10); | |
| 852 | +add_filter('give_form_price', 'give_currency_filter', 20); | |
| 854 | 853 | |
| 855 | 854 | |
| 856 | 855 | /** | 
| @@ -863,19 +862,19 @@ discard block | ||
| 863 | 862 | * | 
| 864 | 863 | * @return float $amount Amount of the price option | 
| 865 | 864 | */ | 
| 866 | -function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) { | |
| 867 | - $prices = give_get_variable_prices( $form_id ); | |
| 865 | +function give_get_price_option_amount($form_id = 0, $price_id = 0) { | |
| 866 | + $prices = give_get_variable_prices($form_id); | |
| 868 | 867 | |
| 869 | 868 | $amount = 0.00; | 
| 870 | 869 | |
| 871 | -	foreach ( $prices as $price ) { | |
| 872 | -		if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) { | |
| 873 | - $amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00; | |
| 870 | +	foreach ($prices as $price) { | |
| 871 | +		if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] == $price_id) { | |
| 872 | + $amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00; | |
| 874 | 873 | break; | 
| 875 | 874 | }; | 
| 876 | 875 | } | 
| 877 | 876 | |
| 878 | - return apply_filters( 'give_get_price_option_amount', give_maybe_sanitize_amount( $amount ), $form_id, $price_id ); | |
| 877 | +	return apply_filters('give_get_price_option_amount', give_maybe_sanitize_amount($amount), $form_id, $price_id); | |
| 879 | 878 | } | 
| 880 | 879 | |
| 881 | 880 | /** | 
| @@ -887,13 +886,13 @@ discard block | ||
| 887 | 886 | * | 
| 888 | 887 | * @return mixed string|int Goal of the form | 
| 889 | 888 | */ | 
| 890 | -function give_get_form_goal( $form_id = 0 ) { | |
| 889 | +function give_get_form_goal($form_id = 0) { | |
| 891 | 890 | |
| 892 | -	if ( empty( $form_id ) ) { | |
| 891 | +	if (empty($form_id)) { | |
| 893 | 892 | return false; | 
| 894 | 893 | } | 
| 895 | 894 | |
| 896 | - $form = new Give_Donate_Form( $form_id ); | |
| 895 | + $form = new Give_Donate_Form($form_id); | |
| 897 | 896 | |
| 898 | 897 | return $form->goal; | 
| 899 | 898 | |
| @@ -908,13 +907,13 @@ discard block | ||
| 908 | 907 | * | 
| 909 | 908 | * @return mixed string|int Goal of the form | 
| 910 | 909 | */ | 
| 911 | -function give_get_form_goal_format( $form_id = 0 ) { | |
| 910 | +function give_get_form_goal_format($form_id = 0) { | |
| 912 | 911 | |
| 913 | -	if ( empty( $form_id ) ) { | |
| 912 | +	if (empty($form_id)) { | |
| 914 | 913 | return false; | 
| 915 | 914 | } | 
| 916 | 915 | |
| 917 | - return give_get_meta( $form_id, '_give_goal_format', true ); | |
| 916 | + return give_get_meta($form_id, '_give_goal_format', true); | |
| 918 | 917 | |
| 919 | 918 | } | 
| 920 | 919 | |
| @@ -928,19 +927,19 @@ discard block | ||
| 928 | 927 | * | 
| 929 | 928 | * @return string $formatted_goal | 
| 930 | 929 | */ | 
| 931 | -function give_goal( $form_id = 0, $echo = true ) { | |
| 930 | +function give_goal($form_id = 0, $echo = true) { | |
| 932 | 931 | |
| 933 | -	if ( empty( $form_id ) ) { | |
| 932 | +	if (empty($form_id)) { | |
| 934 | 933 | $form_id = get_the_ID(); | 
| 935 | 934 | } | 
| 936 | 935 | |
| 937 | - $goal = give_get_form_goal( $form_id ); | |
| 938 | - $goal_format = give_get_form_goal_format( $form_id ); | |
| 936 | + $goal = give_get_form_goal($form_id); | |
| 937 | + $goal_format = give_get_form_goal_format($form_id); | |
| 939 | 938 | |
| 940 | -	if ( 'donation' === $goal_format ) { | |
| 939 | +	if ('donation' === $goal_format) { | |
| 941 | 940 |  		$goal = "{$goal} donations"; | 
| 942 | 941 |  	} else { | 
| 943 | - $goal = apply_filters( 'give_form_goal', give_maybe_sanitize_amount( $goal ), $form_id ); | |
| 942 | +		$goal = apply_filters('give_form_goal', give_maybe_sanitize_amount($goal), $form_id); | |
| 944 | 943 | } | 
| 945 | 944 | |
| 946 | 945 | $formatted_goal = sprintf( | 
| @@ -948,17 +947,17 @@ discard block | ||
| 948 | 947 | $form_id, | 
| 949 | 948 | $goal | 
| 950 | 949 | ); | 
| 951 | - $formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal ); | |
| 950 | +	$formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal); | |
| 952 | 951 | |
| 953 | -	if ( $echo ) { | |
| 952 | +	if ($echo) { | |
| 954 | 953 | echo $formatted_goal; | 
| 955 | 954 |  	} else { | 
| 956 | 955 | return $formatted_goal; | 
| 957 | 956 | } | 
| 958 | 957 | } | 
| 959 | 958 | |
| 960 | -add_filter( 'give_form_goal', 'give_format_amount', 10 ); | |
| 961 | -add_filter( 'give_form_goal', 'give_currency_filter', 20 ); | |
| 959 | +add_filter('give_form_goal', 'give_format_amount', 10); | |
| 960 | +add_filter('give_form_goal', 'give_currency_filter', 20); | |
| 962 | 961 | |
| 963 | 962 | |
| 964 | 963 | /** | 
| @@ -970,15 +969,15 @@ discard block | ||
| 970 | 969 | * | 
| 971 | 970 | * @return bool $ret Whether or not the logged_in_only setting is set | 
| 972 | 971 | */ | 
| 973 | -function give_logged_in_only( $form_id ) { | |
| 972 | +function give_logged_in_only($form_id) { | |
| 974 | 973 | // If _give_logged_in_only is set to enable then guest can donate from that specific form. | 
| 975 | 974 | // Otherwise it is member only donation form. | 
| 976 | - $val = give_get_meta( $form_id, '_give_logged_in_only', true ); | |
| 977 | - $val = ! empty( $val ) ? $val : 'enabled'; | |
| 975 | + $val = give_get_meta($form_id, '_give_logged_in_only', true); | |
| 976 | + $val = ! empty($val) ? $val : 'enabled'; | |
| 978 | 977 | |
| 979 | - $ret = ! give_is_setting_enabled( $val ); | |
| 978 | + $ret = ! give_is_setting_enabled($val); | |
| 980 | 979 | |
| 981 | - return (bool) apply_filters( 'give_logged_in_only', $ret, $form_id ); | |
| 980 | +	return (bool) apply_filters('give_logged_in_only', $ret, $form_id); | |
| 982 | 981 | } | 
| 983 | 982 | |
| 984 | 983 | |
| @@ -991,11 +990,11 @@ discard block | ||
| 991 | 990 | * | 
| 992 | 991 | * @return string | 
| 993 | 992 | */ | 
| 994 | -function give_show_login_register_option( $form_id ) { | |
| 993 | +function give_show_login_register_option($form_id) { | |
| 995 | 994 | |
| 996 | - $show_register_form = give_get_meta( $form_id, '_give_show_register_form', true ); | |
| 995 | + $show_register_form = give_get_meta($form_id, '_give_show_register_form', true); | |
| 997 | 996 | |
| 998 | - return apply_filters( 'give_show_register_form', $show_register_form, $form_id ); | |
| 997 | +	return apply_filters('give_show_register_form', $show_register_form, $form_id); | |
| 999 | 998 | |
| 1000 | 999 | } | 
| 1001 | 1000 | |
| @@ -1011,12 +1010,12 @@ discard block | ||
| 1011 | 1010 | * | 
| 1012 | 1011 | * @return array | 
| 1013 | 1012 | */ | 
| 1014 | -function _give_get_prefill_form_field_values( $form_id ) { | |
| 1013 | +function _give_get_prefill_form_field_values($form_id) { | |
| 1015 | 1014 | $logged_in_donor_info = array(); | 
| 1016 | 1015 | |
| 1017 | - if ( is_user_logged_in() ) : | |
| 1018 | - $donor_data = get_userdata( get_current_user_id() ); | |
| 1019 | - $donor = new Give_Donor( get_current_user_id(), true ); | |
| 1016 | + if (is_user_logged_in()) : | |
| 1017 | + $donor_data = get_userdata(get_current_user_id()); | |
| 1018 | + $donor = new Give_Donor(get_current_user_id(), true); | |
| 1020 | 1019 | $donor_address = $donor->get_donor_address(); | 
| 1021 | 1020 | $company_name = $donor->get_company_name(); | 
| 1022 | 1021 | |
| @@ -1055,23 +1054,23 @@ discard block | ||
| 1055 | 1054 | |
| 1056 | 1055 | // Bailout: Auto fill form field values only form form which donor is donating. | 
| 1057 | 1056 | if ( | 
| 1058 | - empty( $_GET['form-id'] ) | |
| 1057 | + empty($_GET['form-id']) | |
| 1059 | 1058 | || ! $form_id | 
| 1060 | - || ( $form_id !== absint( $_GET['form-id'] ) ) | |
| 1059 | + || ($form_id !== absint($_GET['form-id'])) | |
| 1061 | 1060 |  	) { | 
| 1062 | 1061 | return $logged_in_donor_info; | 
| 1063 | 1062 | } | 
| 1064 | 1063 | |
| 1065 | 1064 | // Get purchase data. | 
| 1066 | - $give_purchase_data = Give()->session->get( 'give_purchase' ); | |
| 1065 | +	$give_purchase_data = Give()->session->get('give_purchase'); | |
| 1067 | 1066 | |
| 1068 | 1067 | // Get donor info from form data. | 
| 1069 | - $give_donor_info_in_session = empty( $give_purchase_data['post_data'] ) | |
| 1068 | + $give_donor_info_in_session = empty($give_purchase_data['post_data']) | |
| 1070 | 1069 | ? array() | 
| 1071 | 1070 | : $give_purchase_data['post_data']; | 
| 1072 | 1071 | |
| 1073 | 1072 | // Output. | 
| 1074 | - return wp_parse_args( $give_donor_info_in_session, $logged_in_donor_info ); | |
| 1073 | + return wp_parse_args($give_donor_info_in_session, $logged_in_donor_info); | |
| 1075 | 1074 | } | 
| 1076 | 1075 | |
| 1077 | 1076 | /** | 
| @@ -1084,13 +1083,13 @@ discard block | ||
| 1084 | 1083 | * | 
| 1085 | 1084 | * @return int | 
| 1086 | 1085 | */ | 
| 1087 | -function give_get_form_donor_count( $form_id, $args = array() ) { | |
| 1086 | +function give_get_form_donor_count($form_id, $args = array()) { | |
| 1088 | 1087 | global $wpdb; | 
| 1089 | 1088 | |
| 1090 | -	$cache_key   = Give_Cache::get_key( "form_donor_count_{$form_id}", $args, false ); | |
| 1091 | - $donor_count = absint( Give_Cache::get_db_query( $cache_key ) ); | |
| 1089 | +	$cache_key   = Give_Cache::get_key("form_donor_count_{$form_id}", $args, false); | |
| 1090 | + $donor_count = absint(Give_Cache::get_db_query($cache_key)); | |
| 1092 | 1091 | |
| 1093 | -	if ( $form_id && ! $donor_count ) { | |
| 1092 | +	if ($form_id && ! $donor_count) { | |
| 1094 | 1093 | // Set arguments. | 
| 1095 | 1094 | $args = wp_parse_args( | 
| 1096 | 1095 | $args, | 
| @@ -1124,7 +1123,7 @@ discard block | ||
| 1124 | 1123 | 'publish' | 
| 1125 | 1124 | ); | 
| 1126 | 1125 | |
| 1127 | - $donor_count = absint( $wpdb->get_var( $query ) ); | |
| 1126 | + $donor_count = absint($wpdb->get_var($query)); | |
| 1128 | 1127 | } | 
| 1129 | 1128 | |
| 1130 | 1129 | |
| @@ -1133,9 +1132,9 @@ discard block | ||
| 1133 | 1132 | * | 
| 1134 | 1133 | * @since 2.1.0 | 
| 1135 | 1134 | */ | 
| 1136 | - $donor_count = apply_filters( 'give_get_form_donor_count', $donor_count, $form_id, $args ); | |
| 1135 | +	$donor_count = apply_filters('give_get_form_donor_count', $donor_count, $form_id, $args); | |
| 1137 | 1136 | |
| 1138 | - Give_Cache::set_db_query( $cache_key, $donor_count ); | |
| 1137 | + Give_Cache::set_db_query($cache_key, $donor_count); | |
| 1139 | 1138 | |
| 1140 | 1139 | return $donor_count; | 
| 1141 | 1140 | } | 
| @@ -1149,33 +1148,33 @@ discard block | ||
| 1149 | 1148 | * | 
| 1150 | 1149 | * @return void | 
| 1151 | 1150 | */ | 
| 1152 | -function give_set_form_closed_status( $form_id ) { | |
| 1151 | +function give_set_form_closed_status($form_id) { | |
| 1153 | 1152 | |
| 1154 | 1153 | // Bailout. | 
| 1155 | -	if ( empty( $form_id ) ) { | |
| 1154 | +	if (empty($form_id)) { | |
| 1156 | 1155 | return; | 
| 1157 | 1156 | } | 
| 1158 | 1157 | |
| 1159 | 1158 | $open_form = false; | 
| 1160 | - $is_goal_enabled = give_is_setting_enabled( give_get_meta( $form_id, '_give_goal_option', true, 'disabled' ) ); | |
| 1159 | + $is_goal_enabled = give_is_setting_enabled(give_get_meta($form_id, '_give_goal_option', true, 'disabled')); | |
| 1161 | 1160 | |
| 1162 | 1161 | // Proceed, if the form goal is enabled. | 
| 1163 | -	if ( $is_goal_enabled ) { | |
| 1162 | +	if ($is_goal_enabled) { | |
| 1164 | 1163 | |
| 1165 | - $close_form_when_goal_achieved = give_is_setting_enabled( give_get_meta( $form_id, '_give_close_form_when_goal_achieved', true, 'disabled' ) ); | |
| 1164 | + $close_form_when_goal_achieved = give_is_setting_enabled(give_get_meta($form_id, '_give_close_form_when_goal_achieved', true, 'disabled')); | |
| 1166 | 1165 | |
| 1167 | 1166 | // Proceed, if close form when goal achieved option is enabled. | 
| 1168 | -		if ( $close_form_when_goal_achieved ) { | |
| 1167 | +		if ($close_form_when_goal_achieved) { | |
| 1169 | 1168 | |
| 1170 | - $form = new Give_Donate_Form( $form_id ); | |
| 1171 | - $goal_progress_stats = give_goal_progress_stats( $form ); | |
| 1169 | + $form = new Give_Donate_Form($form_id); | |
| 1170 | + $goal_progress_stats = give_goal_progress_stats($form); | |
| 1172 | 1171 | |
| 1173 | 1172 | // Verify whether the form is closed or not after processing data. | 
| 1174 | 1173 | $closed = $goal_progress_stats['raw_goal'] <= $goal_progress_stats['raw_actual']; | 
| 1175 | 1174 | |
| 1176 | 1175 | // Update form meta if verified that the form is closed. | 
| 1177 | -			if ( $closed ) { | |
| 1178 | - give_update_meta( $form_id, '_give_form_status', 'closed' ); | |
| 1176 | +			if ($closed) { | |
| 1177 | + give_update_meta($form_id, '_give_form_status', 'closed'); | |
| 1179 | 1178 |  			} else { | 
| 1180 | 1179 | $open_form = true; | 
| 1181 | 1180 | } | 
| @@ -1187,8 +1186,8 @@ discard block | ||
| 1187 | 1186 | } | 
| 1188 | 1187 | |
| 1189 | 1188 | // If $open_form is true, then update form status to open. | 
| 1190 | -	if ( $open_form ) { | |
| 1191 | - give_update_meta( $form_id, '_give_form_status', 'open' ); | |
| 1189 | +	if ($open_form) { | |
| 1190 | + give_update_meta($form_id, '_give_form_status', 'open'); | |
| 1192 | 1191 | } | 
| 1193 | 1192 | } | 
| 1194 | 1193 | |
| @@ -1201,32 +1200,31 @@ discard block | ||
| 1201 | 1200 | * | 
| 1202 | 1201 | * @return string | 
| 1203 | 1202 | */ | 
| 1204 | -function give_admin_form_goal_stats( $form_id ) { | |
| 1203 | +function give_admin_form_goal_stats($form_id) { | |
| 1205 | 1204 | |
| 1206 | 1205 | $html = ''; | 
| 1207 | - $goal_stats = give_goal_progress_stats( $form_id ); | |
| 1208 | - $percent_complete = round( ( $goal_stats['raw_actual'] / $goal_stats['raw_goal'] ), 3 ) * 100; | |
| 1206 | + $goal_stats = give_goal_progress_stats($form_id); | |
| 1207 | + $percent_complete = round(($goal_stats['raw_actual'] / $goal_stats['raw_goal']), 3) * 100; | |
| 1209 | 1208 | |
| 1210 | 1209 | $html .= sprintf( | 
| 1211 | 1210 | '<div class="give-admin-progress-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="%1$s"> | 
| 1212 | 1211 | <span style="width:%1$s%%;"></span> | 
| 1213 | 1212 | </div>', | 
| 1214 | - esc_attr( $goal_stats['progress'] ) | |
| 1213 | + esc_attr($goal_stats['progress']) | |
| 1215 | 1214 | ); | 
| 1216 | 1215 | |
| 1217 | 1216 | $html .= sprintf( | 
| 1218 | - ( 'percentage' !== $goal_stats['format'] ) ? | |
| 1219 | - '<div class="give-goal-text"><span>%1$s</span> %2$s <a href="%3$s">%4$s</a> %5$s ' : | |
| 1220 | - '<div class="give-goal-text"><a href="%3$s">%1$s </a>', | |
| 1221 | - ( 'percentage' !== $goal_stats['format'] ) ? $goal_stats['actual'] : $percent_complete . '%', | |
| 1222 | - ( 'percentage' !== $goal_stats['format'] ) ? __( 'of', 'give' ) : '', | |
| 1223 | -		esc_url( admin_url( "post.php?post={$form_id}&action=edit&give_tab=donation_goal_options" ) ), | |
| 1217 | +		('percentage' !== $goal_stats['format']) ? | |
| 1218 | + '<div class="give-goal-text"><span>%1$s</span> %2$s <a href="%3$s">%4$s</a> %5$s ' : '<div class="give-goal-text"><a href="%3$s">%1$s </a>', | |
| 1219 | +		('percentage' !== $goal_stats['format']) ? $goal_stats['actual'] : $percent_complete.'%', | |
| 1220 | +		('percentage' !== $goal_stats['format']) ? __('of', 'give') : '', | |
| 1221 | +		esc_url(admin_url("post.php?post={$form_id}&action=edit&give_tab=donation_goal_options")), | |
| 1224 | 1222 | $goal_stats['goal'], | 
| 1225 | - ( 'donors' === $goal_stats['format'] ? __( 'Donors', 'give' ) : ( 'donation' === $goal_stats['format'] ? __( 'Donations', 'give' ) : '' ) ) | |
| 1223 | +		('donors' === $goal_stats['format'] ? __('Donors', 'give') : ('donation' === $goal_stats['format'] ? __('Donations', 'give') : '')) | |
| 1226 | 1224 | ); | 
| 1227 | 1225 | |
| 1228 | -	if ( $goal_stats['raw_actual'] >= $goal_stats['raw_goal'] ) { | |
| 1229 | - $html .= sprintf( '<span class="give-admin-goal-achieved"><span class="dashicons dashicons-star-filled"></span> %s</span>', __( 'Goal achieved', 'give' ) ); | |
| 1226 | +	if ($goal_stats['raw_actual'] >= $goal_stats['raw_goal']) { | |
| 1227 | +		$html .= sprintf('<span class="give-admin-goal-achieved"><span class="dashicons dashicons-star-filled"></span> %s</span>', __('Goal achieved', 'give')); | |
| 1230 | 1228 | } | 
| 1231 | 1229 | |
| 1232 | 1230 | $html .= '</div>'; | 
| @@ -228,7 +228,7 @@ discard block | ||
| 228 | 228 | * | 
| 229 | 229 | * @since 1.8.17 | 
| 230 | 230 | * | 
| 231 | - * @return array|string | |
| 231 | + * @return boolean | |
| 232 | 232 | */ | 
| 233 | 233 |  function give_get_history_session() { | 
| 234 | 234 | return (bool) Give()->session->get( 'history_access' ); | 
| @@ -711,7 +711,7 @@ discard block | ||
| 711 | 711 | * | 
| 712 | 712 | * @todo Remove this, when WordPress Core ticket is resolved (https://core.trac.wordpress.org/ticket/16828). | 
| 713 | 713 | * | 
| 714 | - * @return bool | |
| 714 | + * @return false|null | |
| 715 | 715 | */ | 
| 716 | 716 |  function give_donation_metabox_menu() { | 
| 717 | 717 | |
| @@ -1006,7 +1006,7 @@ discard block | ||
| 1006 | 1006 | * | 
| 1007 | 1007 | * @since 1.8 | 
| 1008 | 1008 | * | 
| 1009 | - * @param $form_id | |
| 1009 | + * @param integer $form_id | |
| 1010 | 1010 | * | 
| 1011 | 1011 | * @return bool | 
| 1012 | 1012 | */ | 
| @@ -1125,7 +1125,7 @@ discard block | ||
| 1125 | 1125 | * @param int $id | 
| 1126 | 1126 | * @param string $meta_key | 
| 1127 | 1127 | * @param mixed $meta_value | 
| 1128 | - * @param mixed $prev_value | |
| 1128 | + * @param string $prev_value | |
| 1129 | 1129 | * | 
| 1130 | 1130 | * @return mixed | 
| 1131 | 1131 | */ | 
| @@ -1386,7 +1386,7 @@ discard block | ||
| 1386 | 1386 | * @since 1.8.13 | 
| 1387 | 1387 | * | 
| 1388 | 1388 | * @param array $list List of objects or arrays | 
| 1389 | - * @param int|string $field Field from the object to place instead of the entire object | |
| 1389 | + * @param string $field Field from the object to place instead of the entire object | |
| 1390 | 1390 | * @param int|string $index_key Optional. Field from the object to use as keys for the new array. | 
| 1391 | 1391 | * Default null. | 
| 1392 | 1392 | * | 
| @@ -1813,7 +1813,7 @@ discard block | ||
| 1813 | 1813 | * | 
| 1814 | 1814 | * @since 2.1.0 | 
| 1815 | 1815 | * | 
| 1816 | - * @param $form_id | |
| 1816 | + * @param integer $form_id | |
| 1817 | 1817 | * | 
| 1818 | 1818 | * @return bool | 
| 1819 | 1819 | */ | 
| @@ -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,9 +23,9 @@ discard block | ||
| 23 | 23 | */ | 
| 24 | 24 |  function give_is_test_mode() { | 
| 25 | 25 | |
| 26 | - $ret = give_is_setting_enabled( give_get_option( 'test_mode' ) ); | |
| 26 | +	$ret = give_is_setting_enabled(give_get_option('test_mode')); | |
| 27 | 27 | |
| 28 | - return (bool) apply_filters( 'give_is_test_mode', $ret ); | |
| 28 | +	return (bool) apply_filters('give_is_test_mode', $ret); | |
| 29 | 29 | |
| 30 | 30 | } | 
| 31 | 31 | |
| @@ -39,18 +39,18 @@ discard block | ||
| 39 | 39 | |
| 40 | 40 | global $wp; | 
| 41 | 41 | |
| 42 | -	if ( get_option( 'permalink_structure' ) ) { | |
| 43 | - $base = trailingslashit( home_url( $wp->request ) ); | |
| 42 | +	if (get_option('permalink_structure')) { | |
| 43 | + $base = trailingslashit(home_url($wp->request)); | |
| 44 | 44 |  	} else { | 
| 45 | - $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) ); | |
| 46 | - $base = remove_query_arg( array( 'post_type', 'name' ), $base ); | |
| 45 | + $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request))); | |
| 46 | +		$base = remove_query_arg(array('post_type', 'name'), $base); | |
| 47 | 47 | } | 
| 48 | 48 | |
| 49 | 49 | $scheme = is_ssl() ? 'https' : 'http'; | 
| 50 | - $current_uri = set_url_scheme( $base, $scheme ); | |
| 50 | + $current_uri = set_url_scheme($base, $scheme); | |
| 51 | 51 | |
| 52 | -	if ( is_front_page() ) { | |
| 53 | - $current_uri = home_url( '/' ); | |
| 52 | +	if (is_front_page()) { | |
| 53 | +		$current_uri = home_url('/'); | |
| 54 | 54 | } | 
| 55 | 55 | |
| 56 | 56 | /** | 
| @@ -60,7 +60,7 @@ discard block | ||
| 60 | 60 | * | 
| 61 | 61 | * @param string $current_uri | 
| 62 | 62 | */ | 
| 63 | - return apply_filters( 'give_get_current_page_url', $current_uri ); | |
| 63 | +	return apply_filters('give_get_current_page_url', $current_uri); | |
| 64 | 64 | |
| 65 | 65 | } | 
| 66 | 66 | |
| @@ -82,11 +82,11 @@ discard block | ||
| 82 | 82 | */ | 
| 83 | 83 | $gateways = give_get_enabled_payment_gateways(); | 
| 84 | 84 | |
| 85 | -	if ( count( $gateways ) == 1 && ! isset( $gateways['paypal'] ) && ! isset( $gateways['manual'] ) ) { | |
| 85 | +	if (count($gateways) == 1 && ! isset($gateways['paypal']) && ! isset($gateways['manual'])) { | |
| 86 | 86 | $ret = true; | 
| 87 | -	} elseif ( count( $gateways ) == 1 ) { | |
| 87 | +	} elseif (count($gateways) == 1) { | |
| 88 | 88 | $ret = false; | 
| 89 | -	} elseif ( count( $gateways ) == 2 && isset( $gateways['paypal'] ) && isset( $gateways['manual'] ) ) { | |
| 89 | +	} elseif (count($gateways) == 2 && isset($gateways['paypal']) && isset($gateways['manual'])) { | |
| 90 | 90 | $ret = false; | 
| 91 | 91 | } | 
| 92 | 92 | |
| @@ -97,7 +97,7 @@ discard block | ||
| 97 | 97 | * | 
| 98 | 98 | * @param bool $ret | 
| 99 | 99 | */ | 
| 100 | - return (bool) apply_filters( 'give_is_cc_verify_enabled', $ret ); | |
| 100 | +	return (bool) apply_filters('give_is_cc_verify_enabled', $ret); | |
| 101 | 101 | } | 
| 102 | 102 | |
| 103 | 103 | /** | 
| @@ -109,26 +109,26 @@ discard block | ||
| 109 | 109 |  function give_get_timezone_id() { | 
| 110 | 110 | |
| 111 | 111 | // if site timezone string exists, return it. | 
| 112 | -	if ( $timezone = get_option( 'timezone_string' ) ) { | |
| 112 | +	if ($timezone = get_option('timezone_string')) { | |
| 113 | 113 | return $timezone; | 
| 114 | 114 | } | 
| 115 | 115 | |
| 116 | 116 | // get UTC offset, if it isn't set return UTC. | 
| 117 | -	if ( ! ( $utc_offset = 3600 * get_option( 'gmt_offset', 0 ) ) ) { | |
| 117 | +	if ( ! ($utc_offset = 3600 * get_option('gmt_offset', 0))) { | |
| 118 | 118 | return 'UTC'; | 
| 119 | 119 | } | 
| 120 | 120 | |
| 121 | 121 | // attempt to guess the timezone string from the UTC offset. | 
| 122 | - $timezone = timezone_name_from_abbr( '', $utc_offset ); | |
| 122 | +	$timezone = timezone_name_from_abbr('', $utc_offset); | |
| 123 | 123 | |
| 124 | 124 | // last try, guess timezone string manually. | 
| 125 | -	if ( $timezone === false ) { | |
| 125 | +	if ($timezone === false) { | |
| 126 | 126 | |
| 127 | - $is_dst = date( 'I' ); | |
| 127 | +		$is_dst = date('I'); | |
| 128 | 128 | |
| 129 | -		foreach ( timezone_abbreviations_list() as $abbr ) { | |
| 130 | -			foreach ( $abbr as $city ) { | |
| 131 | -				if ( $city['dst'] == $is_dst && $city['offset'] == $utc_offset ) { | |
| 129 | +		foreach (timezone_abbreviations_list() as $abbr) { | |
| 130 | +			foreach ($abbr as $city) { | |
| 131 | +				if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) { | |
| 132 | 132 | return $city['timezone_id']; | 
| 133 | 133 | } | 
| 134 | 134 | } | 
| @@ -152,13 +152,13 @@ discard block | ||
| 152 | 152 | |
| 153 | 153 | $ip = '127.0.0.1'; | 
| 154 | 154 | |
| 155 | -	if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { | |
| 155 | +	if ( ! empty($_SERVER['HTTP_CLIENT_IP'])) { | |
| 156 | 156 | // check ip from share internet | 
| 157 | 157 | $ip = $_SERVER['HTTP_CLIENT_IP']; | 
| 158 | -	} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { | |
| 158 | +	} elseif ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { | |
| 159 | 159 | // to check ip is pass from proxy | 
| 160 | 160 | $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; | 
| 161 | -	} elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) { | |
| 161 | +	} elseif ( ! empty($_SERVER['REMOTE_ADDR'])) { | |
| 162 | 162 | $ip = $_SERVER['REMOTE_ADDR']; | 
| 163 | 163 | } | 
| 164 | 164 | |
| @@ -167,15 +167,15 @@ discard block | ||
| 167 | 167 | * | 
| 168 | 168 | * @since 1.0 | 
| 169 | 169 | */ | 
| 170 | - $ip = apply_filters( 'give_get_ip', $ip ); | |
| 170 | +	$ip = apply_filters('give_get_ip', $ip); | |
| 171 | 171 | |
| 172 | 172 | // Filter empty values. | 
| 173 | -	if( false !== strpos( $ip, ',' ) ) { | |
| 174 | - $ip = give_clean( explode( ',', $ip ) ); | |
| 175 | - $ip = array_filter( $ip ); | |
| 176 | - $ip = implode( ',', $ip ); | |
| 177 | -	} else{ | |
| 178 | - $ip = give_clean( $ip ); | |
| 173 | +	if (false !== strpos($ip, ',')) { | |
| 174 | +		$ip = give_clean(explode(',', $ip)); | |
| 175 | + $ip = array_filter($ip); | |
| 176 | +		$ip = implode(',', $ip); | |
| 177 | +	} else { | |
| 178 | + $ip = give_clean($ip); | |
| 179 | 179 | } | 
| 180 | 180 | |
| 181 | 181 | return $ip; | 
| @@ -193,9 +193,9 @@ discard block | ||
| 193 | 193 | * | 
| 194 | 194 | * @uses Give()->session->set() | 
| 195 | 195 | */ | 
| 196 | -function give_set_purchase_session( $purchase_data = array() ) { | |
| 197 | - Give()->session->set( 'give_purchase', $purchase_data ); | |
| 198 | - Give()->session->set( 'give_email', $purchase_data['user_email'] ); | |
| 196 | +function give_set_purchase_session($purchase_data = array()) { | |
| 197 | +	Give()->session->set('give_purchase', $purchase_data); | |
| 198 | +	Give()->session->set('give_email', $purchase_data['user_email']); | |
| 199 | 199 | } | 
| 200 | 200 | |
| 201 | 201 | /** | 
| @@ -209,7 +209,7 @@ discard block | ||
| 209 | 209 | * @return mixed array | false | 
| 210 | 210 | */ | 
| 211 | 211 |  function give_get_purchase_session() { | 
| 212 | - return Give()->session->get( 'give_purchase' ); | |
| 212 | +	return Give()->session->get('give_purchase'); | |
| 213 | 213 | } | 
| 214 | 214 | |
| 215 | 215 | /** | 
| @@ -220,7 +220,7 @@ discard block | ||
| 220 | 220 | * @return array|string | 
| 221 | 221 | */ | 
| 222 | 222 |  function give_get_receipt_session() { | 
| 223 | - return Give()->session->get( 'receipt_access' ); | |
| 223 | +	return Give()->session->get('receipt_access'); | |
| 224 | 224 | } | 
| 225 | 225 | |
| 226 | 226 | /** | 
| @@ -231,7 +231,7 @@ discard block | ||
| 231 | 231 | * @return array|string | 
| 232 | 232 | */ | 
| 233 | 233 |  function give_get_history_session() { | 
| 234 | - return (bool) Give()->session->get( 'history_access' ); | |
| 234 | +	return (bool) Give()->session->get('history_access'); | |
| 235 | 235 | } | 
| 236 | 236 | |
| 237 | 237 | /** | 
| @@ -243,17 +243,17 @@ discard block | ||
| 243 | 243 | * | 
| 244 | 244 | * @return string By default, the name of the form. Then the price level text if any is found. | 
| 245 | 245 | */ | 
| 246 | -function give_payment_gateway_item_title( $payment_data ) { | |
| 246 | +function give_payment_gateway_item_title($payment_data) { | |
| 247 | 247 | |
| 248 | - $form_id = intval( $payment_data['post_data']['give-form-id'] ); | |
| 249 | - $item_name = isset( $payment_data['post_data']['give-form-title'] ) ? $payment_data['post_data']['give-form-title'] : ''; | |
| 250 | - $price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : ''; | |
| 248 | + $form_id = intval($payment_data['post_data']['give-form-id']); | |
| 249 | + $item_name = isset($payment_data['post_data']['give-form-title']) ? $payment_data['post_data']['give-form-title'] : ''; | |
| 250 | + $price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : ''; | |
| 251 | 251 | |
| 252 | 252 | |
| 253 | 253 | // Verify has variable prices. | 
| 254 | -	if ( give_has_variable_prices( $form_id ) && ! empty( $price_id ) ) { | |
| 254 | +	if (give_has_variable_prices($form_id) && ! empty($price_id)) { | |
| 255 | 255 | |
| 256 | - $item_price_level_text = give_get_price_option_name( $form_id, $price_id, 0, false ); | |
| 256 | + $item_price_level_text = give_get_price_option_name($form_id, $price_id, 0, false); | |
| 257 | 257 | |
| 258 | 258 | /** | 
| 259 | 259 | * Output donation level text if: | 
| @@ -263,10 +263,10 @@ discard block | ||
| 263 | 263 | */ | 
| 264 | 264 | if ( | 
| 265 | 265 | 'custom' !== $price_id | 
| 266 | - && ! empty( $item_price_level_text ) | |
| 266 | + && ! empty($item_price_level_text) | |
| 267 | 267 |  		) { | 
| 268 | 268 | // Matches a donation level - append level text. | 
| 269 | - $item_name .= ' - ' . $item_price_level_text; | |
| 269 | + $item_name .= ' - '.$item_price_level_text; | |
| 270 | 270 | } | 
| 271 | 271 | } | 
| 272 | 272 | |
| @@ -281,7 +281,7 @@ discard block | ||
| 281 | 281 | * | 
| 282 | 282 | * @return string | 
| 283 | 283 | */ | 
| 284 | - return apply_filters( 'give_payment_gateway_item_title', $item_name, $form_id, $payment_data ); | |
| 284 | +	return apply_filters('give_payment_gateway_item_title', $item_name, $form_id, $payment_data); | |
| 285 | 285 | } | 
| 286 | 286 | |
| 287 | 287 | /** | 
| @@ -297,38 +297,38 @@ discard block | ||
| 297 | 297 | * | 
| 298 | 298 | * @return string | 
| 299 | 299 | */ | 
| 300 | -function give_payment_gateway_donation_summary( $donation_data, $name_and_email = true, $length = 255 ) { | |
| 300 | +function give_payment_gateway_donation_summary($donation_data, $name_and_email = true, $length = 255) { | |
| 301 | 301 | |
| 302 | - $form_id = isset( $donation_data['post_data']['give-form-id'] ) ? $donation_data['post_data']['give-form-id'] : ''; | |
| 303 | - $price_id = isset( $donation_data['post_data']['give-price-id'] ) ? $donation_data['post_data']['give-price-id'] : ''; | |
| 302 | + $form_id = isset($donation_data['post_data']['give-form-id']) ? $donation_data['post_data']['give-form-id'] : ''; | |
| 303 | + $price_id = isset($donation_data['post_data']['give-price-id']) ? $donation_data['post_data']['give-price-id'] : ''; | |
| 304 | 304 | |
| 305 | 305 | // Form title. | 
| 306 | - $summary = ( ! empty( $donation_data['post_data']['give-form-title'] ) ? $donation_data['post_data']['give-form-title'] : ( ! empty( $form_id ) ? wp_sprintf( __( 'Donation Form ID: %d', 'give' ), $form_id ) : __( 'Untitled donation form', 'give' ) ) ); | |
| 306 | +	$summary = ( ! empty($donation_data['post_data']['give-form-title']) ? $donation_data['post_data']['give-form-title'] : ( ! empty($form_id) ? wp_sprintf(__('Donation Form ID: %d', 'give'), $form_id) : __('Untitled donation form', 'give'))); | |
| 307 | 307 | |
| 308 | 308 | // Form multilevel if applicable. | 
| 309 | -	if ( ! empty( $price_id ) && 'custom' !== $price_id ) { | |
| 310 | - $summary .= ': ' . give_get_price_option_name( $form_id, $donation_data['post_data']['give-price-id'] ); | |
| 309 | +	if ( ! empty($price_id) && 'custom' !== $price_id) { | |
| 310 | + $summary .= ': '.give_get_price_option_name($form_id, $donation_data['post_data']['give-price-id']); | |
| 311 | 311 | } | 
| 312 | 312 | |
| 313 | 313 | // Add Donor's name + email if requested. | 
| 314 | -	if ( $name_and_email ) { | |
| 314 | +	if ($name_and_email) { | |
| 315 | 315 | |
| 316 | 316 | // First name | 
| 317 | -		if ( isset( $donation_data['user_info']['first_name'] ) && ! empty( $donation_data['user_info']['first_name'] ) ) { | |
| 318 | - $summary .= ' - ' . $donation_data['user_info']['first_name']; | |
| 317 | +		if (isset($donation_data['user_info']['first_name']) && ! empty($donation_data['user_info']['first_name'])) { | |
| 318 | + $summary .= ' - '.$donation_data['user_info']['first_name']; | |
| 319 | 319 | } | 
| 320 | 320 | |
| 321 | -		if ( isset( $donation_data['user_info']['last_name'] ) && ! empty( $donation_data['user_info']['last_name'] ) ) { | |
| 322 | - $summary .= ' ' . $donation_data['user_info']['last_name']; | |
| 321 | +		if (isset($donation_data['user_info']['last_name']) && ! empty($donation_data['user_info']['last_name'])) { | |
| 322 | + $summary .= ' '.$donation_data['user_info']['last_name']; | |
| 323 | 323 | } | 
| 324 | 324 | |
| 325 | -		$summary .= ' (' . $donation_data['user_email'] . ')'; | |
| 325 | +		$summary .= ' ('.$donation_data['user_email'].')'; | |
| 326 | 326 | } | 
| 327 | 327 | |
| 328 | 328 | // Cut the length | 
| 329 | - $summary = substr( $summary, 0, $length ); | |
| 329 | + $summary = substr($summary, 0, $length); | |
| 330 | 330 | |
| 331 | - return apply_filters( 'give_payment_gateway_donation_summary', $summary ); | |
| 331 | +	return apply_filters('give_payment_gateway_donation_summary', $summary); | |
| 332 | 332 | } | 
| 333 | 333 | |
| 334 | 334 | |
| @@ -343,31 +343,31 @@ discard block | ||
| 343 | 343 |  function give_get_host() { | 
| 344 | 344 | $host = false; | 
| 345 | 345 | |
| 346 | -	if ( defined( 'WPE_APIKEY' ) ) { | |
| 346 | +	if (defined('WPE_APIKEY')) { | |
| 347 | 347 | $host = 'WP Engine'; | 
| 348 | -	} elseif ( defined( 'PAGELYBIN' ) ) { | |
| 348 | +	} elseif (defined('PAGELYBIN')) { | |
| 349 | 349 | $host = 'Pagely'; | 
| 350 | -	} elseif ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { | |
| 350 | +	} elseif (DB_HOST == 'localhost:/tmp/mysql5.sock') { | |
| 351 | 351 | $host = 'ICDSoft'; | 
| 352 | -	} elseif ( DB_HOST == 'mysqlv5' ) { | |
| 352 | +	} elseif (DB_HOST == 'mysqlv5') { | |
| 353 | 353 | $host = 'NetworkSolutions'; | 
| 354 | -	} elseif ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { | |
| 354 | +	} elseif (strpos(DB_HOST, 'ipagemysql.com') !== false) { | |
| 355 | 355 | $host = 'iPage'; | 
| 356 | -	} elseif ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { | |
| 356 | +	} elseif (strpos(DB_HOST, 'ipowermysql.com') !== false) { | |
| 357 | 357 | $host = 'IPower'; | 
| 358 | -	} elseif ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { | |
| 358 | +	} elseif (strpos(DB_HOST, '.gridserver.com') !== false) { | |
| 359 | 359 | $host = 'MediaTemple Grid'; | 
| 360 | -	} elseif ( strpos( DB_HOST, '.pair.com' ) !== false ) { | |
| 360 | +	} elseif (strpos(DB_HOST, '.pair.com') !== false) { | |
| 361 | 361 | $host = 'pair Networks'; | 
| 362 | -	} elseif ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { | |
| 362 | +	} elseif (strpos(DB_HOST, '.stabletransit.com') !== false) { | |
| 363 | 363 | $host = 'Rackspace Cloud'; | 
| 364 | -	} elseif ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { | |
| 364 | +	} elseif (strpos(DB_HOST, '.sysfix.eu') !== false) { | |
| 365 | 365 | $host = 'SysFix.eu Power Hosting'; | 
| 366 | -	} elseif ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { | |
| 366 | +	} elseif (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { | |
| 367 | 367 | $host = 'Flywheel'; | 
| 368 | 368 |  	} else { | 
| 369 | 369 | // Adding a general fallback for data gathering | 
| 370 | - $host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME']; | |
| 370 | + $host = 'DBH: '.DB_HOST.', SRV: '.$_SERVER['SERVER_NAME']; | |
| 371 | 371 | } | 
| 372 | 372 | |
| 373 | 373 | return $host; | 
| @@ -383,67 +383,67 @@ discard block | ||
| 383 | 383 | * | 
| 384 | 384 | * @return bool true if host matches, false if not | 
| 385 | 385 | */ | 
| 386 | -function give_is_host( $host = false ) { | |
| 386 | +function give_is_host($host = false) { | |
| 387 | 387 | |
| 388 | 388 | $return = false; | 
| 389 | 389 | |
| 390 | -	if ( $host ) { | |
| 391 | - $host = str_replace( ' ', '', strtolower( $host ) ); | |
| 390 | +	if ($host) { | |
| 391 | +		$host = str_replace(' ', '', strtolower($host)); | |
| 392 | 392 | |
| 393 | -		switch ( $host ) { | |
| 393 | +		switch ($host) { | |
| 394 | 394 | case 'wpengine': | 
| 395 | -				if ( defined( 'WPE_APIKEY' ) ) { | |
| 395 | +				if (defined('WPE_APIKEY')) { | |
| 396 | 396 | $return = true; | 
| 397 | 397 | } | 
| 398 | 398 | break; | 
| 399 | 399 | case 'pagely': | 
| 400 | -				if ( defined( 'PAGELYBIN' ) ) { | |
| 400 | +				if (defined('PAGELYBIN')) { | |
| 401 | 401 | $return = true; | 
| 402 | 402 | } | 
| 403 | 403 | break; | 
| 404 | 404 | case 'icdsoft': | 
| 405 | -				if ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { | |
| 405 | +				if (DB_HOST == 'localhost:/tmp/mysql5.sock') { | |
| 406 | 406 | $return = true; | 
| 407 | 407 | } | 
| 408 | 408 | break; | 
| 409 | 409 | case 'networksolutions': | 
| 410 | -				if ( DB_HOST == 'mysqlv5' ) { | |
| 410 | +				if (DB_HOST == 'mysqlv5') { | |
| 411 | 411 | $return = true; | 
| 412 | 412 | } | 
| 413 | 413 | break; | 
| 414 | 414 | case 'ipage': | 
| 415 | -				if ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { | |
| 415 | +				if (strpos(DB_HOST, 'ipagemysql.com') !== false) { | |
| 416 | 416 | $return = true; | 
| 417 | 417 | } | 
| 418 | 418 | break; | 
| 419 | 419 | case 'ipower': | 
| 420 | -				if ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { | |
| 420 | +				if (strpos(DB_HOST, 'ipowermysql.com') !== false) { | |
| 421 | 421 | $return = true; | 
| 422 | 422 | } | 
| 423 | 423 | break; | 
| 424 | 424 | case 'mediatemplegrid': | 
| 425 | -				if ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { | |
| 425 | +				if (strpos(DB_HOST, '.gridserver.com') !== false) { | |
| 426 | 426 | $return = true; | 
| 427 | 427 | } | 
| 428 | 428 | break; | 
| 429 | 429 | case 'pairnetworks': | 
| 430 | -				if ( strpos( DB_HOST, '.pair.com' ) !== false ) { | |
| 430 | +				if (strpos(DB_HOST, '.pair.com') !== false) { | |
| 431 | 431 | $return = true; | 
| 432 | 432 | } | 
| 433 | 433 | break; | 
| 434 | 434 | case 'rackspacecloud': | 
| 435 | -				if ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { | |
| 435 | +				if (strpos(DB_HOST, '.stabletransit.com') !== false) { | |
| 436 | 436 | $return = true; | 
| 437 | 437 | } | 
| 438 | 438 | break; | 
| 439 | 439 | case 'sysfix.eu': | 
| 440 | 440 | case 'sysfix.eupowerhosting': | 
| 441 | -				if ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { | |
| 441 | +				if (strpos(DB_HOST, '.sysfix.eu') !== false) { | |
| 442 | 442 | $return = true; | 
| 443 | 443 | } | 
| 444 | 444 | break; | 
| 445 | 445 | case 'flywheel': | 
| 446 | -				if ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { | |
| 446 | +				if (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { | |
| 447 | 447 | $return = true; | 
| 448 | 448 | } | 
| 449 | 449 | break; | 
| @@ -476,7 +476,7 @@ discard block | ||
| 476 | 476 | * @param string $replacement Optional. The function that should have been called. | 
| 477 | 477 | * @param array $backtrace Optional. Contains stack backtrace of deprecated function. | 
| 478 | 478 | */ | 
| 479 | -function _give_deprecated_function( $function, $version, $replacement = null, $backtrace = null ) { | |
| 479 | +function _give_deprecated_function($function, $version, $replacement = null, $backtrace = null) { | |
| 480 | 480 | |
| 481 | 481 | /** | 
| 482 | 482 | * Fires while give deprecated function call occurs. | 
| @@ -489,19 +489,19 @@ discard block | ||
| 489 | 489 | * @param string $replacement Optional. The function that should have been called. | 
| 490 | 490 | * @param string $version The plugin version that deprecated the function. | 
| 491 | 491 | */ | 
| 492 | - do_action( 'give_deprecated_function_run', $function, $replacement, $version ); | |
| 492 | +	do_action('give_deprecated_function_run', $function, $replacement, $version); | |
| 493 | 493 | |
| 494 | - $show_errors = current_user_can( 'manage_options' ); | |
| 494 | +	$show_errors = current_user_can('manage_options'); | |
| 495 | 495 | |
| 496 | 496 | // Allow plugin to filter the output error trigger. | 
| 497 | -	if ( WP_DEBUG && apply_filters( 'give_deprecated_function_trigger_error', $show_errors ) ) { | |
| 498 | -		if ( ! is_null( $replacement ) ) { | |
| 499 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give' ), $function, $version, $replacement ) ); | |
| 500 | - trigger_error( print_r( $backtrace, 1 ) ); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. | |
| 497 | +	if (WP_DEBUG && apply_filters('give_deprecated_function_trigger_error', $show_errors)) { | |
| 498 | +		if ( ! is_null($replacement)) { | |
| 499 | +			trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give'), $function, $version, $replacement)); | |
| 500 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. | |
| 501 | 501 | // Alternatively we could dump this to a file. | 
| 502 | 502 |  		} else { | 
| 503 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give' ), $function, $version ) ); | |
| 504 | - trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. | |
| 503 | +			trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give'), $function, $version)); | |
| 504 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. | |
| 505 | 505 | // Alternatively we could dump this to a file. | 
| 506 | 506 | } | 
| 507 | 507 | } | 
| @@ -515,17 +515,17 @@ discard block | ||
| 515 | 515 | * @return string $post_id | 
| 516 | 516 | */ | 
| 517 | 517 |  function give_get_admin_post_id() { | 
| 518 | - $post_id = isset( $_REQUEST['post'] ) | |
| 519 | - ? absint( $_REQUEST['post'] ) | |
| 518 | + $post_id = isset($_REQUEST['post']) | |
| 519 | + ? absint($_REQUEST['post']) | |
| 520 | 520 | : null; | 
| 521 | 521 | |
| 522 | - $post_id = ! empty( $post_id ) | |
| 522 | + $post_id = ! empty($post_id) | |
| 523 | 523 | ? $post_id | 
| 524 | - : ( isset( $_REQUEST['post_id'] ) ? absint( $_REQUEST['post_id'] ) : null ); | |
| 524 | + : (isset($_REQUEST['post_id']) ? absint($_REQUEST['post_id']) : null); | |
| 525 | 525 | |
| 526 | - $post_id = ! empty( $post_id ) | |
| 526 | + $post_id = ! empty($post_id) | |
| 527 | 527 | ? $post_id | 
| 528 | - : ( isset( $_REQUEST['post_ID'] ) ? absint( $_REQUEST['post_ID'] ) : null ); | |
| 528 | + : (isset($_REQUEST['post_ID']) ? absint($_REQUEST['post_ID']) : null); | |
| 529 | 529 | |
| 530 | 530 | return $post_id; | 
| 531 | 531 | } | 
| @@ -537,7 +537,7 @@ discard block | ||
| 537 | 537 | * @return string Arg separator output | 
| 538 | 538 | */ | 
| 539 | 539 |  function give_get_php_arg_separator_output() { | 
| 540 | - return ini_get( 'arg_separator.output' ); | |
| 540 | +	return ini_get('arg_separator.output'); | |
| 541 | 541 | } | 
| 542 | 542 | |
| 543 | 543 | |
| @@ -552,10 +552,10 @@ discard block | ||
| 552 | 552 | * | 
| 553 | 553 | * @return string Short month name | 
| 554 | 554 | */ | 
| 555 | -function give_month_num_to_name( $n ) { | |
| 556 | - $timestamp = mktime( 0, 0, 0, $n, 1, 2005 ); | |
| 555 | +function give_month_num_to_name($n) { | |
| 556 | + $timestamp = mktime(0, 0, 0, $n, 1, 2005); | |
| 557 | 557 | |
| 558 | - return date_i18n( 'M', $timestamp ); | |
| 558 | +	return date_i18n('M', $timestamp); | |
| 559 | 559 | } | 
| 560 | 560 | |
| 561 | 561 | |
| @@ -568,10 +568,10 @@ discard block | ||
| 568 | 568 | * | 
| 569 | 569 | * @return bool Whether or not function is disabled. | 
| 570 | 570 | */ | 
| 571 | -function give_is_func_disabled( $function ) { | |
| 572 | - $disabled = explode( ',', ini_get( 'disable_functions' ) ); | |
| 571 | +function give_is_func_disabled($function) { | |
| 572 | +	$disabled = explode(',', ini_get('disable_functions')); | |
| 573 | 573 | |
| 574 | - return in_array( $function, $disabled ); | |
| 574 | + return in_array($function, $disabled); | |
| 575 | 575 | } | 
| 576 | 576 | |
| 577 | 577 | |
| @@ -583,7 +583,7 @@ discard block | ||
| 583 | 583 |  function give_get_newsletter() { | 
| 584 | 584 | ?> | 
| 585 | 585 | |
| 586 | - <p class="newsletter-intro"><?php esc_html_e( 'Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give' ); ?></p> | |
| 586 | +	<p class="newsletter-intro"><?php esc_html_e('Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give'); ?></p> | |
| 587 | 587 | |
| 588 | 588 | <div class="give-newsletter-form-wrap"> | 
| 589 | 589 | |
| @@ -591,33 +591,33 @@ discard block | ||
| 591 | 591 | method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" | 
| 592 | 592 | target="_blank" novalidate> | 
| 593 | 593 | <div class="give-newsletter-confirmation"> | 
| 594 | - <p><?php esc_html_e( 'Thanks for Subscribing!', 'give' ); ?> :)</p> | |
| 594 | +				<p><?php esc_html_e('Thanks for Subscribing!', 'give'); ?> :)</p> | |
| 595 | 595 | </div> | 
| 596 | 596 | |
| 597 | 597 | <table class="form-table give-newsletter-form"> | 
| 598 | 598 | <tr valign="middle"> | 
| 599 | 599 | <td> | 
| 600 | 600 | <label for="mce-EMAIL" | 
| 601 | - class="screen-reader-text"><?php esc_html_e( 'Email Address (required)', 'give' ); ?></label> | |
| 601 | +						       class="screen-reader-text"><?php esc_html_e('Email Address (required)', 'give'); ?></label> | |
| 602 | 602 | <input type="email" name="EMAIL" id="mce-EMAIL" | 
| 603 | - placeholder="<?php esc_attr_e( 'Email Address (required)', 'give' ); ?>" | |
| 603 | +						       placeholder="<?php esc_attr_e('Email Address (required)', 'give'); ?>" | |
| 604 | 604 | class="required email" value=""> | 
| 605 | 605 | </td> | 
| 606 | 606 | <td> | 
| 607 | 607 | <label for="mce-FNAME" | 
| 608 | - class="screen-reader-text"><?php esc_html_e( 'First Name', 'give' ); ?></label> | |
| 608 | +						       class="screen-reader-text"><?php esc_html_e('First Name', 'give'); ?></label> | |
| 609 | 609 | <input type="text" name="FNAME" id="mce-FNAME" | 
| 610 | - placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>" class="" value=""> | |
| 610 | +						       placeholder="<?php esc_attr_e('First Name', 'give'); ?>" class="" value=""> | |
| 611 | 611 | </td> | 
| 612 | 612 | <td> | 
| 613 | 613 | <label for="mce-LNAME" | 
| 614 | - class="screen-reader-text"><?php esc_html_e( 'Last Name', 'give' ); ?></label> | |
| 614 | +						       class="screen-reader-text"><?php esc_html_e('Last Name', 'give'); ?></label> | |
| 615 | 615 | <input type="text" name="LNAME" id="mce-LNAME" | 
| 616 | - placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>" class="" value=""> | |
| 616 | +						       placeholder="<?php esc_attr_e('Last Name', 'give'); ?>" class="" value=""> | |
| 617 | 617 | </td> | 
| 618 | 618 | <td> | 
| 619 | 619 | <input type="submit" name="subscribe" id="mc-embedded-subscribe" class="button" | 
| 620 | - value="<?php esc_attr_e( 'Subscribe', 'give' ); ?>"> | |
| 620 | +						       value="<?php esc_attr_e('Subscribe', 'give'); ?>"> | |
| 621 | 621 | </td> | 
| 622 | 622 | </tr> | 
| 623 | 623 | </table> | 
| @@ -670,7 +670,7 @@ discard block | ||
| 670 | 670 | * | 
| 671 | 671 | * @return string | 
| 672 | 672 | */ | 
| 673 | -function give_svg_icons( $icon ) { | |
| 673 | +function give_svg_icons($icon) { | |
| 674 | 674 | |
| 675 | 675 | // Store your SVGs in an associative array | 
| 676 | 676 | $svgs = array( | 
| @@ -682,7 +682,7 @@ discard block | ||
| 682 | 682 | ); | 
| 683 | 683 | |
| 684 | 684 | // Return the chosen icon's SVG string | 
| 685 | - return $svgs[ $icon ]; | |
| 685 | + return $svgs[$icon]; | |
| 686 | 686 | } | 
| 687 | 687 | |
| 688 | 688 | /** | 
| @@ -694,15 +694,15 @@ discard block | ||
| 694 | 694 | * | 
| 695 | 695 | * @return mixed | 
| 696 | 696 | */ | 
| 697 | -function modify_nav_menu_meta_box_object( $post_type ) { | |
| 698 | -	if ( isset( $post_type->name ) && $post_type->name == 'give_forms' ) { | |
| 699 | - $post_type->labels->name = esc_html__( 'Donation Forms', 'give' ); | |
| 697 | +function modify_nav_menu_meta_box_object($post_type) { | |
| 698 | +	if (isset($post_type->name) && $post_type->name == 'give_forms') { | |
| 699 | +		$post_type->labels->name = esc_html__('Donation Forms', 'give'); | |
| 700 | 700 | } | 
| 701 | 701 | |
| 702 | 702 | return $post_type; | 
| 703 | 703 | } | 
| 704 | 704 | |
| 705 | -add_filter( 'nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object' ); | |
| 705 | +add_filter('nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object'); | |
| 706 | 706 | |
| 707 | 707 | /** | 
| 708 | 708 | * Show Donation Forms Post Type in Appearance > Menus by default on fresh install. | 
| @@ -721,35 +721,35 @@ discard block | ||
| 721 | 721 | // Proceed, if current screen is navigation menus. | 
| 722 | 722 | if ( | 
| 723 | 723 | 'nav-menus' === $screen->id && | 
| 724 | - give_is_setting_enabled( give_get_option( 'forms_singular' ) ) && | |
| 725 | - ! get_user_option( 'give_is_donation_forms_menu_updated' ) | |
| 724 | +		give_is_setting_enabled(give_get_option('forms_singular')) && | |
| 725 | +		! get_user_option('give_is_donation_forms_menu_updated') | |
| 726 | 726 |  	) { | 
| 727 | 727 | |
| 728 | 728 | // Return false, if it fails to retrieve hidden meta box list and is not admin. | 
| 729 | 729 | if ( | 
| 730 | 730 | ! is_admin() || | 
| 731 | - ( ! $hidden_meta_boxes = get_user_option( 'metaboxhidden_nav-menus' ) ) | |
| 731 | +			( ! $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus')) | |
| 732 | 732 |  		) { | 
| 733 | 733 | return false; | 
| 734 | 734 | } | 
| 735 | 735 | |
| 736 | 736 | // Return false, In case, we don't find 'Donation Form' in hidden meta box list. | 
| 737 | -		if ( ! in_array( 'add-post-type-give_forms', $hidden_meta_boxes, true ) ) { | |
| 737 | +		if ( ! in_array('add-post-type-give_forms', $hidden_meta_boxes, true)) { | |
| 738 | 738 | return false; | 
| 739 | 739 | } | 
| 740 | 740 | |
| 741 | 741 | // Exclude 'Donation Form' value from hidden meta box's list. | 
| 742 | - $hidden_meta_boxes = array_diff( $hidden_meta_boxes, array( 'add-post-type-give_forms' ) ); | |
| 742 | +		$hidden_meta_boxes = array_diff($hidden_meta_boxes, array('add-post-type-give_forms')); | |
| 743 | 743 | |
| 744 | 744 | // Get current user ID. | 
| 745 | 745 | $user = wp_get_current_user(); | 
| 746 | 746 | |
| 747 | - update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true ); | |
| 748 | - update_user_option( $user->ID, 'give_is_donation_forms_menu_updated', true, true ); | |
| 747 | + update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); | |
| 748 | + update_user_option($user->ID, 'give_is_donation_forms_menu_updated', true, true); | |
| 749 | 749 | } | 
| 750 | 750 | } | 
| 751 | 751 | |
| 752 | -add_action( 'current_screen', 'give_donation_metabox_menu' ); | |
| 752 | +add_action('current_screen', 'give_donation_metabox_menu'); | |
| 753 | 753 | |
| 754 | 754 | /** | 
| 755 | 755 | * Array_column backup usage | 
| @@ -762,7 +762,7 @@ discard block | ||
| 762 | 762 | * @license https://opensource.org/licenses/MIT MIT | 
| 763 | 763 | */ | 
| 764 | 764 | |
| 765 | -if ( ! function_exists( 'array_column' ) ) { | |
| 765 | +if ( ! function_exists('array_column')) { | |
| 766 | 766 | /** | 
| 767 | 767 | * Returns the values from a single column of the input array, identified by | 
| 768 | 768 | * the $columnKey. | 
| @@ -781,53 +781,53 @@ discard block | ||
| 781 | 781 | * | 
| 782 | 782 | * @return array | 
| 783 | 783 | */ | 
| 784 | -	function array_column( $input = null, $columnKey = null, $indexKey = null ) { | |
| 784 | +	function array_column($input = null, $columnKey = null, $indexKey = null) { | |
| 785 | 785 | // Using func_get_args() in order to check for proper number of | 
| 786 | 786 | // parameters and trigger errors exactly as the built-in array_column() | 
| 787 | 787 | // does in PHP 5.5. | 
| 788 | 788 | $argc = func_num_args(); | 
| 789 | 789 | $params = func_get_args(); | 
| 790 | 790 | |
| 791 | -		if ( $argc < 2 ) { | |
| 792 | - trigger_error( sprintf( esc_html__( 'array_column() expects at least 2 parameters, %s given.', 'give' ), $argc ), E_USER_WARNING ); | |
| 791 | +		if ($argc < 2) { | |
| 792 | +			trigger_error(sprintf(esc_html__('array_column() expects at least 2 parameters, %s given.', 'give'), $argc), E_USER_WARNING); | |
| 793 | 793 | |
| 794 | 794 | return null; | 
| 795 | 795 | } | 
| 796 | 796 | |
| 797 | -		if ( ! is_array( $params[0] ) ) { | |
| 798 | - trigger_error( sprintf( esc_html__( 'array_column() expects parameter 1 to be array, %s given.', 'give' ), gettype( $params[0] ) ), E_USER_WARNING ); | |
| 797 | +		if ( ! is_array($params[0])) { | |
| 798 | +			trigger_error(sprintf(esc_html__('array_column() expects parameter 1 to be array, %s given.', 'give'), gettype($params[0])), E_USER_WARNING); | |
| 799 | 799 | |
| 800 | 800 | return null; | 
| 801 | 801 | } | 
| 802 | 802 | |
| 803 | - if ( ! is_int( $params[1] ) | |
| 804 | - && ! is_float( $params[1] ) | |
| 805 | - && ! is_string( $params[1] ) | |
| 803 | + if ( ! is_int($params[1]) | |
| 804 | + && ! is_float($params[1]) | |
| 805 | + && ! is_string($params[1]) | |
| 806 | 806 | && $params[1] !== null | 
| 807 | - && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) | |
| 807 | + && ! (is_object($params[1]) && method_exists($params[1], '__toString')) | |
| 808 | 808 |  		) { | 
| 809 | - trigger_error( esc_html__( 'array_column(): The column key should be either a string or an integer.', 'give' ), E_USER_WARNING ); | |
| 809 | +			trigger_error(esc_html__('array_column(): The column key should be either a string or an integer.', 'give'), E_USER_WARNING); | |
| 810 | 810 | |
| 811 | 811 | return false; | 
| 812 | 812 | } | 
| 813 | 813 | |
| 814 | - if ( isset( $params[2] ) | |
| 815 | - && ! is_int( $params[2] ) | |
| 816 | - && ! is_float( $params[2] ) | |
| 817 | - && ! is_string( $params[2] ) | |
| 818 | - && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) | |
| 814 | + if (isset($params[2]) | |
| 815 | + && ! is_int($params[2]) | |
| 816 | + && ! is_float($params[2]) | |
| 817 | + && ! is_string($params[2]) | |
| 818 | + && ! (is_object($params[2]) && method_exists($params[2], '__toString')) | |
| 819 | 819 |  		) { | 
| 820 | - trigger_error( esc_html__( 'array_column(): The index key should be either a string or an integer.', 'give' ), E_USER_WARNING ); | |
| 820 | +			trigger_error(esc_html__('array_column(): The index key should be either a string or an integer.', 'give'), E_USER_WARNING); | |
| 821 | 821 | |
| 822 | 822 | return false; | 
| 823 | 823 | } | 
| 824 | 824 | |
| 825 | 825 | $paramsInput = $params[0]; | 
| 826 | - $paramsColumnKey = ( $params[1] !== null ) ? (string) $params[1] : null; | |
| 826 | + $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null; | |
| 827 | 827 | |
| 828 | 828 | $paramsIndexKey = null; | 
| 829 | -		if ( isset( $params[2] ) ) { | |
| 830 | -			if ( is_float( $params[2] ) || is_int( $params[2] ) ) { | |
| 829 | +		if (isset($params[2])) { | |
| 830 | +			if (is_float($params[2]) || is_int($params[2])) { | |
| 831 | 831 | $paramsIndexKey = (int) $params[2]; | 
| 832 | 832 |  			} else { | 
| 833 | 833 | $paramsIndexKey = (string) $params[2]; | 
| @@ -836,26 +836,26 @@ discard block | ||
| 836 | 836 | |
| 837 | 837 | $resultArray = array(); | 
| 838 | 838 | |
| 839 | -		foreach ( $paramsInput as $row ) { | |
| 839 | +		foreach ($paramsInput as $row) { | |
| 840 | 840 | $key = $value = null; | 
| 841 | 841 | $keySet = $valueSet = false; | 
| 842 | 842 | |
| 843 | -			if ( $paramsIndexKey !== null && array_key_exists( $paramsIndexKey, $row ) ) { | |
| 843 | +			if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { | |
| 844 | 844 | $keySet = true; | 
| 845 | - $key = (string) $row[ $paramsIndexKey ]; | |
| 845 | + $key = (string) $row[$paramsIndexKey]; | |
| 846 | 846 | } | 
| 847 | 847 | |
| 848 | -			if ( $paramsColumnKey === null ) { | |
| 848 | +			if ($paramsColumnKey === null) { | |
| 849 | 849 | $valueSet = true; | 
| 850 | 850 | $value = $row; | 
| 851 | -			} elseif ( is_array( $row ) && array_key_exists( $paramsColumnKey, $row ) ) { | |
| 851 | +			} elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) { | |
| 852 | 852 | $valueSet = true; | 
| 853 | - $value = $row[ $paramsColumnKey ]; | |
| 853 | + $value = $row[$paramsColumnKey]; | |
| 854 | 854 | } | 
| 855 | 855 | |
| 856 | -			if ( $valueSet ) { | |
| 857 | -				if ( $keySet ) { | |
| 858 | - $resultArray[ $key ] = $value; | |
| 856 | +			if ($valueSet) { | |
| 857 | +				if ($keySet) { | |
| 858 | + $resultArray[$key] = $value; | |
| 859 | 859 |  				} else { | 
| 860 | 860 | $resultArray[] = $value; | 
| 861 | 861 | } | 
| @@ -875,54 +875,54 @@ discard block | ||
| 875 | 875 | * | 
| 876 | 876 | * @return bool Whether the receipt is visible or not. | 
| 877 | 877 | */ | 
| 878 | -function give_can_view_receipt( $payment_key = '' ) { | |
| 878 | +function give_can_view_receipt($payment_key = '') { | |
| 879 | 879 | |
| 880 | 880 | $return = false; | 
| 881 | 881 | |
| 882 | -	if ( empty( $payment_key ) ) { | |
| 882 | +	if (empty($payment_key)) { | |
| 883 | 883 | return $return; | 
| 884 | 884 | } | 
| 885 | 885 | |
| 886 | 886 | global $give_receipt_args; | 
| 887 | 887 | |
| 888 | - $give_receipt_args['id'] = give_get_donation_id_by_key( $payment_key ); | |
| 888 | + $give_receipt_args['id'] = give_get_donation_id_by_key($payment_key); | |
| 889 | 889 | |
| 890 | - $user_id = (int) give_get_payment_user_id( $give_receipt_args['id'] ); | |
| 890 | + $user_id = (int) give_get_payment_user_id($give_receipt_args['id']); | |
| 891 | 891 | |
| 892 | - $payment_meta = give_get_payment_meta( $give_receipt_args['id'] ); | |
| 892 | + $payment_meta = give_get_payment_meta($give_receipt_args['id']); | |
| 893 | 893 | |
| 894 | -	if ( is_user_logged_in() ) { | |
| 895 | -		if ( $user_id === (int) get_current_user_id() ) { | |
| 894 | +	if (is_user_logged_in()) { | |
| 895 | +		if ($user_id === (int) get_current_user_id()) { | |
| 896 | 896 | $return = true; | 
| 897 | -		} elseif ( wp_get_current_user()->user_email === give_get_payment_user_email( $give_receipt_args['id'] ) ) { | |
| 897 | +		} elseif (wp_get_current_user()->user_email === give_get_payment_user_email($give_receipt_args['id'])) { | |
| 898 | 898 | $return = true; | 
| 899 | -		} elseif ( current_user_can( 'view_give_sensitive_data' ) ) { | |
| 899 | +		} elseif (current_user_can('view_give_sensitive_data')) { | |
| 900 | 900 | $return = true; | 
| 901 | 901 | } | 
| 902 | 902 | } | 
| 903 | 903 | |
| 904 | 904 | // Check whether it is purchase session? | 
| 905 | 905 | $purchase_session = give_get_purchase_session(); | 
| 906 | -	if ( ! empty( $purchase_session ) && ! is_user_logged_in() ) { | |
| 907 | -		if ( $purchase_session['purchase_key'] === $payment_meta['key'] ) { | |
| 906 | +	if ( ! empty($purchase_session) && ! is_user_logged_in()) { | |
| 907 | +		if ($purchase_session['purchase_key'] === $payment_meta['key']) { | |
| 908 | 908 | $return = true; | 
| 909 | 909 | } | 
| 910 | 910 | } | 
| 911 | 911 | |
| 912 | 912 | // Check whether it is receipt access session? | 
| 913 | 913 | $receipt_session = give_get_receipt_session(); | 
| 914 | -	if ( ! empty( $receipt_session ) && ! is_user_logged_in() ) { | |
| 915 | -		if ( $receipt_session === $payment_meta['key'] ) { | |
| 914 | +	if ( ! empty($receipt_session) && ! is_user_logged_in()) { | |
| 915 | +		if ($receipt_session === $payment_meta['key']) { | |
| 916 | 916 | $return = true; | 
| 917 | 917 | } | 
| 918 | 918 | } | 
| 919 | 919 | |
| 920 | 920 | // Check whether it is history access session? | 
| 921 | -	if ( true === give_get_history_session() ) { | |
| 921 | +	if (true === give_get_history_session()) { | |
| 922 | 922 | $return = true; | 
| 923 | 923 | } | 
| 924 | 924 | |
| 925 | - return (bool) apply_filters( 'give_can_view_receipt', $return, $payment_key ); | |
| 925 | +	return (bool) apply_filters('give_can_view_receipt', $return, $payment_key); | |
| 926 | 926 | |
| 927 | 927 | } | 
| 928 | 928 | |
| @@ -931,7 +931,7 @@ discard block | ||
| 931 | 931 | * | 
| 932 | 932 | * Fallback in case the calendar extension is not loaded in PHP; Only supports Gregorian calendar | 
| 933 | 933 | */ | 
| 934 | -if ( ! function_exists( 'cal_days_in_month' ) ) { | |
| 934 | +if ( ! function_exists('cal_days_in_month')) { | |
| 935 | 935 | /** | 
| 936 | 936 | * cal_days_in_month | 
| 937 | 937 | * | 
| @@ -941,8 +941,8 @@ discard block | ||
| 941 | 941 | * | 
| 942 | 942 | * @return bool|string | 
| 943 | 943 | */ | 
| 944 | -	function cal_days_in_month( $calendar, $month, $year ) { | |
| 945 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); | |
| 944 | +	function cal_days_in_month($calendar, $month, $year) { | |
| 945 | +		return date('t', mktime(0, 0, 0, $month, 1, $year)); | |
| 946 | 946 | } | 
| 947 | 947 | } | 
| 948 | 948 | |
| @@ -961,40 +961,40 @@ discard block | ||
| 961 | 961 | */ | 
| 962 | 962 |  function give_get_plugins() { | 
| 963 | 963 | $plugins = get_plugins(); | 
| 964 | - $active_plugin_paths = (array) get_option( 'active_plugins', array() ); | |
| 964 | +	$active_plugin_paths = (array) get_option('active_plugins', array()); | |
| 965 | 965 | |
| 966 | -	if ( is_multisite() ) { | |
| 967 | - $network_activated_plugin_paths = array_keys( get_site_option( 'active_sitewide_plugins', array() ) ); | |
| 968 | - $active_plugin_paths = array_merge( $active_plugin_paths, $network_activated_plugin_paths ); | |
| 966 | +	if (is_multisite()) { | |
| 967 | +		$network_activated_plugin_paths = array_keys(get_site_option('active_sitewide_plugins', array())); | |
| 968 | + $active_plugin_paths = array_merge($active_plugin_paths, $network_activated_plugin_paths); | |
| 969 | 969 | } | 
| 970 | 970 | |
| 971 | -	foreach ( $plugins as $plugin_path => $plugin_data ) { | |
| 971 | +	foreach ($plugins as $plugin_path => $plugin_data) { | |
| 972 | 972 | // Is plugin active? | 
| 973 | -		if ( in_array( $plugin_path, $active_plugin_paths ) ) { | |
| 974 | - $plugins[ $plugin_path ]['Status'] = 'active'; | |
| 973 | +		if (in_array($plugin_path, $active_plugin_paths)) { | |
| 974 | + $plugins[$plugin_path]['Status'] = 'active'; | |
| 975 | 975 |  		} else { | 
| 976 | - $plugins[ $plugin_path ]['Status'] = 'inactive'; | |
| 976 | + $plugins[$plugin_path]['Status'] = 'inactive'; | |
| 977 | 977 | } | 
| 978 | 978 | |
| 979 | - $dirname = strtolower( dirname( $plugin_path ) ); | |
| 979 | + $dirname = strtolower(dirname($plugin_path)); | |
| 980 | 980 | |
| 981 | 981 | // Is plugin a Give add-on by WordImpress? | 
| 982 | -		if ( strstr( $dirname, 'give-' ) && strstr( $plugin_data['AuthorURI'], 'wordimpress.com' ) ) { | |
| 982 | +		if (strstr($dirname, 'give-') && strstr($plugin_data['AuthorURI'], 'wordimpress.com')) { | |
| 983 | 983 | // Plugin is a Give-addon. | 
| 984 | - $plugins[ $plugin_path ]['Type'] = 'add-on'; | |
| 984 | + $plugins[$plugin_path]['Type'] = 'add-on'; | |
| 985 | 985 | |
| 986 | 986 | /* @var stdClass $license_active */ | 
| 987 | - $license_active = __give_get_active_license_info( Give_License::get_short_name( $plugin_data['Name'] ) ); | |
| 987 | + $license_active = __give_get_active_license_info(Give_License::get_short_name($plugin_data['Name'])); | |
| 988 | 988 | |
| 989 | 989 | // Does a valid license exist? | 
| 990 | -			if ( ! empty( $license_active ) && 'valid' === $license_active->license ) { | |
| 991 | - $plugins[ $plugin_path ]['License'] = true; | |
| 990 | +			if ( ! empty($license_active) && 'valid' === $license_active->license) { | |
| 991 | + $plugins[$plugin_path]['License'] = true; | |
| 992 | 992 |  			} else { | 
| 993 | - $plugins[ $plugin_path ]['License'] = false; | |
| 993 | + $plugins[$plugin_path]['License'] = false; | |
| 994 | 994 | } | 
| 995 | 995 |  		} else { | 
| 996 | 996 | // Plugin is not a Give add-on. | 
| 997 | - $plugins[ $plugin_path ]['Type'] = 'other'; | |
| 997 | + $plugins[$plugin_path]['Type'] = 'other'; | |
| 998 | 998 | } | 
| 999 | 999 | } | 
| 1000 | 1000 | |
| @@ -1010,16 +1010,16 @@ discard block | ||
| 1010 | 1010 | * | 
| 1011 | 1011 | * @return bool | 
| 1012 | 1012 | */ | 
| 1013 | -function give_is_terms_enabled( $form_id ) { | |
| 1014 | - $form_option = give_get_meta( $form_id, '_give_terms_option', true ); | |
| 1013 | +function give_is_terms_enabled($form_id) { | |
| 1014 | + $form_option = give_get_meta($form_id, '_give_terms_option', true); | |
| 1015 | 1015 | |
| 1016 | 1016 | if ( | 
| 1017 | - give_is_setting_enabled( $form_option, 'global' ) | |
| 1018 | - && give_is_setting_enabled( give_get_option( 'terms' ) ) | |
| 1017 | + give_is_setting_enabled($form_option, 'global') | |
| 1018 | +		&& give_is_setting_enabled(give_get_option('terms')) | |
| 1019 | 1019 |  	) { | 
| 1020 | 1020 | return true; | 
| 1021 | 1021 | |
| 1022 | -	} elseif ( give_is_setting_enabled( $form_option ) ) { | |
| 1022 | +	} elseif (give_is_setting_enabled($form_option)) { | |
| 1023 | 1023 | return true; | 
| 1024 | 1024 | |
| 1025 | 1025 |  	} else { | 
| @@ -1043,10 +1043,10 @@ discard block | ||
| 1043 | 1043 | * | 
| 1044 | 1044 | * @return WP_Error|bool | 
| 1045 | 1045 | */ | 
| 1046 | -function give_delete_donation_stats( $date_range = '', $args = array() ) { | |
| 1046 | +function give_delete_donation_stats($date_range = '', $args = array()) { | |
| 1047 | 1047 | |
| 1048 | 1048 | // Delete all cache. | 
| 1049 | - $status = Give_Cache::delete( Give_Cache::get_options_like( 'give_stats' ) ); | |
| 1049 | +	$status = Give_Cache::delete(Give_Cache::get_options_like('give_stats')); | |
| 1050 | 1050 | |
| 1051 | 1051 | /** | 
| 1052 | 1052 | * Fire the action when donation stats delete. | 
| @@ -1056,7 +1056,7 @@ discard block | ||
| 1056 | 1056 | * @param string|array $date_range | 
| 1057 | 1057 | * @param array $args | 
| 1058 | 1058 | */ | 
| 1059 | - do_action( 'give_delete_donation_stats', $status, $date_range, $args ); | |
| 1059 | +	do_action('give_delete_donation_stats', $status, $date_range, $args); | |
| 1060 | 1060 | |
| 1061 | 1061 | return $status; | 
| 1062 | 1062 | } | 
| @@ -1070,7 +1070,7 @@ discard block | ||
| 1070 | 1070 |  function give_is_add_new_form_page() { | 
| 1071 | 1071 | $status = false; | 
| 1072 | 1072 | |
| 1073 | -	if ( false !== strpos( $_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms' ) ) { | |
| 1073 | +	if (false !== strpos($_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms')) { | |
| 1074 | 1074 | $status = true; | 
| 1075 | 1075 | } | 
| 1076 | 1076 | |
| @@ -1093,7 +1093,7 @@ discard block | ||
| 1093 | 1093 | * | 
| 1094 | 1094 | * @return mixed | 
| 1095 | 1095 | */ | 
| 1096 | -function give_get_meta( $id, $meta_key = '', $single = false, $default = false ) { | |
| 1096 | +function give_get_meta($id, $meta_key = '', $single = false, $default = false) { | |
| 1097 | 1097 | /** | 
| 1098 | 1098 | * Filter the meta value | 
| 1099 | 1099 | * | 
| @@ -1101,14 +1101,14 @@ discard block | ||
| 1101 | 1101 | */ | 
| 1102 | 1102 | $meta_value = apply_filters( | 
| 1103 | 1103 | 'give_get_meta', | 
| 1104 | - get_post_meta( $id, $meta_key, $single ), | |
| 1104 | + get_post_meta($id, $meta_key, $single), | |
| 1105 | 1105 | $id, | 
| 1106 | 1106 | $meta_key, | 
| 1107 | 1107 | $default | 
| 1108 | 1108 | ); | 
| 1109 | 1109 | |
| 1110 | 1110 | if ( | 
| 1111 | - ( empty( $meta_key ) || empty( $meta_value ) ) | |
| 1111 | + (empty($meta_key) || empty($meta_value)) | |
| 1112 | 1112 | && $default | 
| 1113 | 1113 |  	) { | 
| 1114 | 1114 | $meta_value = $default; | 
| @@ -1129,15 +1129,15 @@ discard block | ||
| 1129 | 1129 | * | 
| 1130 | 1130 | * @return mixed | 
| 1131 | 1131 | */ | 
| 1132 | -function give_update_meta( $id, $meta_key, $meta_value, $prev_value = '' ) { | |
| 1133 | - $status = update_post_meta( $id, $meta_key, $meta_value, $prev_value ); | |
| 1132 | +function give_update_meta($id, $meta_key, $meta_value, $prev_value = '') { | |
| 1133 | + $status = update_post_meta($id, $meta_key, $meta_value, $prev_value); | |
| 1134 | 1134 | |
| 1135 | 1135 | /** | 
| 1136 | 1136 | * Filter the meta value update status | 
| 1137 | 1137 | * | 
| 1138 | 1138 | * @since 1.8.8 | 
| 1139 | 1139 | */ | 
| 1140 | - return apply_filters( 'give_update_meta', $status, $id, $meta_key, $meta_value ); | |
| 1140 | +	return apply_filters('give_update_meta', $status, $id, $meta_key, $meta_value); | |
| 1141 | 1141 | } | 
| 1142 | 1142 | |
| 1143 | 1143 | /** | 
| @@ -1151,15 +1151,15 @@ discard block | ||
| 1151 | 1151 | * | 
| 1152 | 1152 | * @return mixed | 
| 1153 | 1153 | */ | 
| 1154 | -function give_delete_meta( $id, $meta_key, $meta_value = '' ) { | |
| 1155 | - $status = delete_post_meta( $id, $meta_key, $meta_value ); | |
| 1154 | +function give_delete_meta($id, $meta_key, $meta_value = '') { | |
| 1155 | + $status = delete_post_meta($id, $meta_key, $meta_value); | |
| 1156 | 1156 | |
| 1157 | 1157 | /** | 
| 1158 | 1158 | * Filter the meta value delete status | 
| 1159 | 1159 | * | 
| 1160 | 1160 | * @since 1.8.8 | 
| 1161 | 1161 | */ | 
| 1162 | - return apply_filters( 'give_delete_meta', $status, $id, $meta_key, $meta_value ); | |
| 1162 | +	return apply_filters('give_delete_meta', $status, $id, $meta_key, $meta_value); | |
| 1163 | 1163 | } | 
| 1164 | 1164 | |
| 1165 | 1165 | /** | 
| @@ -1171,23 +1171,23 @@ discard block | ||
| 1171 | 1171 | * | 
| 1172 | 1172 | * @return bool If the action has been added to the completed actions array | 
| 1173 | 1173 | */ | 
| 1174 | -function give_has_upgrade_completed( $upgrade_action = '' ) { | |
| 1174 | +function give_has_upgrade_completed($upgrade_action = '') { | |
| 1175 | 1175 | // Bailout. | 
| 1176 | -	if ( empty( $upgrade_action ) ) { | |
| 1176 | +	if (empty($upgrade_action)) { | |
| 1177 | 1177 | return false; | 
| 1178 | 1178 | } | 
| 1179 | 1179 | |
| 1180 | 1180 | // Fresh install? | 
| 1181 | 1181 | // If fresh install then all upgrades will be consider as completed. | 
| 1182 | - $is_fresh_install = ! get_option( 'give_version' ); | |
| 1183 | -	if ( $is_fresh_install ) { | |
| 1182 | +	$is_fresh_install = ! get_option('give_version'); | |
| 1183 | +	if ($is_fresh_install) { | |
| 1184 | 1184 | return true; | 
| 1185 | 1185 | } | 
| 1186 | 1186 | |
| 1187 | 1187 | |
| 1188 | 1188 | $completed_upgrades = give_get_completed_upgrades(); | 
| 1189 | 1189 | |
| 1190 | - return in_array( $upgrade_action, $completed_upgrades ); | |
| 1190 | + return in_array($upgrade_action, $completed_upgrades); | |
| 1191 | 1191 | |
| 1192 | 1192 | } | 
| 1193 | 1193 | |
| @@ -1199,8 +1199,8 @@ discard block | ||
| 1199 | 1199 | * @return mixed When nothing to resume returns false, otherwise starts the upgrade where it left off | 
| 1200 | 1200 | */ | 
| 1201 | 1201 |  function give_maybe_resume_upgrade() { | 
| 1202 | - $doing_upgrade = get_option( 'give_doing_upgrade', false ); | |
| 1203 | -	if ( empty( $doing_upgrade ) ) { | |
| 1202 | +	$doing_upgrade = get_option('give_doing_upgrade', false); | |
| 1203 | +	if (empty($doing_upgrade)) { | |
| 1204 | 1204 | return false; | 
| 1205 | 1205 | } | 
| 1206 | 1206 | |
| @@ -1216,9 +1216,9 @@ discard block | ||
| 1216 | 1216 | * | 
| 1217 | 1217 | * @return bool If the function was successfully added | 
| 1218 | 1218 | */ | 
| 1219 | -function give_set_upgrade_complete( $upgrade_action = '' ) { | |
| 1219 | +function give_set_upgrade_complete($upgrade_action = '') { | |
| 1220 | 1220 | |
| 1221 | -	if ( empty( $upgrade_action ) ) { | |
| 1221 | +	if (empty($upgrade_action)) { | |
| 1222 | 1222 | return false; | 
| 1223 | 1223 | } | 
| 1224 | 1224 | |
| @@ -1226,16 +1226,16 @@ discard block | ||
| 1226 | 1226 | $completed_upgrades[] = $upgrade_action; | 
| 1227 | 1227 | |
| 1228 | 1228 | // Remove any blanks, and only show uniques. | 
| 1229 | - $completed_upgrades = array_unique( array_values( $completed_upgrades ) ); | |
| 1229 | + $completed_upgrades = array_unique(array_values($completed_upgrades)); | |
| 1230 | 1230 | |
| 1231 | 1231 | /** | 
| 1232 | 1232 | * Fire the action when any upgrade set to complete. | 
| 1233 | 1233 | * | 
| 1234 | 1234 | * @since 1.8.12 | 
| 1235 | 1235 | */ | 
| 1236 | - do_action( 'give_set_upgrade_completed', $upgrade_action, $completed_upgrades ); | |
| 1236 | +	do_action('give_set_upgrade_completed', $upgrade_action, $completed_upgrades); | |
| 1237 | 1237 | |
| 1238 | - return update_option( 'give_completed_upgrades', $completed_upgrades, 'no' ); | |
| 1238 | +	return update_option('give_completed_upgrades', $completed_upgrades, 'no'); | |
| 1239 | 1239 | } | 
| 1240 | 1240 | |
| 1241 | 1241 | /** | 
| @@ -1245,7 +1245,7 @@ discard block | ||
| 1245 | 1245 | * @return array The array of completed upgrades | 
| 1246 | 1246 | */ | 
| 1247 | 1247 |  function give_get_completed_upgrades() { | 
| 1248 | - return (array) get_option( 'give_completed_upgrades' ); | |
| 1248 | +	return (array) get_option('give_completed_upgrades'); | |
| 1249 | 1249 | } | 
| 1250 | 1250 | |
| 1251 | 1251 | /** | 
| @@ -1260,16 +1260,16 @@ discard block | ||
| 1260 | 1260 | * | 
| 1261 | 1261 | * @return null|array | 
| 1262 | 1262 | */ | 
| 1263 | -function __give_v20_bc_table_details( $type ) { | |
| 1263 | +function __give_v20_bc_table_details($type) { | |
| 1264 | 1264 | global $wpdb; | 
| 1265 | 1265 | $table = array(); | 
| 1266 | 1266 | |
| 1267 | 1267 | // Bailout. | 
| 1268 | -	if ( empty( $type ) ) { | |
| 1268 | +	if (empty($type)) { | |
| 1269 | 1269 | return null; | 
| 1270 | 1270 | } | 
| 1271 | 1271 | |
| 1272 | -	switch ( $type ) { | |
| 1272 | +	switch ($type) { | |
| 1273 | 1273 | case 'form': | 
| 1274 | 1274 | $table['name'] = $wpdb->formmeta; | 
| 1275 | 1275 | $table['column']['id'] = 'form_id'; | 
| @@ -1282,7 +1282,7 @@ discard block | ||
| 1282 | 1282 | } | 
| 1283 | 1283 | |
| 1284 | 1284 | // Backward compatibility. | 
| 1285 | -	if ( ! give_has_upgrade_completed( 'v20_move_metadata_into_new_table' ) ) { | |
| 1285 | +	if ( ! give_has_upgrade_completed('v20_move_metadata_into_new_table')) { | |
| 1286 | 1286 | $table['name'] = $wpdb->postmeta; | 
| 1287 | 1287 | $table['column']['id'] = 'post_id'; | 
| 1288 | 1288 | } | 
| @@ -1298,12 +1298,12 @@ discard block | ||
| 1298 | 1298 | * | 
| 1299 | 1299 | * @param WP_Query $query | 
| 1300 | 1300 | */ | 
| 1301 | -function give_remove_pages_from_search( $query ) { | |
| 1301 | +function give_remove_pages_from_search($query) { | |
| 1302 | 1302 | |
| 1303 | -	if ( ! $query->is_admin && $query->is_search && $query->is_main_query() ) { | |
| 1303 | +	if ( ! $query->is_admin && $query->is_search && $query->is_main_query()) { | |
| 1304 | 1304 | |
| 1305 | - $transaction_failed = give_get_option( 'failure_page', 0 ); | |
| 1306 | - $success_page = give_get_option( 'success_page', 0 ); | |
| 1305 | +		$transaction_failed = give_get_option('failure_page', 0); | |
| 1306 | +		$success_page       = give_get_option('success_page', 0); | |
| 1307 | 1307 | |
| 1308 | 1308 | $args = apply_filters( | 
| 1309 | 1309 | 'give_remove_pages_from_search', array( | 
| @@ -1311,11 +1311,11 @@ discard block | ||
| 1311 | 1311 | $success_page, | 
| 1312 | 1312 | ), $query | 
| 1313 | 1313 | ); | 
| 1314 | - $query->set( 'post__not_in', $args ); | |
| 1314 | +		$query->set('post__not_in', $args); | |
| 1315 | 1315 | } | 
| 1316 | 1316 | } | 
| 1317 | 1317 | |
| 1318 | -add_action( 'pre_get_posts', 'give_remove_pages_from_search', 10, 1 ); | |
| 1318 | +add_action('pre_get_posts', 'give_remove_pages_from_search', 10, 1); | |
| 1319 | 1319 | |
| 1320 | 1320 | /** | 
| 1321 | 1321 | * Inserts a new key/value before a key in the array. | 
| @@ -1331,14 +1331,14 @@ discard block | ||
| 1331 | 1331 | * | 
| 1332 | 1332 | * @see array_insert_before() | 
| 1333 | 1333 | */ | 
| 1334 | -function give_array_insert_before( $key, array &$array, $new_key, $new_value ) { | |
| 1335 | -	if ( array_key_exists( $key, $array ) ) { | |
| 1334 | +function give_array_insert_before($key, array &$array, $new_key, $new_value) { | |
| 1335 | +	if (array_key_exists($key, $array)) { | |
| 1336 | 1336 | $new = array(); | 
| 1337 | -		foreach ( $array as $k => $value ) { | |
| 1338 | -			if ( $k === $key ) { | |
| 1339 | - $new[ $new_key ] = $new_value; | |
| 1337 | +		foreach ($array as $k => $value) { | |
| 1338 | +			if ($k === $key) { | |
| 1339 | + $new[$new_key] = $new_value; | |
| 1340 | 1340 | } | 
| 1341 | - $new[ $k ] = $value; | |
| 1341 | + $new[$k] = $value; | |
| 1342 | 1342 | } | 
| 1343 | 1343 | |
| 1344 | 1344 | return $new; | 
| @@ -1361,13 +1361,13 @@ discard block | ||
| 1361 | 1361 | * | 
| 1362 | 1362 | * @see array_insert_before() | 
| 1363 | 1363 | */ | 
| 1364 | -function give_array_insert_after( $key, array &$array, $new_key, $new_value ) { | |
| 1365 | -	if ( array_key_exists( $key, $array ) ) { | |
| 1364 | +function give_array_insert_after($key, array &$array, $new_key, $new_value) { | |
| 1365 | +	if (array_key_exists($key, $array)) { | |
| 1366 | 1366 | $new = array(); | 
| 1367 | -		foreach ( $array as $k => $value ) { | |
| 1368 | - $new[ $k ] = $value; | |
| 1369 | -			if ( $k === $key ) { | |
| 1370 | - $new[ $new_key ] = $new_value; | |
| 1367 | +		foreach ($array as $k => $value) { | |
| 1368 | + $new[$k] = $value; | |
| 1369 | +			if ($k === $key) { | |
| 1370 | + $new[$new_key] = $new_value; | |
| 1371 | 1371 | } | 
| 1372 | 1372 | } | 
| 1373 | 1373 | |
| @@ -1394,21 +1394,21 @@ discard block | ||
| 1394 | 1394 | * corresponding to `$index_key`. If `$index_key` is null, array keys from the original | 
| 1395 | 1395 | * `$list` will be preserved in the results. | 
| 1396 | 1396 | */ | 
| 1397 | -function give_list_pluck( $list, $field, $index_key = null ) { | |
| 1397 | +function give_list_pluck($list, $field, $index_key = null) { | |
| 1398 | 1398 | |
| 1399 | -	if ( ! $index_key ) { | |
| 1399 | +	if ( ! $index_key) { | |
| 1400 | 1400 | /** | 
| 1401 | 1401 | * This is simple. Could at some point wrap array_column() | 
| 1402 | 1402 | * if we knew we had an array of arrays. | 
| 1403 | 1403 | */ | 
| 1404 | -		foreach ( $list as $key => $value ) { | |
| 1405 | -			if ( is_object( $value ) ) { | |
| 1406 | -				if ( isset( $value->$field ) ) { | |
| 1407 | - $list[ $key ] = $value->$field; | |
| 1404 | +		foreach ($list as $key => $value) { | |
| 1405 | +			if (is_object($value)) { | |
| 1406 | +				if (isset($value->$field)) { | |
| 1407 | + $list[$key] = $value->$field; | |
| 1408 | 1408 | } | 
| 1409 | 1409 |  			} else { | 
| 1410 | -				if ( isset( $value[ $field ] ) ) { | |
| 1411 | - $list[ $key ] = $value[ $field ]; | |
| 1410 | +				if (isset($value[$field])) { | |
| 1411 | + $list[$key] = $value[$field]; | |
| 1412 | 1412 | } | 
| 1413 | 1413 | } | 
| 1414 | 1414 | } | 
| @@ -1421,18 +1421,18 @@ discard block | ||
| 1421 | 1421 | * to the end of the stack. This is how array_column() behaves. | 
| 1422 | 1422 | */ | 
| 1423 | 1423 | $newlist = array(); | 
| 1424 | -	foreach ( $list as $value ) { | |
| 1425 | -		if ( is_object( $value ) ) { | |
| 1426 | -			if ( isset( $value->$index_key ) ) { | |
| 1427 | - $newlist[ $value->$index_key ] = $value->$field; | |
| 1424 | +	foreach ($list as $value) { | |
| 1425 | +		if (is_object($value)) { | |
| 1426 | +			if (isset($value->$index_key)) { | |
| 1427 | + $newlist[$value->$index_key] = $value->$field; | |
| 1428 | 1428 |  			} else { | 
| 1429 | 1429 | $newlist[] = $value->$field; | 
| 1430 | 1430 | } | 
| 1431 | 1431 |  		} else { | 
| 1432 | -			if ( isset( $value[ $index_key ] ) ) { | |
| 1433 | - $newlist[ $value[ $index_key ] ] = $value[ $field ]; | |
| 1432 | +			if (isset($value[$index_key])) { | |
| 1433 | + $newlist[$value[$index_key]] = $value[$field]; | |
| 1434 | 1434 |  			} else { | 
| 1435 | - $newlist[] = $value[ $field ]; | |
| 1435 | + $newlist[] = $value[$field]; | |
| 1436 | 1436 | } | 
| 1437 | 1437 | } | 
| 1438 | 1438 | } | 
| @@ -1455,8 +1455,8 @@ discard block | ||
| 1455 | 1455 | * | 
| 1456 | 1456 | * @return int|false Meta ID on success, false on failure. | 
| 1457 | 1457 | */ | 
| 1458 | -function add_donor_meta( $donor_id, $meta_key, $meta_value, $unique = false ) { | |
| 1459 | - return add_metadata( 'give_customer', $donor_id, $meta_key, $meta_value, $unique ); | |
| 1458 | +function add_donor_meta($donor_id, $meta_key, $meta_value, $unique = false) { | |
| 1459 | +	return add_metadata('give_customer', $donor_id, $meta_key, $meta_value, $unique); | |
| 1460 | 1460 | } | 
| 1461 | 1461 | |
| 1462 | 1462 | /** | 
| @@ -1474,8 +1474,8 @@ discard block | ||
| 1474 | 1474 | * | 
| 1475 | 1475 | * @return bool True on success, false on failure. | 
| 1476 | 1476 | */ | 
| 1477 | -function delete_donor_meta( $donor_id, $meta_key, $meta_value = '' ) { | |
| 1478 | - return delete_metadata( 'give_customer', $donor_id, $meta_key, $meta_value ); | |
| 1477 | +function delete_donor_meta($donor_id, $meta_key, $meta_value = '') { | |
| 1478 | +	return delete_metadata('give_customer', $donor_id, $meta_key, $meta_value); | |
| 1479 | 1479 | } | 
| 1480 | 1480 | |
| 1481 | 1481 | /** | 
| @@ -1490,8 +1490,8 @@ discard block | ||
| 1490 | 1490 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single | 
| 1491 | 1491 | * is true. | 
| 1492 | 1492 | */ | 
| 1493 | -function get_donor_meta( $donor_id, $key = '', $single = false ) { | |
| 1494 | - return get_metadata( 'give_customer', $donor_id, $key, $single ); | |
| 1493 | +function get_donor_meta($donor_id, $key = '', $single = false) { | |
| 1494 | +	return get_metadata('give_customer', $donor_id, $key, $single); | |
| 1495 | 1495 | } | 
| 1496 | 1496 | |
| 1497 | 1497 | /** | 
| @@ -1508,8 +1508,8 @@ discard block | ||
| 1508 | 1508 | * | 
| 1509 | 1509 | * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure. | 
| 1510 | 1510 | */ | 
| 1511 | -function update_donor_meta( $donor_id, $meta_key, $meta_value, $prev_value = '' ) { | |
| 1512 | - return update_metadata( 'give_customer', $donor_id, $meta_key, $meta_value, $prev_value ); | |
| 1511 | +function update_donor_meta($donor_id, $meta_key, $meta_value, $prev_value = '') { | |
| 1512 | +	return update_metadata('give_customer', $donor_id, $meta_key, $meta_value, $prev_value); | |
| 1513 | 1513 | } | 
| 1514 | 1514 | |
| 1515 | 1515 | |
| @@ -1522,15 +1522,15 @@ discard block | ||
| 1522 | 1522 | * | 
| 1523 | 1523 | * @return void | 
| 1524 | 1524 | */ | 
| 1525 | -function give_recount_form_income_donation( $form_id = 0 ) { | |
| 1525 | +function give_recount_form_income_donation($form_id = 0) { | |
| 1526 | 1526 | // Check if form id is not empty. | 
| 1527 | -	if ( ! empty( $form_id ) ) { | |
| 1527 | +	if ( ! empty($form_id)) { | |
| 1528 | 1528 | /** | 
| 1529 | 1529 | * Filter to modify payment status. | 
| 1530 | 1530 | * | 
| 1531 | 1531 | * @since 1.8.13 | 
| 1532 | 1532 | */ | 
| 1533 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); | |
| 1533 | +		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); | |
| 1534 | 1534 | |
| 1535 | 1535 | /** | 
| 1536 | 1536 | * Filter to modify args of payment query before recalculating the form total | 
| @@ -1541,7 +1541,7 @@ discard block | ||
| 1541 | 1541 | 'give_recount_form_stats_args', array( | 
| 1542 | 1542 | 'give_forms' => $form_id, | 
| 1543 | 1543 | 'status' => $accepted_statuses, | 
| 1544 | - 'posts_per_page' => - 1, | |
| 1544 | + 'posts_per_page' => -1, | |
| 1545 | 1545 | 'fields' => 'ids', | 
| 1546 | 1546 | ) | 
| 1547 | 1547 | ); | 
| @@ -1551,28 +1551,28 @@ discard block | ||
| 1551 | 1551 | 'earnings' => 0, | 
| 1552 | 1552 | ); | 
| 1553 | 1553 | |
| 1554 | - $payments = new Give_Payments_Query( $args ); | |
| 1554 | + $payments = new Give_Payments_Query($args); | |
| 1555 | 1555 | $payments = $payments->get_payments(); | 
| 1556 | 1556 | |
| 1557 | -		if ( $payments ) { | |
| 1558 | -			foreach ( $payments as $payment ) { | |
| 1557 | +		if ($payments) { | |
| 1558 | +			foreach ($payments as $payment) { | |
| 1559 | 1559 | // Ensure acceptible status only | 
| 1560 | -				if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { | |
| 1560 | +				if ( ! in_array($payment->post_status, $accepted_statuses)) { | |
| 1561 | 1561 | continue; | 
| 1562 | 1562 | } | 
| 1563 | 1563 | |
| 1564 | 1564 | // Ensure only payments for this form are counted | 
| 1565 | -				if ( $payment->form_id != $form_id ) { | |
| 1565 | +				if ($payment->form_id != $form_id) { | |
| 1566 | 1566 | continue; | 
| 1567 | 1567 | } | 
| 1568 | 1568 | |
| 1569 | - $totals['sales'] ++; | |
| 1569 | + $totals['sales']++; | |
| 1570 | 1570 | $totals['earnings'] += $payment->total; | 
| 1571 | 1571 | |
| 1572 | 1572 | } | 
| 1573 | 1573 | } | 
| 1574 | - give_update_meta( $form_id, '_give_form_sales', $totals['sales'] ); | |
| 1575 | - give_update_meta( $form_id, '_give_form_earnings', give_sanitize_amount_for_db( $totals['earnings'] ) ); | |
| 1574 | + give_update_meta($form_id, '_give_form_sales', $totals['sales']); | |
| 1575 | + give_update_meta($form_id, '_give_form_earnings', give_sanitize_amount_for_db($totals['earnings'])); | |
| 1576 | 1576 | }// End if(). | 
| 1577 | 1577 | } | 
| 1578 | 1578 | |
| @@ -1586,18 +1586,18 @@ discard block | ||
| 1586 | 1586 | * | 
| 1587 | 1587 | * @return string | 
| 1588 | 1588 | */ | 
| 1589 | -function give_get_attribute_str( $attributes ) { | |
| 1589 | +function give_get_attribute_str($attributes) { | |
| 1590 | 1590 | $attribute_str = ''; | 
| 1591 | 1591 | |
| 1592 | -	if ( empty( $attributes ) ) { | |
| 1592 | +	if (empty($attributes)) { | |
| 1593 | 1593 | return $attribute_str; | 
| 1594 | 1594 | } | 
| 1595 | 1595 | |
| 1596 | -	foreach ( $attributes as $tag => $value ) { | |
| 1596 | +	foreach ($attributes as $tag => $value) { | |
| 1597 | 1597 |  		$attribute_str .= " {$tag}=\"{$value}\""; | 
| 1598 | 1598 | } | 
| 1599 | 1599 | |
| 1600 | - return trim( $attribute_str ); | |
| 1600 | + return trim($attribute_str); | |
| 1601 | 1601 | } | 
| 1602 | 1602 | |
| 1603 | 1603 | /** | 
| @@ -1610,7 +1610,7 @@ discard block | ||
| 1610 | 1610 |  function give_get_wp_upload_dir() { | 
| 1611 | 1611 | $wp_upload_dir = wp_upload_dir(); | 
| 1612 | 1612 | |
| 1613 | - return ( ! empty( $wp_upload_dir['path'] ) ? $wp_upload_dir['path'] : false ); | |
| 1613 | + return ( ! empty($wp_upload_dir['path']) ? $wp_upload_dir['path'] : false); | |
| 1614 | 1614 | } | 
| 1615 | 1615 | |
| 1616 | 1616 | /** | 
| @@ -1622,15 +1622,15 @@ discard block | ||
| 1622 | 1622 | * | 
| 1623 | 1623 | * @return string|bool $file_contents File content | 
| 1624 | 1624 | */ | 
| 1625 | -function give_get_core_settings_json( $file_name ) { | |
| 1625 | +function give_get_core_settings_json($file_name) { | |
| 1626 | 1626 | $upload_dir = give_get_wp_upload_dir(); | 
| 1627 | - $file_path = $upload_dir . '/' . $file_name; | |
| 1627 | + $file_path = $upload_dir.'/'.$file_name; | |
| 1628 | 1628 | |
| 1629 | -	if ( is_wp_error( $file_path ) || empty( $file_path ) ) { | |
| 1630 | - Give_Admin_Settings::add_error( 'give-import-csv', __( 'Please upload or provide a valid JSON file.', 'give' ) ); | |
| 1629 | +	if (is_wp_error($file_path) || empty($file_path)) { | |
| 1630 | +		Give_Admin_Settings::add_error('give-import-csv', __('Please upload or provide a valid JSON file.', 'give')); | |
| 1631 | 1631 | } | 
| 1632 | 1632 | |
| 1633 | - $file_contents = file_get_contents( $file_path ); | |
| 1633 | + $file_contents = file_get_contents($file_path); | |
| 1634 | 1634 | |
| 1635 | 1635 | return $file_contents; | 
| 1636 | 1636 | } | 
| @@ -1643,7 +1643,7 @@ discard block | ||
| 1643 | 1643 | * @return int $country The two letter country code for the site's base country | 
| 1644 | 1644 | */ | 
| 1645 | 1645 |  function give_get_limit_display_donations() { | 
| 1646 | - return give_get_option( 'limit_display_donations', 1 ); | |
| 1646 | +	return give_get_option('limit_display_donations', 1); | |
| 1647 | 1647 | } | 
| 1648 | 1648 | |
| 1649 | 1649 | /** | 
| @@ -1652,7 +1652,7 @@ discard block | ||
| 1652 | 1652 | * @since 1.8.17 | 
| 1653 | 1653 | */ | 
| 1654 | 1654 |  function give_donation_history_table_end() { | 
| 1655 | - $email = Give()->session->get( 'give_email' ); | |
| 1655 | +	$email = Give()->session->get('give_email'); | |
| 1656 | 1656 | ?> | 
| 1657 | 1657 | <tfoot> | 
| 1658 | 1658 | <tr> | 
| @@ -1661,16 +1661,16 @@ discard block | ||
| 1661 | 1661 | <div class="give-security-column give-security-description-wrap"> | 
| 1662 | 1662 | <?php | 
| 1663 | 1663 | echo sprintf( | 
| 1664 | - __( 'For security reasons, please confirm your email address (%s) to view your complete donation history.', 'give' ), | |
| 1664 | +						__('For security reasons, please confirm your email address (%s) to view your complete donation history.', 'give'), | |
| 1665 | 1665 | |
| 1666 | 1666 | ); | 
| 1667 | 1667 | ?> | 
| 1668 | 1668 | </div> | 
| 1669 | 1669 | <div class="give-security-column give-security-button-wrap"> | 
| 1670 | 1670 | <a href="#" data-email="<?php echo $email; ?>" id="give-confirm-email-btn" class="give-confirm-email-btn give-btn"> | 
| 1671 | - <?php _e( 'Confirm Email', 'give' ); ?> | |
| 1671 | +						<?php _e('Confirm Email', 'give'); ?> | |
| 1672 | 1672 | </a> | 
| 1673 | - <span><?php _e( 'Email Sent!', 'give' ); ?></span> | |
| 1673 | +					<span><?php _e('Email Sent!', 'give'); ?></span> | |
| 1674 | 1674 | </div> | 
| 1675 | 1675 | </div> | 
| 1676 | 1676 | </td> | 
| @@ -1690,10 +1690,10 @@ discard block | ||
| 1690 | 1690 | * | 
| 1691 | 1691 | * @return void | 
| 1692 | 1692 | */ | 
| 1693 | -function give_doing_it_wrong( $function, $message, $version ) { | |
| 1694 | - $message .= "\nBacktrace:" . wp_debug_backtrace_summary(); | |
| 1693 | +function give_doing_it_wrong($function, $message, $version) { | |
| 1694 | + $message .= "\nBacktrace:".wp_debug_backtrace_summary(); | |
| 1695 | 1695 | |
| 1696 | - _doing_it_wrong( $function, $message , $version ); | |
| 1696 | + _doing_it_wrong($function, $message, $version); | |
| 1697 | 1697 | } | 
| 1698 | 1698 | |
| 1699 | 1699 | |
| @@ -1702,11 +1702,11 @@ discard block | ||
| 1702 | 1702 | * | 
| 1703 | 1703 | * @since 1.8.18 | 
| 1704 | 1704 | */ | 
| 1705 | -function give_ignore_user_abort(){ | |
| 1706 | - ignore_user_abort( true ); | |
| 1705 | +function give_ignore_user_abort() { | |
| 1706 | + ignore_user_abort(true); | |
| 1707 | 1707 | |
| 1708 | -	if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { | |
| 1709 | - set_time_limit( 0 ); | |
| 1708 | +	if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { | |
| 1709 | + set_time_limit(0); | |
| 1710 | 1710 | } | 
| 1711 | 1711 | } | 
| 1712 | 1712 | |
| @@ -1720,28 +1720,28 @@ discard block | ||
| 1720 | 1720 | * | 
| 1721 | 1721 | * @return int | 
| 1722 | 1722 | */ | 
| 1723 | -function give_get_total_post_type_count( $post_type = '', $args = array() ){ | |
| 1723 | +function give_get_total_post_type_count($post_type = '', $args = array()) { | |
| 1724 | 1724 | global $wpdb; | 
| 1725 | 1725 | $where = ''; | 
| 1726 | 1726 | |
| 1727 | -	if( ! $post_type ) { | |
| 1727 | +	if ( ! $post_type) { | |
| 1728 | 1728 | return 0; | 
| 1729 | 1729 | } | 
| 1730 | 1730 | |
| 1731 | 1731 | // Bulit where query | 
| 1732 | -	if( ! empty( $post_type ) ) { | |
| 1733 | - $where.=' WHERE'; | |
| 1732 | +	if ( ! empty($post_type)) { | |
| 1733 | + $where .= ' WHERE'; | |
| 1734 | 1734 | |
| 1735 | -		if( is_array( $post_type ) ) { | |
| 1736 | - $where .= " post_type='" . implode( "' OR post_type='", $post_type ) . "'"; | |
| 1737 | -		}else{ | |
| 1735 | +		if (is_array($post_type)) { | |
| 1736 | +			$where .= " post_type='".implode("' OR post_type='", $post_type)."'"; | |
| 1737 | +		} else { | |
| 1738 | 1738 |  			$where .= " post_type='{$post_type}'"; | 
| 1739 | 1739 | } | 
| 1740 | 1740 | } | 
| 1741 | 1741 | |
| 1742 | 1742 |  	$result = $wpdb->get_var("SELECT count(ID) FROM {$wpdb->posts}{$where}"); | 
| 1743 | 1743 | |
| 1744 | - return absint( $result ); | |
| 1744 | + return absint($result); | |
| 1745 | 1745 | } | 
| 1746 | 1746 | |
| 1747 | 1747 | /** | 
| @@ -1753,9 +1753,9 @@ discard block | ||
| 1753 | 1753 | * | 
| 1754 | 1754 | * @credit WooCommerce | 
| 1755 | 1755 | */ | 
| 1756 | -function give_maybe_define_constant( $name, $value ) { | |
| 1757 | -	if ( ! defined( $name ) ) { | |
| 1758 | - define( $name, $value ); | |
| 1756 | +function give_maybe_define_constant($name, $value) { | |
| 1757 | +	if ( ! defined($name)) { | |
| 1758 | + define($name, $value); | |
| 1759 | 1759 | } | 
| 1760 | 1760 | } | 
| 1761 | 1761 | |
| @@ -1769,8 +1769,8 @@ discard block | ||
| 1769 | 1769 | * | 
| 1770 | 1770 | * @return string | 
| 1771 | 1771 | */ | 
| 1772 | -function give_time_do_tags( $string, $timestamp = 0 ) { | |
| 1773 | - $current_time = ! empty( $timestamp ) ? $timestamp : current_time( 'timestamp' ); | |
| 1772 | +function give_time_do_tags($string, $timestamp = 0) { | |
| 1773 | +	$current_time = ! empty($timestamp) ? $timestamp : current_time('timestamp'); | |
| 1774 | 1774 | |
| 1775 | 1775 | $formatted_string = str_replace( | 
| 1776 | 1776 | array( | 
| @@ -1786,15 +1786,15 @@ discard block | ||
| 1786 | 1786 |  			'{S}' | 
| 1787 | 1787 | ), | 
| 1788 | 1788 | array( | 
| 1789 | - date( 'j', $current_time ), | |
| 1790 | - date( 'd', $current_time ), | |
| 1791 | - date( 'n', $current_time ), | |
| 1792 | - date( 'm', $current_time ), | |
| 1793 | - date( 'Y', $current_time ), | |
| 1794 | - date( 'Y', $current_time ), | |
| 1795 | - date( 'G', $current_time ), | |
| 1796 | - date( 'H', $current_time ), | |
| 1797 | - date( 's', $current_time ) | |
| 1789 | +			date('j', $current_time), | |
| 1790 | +			date('d', $current_time), | |
| 1791 | +			date('n', $current_time), | |
| 1792 | +			date('m', $current_time), | |
| 1793 | +			date('Y', $current_time), | |
| 1794 | +			date('Y', $current_time), | |
| 1795 | +			date('G', $current_time), | |
| 1796 | +			date('H', $current_time), | |
| 1797 | +			date('s', $current_time) | |
| 1798 | 1798 | ), | 
| 1799 | 1799 | $string | 
| 1800 | 1800 | ); | 
| @@ -1804,7 +1804,7 @@ discard block | ||
| 1804 | 1804 | * | 
| 1805 | 1805 | * @since 2.1.0 | 
| 1806 | 1806 | */ | 
| 1807 | - return apply_filters( 'give_time_do_tags', $formatted_string, $string, $timestamp ); | |
| 1807 | +	return apply_filters('give_time_do_tags', $formatted_string, $string, $timestamp); | |
| 1808 | 1808 | } | 
| 1809 | 1809 | |
| 1810 | 1810 | |
| @@ -1817,20 +1817,20 @@ discard block | ||
| 1817 | 1817 | * | 
| 1818 | 1818 | * @return bool | 
| 1819 | 1819 | */ | 
| 1820 | -function give_is_company_field_enabled( $form_id ) { | |
| 1821 | - $form_setting_val = give_get_meta( $form_id, '_give_company_field', true ); | |
| 1822 | - $global_setting_val = give_get_option( 'company_field' ); | |
| 1820 | +function give_is_company_field_enabled($form_id) { | |
| 1821 | + $form_setting_val = give_get_meta($form_id, '_give_company_field', true); | |
| 1822 | +	$global_setting_val = give_get_option('company_field'); | |
| 1823 | 1823 | |
| 1824 | -	if ( ! empty( $form_setting_val ) ) { | |
| 1825 | -		if( give_is_setting_enabled( $form_setting_val, array( 'required', 'optional' ) ) ) { | |
| 1824 | +	if ( ! empty($form_setting_val)) { | |
| 1825 | +		if (give_is_setting_enabled($form_setting_val, array('required', 'optional'))) { | |
| 1826 | 1826 | return true; | 
| 1827 | -		} elseif ( 'global' === $form_setting_val && give_is_setting_enabled( $global_setting_val, array( 'required', 'optional' ) ) ) { | |
| 1827 | +		} elseif ('global' === $form_setting_val && give_is_setting_enabled($global_setting_val, array('required', 'optional'))) { | |
| 1828 | 1828 | return true; | 
| 1829 | -		} else{ | |
| 1829 | +		} else { | |
| 1830 | 1830 | return false; | 
| 1831 | 1831 | } | 
| 1832 | 1832 | |
| 1833 | -	} elseif ( give_is_setting_enabled( $global_setting_val, array( 'required', 'optional' ) ) ) { | |
| 1833 | +	} elseif (give_is_setting_enabled($global_setting_val, array('required', 'optional'))) { | |
| 1834 | 1834 | return true; | 
| 1835 | 1835 | |
| 1836 | 1836 |  	} else { | 
| @@ -1848,13 +1848,13 @@ discard block | ||
| 1848 | 1848 | * | 
| 1849 | 1849 | * @return array | 
| 1850 | 1850 | */ | 
| 1851 | -function __give_get_active_license_info( $license_id ) { | |
| 1851 | +function __give_get_active_license_info($license_id) { | |
| 1852 | 1852 | global $wpdb; | 
| 1853 | 1853 |  	$option_name = "{$license_id}_license_active"; | 
| 1854 | 1854 | $data = array(); | 
| 1855 | 1855 | |
| 1856 | -	if ( ! isset( $GLOBALS['give_active_licenses_info'] ) ) { | |
| 1857 | - $GLOBALS['give_active_licenses_info'] = array(); | |
| 1856 | +	if ( ! isset($GLOBALS['give_active_licenses_info'])) { | |
| 1857 | + $GLOBALS['give_active_licenses_info'] = array(); | |
| 1858 | 1858 | |
| 1859 | 1859 | $licenses_info = $wpdb->get_results( | 
| 1860 | 1860 | " | 
| @@ -1866,16 +1866,16 @@ discard block | ||
| 1866 | 1866 | ARRAY_A | 
| 1867 | 1867 | ); | 
| 1868 | 1868 | |
| 1869 | -		if ( ! empty( $licenses_info ) ) { | |
| 1869 | +		if ( ! empty($licenses_info)) { | |
| 1870 | 1870 | $GLOBALS['give_active_licenses_info'] = array_combine( | 
| 1871 | - wp_list_pluck( $licenses_info, 'option_name' ), | |
| 1872 | - wp_list_pluck( $licenses_info, 'option_value' ) | |
| 1871 | + wp_list_pluck($licenses_info, 'option_name'), | |
| 1872 | + wp_list_pluck($licenses_info, 'option_value') | |
| 1873 | 1873 | ); | 
| 1874 | 1874 | } | 
| 1875 | 1875 | } | 
| 1876 | 1876 | |
| 1877 | -	if ( in_array( $option_name, array_keys( $GLOBALS['give_active_licenses_info'] ) ) ) { | |
| 1878 | - $data = maybe_unserialize( $GLOBALS['give_active_licenses_info'][ $option_name ] ); | |
| 1877 | +	if (in_array($option_name, array_keys($GLOBALS['give_active_licenses_info']))) { | |
| 1878 | + $data = maybe_unserialize($GLOBALS['give_active_licenses_info'][$option_name]); | |
| 1879 | 1879 | } | 
| 1880 | 1880 | |
| 1881 | 1881 | return $data; | 
| @@ -1891,18 +1891,18 @@ discard block | ||
| 1891 | 1891 | * | 
| 1892 | 1892 | * @return array | 
| 1893 | 1893 | */ | 
| 1894 | -function __give_get_active_by_user_meta( $banner_addon_name ) { | |
| 1894 | +function __give_get_active_by_user_meta($banner_addon_name) { | |
| 1895 | 1895 | global $wpdb; | 
| 1896 | 1896 | |
| 1897 | 1897 | // Get the option key. | 
| 1898 | - $option_name = Give_Addon_Activation_Banner::get_banner_user_meta_key( $banner_addon_name ); | |
| 1898 | + $option_name = Give_Addon_Activation_Banner::get_banner_user_meta_key($banner_addon_name); | |
| 1899 | 1899 | $data = array(); | 
| 1900 | 1900 | |
| 1901 | 1901 | if ( | 
| 1902 | - ! isset( $GLOBALS['give_addon_activated_by_user'][ $banner_addon_name ] ) | |
| 1903 | - || empty( $GLOBALS['give_addon_activated_by_user'][ $banner_addon_name ] ) | |
| 1902 | + ! isset($GLOBALS['give_addon_activated_by_user'][$banner_addon_name]) | |
| 1903 | + || empty($GLOBALS['give_addon_activated_by_user'][$banner_addon_name]) | |
| 1904 | 1904 |  	) { | 
| 1905 | - $GLOBALS['give_addon_activated_by_user'][ $banner_addon_name ] = array(); | |
| 1905 | + $GLOBALS['give_addon_activated_by_user'][$banner_addon_name] = array(); | |
| 1906 | 1906 | |
| 1907 | 1907 | // Get the meta of activation banner by user. | 
| 1908 | 1908 | $activation_banners = $wpdb->get_results( | 
| @@ -1915,16 +1915,16 @@ discard block | ||
| 1915 | 1915 | ARRAY_A | 
| 1916 | 1916 | ); | 
| 1917 | 1917 | |
| 1918 | -		if ( ! empty( $activation_banners ) ) { | |
| 1918 | +		if ( ! empty($activation_banners)) { | |
| 1919 | 1919 | $GLOBALS['give_addon_activated_by_user'] = array_combine( | 
| 1920 | - wp_list_pluck( $activation_banners, 'option_name' ), | |
| 1921 | - wp_list_pluck( $activation_banners, 'option_value' ) | |
| 1920 | + wp_list_pluck($activation_banners, 'option_name'), | |
| 1921 | + wp_list_pluck($activation_banners, 'option_value') | |
| 1922 | 1922 | ); | 
| 1923 | 1923 | } | 
| 1924 | 1924 | } | 
| 1925 | 1925 | |
| 1926 | -	if ( in_array( $option_name, array_keys( $GLOBALS['give_addon_activated_by_user'] ) ) ) { | |
| 1927 | - $data = maybe_unserialize( $GLOBALS['give_addon_activated_by_user'][ $option_name ] ); | |
| 1926 | +	if (in_array($option_name, array_keys($GLOBALS['give_addon_activated_by_user']))) { | |
| 1927 | + $data = maybe_unserialize($GLOBALS['give_addon_activated_by_user'][$option_name]); | |
| 1928 | 1928 | } | 
| 1929 | 1929 | |
| 1930 | 1930 | return $data; | 
| @@ -1937,13 +1937,13 @@ discard block | ||
| 1937 | 1937 | * | 
| 1938 | 1938 | * @return int | 
| 1939 | 1939 | */ | 
| 1940 | -function give_get_nonce_life(){ | |
| 1940 | +function give_get_nonce_life() { | |
| 1941 | 1941 | /** | 
| 1942 | 1942 | * Filters the lifespan of nonces in seconds. | 
| 1943 | 1943 | * | 
| 1944 | 1944 | * @see wp-inlucdes/pluggable.php:wp_nonce_tick | 
| 1945 | 1945 | */ | 
| 1946 | - return (int) apply_filters( 'nonce_life', DAY_IN_SECONDS ); | |
| 1946 | +	return (int) apply_filters('nonce_life', DAY_IN_SECONDS); | |
| 1947 | 1947 | } | 
| 1948 | 1948 | |
| 1949 | 1949 | /** | 
| @@ -1957,11 +1957,11 @@ discard block | ||
| 1957 | 1957 | * | 
| 1958 | 1958 | * @return string | 
| 1959 | 1959 | */ | 
| 1960 | -function give_get_nonce_field( $action, $name, $referer = false ) { | |
| 1960 | +function give_get_nonce_field($action, $name, $referer = false) { | |
| 1961 | 1961 | return str_replace( | 
| 1962 | 1962 |  		"id=\"{$name}\"", | 
| 1963 | 1963 | '', | 
| 1964 | - wp_nonce_field( $action, $name, $referer, false ) | |
| 1964 | + wp_nonce_field($action, $name, $referer, false) | |
| 1965 | 1965 | ); | 
| 1966 | 1966 | } | 
| 1967 | 1967 | |
| @@ -1974,31 +1974,31 @@ discard block | ||
| 1974 | 1974 | * | 
| 1975 | 1975 | * @return array | 
| 1976 | 1976 | */ | 
| 1977 | -function give_goal_progress_stats( $form ) { | |
| 1977 | +function give_goal_progress_stats($form) { | |
| 1978 | 1978 | |
| 1979 | -	if ( ! $form instanceof Give_Donate_Form ) { | |
| 1980 | - $form = new Give_Donate_Form( $form ); | |
| 1979 | +	if ( ! $form instanceof Give_Donate_Form) { | |
| 1980 | + $form = new Give_Donate_Form($form); | |
| 1981 | 1981 | } | 
| 1982 | 1982 | |
| 1983 | 1983 | $donors = ''; | 
| 1984 | 1984 | |
| 1985 | - $goal_format = give_get_form_goal_format( $form->ID ); | |
| 1985 | + $goal_format = give_get_form_goal_format($form->ID); | |
| 1986 | 1986 | |
| 1987 | 1987 | /** | 
| 1988 | 1988 | * Filter the form. | 
| 1989 | 1989 | * | 
| 1990 | 1990 | * @since 1.8.8 | 
| 1991 | 1991 | */ | 
| 1992 | - $total_goal = apply_filters( 'give_goal_amount_target_output', round( give_maybe_sanitize_amount( $form->goal ) ), $form->ID, $form ); | |
| 1992 | +	$total_goal = apply_filters('give_goal_amount_target_output', round(give_maybe_sanitize_amount($form->goal)), $form->ID, $form); | |
| 1993 | 1993 | |
| 1994 | -	switch ( $goal_format ) { | |
| 1994 | +	switch ($goal_format) { | |
| 1995 | 1995 | case 'donation': | 
| 1996 | 1996 | /** | 
| 1997 | 1997 | * Filter the form donations. | 
| 1998 | 1998 | * | 
| 1999 | 1999 | * @since 2.1 | 
| 2000 | 2000 | */ | 
| 2001 | - $actual = $donations = apply_filters( 'give_goal_donations_raised_output', $form->sales, $form->ID, $form ); | |
| 2001 | +			$actual = $donations = apply_filters('give_goal_donations_raised_output', $form->sales, $form->ID, $form); | |
| 2002 | 2002 | break; | 
| 2003 | 2003 | case 'donors': | 
| 2004 | 2004 | /** | 
| @@ -2012,7 +2012,7 @@ discard block | ||
| 2012 | 2012 | * | 
| 2013 | 2013 | * @return int $donors Total number of donors that donated to the form. | 
| 2014 | 2014 | */ | 
| 2015 | - $actual = $donors = apply_filters( 'give_goal_donors_target_output', give_get_form_donor_count( $form->ID ), $form->ID, $form ); | |
| 2015 | +			$actual = $donors = apply_filters('give_goal_donors_target_output', give_get_form_donor_count($form->ID), $form->ID, $form); | |
| 2016 | 2016 | break; | 
| 2017 | 2017 | default : | 
| 2018 | 2018 | /** | 
| @@ -2020,11 +2020,11 @@ discard block | ||
| 2020 | 2020 | * | 
| 2021 | 2021 | * @since 1.8.8 | 
| 2022 | 2022 | */ | 
| 2023 | - $actual = $income = apply_filters( 'give_goal_amount_raised_output', $form->earnings, $form->ID, $form ); | |
| 2023 | +			$actual = $income = apply_filters('give_goal_amount_raised_output', $form->earnings, $form->ID, $form); | |
| 2024 | 2024 | break; | 
| 2025 | 2025 | } | 
| 2026 | 2026 | |
| 2027 | - $progress = round( ( $actual / $total_goal ) * 100, 2 ); | |
| 2027 | + $progress = round(($actual / $total_goal) * 100, 2); | |
| 2028 | 2028 | |
| 2029 | 2029 | $stats_array = array( | 
| 2030 | 2030 | 'raw_actual' => $actual, | 
| @@ -2036,20 +2036,20 @@ discard block | ||
| 2036 | 2036 | * | 
| 2037 | 2037 | * @since 1.8.8 | 
| 2038 | 2038 | */ | 
| 2039 | - $progress = apply_filters( 'give_goal_amount_funded_percentage_output', $progress, $form->ID, $form ); | |
| 2039 | +	$progress = apply_filters('give_goal_amount_funded_percentage_output', $progress, $form->ID, $form); | |
| 2040 | 2040 | |
| 2041 | 2041 | // Define Actual Goal based on the goal format. | 
| 2042 | -	if ( 'percentage' === $goal_format ) { | |
| 2042 | +	if ('percentage' === $goal_format) { | |
| 2043 | 2043 |  		$actual = "{$actual}%"; | 
| 2044 | -	} else if ( 'amount' === $goal_format ) { | |
| 2045 | - $actual = give_currency_filter( give_format_amount( $actual ) ); | |
| 2044 | +	} else if ('amount' === $goal_format) { | |
| 2045 | + $actual = give_currency_filter(give_format_amount($actual)); | |
| 2046 | 2046 | } | 
| 2047 | 2047 | |
| 2048 | 2048 | // Define Total Goal based on the goal format. | 
| 2049 | -	if ( 'percentage' === $goal_format ) { | |
| 2049 | +	if ('percentage' === $goal_format) { | |
| 2050 | 2050 | $total_goal = ''; | 
| 2051 | -	} else if ( 'amount' === $goal_format ) { | |
| 2052 | - $total_goal = give_currency_filter( give_format_amount( $total_goal ) ); | |
| 2051 | +	} else if ('amount' === $goal_format) { | |
| 2052 | + $total_goal = give_currency_filter(give_format_amount($total_goal)); | |
| 2053 | 2053 | } | 
| 2054 | 2054 | |
| 2055 | 2055 | $stats_array = array_merge( | 
| @@ -2067,6 +2067,6 @@ discard block | ||
| 2067 | 2067 | * | 
| 2068 | 2068 | * @since 2.1 | 
| 2069 | 2069 | */ | 
| 2070 | - return apply_filters( 'give_goal_progress_stats', $stats_array ); | |
| 2070 | +	return apply_filters('give_goal_progress_stats', $stats_array); | |
| 2071 | 2071 | |
| 2072 | 2072 | } | 
| 2073 | 2073 | \ No newline at end of file | 
| @@ -24,7 +24,7 @@ | ||
| 24 | 24 | * | 
| 25 | 25 | * @throws ReflectionException Exception Handling. | 
| 26 | 26 | * | 
| 27 | - * @return mixed | |
| 27 | + * @return false|null | |
| 28 | 28 | */ | 
| 29 | 29 |  function give_process_donation_form() { | 
| 30 | 30 | |
| @@ -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,18 +28,18 @@ discard block | ||
| 28 | 28 | */ | 
| 29 | 29 |  function give_process_donation_form() { | 
| 30 | 30 | |
| 31 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, CSRF ok. | |
| 32 | - $is_ajax = isset( $post_data['give_ajax'] ); | |
| 31 | + $post_data = give_clean($_POST); // WPCS: input var ok, CSRF ok. | |
| 32 | + $is_ajax = isset($post_data['give_ajax']); | |
| 33 | 33 | |
| 34 | 34 | // Verify donation form nonce. | 
| 35 | -	if ( ! give_verify_donation_form_nonce( $post_data['give-form-hash'], $post_data['give-form-id'] ) ) { | |
| 36 | -		if ( $is_ajax ) { | |
| 35 | +	if ( ! give_verify_donation_form_nonce($post_data['give-form-hash'], $post_data['give-form-id'])) { | |
| 36 | +		if ($is_ajax) { | |
| 37 | 37 | /** | 
| 38 | 38 | * Fires when AJAX sends back errors from the donation form. | 
| 39 | 39 | * | 
| 40 | 40 | * @since 1.0 | 
| 41 | 41 | */ | 
| 42 | - do_action( 'give_ajax_donation_errors' ); | |
| 42 | +			do_action('give_ajax_donation_errors'); | |
| 43 | 43 | give_die(); | 
| 44 | 44 |  		} else { | 
| 45 | 45 | give_send_back_to_checkout(); | 
| @@ -51,7 +51,7 @@ discard block | ||
| 51 | 51 | * | 
| 52 | 52 | * @since 1.0 | 
| 53 | 53 | */ | 
| 54 | - do_action( 'give_pre_process_donation' ); | |
| 54 | +	do_action('give_pre_process_donation'); | |
| 55 | 55 | |
| 56 | 56 | // Validate the form $_POST data. | 
| 57 | 57 | $valid_data = give_donation_form_validate_fields(); | 
| @@ -67,24 +67,24 @@ discard block | ||
| 67 | 67 | * @param array $deprecated Deprecated Since 2.0.2. Use $_POST instead. | 
| 68 | 68 | */ | 
| 69 | 69 | $deprecated = $post_data; | 
| 70 | - do_action( 'give_checkout_error_checks', $valid_data, $deprecated ); | |
| 70 | +	do_action('give_checkout_error_checks', $valid_data, $deprecated); | |
| 71 | 71 | |
| 72 | 72 | // Process the login form. | 
| 73 | -	if ( isset( $post_data['give_login_submit'] ) ) { | |
| 73 | +	if (isset($post_data['give_login_submit'])) { | |
| 74 | 74 | give_process_form_login(); | 
| 75 | 75 | } | 
| 76 | 76 | |
| 77 | 77 | // Validate the user. | 
| 78 | - $user = give_get_donation_form_user( $valid_data ); | |
| 78 | + $user = give_get_donation_form_user($valid_data); | |
| 79 | 79 | |
| 80 | -	if ( false === $valid_data || give_get_errors() || ! $user ) { | |
| 81 | -		if ( $is_ajax ) { | |
| 80 | +	if (false === $valid_data || give_get_errors() || ! $user) { | |
| 81 | +		if ($is_ajax) { | |
| 82 | 82 | /** | 
| 83 | 83 | * Fires when AJAX sends back errors from the donation form. | 
| 84 | 84 | * | 
| 85 | 85 | * @since 1.0 | 
| 86 | 86 | */ | 
| 87 | - do_action( 'give_ajax_donation_errors' ); | |
| 87 | +			do_action('give_ajax_donation_errors'); | |
| 88 | 88 | give_die(); | 
| 89 | 89 |  		} else { | 
| 90 | 90 | return false; | 
| @@ -92,17 +92,17 @@ discard block | ||
| 92 | 92 | } | 
| 93 | 93 | |
| 94 | 94 | // If AJAX send back success to proceed with form submission. | 
| 95 | -	if ( $is_ajax ) { | |
| 95 | +	if ($is_ajax) { | |
| 96 | 96 | echo 'success'; | 
| 97 | 97 | give_die(); | 
| 98 | 98 | } | 
| 99 | 99 | |
| 100 | 100 | // After AJAX: Setup session if not using php_sessions. | 
| 101 | -	if ( ! Give()->session->use_php_sessions() ) { | |
| 101 | +	if ( ! Give()->session->use_php_sessions()) { | |
| 102 | 102 | // Double-check that set_cookie is publicly accessible. | 
| 103 | 103 | // we're using a slightly modified class-wp-sessions.php. | 
| 104 | - $session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' ); | |
| 105 | -		if ( $session_reflection->isPublic() ) { | |
| 104 | +		$session_reflection = new ReflectionMethod('WP_Session', 'set_cookie'); | |
| 105 | +		if ($session_reflection->isPublic()) { | |
| 106 | 106 | // Manually set the cookie. | 
| 107 | 107 | Give()->session->init()->set_cookie(); | 
| 108 | 108 | } | 
| @@ -117,20 +117,19 @@ discard block | ||
| 117 | 117 | 'address' => $user['address'], | 
| 118 | 118 | ); | 
| 119 | 119 | |
| 120 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; | |
| 120 | +	$auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; | |
| 121 | 121 | |
| 122 | - $price = isset( $post_data['give-amount'] ) ? | |
| 123 | - (float) apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $post_data['give-amount'] ) ) : | |
| 124 | - '0.00'; | |
| 125 | - $purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); | |
| 122 | + $price = isset($post_data['give-amount']) ? | |
| 123 | +		(float) apply_filters('give_donation_total', give_maybe_sanitize_amount($post_data['give-amount'])) : '0.00'; | |
| 124 | +	$purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); | |
| 126 | 125 | |
| 127 | 126 | // Setup donation information. | 
| 128 | 127 | $donation_data = array( | 
| 129 | 128 | 'price' => $price, | 
| 130 | 129 | 'purchase_key' => $purchase_key, | 
| 131 | 130 | 'user_email' => $user['user_email'], | 
| 132 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), | |
| 133 | - 'user_info' => stripslashes_deep( $user_info ), | |
| 131 | +		'date'          => date('Y-m-d H:i:s', current_time('timestamp')), | |
| 132 | + 'user_info' => stripslashes_deep($user_info), | |
| 134 | 133 | 'post_data' => $post_data, | 
| 135 | 134 | 'gateway' => $valid_data['gateway'], | 
| 136 | 135 | 'card_info' => $valid_data['cc_info'], | 
| @@ -150,10 +149,10 @@ discard block | ||
| 150 | 149 | * @param array $user_info Array containing basic user information. | 
| 151 | 150 | * @param bool|array $valid_data Validate fields. | 
| 152 | 151 | */ | 
| 153 | - do_action( 'give_checkout_before_gateway', $post_data, $user_info, $valid_data ); | |
| 152 | +	do_action('give_checkout_before_gateway', $post_data, $user_info, $valid_data); | |
| 154 | 153 | |
| 155 | 154 | // Sanity check for price. | 
| 156 | -	if ( ! $donation_data['price'] ) { | |
| 155 | +	if ( ! $donation_data['price']) { | |
| 157 | 156 | // Revert to manual. | 
| 158 | 157 | $donation_data['gateway'] = 'manual'; | 
| 159 | 158 | $_POST['give-gateway'] = 'manual'; | 
| @@ -164,26 +163,26 @@ discard block | ||
| 164 | 163 | * | 
| 165 | 164 | * @since 1.7 | 
| 166 | 165 | */ | 
| 167 | - $donation_data = apply_filters( 'give_donation_data_before_gateway', $donation_data, $valid_data ); | |
| 166 | +	$donation_data = apply_filters('give_donation_data_before_gateway', $donation_data, $valid_data); | |
| 168 | 167 | |
| 169 | 168 | // Setup the data we're storing in the donation session. | 
| 170 | 169 | $session_data = $donation_data; | 
| 171 | 170 | |
| 172 | 171 | // Make sure credit card numbers are never stored in sessions. | 
| 173 | - unset( $session_data['card_info']['card_number'] ); | |
| 174 | - unset( $session_data['post_data']['card_number'] ); | |
| 172 | + unset($session_data['card_info']['card_number']); | |
| 173 | + unset($session_data['post_data']['card_number']); | |
| 175 | 174 | |
| 176 | 175 | // Used for showing data to non logged-in users after donation, and for other plugins needing donation data. | 
| 177 | - give_set_purchase_session( $session_data ); | |
| 176 | + give_set_purchase_session($session_data); | |
| 178 | 177 | |
| 179 | 178 | // Send info to the gateway for payment processing. | 
| 180 | - give_send_to_gateway( $donation_data['gateway'], $donation_data ); | |
| 179 | + give_send_to_gateway($donation_data['gateway'], $donation_data); | |
| 181 | 180 | give_die(); | 
| 182 | 181 | } | 
| 183 | 182 | |
| 184 | -add_action( 'give_purchase', 'give_process_donation_form' ); | |
| 185 | -add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' ); | |
| 186 | -add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' ); | |
| 183 | +add_action('give_purchase', 'give_process_donation_form'); | |
| 184 | +add_action('wp_ajax_give_process_donation', 'give_process_donation_form'); | |
| 185 | +add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form'); | |
| 187 | 186 | |
| 188 | 187 | /** | 
| 189 | 188 | * Verify that when a logged in user makes a donation that the email address used doesn't belong to a different customer. | 
| @@ -194,27 +193,27 @@ discard block | ||
| 194 | 193 | * | 
| 195 | 194 | * @return void | 
| 196 | 195 | */ | 
| 197 | -function give_check_logged_in_user_for_existing_email( $valid_data ) { | |
| 196 | +function give_check_logged_in_user_for_existing_email($valid_data) { | |
| 198 | 197 | |
| 199 | 198 | // Verify that the email address belongs to this customer. | 
| 200 | -	if ( is_user_logged_in() ) { | |
| 199 | +	if (is_user_logged_in()) { | |
| 201 | 200 | |
| 202 | 201 | $submitted_email = $valid_data['logged_in_user']['user_email']; | 
| 203 | - $donor = new Give_Donor( get_current_user_id(), true ); | |
| 202 | + $donor = new Give_Donor(get_current_user_id(), true); | |
| 204 | 203 | |
| 205 | 204 | // If this email address is not registered with this customer, see if it belongs to any other customer. | 
| 206 | 205 | if ( | 
| 207 | 206 | $submitted_email !== $donor->email | 
| 208 | - && ( is_array( $donor->emails ) && ! in_array( $submitted_email, $donor->emails, true ) ) | |
| 207 | + && (is_array($donor->emails) && ! in_array($submitted_email, $donor->emails, true)) | |
| 209 | 208 |  		) { | 
| 210 | - $found_donor = new Give_Donor( $submitted_email ); | |
| 209 | + $found_donor = new Give_Donor($submitted_email); | |
| 211 | 210 | |
| 212 | -			if ( $found_donor->id > 0 ) { | |
| 211 | +			if ($found_donor->id > 0) { | |
| 213 | 212 | give_set_error( | 
| 214 | 213 | 'give-customer-email-exists', | 
| 215 | 214 | sprintf( | 
| 216 | 215 | /* translators: 1. Donor Email, 2. Submitted Email */ | 
| 217 | - __( 'You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give' ), | |
| 216 | +						__('You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give'), | |
| 218 | 217 | $donor->email, | 
| 219 | 218 | $submitted_email | 
| 220 | 219 | ) | 
| @@ -224,7 +223,7 @@ discard block | ||
| 224 | 223 | } | 
| 225 | 224 | } | 
| 226 | 225 | |
| 227 | -add_action( 'give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 1 ); | |
| 226 | +add_action('give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 1); | |
| 228 | 227 | |
| 229 | 228 | /** | 
| 230 | 229 | * Process the checkout login form | 
| @@ -236,49 +235,49 @@ discard block | ||
| 236 | 235 | */ | 
| 237 | 236 |  function give_process_form_login() { | 
| 238 | 237 | |
| 239 | - $is_ajax = ! empty( $_POST['give_ajax'] ) ? give_clean( $_POST['give_ajax'] ) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 238 | + $is_ajax = ! empty($_POST['give_ajax']) ? give_clean($_POST['give_ajax']) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 240 | 239 | $referrer = wp_get_referer(); | 
| 241 | 240 | $user_data = give_donation_form_validate_user_login(); | 
| 242 | 241 | |
| 243 | -	if ( give_get_errors() || $user_data['user_id'] < 1 ) { | |
| 244 | -		if ( $is_ajax ) { | |
| 242 | +	if (give_get_errors() || $user_data['user_id'] < 1) { | |
| 243 | +		if ($is_ajax) { | |
| 245 | 244 | /** | 
| 246 | 245 | * Fires when AJAX sends back errors from the donation form. | 
| 247 | 246 | * | 
| 248 | 247 | * @since 1.0 | 
| 249 | 248 | */ | 
| 250 | 249 | ob_start(); | 
| 251 | - do_action( 'give_ajax_donation_errors' ); | |
| 250 | +			do_action('give_ajax_donation_errors'); | |
| 252 | 251 | $message = ob_get_contents(); | 
| 253 | 252 | ob_end_clean(); | 
| 254 | - wp_send_json_error( $message ); | |
| 253 | + wp_send_json_error($message); | |
| 255 | 254 |  		} else { | 
| 256 | - wp_safe_redirect( $referrer ); | |
| 255 | + wp_safe_redirect($referrer); | |
| 257 | 256 | exit; | 
| 258 | 257 | } | 
| 259 | 258 | } | 
| 260 | 259 | |
| 261 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] ); | |
| 260 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']); | |
| 262 | 261 | |
| 263 | -	if ( $is_ajax ) { | |
| 262 | +	if ($is_ajax) { | |
| 264 | 263 | $message = Give()->notices->print_frontend_notice( | 
| 265 | 264 | sprintf( | 
| 266 | 265 | /* translators: %s: user first name */ | 
| 267 | - esc_html__( 'Welcome %s! You have successfully logged into your account.', 'give' ), | |
| 268 | - ( ! empty( $user_data['user_first'] ) ) ? $user_data['user_first'] : $user_data['user_login'] | |
| 266 | +				esc_html__('Welcome %s! You have successfully logged into your account.', 'give'), | |
| 267 | + ( ! empty($user_data['user_first'])) ? $user_data['user_first'] : $user_data['user_login'] | |
| 269 | 268 | ), | 
| 270 | 269 | false, | 
| 271 | 270 | 'success' | 
| 272 | 271 | ); | 
| 273 | 272 | |
| 274 | - wp_send_json_success( $message ); | |
| 273 | + wp_send_json_success($message); | |
| 275 | 274 |  	} else { | 
| 276 | - wp_safe_redirect( $referrer ); | |
| 275 | + wp_safe_redirect($referrer); | |
| 277 | 276 | } | 
| 278 | 277 | } | 
| 279 | 278 | |
| 280 | -add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' ); | |
| 281 | -add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' ); | |
| 279 | +add_action('wp_ajax_give_process_donation_login', 'give_process_form_login'); | |
| 280 | +add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login'); | |
| 282 | 281 | |
| 283 | 282 | /** | 
| 284 | 283 | * Donation Form Validate Fields. | 
| @@ -290,49 +289,49 @@ discard block | ||
| 290 | 289 | */ | 
| 291 | 290 |  function give_donation_form_validate_fields() { | 
| 292 | 291 | |
| 293 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 292 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 294 | 293 | |
| 295 | 294 | // Validate Honeypot First. | 
| 296 | -	if ( ! empty( $post_data['give-honeypot'] ) ) { | |
| 297 | - give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) ); | |
| 295 | +	if ( ! empty($post_data['give-honeypot'])) { | |
| 296 | +		give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give')); | |
| 298 | 297 | } | 
| 299 | 298 | |
| 300 | 299 | // Check spam detect. | 
| 301 | 300 | if ( | 
| 302 | - isset( $post_data['action'] ) && | |
| 303 | - give_is_setting_enabled( give_get_option( 'akismet_spam_protection' ) ) && | |
| 301 | + isset($post_data['action']) && | |
| 302 | +		give_is_setting_enabled(give_get_option('akismet_spam_protection')) && | |
| 304 | 303 | give_is_spam_donation() | 
| 305 | 304 |  	) { | 
| 306 | - give_set_error( 'spam_donation', __( 'This donation has been flagged as spam. Please try again.', 'give' ) ); | |
| 305 | +		give_set_error('spam_donation', __('This donation has been flagged as spam. Please try again.', 'give')); | |
| 307 | 306 | } | 
| 308 | 307 | |
| 309 | 308 | // Start an array to collect valid data. | 
| 310 | 309 | $valid_data = array( | 
| 311 | 310 | 'gateway' => give_donation_form_validate_gateway(), // Gateway fallback (amount is validated here). | 
| 312 | - 'need_new_user' => false, // New user flag. | |
| 313 | - 'need_user_login' => false, // Login user flag. | |
| 314 | - 'logged_user_data' => array(), // Logged user collected data. | |
| 315 | - 'new_user_data' => array(), // New user collected data. | |
| 316 | - 'login_user_data' => array(), // Login user collected data. | |
| 317 | - 'guest_user_data' => array(), // Guest user collected data. | |
| 311 | + 'need_new_user' => false, // New user flag. | |
| 312 | + 'need_user_login' => false, // Login user flag. | |
| 313 | + 'logged_user_data' => array(), // Logged user collected data. | |
| 314 | + 'new_user_data' => array(), // New user collected data. | |
| 315 | + 'login_user_data' => array(), // Login user collected data. | |
| 316 | + 'guest_user_data' => array(), // Guest user collected data. | |
| 318 | 317 | 'cc_info' => give_donation_form_validate_cc(), // Credit card info. | 
| 319 | 318 | ); | 
| 320 | 319 | |
| 321 | - $form_id = intval( $post_data['give-form-id'] ); | |
| 320 | + $form_id = intval($post_data['give-form-id']); | |
| 322 | 321 | |
| 323 | 322 | // Validate agree to terms. | 
| 324 | -	if ( give_is_terms_enabled( $form_id ) ) { | |
| 323 | +	if (give_is_terms_enabled($form_id)) { | |
| 325 | 324 | give_donation_form_validate_agree_to_terms(); | 
| 326 | 325 | } | 
| 327 | 326 | |
| 328 | -	if ( is_user_logged_in() ) { | |
| 327 | +	if (is_user_logged_in()) { | |
| 329 | 328 | |
| 330 | 329 | // Collect logged in user data. | 
| 331 | 330 | $valid_data['logged_in_user'] = give_donation_form_validate_logged_in_user(); | 
| 332 | 331 | } elseif ( | 
| 333 | - isset( $post_data['give-purchase-var'] ) && | |
| 332 | + isset($post_data['give-purchase-var']) && | |
| 334 | 333 | 'needs-to-register' === $post_data['give-purchase-var'] && | 
| 335 | - ! empty( $post_data['give_create_account'] ) | |
| 334 | + ! empty($post_data['give_create_account']) | |
| 336 | 335 |  	) { | 
| 337 | 336 | |
| 338 | 337 | // Set new user registration as required. | 
| @@ -341,7 +340,7 @@ discard block | ||
| 341 | 340 | // Validate new user data. | 
| 342 | 341 | $valid_data['new_user_data'] = give_donation_form_validate_new_user(); | 
| 343 | 342 | } elseif ( | 
| 344 | - isset( $post_data['give-purchase-var'] ) && | |
| 343 | + isset($post_data['give-purchase-var']) && | |
| 345 | 344 | 'needs-to-login' === $post_data['give-purchase-var'] | 
| 346 | 345 |  	) { | 
| 347 | 346 | |
| @@ -370,14 +369,14 @@ discard block | ||
| 370 | 369 |  function give_is_spam_donation() { | 
| 371 | 370 | $spam = false; | 
| 372 | 371 | |
| 373 | - $user_agent = (string) isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : ''; | |
| 372 | + $user_agent = (string) isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; | |
| 374 | 373 | |
| 375 | -	if ( strlen( $user_agent ) < 2 ) { | |
| 374 | +	if (strlen($user_agent) < 2) { | |
| 376 | 375 | $spam = true; | 
| 377 | 376 | } | 
| 378 | 377 | |
| 379 | 378 | // Allow developer to customized Akismet spam detect API call and it's response. | 
| 380 | - return apply_filters( 'give_spam', $spam ); | |
| 379 | +	return apply_filters('give_spam', $spam); | |
| 381 | 380 | } | 
| 382 | 381 | |
| 383 | 382 | /** | 
| @@ -392,33 +391,33 @@ discard block | ||
| 392 | 391 | */ | 
| 393 | 392 |  function give_donation_form_validate_gateway() { | 
| 394 | 393 | |
| 395 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 396 | - $form_id = ! empty( $post_data['give-form-id'] ) ? $post_data['give-form-id'] : 0; | |
| 397 | - $amount = ! empty( $post_data['give-amount'] ) ? give_maybe_sanitize_amount( $post_data['give-amount'] ) : 0; | |
| 398 | - $gateway = ! empty( $post_data['give-gateway'] ) ? $post_data['give-gateway'] : 0; | |
| 394 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 395 | + $form_id = ! empty($post_data['give-form-id']) ? $post_data['give-form-id'] : 0; | |
| 396 | + $amount = ! empty($post_data['give-amount']) ? give_maybe_sanitize_amount($post_data['give-amount']) : 0; | |
| 397 | + $gateway = ! empty($post_data['give-gateway']) ? $post_data['give-gateway'] : 0; | |
| 399 | 398 | |
| 400 | 399 | // Bailout, if payment gateway is not submitted with donation form data. | 
| 401 | -	if ( empty( $gateway ) ) { | |
| 400 | +	if (empty($gateway)) { | |
| 402 | 401 | |
| 403 | - give_set_error( 'empty_gateway', __( 'The donation form will process with a valid payment gateway.', 'give' ) ); | |
| 402 | +		give_set_error('empty_gateway', __('The donation form will process with a valid payment gateway.', 'give')); | |
| 404 | 403 | |
| 405 | -	} elseif ( ! give_is_gateway_active( $gateway ) ) { | |
| 404 | +	} elseif ( ! give_is_gateway_active($gateway)) { | |
| 406 | 405 | |
| 407 | - give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled.', 'give' ) ); | |
| 406 | +		give_set_error('invalid_gateway', __('The selected payment gateway is not enabled.', 'give')); | |
| 408 | 407 | |
| 409 | -	} elseif ( empty( $amount ) ) { | |
| 408 | +	} elseif (empty($amount)) { | |
| 410 | 409 | |
| 411 | - give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) ); | |
| 410 | +		give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give')); | |
| 412 | 411 | |
| 413 | -	} elseif ( ! give_verify_minimum_price( 'minimum' ) ) { | |
| 412 | +	} elseif ( ! give_verify_minimum_price('minimum')) { | |
| 414 | 413 | |
| 415 | 414 | give_set_error( | 
| 416 | 415 | 'invalid_donation_minimum', | 
| 417 | 416 | sprintf( | 
| 418 | 417 | /* translators: %s: minimum donation amount */ | 
| 419 | - __( 'This form has a minimum donation amount of %s.', 'give' ), | |
| 418 | +				__('This form has a minimum donation amount of %s.', 'give'), | |
| 420 | 419 | give_currency_filter( | 
| 421 | - give_format_amount( give_get_form_minimum_price( $form_id ), | |
| 420 | + give_format_amount(give_get_form_minimum_price($form_id), | |
| 422 | 421 | array( | 
| 423 | 422 | 'sanitize' => false, | 
| 424 | 423 | ) | 
| @@ -426,15 +425,15 @@ discard block | ||
| 426 | 425 | ) | 
| 427 | 426 | ) | 
| 428 | 427 | ); | 
| 429 | -	} elseif ( ! give_verify_minimum_price( 'maximum' ) ) { | |
| 428 | +	} elseif ( ! give_verify_minimum_price('maximum')) { | |
| 430 | 429 | |
| 431 | 430 | give_set_error( | 
| 432 | 431 | 'invalid_donation_maximum', | 
| 433 | 432 | sprintf( | 
| 434 | 433 | /* translators: %s: Maximum donation amount */ | 
| 435 | - __( 'This form has a maximum donation amount of %s.', 'give' ), | |
| 434 | +				__('This form has a maximum donation amount of %s.', 'give'), | |
| 436 | 435 | give_currency_filter( | 
| 437 | - give_format_amount( give_get_form_maximum_price( $form_id ), | |
| 436 | + give_format_amount(give_get_form_maximum_price($form_id), | |
| 438 | 437 | array( | 
| 439 | 438 | 'sanitize' => false, | 
| 440 | 439 | ) | 
| @@ -460,32 +459,32 @@ discard block | ||
| 460 | 459 | * | 
| 461 | 460 | * @return bool | 
| 462 | 461 | */ | 
| 463 | -function give_verify_minimum_price( $amount_range = 'minimum' ) { | |
| 462 | +function give_verify_minimum_price($amount_range = 'minimum') { | |
| 464 | 463 | |
| 465 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 466 | - $amount = ! empty( $post_data['give-amount'] ) ? give_maybe_sanitize_amount( $post_data['give-amount'] ) : 0; | |
| 467 | - $form_id = ! empty( $post_data['give-form-id'] ) ? $post_data['give-form-id'] : 0; | |
| 468 | - $price_id = ! empty( $post_data['give-price-id'] ) ? $post_data['give-price-id'] : ''; | |
| 464 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 465 | + $amount = ! empty($post_data['give-amount']) ? give_maybe_sanitize_amount($post_data['give-amount']) : 0; | |
| 466 | + $form_id = ! empty($post_data['give-form-id']) ? $post_data['give-form-id'] : 0; | |
| 467 | + $price_id = ! empty($post_data['give-price-id']) ? $post_data['give-price-id'] : ''; | |
| 469 | 468 | |
| 470 | - $variable_prices = give_has_variable_prices( $form_id ); | |
| 469 | + $variable_prices = give_has_variable_prices($form_id); | |
| 471 | 470 | $verified_stat = false; | 
| 472 | 471 | |
| 473 | -	if ( $variable_prices && in_array( $price_id, give_get_variable_price_ids( $form_id ), true ) ) { | |
| 472 | +	if ($variable_prices && in_array($price_id, give_get_variable_price_ids($form_id), true)) { | |
| 474 | 473 | |
| 475 | - $price_level_amount = give_get_price_option_amount( $form_id, $price_id ); | |
| 474 | + $price_level_amount = give_get_price_option_amount($form_id, $price_id); | |
| 476 | 475 | |
| 477 | -		if ( $price_level_amount == $amount ) { | |
| 476 | +		if ($price_level_amount == $amount) { | |
| 478 | 477 | $verified_stat = true; | 
| 479 | 478 | } | 
| 480 | 479 | } | 
| 481 | 480 | |
| 482 | -	if ( ! $verified_stat ) { | |
| 483 | -		switch ( $amount_range ) { | |
| 481 | +	if ( ! $verified_stat) { | |
| 482 | +		switch ($amount_range) { | |
| 484 | 483 | case 'minimum' : | 
| 485 | - $verified_stat = ( give_get_form_minimum_price( $form_id ) > $amount ) ? false : true; | |
| 484 | + $verified_stat = (give_get_form_minimum_price($form_id) > $amount) ? false : true; | |
| 486 | 485 | break; | 
| 487 | 486 | case 'maximum' : | 
| 488 | - $verified_stat = ( give_get_form_maximum_price( $form_id ) < $amount ) ? false : true; | |
| 487 | + $verified_stat = (give_get_form_maximum_price($form_id) < $amount) ? false : true; | |
| 489 | 488 | break; | 
| 490 | 489 | } | 
| 491 | 490 | } | 
| @@ -499,7 +498,7 @@ discard block | ||
| 499 | 498 | * @param string $amount_range Type of the amount. | 
| 500 | 499 | * @param integer $form_id Give Donation Form ID. | 
| 501 | 500 | */ | 
| 502 | - return apply_filters( 'give_verify_minimum_maximum_price', $verified_stat, $amount_range, $form_id ); | |
| 501 | +	return apply_filters('give_verify_minimum_maximum_price', $verified_stat, $amount_range, $form_id); | |
| 503 | 502 | } | 
| 504 | 503 | |
| 505 | 504 | /** | 
| @@ -512,13 +511,13 @@ discard block | ||
| 512 | 511 | */ | 
| 513 | 512 |  function give_donation_form_validate_agree_to_terms() { | 
| 514 | 513 | |
| 515 | - $agree_to_terms = ! empty( $_POST['give_agree_to_terms'] ) ? give_clean( $_POST['give_agree_to_terms'] ) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 514 | + $agree_to_terms = ! empty($_POST['give_agree_to_terms']) ? give_clean($_POST['give_agree_to_terms']) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 516 | 515 | |
| 517 | 516 | // Proceed only, if donor agreed to terms. | 
| 518 | -	if ( ! $agree_to_terms ) { | |
| 517 | +	if ( ! $agree_to_terms) { | |
| 519 | 518 | |
| 520 | 519 | // User did not agree. | 
| 521 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms and conditions.', 'give' ) ) ); | |
| 520 | +		give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms and conditions.', 'give'))); | |
| 522 | 521 | } | 
| 523 | 522 | } | 
| 524 | 523 | |
| @@ -532,84 +531,84 @@ discard block | ||
| 532 | 531 | * | 
| 533 | 532 | * @return array | 
| 534 | 533 | */ | 
| 535 | -function give_get_required_fields( $form_id ) { | |
| 534 | +function give_get_required_fields($form_id) { | |
| 536 | 535 | |
| 537 | - $payment_mode = give_get_chosen_gateway( $form_id ); | |
| 536 | + $payment_mode = give_get_chosen_gateway($form_id); | |
| 538 | 537 | |
| 539 | 538 | $required_fields = array( | 
| 540 | 539 | 'give_email' => array( | 
| 541 | 540 | 'error_id' => 'invalid_email', | 
| 542 | - 'error_message' => __( 'Please enter a valid email address.', 'give' ), | |
| 541 | +			'error_message' => __('Please enter a valid email address.', 'give'), | |
| 543 | 542 | ), | 
| 544 | 543 | 'give_first' => array( | 
| 545 | 544 | 'error_id' => 'invalid_first_name', | 
| 546 | - 'error_message' => __( 'Please enter your first name.', 'give' ), | |
| 545 | +			'error_message' => __('Please enter your first name.', 'give'), | |
| 547 | 546 | ), | 
| 548 | 547 | ); | 
| 549 | 548 | |
| 550 | - $require_address = give_require_billing_address( $payment_mode ); | |
| 549 | + $require_address = give_require_billing_address($payment_mode); | |
| 551 | 550 | |
| 552 | -	if ( $require_address ) { | |
| 553 | - $required_fields['card_address'] = array( | |
| 551 | +	if ($require_address) { | |
| 552 | + $required_fields['card_address'] = array( | |
| 554 | 553 | 'error_id' => 'invalid_card_address', | 
| 555 | - 'error_message' => __( 'Please enter your primary billing address.', 'give' ), | |
| 554 | +			'error_message' => __('Please enter your primary billing address.', 'give'), | |
| 556 | 555 | ); | 
| 557 | - $required_fields['card_zip'] = array( | |
| 556 | + $required_fields['card_zip'] = array( | |
| 558 | 557 | 'error_id' => 'invalid_zip_code', | 
| 559 | - 'error_message' => __( 'Please enter your zip / postal code.', 'give' ), | |
| 558 | +			'error_message' => __('Please enter your zip / postal code.', 'give'), | |
| 560 | 559 | ); | 
| 561 | - $required_fields['card_city'] = array( | |
| 560 | + $required_fields['card_city'] = array( | |
| 562 | 561 | 'error_id' => 'invalid_city', | 
| 563 | - 'error_message' => __( 'Please enter your billing city.', 'give' ), | |
| 562 | +			'error_message' => __('Please enter your billing city.', 'give'), | |
| 564 | 563 | ); | 
| 565 | 564 | $required_fields['billing_country'] = array( | 
| 566 | 565 | 'error_id' => 'invalid_country', | 
| 567 | - 'error_message' => __( 'Please select your billing country.', 'give' ), | |
| 566 | +			'error_message' => __('Please select your billing country.', 'give'), | |
| 568 | 567 | ); | 
| 569 | 568 | |
| 570 | 569 | |
| 571 | 570 | $required_fields['card_state'] = array( | 
| 572 | 571 | 'error_id' => 'invalid_state', | 
| 573 | - 'error_message' => __( 'Please enter billing state / province / County.', 'give' ), | |
| 572 | +			'error_message' => __('Please enter billing state / province / County.', 'give'), | |
| 574 | 573 | ); | 
| 575 | 574 | |
| 576 | - $country = ! empty( $_POST['billing_country'] ) ? give_clean( $_POST['billing_country'] ) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 575 | + $country = ! empty($_POST['billing_country']) ? give_clean($_POST['billing_country']) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 577 | 576 | |
| 578 | 577 | // Check if billing country already exists. | 
| 579 | -		if ( $country ) { | |
| 578 | +		if ($country) { | |
| 580 | 579 | |
| 581 | 580 | // Get the country list that does not required any states init. | 
| 582 | 581 | $states_country = give_states_not_required_country_list(); | 
| 583 | 582 | |
| 584 | 583 | // Check if states is empty or not. | 
| 585 | -			if ( array_key_exists( $country, $states_country ) ) { | |
| 584 | +			if (array_key_exists($country, $states_country)) { | |
| 586 | 585 | // If states is empty remove the required fields of state in billing cart. | 
| 587 | - unset( $required_fields['card_state'] ); | |
| 586 | + unset($required_fields['card_state']); | |
| 588 | 587 | } | 
| 589 | 588 | } | 
| 590 | 589 | } // End if(). | 
| 591 | 590 | |
| 592 | -	if ( give_is_company_field_enabled( $form_id ) ) { | |
| 593 | - $form_option = give_get_meta( $form_id, '_give_company_field', true ); | |
| 594 | - $global_setting = give_get_option( 'company_field' ); | |
| 591 | +	if (give_is_company_field_enabled($form_id)) { | |
| 592 | + $form_option = give_get_meta($form_id, '_give_company_field', true); | |
| 593 | +		$global_setting = give_get_option('company_field'); | |
| 595 | 594 | |
| 596 | 595 | $is_company_field_required = false; | 
| 597 | 596 | |
| 598 | -		if ( ! empty( $form_option ) && give_is_setting_enabled( $form_option, array( 'required' ) ) ) { | |
| 597 | +		if ( ! empty($form_option) && give_is_setting_enabled($form_option, array('required'))) { | |
| 599 | 598 | $is_company_field_required = true; | 
| 600 | 599 | |
| 601 | -		} elseif ( 'global' === $form_option && give_is_setting_enabled( $global_setting, array( 'required' ) ) ) { | |
| 600 | +		} elseif ('global' === $form_option && give_is_setting_enabled($global_setting, array('required'))) { | |
| 602 | 601 | $is_company_field_required = true; | 
| 603 | 602 | |
| 604 | -		} elseif ( empty( $form_option ) && give_is_setting_enabled( $global_setting, array( 'required' ) ) ) { | |
| 603 | +		} elseif (empty($form_option) && give_is_setting_enabled($global_setting, array('required'))) { | |
| 605 | 604 | $is_company_field_required = true; | 
| 606 | 605 | |
| 607 | 606 | } | 
| 608 | 607 | |
| 609 | -		if ( $is_company_field_required ) { | |
| 608 | +		if ($is_company_field_required) { | |
| 610 | 609 | $required_fields['give_company_name'] = array( | 
| 611 | 610 | 'error_id' => 'invalid_company', | 
| 612 | - 'error_message' => __( 'Please enter Company Name.', 'give' ), | |
| 611 | +				'error_message' => __('Please enter Company Name.', 'give'), | |
| 613 | 612 | ); | 
| 614 | 613 | } | 
| 615 | 614 | } | 
| @@ -619,7 +618,7 @@ discard block | ||
| 619 | 618 | * | 
| 620 | 619 | * @since 1.7 | 
| 621 | 620 | */ | 
| 622 | - $required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id ); | |
| 621 | +	$required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id); | |
| 623 | 622 | |
| 624 | 623 | return $required_fields; | 
| 625 | 624 | |
| @@ -634,17 +633,17 @@ discard block | ||
| 634 | 633 | * | 
| 635 | 634 | * @return bool | 
| 636 | 635 | */ | 
| 637 | -function give_require_billing_address( $payment_mode ) { | |
| 636 | +function give_require_billing_address($payment_mode) { | |
| 638 | 637 | |
| 639 | 638 | $return = false; | 
| 640 | - $billing_country = ! empty( $_POST['billing_country'] ) ? give_clean( $_POST['billing_country'] ) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 639 | + $billing_country = ! empty($_POST['billing_country']) ? give_clean($_POST['billing_country']) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 641 | 640 | |
| 642 | -	if ( $billing_country || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { | |
| 641 | +	if ($billing_country || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { | |
| 643 | 642 | $return = true; | 
| 644 | 643 | } | 
| 645 | 644 | |
| 646 | 645 | // Let payment gateways and other extensions determine if address fields should be required. | 
| 647 | - return apply_filters( 'give_require_billing_address', $return ); | |
| 646 | +	return apply_filters('give_require_billing_address', $return); | |
| 648 | 647 | |
| 649 | 648 | } | 
| 650 | 649 | |
| @@ -658,47 +657,47 @@ discard block | ||
| 658 | 657 | */ | 
| 659 | 658 |  function give_donation_form_validate_logged_in_user() { | 
| 660 | 659 | |
| 661 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 660 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 662 | 661 | $user_id = get_current_user_id(); | 
| 663 | - $form_id = ! empty( $post_data['give-form-id'] ) ? $post_data['give-form-id'] : 0; | |
| 662 | + $form_id = ! empty($post_data['give-form-id']) ? $post_data['give-form-id'] : 0; | |
| 664 | 663 | |
| 665 | 664 | // Start empty array to collect valid user data. | 
| 666 | 665 | $valid_user_data = array( | 
| 667 | 666 | |
| 668 | 667 | // Assume there will be errors. | 
| 669 | - 'user_id' => - 1, | |
| 668 | + 'user_id' => -1, | |
| 670 | 669 | ); | 
| 671 | 670 | |
| 672 | 671 | // Proceed on;y, if valid $user_id found. | 
| 673 | -	if ( $user_id > 0 ) { | |
| 672 | +	if ($user_id > 0) { | |
| 674 | 673 | |
| 675 | 674 | // Get the logged in user data. | 
| 676 | - $user_data = get_userdata( $user_id ); | |
| 675 | + $user_data = get_userdata($user_id); | |
| 677 | 676 | |
| 678 | 677 | // Validate Required Form Fields. | 
| 679 | - give_validate_required_form_fields( $form_id ); | |
| 678 | + give_validate_required_form_fields($form_id); | |
| 680 | 679 | |
| 681 | 680 | // Verify data. | 
| 682 | -		if ( is_object( $user_data ) && $user_data->ID > 0 ) { | |
| 681 | +		if (is_object($user_data) && $user_data->ID > 0) { | |
| 683 | 682 | |
| 684 | 683 | // Collected logged in user data. | 
| 685 | 684 | $valid_user_data = array( | 
| 686 | 685 | 'user_id' => $user_id, | 
| 687 | - 'user_email' => ! empty( $post_data['give_email'] ) ? sanitize_email( $post_data['give_email'] ) : $user_data->user_email, | |
| 688 | - 'user_first' => ! empty( $post_data['give_first'] ) ? $post_data['give_first'] : $user_data->first_name, | |
| 689 | - 'user_last' => ! empty( $post_data['give_last'] ) ? $post_data['give_last'] : $user_data->last_name, | |
| 686 | + 'user_email' => ! empty($post_data['give_email']) ? sanitize_email($post_data['give_email']) : $user_data->user_email, | |
| 687 | + 'user_first' => ! empty($post_data['give_first']) ? $post_data['give_first'] : $user_data->first_name, | |
| 688 | + 'user_last' => ! empty($post_data['give_last']) ? $post_data['give_last'] : $user_data->last_name, | |
| 690 | 689 | ); | 
| 691 | 690 | |
| 692 | 691 | // Validate essential form fields. | 
| 693 | - give_donation_form_validate_name_fields( $post_data ); | |
| 692 | + give_donation_form_validate_name_fields($post_data); | |
| 694 | 693 | |
| 695 | -			if ( ! is_email( $valid_user_data['user_email'] ) ) { | |
| 696 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); | |
| 694 | +			if ( ! is_email($valid_user_data['user_email'])) { | |
| 695 | +				give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); | |
| 697 | 696 | } | 
| 698 | 697 |  		} else { | 
| 699 | 698 | |
| 700 | 699 | // Set invalid user information error. | 
| 701 | - give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) ); | |
| 700 | +			give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give')); | |
| 702 | 701 | } | 
| 703 | 702 | } | 
| 704 | 703 | |
| @@ -716,12 +715,12 @@ discard block | ||
| 716 | 715 | */ | 
| 717 | 716 |  function give_donation_form_validate_new_user() { | 
| 718 | 717 | |
| 719 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 720 | - $nonce = ! empty( $post_data['give-form-user-register-hash'] ) ? $post_data['give-form-user-register-hash'] : ''; | |
| 718 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 719 | + $nonce = ! empty($post_data['give-form-user-register-hash']) ? $post_data['give-form-user-register-hash'] : ''; | |
| 721 | 720 | |
| 722 | 721 | // Validate user creation nonce. | 
| 723 | -	if ( ! wp_verify_nonce( $nonce, 'give_form_create_user_nonce' ) ) { | |
| 724 | - give_set_error( 'invalid_nonce', __( 'Nonce verification has failed.', 'give' ) ); | |
| 722 | +	if ( ! wp_verify_nonce($nonce, 'give_form_create_user_nonce')) { | |
| 723 | +		give_set_error('invalid_nonce', __('Nonce verification has failed.', 'give')); | |
| 725 | 724 | } | 
| 726 | 725 | |
| 727 | 726 | $auto_generated_password = wp_generate_password(); | 
| @@ -729,7 +728,7 @@ discard block | ||
| 729 | 728 | // Default user data. | 
| 730 | 729 | $default_user_data = array( | 
| 731 | 730 | 'give-form-id' => '', | 
| 732 | - 'user_id' => - 1, // Assume there will be errors. | |
| 731 | + 'user_id' => -1, // Assume there will be errors. | |
| 733 | 732 | 'user_first' => '', | 
| 734 | 733 | 'user_last' => '', | 
| 735 | 734 | 'give_user_login' => false, | 
| @@ -739,17 +738,17 @@ discard block | ||
| 739 | 738 | ); | 
| 740 | 739 | |
| 741 | 740 | // Get user data. | 
| 742 | - $user_data = wp_parse_args( $post_data, $default_user_data ); | |
| 741 | + $user_data = wp_parse_args($post_data, $default_user_data); | |
| 743 | 742 | $registering_new_user = false; | 
| 744 | - $form_id = absint( $user_data['give-form-id'] ); | |
| 743 | + $form_id = absint($user_data['give-form-id']); | |
| 745 | 744 | |
| 746 | - give_donation_form_validate_name_fields( $user_data ); | |
| 745 | + give_donation_form_validate_name_fields($user_data); | |
| 747 | 746 | |
| 748 | 747 | // Start an empty array to collect valid user data. | 
| 749 | 748 | $valid_user_data = array( | 
| 750 | 749 | |
| 751 | 750 | // Assume there will be errors. | 
| 752 | - 'user_id' => - 1, | |
| 751 | + 'user_id' => -1, | |
| 753 | 752 | |
| 754 | 753 | // Get first name. | 
| 755 | 754 | 'user_first' => $user_data['give_first'], | 
| @@ -762,13 +761,13 @@ discard block | ||
| 762 | 761 | ); | 
| 763 | 762 | |
| 764 | 763 | // Validate Required Form Fields. | 
| 765 | - give_validate_required_form_fields( $form_id ); | |
| 764 | + give_validate_required_form_fields($form_id); | |
| 766 | 765 | |
| 767 | 766 | // Set Email as Username. | 
| 768 | 767 | $valid_user_data['user_login'] = $user_data['give_email']; | 
| 769 | 768 | |
| 770 | 769 | // Check if we have an email to verify. | 
| 771 | -	if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) { | |
| 770 | +	if (give_validate_user_email($user_data['give_email'], $registering_new_user)) { | |
| 772 | 771 | $valid_user_data['user_email'] = $user_data['give_email']; | 
| 773 | 772 | } | 
| 774 | 773 | |
| @@ -785,47 +784,47 @@ discard block | ||
| 785 | 784 | */ | 
| 786 | 785 |  function give_donation_form_validate_user_login() { | 
| 787 | 786 | |
| 788 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 787 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 789 | 788 | |
| 790 | 789 | // Start an array to collect valid user data. | 
| 791 | 790 | $valid_user_data = array( | 
| 792 | 791 | |
| 793 | 792 | // Assume there will be errors. | 
| 794 | - 'user_id' => - 1, | |
| 793 | + 'user_id' => -1, | |
| 795 | 794 | ); | 
| 796 | 795 | |
| 797 | 796 | // Bailout, if Username is empty. | 
| 798 | -	if ( empty( $post_data['give_user_login'] ) ) { | |
| 799 | - give_set_error( 'must_log_in', __( 'You must register or login to complete your donation.', 'give' ) ); | |
| 797 | +	if (empty($post_data['give_user_login'])) { | |
| 798 | +		give_set_error('must_log_in', __('You must register or login to complete your donation.', 'give')); | |
| 800 | 799 | |
| 801 | 800 | return $valid_user_data; | 
| 802 | 801 | } | 
| 803 | 802 | |
| 804 | 803 | // Get the user by login. | 
| 805 | - $user_data = get_user_by( 'login', strip_tags( $post_data['give_user_login'] ) ); | |
| 804 | +	$user_data = get_user_by('login', strip_tags($post_data['give_user_login'])); | |
| 806 | 805 | |
| 807 | 806 | // Check if user exists. | 
| 808 | -	if ( $user_data ) { | |
| 807 | +	if ($user_data) { | |
| 809 | 808 | |
| 810 | 809 | // Get password. | 
| 811 | - $user_pass = ! empty( $post_data['give_user_pass'] ) ? $post_data['give_user_pass'] : false; | |
| 810 | + $user_pass = ! empty($post_data['give_user_pass']) ? $post_data['give_user_pass'] : false; | |
| 812 | 811 | |
| 813 | 812 | // Check user_pass. | 
| 814 | -		if ( $user_pass ) { | |
| 813 | +		if ($user_pass) { | |
| 815 | 814 | |
| 816 | 815 | // Check if password is valid. | 
| 817 | -			if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { | |
| 816 | +			if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { | |
| 818 | 817 | |
| 819 | - $current_page_url = site_url() . '/' . get_page_uri(); | |
| 818 | + $current_page_url = site_url().'/'.get_page_uri(); | |
| 820 | 819 | |
| 821 | 820 | // Incorrect password. | 
| 822 | 821 | give_set_error( | 
| 823 | 822 | 'password_incorrect', | 
| 824 | 823 | sprintf( | 
| 825 | 824 | '%1$s <a href="%2$s">%3$s</a>', | 
| 826 | - __( 'The password you entered is incorrect.', 'give' ), | |
| 827 | - wp_lostpassword_url( $current_page_url ), | |
| 828 | - __( 'Reset Password', 'give' ) | |
| 825 | +						__('The password you entered is incorrect.', 'give'), | |
| 826 | + wp_lostpassword_url($current_page_url), | |
| 827 | +						__('Reset Password', 'give') | |
| 829 | 828 | ) | 
| 830 | 829 | ); | 
| 831 | 830 | |
| @@ -843,11 +842,11 @@ discard block | ||
| 843 | 842 | } | 
| 844 | 843 |  		} else { | 
| 845 | 844 | // Empty password. | 
| 846 | - give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) ); | |
| 845 | +			give_set_error('password_empty', __('Enter a password.', 'give')); | |
| 847 | 846 | } | 
| 848 | 847 |  	} else { | 
| 849 | 848 | // No username. | 
| 850 | - give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) ); | |
| 849 | +		give_set_error('username_incorrect', __('The username you entered does not exist.', 'give')); | |
| 851 | 850 | } // End if(). | 
| 852 | 851 | |
| 853 | 852 | return $valid_user_data; | 
| @@ -863,8 +862,8 @@ discard block | ||
| 863 | 862 | */ | 
| 864 | 863 |  function give_donation_form_validate_guest_user() { | 
| 865 | 864 | |
| 866 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 867 | - $form_id = ! empty( $post_data['give-form-id'] ) ? $post_data['give-form-id'] : 0; | |
| 865 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 866 | + $form_id = ! empty($post_data['give-form-id']) ? $post_data['give-form-id'] : 0; | |
| 868 | 867 | |
| 869 | 868 | // Start an array to collect valid user data. | 
| 870 | 869 | $valid_user_data = array( | 
| @@ -873,22 +872,22 @@ discard block | ||
| 873 | 872 | ); | 
| 874 | 873 | |
| 875 | 874 | // Validate name fields. | 
| 876 | - give_donation_form_validate_name_fields( $post_data ); | |
| 875 | + give_donation_form_validate_name_fields($post_data); | |
| 877 | 876 | |
| 878 | 877 | // Validate Required Form Fields. | 
| 879 | - give_validate_required_form_fields( $form_id ); | |
| 878 | + give_validate_required_form_fields($form_id); | |
| 880 | 879 | |
| 881 | 880 | // Get the guest email. | 
| 882 | - $guest_email = ! empty( $post_data['give_email'] ) ? $post_data['give_email'] : false; | |
| 881 | + $guest_email = ! empty($post_data['give_email']) ? $post_data['give_email'] : false; | |
| 883 | 882 | |
| 884 | 883 | // Check email. | 
| 885 | -	if ( $guest_email && strlen( $guest_email ) > 0 ) { | |
| 884 | +	if ($guest_email && strlen($guest_email) > 0) { | |
| 886 | 885 | |
| 887 | 886 | // Validate email. | 
| 888 | -		if ( ! is_email( $guest_email ) ) { | |
| 887 | +		if ( ! is_email($guest_email)) { | |
| 889 | 888 | |
| 890 | 889 | // Invalid email. | 
| 891 | - give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) ); | |
| 890 | +			give_set_error('email_invalid', __('Invalid email.', 'give')); | |
| 892 | 891 | |
| 893 | 892 |  		} else { | 
| 894 | 893 | |
| @@ -896,15 +895,15 @@ discard block | ||
| 896 | 895 | $valid_user_data['user_email'] = $guest_email; | 
| 897 | 896 | |
| 898 | 897 | // Get user_id from donor if exist. | 
| 899 | - $donor = new Give_Donor( $guest_email ); | |
| 898 | + $donor = new Give_Donor($guest_email); | |
| 900 | 899 | |
| 901 | -			if ( $donor->id && $donor->user_id ) { | |
| 900 | +			if ($donor->id && $donor->user_id) { | |
| 902 | 901 | $valid_user_data['user_id'] = $donor->user_id; | 
| 903 | 902 | } | 
| 904 | 903 | } | 
| 905 | 904 |  	} else { | 
| 906 | 905 | // No email. | 
| 907 | - give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) ); | |
| 906 | +		give_set_error('email_empty', __('Enter an email.', 'give')); | |
| 908 | 907 | } | 
| 909 | 908 | |
| 910 | 909 | return $valid_user_data; | 
| @@ -920,36 +919,36 @@ discard block | ||
| 920 | 919 | * | 
| 921 | 920 | * @return integer | 
| 922 | 921 | */ | 
| 923 | -function give_register_and_login_new_user( $user_data = array() ) { | |
| 922 | +function give_register_and_login_new_user($user_data = array()) { | |
| 924 | 923 | // Verify the array. | 
| 925 | -	if ( empty( $user_data ) ) { | |
| 926 | - return - 1; | |
| 924 | +	if (empty($user_data)) { | |
| 925 | + return -1; | |
| 927 | 926 | } | 
| 928 | 927 | |
| 929 | -	if ( give_get_errors() ) { | |
| 930 | - return - 1; | |
| 928 | +	if (give_get_errors()) { | |
| 929 | + return -1; | |
| 931 | 930 | } | 
| 932 | 931 | |
| 933 | - $user_args = apply_filters( 'give_insert_user_args', array( | |
| 934 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '', | |
| 935 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '', | |
| 936 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '', | |
| 937 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '', | |
| 938 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '', | |
| 939 | - 'user_registered' => date( 'Y-m-d H:i:s' ), | |
| 940 | - 'role' => give_get_option( 'donor_default_user_role', 'give_donor' ), | |
| 941 | - ), $user_data ); | |
| 932 | +	$user_args = apply_filters('give_insert_user_args', array( | |
| 933 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', | |
| 934 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', | |
| 935 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', | |
| 936 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', | |
| 937 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', | |
| 938 | +		'user_registered' => date('Y-m-d H:i:s'), | |
| 939 | +		'role'            => give_get_option('donor_default_user_role', 'give_donor'), | |
| 940 | + ), $user_data); | |
| 942 | 941 | |
| 943 | 942 | // Insert new user. | 
| 944 | - $user_id = wp_insert_user( $user_args ); | |
| 943 | + $user_id = wp_insert_user($user_args); | |
| 945 | 944 | |
| 946 | 945 | // Validate inserted user. | 
| 947 | -	if ( is_wp_error( $user_id ) ) { | |
| 948 | - return - 1; | |
| 946 | +	if (is_wp_error($user_id)) { | |
| 947 | + return -1; | |
| 949 | 948 | } | 
| 950 | 949 | |
| 951 | 950 | // Allow themes and plugins to filter the user data. | 
| 952 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args ); | |
| 951 | +	$user_data = apply_filters('give_insert_user_data', $user_data, $user_args); | |
| 953 | 952 | |
| 954 | 953 | /** | 
| 955 | 954 | * Fires after inserting user. | 
| @@ -959,7 +958,7 @@ discard block | ||
| 959 | 958 | * @param int $user_id User id. | 
| 960 | 959 | * @param array $user_data Array containing user data. | 
| 961 | 960 | */ | 
| 962 | - do_action( 'give_insert_user', $user_id, $user_data ); | |
| 961 | +	do_action('give_insert_user', $user_id, $user_data); | |
| 963 | 962 | |
| 964 | 963 | /** | 
| 965 | 964 | * Filter allow user to alter if user when to login or not when user is register for the first time. | 
| @@ -968,9 +967,9 @@ discard block | ||
| 968 | 967 | * | 
| 969 | 968 | * return bool True if login with registration and False if only want to register. | 
| 970 | 969 | */ | 
| 971 | -	if ( true === (bool) apply_filters( 'give_log_user_in_on_register', true ) ) { | |
| 970 | +	if (true === (bool) apply_filters('give_log_user_in_on_register', true)) { | |
| 972 | 971 | // Login new user. | 
| 973 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] ); | |
| 972 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']); | |
| 974 | 973 | } | 
| 975 | 974 | |
| 976 | 975 | // Return user id. | 
| @@ -987,33 +986,33 @@ discard block | ||
| 987 | 986 | * | 
| 988 | 987 | * @return array|bool | 
| 989 | 988 | */ | 
| 990 | -function give_get_donation_form_user( $valid_data = array() ) { | |
| 989 | +function give_get_donation_form_user($valid_data = array()) { | |
| 991 | 990 | |
| 992 | 991 | // Initialize user. | 
| 993 | 992 | $user = false; | 
| 994 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; | |
| 995 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 993 | +	$is_ajax   = defined('DOING_AJAX') && DOING_AJAX; | |
| 994 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 996 | 995 | |
| 997 | -	if ( $is_ajax ) { | |
| 996 | +	if ($is_ajax) { | |
| 998 | 997 | |
| 999 | 998 | // Do not create or login the user during the ajax submission (check for errors only). | 
| 1000 | 999 | return true; | 
| 1001 | -	} elseif ( is_user_logged_in() ) { | |
| 1000 | +	} elseif (is_user_logged_in()) { | |
| 1002 | 1001 | |
| 1003 | 1002 | // Set the valid user as the logged in collected data. | 
| 1004 | 1003 | $user = $valid_data['logged_in_user']; | 
| 1005 | -	} elseif ( true === $valid_data['need_new_user'] || true === $valid_data['need_user_login'] ) { | |
| 1004 | +	} elseif (true === $valid_data['need_new_user'] || true === $valid_data['need_user_login']) { | |
| 1006 | 1005 | |
| 1007 | 1006 | // New user registration. | 
| 1008 | -		if ( true === $valid_data['need_new_user'] ) { | |
| 1007 | +		if (true === $valid_data['need_new_user']) { | |
| 1009 | 1008 | |
| 1010 | 1009 | // Set user. | 
| 1011 | 1010 | $user = $valid_data['new_user_data']; | 
| 1012 | 1011 | |
| 1013 | 1012 | // Register and login new user. | 
| 1014 | - $user['user_id'] = give_register_and_login_new_user( $user ); | |
| 1013 | + $user['user_id'] = give_register_and_login_new_user($user); | |
| 1015 | 1014 | |
| 1016 | -		} elseif ( true === $valid_data['need_user_login'] && ! $is_ajax ) { | |
| 1015 | +		} elseif (true === $valid_data['need_user_login'] && ! $is_ajax) { | |
| 1017 | 1016 | |
| 1018 | 1017 | /** | 
| 1019 | 1018 | * The login form is now processed in the give_process_donation_login() function. | 
| @@ -1025,42 +1024,42 @@ discard block | ||
| 1025 | 1024 | $user = $valid_data['login_user_data']; | 
| 1026 | 1025 | |
| 1027 | 1026 | // Login user. | 
| 1028 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] ); | |
| 1027 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); | |
| 1029 | 1028 | } | 
| 1030 | 1029 | } // End if(). | 
| 1031 | 1030 | |
| 1032 | 1031 | // Check guest checkout. | 
| 1033 | -	if ( false === $user && false === give_logged_in_only( $post_data['give-form-id'] ) ) { | |
| 1032 | +	if (false === $user && false === give_logged_in_only($post_data['give-form-id'])) { | |
| 1034 | 1033 | |
| 1035 | 1034 | // Set user. | 
| 1036 | 1035 | $user = $valid_data['guest_user_data']; | 
| 1037 | 1036 | } | 
| 1038 | 1037 | |
| 1039 | 1038 | // Verify we have an user. | 
| 1040 | -	if ( false === $user || empty( $user ) ) { | |
| 1039 | +	if (false === $user || empty($user)) { | |
| 1041 | 1040 | return false; | 
| 1042 | 1041 | } | 
| 1043 | 1042 | |
| 1044 | 1043 | // Get user first name. | 
| 1045 | -	if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { | |
| 1046 | - $user['user_first'] = isset( $post_data['give_first'] ) ? strip_tags( trim( $post_data['give_first'] ) ) : ''; | |
| 1044 | +	if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { | |
| 1045 | + $user['user_first'] = isset($post_data['give_first']) ? strip_tags(trim($post_data['give_first'])) : ''; | |
| 1047 | 1046 | } | 
| 1048 | 1047 | |
| 1049 | 1048 | // Get user last name. | 
| 1050 | -	if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { | |
| 1051 | - $user['user_last'] = isset( $post_data['give_last'] ) ? strip_tags( trim( $post_data['give_last'] ) ) : ''; | |
| 1049 | +	if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { | |
| 1050 | + $user['user_last'] = isset($post_data['give_last']) ? strip_tags(trim($post_data['give_last'])) : ''; | |
| 1052 | 1051 | } | 
| 1053 | 1052 | |
| 1054 | 1053 | // Get the user's billing address details. | 
| 1055 | 1054 | $user['address'] = array(); | 
| 1056 | - $user['address']['line1'] = ! empty( $post_data['card_address'] ) ? $post_data['card_address'] : false; | |
| 1057 | - $user['address']['line2'] = ! empty( $post_data['card_address_2'] ) ? $post_data['card_address_2'] : false; | |
| 1058 | - $user['address']['city'] = ! empty( $post_data['card_city'] ) ? $post_data['card_city'] : false; | |
| 1059 | - $user['address']['state'] = ! empty( $post_data['card_state'] ) ? $post_data['card_state'] : false; | |
| 1060 | - $user['address']['zip'] = ! empty( $post_data['card_zip'] ) ? $post_data['card_zip'] : false; | |
| 1061 | - $user['address']['country'] = ! empty( $post_data['billing_country'] ) ? $post_data['billing_country'] : false; | |
| 1062 | - | |
| 1063 | -	if ( empty( $user['address']['country'] ) ) { | |
| 1055 | + $user['address']['line1'] = ! empty($post_data['card_address']) ? $post_data['card_address'] : false; | |
| 1056 | + $user['address']['line2'] = ! empty($post_data['card_address_2']) ? $post_data['card_address_2'] : false; | |
| 1057 | + $user['address']['city'] = ! empty($post_data['card_city']) ? $post_data['card_city'] : false; | |
| 1058 | + $user['address']['state'] = ! empty($post_data['card_state']) ? $post_data['card_state'] : false; | |
| 1059 | + $user['address']['zip'] = ! empty($post_data['card_zip']) ? $post_data['card_zip'] : false; | |
| 1060 | + $user['address']['country'] = ! empty($post_data['billing_country']) ? $post_data['billing_country'] : false; | |
| 1061 | + | |
| 1062 | +	if (empty($user['address']['country'])) { | |
| 1064 | 1063 | $user['address'] = false; | 
| 1065 | 1064 | } // End if(). | 
| 1066 | 1065 | |
| @@ -1081,16 +1080,16 @@ discard block | ||
| 1081 | 1080 | $card_data = give_get_donation_cc_info(); | 
| 1082 | 1081 | |
| 1083 | 1082 | // Validate the card zip. | 
| 1084 | -	if ( ! empty( $card_data['card_zip'] ) ) { | |
| 1085 | -		if ( ! give_donation_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { | |
| 1086 | - give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) ); | |
| 1083 | +	if ( ! empty($card_data['card_zip'])) { | |
| 1084 | +		if ( ! give_donation_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { | |
| 1085 | +			give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid.', 'give')); | |
| 1087 | 1086 | } | 
| 1088 | 1087 | } | 
| 1089 | 1088 | |
| 1090 | 1089 | // Ensure no spaces. | 
| 1091 | -	if ( ! empty( $card_data['card_number'] ) ) { | |
| 1092 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs. | |
| 1093 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces. | |
| 1090 | +	if ( ! empty($card_data['card_number'])) { | |
| 1091 | +		$card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs. | |
| 1092 | +		$card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces. | |
| 1094 | 1093 | } | 
| 1095 | 1094 | |
| 1096 | 1095 | // This should validate card numbers at some point too. | 
| @@ -1108,20 +1107,20 @@ discard block | ||
| 1108 | 1107 |  function give_get_donation_cc_info() { | 
| 1109 | 1108 | |
| 1110 | 1109 | // Sanitize the values submitted with donation form. | 
| 1111 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 1110 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 1112 | 1111 | |
| 1113 | 1112 | $cc_info = array(); | 
| 1114 | - $cc_info['card_name'] = ! empty( $post_data['card_name'] ) ? $post_data['card_name'] : ''; | |
| 1115 | - $cc_info['card_number'] = ! empty( $post_data['card_number'] ) ? $post_data['card_number'] : ''; | |
| 1116 | - $cc_info['card_cvc'] = ! empty( $post_data['card_cvc'] ) ? $post_data['card_cvc'] : ''; | |
| 1117 | - $cc_info['card_exp_month'] = ! empty( $post_data['card_exp_month'] ) ? $post_data['card_exp_month'] : ''; | |
| 1118 | - $cc_info['card_exp_year'] = ! empty( $post_data['card_exp_year'] ) ? $post_data['card_exp_year'] : ''; | |
| 1119 | - $cc_info['card_address'] = ! empty( $post_data['card_address'] ) ? $post_data['card_address'] : ''; | |
| 1120 | - $cc_info['card_address_2'] = ! empty( $post_data['card_address_2'] ) ? $post_data['card_address_2'] : ''; | |
| 1121 | - $cc_info['card_city'] = ! empty( $post_data['card_city'] ) ? $post_data['card_city'] : ''; | |
| 1122 | - $cc_info['card_state'] = ! empty( $post_data['card_state'] ) ? $post_data['card_state'] : ''; | |
| 1123 | - $cc_info['card_country'] = ! empty( $post_data['billing_country'] ) ? $post_data['billing_country'] : ''; | |
| 1124 | - $cc_info['card_zip'] = ! empty( $post_data['card_zip'] ) ? $post_data['card_zip'] : ''; | |
| 1113 | + $cc_info['card_name'] = ! empty($post_data['card_name']) ? $post_data['card_name'] : ''; | |
| 1114 | + $cc_info['card_number'] = ! empty($post_data['card_number']) ? $post_data['card_number'] : ''; | |
| 1115 | + $cc_info['card_cvc'] = ! empty($post_data['card_cvc']) ? $post_data['card_cvc'] : ''; | |
| 1116 | + $cc_info['card_exp_month'] = ! empty($post_data['card_exp_month']) ? $post_data['card_exp_month'] : ''; | |
| 1117 | + $cc_info['card_exp_year'] = ! empty($post_data['card_exp_year']) ? $post_data['card_exp_year'] : ''; | |
| 1118 | + $cc_info['card_address'] = ! empty($post_data['card_address']) ? $post_data['card_address'] : ''; | |
| 1119 | + $cc_info['card_address_2'] = ! empty($post_data['card_address_2']) ? $post_data['card_address_2'] : ''; | |
| 1120 | + $cc_info['card_city'] = ! empty($post_data['card_city']) ? $post_data['card_city'] : ''; | |
| 1121 | + $cc_info['card_state'] = ! empty($post_data['card_state']) ? $post_data['card_state'] : ''; | |
| 1122 | + $cc_info['card_country'] = ! empty($post_data['billing_country']) ? $post_data['billing_country'] : ''; | |
| 1123 | + $cc_info['card_zip'] = ! empty($post_data['card_zip']) ? $post_data['card_zip'] : ''; | |
| 1125 | 1124 | |
| 1126 | 1125 | // Return cc info. | 
| 1127 | 1126 | return $cc_info; | 
| @@ -1137,14 +1136,14 @@ discard block | ||
| 1137 | 1136 | * | 
| 1138 | 1137 | * @return bool|mixed | 
| 1139 | 1138 | */ | 
| 1140 | -function give_donation_form_validate_cc_zip( $zip = 0, $country_code = '' ) { | |
| 1139 | +function give_donation_form_validate_cc_zip($zip = 0, $country_code = '') { | |
| 1141 | 1140 | $ret = false; | 
| 1142 | 1141 | |
| 1143 | -	if ( empty( $zip ) || empty( $country_code ) ) { | |
| 1142 | +	if (empty($zip) || empty($country_code)) { | |
| 1144 | 1143 | return $ret; | 
| 1145 | 1144 | } | 
| 1146 | 1145 | |
| 1147 | - $country_code = strtoupper( $country_code ); | |
| 1146 | + $country_code = strtoupper($country_code); | |
| 1148 | 1147 | |
| 1149 | 1148 | $zip_regex = array( | 
| 1150 | 1149 |  		'AD' => 'AD\d{3}', | 
| @@ -1304,11 +1303,11 @@ discard block | ||
| 1304 | 1303 |  		'ZM' => '\d{5}', | 
| 1305 | 1304 | ); | 
| 1306 | 1305 | |
| 1307 | -	if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) { | |
| 1306 | +	if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) { | |
| 1308 | 1307 | $ret = true; | 
| 1309 | 1308 | } | 
| 1310 | 1309 | |
| 1311 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code ); | |
| 1310 | +	return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); | |
| 1312 | 1311 | } | 
| 1313 | 1312 | |
| 1314 | 1313 | /** | 
| @@ -1320,56 +1319,56 @@ discard block | ||
| 1320 | 1319 | * | 
| 1321 | 1320 | * @return bool | 
| 1322 | 1321 | */ | 
| 1323 | -function give_validate_donation_amount( $valid_data ) { | |
| 1322 | +function give_validate_donation_amount($valid_data) { | |
| 1324 | 1323 | |
| 1325 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 1324 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 1326 | 1325 | |
| 1327 | 1326 | /* @var Give_Donate_Form $form */ | 
| 1328 | - $form = new Give_Donate_Form( $post_data['give-form-id'] ); | |
| 1327 | + $form = new Give_Donate_Form($post_data['give-form-id']); | |
| 1329 | 1328 | |
| 1330 | 1329 | $donation_level_matched = false; | 
| 1331 | 1330 | |
| 1332 | -	if ( $form->is_set_type_donation_form() ) { | |
| 1331 | +	if ($form->is_set_type_donation_form()) { | |
| 1333 | 1332 | |
| 1334 | 1333 | // Sanitize donation amount. | 
| 1335 | - $post_data['give-amount'] = give_maybe_sanitize_amount( $post_data['give-amount'] ); | |
| 1334 | + $post_data['give-amount'] = give_maybe_sanitize_amount($post_data['give-amount']); | |
| 1336 | 1335 | |
| 1337 | 1336 | // Backward compatibility. | 
| 1338 | -		if ( $form->is_custom_price( $post_data['give-amount'] ) ) { | |
| 1337 | +		if ($form->is_custom_price($post_data['give-amount'])) { | |
| 1339 | 1338 | $post_data['give-price-id'] = 'custom'; | 
| 1340 | 1339 | } | 
| 1341 | 1340 | |
| 1342 | 1341 | $donation_level_matched = true; | 
| 1343 | 1342 | |
| 1344 | -	} elseif ( $form->is_multi_type_donation_form() ) { | |
| 1343 | +	} elseif ($form->is_multi_type_donation_form()) { | |
| 1345 | 1344 | |
| 1346 | 1345 | $variable_prices = $form->get_prices(); | 
| 1347 | 1346 | |
| 1348 | 1347 | // Bailout. | 
| 1349 | -		if ( ! $variable_prices ) { | |
| 1348 | +		if ( ! $variable_prices) { | |
| 1350 | 1349 | return false; | 
| 1351 | 1350 | } | 
| 1352 | 1351 | |
| 1353 | 1352 | // Sanitize donation amount. | 
| 1354 | - $post_data['give-amount'] = give_maybe_sanitize_amount( $post_data['give-amount'] ); | |
| 1355 | - $variable_price_option_amount = give_maybe_sanitize_amount( give_get_price_option_amount( $post_data['give-form-id'], $post_data['give-price-id'] ) ); | |
| 1353 | + $post_data['give-amount'] = give_maybe_sanitize_amount($post_data['give-amount']); | |
| 1354 | + $variable_price_option_amount = give_maybe_sanitize_amount(give_get_price_option_amount($post_data['give-form-id'], $post_data['give-price-id'])); | |
| 1356 | 1355 | |
| 1357 | -		if ( $post_data['give-amount'] === $variable_price_option_amount ) { | |
| 1356 | +		if ($post_data['give-amount'] === $variable_price_option_amount) { | |
| 1358 | 1357 | return true; | 
| 1359 | 1358 | } | 
| 1360 | 1359 | |
| 1361 | -		if ( $form->is_custom_price( $post_data['give-amount'] ) ) { | |
| 1360 | +		if ($form->is_custom_price($post_data['give-amount'])) { | |
| 1362 | 1361 | $post_data['give-price-id'] = 'custom'; | 
| 1363 | 1362 |  		} else { | 
| 1364 | 1363 | |
| 1365 | 1364 | // Find correct donation level from all donation levels. | 
| 1366 | -			foreach ( $variable_prices as $variable_price ) { | |
| 1365 | +			foreach ($variable_prices as $variable_price) { | |
| 1367 | 1366 | |
| 1368 | 1367 | // Sanitize level amount. | 
| 1369 | - $variable_price['_give_amount'] = give_maybe_sanitize_amount( $variable_price['_give_amount'] ); | |
| 1368 | + $variable_price['_give_amount'] = give_maybe_sanitize_amount($variable_price['_give_amount']); | |
| 1370 | 1369 | |
| 1371 | 1370 | // Set first match donation level ID. | 
| 1372 | -				if ( $post_data['give-amount'] === $variable_price['_give_amount'] ) { | |
| 1371 | +				if ($post_data['give-amount'] === $variable_price['_give_amount']) { | |
| 1373 | 1372 | $post_data['give-price-id'] = $variable_price['_give_id']['level_id']; | 
| 1374 | 1373 | break; | 
| 1375 | 1374 | } | 
| @@ -1378,15 +1377,15 @@ discard block | ||
| 1378 | 1377 | |
| 1379 | 1378 | // If donation amount is not find in donation levels then check if form has custom donation feature enable or not. | 
| 1380 | 1379 | // If yes then set price id to custom if amount is greater then custom minimum amount (if any). | 
| 1381 | -		if ( ! empty( $post_data['give-price-id'] ) ) { | |
| 1380 | +		if ( ! empty($post_data['give-price-id'])) { | |
| 1382 | 1381 | $donation_level_matched = true; | 
| 1383 | 1382 | } | 
| 1384 | 1383 | } // End if(). | 
| 1385 | 1384 | |
| 1386 | - return ( $donation_level_matched ? true : false ); | |
| 1385 | + return ($donation_level_matched ? true : false); | |
| 1387 | 1386 | } | 
| 1388 | 1387 | |
| 1389 | -add_action( 'give_checkout_error_checks', 'give_validate_donation_amount', 10, 1 ); | |
| 1388 | +add_action('give_checkout_error_checks', 'give_validate_donation_amount', 10, 1); | |
| 1390 | 1389 | |
| 1391 | 1390 | /** | 
| 1392 | 1391 | * Validate Required Form Fields. | 
| @@ -1395,20 +1394,20 @@ discard block | ||
| 1395 | 1394 | * | 
| 1396 | 1395 | * @since 2.0 | 
| 1397 | 1396 | */ | 
| 1398 | -function give_validate_required_form_fields( $form_id ) { | |
| 1397 | +function give_validate_required_form_fields($form_id) { | |
| 1399 | 1398 | |
| 1400 | 1399 | // Sanitize values submitted with donation form. | 
| 1401 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 1400 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. | |
| 1402 | 1401 | |
| 1403 | 1402 | // Loop through required fields and show error messages. | 
| 1404 | -	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { | |
| 1403 | +	foreach (give_get_required_fields($form_id) as $field_name => $value) { | |
| 1405 | 1404 | |
| 1406 | 1405 | // Clean Up Data of the input fields. | 
| 1407 | - $field_value = $post_data[ $field_name ]; | |
| 1406 | + $field_value = $post_data[$field_name]; | |
| 1408 | 1407 | |
| 1409 | 1408 | // Check whether the required field is empty, then show the error message. | 
| 1410 | -		if ( in_array( $value, give_get_required_fields( $form_id ), true ) && empty( $field_value ) ) { | |
| 1411 | - give_set_error( $value['error_id'], $value['error_message'] ); | |
| 1409 | +		if (in_array($value, give_get_required_fields($form_id), true) && empty($field_value)) { | |
| 1410 | + give_set_error($value['error_id'], $value['error_message']); | |
| 1412 | 1411 | } | 
| 1413 | 1412 | } | 
| 1414 | 1413 | } | 
| @@ -1422,11 +1421,11 @@ discard block | ||
| 1422 | 1421 | * | 
| 1423 | 1422 | * @return void | 
| 1424 | 1423 | */ | 
| 1425 | -function give_donation_form_validate_name_fields( $post_data ) { | |
| 1426 | - $is_alpha_first_name = ctype_alpha( $post_data['give_first'] ) ? true : false; | |
| 1427 | - $is_alpha_last_name = ctype_alpha( $post_data['give_last'] ) ? true : false; | |
| 1424 | +function give_donation_form_validate_name_fields($post_data) { | |
| 1425 | + $is_alpha_first_name = ctype_alpha($post_data['give_first']) ? true : false; | |
| 1426 | + $is_alpha_last_name = ctype_alpha($post_data['give_last']) ? true : false; | |
| 1428 | 1427 | |
| 1429 | -	if ( ! $is_alpha_first_name || ( ! empty( $post_data['give_last'] ) && ! $is_alpha_last_name ) ) { | |
| 1430 | - give_set_error( 'invalid_name', esc_html__( '<First Name | Last Name> cannot contain email address, numbers or special characters.', 'give' ) ); | |
| 1428 | +	if ( ! $is_alpha_first_name || ( ! empty($post_data['give_last']) && ! $is_alpha_last_name)) { | |
| 1429 | +		give_set_error('invalid_name', esc_html__('<First Name | Last Name> cannot contain email address, numbers or special characters.', 'give')); | |
| 1431 | 1430 | } | 
| 1432 | 1431 | } | 
| @@ -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 | |
| @@ -149,32 +149,32 @@ discard block | ||
| 149 | 149 | * @param int|bool $_id_or_email | 
| 150 | 150 | * @param bool $by_user_id | 
| 151 | 151 | */ | 
| 152 | -	public function __construct( $_id_or_email = false, $by_user_id = false ) { | |
| 152 | +	public function __construct($_id_or_email = false, $by_user_id = false) { | |
| 153 | 153 | |
| 154 | 154 | $this->db = Give()->donors; | 
| 155 | 155 | |
| 156 | 156 | if ( | 
| 157 | 157 | false === $_id_or_email | 
| 158 | - || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) | |
| 158 | + || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email)) | |
| 159 | 159 |  		) { | 
| 160 | 160 | return false; | 
| 161 | 161 | } | 
| 162 | 162 | |
| 163 | - $by_user_id = is_bool( $by_user_id ) ? $by_user_id : false; | |
| 163 | + $by_user_id = is_bool($by_user_id) ? $by_user_id : false; | |
| 164 | 164 | |
| 165 | -		if ( is_numeric( $_id_or_email ) ) { | |
| 165 | +		if (is_numeric($_id_or_email)) { | |
| 166 | 166 | $field = $by_user_id ? 'user_id' : 'id'; | 
| 167 | 167 |  		} else { | 
| 168 | 168 | $field = 'email'; | 
| 169 | 169 | } | 
| 170 | 170 | |
| 171 | - $donor = $this->db->get_donor_by( $field, $_id_or_email ); | |
| 171 | + $donor = $this->db->get_donor_by($field, $_id_or_email); | |
| 172 | 172 | |
| 173 | -		if ( empty( $donor ) || ! is_object( $donor ) ) { | |
| 173 | +		if (empty($donor) || ! is_object($donor)) { | |
| 174 | 174 | return false; | 
| 175 | 175 | } | 
| 176 | 176 | |
| 177 | - $this->setup_donor( $donor ); | |
| 177 | + $this->setup_donor($donor); | |
| 178 | 178 | |
| 179 | 179 | } | 
| 180 | 180 | |
| @@ -190,19 +190,19 @@ discard block | ||
| 190 | 190 | * | 
| 191 | 191 | * @return bool If the setup was successful or not. | 
| 192 | 192 | */ | 
| 193 | -	private function setup_donor( $donor ) { | |
| 193 | +	private function setup_donor($donor) { | |
| 194 | 194 | |
| 195 | -		if ( ! is_object( $donor ) ) { | |
| 195 | +		if ( ! is_object($donor)) { | |
| 196 | 196 | return false; | 
| 197 | 197 | } | 
| 198 | 198 | |
| 199 | 199 | // Get cached donors. | 
| 200 | - $donor_vars = Give_Cache::get_group( $donor->id, 'give-donors' ); | |
| 200 | + $donor_vars = Give_Cache::get_group($donor->id, 'give-donors'); | |
| 201 | 201 | |
| 202 | -		if( is_null( $donor_vars ) ){ | |
| 203 | -			foreach ( $donor as $key => $value ) { | |
| 202 | +		if (is_null($donor_vars)) { | |
| 203 | +			foreach ($donor as $key => $value) { | |
| 204 | 204 | |
| 205 | -				switch ( $key ) { | |
| 205 | +				switch ($key) { | |
| 206 | 206 | |
| 207 | 207 | case 'notes': | 
| 208 | 208 | $this->$key = $this->get_notes(); | 
| @@ -216,20 +216,20 @@ discard block | ||
| 216 | 216 | } | 
| 217 | 217 | |
| 218 | 218 | // Get donor's all email including primary email. | 
| 219 | - $this->emails = (array) $this->get_meta( 'additional_email', false ); | |
| 220 | - $this->emails = array( 'primary' => $this->email ) + $this->emails; | |
| 219 | +			$this->emails = (array) $this->get_meta('additional_email', false); | |
| 220 | +			$this->emails = array('primary' => $this->email) + $this->emails; | |
| 221 | 221 | |
| 222 | 222 | $this->setup_address(); | 
| 223 | 223 | |
| 224 | - Give_Cache::set_group( $donor->id, get_object_vars( $this ), 'give-donors' ); | |
| 225 | -		} else{ | |
| 226 | -			foreach ( $donor_vars as $donor_var => $value ) { | |
| 224 | + Give_Cache::set_group($donor->id, get_object_vars($this), 'give-donors'); | |
| 225 | +		} else { | |
| 226 | +			foreach ($donor_vars as $donor_var => $value) { | |
| 227 | 227 | $this->$donor_var = $value; | 
| 228 | 228 | } | 
| 229 | 229 | } | 
| 230 | 230 | |
| 231 | 231 | // Donor ID and email are the only things that are necessary, make sure they exist. | 
| 232 | -		if ( ! empty( $this->id ) && ! empty( $this->email ) ) { | |
| 232 | +		if ( ! empty($this->id) && ! empty($this->email)) { | |
| 233 | 233 | return true; | 
| 234 | 234 | } | 
| 235 | 235 | |
| @@ -262,18 +262,18 @@ discard block | ||
| 262 | 262 | ARRAY_N | 
| 263 | 263 | ); | 
| 264 | 264 | |
| 265 | -		if ( empty( $addresses ) ) { | |
| 265 | +		if (empty($addresses)) { | |
| 266 | 266 | return $this->address; | 
| 267 | 267 | } | 
| 268 | 268 | |
| 269 | -		foreach ( $addresses as $address ) { | |
| 270 | - $address[0] = str_replace( '_give_donor_address_', '', $address[0] ); | |
| 271 | - $address[0] = explode( '_', $address[0] ); | |
| 269 | +		foreach ($addresses as $address) { | |
| 270 | +			$address[0] = str_replace('_give_donor_address_', '', $address[0]); | |
| 271 | +			$address[0] = explode('_', $address[0]); | |
| 272 | 272 | |
| 273 | -			if ( 3 === count( $address[0] ) ) { | |
| 274 | - $this->address[ $address[0][0] ][ $address[0][2] ][ $address[0][1] ] = $address[1]; | |
| 273 | +			if (3 === count($address[0])) { | |
| 274 | + $this->address[$address[0][0]][$address[0][2]][$address[0][1]] = $address[1]; | |
| 275 | 275 |  			} else { | 
| 276 | - $this->address[ $address[0][0] ][ $address[0][1] ] = $address[1]; | |
| 276 | + $this->address[$address[0][0]][$address[0][1]] = $address[1]; | |
| 277 | 277 | } | 
| 278 | 278 | } | 
| 279 | 279 | } | 
| @@ -289,7 +289,7 @@ discard block | ||
| 289 | 289 | * | 
| 290 | 290 | * @return array The donor's address, if any | 
| 291 | 291 | */ | 
| 292 | -	public function get_donor_address( $args = array() ) { | |
| 292 | +	public function get_donor_address($args = array()) { | |
| 293 | 293 | $args = wp_parse_args( | 
| 294 | 294 | $args, | 
| 295 | 295 | array( | 
| @@ -307,24 +307,24 @@ discard block | ||
| 307 | 307 | ); | 
| 308 | 308 | |
| 309 | 309 | // Backward compatibility. | 
| 310 | -		if ( ! give_has_upgrade_completed( 'v20_upgrades_user_address' ) ) { | |
| 310 | +		if ( ! give_has_upgrade_completed('v20_upgrades_user_address')) { | |
| 311 | 311 | |
| 312 | 312 | // Backward compatibility for user id param. | 
| 313 | - return wp_parse_args( (array) get_user_meta( $this->user_id, '_give_user_address', true ), $default_address ); | |
| 313 | + return wp_parse_args((array) get_user_meta($this->user_id, '_give_user_address', true), $default_address); | |
| 314 | 314 | |
| 315 | 315 | } | 
| 316 | 316 | |
| 317 | -		if ( ! $this->id || empty( $this->address ) || ! array_key_exists( $args['address_type'], $this->address ) ) { | |
| 317 | +		if ( ! $this->id || empty($this->address) || ! array_key_exists($args['address_type'], $this->address)) { | |
| 318 | 318 | return $default_address; | 
| 319 | 319 | } | 
| 320 | 320 | |
| 321 | -		switch ( true ) { | |
| 322 | - case is_string( end( $this->address[ $args['address_type'] ] ) ): | |
| 323 | - $address = wp_parse_args( $this->address[ $args['address_type'] ], $default_address ); | |
| 321 | +		switch (true) { | |
| 322 | + case is_string(end($this->address[$args['address_type']])): | |
| 323 | + $address = wp_parse_args($this->address[$args['address_type']], $default_address); | |
| 324 | 324 | break; | 
| 325 | 325 | |
| 326 | - case is_array( end( $this->address[ $args['address_type'] ] ) ): | |
| 327 | - $address = wp_parse_args( array_shift( $this->address[ $args['address_type'] ] ), $default_address ); | |
| 326 | + case is_array(end($this->address[$args['address_type']])): | |
| 327 | + $address = wp_parse_args(array_shift($this->address[$args['address_type']]), $default_address); | |
| 328 | 328 | break; | 
| 329 | 329 | } | 
| 330 | 330 | |
| @@ -340,16 +340,16 @@ discard block | ||
| 340 | 340 | * | 
| 341 | 341 | * @return mixed|\WP_Error | 
| 342 | 342 | */ | 
| 343 | -	public function __get( $key ) { | |
| 343 | +	public function __get($key) { | |
| 344 | 344 | |
| 345 | -		if ( method_exists( $this, 'get_' . $key ) ) { | |
| 345 | +		if (method_exists($this, 'get_'.$key)) { | |
| 346 | 346 | |
| 347 | - return call_user_func( array( $this, 'get_' . $key ) ); | |
| 347 | + return call_user_func(array($this, 'get_'.$key)); | |
| 348 | 348 | |
| 349 | 349 |  		} else { | 
| 350 | 350 | |
| 351 | 351 | /* translators: %s: property key */ | 
| 352 | - return new WP_Error( 'give-donor-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); | |
| 352 | +			return new WP_Error('give-donor-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key)); | |
| 353 | 353 | |
| 354 | 354 | } | 
| 355 | 355 | |
| @@ -365,9 +365,9 @@ discard block | ||
| 365 | 365 | * | 
| 366 | 366 | * @return bool|int False if not a valid creation, donor ID if user is found or valid creation. | 
| 367 | 367 | */ | 
| 368 | -	public function create( $data = array() ) { | |
| 368 | +	public function create($data = array()) { | |
| 369 | 369 | |
| 370 | -		if ( $this->id != 0 || empty( $data ) ) { | |
| 370 | +		if ($this->id != 0 || empty($data)) { | |
| 371 | 371 | return false; | 
| 372 | 372 | } | 
| 373 | 373 | |
| @@ -375,15 +375,15 @@ discard block | ||
| 375 | 375 | 'payment_ids' => '', | 
| 376 | 376 | ); | 
| 377 | 377 | |
| 378 | - $args = wp_parse_args( $data, $defaults ); | |
| 379 | - $args = $this->sanitize_columns( $args ); | |
| 378 | + $args = wp_parse_args($data, $defaults); | |
| 379 | + $args = $this->sanitize_columns($args); | |
| 380 | 380 | |
| 381 | -		if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) { | |
| 381 | +		if (empty($args['email']) || ! is_email($args['email'])) { | |
| 382 | 382 | return false; | 
| 383 | 383 | } | 
| 384 | 384 | |
| 385 | -		if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { | |
| 386 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); | |
| 385 | +		if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { | |
| 386 | +			$args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); | |
| 387 | 387 | } | 
| 388 | 388 | |
| 389 | 389 | /** | 
| @@ -393,18 +393,18 @@ discard block | ||
| 393 | 393 | * | 
| 394 | 394 | * @param array $args Donor attributes. | 
| 395 | 395 | */ | 
| 396 | - do_action( 'give_donor_pre_create', $args ); | |
| 396 | +		do_action('give_donor_pre_create', $args); | |
| 397 | 397 | |
| 398 | 398 | $created = false; | 
| 399 | 399 | |
| 400 | 400 | // The DB class 'add' implies an update if the donor being asked to be created already exists | 
| 401 | -		if ( $this->db->add( $data ) ) { | |
| 401 | +		if ($this->db->add($data)) { | |
| 402 | 402 | |
| 403 | 403 | // We've successfully added/updated the donor, reset the class vars with the new data | 
| 404 | - $donor = $this->db->get_donor_by( 'email', $args['email'] ); | |
| 404 | +			$donor = $this->db->get_donor_by('email', $args['email']); | |
| 405 | 405 | |
| 406 | 406 | // Setup the donor data with the values from DB | 
| 407 | - $this->setup_donor( $donor ); | |
| 407 | + $this->setup_donor($donor); | |
| 408 | 408 | |
| 409 | 409 | $created = $this->id; | 
| 410 | 410 | } | 
| @@ -417,7 +417,7 @@ discard block | ||
| 417 | 417 | * @param bool|int $created False if not a valid creation, donor ID if user is found or valid creation. | 
| 418 | 418 | * @param array $args Customer attributes. | 
| 419 | 419 | */ | 
| 420 | - do_action( 'give_donor_post_create', $created, $args ); | |
| 420 | +		do_action('give_donor_post_create', $created, $args); | |
| 421 | 421 | |
| 422 | 422 | return $created; | 
| 423 | 423 | |
| @@ -433,13 +433,13 @@ discard block | ||
| 433 | 433 | * | 
| 434 | 434 | * @return bool If the update was successful or not. | 
| 435 | 435 | */ | 
| 436 | -	public function update( $data = array() ) { | |
| 436 | +	public function update($data = array()) { | |
| 437 | 437 | |
| 438 | -		if ( empty( $data ) ) { | |
| 438 | +		if (empty($data)) { | |
| 439 | 439 | return false; | 
| 440 | 440 | } | 
| 441 | 441 | |
| 442 | - $data = $this->sanitize_columns( $data ); | |
| 442 | + $data = $this->sanitize_columns($data); | |
| 443 | 443 | |
| 444 | 444 | /** | 
| 445 | 445 | * Fires before updating donors. | 
| @@ -449,15 +449,15 @@ discard block | ||
| 449 | 449 | * @param int $donor_id Donor id. | 
| 450 | 450 | * @param array $data Donor attributes. | 
| 451 | 451 | */ | 
| 452 | - do_action( 'give_donor_pre_update', $this->id, $data ); | |
| 452 | +		do_action('give_donor_pre_update', $this->id, $data); | |
| 453 | 453 | |
| 454 | 454 | $updated = false; | 
| 455 | 455 | |
| 456 | -		if ( $this->db->update( $this->id, $data ) ) { | |
| 456 | +		if ($this->db->update($this->id, $data)) { | |
| 457 | 457 | |
| 458 | - $donor = $this->db->get_donor_by( 'id', $this->id ); | |
| 458 | +			$donor = $this->db->get_donor_by('id', $this->id); | |
| 459 | 459 | |
| 460 | - $this->setup_donor( $donor ); | |
| 460 | + $this->setup_donor($donor); | |
| 461 | 461 | |
| 462 | 462 | $updated = true; | 
| 463 | 463 | } | 
| @@ -471,7 +471,7 @@ discard block | ||
| 471 | 471 | * @param int $donor_id Donor id. | 
| 472 | 472 | * @param array $data Donor attributes. | 
| 473 | 473 | */ | 
| 474 | - do_action( 'give_donor_post_update', $updated, $this->id, $data ); | |
| 474 | +		do_action('give_donor_post_update', $updated, $this->id, $data); | |
| 475 | 475 | |
| 476 | 476 | return $updated; | 
| 477 | 477 | } | 
| @@ -489,27 +489,27 @@ discard block | ||
| 489 | 489 | * | 
| 490 | 490 | * @return bool If the attachment was successfully. | 
| 491 | 491 | */ | 
| 492 | -	public function attach_payment( $payment_id = 0, $update_stats = true ) { | |
| 492 | +	public function attach_payment($payment_id = 0, $update_stats = true) { | |
| 493 | 493 | |
| 494 | -		if ( empty( $payment_id ) ) { | |
| 494 | +		if (empty($payment_id)) { | |
| 495 | 495 | return false; | 
| 496 | 496 | } | 
| 497 | 497 | |
| 498 | -		if ( empty( $this->payment_ids ) ) { | |
| 498 | +		if (empty($this->payment_ids)) { | |
| 499 | 499 | |
| 500 | 500 | $new_payment_ids = $payment_id; | 
| 501 | 501 | |
| 502 | 502 |  		} else { | 
| 503 | 503 | |
| 504 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); | |
| 504 | +			$payment_ids = array_map('absint', explode(',', $this->payment_ids)); | |
| 505 | 505 | |
| 506 | -			if ( in_array( $payment_id, $payment_ids ) ) { | |
| 506 | +			if (in_array($payment_id, $payment_ids)) { | |
| 507 | 507 | $update_stats = false; | 
| 508 | 508 | } | 
| 509 | 509 | |
| 510 | 510 | $payment_ids[] = $payment_id; | 
| 511 | 511 | |
| 512 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); | |
| 512 | +			$new_payment_ids = implode(',', array_unique(array_values($payment_ids))); | |
| 513 | 513 | |
| 514 | 514 | } | 
| 515 | 515 | |
| @@ -521,20 +521,20 @@ discard block | ||
| 521 | 521 | * @param int $payment_id Payment id. | 
| 522 | 522 | * @param int $donor_id Customer id. | 
| 523 | 523 | */ | 
| 524 | - do_action( 'give_donor_pre_attach_payment', $payment_id, $this->id ); | |
| 524 | +		do_action('give_donor_pre_attach_payment', $payment_id, $this->id); | |
| 525 | 525 | |
| 526 | - $payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) ); | |
| 526 | +		$payment_added = $this->update(array('payment_ids' => $new_payment_ids)); | |
| 527 | 527 | |
| 528 | -		if ( $payment_added ) { | |
| 528 | +		if ($payment_added) { | |
| 529 | 529 | |
| 530 | 530 | $this->payment_ids = $new_payment_ids; | 
| 531 | 531 | |
| 532 | 532 | // We added this payment successfully, increment the stats | 
| 533 | -			if ( $update_stats ) { | |
| 534 | - $payment_amount = give_donation_amount( $payment_id, array( 'type' => 'stats' ) ); | |
| 533 | +			if ($update_stats) { | |
| 534 | +				$payment_amount = give_donation_amount($payment_id, array('type' => 'stats')); | |
| 535 | 535 | |
| 536 | -				if ( ! empty( $payment_amount ) ) { | |
| 537 | - $this->increase_value( $payment_amount ); | |
| 536 | +				if ( ! empty($payment_amount)) { | |
| 537 | + $this->increase_value($payment_amount); | |
| 538 | 538 | } | 
| 539 | 539 | |
| 540 | 540 | $this->increase_purchase_count(); | 
| @@ -550,7 +550,7 @@ discard block | ||
| 550 | 550 | * @param int $payment_id Payment id. | 
| 551 | 551 | * @param int $donor_id Donor id. | 
| 552 | 552 | */ | 
| 553 | - do_action( 'give_donor_post_attach_payment', $payment_added, $payment_id, $this->id ); | |
| 553 | +		do_action('give_donor_post_attach_payment', $payment_added, $payment_id, $this->id); | |
| 554 | 554 | |
| 555 | 555 | return $payment_added; | 
| 556 | 556 | } | 
| @@ -568,33 +568,33 @@ discard block | ||
| 568 | 568 | * | 
| 569 | 569 | * @return boolean If the removal was successful. | 
| 570 | 570 | */ | 
| 571 | -	public function remove_payment( $payment_id = 0, $update_stats = true ) { | |
| 571 | +	public function remove_payment($payment_id = 0, $update_stats = true) { | |
| 572 | 572 | |
| 573 | -		if ( empty( $payment_id ) ) { | |
| 573 | +		if (empty($payment_id)) { | |
| 574 | 574 | return false; | 
| 575 | 575 | } | 
| 576 | 576 | |
| 577 | - $payment = new Give_Payment( $payment_id ); | |
| 577 | + $payment = new Give_Payment($payment_id); | |
| 578 | 578 | |
| 579 | -		if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) { | |
| 579 | +		if ('publish' !== $payment->status && 'revoked' !== $payment->status) { | |
| 580 | 580 | $update_stats = false; | 
| 581 | 581 | } | 
| 582 | 582 | |
| 583 | 583 | $new_payment_ids = ''; | 
| 584 | 584 | |
| 585 | -		if ( ! empty( $this->payment_ids ) ) { | |
| 585 | +		if ( ! empty($this->payment_ids)) { | |
| 586 | 586 | |
| 587 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); | |
| 587 | +			$payment_ids = array_map('absint', explode(',', $this->payment_ids)); | |
| 588 | 588 | |
| 589 | - $pos = array_search( $payment_id, $payment_ids ); | |
| 590 | -			if ( false === $pos ) { | |
| 589 | + $pos = array_search($payment_id, $payment_ids); | |
| 590 | +			if (false === $pos) { | |
| 591 | 591 | return false; | 
| 592 | 592 | } | 
| 593 | 593 | |
| 594 | - unset( $payment_ids[ $pos ] ); | |
| 595 | - $payment_ids = array_filter( $payment_ids ); | |
| 594 | + unset($payment_ids[$pos]); | |
| 595 | + $payment_ids = array_filter($payment_ids); | |
| 596 | 596 | |
| 597 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); | |
| 597 | +			$new_payment_ids = implode(',', array_unique(array_values($payment_ids))); | |
| 598 | 598 | |
| 599 | 599 | } | 
| 600 | 600 | |
| @@ -606,20 +606,20 @@ discard block | ||
| 606 | 606 | * @param int $payment_id Payment id. | 
| 607 | 607 | * @param int $donor_id Customer id. | 
| 608 | 608 | */ | 
| 609 | - do_action( 'give_donor_pre_remove_payment', $payment_id, $this->id ); | |
| 609 | +		do_action('give_donor_pre_remove_payment', $payment_id, $this->id); | |
| 610 | 610 | |
| 611 | - $payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) ); | |
| 611 | +		$payment_removed = $this->update(array('payment_ids' => $new_payment_ids)); | |
| 612 | 612 | |
| 613 | -		if ( $payment_removed ) { | |
| 613 | +		if ($payment_removed) { | |
| 614 | 614 | |
| 615 | 615 | $this->payment_ids = $new_payment_ids; | 
| 616 | 616 | |
| 617 | -			if ( $update_stats ) { | |
| 617 | +			if ($update_stats) { | |
| 618 | 618 | // We removed this payment successfully, decrement the stats | 
| 619 | - $payment_amount = give_donation_amount( $payment_id ); | |
| 619 | + $payment_amount = give_donation_amount($payment_id); | |
| 620 | 620 | |
| 621 | -				if ( ! empty( $payment_amount ) ) { | |
| 622 | - $this->decrease_value( $payment_amount ); | |
| 621 | +				if ( ! empty($payment_amount)) { | |
| 622 | + $this->decrease_value($payment_amount); | |
| 623 | 623 | } | 
| 624 | 624 | |
| 625 | 625 | $this->decrease_donation_count(); | 
| @@ -635,7 +635,7 @@ discard block | ||
| 635 | 635 | * @param int $payment_id Payment id. | 
| 636 | 636 | * @param int $donor_id Donor id. | 
| 637 | 637 | */ | 
| 638 | - do_action( 'give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id ); | |
| 638 | +		do_action('give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id); | |
| 639 | 639 | |
| 640 | 640 | return $payment_removed; | 
| 641 | 641 | |
| @@ -651,10 +651,10 @@ discard block | ||
| 651 | 651 | * | 
| 652 | 652 | * @return int The donation count. | 
| 653 | 653 | */ | 
| 654 | -	public function increase_purchase_count( $count = 1 ) { | |
| 654 | +	public function increase_purchase_count($count = 1) { | |
| 655 | 655 | |
| 656 | 656 | // Make sure it's numeric and not negative. | 
| 657 | -		if ( ! is_numeric( $count ) || $count != absint( $count ) ) { | |
| 657 | +		if ( ! is_numeric($count) || $count != absint($count)) { | |
| 658 | 658 | return false; | 
| 659 | 659 | } | 
| 660 | 660 | |
| @@ -668,9 +668,9 @@ discard block | ||
| 668 | 668 | * @param int $count The number to increase by. | 
| 669 | 669 | * @param int $donor_id Donor id. | 
| 670 | 670 | */ | 
| 671 | - do_action( 'give_donor_pre_increase_donation_count', $count, $this->id ); | |
| 671 | +		do_action('give_donor_pre_increase_donation_count', $count, $this->id); | |
| 672 | 672 | |
| 673 | -		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { | |
| 673 | +		if ($this->update(array('purchase_count' => $new_total))) { | |
| 674 | 674 | $this->purchase_count = $new_total; | 
| 675 | 675 | } | 
| 676 | 676 | |
| @@ -683,7 +683,7 @@ discard block | ||
| 683 | 683 | * @param int $count The number increased by. | 
| 684 | 684 | * @param int $donor_id Donor id. | 
| 685 | 685 | */ | 
| 686 | - do_action( 'give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id ); | |
| 686 | +		do_action('give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id); | |
| 687 | 687 | |
| 688 | 688 | return $this->purchase_count; | 
| 689 | 689 | } | 
| @@ -698,16 +698,16 @@ discard block | ||
| 698 | 698 | * | 
| 699 | 699 | * @return mixed If successful, the new count, otherwise false. | 
| 700 | 700 | */ | 
| 701 | -	public function decrease_donation_count( $count = 1 ) { | |
| 701 | +	public function decrease_donation_count($count = 1) { | |
| 702 | 702 | |
| 703 | 703 | // Make sure it's numeric and not negative | 
| 704 | -		if ( ! is_numeric( $count ) || $count != absint( $count ) ) { | |
| 704 | +		if ( ! is_numeric($count) || $count != absint($count)) { | |
| 705 | 705 | return false; | 
| 706 | 706 | } | 
| 707 | 707 | |
| 708 | 708 | $new_total = (int) $this->purchase_count - (int) $count; | 
| 709 | 709 | |
| 710 | -		if ( $new_total < 0 ) { | |
| 710 | +		if ($new_total < 0) { | |
| 711 | 711 | $new_total = 0; | 
| 712 | 712 | } | 
| 713 | 713 | |
| @@ -719,9 +719,9 @@ discard block | ||
| 719 | 719 | * @param int $count The number to decrease by. | 
| 720 | 720 | * @param int $donor_id Customer id. | 
| 721 | 721 | */ | 
| 722 | - do_action( 'give_donor_pre_decrease_donation_count', $count, $this->id ); | |
| 722 | +		do_action('give_donor_pre_decrease_donation_count', $count, $this->id); | |
| 723 | 723 | |
| 724 | -		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { | |
| 724 | +		if ($this->update(array('purchase_count' => $new_total))) { | |
| 725 | 725 | $this->purchase_count = $new_total; | 
| 726 | 726 | } | 
| 727 | 727 | |
| @@ -734,7 +734,7 @@ discard block | ||
| 734 | 734 | * @param int $count The number decreased by. | 
| 735 | 735 | * @param int $donor_id Donor id. | 
| 736 | 736 | */ | 
| 737 | - do_action( 'give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id ); | |
| 737 | +		do_action('give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id); | |
| 738 | 738 | |
| 739 | 739 | return $this->purchase_count; | 
| 740 | 740 | } | 
| @@ -749,9 +749,9 @@ discard block | ||
| 749 | 749 | * | 
| 750 | 750 | * @return mixed If successful, the new value, otherwise false. | 
| 751 | 751 | */ | 
| 752 | -	public function increase_value( $value = 0.00 ) { | |
| 752 | +	public function increase_value($value = 0.00) { | |
| 753 | 753 | |
| 754 | - $new_value = floatval( $this->purchase_value ) + $value; | |
| 754 | + $new_value = floatval($this->purchase_value) + $value; | |
| 755 | 755 | |
| 756 | 756 | /** | 
| 757 | 757 | * Fires before increasing donor lifetime value. | 
| @@ -761,9 +761,9 @@ discard block | ||
| 761 | 761 | * @param float $value The value to increase by. | 
| 762 | 762 | * @param int $donor_id Customer id. | 
| 763 | 763 | */ | 
| 764 | - do_action( 'give_donor_pre_increase_value', $value, $this->id ); | |
| 764 | +		do_action('give_donor_pre_increase_value', $value, $this->id); | |
| 765 | 765 | |
| 766 | -		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { | |
| 766 | +		if ($this->update(array('purchase_value' => $new_value))) { | |
| 767 | 767 | $this->purchase_value = $new_value; | 
| 768 | 768 | } | 
| 769 | 769 | |
| @@ -776,7 +776,7 @@ discard block | ||
| 776 | 776 | * @param float $value The value increased by. | 
| 777 | 777 | * @param int $donor_id Donor id. | 
| 778 | 778 | */ | 
| 779 | - do_action( 'give_donor_post_increase_value', $this->purchase_value, $value, $this->id ); | |
| 779 | +		do_action('give_donor_post_increase_value', $this->purchase_value, $value, $this->id); | |
| 780 | 780 | |
| 781 | 781 | return $this->purchase_value; | 
| 782 | 782 | } | 
| @@ -791,11 +791,11 @@ discard block | ||
| 791 | 791 | * | 
| 792 | 792 | * @return mixed If successful, the new value, otherwise false. | 
| 793 | 793 | */ | 
| 794 | -	public function decrease_value( $value = 0.00 ) { | |
| 794 | +	public function decrease_value($value = 0.00) { | |
| 795 | 795 | |
| 796 | - $new_value = floatval( $this->purchase_value ) - $value; | |
| 796 | + $new_value = floatval($this->purchase_value) - $value; | |
| 797 | 797 | |
| 798 | -		if ( $new_value < 0 ) { | |
| 798 | +		if ($new_value < 0) { | |
| 799 | 799 | $new_value = 0.00; | 
| 800 | 800 | } | 
| 801 | 801 | |
| @@ -807,9 +807,9 @@ discard block | ||
| 807 | 807 | * @param float $value The value to decrease by. | 
| 808 | 808 | * @param int $donor_id Donor id. | 
| 809 | 809 | */ | 
| 810 | - do_action( 'give_donor_pre_decrease_value', $value, $this->id ); | |
| 810 | +		do_action('give_donor_pre_decrease_value', $value, $this->id); | |
| 811 | 811 | |
| 812 | -		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { | |
| 812 | +		if ($this->update(array('purchase_value' => $new_value))) { | |
| 813 | 813 | $this->purchase_value = $new_value; | 
| 814 | 814 | } | 
| 815 | 815 | |
| @@ -822,7 +822,7 @@ discard block | ||
| 822 | 822 | * @param float $value The value decreased by. | 
| 823 | 823 | * @param int $donor_id Donor id. | 
| 824 | 824 | */ | 
| 825 | - do_action( 'give_donor_post_decrease_value', $this->purchase_value, $value, $this->id ); | |
| 825 | +		do_action('give_donor_post_decrease_value', $this->purchase_value, $value, $this->id); | |
| 826 | 826 | |
| 827 | 827 | return $this->purchase_value; | 
| 828 | 828 | } | 
| @@ -841,7 +841,7 @@ discard block | ||
| 841 | 841 | * | 
| 842 | 842 | * @return mixed If successful, the new donation stat value, otherwise false. | 
| 843 | 843 | */ | 
| 844 | -	public function update_donation_value( $curr_amount, $new_amount ) { | |
| 844 | +	public function update_donation_value($curr_amount, $new_amount) { | |
| 845 | 845 | /** | 
| 846 | 846 | * Payment total difference value can be: | 
| 847 | 847 | * zero (in case amount not change) | 
| @@ -851,15 +851,15 @@ discard block | ||
| 851 | 851 | $payment_total_diff = $new_amount - $curr_amount; | 
| 852 | 852 | |
| 853 | 853 | // We do not need to update donation stat if donation did not change. | 
| 854 | -		if ( ! $payment_total_diff ) { | |
| 854 | +		if ( ! $payment_total_diff) { | |
| 855 | 855 | return false; | 
| 856 | 856 | } | 
| 857 | 857 | |
| 858 | -		if ( $payment_total_diff > 0 ) { | |
| 859 | - $this->increase_value( $payment_total_diff ); | |
| 858 | +		if ($payment_total_diff > 0) { | |
| 859 | + $this->increase_value($payment_total_diff); | |
| 860 | 860 |  		} else { | 
| 861 | 861 | // Pass payment total difference as +ve value to decrease amount from user lifetime stat. | 
| 862 | - $this->decrease_value( - $payment_total_diff ); | |
| 862 | + $this->decrease_value( -$payment_total_diff ); | |
| 863 | 863 | } | 
| 864 | 864 | |
| 865 | 865 | return $this->purchase_value; | 
| @@ -876,15 +876,15 @@ discard block | ||
| 876 | 876 | * | 
| 877 | 877 | * @return array The notes requested. | 
| 878 | 878 | */ | 
| 879 | -	public function get_notes( $length = 20, $paged = 1 ) { | |
| 879 | +	public function get_notes($length = 20, $paged = 1) { | |
| 880 | 880 | |
| 881 | - $length = is_numeric( $length ) ? $length : 20; | |
| 882 | - $offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0; | |
| 881 | + $length = is_numeric($length) ? $length : 20; | |
| 882 | + $offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0; | |
| 883 | 883 | |
| 884 | 884 | $all_notes = $this->get_raw_notes(); | 
| 885 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); | |
| 885 | +		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); | |
| 886 | 886 | |
| 887 | - $desired_notes = array_slice( $notes_array, $offset, $length ); | |
| 887 | + $desired_notes = array_slice($notes_array, $offset, $length); | |
| 888 | 888 | |
| 889 | 889 | return $desired_notes; | 
| 890 | 890 | |
| @@ -901,9 +901,9 @@ discard block | ||
| 901 | 901 |  	public function get_notes_count() { | 
| 902 | 902 | |
| 903 | 903 | $all_notes = $this->get_raw_notes(); | 
| 904 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); | |
| 904 | +		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); | |
| 905 | 905 | |
| 906 | - return count( $notes_array ); | |
| 906 | + return count($notes_array); | |
| 907 | 907 | |
| 908 | 908 | } | 
| 909 | 909 | |
| @@ -916,7 +916,7 @@ discard block | ||
| 916 | 916 | * | 
| 917 | 917 | * @return string|float | 
| 918 | 918 | */ | 
| 919 | -	public function get_total_donation_amount( $args = array() ) { | |
| 919 | +	public function get_total_donation_amount($args = array()) { | |
| 920 | 920 | |
| 921 | 921 | /** | 
| 922 | 922 | * Filter total donation amount. | 
| @@ -927,7 +927,7 @@ discard block | ||
| 927 | 927 | * @param integer $donor_id Donor ID. | 
| 928 | 928 | * @param array $args Pass additional data. | 
| 929 | 929 | */ | 
| 930 | - return apply_filters( 'give_get_total_donation_amount', $this->purchase_value, $this->id, $args ); | |
| 930 | +		return apply_filters('give_get_total_donation_amount', $this->purchase_value, $this->id, $args); | |
| 931 | 931 | } | 
| 932 | 932 | |
| 933 | 933 | /** | 
| @@ -940,22 +940,22 @@ discard block | ||
| 940 | 940 | * | 
| 941 | 941 | * @return string|boolean The new note if added successfully, false otherwise. | 
| 942 | 942 | */ | 
| 943 | -	public function add_note( $note = '' ) { | |
| 943 | +	public function add_note($note = '') { | |
| 944 | 944 | |
| 945 | - $note = trim( $note ); | |
| 946 | -		if ( empty( $note ) ) { | |
| 945 | + $note = trim($note); | |
| 946 | +		if (empty($note)) { | |
| 947 | 947 | return false; | 
| 948 | 948 | } | 
| 949 | 949 | |
| 950 | 950 | $notes = $this->get_raw_notes(); | 
| 951 | 951 | |
| 952 | -		if ( empty( $notes ) ) { | |
| 952 | +		if (empty($notes)) { | |
| 953 | 953 | $notes = ''; | 
| 954 | 954 | } | 
| 955 | 955 | |
| 956 | - $note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note; | |
| 957 | - $new_note = apply_filters( 'give_customer_add_note_string', $note_string ); | |
| 958 | - $notes .= "\n\n" . $new_note; | |
| 956 | +		$note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note; | |
| 957 | +		$new_note    = apply_filters('give_customer_add_note_string', $note_string); | |
| 958 | + $notes .= "\n\n".$new_note; | |
| 959 | 959 | |
| 960 | 960 | /** | 
| 961 | 961 | * Fires before donor note is added. | 
| @@ -965,11 +965,11 @@ discard block | ||
| 965 | 965 | * @param string $new_note New note to add. | 
| 966 | 966 | * @param int $donor_id Donor id. | 
| 967 | 967 | */ | 
| 968 | - do_action( 'give_donor_pre_add_note', $new_note, $this->id ); | |
| 968 | +		do_action('give_donor_pre_add_note', $new_note, $this->id); | |
| 969 | 969 | |
| 970 | - $updated = $this->update( array( 'notes' => $notes ) ); | |
| 970 | +		$updated = $this->update(array('notes' => $notes)); | |
| 971 | 971 | |
| 972 | -		if ( $updated ) { | |
| 972 | +		if ($updated) { | |
| 973 | 973 | $this->notes = $this->get_notes(); | 
| 974 | 974 | } | 
| 975 | 975 | |
| @@ -982,7 +982,7 @@ discard block | ||
| 982 | 982 | * @param string $new_note New note added. | 
| 983 | 983 | * @param int $donor_id Donor id. | 
| 984 | 984 | */ | 
| 985 | - do_action( 'give_donor_post_add_note', $this->notes, $new_note, $this->id ); | |
| 985 | +		do_action('give_donor_post_add_note', $this->notes, $new_note, $this->id); | |
| 986 | 986 | |
| 987 | 987 | // Return the formatted note, so we can test, as well as update any displays | 
| 988 | 988 | return $new_note; | 
| @@ -999,7 +999,7 @@ discard block | ||
| 999 | 999 | */ | 
| 1000 | 1000 |  	private function get_raw_notes() { | 
| 1001 | 1001 | |
| 1002 | - $all_notes = $this->db->get_column( 'notes', $this->id ); | |
| 1002 | +		$all_notes = $this->db->get_column('notes', $this->id); | |
| 1003 | 1003 | |
| 1004 | 1004 | return $all_notes; | 
| 1005 | 1005 | |
| @@ -1016,8 +1016,8 @@ discard block | ||
| 1016 | 1016 | * | 
| 1017 | 1017 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true. | 
| 1018 | 1018 | */ | 
| 1019 | -	public function get_meta( $meta_key = '', $single = true ) { | |
| 1020 | - return Give()->donor_meta->get_meta( $this->id, $meta_key, $single ); | |
| 1019 | +	public function get_meta($meta_key = '', $single = true) { | |
| 1020 | + return Give()->donor_meta->get_meta($this->id, $meta_key, $single); | |
| 1021 | 1021 | } | 
| 1022 | 1022 | |
| 1023 | 1023 | /** | 
| @@ -1032,8 +1032,8 @@ discard block | ||
| 1032 | 1032 | * | 
| 1033 | 1033 | * @return bool False for failure. True for success. | 
| 1034 | 1034 | */ | 
| 1035 | -	public function add_meta( $meta_key = '', $meta_value, $unique = false ) { | |
| 1036 | - return Give()->donor_meta->add_meta( $this->id, $meta_key, $meta_value, $unique ); | |
| 1035 | +	public function add_meta($meta_key = '', $meta_value, $unique = false) { | |
| 1036 | + return Give()->donor_meta->add_meta($this->id, $meta_key, $meta_value, $unique); | |
| 1037 | 1037 | } | 
| 1038 | 1038 | |
| 1039 | 1039 | /** | 
| @@ -1048,8 +1048,8 @@ discard block | ||
| 1048 | 1048 | * | 
| 1049 | 1049 | * @return bool False on failure, true if success. | 
| 1050 | 1050 | */ | 
| 1051 | -	public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) { | |
| 1052 | - return Give()->donor_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value ); | |
| 1051 | +	public function update_meta($meta_key = '', $meta_value, $prev_value = '') { | |
| 1052 | + return Give()->donor_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value); | |
| 1053 | 1053 | } | 
| 1054 | 1054 | |
| 1055 | 1055 | /** | 
| @@ -1063,8 +1063,8 @@ discard block | ||
| 1063 | 1063 | * | 
| 1064 | 1064 | * @return bool False for failure. True for success. | 
| 1065 | 1065 | */ | 
| 1066 | -	public function delete_meta( $meta_key = '', $meta_value = '' ) { | |
| 1067 | - return Give()->donor_meta->delete_meta( $this->id, $meta_key, $meta_value ); | |
| 1066 | +	public function delete_meta($meta_key = '', $meta_value = '') { | |
| 1067 | + return Give()->donor_meta->delete_meta($this->id, $meta_key, $meta_value); | |
| 1068 | 1068 | } | 
| 1069 | 1069 | |
| 1070 | 1070 | /** | 
| @@ -1077,51 +1077,51 @@ discard block | ||
| 1077 | 1077 | * | 
| 1078 | 1078 | * @return array The sanitized data, based off column defaults. | 
| 1079 | 1079 | */ | 
| 1080 | -	private function sanitize_columns( $data ) { | |
| 1080 | +	private function sanitize_columns($data) { | |
| 1081 | 1081 | |
| 1082 | 1082 | $columns = $this->db->get_columns(); | 
| 1083 | 1083 | $default_values = $this->db->get_column_defaults(); | 
| 1084 | 1084 | |
| 1085 | -		foreach ( $columns as $key => $type ) { | |
| 1085 | +		foreach ($columns as $key => $type) { | |
| 1086 | 1086 | |
| 1087 | 1087 | // Only sanitize data that we were provided | 
| 1088 | -			if ( ! array_key_exists( $key, $data ) ) { | |
| 1088 | +			if ( ! array_key_exists($key, $data)) { | |
| 1089 | 1089 | continue; | 
| 1090 | 1090 | } | 
| 1091 | 1091 | |
| 1092 | -			switch ( $type ) { | |
| 1092 | +			switch ($type) { | |
| 1093 | 1093 | |
| 1094 | 1094 | case '%s': | 
| 1095 | -					if ( 'email' == $key ) { | |
| 1096 | - $data[ $key ] = sanitize_email( $data[ $key ] ); | |
| 1097 | -					} elseif ( 'notes' == $key ) { | |
| 1098 | - $data[ $key ] = strip_tags( $data[ $key ] ); | |
| 1095 | +					if ('email' == $key) { | |
| 1096 | + $data[$key] = sanitize_email($data[$key]); | |
| 1097 | +					} elseif ('notes' == $key) { | |
| 1098 | + $data[$key] = strip_tags($data[$key]); | |
| 1099 | 1099 |  					} else { | 
| 1100 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); | |
| 1100 | + $data[$key] = sanitize_text_field($data[$key]); | |
| 1101 | 1101 | } | 
| 1102 | 1102 | break; | 
| 1103 | 1103 | |
| 1104 | 1104 | case '%d': | 
| 1105 | -					if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) { | |
| 1106 | - $data[ $key ] = $default_values[ $key ]; | |
| 1105 | +					if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) { | |
| 1106 | + $data[$key] = $default_values[$key]; | |
| 1107 | 1107 |  					} else { | 
| 1108 | - $data[ $key ] = absint( $data[ $key ] ); | |
| 1108 | + $data[$key] = absint($data[$key]); | |
| 1109 | 1109 | } | 
| 1110 | 1110 | break; | 
| 1111 | 1111 | |
| 1112 | 1112 | case '%f': | 
| 1113 | 1113 | // Convert what was given to a float | 
| 1114 | - $value = floatval( $data[ $key ] ); | |
| 1114 | + $value = floatval($data[$key]); | |
| 1115 | 1115 | |
| 1116 | -					if ( ! is_float( $value ) ) { | |
| 1117 | - $data[ $key ] = $default_values[ $key ]; | |
| 1116 | +					if ( ! is_float($value)) { | |
| 1117 | + $data[$key] = $default_values[$key]; | |
| 1118 | 1118 |  					} else { | 
| 1119 | - $data[ $key ] = $value; | |
| 1119 | + $data[$key] = $value; | |
| 1120 | 1120 | } | 
| 1121 | 1121 | break; | 
| 1122 | 1122 | |
| 1123 | 1123 | default: | 
| 1124 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); | |
| 1124 | + $data[$key] = sanitize_text_field($data[$key]); | |
| 1125 | 1125 | break; | 
| 1126 | 1126 | |
| 1127 | 1127 | } | 
| @@ -1141,33 +1141,33 @@ discard block | ||
| 1141 | 1141 | * | 
| 1142 | 1142 | * @return bool If the email was added successfully | 
| 1143 | 1143 | */ | 
| 1144 | -	public function add_email( $email = '', $primary = false ) { | |
| 1145 | -		if ( ! is_email( $email ) ) { | |
| 1144 | +	public function add_email($email = '', $primary = false) { | |
| 1145 | +		if ( ! is_email($email)) { | |
| 1146 | 1146 | return false; | 
| 1147 | 1147 | } | 
| 1148 | - $existing = new Give_Donor( $email ); | |
| 1148 | + $existing = new Give_Donor($email); | |
| 1149 | 1149 | |
| 1150 | -		if ( $existing->id > 0 ) { | |
| 1150 | +		if ($existing->id > 0) { | |
| 1151 | 1151 | // Email address already belongs to another donor | 
| 1152 | 1152 | return false; | 
| 1153 | 1153 | } | 
| 1154 | 1154 | |
| 1155 | -		if ( email_exists( $email ) ) { | |
| 1156 | - $user = get_user_by( 'email', $email ); | |
| 1157 | -			if ( $user->ID != $this->user_id ) { | |
| 1155 | +		if (email_exists($email)) { | |
| 1156 | +			$user = get_user_by('email', $email); | |
| 1157 | +			if ($user->ID != $this->user_id) { | |
| 1158 | 1158 | return false; | 
| 1159 | 1159 | } | 
| 1160 | 1160 | } | 
| 1161 | 1161 | |
| 1162 | - do_action( 'give_donor_pre_add_email', $email, $this->id, $this ); | |
| 1162 | +		do_action('give_donor_pre_add_email', $email, $this->id, $this); | |
| 1163 | 1163 | |
| 1164 | 1164 | // Add is used to ensure duplicate emails are not added | 
| 1165 | - $ret = (bool) $this->add_meta( 'additional_email', $email ); | |
| 1165 | +		$ret = (bool) $this->add_meta('additional_email', $email); | |
| 1166 | 1166 | |
| 1167 | - do_action( 'give_donor_post_add_email', $email, $this->id, $this ); | |
| 1167 | +		do_action('give_donor_post_add_email', $email, $this->id, $this); | |
| 1168 | 1168 | |
| 1169 | -		if ( $ret && true === $primary ) { | |
| 1170 | - $this->set_primary_email( $email ); | |
| 1169 | +		if ($ret && true === $primary) { | |
| 1170 | + $this->set_primary_email($email); | |
| 1171 | 1171 | } | 
| 1172 | 1172 | |
| 1173 | 1173 | return $ret; | 
| @@ -1183,16 +1183,16 @@ discard block | ||
| 1183 | 1183 | * | 
| 1184 | 1184 | * @return bool If the email was removed successfully. | 
| 1185 | 1185 | */ | 
| 1186 | -	public function remove_email( $email = '' ) { | |
| 1187 | -		if ( ! is_email( $email ) ) { | |
| 1186 | +	public function remove_email($email = '') { | |
| 1187 | +		if ( ! is_email($email)) { | |
| 1188 | 1188 | return false; | 
| 1189 | 1189 | } | 
| 1190 | 1190 | |
| 1191 | - do_action( 'give_donor_pre_remove_email', $email, $this->id, $this ); | |
| 1191 | +		do_action('give_donor_pre_remove_email', $email, $this->id, $this); | |
| 1192 | 1192 | |
| 1193 | - $ret = (bool) $this->delete_meta( 'additional_email', $email ); | |
| 1193 | +		$ret = (bool) $this->delete_meta('additional_email', $email); | |
| 1194 | 1194 | |
| 1195 | - do_action( 'give_donor_post_remove_email', $email, $this->id, $this ); | |
| 1195 | +		do_action('give_donor_post_remove_email', $email, $this->id, $this); | |
| 1196 | 1196 | |
| 1197 | 1197 | return $ret; | 
| 1198 | 1198 | } | 
| @@ -1209,16 +1209,16 @@ discard block | ||
| 1209 | 1209 | * | 
| 1210 | 1210 | * @return bool If the email was set as primary successfully. | 
| 1211 | 1211 | */ | 
| 1212 | -	public function set_primary_email( $new_primary_email = '' ) { | |
| 1213 | -		if ( ! is_email( $new_primary_email ) ) { | |
| 1212 | +	public function set_primary_email($new_primary_email = '') { | |
| 1213 | +		if ( ! is_email($new_primary_email)) { | |
| 1214 | 1214 | return false; | 
| 1215 | 1215 | } | 
| 1216 | 1216 | |
| 1217 | - do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this ); | |
| 1217 | +		do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this); | |
| 1218 | 1218 | |
| 1219 | - $existing = new Give_Donor( $new_primary_email ); | |
| 1219 | + $existing = new Give_Donor($new_primary_email); | |
| 1220 | 1220 | |
| 1221 | -		if ( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) { | |
| 1221 | +		if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) { | |
| 1222 | 1222 | // This email belongs to another donor. | 
| 1223 | 1223 | return false; | 
| 1224 | 1224 | } | 
| @@ -1226,21 +1226,21 @@ discard block | ||
| 1226 | 1226 | $old_email = $this->email; | 
| 1227 | 1227 | |
| 1228 | 1228 | // Update donor record with new email. | 
| 1229 | - $update = $this->update( array( 'email' => $new_primary_email ) ); | |
| 1229 | +		$update = $this->update(array('email' => $new_primary_email)); | |
| 1230 | 1230 | |
| 1231 | 1231 | // Remove new primary from list of additional emails. | 
| 1232 | - $remove = $this->remove_email( $new_primary_email ); | |
| 1232 | + $remove = $this->remove_email($new_primary_email); | |
| 1233 | 1233 | |
| 1234 | 1234 | // Add old email to additional emails list. | 
| 1235 | - $add = $this->add_email( $old_email ); | |
| 1235 | + $add = $this->add_email($old_email); | |
| 1236 | 1236 | |
| 1237 | 1237 | $ret = $update && $remove && $add; | 
| 1238 | 1238 | |
| 1239 | -		if ( $ret ) { | |
| 1239 | +		if ($ret) { | |
| 1240 | 1240 | $this->email = $new_primary_email; | 
| 1241 | 1241 | } | 
| 1242 | 1242 | |
| 1243 | - do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this ); | |
| 1243 | +		do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this); | |
| 1244 | 1244 | |
| 1245 | 1245 | return $ret; | 
| 1246 | 1246 | } | 
| @@ -1255,17 +1255,17 @@ discard block | ||
| 1255 | 1255 | * | 
| 1256 | 1256 | * @return bool | 
| 1257 | 1257 | */ | 
| 1258 | -	private function is_valid_address( $address ) { | |
| 1258 | +	private function is_valid_address($address) { | |
| 1259 | 1259 | $is_valid_address = true; | 
| 1260 | 1260 | |
| 1261 | 1261 | // Address ready to process even if only one value set. | 
| 1262 | -		foreach ( $address as $address_type => $value ) { | |
| 1262 | +		foreach ($address as $address_type => $value) { | |
| 1263 | 1263 | // @todo: Handle state field validation on basis of country. | 
| 1264 | -			if( in_array( $address_type, array( 'line2', 'state' )) ) { | |
| 1264 | +			if (in_array($address_type, array('line2', 'state'))) { | |
| 1265 | 1265 | continue; | 
| 1266 | 1266 | } | 
| 1267 | 1267 | |
| 1268 | -			if ( empty( $value ) ) { | |
| 1268 | +			if (empty($value)) { | |
| 1269 | 1269 | $is_valid_address = false; | 
| 1270 | 1270 | break; | 
| 1271 | 1271 | } | 
| @@ -1292,30 +1292,27 @@ discard block | ||
| 1292 | 1292 | * | 
| 1293 | 1293 | * @return bool | 
| 1294 | 1294 | */ | 
| 1295 | -	public function add_address( $address_type, $address ) { | |
| 1295 | +	public function add_address($address_type, $address) { | |
| 1296 | 1296 | // Bailout. | 
| 1297 | -		if ( empty( $address_type ) || ! $this->is_valid_address( $address ) || ! $this->id ) { | |
| 1297 | +		if (empty($address_type) || ! $this->is_valid_address($address) || ! $this->id) { | |
| 1298 | 1298 | return false; | 
| 1299 | 1299 | } | 
| 1300 | 1300 | |
| 1301 | 1301 | // Check if multiple address exist or not and set params. | 
| 1302 | 1302 | $multi_address_id = null; | 
| 1303 | -		if( $is_multi_address = ( false !== strpos( $address_type, '[]' ) ) ) { | |
| 1304 | - $address_type = $is_multi_address ? | |
| 1305 | - str_replace( '[]', '', $address_type ) : | |
| 1306 | - $address_type; | |
| 1307 | -		} elseif ( $is_multi_address = ( false !== strpos( $address_type, '_' ) ) ){ | |
| 1308 | - $multi_address_id = $is_multi_address ? | |
| 1309 | - array_pop( explode( '_', $address_type ) ) : | |
| 1310 | - $address_type; | |
| 1303 | +		if ($is_multi_address = (false !== strpos($address_type, '[]'))) { | |
| 1304 | + $address_type = $is_multi_address ? | |
| 1305 | +				str_replace('[]', '', $address_type) : $address_type; | |
| 1306 | +		} elseif ($is_multi_address = (false !== strpos($address_type, '_'))) { | |
| 1307 | + $multi_address_id = $is_multi_address ? | |
| 1308 | +				array_pop(explode('_', $address_type)) : $address_type; | |
| 1311 | 1309 | |
| 1312 | - $address_type = $is_multi_address ? | |
| 1313 | - array_shift( explode( '_', $address_type ) ) : | |
| 1314 | - $address_type; | |
| 1310 | + $address_type = $is_multi_address ? | |
| 1311 | +				array_shift(explode('_', $address_type)) : $address_type; | |
| 1315 | 1312 | } | 
| 1316 | 1313 | |
| 1317 | 1314 | // Bailout: do not save duplicate orders | 
| 1318 | -		if( $this->is_address_exist( $address_type, $address ) ) { | |
| 1315 | +		if ($this->is_address_exist($address_type, $address)) { | |
| 1319 | 1316 | return false; | 
| 1320 | 1317 | } | 
| 1321 | 1318 | |
| @@ -1337,8 +1334,8 @@ discard block | ||
| 1337 | 1334 |  		$meta_key_prefix = "_give_donor_address_{$address_type}_{address_name}"; | 
| 1338 | 1335 | $meta_type = Give()->donor_meta->meta_type; | 
| 1339 | 1336 | |
| 1340 | -		if ( $is_multi_address ) { | |
| 1341 | -			if ( is_null( $multi_address_id ) ) { | |
| 1337 | +		if ($is_multi_address) { | |
| 1338 | +			if (is_null($multi_address_id)) { | |
| 1342 | 1339 | // Get latest address key to set multi address id. | 
| 1343 | 1340 | $multi_address_id = $wpdb->get_var( | 
| 1344 | 1341 | $wpdb->prepare( | 
| @@ -1355,10 +1352,10 @@ discard block | ||
| 1355 | 1352 | ) | 
| 1356 | 1353 | ); | 
| 1357 | 1354 | |
| 1358 | -				if( ! empty( $multi_address_id ) ) { | |
| 1359 | - $multi_address_id = absint( substr( strrchr( $multi_address_id, '_' ), 1 ) ); | |
| 1355 | +				if ( ! empty($multi_address_id)) { | |
| 1356 | + $multi_address_id = absint(substr(strrchr($multi_address_id, '_'), 1)); | |
| 1360 | 1357 | $multi_address_id++; | 
| 1361 | -				} else{ | |
| 1358 | +				} else { | |
| 1362 | 1359 | $multi_address_id = 0; | 
| 1363 | 1360 | } | 
| 1364 | 1361 | } | 
| @@ -1367,9 +1364,9 @@ discard block | ||
| 1367 | 1364 | } | 
| 1368 | 1365 | |
| 1369 | 1366 | // Save donor address. | 
| 1370 | -		foreach ( $address as $type => $value ) { | |
| 1371 | -			$meta_key = str_replace( '{address_name}', $type, $meta_key_prefix ); | |
| 1372 | - Give()->donor_meta->update_meta( $this->id, $meta_key, $value ); | |
| 1367 | +		foreach ($address as $type => $value) { | |
| 1368 | +			$meta_key = str_replace('{address_name}', $type, $meta_key_prefix); | |
| 1369 | + Give()->donor_meta->update_meta($this->id, $meta_key, $value); | |
| 1373 | 1370 | } | 
| 1374 | 1371 | |
| 1375 | 1372 | $this->setup_address(); | 
| @@ -1388,23 +1385,21 @@ discard block | ||
| 1388 | 1385 | * | 
| 1389 | 1386 | * @return bool | 
| 1390 | 1387 | */ | 
| 1391 | -	public function remove_address( $address_id ) { | |
| 1388 | +	public function remove_address($address_id) { | |
| 1392 | 1389 | global $wpdb; | 
| 1393 | 1390 | |
| 1394 | 1391 | // Get address type. | 
| 1395 | - $is_multi_address = false !== strpos( $address_id, '_' ) ? true : false; | |
| 1392 | + $is_multi_address = false !== strpos($address_id, '_') ? true : false; | |
| 1396 | 1393 | |
| 1397 | - $address_type = false !== strpos( $address_id, '_' ) ? | |
| 1398 | - array_shift( explode( '_', $address_id ) ) : | |
| 1399 | - $address_id; | |
| 1394 | + $address_type = false !== strpos($address_id, '_') ? | |
| 1395 | +			array_shift(explode('_', $address_id)) : $address_id; | |
| 1400 | 1396 | |
| 1401 | - $address_count = false !== strpos( $address_id, '_' ) ? | |
| 1402 | - array_pop( explode( '_', $address_id ) ) : | |
| 1403 | - null; | |
| 1397 | + $address_count = false !== strpos($address_id, '_') ? | |
| 1398 | +			array_pop(explode('_', $address_id)) : null; | |
| 1404 | 1399 | |
| 1405 | 1400 | // Set meta key prefix. | 
| 1406 | 1401 |  		$meta_key_prefix = "_give_donor_address_{$address_type}_%"; | 
| 1407 | -		if ( $is_multi_address && is_numeric( $address_count ) ) { | |
| 1402 | +		if ($is_multi_address && is_numeric($address_count)) { | |
| 1408 | 1403 |  			$meta_key_prefix .= "_{$address_count}"; | 
| 1409 | 1404 | } | 
| 1410 | 1405 | |
| @@ -1441,23 +1436,21 @@ discard block | ||
| 1441 | 1436 | * | 
| 1442 | 1437 | * @return bool | 
| 1443 | 1438 | */ | 
| 1444 | -	public function update_address( $address_id, $address ) { | |
| 1439 | +	public function update_address($address_id, $address) { | |
| 1445 | 1440 | global $wpdb; | 
| 1446 | 1441 | |
| 1447 | 1442 | // Get address type. | 
| 1448 | - $is_multi_address = false !== strpos( $address_id, '_' ) ? true : false; | |
| 1443 | + $is_multi_address = false !== strpos($address_id, '_') ? true : false; | |
| 1449 | 1444 | |
| 1450 | - $address_type = false !== strpos( $address_id, '_' ) ? | |
| 1451 | - array_shift( explode( '_', $address_id ) ) : | |
| 1452 | - $address_id; | |
| 1445 | + $address_type = false !== strpos($address_id, '_') ? | |
| 1446 | +			array_shift(explode('_', $address_id)) : $address_id; | |
| 1453 | 1447 | |
| 1454 | - $address_count = false !== strpos( $address_id, '_' ) ? | |
| 1455 | - array_pop( explode( '_', $address_id ) ) : | |
| 1456 | - null; | |
| 1448 | + $address_count = false !== strpos($address_id, '_') ? | |
| 1449 | +			array_pop(explode('_', $address_id)) : null; | |
| 1457 | 1450 | |
| 1458 | 1451 | // Set meta key prefix. | 
| 1459 | 1452 |  		$meta_key_prefix = "_give_donor_address_{$address_type}_%"; | 
| 1460 | -		if ( $is_multi_address && is_numeric( $address_count ) ) { | |
| 1453 | +		if ($is_multi_address && is_numeric($address_count)) { | |
| 1461 | 1454 |  			$meta_key_prefix .= "_{$address_count}"; | 
| 1462 | 1455 | } | 
| 1463 | 1456 | |
| @@ -1478,12 +1471,12 @@ discard block | ||
| 1478 | 1471 | ); | 
| 1479 | 1472 | |
| 1480 | 1473 | // Return result. | 
| 1481 | -		if( ! count( $row_affected ) ) { | |
| 1474 | +		if ( ! count($row_affected)) { | |
| 1482 | 1475 | return false; | 
| 1483 | 1476 | } | 
| 1484 | 1477 | |
| 1485 | 1478 | // Update address. | 
| 1486 | -		if( ! $this->add_address( $address_id, $address ) ) { | |
| 1479 | +		if ( ! $this->add_address($address_id, $address)) { | |
| 1487 | 1480 | return false; | 
| 1488 | 1481 | } | 
| 1489 | 1482 | |
| @@ -1502,39 +1495,39 @@ discard block | ||
| 1502 | 1495 | * | 
| 1503 | 1496 | * @return bool|null | 
| 1504 | 1497 | */ | 
| 1505 | -	public function is_address_exist( $current_address_type, $current_address ) { | |
| 1498 | +	public function is_address_exist($current_address_type, $current_address) { | |
| 1506 | 1499 | $status = false; | 
| 1507 | 1500 | |
| 1508 | 1501 | // Bailout. | 
| 1509 | -		if( empty( $current_address_type ) || empty( $current_address ) ) { | |
| 1502 | +		if (empty($current_address_type) || empty($current_address)) { | |
| 1510 | 1503 | return null; | 
| 1511 | 1504 | } | 
| 1512 | 1505 | |
| 1513 | 1506 | // Bailout. | 
| 1514 | -		if( empty( $this->address ) || empty( $this->address[ $current_address_type ] ) ) { | |
| 1507 | +		if (empty($this->address) || empty($this->address[$current_address_type])) { | |
| 1515 | 1508 | return $status; | 
| 1516 | 1509 | } | 
| 1517 | 1510 | |
| 1518 | 1511 | // Get address. | 
| 1519 | - $address = $this->address[ $current_address_type ]; | |
| 1512 | + $address = $this->address[$current_address_type]; | |
| 1520 | 1513 | |
| 1521 | -		switch ( true ){ | |
| 1514 | +		switch (true) { | |
| 1522 | 1515 | |
| 1523 | 1516 | // Single address. | 
| 1524 | - case is_string( end( $address ) ) : | |
| 1525 | - $status = $this->is_address_match( $current_address, $address ); | |
| 1517 | + case is_string(end($address)) : | |
| 1518 | + $status = $this->is_address_match($current_address, $address); | |
| 1526 | 1519 | break; | 
| 1527 | 1520 | |
| 1528 | 1521 | // Multi address. | 
| 1529 | - case is_array( end( $address ) ): | |
| 1522 | + case is_array(end($address)): | |
| 1530 | 1523 | // Compare address. | 
| 1531 | -				foreach ( $address as $saved_address ) { | |
| 1532 | -					if( empty( $saved_address ) ) { | |
| 1524 | +				foreach ($address as $saved_address) { | |
| 1525 | +					if (empty($saved_address)) { | |
| 1533 | 1526 | continue; | 
| 1534 | 1527 | } | 
| 1535 | 1528 | |
| 1536 | 1529 | // Exit loop immediately if address exist. | 
| 1537 | -					if( $status = $this->is_address_match( $current_address, $saved_address ) ) { | |
| 1530 | +					if ($status = $this->is_address_match($current_address, $saved_address)) { | |
| 1538 | 1531 | break; | 
| 1539 | 1532 | } | 
| 1540 | 1533 | } | 
| @@ -1555,10 +1548,10 @@ discard block | ||
| 1555 | 1548 | * | 
| 1556 | 1549 | * @return bool | 
| 1557 | 1550 | */ | 
| 1558 | -	private function is_address_match( $address_1, $address_2 ) { | |
| 1559 | - $result = array_diff( $address_1, $address_2 ); | |
| 1551 | +	private function is_address_match($address_1, $address_2) { | |
| 1552 | + $result = array_diff($address_1, $address_2); | |
| 1560 | 1553 | |
| 1561 | - return empty( $result ); | |
| 1554 | + return empty($result); | |
| 1562 | 1555 | } | 
| 1563 | 1556 | |
| 1564 | 1557 | /** | 
| @@ -1568,22 +1561,22 @@ discard block | ||
| 1568 | 1561 | * @since 2.0 | 
| 1569 | 1562 | * @return object | 
| 1570 | 1563 | */ | 
| 1571 | -	public function split_donor_name( $id ) { | |
| 1572 | - $first_name = $last_name = ''; | |
| 1573 | - $donor = new Give_Donor( $id ); | |
| 1564 | +	public function split_donor_name($id) { | |
| 1565 | + $first_name = $last_name = ''; | |
| 1566 | + $donor = new Give_Donor($id); | |
| 1574 | 1567 | |
| 1575 | - $split_donor_name = explode( ' ', $donor->name, 2 ); | |
| 1568 | +		$split_donor_name = explode(' ', $donor->name, 2); | |
| 1576 | 1569 | |
| 1577 | 1570 | // Check for existence of first name after split of donor name. | 
| 1578 | -		if( is_array( $split_donor_name ) && ! empty( $split_donor_name[0] ) ) { | |
| 1571 | +		if (is_array($split_donor_name) && ! empty($split_donor_name[0])) { | |
| 1579 | 1572 | $first_name = $split_donor_name[0]; | 
| 1580 | 1573 | } | 
| 1581 | 1574 | |
| 1582 | 1575 | // Check for existence of last name after split of donor name. | 
| 1583 | -		if( is_array( $split_donor_name ) && ! empty( $split_donor_name[1] ) ) { | |
| 1576 | +		if (is_array($split_donor_name) && ! empty($split_donor_name[1])) { | |
| 1584 | 1577 | $last_name = $split_donor_name[1]; | 
| 1585 | 1578 | } | 
| 1586 | - return (object) array( 'first_name' => $first_name, 'last_name' => $last_name ); | |
| 1579 | +		return (object) array('first_name' => $first_name, 'last_name' => $last_name); | |
| 1587 | 1580 | } | 
| 1588 | 1581 | |
| 1589 | 1582 | /** | 
| @@ -1593,9 +1586,9 @@ discard block | ||
| 1593 | 1586 | * @return string | 
| 1594 | 1587 | */ | 
| 1595 | 1588 |  	public function get_first_name() { | 
| 1596 | - $first_name = $this->get_meta( '_give_donor_first_name'); | |
| 1597 | -		if( ! $first_name ) { | |
| 1598 | - $first_name = $this->split_donor_name( $this->id )->first_name; | |
| 1589 | +		$first_name = $this->get_meta('_give_donor_first_name'); | |
| 1590 | +		if ( ! $first_name) { | |
| 1591 | + $first_name = $this->split_donor_name($this->id)->first_name; | |
| 1599 | 1592 | } | 
| 1600 | 1593 | |
| 1601 | 1594 | return $first_name; | 
| @@ -1608,15 +1601,15 @@ discard block | ||
| 1608 | 1601 | * @return string | 
| 1609 | 1602 | */ | 
| 1610 | 1603 |  	public function get_last_name() { | 
| 1611 | - $first_name = $this->get_meta( '_give_donor_first_name'); | |
| 1612 | - $last_name = $this->get_meta( '_give_donor_last_name'); | |
| 1604 | +		$first_name = $this->get_meta('_give_donor_first_name'); | |
| 1605 | +		$last_name = $this->get_meta('_give_donor_last_name'); | |
| 1613 | 1606 | |
| 1614 | 1607 | // This condition will prevent unnecessary splitting of donor name to fetch last name. | 
| 1615 | -		if( ! $first_name && ! $last_name ) { | |
| 1616 | - $last_name = $this->split_donor_name( $this->id )->last_name; | |
| 1608 | +		if ( ! $first_name && ! $last_name) { | |
| 1609 | + $last_name = $this->split_donor_name($this->id)->last_name; | |
| 1617 | 1610 | } | 
| 1618 | 1611 | |
| 1619 | - return ( $last_name ) ? $last_name : ''; | |
| 1612 | + return ($last_name) ? $last_name : ''; | |
| 1620 | 1613 | } | 
| 1621 | 1614 | |
| 1622 | 1615 | /** | 
| @@ -1627,7 +1620,7 @@ discard block | ||
| 1627 | 1620 | * @return string $company_name Donor Company Name | 
| 1628 | 1621 | */ | 
| 1629 | 1622 |  	public function get_company_name() { | 
| 1630 | - $company_name = $this->get_meta( '_give_donor_company' ); | |
| 1623 | +		$company_name = $this->get_meta('_give_donor_company'); | |
| 1631 | 1624 | |
| 1632 | 1625 | return $company_name; | 
| 1633 | 1626 | } | 
| @@ -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,54 +30,54 @@ discard block | ||
| 30 | 30 | * | 
| 31 | 31 | * @return bool|array List of all user donations. | 
| 32 | 32 | */ | 
| 33 | -function give_get_users_donations( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) { | |
| 33 | +function give_get_users_donations($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 | - $status = ( 'complete' === $status ) ? 'publish' : $status; | |
| 43 | +	$status = ('complete' === $status) ? 'publish' : $status; | |
| 44 | 44 | $paged = 1; | 
| 45 | 45 | |
| 46 | -	if ( $pagination ) { | |
| 47 | -		if ( get_query_var( 'paged' ) ) { | |
| 48 | - $paged = get_query_var( 'paged' ); | |
| 49 | -		} elseif ( get_query_var( 'page' ) ) { | |
| 50 | - $paged = get_query_var( 'page' ); | |
| 46 | +	if ($pagination) { | |
| 47 | +		if (get_query_var('paged')) { | |
| 48 | +			$paged = get_query_var('paged'); | |
| 49 | +		} elseif (get_query_var('page')) { | |
| 50 | +			$paged = get_query_var('page'); | |
| 51 | 51 | } | 
| 52 | 52 | } | 
| 53 | 53 | |
| 54 | - $args = apply_filters( 'give_get_users_donations_args', array( | |
| 54 | +	$args = apply_filters('give_get_users_donations_args', array( | |
| 55 | 55 | 'user' => $user, | 
| 56 | 56 | 'number' => $number, | 
| 57 | 57 | 'status' => $status, | 
| 58 | 58 | 'orderby' => 'date', | 
| 59 | - ) ); | |
| 59 | + )); | |
| 60 | 60 | |
| 61 | -	if ( $pagination ) { | |
| 61 | +	if ($pagination) { | |
| 62 | 62 | $args['page'] = $paged; | 
| 63 | 63 |  	} else { | 
| 64 | 64 | $args['nopaging'] = true; | 
| 65 | 65 | } | 
| 66 | 66 | |
| 67 | - $by_user_id = is_numeric( $user ) ? true : false; | |
| 68 | - $donor = new Give_Donor( $user, $by_user_id ); | |
| 67 | + $by_user_id = is_numeric($user) ? true : false; | |
| 68 | + $donor = new Give_Donor($user, $by_user_id); | |
| 69 | 69 | |
| 70 | -	if ( ! empty( $donor->payment_ids ) ) { | |
| 70 | +	if ( ! empty($donor->payment_ids)) { | |
| 71 | 71 | |
| 72 | - unset( $args['user'] ); | |
| 73 | - $args['post__in'] = array_map( 'absint', explode( ',', $donor->payment_ids ) ); | |
| 72 | + unset($args['user']); | |
| 73 | +		$args['post__in'] = array_map('absint', explode(',', $donor->payment_ids)); | |
| 74 | 74 | |
| 75 | 75 | } | 
| 76 | 76 | |
| 77 | - $donations = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) ); | |
| 77 | +	$donations = give_get_payments(apply_filters('give_get_users_donations_args', $args)); | |
| 78 | 78 | |
| 79 | 79 | // No donations. | 
| 80 | -	if ( ! $donations ) { | |
| 80 | +	if ( ! $donations) { | |
| 81 | 81 | return false; | 
| 82 | 82 | } | 
| 83 | 83 | |
| @@ -96,65 +96,65 @@ discard block | ||
| 96 | 96 | * | 
| 97 | 97 | * @return bool|object List of unique forms donated by user | 
| 98 | 98 | */ | 
| 99 | -function give_get_users_completed_donations( $user = 0, $status = 'complete' ) { | |
| 100 | -	if ( empty( $user ) ) { | |
| 99 | +function give_get_users_completed_donations($user = 0, $status = 'complete') { | |
| 100 | +	if (empty($user)) { | |
| 101 | 101 | $user = get_current_user_id(); | 
| 102 | 102 | } | 
| 103 | 103 | |
| 104 | -	if ( empty( $user ) ) { | |
| 104 | +	if (empty($user)) { | |
| 105 | 105 | return false; | 
| 106 | 106 | } | 
| 107 | 107 | |
| 108 | - $by_user_id = is_numeric( $user ) ? true : false; | |
| 108 | + $by_user_id = is_numeric($user) ? true : false; | |
| 109 | 109 | |
| 110 | - $donor = new Give_Donor( $user, $by_user_id ); | |
| 110 | + $donor = new Give_Donor($user, $by_user_id); | |
| 111 | 111 | |
| 112 | -	if ( empty( $donor->payment_ids ) ) { | |
| 112 | +	if (empty($donor->payment_ids)) { | |
| 113 | 113 | return false; | 
| 114 | 114 | } | 
| 115 | 115 | |
| 116 | 116 | // Get all the items donated. | 
| 117 | - $payment_ids = array_reverse( explode( ',', $donor->payment_ids ) ); | |
| 118 | - $limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 ); | |
| 119 | -	if ( ! empty( $limit_payments ) ) { | |
| 120 | - $payment_ids = array_slice( $payment_ids, 0, $limit_payments ); | |
| 117 | +	$payment_ids    = array_reverse(explode(',', $donor->payment_ids)); | |
| 118 | +	$limit_payments = apply_filters('give_users_completed_donations_payments', 50); | |
| 119 | +	if ( ! empty($limit_payments)) { | |
| 120 | + $payment_ids = array_slice($payment_ids, 0, $limit_payments); | |
| 121 | 121 | } | 
| 122 | 122 | $donation_data = array(); | 
| 123 | -	foreach ( $payment_ids as $payment_id ) { | |
| 124 | - $donation_data[] = give_get_payment_meta( $payment_id ); | |
| 123 | +	foreach ($payment_ids as $payment_id) { | |
| 124 | + $donation_data[] = give_get_payment_meta($payment_id); | |
| 125 | 125 | } | 
| 126 | 126 | |
| 127 | -	if ( empty( $donation_data ) ) { | |
| 127 | +	if (empty($donation_data)) { | |
| 128 | 128 | return false; | 
| 129 | 129 | } | 
| 130 | 130 | |
| 131 | 131 | // Grab only the post ids "form_id" of the forms donated on this order. | 
| 132 | 132 | $completed_donations_ids = array(); | 
| 133 | -	foreach ( $donation_data as $donation_meta ) { | |
| 134 | - $completed_donations_ids[] = isset( $donation_meta['form_id'] ) ? $donation_meta['form_id'] : ''; | |
| 133 | +	foreach ($donation_data as $donation_meta) { | |
| 134 | + $completed_donations_ids[] = isset($donation_meta['form_id']) ? $donation_meta['form_id'] : ''; | |
| 135 | 135 | } | 
| 136 | 136 | |
| 137 | -	if ( empty( $completed_donations_ids ) ) { | |
| 137 | +	if (empty($completed_donations_ids)) { | |
| 138 | 138 | return false; | 
| 139 | 139 | } | 
| 140 | 140 | |
| 141 | 141 | // Only include each donation once. | 
| 142 | - $form_ids = array_unique( $completed_donations_ids ); | |
| 142 | + $form_ids = array_unique($completed_donations_ids); | |
| 143 | 143 | |
| 144 | 144 | // Make sure we still have some products and a first item. | 
| 145 | -	if ( empty( $form_ids ) || ! isset( $form_ids[0] ) ) { | |
| 145 | +	if (empty($form_ids) || ! isset($form_ids[0])) { | |
| 146 | 146 | return false; | 
| 147 | 147 | } | 
| 148 | 148 | |
| 149 | - $post_type = get_post_type( $form_ids[0] ); | |
| 149 | + $post_type = get_post_type($form_ids[0]); | |
| 150 | 150 | |
| 151 | - $args = apply_filters( 'give_get_users_completed_donations_args', array( | |
| 151 | +	$args = apply_filters('give_get_users_completed_donations_args', array( | |
| 152 | 152 | 'include' => $form_ids, | 
| 153 | 153 | 'post_type' => $post_type, | 
| 154 | - 'posts_per_page' => - 1, | |
| 155 | - ) ); | |
| 154 | + 'posts_per_page' => -1, | |
| 155 | + )); | |
| 156 | 156 | |
| 157 | - return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) ); | |
| 157 | +	return apply_filters('give_users_completed_donations_list', get_posts($args)); | |
| 158 | 158 | } | 
| 159 | 159 | |
| 160 | 160 | |
| @@ -170,12 +170,12 @@ discard block | ||
| 170 | 170 | * | 
| 171 | 171 | * @return bool True if has donated, false other wise. | 
| 172 | 172 | */ | 
| 173 | -function give_has_donations( $user_id = null ) { | |
| 174 | -	if ( empty( $user_id ) ) { | |
| 173 | +function give_has_donations($user_id = null) { | |
| 174 | +	if (empty($user_id)) { | |
| 175 | 175 | $user_id = get_current_user_id(); | 
| 176 | 176 | } | 
| 177 | 177 | |
| 178 | -	if ( give_get_users_donations( $user_id, 1 ) ) { | |
| 178 | +	if (give_get_users_donations($user_id, 1)) { | |
| 179 | 179 | return true; // User has at least one donation. | 
| 180 | 180 | } | 
| 181 | 181 | |
| @@ -196,23 +196,23 @@ discard block | ||
| 196 | 196 | * | 
| 197 | 197 | * @return array | 
| 198 | 198 | */ | 
| 199 | -function give_get_donation_stats_by_user( $user = '' ) { | |
| 199 | +function give_get_donation_stats_by_user($user = '') { | |
| 200 | 200 | |
| 201 | 201 | $field = ''; | 
| 202 | 202 | |
| 203 | -	if ( is_email( $user ) ) { | |
| 203 | +	if (is_email($user)) { | |
| 204 | 204 | $field = 'email'; | 
| 205 | -	} elseif ( is_numeric( $user ) ) { | |
| 205 | +	} elseif (is_numeric($user)) { | |
| 206 | 206 | $field = 'user_id'; | 
| 207 | 207 | } | 
| 208 | 208 | |
| 209 | - $stats = array(); | |
| 210 | - $donor = Give()->donors->get_donor_by( $field, $user ); | |
| 209 | + $stats = array(); | |
| 210 | + $donor = Give()->donors->get_donor_by($field, $user); | |
| 211 | 211 | |
| 212 | -	if ( $donor ) { | |
| 213 | - $donor = new Give_Donor( $donor->id ); | |
| 214 | - $stats['purchases'] = absint( $donor->purchase_count ); | |
| 215 | - $stats['total_spent'] = give_maybe_sanitize_amount( $donor->get_total_donation_amount() ); | |
| 212 | +	if ($donor) { | |
| 213 | + $donor = new Give_Donor($donor->id); | |
| 214 | + $stats['purchases'] = absint($donor->purchase_count); | |
| 215 | + $stats['total_spent'] = give_maybe_sanitize_amount($donor->get_total_donation_amount()); | |
| 216 | 216 | } | 
| 217 | 217 | |
| 218 | 218 | /** | 
| @@ -220,7 +220,7 @@ discard block | ||
| 220 | 220 | * | 
| 221 | 221 | * @since 1.7 | 
| 222 | 222 | */ | 
| 223 | - $stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user ); | |
| 223 | +	$stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user); | |
| 224 | 224 | |
| 225 | 225 | return $stats; | 
| 226 | 226 | } | 
| @@ -238,21 +238,21 @@ discard block | ||
| 238 | 238 | * | 
| 239 | 239 | * @return int The total number of donations. | 
| 240 | 240 | */ | 
| 241 | -function give_count_donations_of_donor( $user = null ) { | |
| 241 | +function give_count_donations_of_donor($user = null) { | |
| 242 | 242 | |
| 243 | 243 | // Logged in? | 
| 244 | -	if ( empty( $user ) ) { | |
| 244 | +	if (empty($user)) { | |
| 245 | 245 | $user = get_current_user_id(); | 
| 246 | 246 | } | 
| 247 | 247 | |
| 248 | 248 | // Email access? | 
| 249 | -	if ( empty( $user ) && Give()->email_access->token_email ) { | |
| 249 | +	if (empty($user) && Give()->email_access->token_email) { | |
| 250 | 250 | $user = Give()->email_access->token_email; | 
| 251 | 251 | } | 
| 252 | 252 | |
| 253 | - $stats = ! empty( $user ) ? give_get_donation_stats_by_user( $user ) : false; | |
| 253 | + $stats = ! empty($user) ? give_get_donation_stats_by_user($user) : false; | |
| 254 | 254 | |
| 255 | - return isset( $stats['purchases'] ) ? $stats['purchases'] : 0; | |
| 255 | + return isset($stats['purchases']) ? $stats['purchases'] : 0; | |
| 256 | 256 | } | 
| 257 | 257 | |
| 258 | 258 | /** | 
| @@ -265,9 +265,9 @@ discard block | ||
| 265 | 265 | * | 
| 266 | 266 | * @return float The total amount the user has spent | 
| 267 | 267 | */ | 
| 268 | -function give_donation_total_of_user( $user = null ) { | |
| 268 | +function give_donation_total_of_user($user = null) { | |
| 269 | 269 | |
| 270 | - $stats = give_get_donation_stats_by_user( $user ); | |
| 270 | + $stats = give_get_donation_stats_by_user($user); | |
| 271 | 271 | |
| 272 | 272 | return $stats['total_spent']; | 
| 273 | 273 | } | 
| @@ -283,40 +283,40 @@ discard block | ||
| 283 | 283 | * | 
| 284 | 284 | * @return bool | 
| 285 | 285 | */ | 
| 286 | -function give_validate_username( $username, $form_id = 0 ) { | |
| 286 | +function give_validate_username($username, $form_id = 0) { | |
| 287 | 287 | $valid = true; | 
| 288 | 288 | |
| 289 | 289 | // Validate username. | 
| 290 | -	if ( ! empty( $username ) ) { | |
| 290 | +	if ( ! empty($username)) { | |
| 291 | 291 | |
| 292 | 292 | // Sanitize username. | 
| 293 | - $sanitized_user_name = sanitize_user( $username, false ); | |
| 293 | + $sanitized_user_name = sanitize_user($username, false); | |
| 294 | 294 | |
| 295 | 295 | // We have an user name, check if it already exists. | 
| 296 | -		if ( username_exists( $username ) ) { | |
| 296 | +		if (username_exists($username)) { | |
| 297 | 297 | // Username already registered. | 
| 298 | - give_set_error( 'username_unavailable', __( 'Username already taken.', 'give' ) ); | |
| 298 | +			give_set_error('username_unavailable', __('Username already taken.', 'give')); | |
| 299 | 299 | $valid = false; | 
| 300 | 300 | |
| 301 | 301 | // Check if it's valid. | 
| 302 | -		} elseif ( $sanitized_user_name !== $username ) { | |
| 302 | +		} elseif ($sanitized_user_name !== $username) { | |
| 303 | 303 | // Invalid username. | 
| 304 | -			if ( is_multisite() ) { | |
| 305 | - give_set_error( 'username_invalid', __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) ); | |
| 304 | +			if (is_multisite()) { | |
| 305 | +				give_set_error('username_invalid', __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give')); | |
| 306 | 306 | $valid = false; | 
| 307 | 307 |  			} else { | 
| 308 | - give_set_error( 'username_invalid', __( 'Invalid username.', 'give' ) ); | |
| 308 | +				give_set_error('username_invalid', __('Invalid username.', 'give')); | |
| 309 | 309 | $valid = false; | 
| 310 | 310 | } | 
| 311 | 311 | } | 
| 312 | 312 |  	} else { | 
| 313 | 313 | // Username is empty. | 
| 314 | - give_set_error( 'username_empty', __( 'Enter a username.', 'give' ) ); | |
| 314 | +		give_set_error('username_empty', __('Enter a username.', 'give')); | |
| 315 | 315 | $valid = false; | 
| 316 | 316 | |
| 317 | 317 | // Check if guest checkout is disable for form. | 
| 318 | -		if ( $form_id && give_logged_in_only( $form_id ) ) { | |
| 319 | - give_set_error( 'registration_required', __( 'You must register or login to complete your donation.', 'give' ) ); | |
| 318 | +		if ($form_id && give_logged_in_only($form_id)) { | |
| 319 | +			give_set_error('registration_required', __('You must register or login to complete your donation.', 'give')); | |
| 320 | 320 | $valid = false; | 
| 321 | 321 | } | 
| 322 | 322 | } | 
| @@ -330,7 +330,7 @@ discard block | ||
| 330 | 330 | * | 
| 331 | 331 | * @since 1.8 | 
| 332 | 332 | */ | 
| 333 | - $valid = (bool) apply_filters( 'give_validate_username', $valid, $username, $form_id ); | |
| 333 | +	$valid = (bool) apply_filters('give_validate_username', $valid, $username, $form_id); | |
| 334 | 334 | |
| 335 | 335 | return $valid; | 
| 336 | 336 | } | 
| @@ -346,30 +346,30 @@ discard block | ||
| 346 | 346 | * | 
| 347 | 347 | * @return bool | 
| 348 | 348 | */ | 
| 349 | -function give_validate_user_email( $email, $registering_new_user = false ) { | |
| 349 | +function give_validate_user_email($email, $registering_new_user = false) { | |
| 350 | 350 | $valid = true; | 
| 351 | 351 | |
| 352 | -	if ( empty( $email ) ) { | |
| 352 | +	if (empty($email)) { | |
| 353 | 353 | // No email. | 
| 354 | - give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) ); | |
| 354 | +		give_set_error('email_empty', __('Enter an email.', 'give')); | |
| 355 | 355 | $valid = false; | 
| 356 | 356 | |
| 357 | -	} elseif ( email_exists( $email ) ) { | |
| 357 | +	} elseif (email_exists($email)) { | |
| 358 | 358 | // Email already exists. | 
| 359 | - give_set_error( 'email_exists', __( 'Email already exists.', 'give' ) ); | |
| 359 | +		give_set_error('email_exists', __('Email already exists.', 'give')); | |
| 360 | 360 | $valid = false; | 
| 361 | 361 | |
| 362 | -	} elseif ( ! is_email( $email ) ) { | |
| 362 | +	} elseif ( ! is_email($email)) { | |
| 363 | 363 | // Validate email. | 
| 364 | - give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) ); | |
| 364 | +		give_set_error('email_invalid', __('Invalid email.', 'give')); | |
| 365 | 365 | $valid = false; | 
| 366 | 366 | |
| 367 | -	} elseif ( $registering_new_user ) { | |
| 367 | +	} elseif ($registering_new_user) { | |
| 368 | 368 | |
| 369 | 369 | // If donor email is not primary. | 
| 370 | -		if ( ! email_exists( $email ) && give_donor_email_exists( $email ) && give_is_additional_email( $email ) ) { | |
| 370 | +		if ( ! email_exists($email) && give_donor_email_exists($email) && give_is_additional_email($email)) { | |
| 371 | 371 | // Check if email exists. | 
| 372 | - give_set_error( 'email_used', __( 'The email address provided is already active for another user.', 'give' ) ); | |
| 372 | +			give_set_error('email_used', __('The email address provided is already active for another user.', 'give')); | |
| 373 | 373 | $valid = false; | 
| 374 | 374 | } | 
| 375 | 375 | } | 
| @@ -383,7 +383,7 @@ discard block | ||
| 383 | 383 | * | 
| 384 | 384 | * @since 1.8 | 
| 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,34 +399,34 @@ 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 | 405 | // Passwords Validation For New Donors Only. | 
| 406 | -	if ( $registering_new_user ) { | |
| 406 | +	if ($registering_new_user) { | |
| 407 | 407 | // Password or confirmation missing. | 
| 408 | -		if ( ! $password ) { | |
| 408 | +		if ( ! $password) { | |
| 409 | 409 | // The password is invalid. | 
| 410 | - give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) ); | |
| 410 | +			give_set_error('password_empty', __('Enter a password.', 'give')); | |
| 411 | 411 | $valid = false; | 
| 412 | -		} elseif ( ! $confirm_password ) { | |
| 412 | +		} elseif ( ! $confirm_password) { | |
| 413 | 413 | // Confirmation password is invalid. | 
| 414 | - give_set_error( 'confirmation_empty', __( 'Enter the password confirmation.', 'give' ) ); | |
| 414 | +			give_set_error('confirmation_empty', __('Enter the password confirmation.', 'give')); | |
| 415 | 415 | $valid = false; | 
| 416 | 416 | } | 
| 417 | 417 | } | 
| 418 | 418 | // Passwords Validation For New Donors as well as Existing Donors. | 
| 419 | -	if ( $password || $confirm_password ) { | |
| 420 | -		if ( strlen( $password ) < 6 || strlen( $confirm_password ) < 6 ) { | |
| 419 | +	if ($password || $confirm_password) { | |
| 420 | +		if (strlen($password) < 6 || strlen($confirm_password) < 6) { | |
| 421 | 421 | // Seems Weak Password. | 
| 422 | - give_set_error( 'password_weak', __( 'Passwords should have at least 6 characters.', 'give' ) ); | |
| 422 | +			give_set_error('password_weak', __('Passwords should have at least 6 characters.', 'give')); | |
| 423 | 423 | $valid = false; | 
| 424 | 424 | } | 
| 425 | -		if ( $password && $confirm_password ) { | |
| 425 | +		if ($password && $confirm_password) { | |
| 426 | 426 | // Verify confirmation matches. | 
| 427 | -			if ( $password !== $confirm_password ) { | |
| 427 | +			if ($password !== $confirm_password) { | |
| 428 | 428 | // Passwords do not match. | 
| 429 | - give_set_error( 'password_mismatch', __( 'Passwords you entered do not match. Please try again.', 'give' ) ); | |
| 429 | +				give_set_error('password_mismatch', __('Passwords you entered do not match. Please try again.', 'give')); | |
| 430 | 430 | $valid = false; | 
| 431 | 431 | } | 
| 432 | 432 | } | 
| @@ -442,7 +442,7 @@ discard block | ||
| 442 | 442 | * | 
| 443 | 443 | * @since 1.8 | 
| 444 | 444 | */ | 
| 445 | - $valid = (bool) apply_filters( 'give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user ); | |
| 445 | +	$valid = (bool) apply_filters('give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user); | |
| 446 | 446 | |
| 447 | 447 | return $valid; | 
| 448 | 448 | } | 
| @@ -470,8 +470,8 @@ discard block | ||
| 470 | 470 | * | 
| 471 | 471 | * @return array The donor's address, if any | 
| 472 | 472 | */ | 
| 473 | -function give_get_donor_address( $donor_id = null, $args = array() ) { | |
| 474 | -	if ( empty( $donor_id ) ) { | |
| 473 | +function give_get_donor_address($donor_id = null, $args = array()) { | |
| 474 | +	if (empty($donor_id)) { | |
| 475 | 475 | $donor_id = get_current_user_id(); | 
| 476 | 476 | } | 
| 477 | 477 | |
| @@ -493,33 +493,33 @@ discard block | ||
| 493 | 493 | |
| 494 | 494 | |
| 495 | 495 | // Backward compatibility for user id param. | 
| 496 | - $by_user_id = get_user_by( 'id', $donor_id ) ? true : false; | |
| 496 | +	$by_user_id = get_user_by('id', $donor_id) ? true : false; | |
| 497 | 497 | |
| 498 | 498 | // Backward compatibility. | 
| 499 | -	if ( ! give_has_upgrade_completed( 'v20_upgrades_user_address' ) && $by_user_id ) { | |
| 499 | +	if ( ! give_has_upgrade_completed('v20_upgrades_user_address') && $by_user_id) { | |
| 500 | 500 | return wp_parse_args( | 
| 501 | - (array) get_user_meta( $donor_id, '_give_user_address', true ), | |
| 501 | + (array) get_user_meta($donor_id, '_give_user_address', true), | |
| 502 | 502 | $default_address | 
| 503 | 503 | ); | 
| 504 | 504 | } | 
| 505 | 505 | |
| 506 | - $donor = new Give_Donor( $donor_id, $by_user_id ); | |
| 506 | + $donor = new Give_Donor($donor_id, $by_user_id); | |
| 507 | 507 | |
| 508 | 508 | if ( | 
| 509 | 509 | ! $donor->id || | 
| 510 | - empty( $donor->address ) || | |
| 511 | - ! array_key_exists( $args['address_type'], $donor->address ) | |
| 510 | + empty($donor->address) || | |
| 511 | + ! array_key_exists($args['address_type'], $donor->address) | |
| 512 | 512 |  	) { | 
| 513 | 513 | return $default_address; | 
| 514 | 514 | } | 
| 515 | 515 | |
| 516 | -	switch ( true ) { | |
| 517 | - case is_string( end( $donor->address[ $args['address_type'] ] ) ): | |
| 518 | - $address = wp_parse_args( $donor->address[ $args['address_type'] ], $default_address ); | |
| 516 | +	switch (true) { | |
| 517 | + case is_string(end($donor->address[$args['address_type']])): | |
| 518 | + $address = wp_parse_args($donor->address[$args['address_type']], $default_address); | |
| 519 | 519 | break; | 
| 520 | 520 | |
| 521 | - case is_array( end( $donor->address[ $args['address_type'] ] ) ): | |
| 522 | - $address = wp_parse_args( array_shift( $donor->address[ $args['address_type'] ] ), $default_address ); | |
| 521 | + case is_array(end($donor->address[$args['address_type']])): | |
| 522 | + $address = wp_parse_args(array_shift($donor->address[$args['address_type']]), $default_address); | |
| 523 | 523 | break; | 
| 524 | 524 | } | 
| 525 | 525 | |
| @@ -539,17 +539,17 @@ discard block | ||
| 539 | 539 | * | 
| 540 | 540 | * @return void | 
| 541 | 541 | */ | 
| 542 | -function give_new_user_notification( $user_id = 0, $user_data = array() ) { | |
| 542 | +function give_new_user_notification($user_id = 0, $user_data = array()) { | |
| 543 | 543 | // Bailout. | 
| 544 | -	if ( empty( $user_id ) || empty( $user_data ) ) { | |
| 544 | +	if (empty($user_id) || empty($user_data)) { | |
| 545 | 545 | return; | 
| 546 | 546 | } | 
| 547 | 547 | |
| 548 | - do_action( 'give_new-donor-register_email_notification', $user_id, $user_data ); | |
| 549 | - do_action( 'give_donor-register_email_notification', $user_id, $user_data ); | |
| 548 | +	do_action('give_new-donor-register_email_notification', $user_id, $user_data); | |
| 549 | +	do_action('give_donor-register_email_notification', $user_id, $user_data); | |
| 550 | 550 | } | 
| 551 | 551 | |
| 552 | -add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 ); | |
| 552 | +add_action('give_insert_user', 'give_new_user_notification', 10, 2); | |
| 553 | 553 | |
| 554 | 554 | |
| 555 | 555 | /** | 
| @@ -565,33 +565,33 @@ discard block | ||
| 565 | 565 | * | 
| 566 | 566 | * @return string | 
| 567 | 567 | */ | 
| 568 | -function give_get_donor_name_by( $id = 0, $from = 'donation' ) { | |
| 568 | +function give_get_donor_name_by($id = 0, $from = 'donation') { | |
| 569 | 569 | |
| 570 | 570 | // ID shouldn't be empty. | 
| 571 | -	if ( empty( $id ) ) { | |
| 571 | +	if (empty($id)) { | |
| 572 | 572 | return ''; | 
| 573 | 573 | } | 
| 574 | 574 | |
| 575 | 575 | $name = ''; | 
| 576 | 576 | |
| 577 | -	switch ( $from ) { | |
| 577 | +	switch ($from) { | |
| 578 | 578 | |
| 579 | 579 | case 'donation': | 
| 580 | - $first_name = give_get_meta( $id, '_give_donor_billing_first_name', true ); | |
| 581 | - $last_name = give_get_meta( $id, '_give_donor_billing_last_name', true ); | |
| 580 | + $first_name = give_get_meta($id, '_give_donor_billing_first_name', true); | |
| 581 | + $last_name = give_get_meta($id, '_give_donor_billing_last_name', true); | |
| 582 | 582 | |
| 583 | -			$name = trim( "{$first_name} {$last_name}" ); | |
| 583 | +			$name = trim("{$first_name} {$last_name}"); | |
| 584 | 584 | |
| 585 | 585 | break; | 
| 586 | 586 | |
| 587 | 587 | case 'donor': | 
| 588 | - $name = Give()->donors->get_column( 'name', $id ); | |
| 588 | +			$name = Give()->donors->get_column('name', $id); | |
| 589 | 589 | |
| 590 | 590 | break; | 
| 591 | 591 | |
| 592 | 592 | } | 
| 593 | 593 | |
| 594 | - return trim( $name ); | |
| 594 | + return trim($name); | |
| 595 | 595 | |
| 596 | 596 | } | 
| 597 | 597 | |
| @@ -604,8 +604,8 @@ discard block | ||
| 604 | 604 | * | 
| 605 | 605 | * @return boolean The user's ID on success, and false on failure. | 
| 606 | 606 | */ | 
| 607 | -function give_donor_email_exists( $email ) { | |
| 608 | -	if ( Give()->donors->get_donor_by( 'email', $email ) ) { | |
| 607 | +function give_donor_email_exists($email) { | |
| 608 | +	if (Give()->donors->get_donor_by('email', $email)) { | |
| 609 | 609 | return true; | 
| 610 | 610 | } | 
| 611 | 611 | return false; | 
| @@ -620,14 +620,14 @@ discard block | ||
| 620 | 620 | * | 
| 621 | 621 | * @return bool | 
| 622 | 622 | */ | 
| 623 | -function give_is_additional_email( $email ) { | |
| 623 | +function give_is_additional_email($email) { | |
| 624 | 624 | global $wpdb; | 
| 625 | 625 | |
| 626 | 626 | $meta_table = Give()->donor_meta->table_name; | 
| 627 | 627 | $meta_type = Give()->donor_meta->meta_type; | 
| 628 | -	$donor_id   = $wpdb->get_var( $wpdb->prepare( "SELECT {$meta_type}_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $email ) ); | |
| 628 | +	$donor_id   = $wpdb->get_var($wpdb->prepare("SELECT {$meta_type}_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $email)); | |
| 629 | 629 | |
| 630 | -	if ( empty( $donor_id ) ) { | |
| 630 | +	if (empty($donor_id)) { | |
| 631 | 631 | return false; | 
| 632 | 632 | } | 
| 633 | 633 | |
| @@ -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,15 +28,15 @@ discard block | ||
| 28 | 28 | * @global $wpdb | 
| 29 | 29 | * @return void | 
| 30 | 30 | */ | 
| 31 | -function give_install( $network_wide = false ) { | |
| 31 | +function give_install($network_wide = false) { | |
| 32 | 32 | |
| 33 | 33 | global $wpdb; | 
| 34 | 34 | |
| 35 | -	if ( is_multisite() && $network_wide ) { | |
| 35 | +	if (is_multisite() && $network_wide) { | |
| 36 | 36 | |
| 37 | -		foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) { | |
| 37 | +		foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) { | |
| 38 | 38 | |
| 39 | - switch_to_blog( $blog_id ); | |
| 39 | + switch_to_blog($blog_id); | |
| 40 | 40 | give_run_install(); | 
| 41 | 41 | restore_current_blog(); | 
| 42 | 42 | |
| @@ -63,31 +63,31 @@ discard block | ||
| 63 | 63 | give_setup_post_types(); | 
| 64 | 64 | |
| 65 | 65 | // Add Upgraded From Option. | 
| 66 | - $current_version = get_option( 'give_version' ); | |
| 67 | -	if ( $current_version ) { | |
| 68 | - update_option( 'give_version_upgraded_from', $current_version ); | |
| 66 | +	$current_version = get_option('give_version'); | |
| 67 | +	if ($current_version) { | |
| 68 | +		update_option('give_version_upgraded_from', $current_version); | |
| 69 | 69 | } | 
| 70 | 70 | |
| 71 | 71 | // Setup some default options. | 
| 72 | 72 | $options = array(); | 
| 73 | 73 | |
| 74 | 74 | //Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency. | 
| 75 | -	if ( empty( $current_version ) ) { | |
| 76 | - $options = array_merge( $options, give_get_default_settings() ); | |
| 75 | +	if (empty($current_version)) { | |
| 76 | + $options = array_merge($options, give_get_default_settings()); | |
| 77 | 77 | } | 
| 78 | 78 | |
| 79 | 79 | // Populate the default values. | 
| 80 | - update_option( 'give_settings', array_merge( $give_options, $options ) ); | |
| 80 | +	update_option('give_settings', array_merge($give_options, $options)); | |
| 81 | 81 | |
| 82 | 82 | /** | 
| 83 | 83 | * Run plugin upgrades. | 
| 84 | 84 | * | 
| 85 | 85 | * @since 1.8 | 
| 86 | 86 | */ | 
| 87 | - do_action( 'give_upgrades' ); | |
| 87 | +	do_action('give_upgrades'); | |
| 88 | 88 | |
| 89 | -	if ( GIVE_VERSION !== get_option( 'give_version' ) ) { | |
| 90 | - update_option( 'give_version', GIVE_VERSION ); | |
| 89 | +	if (GIVE_VERSION !== get_option('give_version')) { | |
| 90 | +		update_option('give_version', GIVE_VERSION); | |
| 91 | 91 | } | 
| 92 | 92 | |
| 93 | 93 | // Create Give roles. | 
| @@ -98,7 +98,7 @@ discard block | ||
| 98 | 98 | // Set api version, end point and refresh permalink. | 
| 99 | 99 | $api = new Give_API(); | 
| 100 | 100 | $api->add_endpoint(); | 
| 101 | - update_option( 'give_default_api_version', 'v' . $api->get_version() ); | |
| 101 | +	update_option('give_default_api_version', 'v'.$api->get_version()); | |
| 102 | 102 | |
| 103 | 103 | flush_rewrite_rules(); | 
| 104 | 104 | |
| @@ -113,11 +113,11 @@ discard block | ||
| 113 | 113 | $give_sessions->use_php_sessions(); | 
| 114 | 114 | |
| 115 | 115 | // Add a temporary option to note that Give pages have been created. | 
| 116 | - Give_Cache::set( '_give_installed', $options, 30, true ); | |
| 116 | +	Give_Cache::set('_give_installed', $options, 30, true); | |
| 117 | 117 | |
| 118 | -	if ( ! $current_version ) { | |
| 118 | +	if ( ! $current_version) { | |
| 119 | 119 | |
| 120 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; | |
| 120 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; | |
| 121 | 121 | |
| 122 | 122 | // When new upgrade routines are added, mark them as complete on fresh install. | 
| 123 | 123 | $upgrade_routines = array( | 
| @@ -150,18 +150,18 @@ discard block | ||
| 150 | 150 | 'v213_delete_donation_meta' | 
| 151 | 151 | ); | 
| 152 | 152 | |
| 153 | -		foreach ( $upgrade_routines as $upgrade ) { | |
| 154 | - give_set_upgrade_complete( $upgrade ); | |
| 153 | +		foreach ($upgrade_routines as $upgrade) { | |
| 154 | + give_set_upgrade_complete($upgrade); | |
| 155 | 155 | } | 
| 156 | 156 | } | 
| 157 | 157 | |
| 158 | 158 | // Bail if activating from network, or bulk. | 
| 159 | -	if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { | |
| 159 | +	if (is_network_admin() || isset($_GET['activate-multi'])) { | |
| 160 | 160 | return; | 
| 161 | 161 | } | 
| 162 | 162 | |
| 163 | 163 | // Add the transient to redirect. | 
| 164 | - Give_Cache::set( '_give_activation_redirect', true, 30, true ); | |
| 164 | +	Give_Cache::set('_give_activation_redirect', true, 30, true); | |
| 165 | 165 | } | 
| 166 | 166 | |
| 167 | 167 | /** | 
| @@ -179,11 +179,11 @@ discard block | ||
| 179 | 179 | * @param int $site_id The Site ID. | 
| 180 | 180 | * @param array $meta Blog Meta. | 
| 181 | 181 | */ | 
| 182 | -function give_on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { | |
| 182 | +function give_on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) { | |
| 183 | 183 | |
| 184 | -	if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) { | |
| 184 | +	if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) { | |
| 185 | 185 | |
| 186 | - switch_to_blog( $blog_id ); | |
| 186 | + switch_to_blog($blog_id); | |
| 187 | 187 | give_install(); | 
| 188 | 188 | restore_current_blog(); | 
| 189 | 189 | |
| @@ -191,7 +191,7 @@ discard block | ||
| 191 | 191 | |
| 192 | 192 | } | 
| 193 | 193 | |
| 194 | -add_action( 'wpmu_new_blog', 'give_on_create_blog', 10, 6 ); | |
| 194 | +add_action('wpmu_new_blog', 'give_on_create_blog', 10, 6); | |
| 195 | 195 | |
| 196 | 196 | |
| 197 | 197 | /** | 
| @@ -204,13 +204,13 @@ discard block | ||
| 204 | 204 | * | 
| 205 | 205 | * @return array The tables to drop. | 
| 206 | 206 | */ | 
| 207 | -function give_wpmu_drop_tables( $tables, $blog_id ) { | |
| 207 | +function give_wpmu_drop_tables($tables, $blog_id) { | |
| 208 | 208 | |
| 209 | - switch_to_blog( $blog_id ); | |
| 209 | + switch_to_blog($blog_id); | |
| 210 | 210 | $donors_db = new Give_DB_Donors(); | 
| 211 | 211 | $donor_meta_db = new Give_DB_Donor_Meta(); | 
| 212 | 212 | |
| 213 | -	if ( $donors_db->installed() ) { | |
| 213 | +	if ($donors_db->installed()) { | |
| 214 | 214 | $tables[] = $donors_db->table_name; | 
| 215 | 215 | $tables[] = $donor_meta_db->table_name; | 
| 216 | 216 | } | 
| @@ -220,7 +220,7 @@ discard block | ||
| 220 | 220 | |
| 221 | 221 | } | 
| 222 | 222 | |
| 223 | -add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 ); | |
| 223 | +add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2); | |
| 224 | 224 | |
| 225 | 225 | /** | 
| 226 | 226 | * Post-installation | 
| @@ -232,16 +232,16 @@ discard block | ||
| 232 | 232 | */ | 
| 233 | 233 |  function give_after_install() { | 
| 234 | 234 | |
| 235 | -	if ( ! is_admin() ) { | |
| 235 | +	if ( ! is_admin()) { | |
| 236 | 236 | return; | 
| 237 | 237 | } | 
| 238 | 238 | |
| 239 | - $give_options = Give_Cache::get( '_give_installed', true ); | |
| 240 | - $give_table_check = get_option( '_give_table_check', false ); | |
| 239 | +	$give_options     = Give_Cache::get('_give_installed', true); | |
| 240 | +	$give_table_check = get_option('_give_table_check', false); | |
| 241 | 241 | |
| 242 | -	if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) { | |
| 242 | +	if (false === $give_table_check || current_time('timestamp') > $give_table_check) { | |
| 243 | 243 | |
| 244 | -		if ( ! @Give()->donor_meta->installed() ) { | |
| 244 | +		if ( ! @Give()->donor_meta->installed()) { | |
| 245 | 245 | |
| 246 | 246 | // Create the donor meta database. | 
| 247 | 247 | // (this ensures it creates it on multisite instances where it is network activated). | 
| @@ -249,7 +249,7 @@ discard block | ||
| 249 | 249 | |
| 250 | 250 | } | 
| 251 | 251 | |
| 252 | -		if ( ! @Give()->donors->installed() ) { | |
| 252 | +		if ( ! @Give()->donors->installed()) { | |
| 253 | 253 | // Create the donor database. | 
| 254 | 254 | // (this ensures it creates it on multisite instances where it is network activated). | 
| 255 | 255 | @Give()->donors->create_table(); | 
| @@ -261,22 +261,22 @@ discard block | ||
| 261 | 261 | * | 
| 262 | 262 | * @param array $give_options Give plugin options. | 
| 263 | 263 | */ | 
| 264 | - do_action( 'give_after_install', $give_options ); | |
| 264 | +			do_action('give_after_install', $give_options); | |
| 265 | 265 | } | 
| 266 | 266 | |
| 267 | - update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) ); | |
| 267 | +		update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS)); | |
| 268 | 268 | |
| 269 | 269 | } | 
| 270 | 270 | |
| 271 | 271 | // Delete the transient | 
| 272 | -	if ( false !== $give_options ) { | |
| 273 | - Give_Cache::delete( Give_Cache::get_key( '_give_installed' ) ); | |
| 272 | +	if (false !== $give_options) { | |
| 273 | +		Give_Cache::delete(Give_Cache::get_key('_give_installed')); | |
| 274 | 274 | } | 
| 275 | 275 | |
| 276 | 276 | |
| 277 | 277 | } | 
| 278 | 278 | |
| 279 | -add_action( 'admin_init', 'give_after_install' ); | |
| 279 | +add_action('admin_init', 'give_after_install'); | |
| 280 | 280 | |
| 281 | 281 | |
| 282 | 282 | /** | 
| @@ -291,11 +291,11 @@ discard block | ||
| 291 | 291 | |
| 292 | 292 | global $wp_roles; | 
| 293 | 293 | |
| 294 | -	if ( ! is_object( $wp_roles ) ) { | |
| 294 | +	if ( ! is_object($wp_roles)) { | |
| 295 | 295 | return; | 
| 296 | 296 | } | 
| 297 | 297 | |
| 298 | -	if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) { | |
| 298 | +	if ( ! array_key_exists('give_manager', $wp_roles->roles)) { | |
| 299 | 299 | |
| 300 | 300 | // Create Give plugin roles | 
| 301 | 301 | $roles = new Give_Roles(); | 
| @@ -306,7 +306,7 @@ discard block | ||
| 306 | 306 | |
| 307 | 307 | } | 
| 308 | 308 | |
| 309 | -add_action( 'admin_init', 'give_install_roles_on_network' ); | |
| 309 | +add_action('admin_init', 'give_install_roles_on_network'); | |
| 310 | 310 | |
| 311 | 311 | /** | 
| 312 | 312 | * Default core setting values. | 
| @@ -347,14 +347,14 @@ discard block | ||
| 347 | 347 | 'uninstall_on_delete' => 'disabled', | 
| 348 | 348 | 'the_content_filter' => 'enabled', | 
| 349 | 349 | 'scripts_footer' => 'disabled', | 
| 350 | - 'agree_to_terms_label' => __( 'Agree to Terms?', 'give' ), | |
| 350 | +		'agree_to_terms_label'                        => __('Agree to Terms?', 'give'), | |
| 351 | 351 | 'agreement_text' => give_get_default_agreement_text(), | 
| 352 | 352 | |
| 353 | 353 | // Paypal IPN verification. | 
| 354 | 354 | 'paypal_verification' => 'enabled', | 
| 355 | 355 | |
| 356 | 356 | // Default is manual gateway. | 
| 357 | - 'gateways' => array( 'manual' => 1, 'offline' => 1 ), | |
| 357 | +		'gateways'                                    => array('manual' => 1, 'offline' => 1), | |
| 358 | 358 | 'default_gateway' => 'manual', | 
| 359 | 359 | |
| 360 | 360 | // Offline gateway setup. | 
| @@ -382,7 +382,7 @@ discard block | ||
| 382 | 382 | */ | 
| 383 | 383 |  function give_get_default_agreement_text() { | 
| 384 | 384 | |
| 385 | - $org_name = get_bloginfo( 'name' ); | |
| 385 | +	$org_name = get_bloginfo('name'); | |
| 386 | 386 | |
| 387 | 387 | $agreement = sprintf( | 
| 388 | 388 | '<p>Acceptance of any contribution, gift or grant is at the discretion of the %1$s. The %1$s will not accept any gift unless it can be used or expended consistently with the purpose and mission of the %1$s.</p> | 
| @@ -396,7 +396,7 @@ discard block | ||
| 396 | 396 | $org_name | 
| 397 | 397 | ); | 
| 398 | 398 | |
| 399 | - return apply_filters( 'give_get_default_agreement_text', $agreement, $org_name ); | |
| 399 | +	return apply_filters('give_get_default_agreement_text', $agreement, $org_name); | |
| 400 | 400 | } | 
| 401 | 401 | |
| 402 | 402 | |
| @@ -410,19 +410,19 @@ discard block | ||
| 410 | 410 |  function give_create_pages() { | 
| 411 | 411 | |
| 412 | 412 | // Bailout if pages already created. | 
| 413 | -	if ( get_option( 'give_install_pages_created' ) ) { | |
| 413 | +	if (get_option('give_install_pages_created')) { | |
| 414 | 414 | return false; | 
| 415 | 415 | } | 
| 416 | 416 | |
| 417 | 417 | $options = array(); | 
| 418 | 418 | |
| 419 | 419 | // Checks if the Success Page option exists AND that the page exists. | 
| 420 | -	if ( ! get_post( give_get_option( 'success_page' ) ) ) { | |
| 420 | +	if ( ! get_post(give_get_option('success_page'))) { | |
| 421 | 421 | |
| 422 | 422 | // Donation Confirmation (Success) Page | 
| 423 | 423 | $success = wp_insert_post( | 
| 424 | 424 | array( | 
| 425 | - 'post_title' => esc_html__( 'Donation Confirmation', 'give' ), | |
| 425 | +				'post_title'     => esc_html__('Donation Confirmation', 'give'), | |
| 426 | 426 | 'post_content' => '[give_receipt]', | 
| 427 | 427 | 'post_status' => 'publish', | 
| 428 | 428 | 'post_author' => 1, | 
| @@ -436,13 +436,13 @@ discard block | ||
| 436 | 436 | } | 
| 437 | 437 | |
| 438 | 438 | // Checks if the Failure Page option exists AND that the page exists. | 
| 439 | -	if ( ! get_post( give_get_option( 'failure_page' ) ) ) { | |
| 439 | +	if ( ! get_post(give_get_option('failure_page'))) { | |
| 440 | 440 | |
| 441 | 441 | // Failed Donation Page | 
| 442 | 442 | $failed = wp_insert_post( | 
| 443 | 443 | array( | 
| 444 | - 'post_title' => esc_html__( 'Donation Failed', 'give' ), | |
| 445 | - 'post_content' => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ), | |
| 444 | +				'post_title'     => esc_html__('Donation Failed', 'give'), | |
| 445 | +				'post_content'   => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'), | |
| 446 | 446 | 'post_status' => 'publish', | 
| 447 | 447 | 'post_author' => 1, | 
| 448 | 448 | 'post_type' => 'page', | 
| @@ -454,11 +454,11 @@ discard block | ||
| 454 | 454 | } | 
| 455 | 455 | |
| 456 | 456 | // Checks if the History Page option exists AND that the page exists. | 
| 457 | -	if ( ! get_post( give_get_option( 'history_page' ) ) ) { | |
| 457 | +	if ( ! get_post(give_get_option('history_page'))) { | |
| 458 | 458 | // Donation History Page | 
| 459 | 459 | $history = wp_insert_post( | 
| 460 | 460 | array( | 
| 461 | - 'post_title' => esc_html__( 'Donation History', 'give' ), | |
| 461 | +				'post_title'     => esc_html__('Donation History', 'give'), | |
| 462 | 462 | 'post_content' => '[donation_history]', | 
| 463 | 463 | 'post_status' => 'publish', | 
| 464 | 464 | 'post_author' => 1, | 
| @@ -470,11 +470,11 @@ discard block | ||
| 470 | 470 | $options['history_page'] = $history; | 
| 471 | 471 | } | 
| 472 | 472 | |
| 473 | -	if ( ! empty( $options ) ) { | |
| 474 | - update_option( 'give_settings', array_merge( give_get_settings(), $options ) ); | |
| 473 | +	if ( ! empty($options)) { | |
| 474 | +		update_option('give_settings', array_merge(give_get_settings(), $options)); | |
| 475 | 475 | } | 
| 476 | 476 | |
| 477 | - add_option( 'give_install_pages_created', 1, '', 'no' ); | |
| 477 | +	add_option('give_install_pages_created', 1, '', 'no'); | |
| 478 | 478 | } | 
| 479 | 479 | |
| 480 | -add_action( 'admin_init', 'give_create_pages', - 1 ); | |
| 480 | +add_action('admin_init', 'give_create_pages', - 1); | |
| @@ -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 | |
| @@ -21,14 +21,14 @@ discard block | ||
| 21 | 21 | * | 
| 22 | 22 | * @param $data | 
| 23 | 23 | */ | 
| 24 | -function give_process_gateway_select( $data ) { | |
| 25 | -	if ( isset( $_POST['gateway_submit'] ) ) { | |
| 26 | - wp_redirect( esc_url( add_query_arg( 'payment-mode', $_POST['payment-mode'] ) ) ); | |
| 24 | +function give_process_gateway_select($data) { | |
| 25 | +	if (isset($_POST['gateway_submit'])) { | |
| 26 | +		wp_redirect(esc_url(add_query_arg('payment-mode', $_POST['payment-mode']))); | |
| 27 | 27 | exit; | 
| 28 | 28 | } | 
| 29 | 29 | } | 
| 30 | 30 | |
| 31 | -add_action( 'give_gateway_select', 'give_process_gateway_select' ); | |
| 31 | +add_action('give_gateway_select', 'give_process_gateway_select'); | |
| 32 | 32 | |
| 33 | 33 | /** | 
| 34 | 34 | * Loads a payment gateway via AJAX. | 
| @@ -39,11 +39,11 @@ discard block | ||
| 39 | 39 | */ | 
| 40 | 40 |  function give_load_ajax_gateway() { | 
| 41 | 41 | |
| 42 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, CSRF ok. | |
| 42 | + $post_data = give_clean($_POST); // WPCS: input var ok, CSRF ok. | |
| 43 | 43 | |
| 44 | -	if ( isset( $post_data['give_payment_mode'] ) ) { | |
| 44 | +	if (isset($post_data['give_payment_mode'])) { | |
| 45 | 45 | |
| 46 | - $form_id_prefix = ! empty( $post_data['give_form_id_prefix'] ) ? $post_data['give_form_id_prefix'] : ''; | |
| 46 | + $form_id_prefix = ! empty($post_data['give_form_id_prefix']) ? $post_data['give_form_id_prefix'] : ''; | |
| 47 | 47 | |
| 48 | 48 | $args = array( | 
| 49 | 49 | 'id_prefix' => $form_id_prefix, | 
| @@ -54,14 +54,14 @@ discard block | ||
| 54 | 54 | * | 
| 55 | 55 | * @since 1.7 | 
| 56 | 56 | */ | 
| 57 | - do_action( 'give_donation_form', $post_data['give_form_id'], $args ); | |
| 57 | +		do_action('give_donation_form', $post_data['give_form_id'], $args); | |
| 58 | 58 | |
| 59 | 59 | exit(); | 
| 60 | 60 | } | 
| 61 | 61 | } | 
| 62 | 62 | |
| 63 | -add_action( 'wp_ajax_give_load_gateway', 'give_load_ajax_gateway' ); | |
| 64 | -add_action( 'wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway' ); | |
| 63 | +add_action('wp_ajax_give_load_gateway', 'give_load_ajax_gateway'); | |
| 64 | +add_action('wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway'); | |
| 65 | 65 | |
| 66 | 66 | /** | 
| 67 | 67 | * Create wp nonce using Ajax call. | 
| @@ -73,18 +73,18 @@ discard block | ||
| 73 | 73 | * @return void | 
| 74 | 74 | */ | 
| 75 | 75 |  function give_donation_form_nonce() { | 
| 76 | -	if ( isset( $_POST['give_form_id'] ) ) { | |
| 76 | +	if (isset($_POST['give_form_id'])) { | |
| 77 | 77 | |
| 78 | 78 | // Get donation form id. | 
| 79 | - $form_id = is_numeric( $_POST['give_form_id'] ) ? absint( $_POST['give_form_id'] ) : 0; | |
| 79 | + $form_id = is_numeric($_POST['give_form_id']) ? absint($_POST['give_form_id']) : 0; | |
| 80 | 80 | |
| 81 | 81 | // Send nonce json data. | 
| 82 | -		wp_send_json_success( wp_create_nonce( "give_donation_form_nonce_{$form_id}" ) ); | |
| 82 | +		wp_send_json_success(wp_create_nonce("give_donation_form_nonce_{$form_id}")); | |
| 83 | 83 | } | 
| 84 | 84 | } | 
| 85 | 85 | |
| 86 | -add_action( 'wp_ajax_give_donation_form_nonce', 'give_donation_form_nonce' ); | |
| 87 | -add_action( 'wp_ajax_nopriv_give_donation_form_nonce', 'give_donation_form_nonce' ); | |
| 86 | +add_action('wp_ajax_give_donation_form_nonce', 'give_donation_form_nonce'); | |
| 87 | +add_action('wp_ajax_nopriv_give_donation_form_nonce', 'give_donation_form_nonce'); | |
| 88 | 88 | |
| 89 | 89 | /** | 
| 90 | 90 | * Sets an error within the donation form if no gateways are enabled. | 
| @@ -97,11 +97,11 @@ discard block | ||
| 97 | 97 |  function give_no_gateway_error() { | 
| 98 | 98 | $gateways = give_get_enabled_payment_gateways(); | 
| 99 | 99 | |
| 100 | -	if ( empty( $gateways ) ) { | |
| 101 | - give_set_error( 'no_gateways', esc_html__( 'You must enable a payment gateway to use Give.', 'give' ) ); | |
| 100 | +	if (empty($gateways)) { | |
| 101 | +		give_set_error('no_gateways', esc_html__('You must enable a payment gateway to use Give.', 'give')); | |
| 102 | 102 |  	} else { | 
| 103 | - give_unset_error( 'no_gateways' ); | |
| 103 | +		give_unset_error('no_gateways'); | |
| 104 | 104 | } | 
| 105 | 105 | } | 
| 106 | 106 | |
| 107 | -add_action( 'init', 'give_no_gateway_error' ); | |
| 107 | +add_action('init', 'give_no_gateway_error'); | |
| @@ -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 | |
| @@ -141,27 +141,27 @@ discard block | ||
| 141 | 141 | 'v1' => 'GIVE_API_V1', | 
| 142 | 142 | ); | 
| 143 | 143 | |
| 144 | -		foreach ( $this->get_versions() as $version => $class ) { | |
| 145 | - require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-' . $version . '.php'; | |
| 144 | +		foreach ($this->get_versions() as $version => $class) { | |
| 145 | + require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api-'.$version.'.php'; | |
| 146 | 146 | } | 
| 147 | 147 | |
| 148 | - add_action( 'init', array( $this, 'add_endpoint' ) ); | |
| 149 | - add_action( 'wp', array( $this, 'process_query' ), - 1 ); | |
| 150 | - add_filter( 'query_vars', array( $this, 'query_vars' ) ); | |
| 151 | - add_action( 'show_user_profile', array( $this, 'user_key_field' ) ); | |
| 152 | - add_action( 'edit_user_profile', array( $this, 'user_key_field' ) ); | |
| 153 | - add_action( 'personal_options_update', array( $this, 'generate_api_key' ) ); | |
| 154 | - add_action( 'edit_user_profile_update', array( $this, 'generate_api_key' ) ); | |
| 155 | - add_action( 'give_process_api_key', array( $this, 'process_api_key' ) ); | |
| 148 | +		add_action('init', array($this, 'add_endpoint')); | |
| 149 | +		add_action('wp', array($this, 'process_query'), - 1); | |
| 150 | +		add_filter('query_vars', array($this, 'query_vars')); | |
| 151 | +		add_action('show_user_profile', array($this, 'user_key_field')); | |
| 152 | +		add_action('edit_user_profile', array($this, 'user_key_field')); | |
| 153 | +		add_action('personal_options_update', array($this, 'generate_api_key')); | |
| 154 | +		add_action('edit_user_profile_update', array($this, 'generate_api_key')); | |
| 155 | +		add_action('give_process_api_key', array($this, 'process_api_key')); | |
| 156 | 156 | |
| 157 | 157 | // Setup a backwards compatibility check for user API Keys | 
| 158 | - add_filter( 'get_user_metadata', array( $this, 'api_key_backwards_compat' ), 10, 4 ); | |
| 158 | +		add_filter('get_user_metadata', array($this, 'api_key_backwards_compat'), 10, 4); | |
| 159 | 159 | |
| 160 | 160 | // Determine if JSON_PRETTY_PRINT is available | 
| 161 | - $this->pretty_print = defined( 'JSON_PRETTY_PRINT' ) ? JSON_PRETTY_PRINT : null; | |
| 161 | +		$this->pretty_print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null; | |
| 162 | 162 | |
| 163 | 163 | // Allow API request logging to be turned off | 
| 164 | - $this->log_requests = apply_filters( 'give_api_log_requests', $this->log_requests ); | |
| 164 | +		$this->log_requests = apply_filters('give_api_log_requests', $this->log_requests); | |
| 165 | 165 | |
| 166 | 166 | // Setup Give_Payment_Stats instance | 
| 167 | 167 | $this->stats = new Give_Payment_Stats(); | 
| @@ -179,17 +179,17 @@ discard block | ||
| 179 | 179 | * | 
| 180 | 180 | * @return mixed | 
| 181 | 181 | */ | 
| 182 | -	public function __call( $name, $arguments ) { | |
| 182 | +	public function __call($name, $arguments) { | |
| 183 | 183 | $deprecated_function_arr = array( | 
| 184 | 184 | 'get_customers', | 
| 185 | 185 | ); | 
| 186 | 186 | |
| 187 | -		if ( in_array( $name, $deprecated_function_arr, true ) ) { | |
| 188 | -			switch ( $name ) { | |
| 187 | +		if (in_array($name, $deprecated_function_arr, true)) { | |
| 188 | +			switch ($name) { | |
| 189 | 189 | case 'get_customers': | 
| 190 | - $args = ! empty( $arguments[0] ) ? $arguments[0] : array(); | |
| 190 | + $args = ! empty($arguments[0]) ? $arguments[0] : array(); | |
| 191 | 191 | |
| 192 | - return $this->get_donors( $args ); | |
| 192 | + return $this->get_donors($args); | |
| 193 | 193 | } | 
| 194 | 194 | } | 
| 195 | 195 | } | 
| @@ -202,7 +202,7 @@ discard block | ||
| 202 | 202 | * @since 1.1 | 
| 203 | 203 | */ | 
| 204 | 204 |  	public function add_endpoint() { | 
| 205 | - add_rewrite_endpoint( 'give-api', EP_ALL ); | |
| 205 | +		add_rewrite_endpoint('give-api', EP_ALL); | |
| 206 | 206 | } | 
| 207 | 207 | |
| 208 | 208 | /** | 
| @@ -215,7 +215,7 @@ discard block | ||
| 215 | 215 | * | 
| 216 | 216 | * @return string[] $vars New query vars | 
| 217 | 217 | */ | 
| 218 | -	public function query_vars( $vars ) { | |
| 218 | +	public function query_vars($vars) { | |
| 219 | 219 | |
| 220 | 220 | $vars[] = 'token'; | 
| 221 | 221 | $vars[] = 'key'; | 
| @@ -266,11 +266,11 @@ discard block | ||
| 266 | 266 | */ | 
| 267 | 267 |  	public function get_default_version() { | 
| 268 | 268 | |
| 269 | - $version = get_option( 'give_default_api_version' ); | |
| 269 | +		$version = get_option('give_default_api_version'); | |
| 270 | 270 | |
| 271 | -		if ( defined( 'GIVE_API_VERSION' ) ) { | |
| 271 | +		if (defined('GIVE_API_VERSION')) { | |
| 272 | 272 | $version = GIVE_API_VERSION; | 
| 273 | -		} elseif ( ! $version ) { | |
| 273 | +		} elseif ( ! $version) { | |
| 274 | 274 | $version = 'v1'; | 
| 275 | 275 | } | 
| 276 | 276 | |
| @@ -291,14 +291,14 @@ discard block | ||
| 291 | 291 | |
| 292 | 292 | $version = $wp_query->query_vars['give-api']; | 
| 293 | 293 | |
| 294 | -		if ( strpos( $version, '/' ) ) { | |
| 294 | +		if (strpos($version, '/')) { | |
| 295 | 295 | |
| 296 | - $version = explode( '/', $version ); | |
| 297 | - $version = strtolower( $version[0] ); | |
| 296 | +			$version = explode('/', $version); | |
| 297 | + $version = strtolower($version[0]); | |
| 298 | 298 | |
| 299 | - $wp_query->query_vars['give-api'] = str_replace( $version . '/', '', $wp_query->query_vars['give-api'] ); | |
| 299 | + $wp_query->query_vars['give-api'] = str_replace($version.'/', '', $wp_query->query_vars['give-api']); | |
| 300 | 300 | |
| 301 | -			if ( array_key_exists( $version, $this->versions ) ) { | |
| 301 | +			if (array_key_exists($version, $this->versions)) { | |
| 302 | 302 | |
| 303 | 303 | $this->queried_version = $version; | 
| 304 | 304 | |
| @@ -334,16 +334,16 @@ discard block | ||
| 334 | 334 | $this->override = false; | 
| 335 | 335 | |
| 336 | 336 | // Make sure we have both user and api key | 
| 337 | -		if ( ! empty( $wp_query->query_vars['give-api'] ) && ( $wp_query->query_vars['give-api'] !== 'forms' || ! empty( $wp_query->query_vars['token'] ) ) ) { | |
| 337 | +		if ( ! empty($wp_query->query_vars['give-api']) && ($wp_query->query_vars['give-api'] !== 'forms' || ! empty($wp_query->query_vars['token']))) { | |
| 338 | 338 | |
| 339 | -			if ( empty( $wp_query->query_vars['token'] ) || empty( $wp_query->query_vars['key'] ) ) { | |
| 339 | +			if (empty($wp_query->query_vars['token']) || empty($wp_query->query_vars['key'])) { | |
| 340 | 340 | $this->missing_auth(); | 
| 341 | 341 | |
| 342 | 342 | return false; | 
| 343 | 343 | } | 
| 344 | 344 | |
| 345 | 345 | // Retrieve the user by public API key and ensure they exist | 
| 346 | -			if ( ! ( $user = $this->get_user( $wp_query->query_vars['key'] ) ) ) { | |
| 346 | +			if ( ! ($user = $this->get_user($wp_query->query_vars['key']))) { | |
| 347 | 347 | |
| 348 | 348 | $this->invalid_key(); | 
| 349 | 349 | |
| @@ -351,11 +351,11 @@ discard block | ||
| 351 | 351 | |
| 352 | 352 |  			} else { | 
| 353 | 353 | |
| 354 | - $token = urldecode( $wp_query->query_vars['token'] ); | |
| 355 | - $secret = $this->get_user_secret_key( $user ); | |
| 356 | - $public = urldecode( $wp_query->query_vars['key'] ); | |
| 354 | + $token = urldecode($wp_query->query_vars['token']); | |
| 355 | + $secret = $this->get_user_secret_key($user); | |
| 356 | + $public = urldecode($wp_query->query_vars['key']); | |
| 357 | 357 | |
| 358 | -				if ( hash_equals( md5( $secret . $public ), $token ) ) { | |
| 358 | +				if (hash_equals(md5($secret.$public), $token)) { | |
| 359 | 359 | $this->is_valid_request = true; | 
| 360 | 360 |  				} else { | 
| 361 | 361 | $this->invalid_auth(); | 
| @@ -364,9 +364,9 @@ discard block | ||
| 364 | 364 | } | 
| 365 | 365 | |
| 366 | 366 | } | 
| 367 | -		} elseif ( ! empty( $wp_query->query_vars['give-api'] ) && $wp_query->query_vars['give-api'] === 'forms' ) { | |
| 367 | +		} elseif ( ! empty($wp_query->query_vars['give-api']) && $wp_query->query_vars['give-api'] === 'forms') { | |
| 368 | 368 | $this->is_valid_request = true; | 
| 369 | - $wp_query->set( 'key', 'public' ); | |
| 369 | +			$wp_query->set('key', 'public'); | |
| 370 | 370 | } | 
| 371 | 371 | } | 
| 372 | 372 | |
| @@ -382,25 +382,25 @@ discard block | ||
| 382 | 382 | * | 
| 383 | 383 | * @return bool if user ID is found, false otherwise | 
| 384 | 384 | */ | 
| 385 | -	public function get_user( $key = '' ) { | |
| 385 | +	public function get_user($key = '') { | |
| 386 | 386 | global $wpdb, $wp_query; | 
| 387 | 387 | |
| 388 | -		if ( empty( $key ) ) { | |
| 389 | - $key = urldecode( $wp_query->query_vars['key'] ); | |
| 388 | +		if (empty($key)) { | |
| 389 | + $key = urldecode($wp_query->query_vars['key']); | |
| 390 | 390 | } | 
| 391 | 391 | |
| 392 | -		if ( empty( $key ) ) { | |
| 392 | +		if (empty($key)) { | |
| 393 | 393 | return false; | 
| 394 | 394 | } | 
| 395 | 395 | |
| 396 | - $user = Give_Cache::get( md5( 'give_api_user_' . $key ), true ); | |
| 396 | +		$user = Give_Cache::get(md5('give_api_user_'.$key), true); | |
| 397 | 397 | |
| 398 | -		if ( false === $user ) { | |
| 399 | - $user = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key ) ); | |
| 400 | - Give_Cache::set( md5( 'give_api_user_' . $key ), $user, DAY_IN_SECONDS, true ); | |
| 398 | +		if (false === $user) { | |
| 399 | +			$user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key)); | |
| 400 | +			Give_Cache::set(md5('give_api_user_'.$key), $user, DAY_IN_SECONDS, true); | |
| 401 | 401 | } | 
| 402 | 402 | |
| 403 | -		if ( $user != null ) { | |
| 403 | +		if ($user != null) { | |
| 404 | 404 | $this->user_id = $user; | 
| 405 | 405 | |
| 406 | 406 | return $user; | 
| @@ -416,19 +416,19 @@ discard block | ||
| 416 | 416 | * | 
| 417 | 417 | * @return mixed|null|string | 
| 418 | 418 | */ | 
| 419 | -	public function get_user_public_key( $user_id = 0 ) { | |
| 419 | +	public function get_user_public_key($user_id = 0) { | |
| 420 | 420 | global $wpdb; | 
| 421 | 421 | |
| 422 | -		if ( empty( $user_id ) ) { | |
| 422 | +		if (empty($user_id)) { | |
| 423 | 423 | return ''; | 
| 424 | 424 | } | 
| 425 | 425 | |
| 426 | - $cache_key = md5( 'give_api_user_public_key' . $user_id ); | |
| 427 | - $user_public_key = Give_Cache::get( $cache_key, true ); | |
| 426 | +		$cache_key       = md5('give_api_user_public_key'.$user_id); | |
| 427 | + $user_public_key = Give_Cache::get($cache_key, true); | |
| 428 | 428 | |
| 429 | -		if ( empty( $user_public_key ) ) { | |
| 430 | - $user_public_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id ) ); | |
| 431 | - Give_Cache::set( $cache_key, $user_public_key, HOUR_IN_SECONDS, true ); | |
| 429 | +		if (empty($user_public_key)) { | |
| 430 | +			$user_public_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id)); | |
| 431 | + Give_Cache::set($cache_key, $user_public_key, HOUR_IN_SECONDS, true); | |
| 432 | 432 | } | 
| 433 | 433 | |
| 434 | 434 | return $user_public_key; | 
| @@ -441,19 +441,19 @@ discard block | ||
| 441 | 441 | * | 
| 442 | 442 | * @return mixed|null|string | 
| 443 | 443 | */ | 
| 444 | -	public function get_user_secret_key( $user_id = 0 ) { | |
| 444 | +	public function get_user_secret_key($user_id = 0) { | |
| 445 | 445 | global $wpdb; | 
| 446 | 446 | |
| 447 | -		if ( empty( $user_id ) ) { | |
| 447 | +		if (empty($user_id)) { | |
| 448 | 448 | return ''; | 
| 449 | 449 | } | 
| 450 | 450 | |
| 451 | - $cache_key = md5( 'give_api_user_secret_key' . $user_id ); | |
| 452 | - $user_secret_key = Give_Cache::get( $cache_key, true ); | |
| 451 | +		$cache_key       = md5('give_api_user_secret_key'.$user_id); | |
| 452 | + $user_secret_key = Give_Cache::get($cache_key, true); | |
| 453 | 453 | |
| 454 | -		if ( empty( $user_secret_key ) ) { | |
| 455 | - $user_secret_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id ) ); | |
| 456 | - Give_Cache::set( $cache_key, $user_secret_key, HOUR_IN_SECONDS, true ); | |
| 454 | +		if (empty($user_secret_key)) { | |
| 455 | +			$user_secret_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id)); | |
| 456 | + Give_Cache::set($cache_key, $user_secret_key, HOUR_IN_SECONDS, true); | |
| 457 | 457 | } | 
| 458 | 458 | |
| 459 | 459 | return $user_secret_key; | 
| @@ -469,10 +469,10 @@ discard block | ||
| 469 | 469 | */ | 
| 470 | 470 |  	private function missing_auth() { | 
| 471 | 471 | $error = array(); | 
| 472 | - $error['error'] = __( 'You must specify both a token and API key.', 'give' ); | |
| 472 | +		$error['error'] = __('You must specify both a token and API key.', 'give'); | |
| 473 | 473 | |
| 474 | 474 | $this->data = $error; | 
| 475 | - $this->output( 401 ); | |
| 475 | + $this->output(401); | |
| 476 | 476 | } | 
| 477 | 477 | |
| 478 | 478 | /** | 
| @@ -486,10 +486,10 @@ discard block | ||
| 486 | 486 | */ | 
| 487 | 487 |  	private function invalid_auth() { | 
| 488 | 488 | $error = array(); | 
| 489 | - $error['error'] = __( 'Your request could not be authenticated.', 'give' ); | |
| 489 | +		$error['error'] = __('Your request could not be authenticated.', 'give'); | |
| 490 | 490 | |
| 491 | 491 | $this->data = $error; | 
| 492 | - $this->output( 403 ); | |
| 492 | + $this->output(403); | |
| 493 | 493 | } | 
| 494 | 494 | |
| 495 | 495 | /** | 
| @@ -503,10 +503,10 @@ discard block | ||
| 503 | 503 | */ | 
| 504 | 504 |  	private function invalid_key() { | 
| 505 | 505 | $error = array(); | 
| 506 | - $error['error'] = __( 'Invalid API key.', 'give' ); | |
| 506 | +		$error['error'] = __('Invalid API key.', 'give'); | |
| 507 | 507 | |
| 508 | 508 | $this->data = $error; | 
| 509 | - $this->output( 403 ); | |
| 509 | + $this->output(403); | |
| 510 | 510 | } | 
| 511 | 511 | |
| 512 | 512 | /** | 
| @@ -519,10 +519,10 @@ discard block | ||
| 519 | 519 | */ | 
| 520 | 520 |  	private function invalid_version() { | 
| 521 | 521 | $error = array(); | 
| 522 | - $error['error'] = __( 'Invalid API version.', 'give' ); | |
| 522 | +		$error['error'] = __('Invalid API version.', 'give'); | |
| 523 | 523 | |
| 524 | 524 | $this->data = $error; | 
| 525 | - $this->output( 404 ); | |
| 525 | + $this->output(404); | |
| 526 | 526 | } | 
| 527 | 527 | |
| 528 | 528 | /** | 
| @@ -538,10 +538,10 @@ discard block | ||
| 538 | 538 | global $wp_query; | 
| 539 | 539 | |
| 540 | 540 | // Start logging how long the request takes for logging | 
| 541 | - $before = microtime( true ); | |
| 541 | + $before = microtime(true); | |
| 542 | 542 | |
| 543 | 543 | // Check for give-api var. Get out if not present | 
| 544 | -		if ( empty( $wp_query->query_vars['give-api'] ) ) { | |
| 544 | +		if (empty($wp_query->query_vars['give-api'])) { | |
| 545 | 545 | return; | 
| 546 | 546 | } | 
| 547 | 547 | |
| @@ -555,45 +555,45 @@ discard block | ||
| 555 | 555 | $this->validate_request(); | 
| 556 | 556 | |
| 557 | 557 | // Only proceed if no errors have been noted | 
| 558 | -		if ( ! $this->is_valid_request ) { | |
| 558 | +		if ( ! $this->is_valid_request) { | |
| 559 | 559 | return; | 
| 560 | 560 | } | 
| 561 | 561 | |
| 562 | -		if ( ! defined( 'GIVE_DOING_API' ) ) { | |
| 563 | - define( 'GIVE_DOING_API', true ); | |
| 562 | +		if ( ! defined('GIVE_DOING_API')) { | |
| 563 | +			define('GIVE_DOING_API', true); | |
| 564 | 564 | } | 
| 565 | 565 | |
| 566 | 566 | $data = array(); | 
| 567 | 567 | $this->routes = new $this->versions[$this->get_queried_version()]; | 
| 568 | 568 | $this->routes->validate_request(); | 
| 569 | 569 | |
| 570 | - switch ( $this->endpoint ) : | |
| 570 | + switch ($this->endpoint) : | |
| 571 | 571 | |
| 572 | 572 | case 'stats' : | 
| 573 | 573 | |
| 574 | - $data = $this->routes->get_stats( array( | |
| 575 | - 'type' => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null, | |
| 576 | - 'form' => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null, | |
| 577 | - 'date' => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null, | |
| 578 | - 'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null, | |
| 579 | - 'enddate' => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null, | |
| 580 | - ) ); | |
| 574 | + $data = $this->routes->get_stats(array( | |
| 575 | + 'type' => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null, | |
| 576 | + 'form' => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null, | |
| 577 | + 'date' => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null, | |
| 578 | + 'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null, | |
| 579 | + 'enddate' => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null, | |
| 580 | + )); | |
| 581 | 581 | |
| 582 | 582 | break; | 
| 583 | 583 | |
| 584 | 584 | case 'forms' : | 
| 585 | 585 | |
| 586 | - $form = isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null; | |
| 586 | + $form = isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null; | |
| 587 | 587 | |
| 588 | - $data = $this->routes->get_forms( $form ); | |
| 588 | + $data = $this->routes->get_forms($form); | |
| 589 | 589 | |
| 590 | 590 | break; | 
| 591 | 591 | |
| 592 | 592 | case 'donors' : | 
| 593 | 593 | |
| 594 | - $donor = isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null; | |
| 594 | + $donor = isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null; | |
| 595 | 595 | |
| 596 | - $data = $this->routes->get_donors( $donor ); | |
| 596 | + $data = $this->routes->get_donors($donor); | |
| 597 | 597 | |
| 598 | 598 | break; | 
| 599 | 599 | |
| @@ -606,26 +606,26 @@ discard block | ||
| 606 | 606 | * @params date startdate | required when date = range and format to be YYYYMMDD (i.e. 20170524) | 
| 607 | 607 | * @params date enddate | required when date = range and format to be YYYYMMDD (i.e. 20170524) | 
| 608 | 608 | */ | 
| 609 | - $data = $this->routes->get_recent_donations( array( | |
| 610 | - 'id' => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null, | |
| 611 | - 'date' => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null, | |
| 612 | - 'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null, | |
| 613 | - 'enddate' => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null, | |
| 614 | - ) ); | |
| 609 | + $data = $this->routes->get_recent_donations(array( | |
| 610 | + 'id' => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null, | |
| 611 | + 'date' => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null, | |
| 612 | + 'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null, | |
| 613 | + 'enddate' => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null, | |
| 614 | + )); | |
| 615 | 615 | |
| 616 | 616 | break; | 
| 617 | 617 | |
| 618 | 618 | endswitch; | 
| 619 | 619 | |
| 620 | 620 | // Allow extensions to setup their own return data | 
| 621 | - $this->data = apply_filters( 'give_api_output_data', $data, $this->endpoint, $this ); | |
| 621 | +		$this->data = apply_filters('give_api_output_data', $data, $this->endpoint, $this); | |
| 622 | 622 | |
| 623 | - $after = microtime( true ); | |
| 624 | - $request_time = ( $after - $before ); | |
| 623 | + $after = microtime(true); | |
| 624 | + $request_time = ($after - $before); | |
| 625 | 625 | $this->data['request_speed'] = $request_time; | 
| 626 | 626 | |
| 627 | 627 | // Log this API request, if enabled. We log it here because we have access to errors. | 
| 628 | - $this->log_request( $this->data ); | |
| 628 | + $this->log_request($this->data); | |
| 629 | 629 | |
| 630 | 630 | // Send out data to the output function | 
| 631 | 631 | $this->output(); | 
| @@ -655,25 +655,25 @@ discard block | ||
| 655 | 655 | global $wp_query; | 
| 656 | 656 | |
| 657 | 657 | // Whitelist our query options | 
| 658 | - $accepted = apply_filters( 'give_api_valid_query_modes', array( | |
| 658 | +		$accepted = apply_filters('give_api_valid_query_modes', array( | |
| 659 | 659 | 'stats', | 
| 660 | 660 | 'forms', | 
| 661 | 661 | 'donors', | 
| 662 | 662 | 'donations', | 
| 663 | - ) ); | |
| 663 | + )); | |
| 664 | 664 | |
| 665 | - $query = isset( $wp_query->query_vars['give-api'] ) ? $wp_query->query_vars['give-api'] : null; | |
| 666 | - $query = str_replace( $this->queried_version . '/', '', $query ); | |
| 665 | + $query = isset($wp_query->query_vars['give-api']) ? $wp_query->query_vars['give-api'] : null; | |
| 666 | + $query = str_replace($this->queried_version.'/', '', $query); | |
| 667 | 667 | |
| 668 | 668 | $error = array(); | 
| 669 | 669 | |
| 670 | 670 | // Make sure our query is valid | 
| 671 | -		if ( ! in_array( $query, $accepted ) ) { | |
| 672 | - $error['error'] = __( 'Invalid query.', 'give' ); | |
| 671 | +		if ( ! in_array($query, $accepted)) { | |
| 672 | +			$error['error'] = __('Invalid query.', 'give'); | |
| 673 | 673 | |
| 674 | 674 | $this->data = $error; | 
| 675 | 675 | // 400 is Bad Request | 
| 676 | - $this->output( 400 ); | |
| 676 | + $this->output(400); | |
| 677 | 677 | } | 
| 678 | 678 | |
| 679 | 679 | $this->endpoint = $query; | 
| @@ -690,7 +690,7 @@ discard block | ||
| 690 | 690 |  	public function get_paged() { | 
| 691 | 691 | global $wp_query; | 
| 692 | 692 | |
| 693 | - return isset( $wp_query->query_vars['page'] ) ? $wp_query->query_vars['page'] : 1; | |
| 693 | + return isset($wp_query->query_vars['page']) ? $wp_query->query_vars['page'] : 1; | |
| 694 | 694 | } | 
| 695 | 695 | |
| 696 | 696 | |
| @@ -705,13 +705,13 @@ discard block | ||
| 705 | 705 |  	public function per_page() { | 
| 706 | 706 | global $wp_query; | 
| 707 | 707 | |
| 708 | - $per_page = isset( $wp_query->query_vars['number'] ) ? $wp_query->query_vars['number'] : 10; | |
| 708 | + $per_page = isset($wp_query->query_vars['number']) ? $wp_query->query_vars['number'] : 10; | |
| 709 | 709 | |
| 710 | -		if ( $per_page < 0 && $this->get_query_mode() == 'donors' ) { | |
| 710 | +		if ($per_page < 0 && $this->get_query_mode() == 'donors') { | |
| 711 | 711 | $per_page = 99999999; | 
| 712 | 712 | } // End if(). | 
| 713 | 713 | |
| 714 | - return apply_filters( 'give_api_results_per_page', $per_page ); | |
| 714 | +		return apply_filters('give_api_results_per_page', $per_page); | |
| 715 | 715 | } | 
| 716 | 716 | |
| 717 | 717 | /** | 
| @@ -724,7 +724,7 @@ discard block | ||
| 724 | 724 | * | 
| 725 | 725 | * @return array $dates | 
| 726 | 726 | */ | 
| 727 | -	public function get_dates( $args = array() ) { | |
| 727 | +	public function get_dates($args = array()) { | |
| 728 | 728 | $dates = array(); | 
| 729 | 729 | |
| 730 | 730 | $defaults = array( | 
| @@ -735,60 +735,60 @@ discard block | ||
| 735 | 735 | 'enddate' => null, | 
| 736 | 736 | ); | 
| 737 | 737 | |
| 738 | - $args = wp_parse_args( $args, $defaults ); | |
| 738 | + $args = wp_parse_args($args, $defaults); | |
| 739 | 739 | |
| 740 | - $current_time = current_time( 'timestamp' ); | |
| 740 | +		$current_time = current_time('timestamp'); | |
| 741 | 741 | |
| 742 | -		if ( 'range' === $args['date'] ) { | |
| 743 | - $startdate = strtotime( $args['startdate'] ); | |
| 744 | - $enddate = strtotime( $args['enddate'] ); | |
| 745 | - $dates['day_start'] = date( 'd', $startdate ); | |
| 746 | - $dates['day_end'] = date( 'd', $enddate ); | |
| 747 | - $dates['m_start'] = date( 'n', $startdate ); | |
| 748 | - $dates['m_end'] = date( 'n', $enddate ); | |
| 749 | - $dates['year'] = date( 'Y', $startdate ); | |
| 750 | - $dates['year_end'] = date( 'Y', $enddate ); | |
| 742 | +		if ('range' === $args['date']) { | |
| 743 | + $startdate = strtotime($args['startdate']); | |
| 744 | + $enddate = strtotime($args['enddate']); | |
| 745 | +			$dates['day_start'] = date('d', $startdate); | |
| 746 | +			$dates['day_end']   = date('d', $enddate); | |
| 747 | +			$dates['m_start']   = date('n', $startdate); | |
| 748 | +			$dates['m_end']     = date('n', $enddate); | |
| 749 | +			$dates['year']      = date('Y', $startdate); | |
| 750 | +			$dates['year_end']  = date('Y', $enddate); | |
| 751 | 751 |  		} else { | 
| 752 | 752 | // Modify dates based on predefined ranges | 
| 753 | - switch ( $args['date'] ) : | |
| 753 | + switch ($args['date']) : | |
| 754 | 754 | |
| 755 | 755 | case 'this_month' : | 
| 756 | 756 | $dates['day'] = null; | 
| 757 | - $dates['m_start'] = date( 'n', $current_time ); | |
| 758 | - $dates['m_end'] = date( 'n', $current_time ); | |
| 759 | - $dates['year'] = date( 'Y', $current_time ); | |
| 757 | +					$dates['m_start'] = date('n', $current_time); | |
| 758 | +					$dates['m_end']   = date('n', $current_time); | |
| 759 | +					$dates['year']    = date('Y', $current_time); | |
| 760 | 760 | break; | 
| 761 | 761 | |
| 762 | 762 | case 'last_month' : | 
| 763 | 763 | $dates['day'] = null; | 
| 764 | - $dates['m_start'] = date( 'n', $current_time ) == 1 ? 12 : date( 'n', $current_time ) - 1; | |
| 764 | +					$dates['m_start'] = date('n', $current_time) == 1 ? 12 : date('n', $current_time) - 1; | |
| 765 | 765 | $dates['m_end'] = $dates['m_start']; | 
| 766 | - $dates['year'] = date( 'n', $current_time ) == 1 ? date( 'Y', $current_time ) - 1 : date( 'Y', $current_time ); | |
| 766 | +					$dates['year']    = date('n', $current_time) == 1 ? date('Y', $current_time) - 1 : date('Y', $current_time); | |
| 767 | 767 | break; | 
| 768 | 768 | |
| 769 | 769 | case 'today' : | 
| 770 | - $dates['day'] = date( 'd', $current_time ); | |
| 771 | - $dates['m_start'] = date( 'n', $current_time ); | |
| 772 | - $dates['m_end'] = date( 'n', $current_time ); | |
| 773 | - $dates['year'] = date( 'Y', $current_time ); | |
| 770 | +					$dates['day']     = date('d', $current_time); | |
| 771 | +					$dates['m_start'] = date('n', $current_time); | |
| 772 | +					$dates['m_end']   = date('n', $current_time); | |
| 773 | +					$dates['year']    = date('Y', $current_time); | |
| 774 | 774 | break; | 
| 775 | 775 | |
| 776 | 776 | case 'yesterday' : | 
| 777 | 777 | |
| 778 | - $year = date( 'Y', $current_time ); | |
| 779 | - $month = date( 'n', $current_time ); | |
| 780 | - $day = date( 'd', $current_time ); | |
| 778 | +					$year  = date('Y', $current_time); | |
| 779 | +					$month = date('n', $current_time); | |
| 780 | +					$day   = date('d', $current_time); | |
| 781 | 781 | |
| 782 | -					if ( $month == 1 && $day == 1 ) { | |
| 782 | +					if ($month == 1 && $day == 1) { | |
| 783 | 783 | |
| 784 | - $year -= 1; | |
| 784 | + $year -= 1; | |
| 785 | 785 | $month = 12; | 
| 786 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); | |
| 786 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); | |
| 787 | 787 | |
| 788 | -					} elseif ( $month > 1 && $day == 1 ) { | |
| 788 | +					} elseif ($month > 1 && $day == 1) { | |
| 789 | 789 | |
| 790 | 790 | $month -= 1; | 
| 791 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); | |
| 791 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); | |
| 792 | 792 | |
| 793 | 793 |  					} else { | 
| 794 | 794 | |
| @@ -804,65 +804,65 @@ discard block | ||
| 804 | 804 | break; | 
| 805 | 805 | |
| 806 | 806 | case 'this_quarter' : | 
| 807 | - $month_now = date( 'n', $current_time ); | |
| 807 | +					$month_now = date('n', $current_time); | |
| 808 | 808 | |
| 809 | 809 | $dates['day'] = null; | 
| 810 | 810 | |
| 811 | -					if ( $month_now <= 3 ) { | |
| 811 | +					if ($month_now <= 3) { | |
| 812 | 812 | |
| 813 | 813 | $dates['m_start'] = 1; | 
| 814 | 814 | $dates['m_end'] = 3; | 
| 815 | - $dates['year'] = date( 'Y', $current_time ); | |
| 815 | +						$dates['year']    = date('Y', $current_time); | |
| 816 | 816 | |
| 817 | -					} elseif ( $month_now <= 6 ) { | |
| 817 | +					} elseif ($month_now <= 6) { | |
| 818 | 818 | |
| 819 | 819 | $dates['m_start'] = 4; | 
| 820 | 820 | $dates['m_end'] = 6; | 
| 821 | - $dates['year'] = date( 'Y', $current_time ); | |
| 821 | +						$dates['year']    = date('Y', $current_time); | |
| 822 | 822 | |
| 823 | -					} elseif ( $month_now <= 9 ) { | |
| 823 | +					} elseif ($month_now <= 9) { | |
| 824 | 824 | |
| 825 | 825 | $dates['m_start'] = 7; | 
| 826 | 826 | $dates['m_end'] = 9; | 
| 827 | - $dates['year'] = date( 'Y', $current_time ); | |
| 827 | +						$dates['year']    = date('Y', $current_time); | |
| 828 | 828 | |
| 829 | 829 |  					} else { | 
| 830 | 830 | |
| 831 | 831 | $dates['m_start'] = 10; | 
| 832 | 832 | $dates['m_end'] = 12; | 
| 833 | - $dates['year'] = date( 'Y', $current_time ); | |
| 833 | +						$dates['year']    = date('Y', $current_time); | |
| 834 | 834 | |
| 835 | 835 | } | 
| 836 | 836 | break; | 
| 837 | 837 | |
| 838 | 838 | case 'last_quarter' : | 
| 839 | - $month_now = date( 'n', $current_time ); | |
| 839 | +					$month_now = date('n', $current_time); | |
| 840 | 840 | |
| 841 | 841 | $dates['day'] = null; | 
| 842 | 842 | |
| 843 | -					if ( $month_now <= 3 ) { | |
| 843 | +					if ($month_now <= 3) { | |
| 844 | 844 | |
| 845 | 845 | $dates['m_start'] = 10; | 
| 846 | 846 | $dates['m_end'] = 12; | 
| 847 | - $dates['year'] = date( 'Y', $current_time ) - 1; // Previous year | |
| 847 | +						$dates['year']    = date('Y', $current_time) - 1; // Previous year | |
| 848 | 848 | |
| 849 | -					} elseif ( $month_now <= 6 ) { | |
| 849 | +					} elseif ($month_now <= 6) { | |
| 850 | 850 | |
| 851 | 851 | $dates['m_start'] = 1; | 
| 852 | 852 | $dates['m_end'] = 3; | 
| 853 | - $dates['year'] = date( 'Y', $current_time ); | |
| 853 | +						$dates['year']    = date('Y', $current_time); | |
| 854 | 854 | |
| 855 | -					} elseif ( $month_now <= 9 ) { | |
| 855 | +					} elseif ($month_now <= 9) { | |
| 856 | 856 | |
| 857 | 857 | $dates['m_start'] = 4; | 
| 858 | 858 | $dates['m_end'] = 6; | 
| 859 | - $dates['year'] = date( 'Y', $current_time ); | |
| 859 | +						$dates['year']    = date('Y', $current_time); | |
| 860 | 860 | |
| 861 | 861 |  					} else { | 
| 862 | 862 | |
| 863 | 863 | $dates['m_start'] = 7; | 
| 864 | 864 | $dates['m_end'] = 9; | 
| 865 | - $dates['year'] = date( 'Y', $current_time ); | |
| 865 | +						$dates['year']    = date('Y', $current_time); | |
| 866 | 866 | |
| 867 | 867 | } | 
| 868 | 868 | break; | 
| @@ -871,14 +871,14 @@ discard block | ||
| 871 | 871 | $dates['day'] = null; | 
| 872 | 872 | $dates['m_start'] = null; | 
| 873 | 873 | $dates['m_end'] = null; | 
| 874 | - $dates['year'] = date( 'Y', $current_time ); | |
| 874 | +					$dates['year']    = date('Y', $current_time); | |
| 875 | 875 | break; | 
| 876 | 876 | |
| 877 | 877 | case 'last_year' : | 
| 878 | 878 | $dates['day'] = null; | 
| 879 | 879 | $dates['m_start'] = null; | 
| 880 | 880 | $dates['m_end'] = null; | 
| 881 | - $dates['year'] = date( 'Y', $current_time ) - 1; | |
| 881 | +					$dates['year']    = date('Y', $current_time) - 1; | |
| 882 | 882 | break; | 
| 883 | 883 | |
| 884 | 884 | endswitch; | 
| @@ -891,7 +891,7 @@ discard block | ||
| 891 | 891 | * | 
| 892 | 892 | * @param array $dates The dates used for retrieving earnings. | 
| 893 | 893 | */ | 
| 894 | - return apply_filters( 'give_api_stat_dates', $dates ); | |
| 894 | +		return apply_filters('give_api_stat_dates', $dates); | |
| 895 | 895 | } | 
| 896 | 896 | |
| 897 | 897 | /** | 
| @@ -905,84 +905,84 @@ discard block | ||
| 905 | 905 | * | 
| 906 | 906 | * @return array $donors Multidimensional array of the donors. | 
| 907 | 907 | */ | 
| 908 | -	public function get_donors( $donor = null ) { | |
| 908 | +	public function get_donors($donor = null) { | |
| 909 | 909 | |
| 910 | 910 | $donors = array(); | 
| 911 | 911 | $error = array(); | 
| 912 | -		if ( ! user_can( $this->user_id, 'view_give_sensitive_data' ) && ! $this->override ) { | |
| 912 | +		if ( ! user_can($this->user_id, 'view_give_sensitive_data') && ! $this->override) { | |
| 913 | 913 | return $donors; | 
| 914 | 914 | } | 
| 915 | 915 | |
| 916 | 916 | $paged = $this->get_paged(); | 
| 917 | 917 | $per_page = $this->per_page(); | 
| 918 | - $offset = $per_page * ( $paged - 1 ); | |
| 918 | + $offset = $per_page * ($paged - 1); | |
| 919 | 919 | |
| 920 | -		if ( is_numeric( $donor ) ) { | |
| 920 | +		if (is_numeric($donor)) { | |
| 921 | 921 | $field = 'id'; | 
| 922 | 922 |  		} else { | 
| 923 | 923 | $field = 'email'; | 
| 924 | 924 | } | 
| 925 | 925 | |
| 926 | - $donor_query = Give()->donors->get_donors( array( | |
| 926 | + $donor_query = Give()->donors->get_donors(array( | |
| 927 | 927 | 'number' => $per_page, | 
| 928 | 928 | 'offset' => $offset, | 
| 929 | 929 | $field => $donor, | 
| 930 | - ) ); | |
| 930 | + )); | |
| 931 | 931 | $donor_count = 0; | 
| 932 | 932 | |
| 933 | -		if ( $donor_query ) { | |
| 933 | +		if ($donor_query) { | |
| 934 | 934 | |
| 935 | -			foreach ( $donor_query as $donor_obj ) { | |
| 935 | +			foreach ($donor_query as $donor_obj) { | |
| 936 | 936 | |
| 937 | - $names = explode( ' ', $donor_obj->name ); | |
| 938 | - $first_name = ! empty( $names[0] ) ? $names[0] : ''; | |
| 937 | +				$names      = explode(' ', $donor_obj->name); | |
| 938 | + $first_name = ! empty($names[0]) ? $names[0] : ''; | |
| 939 | 939 | $last_name = ''; | 
| 940 | -				if ( ! empty( $names[1] ) ) { | |
| 941 | - unset( $names[0] ); | |
| 942 | - $last_name = implode( ' ', $names ); | |
| 940 | +				if ( ! empty($names[1])) { | |
| 941 | + unset($names[0]); | |
| 942 | +					$last_name = implode(' ', $names); | |
| 943 | 943 | } | 
| 944 | 944 | |
| 945 | - $donors['donors'][ $donor_count ]['info']['user_id'] = ''; | |
| 946 | - $donors['donors'][ $donor_count ]['info']['username'] = ''; | |
| 947 | - $donors['donors'][ $donor_count ]['info']['display_name'] = ''; | |
| 948 | - $donors['donors'][ $donor_count ]['info']['donor_id'] = $donor_obj->id; | |
| 949 | - $donors['donors'][ $donor_count ]['info']['first_name'] = $first_name; | |
| 950 | - $donors['donors'][ $donor_count ]['info']['last_name'] = $last_name; | |
| 951 | - $donors['donors'][ $donor_count ]['info']['email'] = $donor_obj->email; | |
| 945 | + $donors['donors'][$donor_count]['info']['user_id'] = ''; | |
| 946 | + $donors['donors'][$donor_count]['info']['username'] = ''; | |
| 947 | + $donors['donors'][$donor_count]['info']['display_name'] = ''; | |
| 948 | + $donors['donors'][$donor_count]['info']['donor_id'] = $donor_obj->id; | |
| 949 | + $donors['donors'][$donor_count]['info']['first_name'] = $first_name; | |
| 950 | + $donors['donors'][$donor_count]['info']['last_name'] = $last_name; | |
| 951 | + $donors['donors'][$donor_count]['info']['email'] = $donor_obj->email; | |
| 952 | 952 | |
| 953 | -				if ( ! empty( $donor_obj->user_id ) ) { | |
| 953 | +				if ( ! empty($donor_obj->user_id)) { | |
| 954 | 954 | |
| 955 | - $user_data = get_userdata( $donor_obj->user_id ); | |
| 955 | + $user_data = get_userdata($donor_obj->user_id); | |
| 956 | 956 | |
| 957 | 957 | // Donor with registered account. | 
| 958 | - $donors['donors'][ $donor_count ]['info']['user_id'] = $donor_obj->user_id; | |
| 959 | - $donors['donors'][ $donor_count ]['info']['username'] = $user_data->user_login; | |
| 960 | - $donors['donors'][ $donor_count ]['info']['display_name'] = $user_data->display_name; | |
| 958 | + $donors['donors'][$donor_count]['info']['user_id'] = $donor_obj->user_id; | |
| 959 | + $donors['donors'][$donor_count]['info']['username'] = $user_data->user_login; | |
| 960 | + $donors['donors'][$donor_count]['info']['display_name'] = $user_data->display_name; | |
| 961 | 961 | |
| 962 | 962 | } | 
| 963 | 963 | |
| 964 | - $donors['donors'][ $donor_count ]['stats']['total_donations'] = $donor_obj->purchase_count; | |
| 965 | - $donors['donors'][ $donor_count ]['stats']['total_spent'] = $donor_obj->purchase_value; | |
| 964 | + $donors['donors'][$donor_count]['stats']['total_donations'] = $donor_obj->purchase_count; | |
| 965 | + $donors['donors'][$donor_count]['stats']['total_spent'] = $donor_obj->purchase_value; | |
| 966 | 966 | |
| 967 | 967 | /** @var $donor \Give_Donor */ | 
| 968 | - $donor = new Give_Donor( $donor_obj->id ); | |
| 968 | + $donor = new Give_Donor($donor_obj->id); | |
| 969 | 969 | |
| 970 | 970 | // Get donor's addresses. | 
| 971 | - $donors['donors'][ $donor_count ]['address'] = $donor->address; | |
| 971 | + $donors['donors'][$donor_count]['address'] = $donor->address; | |
| 972 | 972 | |
| 973 | - $donor_count ++; | |
| 973 | + $donor_count++; | |
| 974 | 974 | |
| 975 | 975 | } | 
| 976 | -		} elseif ( $donor ) { | |
| 976 | +		} elseif ($donor) { | |
| 977 | 977 | |
| 978 | 978 | $error['error'] = sprintf( /* translators: %s: donor */ | 
| 979 | - __( 'Donor %s not found.', 'give' ), $donor ); | |
| 979 | +				__('Donor %s not found.', 'give'), $donor ); | |
| 980 | 980 | |
| 981 | 981 | return $error; | 
| 982 | 982 | |
| 983 | 983 |  		} else { | 
| 984 | 984 | |
| 985 | - $error['error'] = __( 'No donors found.', 'give' ); | |
| 985 | +			$error['error'] = __('No donors found.', 'give'); | |
| 986 | 986 | |
| 987 | 987 | return $error; | 
| 988 | 988 | |
| @@ -1001,37 +1001,37 @@ discard block | ||
| 1001 | 1001 | * | 
| 1002 | 1002 | * @return array $donors Multidimensional array of the forms. | 
| 1003 | 1003 | */ | 
| 1004 | -	public function get_forms( $form = null ) { | |
| 1004 | +	public function get_forms($form = null) { | |
| 1005 | 1005 | |
| 1006 | 1006 | $forms = array(); | 
| 1007 | 1007 | $error = array(); | 
| 1008 | 1008 | |
| 1009 | -		if ( $form == null ) { | |
| 1009 | +		if ($form == null) { | |
| 1010 | 1010 | $forms['forms'] = array(); | 
| 1011 | 1011 | |
| 1012 | - $form_list = get_posts( array( | |
| 1012 | + $form_list = get_posts(array( | |
| 1013 | 1013 | 'post_type' => 'give_forms', | 
| 1014 | 1014 | 'posts_per_page' => $this->per_page(), | 
| 1015 | 1015 | 'suppress_filters' => true, | 
| 1016 | 1016 | 'paged' => $this->get_paged(), | 
| 1017 | - ) ); | |
| 1017 | + )); | |
| 1018 | 1018 | |
| 1019 | -			if ( $form_list ) { | |
| 1019 | +			if ($form_list) { | |
| 1020 | 1020 | $i = 0; | 
| 1021 | -				foreach ( $form_list as $form_info ) { | |
| 1022 | - $forms['forms'][ $i ] = $this->get_form_data( $form_info ); | |
| 1023 | - $i ++; | |
| 1021 | +				foreach ($form_list as $form_info) { | |
| 1022 | + $forms['forms'][$i] = $this->get_form_data($form_info); | |
| 1023 | + $i++; | |
| 1024 | 1024 | } | 
| 1025 | 1025 | } | 
| 1026 | 1026 |  		} else { | 
| 1027 | -			if ( get_post_type( $form ) == 'give_forms' ) { | |
| 1028 | - $form_info = get_post( $form ); | |
| 1027 | +			if (get_post_type($form) == 'give_forms') { | |
| 1028 | + $form_info = get_post($form); | |
| 1029 | 1029 | |
| 1030 | - $forms['forms'][0] = $this->get_form_data( $form_info ); | |
| 1030 | + $forms['forms'][0] = $this->get_form_data($form_info); | |
| 1031 | 1031 | |
| 1032 | 1032 |  			} else { | 
| 1033 | 1033 | $error['error'] = sprintf( /* translators: %s: form */ | 
| 1034 | - __( 'Form %s not found.', 'give' ), $form ); | |
| 1034 | +					__('Form %s not found.', 'give'), $form ); | |
| 1035 | 1035 | |
| 1036 | 1036 | return $error; | 
| 1037 | 1037 | } | 
| @@ -1049,7 +1049,7 @@ discard block | ||
| 1049 | 1049 | * | 
| 1050 | 1050 | * @return array Array of post data to return back in the API. | 
| 1051 | 1051 | */ | 
| 1052 | -	private function get_form_data( $form_info ) { | |
| 1052 | +	private function get_form_data($form_info) { | |
| 1053 | 1053 | |
| 1054 | 1054 | $form = array(); | 
| 1055 | 1055 | |
| @@ -1059,60 +1059,60 @@ discard block | ||
| 1059 | 1059 | $form['info']['create_date'] = $form_info->post_date; | 
| 1060 | 1060 | $form['info']['modified_date'] = $form_info->post_modified; | 
| 1061 | 1061 | $form['info']['status'] = $form_info->post_status; | 
| 1062 | - $form['info']['link'] = html_entity_decode( $form_info->guid ); | |
| 1063 | - $form['info']['content'] = give_get_meta( $form_info->ID, '_give_form_content', true ); | |
| 1064 | - $form['info']['thumbnail'] = wp_get_attachment_url( get_post_thumbnail_id( $form_info->ID ) ); | |
| 1062 | + $form['info']['link'] = html_entity_decode($form_info->guid); | |
| 1063 | + $form['info']['content'] = give_get_meta($form_info->ID, '_give_form_content', true); | |
| 1064 | + $form['info']['thumbnail'] = wp_get_attachment_url(get_post_thumbnail_id($form_info->ID)); | |
| 1065 | 1065 | |
| 1066 | -		if ( give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ) ) { | |
| 1067 | - $form['info']['category'] = get_the_terms( $form_info, 'give_forms_category' ); | |
| 1068 | - $form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' ); | |
| 1066 | +		if (give_is_setting_enabled(give_get_option('categories', 'disabled'))) { | |
| 1067 | + $form['info']['category'] = get_the_terms($form_info, 'give_forms_category'); | |
| 1068 | + $form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag'); | |
| 1069 | 1069 | } | 
| 1070 | -		if ( give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ) ) { | |
| 1071 | - $form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' ); | |
| 1070 | +		if (give_is_setting_enabled(give_get_option('tags', 'disabled'))) { | |
| 1071 | + $form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag'); | |
| 1072 | 1072 | } | 
| 1073 | 1073 | |
| 1074 | 1074 | // Check whether any goal is to be achieved for the donation form. | 
| 1075 | - $goal_option = give_get_meta( $form_info->ID, '_give_goal_option', true ); | |
| 1076 | - $goal_amount = give_get_meta( $form_info->ID, '_give_set_goal', true ); | |
| 1077 | -		if ( give_is_setting_enabled( $goal_option ) && $goal_amount ) { | |
| 1078 | - $total_income = give_get_form_earnings_stats( $form_info->ID ); | |
| 1079 | - $goal_percentage_completed = ( $total_income < $goal_amount ) ? round( ( $total_income / $goal_amount ) * 100, 2 ) : 100; | |
| 1080 | - $form['goal']['amount'] = isset( $goal_amount ) ? $goal_amount : ''; | |
| 1081 | - $form['goal']['percentage_completed'] = isset( $goal_percentage_completed ) ? $goal_percentage_completed : ''; | |
| 1075 | + $goal_option = give_get_meta($form_info->ID, '_give_goal_option', true); | |
| 1076 | + $goal_amount = give_get_meta($form_info->ID, '_give_set_goal', true); | |
| 1077 | +		if (give_is_setting_enabled($goal_option) && $goal_amount) { | |
| 1078 | + $total_income = give_get_form_earnings_stats($form_info->ID); | |
| 1079 | + $goal_percentage_completed = ($total_income < $goal_amount) ? round(($total_income / $goal_amount) * 100, 2) : 100; | |
| 1080 | + $form['goal']['amount'] = isset($goal_amount) ? $goal_amount : ''; | |
| 1081 | + $form['goal']['percentage_completed'] = isset($goal_percentage_completed) ? $goal_percentage_completed : ''; | |
| 1082 | 1082 | } | 
| 1083 | 1083 | |
| 1084 | -		if ( user_can( $this->user_id, 'view_give_reports' ) || $this->override ) { | |
| 1085 | - $form['stats']['total']['donations'] = give_get_form_sales_stats( $form_info->ID ); | |
| 1086 | - $form['stats']['total']['earnings'] = give_get_form_earnings_stats( $form_info->ID ); | |
| 1087 | - $form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales( $form_info->ID ); | |
| 1088 | - $form['stats']['monthly_average']['earnings'] = give_get_average_monthly_form_earnings( $form_info->ID ); | |
| 1084 | +		if (user_can($this->user_id, 'view_give_reports') || $this->override) { | |
| 1085 | + $form['stats']['total']['donations'] = give_get_form_sales_stats($form_info->ID); | |
| 1086 | + $form['stats']['total']['earnings'] = give_get_form_earnings_stats($form_info->ID); | |
| 1087 | + $form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales($form_info->ID); | |
| 1088 | + $form['stats']['monthly_average']['earnings'] = give_get_average_monthly_form_earnings($form_info->ID); | |
| 1089 | 1089 | } | 
| 1090 | 1090 | |
| 1091 | 1091 | $counter = 0; | 
| 1092 | -		if ( give_has_variable_prices( $form_info->ID ) ) { | |
| 1093 | -			foreach ( give_get_variable_prices( $form_info->ID ) as $price ) { | |
| 1094 | - $counter ++; | |
| 1092 | +		if (give_has_variable_prices($form_info->ID)) { | |
| 1093 | +			foreach (give_get_variable_prices($form_info->ID) as $price) { | |
| 1094 | + $counter++; | |
| 1095 | 1095 | // multi-level item | 
| 1096 | - $level = isset( $price['_give_text'] ) ? $price['_give_text'] : 'level-' . $counter; | |
| 1097 | - $form['pricing'][ sanitize_key( $level ) ] = $price['_give_amount']; | |
| 1096 | + $level = isset($price['_give_text']) ? $price['_give_text'] : 'level-'.$counter; | |
| 1097 | + $form['pricing'][sanitize_key($level)] = $price['_give_amount']; | |
| 1098 | 1098 | |
| 1099 | 1099 | } | 
| 1100 | 1100 |  		} else { | 
| 1101 | - $form['pricing']['amount'] = give_get_form_price( $form_info->ID ); | |
| 1101 | + $form['pricing']['amount'] = give_get_form_price($form_info->ID); | |
| 1102 | 1102 | } | 
| 1103 | 1103 | |
| 1104 | -		if ( user_can( $this->user_id, 'view_give_sensitive_data' ) || $this->override ) { | |
| 1104 | +		if (user_can($this->user_id, 'view_give_sensitive_data') || $this->override) { | |
| 1105 | 1105 | |
| 1106 | 1106 | /** | 
| 1107 | 1107 | * Fires when generating API sensitive data. | 
| 1108 | 1108 | * | 
| 1109 | 1109 | * @since 1.1 | 
| 1110 | 1110 | */ | 
| 1111 | - do_action( 'give_api_sensitive_data' ); | |
| 1111 | +			do_action('give_api_sensitive_data'); | |
| 1112 | 1112 | |
| 1113 | 1113 | } | 
| 1114 | 1114 | |
| 1115 | - return apply_filters( 'give_api_forms_form', $form ); | |
| 1115 | +		return apply_filters('give_api_forms_form', $form); | |
| 1116 | 1116 | |
| 1117 | 1117 | } | 
| 1118 | 1118 | |
| @@ -1127,7 +1127,7 @@ discard block | ||
| 1127 | 1127 | * | 
| 1128 | 1128 | * @return array | 
| 1129 | 1129 | */ | 
| 1130 | -	public function get_stats( $args = array() ) { | |
| 1130 | +	public function get_stats($args = array()) { | |
| 1131 | 1131 | $defaults = array( | 
| 1132 | 1132 | 'type' => null, | 
| 1133 | 1133 | 'form' => null, | 
| @@ -1136,9 +1136,9 @@ discard block | ||
| 1136 | 1136 | 'enddate' => null, | 
| 1137 | 1137 | ); | 
| 1138 | 1138 | |
| 1139 | - $args = wp_parse_args( $args, $defaults ); | |
| 1139 | + $args = wp_parse_args($args, $defaults); | |
| 1140 | 1140 | |
| 1141 | - $dates = $this->get_dates( $args ); | |
| 1141 | + $dates = $this->get_dates($args); | |
| 1142 | 1142 | |
| 1143 | 1143 | $stats = array(); | 
| 1144 | 1144 | $earnings = array( | 
| @@ -1149,40 +1149,40 @@ discard block | ||
| 1149 | 1149 | ); | 
| 1150 | 1150 | $error = array(); | 
| 1151 | 1151 | |
| 1152 | -		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) { | |
| 1152 | +		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) { | |
| 1153 | 1153 | return $stats; | 
| 1154 | 1154 | } | 
| 1155 | 1155 | |
| 1156 | -		if ( $args['type'] == 'donations' ) { | |
| 1156 | +		if ($args['type'] == 'donations') { | |
| 1157 | 1157 | |
| 1158 | -			if ( $args['form'] == null ) { | |
| 1159 | -				if ( $args['date'] == null ) { | |
| 1158 | +			if ($args['form'] == null) { | |
| 1159 | +				if ($args['date'] == null) { | |
| 1160 | 1160 | $donations = $this->get_default_sales_stats(); | 
| 1161 | -				} elseif ( $args['date'] === 'range' ) { | |
| 1161 | +				} elseif ($args['date'] === 'range') { | |
| 1162 | 1162 | // Return donations for a date range. | 
| 1163 | 1163 | // Ensure the end date is later than the start date. | 
| 1164 | -					if ( $args['enddate'] < $args['startdate'] ) { | |
| 1165 | - $error['error'] = __( 'The end date must be later than the start date.', 'give' ); | |
| 1164 | +					if ($args['enddate'] < $args['startdate']) { | |
| 1165 | +						$error['error'] = __('The end date must be later than the start date.', 'give'); | |
| 1166 | 1166 | } | 
| 1167 | 1167 | |
| 1168 | 1168 | // Ensure both the start and end date are specified | 
| 1169 | -					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) { | |
| 1170 | - $error['error'] = __( 'Invalid or no date range specified.', 'give' ); | |
| 1169 | +					if (empty($args['startdate']) || empty($args['enddate'])) { | |
| 1170 | +						$error['error'] = __('Invalid or no date range specified.', 'give'); | |
| 1171 | 1171 | } | 
| 1172 | 1172 | |
| 1173 | 1173 | $total = 0; | 
| 1174 | 1174 | |
| 1175 | 1175 | // Loop through the years | 
| 1176 | 1176 | $y = $dates['year']; | 
| 1177 | - while ( $y <= $dates['year_end'] ) : | |
| 1177 | + while ($y <= $dates['year_end']) : | |
| 1178 | 1178 | |
| 1179 | -						if ( $dates['year'] == $dates['year_end'] ) { | |
| 1179 | +						if ($dates['year'] == $dates['year_end']) { | |
| 1180 | 1180 | $month_start = $dates['m_start']; | 
| 1181 | 1181 | $month_end = $dates['m_end']; | 
| 1182 | -						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) { | |
| 1182 | +						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) { | |
| 1183 | 1183 | $month_start = $dates['m_start']; | 
| 1184 | 1184 | $month_end = 12; | 
| 1185 | -						} elseif ( $y == $dates['year_end'] ) { | |
| 1185 | +						} elseif ($y == $dates['year_end']) { | |
| 1186 | 1186 | $month_start = 1; | 
| 1187 | 1187 | $month_end = $dates['m_end']; | 
| 1188 | 1188 |  						} else { | 
| @@ -1191,116 +1191,116 @@ discard block | ||
| 1191 | 1191 | } | 
| 1192 | 1192 | |
| 1193 | 1193 | $i = $month_start; | 
| 1194 | - while ( $i <= $month_end ) : | |
| 1194 | + while ($i <= $month_end) : | |
| 1195 | 1195 | |
| 1196 | -							if ( $i == $dates['m_start'] ) { | |
| 1196 | +							if ($i == $dates['m_start']) { | |
| 1197 | 1197 | $d = $dates['day_start']; | 
| 1198 | 1198 |  							} else { | 
| 1199 | 1199 | $d = 1; | 
| 1200 | 1200 | } | 
| 1201 | 1201 | |
| 1202 | -							if ( $i == $dates['m_end'] ) { | |
| 1202 | +							if ($i == $dates['m_end']) { | |
| 1203 | 1203 | $num_of_days = $dates['day_end']; | 
| 1204 | 1204 |  							} else { | 
| 1205 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); | |
| 1205 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); | |
| 1206 | 1206 | } | 
| 1207 | 1207 | |
| 1208 | - while ( $d <= $num_of_days ) : | |
| 1209 | - $sale_count = give_get_sales_by_date( $d, $i, $y ); | |
| 1210 | - $date_key = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) ); | |
| 1211 | -								if ( ! isset( $donations['sales'][ $date_key ] ) ) { | |
| 1212 | - $donations['sales'][ $date_key ] = 0; | |
| 1208 | + while ($d <= $num_of_days) : | |
| 1209 | + $sale_count = give_get_sales_by_date($d, $i, $y); | |
| 1210 | +								$date_key   = date('Ymd', strtotime($y.'/'.$i.'/'.$d)); | |
| 1211 | +								if ( ! isset($donations['sales'][$date_key])) { | |
| 1212 | + $donations['sales'][$date_key] = 0; | |
| 1213 | 1213 | } | 
| 1214 | - $donations['sales'][ $date_key ] += $sale_count; | |
| 1214 | + $donations['sales'][$date_key] += $sale_count; | |
| 1215 | 1215 | $total += $sale_count; | 
| 1216 | - $d ++; | |
| 1216 | + $d++; | |
| 1217 | 1217 | endwhile; | 
| 1218 | - $i ++; | |
| 1218 | + $i++; | |
| 1219 | 1219 | endwhile; | 
| 1220 | 1220 | |
| 1221 | - $y ++; | |
| 1221 | + $y++; | |
| 1222 | 1222 | endwhile; | 
| 1223 | 1223 | |
| 1224 | 1224 | $donations['totals'] = $total; | 
| 1225 | 1225 |  				} else { | 
| 1226 | -					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) { | |
| 1226 | +					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') { | |
| 1227 | 1227 | $donations_count = 0; | 
| 1228 | 1228 | |
| 1229 | 1229 | // Loop through the months | 
| 1230 | 1230 | $month = $dates['m_start']; | 
| 1231 | 1231 | |
| 1232 | - while ( $month <= $dates['m_end'] ) : | |
| 1233 | - $donations_count += give_get_sales_by_date( null, $month, $dates['year'] ); | |
| 1234 | - $month ++; | |
| 1232 | + while ($month <= $dates['m_end']) : | |
| 1233 | + $donations_count += give_get_sales_by_date(null, $month, $dates['year']); | |
| 1234 | + $month++; | |
| 1235 | 1235 | endwhile; | 
| 1236 | 1236 | |
| 1237 | - $donations['donations'][ $args['date'] ] = $donations_count; | |
| 1237 | + $donations['donations'][$args['date']] = $donations_count; | |
| 1238 | 1238 |  					} else { | 
| 1239 | - $donations['donations'][ $args['date'] ] = give_get_sales_by_date( $dates['day'], $dates['m_start'], $dates['year'] ); | |
| 1239 | + $donations['donations'][$args['date']] = give_get_sales_by_date($dates['day'], $dates['m_start'], $dates['year']); | |
| 1240 | 1240 | } | 
| 1241 | 1241 | }// End if(). | 
| 1242 | -			} elseif ( $args['form'] == 'all' ) { | |
| 1243 | - $forms = get_posts( array( | |
| 1242 | +			} elseif ($args['form'] == 'all') { | |
| 1243 | + $forms = get_posts(array( | |
| 1244 | 1244 | 'post_type' => 'give_forms', | 
| 1245 | 1245 | 'nopaging' => true, | 
| 1246 | - ) ); | |
| 1247 | - $i = 0; | |
| 1248 | -				foreach ( $forms as $form_info ) { | |
| 1249 | - $donations['donations'][ $i ] = array( | |
| 1250 | - $form_info->post_name => give_get_form_sales_stats( $form_info->ID ), | |
| 1246 | + )); | |
| 1247 | + $i = 0; | |
| 1248 | +				foreach ($forms as $form_info) { | |
| 1249 | + $donations['donations'][$i] = array( | |
| 1250 | + $form_info->post_name => give_get_form_sales_stats($form_info->ID), | |
| 1251 | 1251 | ); | 
| 1252 | - $i ++; | |
| 1252 | + $i++; | |
| 1253 | 1253 | } | 
| 1254 | 1254 |  			} else { | 
| 1255 | -				if ( get_post_type( $args['form'] ) == 'give_forms' ) { | |
| 1256 | - $form_info = get_post( $args['form'] ); | |
| 1255 | +				if (get_post_type($args['form']) == 'give_forms') { | |
| 1256 | + $form_info = get_post($args['form']); | |
| 1257 | 1257 | $donations['donations'][0] = array( | 
| 1258 | - $form_info->post_name => give_get_form_sales_stats( $args['form'] ), | |
| 1258 | + $form_info->post_name => give_get_form_sales_stats($args['form']), | |
| 1259 | 1259 | ); | 
| 1260 | 1260 |  				} else { | 
| 1261 | 1261 | $error['error'] = sprintf( /* translators: %s: form */ | 
| 1262 | - __( 'Form %s not found.', 'give' ), $args['form'] ); | |
| 1262 | +						__('Form %s not found.', 'give'), $args['form'] ); | |
| 1263 | 1263 | } | 
| 1264 | 1264 | }// End if(). | 
| 1265 | 1265 | |
| 1266 | -			if ( ! empty( $error ) ) { | |
| 1266 | +			if ( ! empty($error)) { | |
| 1267 | 1267 | return $error; | 
| 1268 | 1268 | } | 
| 1269 | 1269 | |
| 1270 | 1270 | return $donations; | 
| 1271 | 1271 | |
| 1272 | -		} elseif ( $args['type'] == 'earnings' ) { | |
| 1273 | -			if ( $args['form'] == null ) { | |
| 1274 | -				if ( $args['date'] == null ) { | |
| 1272 | +		} elseif ($args['type'] == 'earnings') { | |
| 1273 | +			if ($args['form'] == null) { | |
| 1274 | +				if ($args['date'] == null) { | |
| 1275 | 1275 | $earnings = $this->get_default_earnings_stats(); | 
| 1276 | -				} elseif ( $args['date'] === 'range' ) { | |
| 1276 | +				} elseif ($args['date'] === 'range') { | |
| 1277 | 1277 | // Return sales for a date range | 
| 1278 | 1278 | // Ensure the end date is later than the start date | 
| 1279 | -					if ( $args['enddate'] < $args['startdate'] ) { | |
| 1280 | - $error['error'] = __( 'The end date must be later than the start date.', 'give' ); | |
| 1279 | +					if ($args['enddate'] < $args['startdate']) { | |
| 1280 | +						$error['error'] = __('The end date must be later than the start date.', 'give'); | |
| 1281 | 1281 | } | 
| 1282 | 1282 | |
| 1283 | 1283 | // Ensure both the start and end date are specified | 
| 1284 | -					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) { | |
| 1285 | - $error['error'] = __( 'Invalid or no date range specified.', 'give' ); | |
| 1284 | +					if (empty($args['startdate']) || empty($args['enddate'])) { | |
| 1285 | +						$error['error'] = __('Invalid or no date range specified.', 'give'); | |
| 1286 | 1286 | } | 
| 1287 | 1287 | |
| 1288 | 1288 | $total = (float) 0.00; | 
| 1289 | 1289 | |
| 1290 | 1290 | // Loop through the years | 
| 1291 | 1291 | $y = $dates['year']; | 
| 1292 | -					if ( ! isset( $earnings['earnings'] ) ) { | |
| 1292 | +					if ( ! isset($earnings['earnings'])) { | |
| 1293 | 1293 | $earnings['earnings'] = array(); | 
| 1294 | 1294 | } | 
| 1295 | - while ( $y <= $dates['year_end'] ) : | |
| 1295 | + while ($y <= $dates['year_end']) : | |
| 1296 | 1296 | |
| 1297 | -						if ( $dates['year'] == $dates['year_end'] ) { | |
| 1297 | +						if ($dates['year'] == $dates['year_end']) { | |
| 1298 | 1298 | $month_start = $dates['m_start']; | 
| 1299 | 1299 | $month_end = $dates['m_end']; | 
| 1300 | -						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) { | |
| 1300 | +						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) { | |
| 1301 | 1301 | $month_start = $dates['m_start']; | 
| 1302 | 1302 | $month_end = 12; | 
| 1303 | -						} elseif ( $y == $dates['year_end'] ) { | |
| 1303 | +						} elseif ($y == $dates['year_end']) { | |
| 1304 | 1304 | $month_start = 1; | 
| 1305 | 1305 | $month_end = $dates['m_end']; | 
| 1306 | 1306 |  						} else { | 
| @@ -1309,102 +1309,102 @@ discard block | ||
| 1309 | 1309 | } | 
| 1310 | 1310 | |
| 1311 | 1311 | $i = $month_start; | 
| 1312 | - while ( $i <= $month_end ) : | |
| 1312 | + while ($i <= $month_end) : | |
| 1313 | 1313 | |
| 1314 | -							if ( $i == $dates['m_start'] ) { | |
| 1314 | +							if ($i == $dates['m_start']) { | |
| 1315 | 1315 | $d = $dates['day_start']; | 
| 1316 | 1316 |  							} else { | 
| 1317 | 1317 | $d = 1; | 
| 1318 | 1318 | } | 
| 1319 | 1319 | |
| 1320 | -							if ( $i == $dates['m_end'] ) { | |
| 1320 | +							if ($i == $dates['m_end']) { | |
| 1321 | 1321 | $num_of_days = $dates['day_end']; | 
| 1322 | 1322 |  							} else { | 
| 1323 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); | |
| 1323 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); | |
| 1324 | 1324 | } | 
| 1325 | 1325 | |
| 1326 | - while ( $d <= $num_of_days ) : | |
| 1327 | - $earnings_stat = give_get_earnings_by_date( $d, $i, $y ); | |
| 1328 | - $date_key = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) ); | |
| 1329 | -								if ( ! isset( $earnings['earnings'][ $date_key ] ) ) { | |
| 1330 | - $earnings['earnings'][ $date_key ] = 0; | |
| 1326 | + while ($d <= $num_of_days) : | |
| 1327 | + $earnings_stat = give_get_earnings_by_date($d, $i, $y); | |
| 1328 | +								$date_key      = date('Ymd', strtotime($y.'/'.$i.'/'.$d)); | |
| 1329 | +								if ( ! isset($earnings['earnings'][$date_key])) { | |
| 1330 | + $earnings['earnings'][$date_key] = 0; | |
| 1331 | 1331 | } | 
| 1332 | - $earnings['earnings'][ $date_key ] += $earnings_stat; | |
| 1332 | + $earnings['earnings'][$date_key] += $earnings_stat; | |
| 1333 | 1333 | $total += $earnings_stat; | 
| 1334 | - $d ++; | |
| 1334 | + $d++; | |
| 1335 | 1335 | endwhile; | 
| 1336 | 1336 | |
| 1337 | - $i ++; | |
| 1337 | + $i++; | |
| 1338 | 1338 | endwhile; | 
| 1339 | 1339 | |
| 1340 | - $y ++; | |
| 1340 | + $y++; | |
| 1341 | 1341 | endwhile; | 
| 1342 | 1342 | |
| 1343 | 1343 | $earnings['totals'] = $total; | 
| 1344 | 1344 |  				} else { | 
| 1345 | -					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) { | |
| 1345 | +					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') { | |
| 1346 | 1346 | $earnings_count = (float) 0.00; | 
| 1347 | 1347 | |
| 1348 | 1348 | // Loop through the months | 
| 1349 | 1349 | $month = $dates['m_start']; | 
| 1350 | 1350 | |
| 1351 | - while ( $month <= $dates['m_end'] ) : | |
| 1352 | - $earnings_count += give_get_earnings_by_date( null, $month, $dates['year'] ); | |
| 1353 | - $month ++; | |
| 1351 | + while ($month <= $dates['m_end']) : | |
| 1352 | + $earnings_count += give_get_earnings_by_date(null, $month, $dates['year']); | |
| 1353 | + $month++; | |
| 1354 | 1354 | endwhile; | 
| 1355 | 1355 | |
| 1356 | - $earnings['earnings'][ $args['date'] ] = $earnings_count; | |
| 1356 | + $earnings['earnings'][$args['date']] = $earnings_count; | |
| 1357 | 1357 |  					} else { | 
| 1358 | - $earnings['earnings'][ $args['date'] ] = give_get_earnings_by_date( $dates['day'], $dates['m_start'], $dates['year'] ); | |
| 1358 | + $earnings['earnings'][$args['date']] = give_get_earnings_by_date($dates['day'], $dates['m_start'], $dates['year']); | |
| 1359 | 1359 | } | 
| 1360 | 1360 | }// End if(). | 
| 1361 | -			} elseif ( $args['form'] == 'all' ) { | |
| 1362 | - $forms = get_posts( array( | |
| 1361 | +			} elseif ($args['form'] == 'all') { | |
| 1362 | + $forms = get_posts(array( | |
| 1363 | 1363 | 'post_type' => 'give_forms', | 
| 1364 | 1364 | 'nopaging' => true, | 
| 1365 | - ) ); | |
| 1365 | + )); | |
| 1366 | 1366 | |
| 1367 | 1367 | $i = 0; | 
| 1368 | -				foreach ( $forms as $form_info ) { | |
| 1369 | - $earnings['earnings'][ $i ] = array( | |
| 1370 | - $form_info->post_name => give_get_form_earnings_stats( $form_info->ID ), | |
| 1368 | +				foreach ($forms as $form_info) { | |
| 1369 | + $earnings['earnings'][$i] = array( | |
| 1370 | + $form_info->post_name => give_get_form_earnings_stats($form_info->ID), | |
| 1371 | 1371 | ); | 
| 1372 | - $i ++; | |
| 1372 | + $i++; | |
| 1373 | 1373 | } | 
| 1374 | 1374 |  			} else { | 
| 1375 | -				if ( get_post_type( $args['form'] ) == 'give_forms' ) { | |
| 1376 | - $form_info = get_post( $args['form'] ); | |
| 1375 | +				if (get_post_type($args['form']) == 'give_forms') { | |
| 1376 | + $form_info = get_post($args['form']); | |
| 1377 | 1377 | $earnings['earnings'][0] = array( | 
| 1378 | 1378 | $form_info->post_name => $this->stats->get_earnings( | 
| 1379 | 1379 | $args['form'], | 
| 1380 | - is_numeric( $args['startdate'] ) | |
| 1381 | - ? strtotime( $args['startdate'] ) | |
| 1380 | + is_numeric($args['startdate']) | |
| 1381 | + ? strtotime($args['startdate']) | |
| 1382 | 1382 | : $args['startdate'], | 
| 1383 | - is_numeric( $args['enddate'] ) | |
| 1384 | - ? strtotime( $args['enddate'] ) | |
| 1383 | + is_numeric($args['enddate']) | |
| 1384 | + ? strtotime($args['enddate']) | |
| 1385 | 1385 | : $args['enddate'] | 
| 1386 | 1386 | ), | 
| 1387 | 1387 | ); | 
| 1388 | 1388 |  				} else { | 
| 1389 | 1389 | $error['error'] = sprintf( /* translators: %s: form */ | 
| 1390 | - __( 'Form %s not found.', 'give' ), $args['form'] ); | |
| 1390 | +						__('Form %s not found.', 'give'), $args['form'] ); | |
| 1391 | 1391 | } | 
| 1392 | 1392 | }// End if(). | 
| 1393 | 1393 | |
| 1394 | -			if ( ! empty( $error ) ) { | |
| 1394 | +			if ( ! empty($error)) { | |
| 1395 | 1395 | return $error; | 
| 1396 | 1396 | } | 
| 1397 | 1397 | |
| 1398 | 1398 | return $earnings; | 
| 1399 | -		} elseif ( $args['type'] == 'donors' ) { | |
| 1399 | +		} elseif ($args['type'] == 'donors') { | |
| 1400 | 1400 | $donors = new Give_DB_Donors(); | 
| 1401 | 1401 | $stats['donations']['total_donors'] = $donors->count(); | 
| 1402 | 1402 | |
| 1403 | 1403 | return $stats; | 
| 1404 | 1404 | |
| 1405 | -		} elseif ( empty( $args['type'] ) ) { | |
| 1406 | - $stats = array_merge( $stats, $this->get_default_sales_stats() ); | |
| 1407 | - $stats = array_merge( $stats, $this->get_default_earnings_stats() ); | |
| 1405 | +		} elseif (empty($args['type'])) { | |
| 1406 | + $stats = array_merge($stats, $this->get_default_sales_stats()); | |
| 1407 | + $stats = array_merge($stats, $this->get_default_earnings_stats()); | |
| 1408 | 1408 | |
| 1409 | 1409 | return array( | 
| 1410 | 1410 | 'stats' => $stats, | 
| @@ -1422,7 +1422,7 @@ discard block | ||
| 1422 | 1422 | * | 
| 1423 | 1423 | * @return array | 
| 1424 | 1424 | */ | 
| 1425 | -	public function get_recent_donations( $args = array() ) { | |
| 1425 | +	public function get_recent_donations($args = array()) { | |
| 1426 | 1426 | global $wp_query; | 
| 1427 | 1427 | |
| 1428 | 1428 | $defaults = array( | 
| @@ -1432,33 +1432,33 @@ discard block | ||
| 1432 | 1432 | 'enddate' => null, | 
| 1433 | 1433 | ); | 
| 1434 | 1434 | |
| 1435 | - $args = wp_parse_args( $args, $defaults ); | |
| 1435 | + $args = wp_parse_args($args, $defaults); | |
| 1436 | 1436 | |
| 1437 | 1437 | $donations = array(); | 
| 1438 | 1438 | |
| 1439 | -		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) { | |
| 1439 | +		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) { | |
| 1440 | 1440 | return $donations; | 
| 1441 | 1441 | } | 
| 1442 | 1442 | |
| 1443 | -		if ( isset( $wp_query->query_vars['id'] ) ) { | |
| 1443 | +		if (isset($wp_query->query_vars['id'])) { | |
| 1444 | 1444 | $query = array(); | 
| 1445 | - $query[] = new Give_Payment( $wp_query->query_vars['id'] ); | |
| 1446 | -		} elseif ( isset( $wp_query->query_vars['purchasekey'] ) ) { | |
| 1445 | + $query[] = new Give_Payment($wp_query->query_vars['id']); | |
| 1446 | +		} elseif (isset($wp_query->query_vars['purchasekey'])) { | |
| 1447 | 1447 | $query = array(); | 
| 1448 | - $query[] = give_get_payment_by( 'key', $wp_query->query_vars['purchasekey'] ); | |
| 1449 | -		} elseif ( isset( $wp_query->query_vars['email'] ) ) { | |
| 1450 | - $args = array( | |
| 1448 | +			$query[] = give_get_payment_by('key', $wp_query->query_vars['purchasekey']); | |
| 1449 | +		} elseif (isset($wp_query->query_vars['email'])) { | |
| 1450 | + $args = array( | |
| 1451 | 1451 | 'fields' => 'ids', | 
| 1452 | 1452 | 'meta_key' => '_give_payment_donor_email', | 
| 1453 | 1453 | 'meta_value' => $wp_query->query_vars['email'], | 
| 1454 | 1454 | 'number' => $this->per_page(), | 
| 1455 | 1455 | 'page' => $this->get_paged(), | 
| 1456 | 1456 | ); | 
| 1457 | - $query = give_get_payments( $args ); | |
| 1458 | -		} elseif ( isset( $wp_query->query_vars['date'] ) ) { | |
| 1457 | + $query = give_get_payments($args); | |
| 1458 | +		} elseif (isset($wp_query->query_vars['date'])) { | |
| 1459 | 1459 | |
| 1460 | - $current_time = current_time( 'timestamp' ); | |
| 1461 | - $dates = $this->get_dates( $args ); | |
| 1460 | +			$current_time = current_time('timestamp'); | |
| 1461 | + $dates = $this->get_dates($args); | |
| 1462 | 1462 | $start_date = ''; | 
| 1463 | 1463 | $end_date = ''; | 
| 1464 | 1464 | |
| @@ -1471,27 +1471,27 @@ discard block | ||
| 1471 | 1471 | * @params date startdate | required when date = range and format to be YYYYMMDD (i.e. 20170524) | 
| 1472 | 1472 | * @params date enddate | required when date = range and format to be YYYYMMDD (i.e. 20170524) | 
| 1473 | 1473 | */ | 
| 1474 | -			switch ( $wp_query->query_vars['date'] ) { | |
| 1474 | +			switch ($wp_query->query_vars['date']) { | |
| 1475 | 1475 | |
| 1476 | 1476 | case 'today': | 
| 1477 | 1477 | |
| 1478 | 1478 | // Set and Format Start and End Date to be date of today. | 
| 1479 | - $start_date = $end_date = date( 'Y/m/d', $current_time ); | |
| 1479 | +					$start_date = $end_date = date('Y/m/d', $current_time); | |
| 1480 | 1480 | |
| 1481 | 1481 | break; | 
| 1482 | 1482 | |
| 1483 | 1483 | case 'yesterday': | 
| 1484 | 1484 | |
| 1485 | 1485 | // Set and Format Start and End Date to be date of yesterday. | 
| 1486 | - $start_date = $end_date = date( 'Y/m', $current_time ) . '/' . ( date( 'd', $current_time ) - 1 ); | |
| 1486 | +					$start_date = $end_date = date('Y/m', $current_time).'/'.(date('d', $current_time) - 1); | |
| 1487 | 1487 | |
| 1488 | 1488 | break; | 
| 1489 | 1489 | |
| 1490 | 1490 | case 'range': | 
| 1491 | 1491 | |
| 1492 | 1492 | // Format Start Date and End Date for filtering payment based on date range. | 
| 1493 | - $start_date = $dates['year'] . '/' . $dates['m_start'] . '/' . $dates['day_start']; | |
| 1494 | - $end_date = $dates['year_end'] . '/' . $dates['m_end'] . '/' . $dates['day_end']; | |
| 1493 | + $start_date = $dates['year'].'/'.$dates['m_start'].'/'.$dates['day_start']; | |
| 1494 | + $end_date = $dates['year_end'].'/'.$dates['m_end'].'/'.$dates['day_end']; | |
| 1495 | 1495 | |
| 1496 | 1496 | break; | 
| 1497 | 1497 | |
| @@ -1505,22 +1505,22 @@ discard block | ||
| 1505 | 1505 | 'page' => $this->get_paged(), | 
| 1506 | 1506 | ); | 
| 1507 | 1507 | |
| 1508 | - $query = give_get_payments( $args ); | |
| 1508 | + $query = give_get_payments($args); | |
| 1509 | 1509 |  		} else { | 
| 1510 | 1510 | $args = array( | 
| 1511 | 1511 | 'fields' => 'ids', | 
| 1512 | 1512 | 'number' => $this->per_page(), | 
| 1513 | 1513 | 'page' => $this->get_paged(), | 
| 1514 | 1514 | ); | 
| 1515 | - $query = give_get_payments( $args ); | |
| 1515 | + $query = give_get_payments($args); | |
| 1516 | 1516 | }// End if(). | 
| 1517 | 1517 | |
| 1518 | -		if ( $query ) { | |
| 1518 | +		if ($query) { | |
| 1519 | 1519 | $i = 0; | 
| 1520 | -			foreach ( $query as $payment ) { | |
| 1520 | +			foreach ($query as $payment) { | |
| 1521 | 1521 | |
| 1522 | -				if ( is_numeric( $payment ) ) { | |
| 1523 | - $payment = new Give_Payment( $payment ); | |
| 1522 | +				if (is_numeric($payment)) { | |
| 1523 | + $payment = new Give_Payment($payment); | |
| 1524 | 1524 | $payment_meta = $payment->get_meta(); | 
| 1525 | 1525 | $user_info = $payment->user_info; | 
| 1526 | 1526 | } | 
| @@ -1528,44 +1528,44 @@ discard block | ||
| 1528 | 1528 | $payment_meta = $payment->get_meta(); | 
| 1529 | 1529 | $user_info = $payment->user_info; | 
| 1530 | 1530 | |
| 1531 | - $first_name = isset( $user_info['first_name'] ) ? $user_info['first_name'] : ''; | |
| 1532 | - $last_name = isset( $user_info['last_name'] ) ? $user_info['last_name'] : ''; | |
| 1533 | - | |
| 1534 | - $donations['donations'][ $i ]['ID'] = $payment->ID; | |
| 1535 | - $donations['donations'][ $i ]['number'] = $payment->number; | |
| 1536 | - $donations['donations'][ $i ]['transaction_id'] = $payment->transaction_id; | |
| 1537 | - $donations['donations'][ $i ]['key'] = $payment->key; | |
| 1538 | - $donations['donations'][ $i ]['total'] = $payment->total; | |
| 1539 | - $donations['donations'][ $i ]['status'] = give_get_payment_status( $payment, true ); | |
| 1540 | - $donations['donations'][ $i ]['gateway'] = $payment->gateway; | |
| 1541 | - $donations['donations'][ $i ]['name'] = $first_name . ' ' . $last_name; | |
| 1542 | - $donations['donations'][ $i ]['fname'] = $first_name; | |
| 1543 | - $donations['donations'][ $i ]['lname'] = $last_name; | |
| 1544 | - $donations['donations'][ $i ]['email'] = $payment->email; | |
| 1545 | - $donations['donations'][ $i ]['date'] = $payment->date; | |
| 1546 | - $donations['donations'][ $i ]['payment_meta'] = array(); | |
| 1547 | - | |
| 1548 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : $payment_meta; | |
| 1549 | - $price = isset( $payment_meta['form_id'] ) ? give_get_form_price( $payment_meta['form_id'] ) : false; | |
| 1550 | - $price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null; | |
| 1551 | - | |
| 1552 | - $donations['donations'][ $i ]['form']['id'] = $form_id; | |
| 1553 | - $donations['donations'][ $i ]['form']['name'] = get_the_title( $payment_meta['form_id'] ); | |
| 1554 | - $donations['donations'][ $i ]['form']['price'] = $price; | |
| 1555 | - | |
| 1556 | -				if ( give_has_variable_prices( $form_id ) ) { | |
| 1557 | -					if ( isset( $payment_meta['price_id'] ) ) { | |
| 1558 | - $price_name = give_get_price_option_name( $form_id, $payment_meta['price_id'], $payment->ID ); | |
| 1559 | - $donations['donations'][ $i ]['form']['price_name'] = $price_name; | |
| 1560 | - $donations['donations'][ $i ]['form']['price_id'] = $price_id; | |
| 1561 | - $donations['donations'][ $i ]['form']['price'] = give_get_price_option_amount( $form_id, $price_id ); | |
| 1531 | + $first_name = isset($user_info['first_name']) ? $user_info['first_name'] : ''; | |
| 1532 | + $last_name = isset($user_info['last_name']) ? $user_info['last_name'] : ''; | |
| 1533 | + | |
| 1534 | + $donations['donations'][$i]['ID'] = $payment->ID; | |
| 1535 | + $donations['donations'][$i]['number'] = $payment->number; | |
| 1536 | + $donations['donations'][$i]['transaction_id'] = $payment->transaction_id; | |
| 1537 | + $donations['donations'][$i]['key'] = $payment->key; | |
| 1538 | + $donations['donations'][$i]['total'] = $payment->total; | |
| 1539 | + $donations['donations'][$i]['status'] = give_get_payment_status($payment, true); | |
| 1540 | + $donations['donations'][$i]['gateway'] = $payment->gateway; | |
| 1541 | + $donations['donations'][$i]['name'] = $first_name.' '.$last_name; | |
| 1542 | + $donations['donations'][$i]['fname'] = $first_name; | |
| 1543 | + $donations['donations'][$i]['lname'] = $last_name; | |
| 1544 | + $donations['donations'][$i]['email'] = $payment->email; | |
| 1545 | + $donations['donations'][$i]['date'] = $payment->date; | |
| 1546 | + $donations['donations'][$i]['payment_meta'] = array(); | |
| 1547 | + | |
| 1548 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : $payment_meta; | |
| 1549 | + $price = isset($payment_meta['form_id']) ? give_get_form_price($payment_meta['form_id']) : false; | |
| 1550 | + $price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null; | |
| 1551 | + | |
| 1552 | + $donations['donations'][$i]['form']['id'] = $form_id; | |
| 1553 | + $donations['donations'][$i]['form']['name'] = get_the_title($payment_meta['form_id']); | |
| 1554 | + $donations['donations'][$i]['form']['price'] = $price; | |
| 1555 | + | |
| 1556 | +				if (give_has_variable_prices($form_id)) { | |
| 1557 | +					if (isset($payment_meta['price_id'])) { | |
| 1558 | + $price_name = give_get_price_option_name($form_id, $payment_meta['price_id'], $payment->ID); | |
| 1559 | + $donations['donations'][$i]['form']['price_name'] = $price_name; | |
| 1560 | + $donations['donations'][$i]['form']['price_id'] = $price_id; | |
| 1561 | + $donations['donations'][$i]['form']['price'] = give_get_price_option_amount($form_id, $price_id); | |
| 1562 | 1562 | |
| 1563 | 1563 | } | 
| 1564 | 1564 | } | 
| 1565 | 1565 | |
| 1566 | -				if( ! empty( $payment_meta ) ) { | |
| 1566 | +				if ( ! empty($payment_meta)) { | |
| 1567 | 1567 | // Add custom meta to API | 
| 1568 | -					foreach ( $payment_meta as $meta_key => $meta_value ) { | |
| 1568 | +					foreach ($payment_meta as $meta_key => $meta_value) { | |
| 1569 | 1569 | |
| 1570 | 1570 | $exceptions = array( | 
| 1571 | 1571 | 'form_title', | 
| @@ -1578,20 +1578,20 @@ discard block | ||
| 1578 | 1578 | ); | 
| 1579 | 1579 | |
| 1580 | 1580 | // Don't clutter up results with dupes | 
| 1581 | -						if ( in_array( $meta_key, $exceptions ) ) { | |
| 1581 | +						if (in_array($meta_key, $exceptions)) { | |
| 1582 | 1582 | continue; | 
| 1583 | 1583 | } | 
| 1584 | 1584 | |
| 1585 | - $donations['donations'][ $i ]['payment_meta'][ $meta_key ] = $meta_value; | |
| 1585 | + $donations['donations'][$i]['payment_meta'][$meta_key] = $meta_value; | |
| 1586 | 1586 | |
| 1587 | 1587 | } | 
| 1588 | 1588 | } | 
| 1589 | 1589 | |
| 1590 | - $i ++; | |
| 1590 | + $i++; | |
| 1591 | 1591 | }// End foreach(). | 
| 1592 | 1592 | }// End if(). | 
| 1593 | 1593 | |
| 1594 | - return apply_filters( 'give_api_donations_endpoint', $donations ); | |
| 1594 | +		return apply_filters('give_api_donations_endpoint', $donations); | |
| 1595 | 1595 | } | 
| 1596 | 1596 | |
| 1597 | 1597 | /** | 
| @@ -1607,9 +1607,9 @@ discard block | ||
| 1607 | 1607 |  	public function get_output_format() { | 
| 1608 | 1608 | global $wp_query; | 
| 1609 | 1609 | |
| 1610 | - $format = isset( $wp_query->query_vars['format'] ) ? $wp_query->query_vars['format'] : 'json'; | |
| 1610 | + $format = isset($wp_query->query_vars['format']) ? $wp_query->query_vars['format'] : 'json'; | |
| 1611 | 1611 | |
| 1612 | - return apply_filters( 'give_api_output_format', $format ); | |
| 1612 | +		return apply_filters('give_api_output_format', $format); | |
| 1613 | 1613 | } | 
| 1614 | 1614 | |
| 1615 | 1615 | |
| @@ -1625,8 +1625,8 @@ discard block | ||
| 1625 | 1625 | * | 
| 1626 | 1626 | * @return void | 
| 1627 | 1627 | */ | 
| 1628 | -	private function log_request( $data = array() ) { | |
| 1629 | -		if ( ! $this->log_requests ) { | |
| 1628 | +	private function log_request($data = array()) { | |
| 1629 | +		if ( ! $this->log_requests) { | |
| 1630 | 1630 | return; | 
| 1631 | 1631 | } | 
| 1632 | 1632 | |
| @@ -1637,37 +1637,37 @@ discard block | ||
| 1637 | 1637 | |
| 1638 | 1638 | $query = array( | 
| 1639 | 1639 | 'give-api' => $wp_query->query_vars['give-api'], | 
| 1640 | - 'key' => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null, | |
| 1641 | - 'token' => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null, | |
| 1642 | - 'query' => isset( $wp_query->query_vars['query'] ) ? $wp_query->query_vars['query'] : null, | |
| 1643 | - 'type' => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null, | |
| 1644 | - 'form' => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null, | |
| 1645 | - 'donor' => isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null, | |
| 1646 | - 'date' => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null, | |
| 1647 | - 'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null, | |
| 1648 | - 'enddate' => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null, | |
| 1649 | - 'id' => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null, | |
| 1650 | - 'purchasekey' => isset( $wp_query->query_vars['purchasekey'] ) ? $wp_query->query_vars['purchasekey'] : null, | |
| 1651 | - 'email' => isset( $wp_query->query_vars['email'] ) ? $wp_query->query_vars['email'] : null, | |
| 1640 | + 'key' => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null, | |
| 1641 | + 'token' => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null, | |
| 1642 | + 'query' => isset($wp_query->query_vars['query']) ? $wp_query->query_vars['query'] : null, | |
| 1643 | + 'type' => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null, | |
| 1644 | + 'form' => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null, | |
| 1645 | + 'donor' => isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null, | |
| 1646 | + 'date' => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null, | |
| 1647 | + 'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null, | |
| 1648 | + 'enddate' => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null, | |
| 1649 | + 'id' => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null, | |
| 1650 | + 'purchasekey' => isset($wp_query->query_vars['purchasekey']) ? $wp_query->query_vars['purchasekey'] : null, | |
| 1651 | + 'email' => isset($wp_query->query_vars['email']) ? $wp_query->query_vars['email'] : null, | |
| 1652 | 1652 | ); | 
| 1653 | 1653 | |
| 1654 | 1654 | $log_data = array( | 
| 1655 | 1655 | 'log_type' => 'api_request', | 
| 1656 | - 'post_excerpt' => http_build_query( $query ), | |
| 1657 | - 'post_content' => ! empty( $data['error'] ) ? $data['error'] : '', | |
| 1656 | + 'post_excerpt' => http_build_query($query), | |
| 1657 | + 'post_content' => ! empty($data['error']) ? $data['error'] : '', | |
| 1658 | 1658 | ); | 
| 1659 | 1659 | |
| 1660 | 1660 | $log_meta = array( | 
| 1661 | - 'api_query' => http_build_query( $query ), | |
| 1661 | + 'api_query' => http_build_query($query), | |
| 1662 | 1662 | 'request_ip' => give_get_ip(), | 
| 1663 | 1663 | 'user' => $this->user_id, | 
| 1664 | - 'key' => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null, | |
| 1665 | - 'token' => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null, | |
| 1664 | + 'key' => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null, | |
| 1665 | + 'token' => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null, | |
| 1666 | 1666 | 'time' => $data['request_speed'], | 
| 1667 | 1667 | 'version' => $this->get_queried_version(), | 
| 1668 | 1668 | ); | 
| 1669 | 1669 | |
| 1670 | - Give()->logs->insert_log( $log_data, $log_meta ); | |
| 1670 | + Give()->logs->insert_log($log_data, $log_meta); | |
| 1671 | 1671 | } | 
| 1672 | 1672 | |
| 1673 | 1673 | |
| @@ -1691,11 +1691,11 @@ discard block | ||
| 1691 | 1691 | * | 
| 1692 | 1692 | * @param int $status_code | 
| 1693 | 1693 | */ | 
| 1694 | -	public function output( $status_code = 200 ) { | |
| 1694 | +	public function output($status_code = 200) { | |
| 1695 | 1695 | |
| 1696 | 1696 | $format = $this->get_output_format(); | 
| 1697 | 1697 | |
| 1698 | - status_header( $status_code ); | |
| 1698 | + status_header($status_code); | |
| 1699 | 1699 | |
| 1700 | 1700 | /** | 
| 1701 | 1701 | * Fires before outputting the API. | 
| @@ -1706,25 +1706,25 @@ discard block | ||
| 1706 | 1706 | * @param Give_API $this The Give_API object. | 
| 1707 | 1707 | * @param string $format Output format, XML or JSON. Default is JSON. | 
| 1708 | 1708 | */ | 
| 1709 | - do_action( 'give_api_output_before', $this->data, $this, $format ); | |
| 1709 | +		do_action('give_api_output_before', $this->data, $this, $format); | |
| 1710 | 1710 | |
| 1711 | - switch ( $format ) : | |
| 1711 | + switch ($format) : | |
| 1712 | 1712 | |
| 1713 | 1713 | case 'xml' : | 
| 1714 | 1714 | |
| 1715 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/array2xml.php'; | |
| 1716 | - $xml = Array2XML::createXML( 'give', $this->data ); | |
| 1715 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/array2xml.php'; | |
| 1716 | +				$xml = Array2XML::createXML('give', $this->data); | |
| 1717 | 1717 | echo $xml->saveXML(); | 
| 1718 | 1718 | |
| 1719 | 1719 | break; | 
| 1720 | 1720 | |
| 1721 | 1721 | case 'json' : | 
| 1722 | 1722 | |
| 1723 | - header( 'Content-Type: application/json' ); | |
| 1724 | -				if ( ! empty( $this->pretty_print ) ) { | |
| 1725 | - echo json_encode( $this->data, $this->pretty_print ); | |
| 1723 | +				header('Content-Type: application/json'); | |
| 1724 | +				if ( ! empty($this->pretty_print)) { | |
| 1725 | + echo json_encode($this->data, $this->pretty_print); | |
| 1726 | 1726 |  				} else { | 
| 1727 | - echo json_encode( $this->data ); | |
| 1727 | + echo json_encode($this->data); | |
| 1728 | 1728 | } | 
| 1729 | 1729 | |
| 1730 | 1730 | break; | 
| @@ -1739,7 +1739,7 @@ discard block | ||
| 1739 | 1739 | * @param array $data Response data to return. | 
| 1740 | 1740 | * @param Give_API $this The Give_API object. | 
| 1741 | 1741 | */ | 
| 1742 | -				do_action( "give_api_output_{$format}", $this->data, $this ); | |
| 1742 | +				do_action("give_api_output_{$format}", $this->data, $this); | |
| 1743 | 1743 | |
| 1744 | 1744 | break; | 
| 1745 | 1745 | |
| @@ -1754,7 +1754,7 @@ discard block | ||
| 1754 | 1754 | * @param Give_API $this The Give_API object. | 
| 1755 | 1755 | * @param string $format Output format, XML or JSON. Default is JSON. | 
| 1756 | 1756 | */ | 
| 1757 | - do_action( 'give_api_output_after', $this->data, $this, $format ); | |
| 1757 | +		do_action('give_api_output_after', $this->data, $this, $format); | |
| 1758 | 1758 | |
| 1759 | 1759 | give_die(); | 
| 1760 | 1760 | } | 
| @@ -1771,41 +1771,41 @@ discard block | ||
| 1771 | 1771 | * | 
| 1772 | 1772 | * @return void | 
| 1773 | 1773 | */ | 
| 1774 | -	function user_key_field( $user ) { | |
| 1774 | +	function user_key_field($user) { | |
| 1775 | 1775 | |
| 1776 | -		if ( ( give_get_option( 'api_allow_user_keys', false ) || current_user_can( 'manage_give_settings' ) ) && current_user_can( 'edit_user', $user->ID ) ) { | |
| 1776 | +		if ((give_get_option('api_allow_user_keys', false) || current_user_can('manage_give_settings')) && current_user_can('edit_user', $user->ID)) { | |
| 1777 | 1777 | |
| 1778 | - $user = get_userdata( $user->ID ); | |
| 1778 | + $user = get_userdata($user->ID); | |
| 1779 | 1779 | ?> | 
| 1780 | 1780 | <table class="form-table"> | 
| 1781 | 1781 | <tbody> | 
| 1782 | 1782 | <tr> | 
| 1783 | 1783 | <th> | 
| 1784 | - <?php _e( 'Give API Keys', 'give' ); ?> | |
| 1784 | +						<?php _e('Give API Keys', 'give'); ?> | |
| 1785 | 1785 | </th> | 
| 1786 | 1786 | <td> | 
| 1787 | 1787 | <?php | 
| 1788 | - $public_key = $this->get_user_public_key( $user->ID ); | |
| 1789 | - $secret_key = $this->get_user_secret_key( $user->ID ); | |
| 1788 | + $public_key = $this->get_user_public_key($user->ID); | |
| 1789 | + $secret_key = $this->get_user_secret_key($user->ID); | |
| 1790 | 1790 | ?> | 
| 1791 | -						<?php if ( empty( $user->give_user_public_key ) ) { ?> | |
| 1791 | +						<?php if (empty($user->give_user_public_key)) { ?> | |
| 1792 | 1792 | <input name="give_set_api_key" type="checkbox" id="give_set_api_key" /> | 
| 1793 | - <span class="description"><?php _e( 'Generate API Key', 'give' ); ?></span> | |
| 1793 | +							<span class="description"><?php _e('Generate API Key', 'give'); ?></span> | |
| 1794 | 1794 |  						<?php } else { ?> | 
| 1795 | - <strong style="display:inline-block; width: 125px;"><?php _e( 'Public key:', 'give' ); ?> | |
| 1795 | +							<strong style="display:inline-block; width: 125px;"><?php _e('Public key:', 'give'); ?> | |
| 1796 | 1796 |  </strong> | 
| 1797 | - <input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr( $public_key ); ?>" /> | |
| 1797 | + <input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr($public_key); ?>" /> | |
| 1798 | 1798 | <br /> | 
| 1799 | - <strong style="display:inline-block; width: 125px;"><?php _e( 'Secret key:', 'give' ); ?> | |
| 1799 | +							<strong style="display:inline-block; width: 125px;"><?php _e('Secret key:', 'give'); ?> | |
| 1800 | 1800 |  </strong> | 
| 1801 | - <input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr( $secret_key ); ?>" /> | |
| 1801 | + <input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr($secret_key); ?>" /> | |
| 1802 | 1802 | <br /> | 
| 1803 | - <strong style="display:inline-block; width: 125px;"><?php _e( 'Token:', 'give' ); ?> | |
| 1803 | +							<strong style="display:inline-block; width: 125px;"><?php _e('Token:', 'give'); ?> | |
| 1804 | 1804 |  </strong> | 
| 1805 | - <input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr( $this->get_token( $user->ID ) ); ?>" /> | |
| 1805 | + <input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr($this->get_token($user->ID)); ?>" /> | |
| 1806 | 1806 | <br /> | 
| 1807 | 1807 | <input name="give_revoke_api_key" type="checkbox" id="give_revoke_api_key" /> | 
| 1808 | - <span class="description"><label for="give_revoke_api_key"><?php _e( 'Revoke API Keys', 'give' ); ?></label></span> | |
| 1808 | +							<span class="description"><label for="give_revoke_api_key"><?php _e('Revoke API Keys', 'give'); ?></label></span> | |
| 1809 | 1809 | <?php } ?> | 
| 1810 | 1810 | </td> | 
| 1811 | 1811 | </tr> | 
| @@ -1824,61 +1824,61 @@ discard block | ||
| 1824 | 1824 | * | 
| 1825 | 1825 | * @return void | 
| 1826 | 1826 | */ | 
| 1827 | -	public function process_api_key( $args ) { | |
| 1827 | +	public function process_api_key($args) { | |
| 1828 | 1828 | |
| 1829 | -		if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'give-api-nonce' ) ) { | |
| 1830 | - wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( | |
| 1829 | +		if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'give-api-nonce')) { | |
| 1830 | +			wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array( | |
| 1831 | 1831 | 'response' => 403, | 
| 1832 | - ) ); | |
| 1832 | + )); | |
| 1833 | 1833 | } | 
| 1834 | 1834 | |
| 1835 | -		if ( empty( $args['user_id'] ) ) { | |
| 1836 | - wp_die( __( 'User ID Required.', 'give' ), __( 'Error', 'give' ), array( | |
| 1835 | +		if (empty($args['user_id'])) { | |
| 1836 | +			wp_die(__('User ID Required.', 'give'), __('Error', 'give'), array( | |
| 1837 | 1837 | 'response' => 401, | 
| 1838 | - ) ); | |
| 1838 | + )); | |
| 1839 | 1839 | } | 
| 1840 | 1840 | |
| 1841 | -		if ( is_numeric( $args['user_id'] ) ) { | |
| 1842 | - $user_id = isset( $args['user_id'] ) ? absint( $args['user_id'] ) : get_current_user_id(); | |
| 1841 | +		if (is_numeric($args['user_id'])) { | |
| 1842 | + $user_id = isset($args['user_id']) ? absint($args['user_id']) : get_current_user_id(); | |
| 1843 | 1843 |  		} else { | 
| 1844 | - $userdata = get_user_by( 'login', $args['user_id'] ); | |
| 1844 | +			$userdata = get_user_by('login', $args['user_id']); | |
| 1845 | 1845 | $user_id = $userdata->ID; | 
| 1846 | 1846 | } | 
| 1847 | - $process = isset( $args['give_api_process'] ) ? strtolower( $args['give_api_process'] ) : false; | |
| 1847 | + $process = isset($args['give_api_process']) ? strtolower($args['give_api_process']) : false; | |
| 1848 | 1848 | |
| 1849 | -		if ( $user_id == get_current_user_id() && ! give_get_option( 'allow_user_api_keys' ) && ! current_user_can( 'manage_give_settings' ) ) { | |
| 1850 | - wp_die( sprintf( /* translators: %s: process */ | |
| 1851 | - __( 'You do not have permission to %s API keys for this user.', 'give' ), $process ), __( 'Error', 'give' ), array( | |
| 1849 | +		if ($user_id == get_current_user_id() && ! give_get_option('allow_user_api_keys') && ! current_user_can('manage_give_settings')) { | |
| 1850 | + wp_die(sprintf( /* translators: %s: process */ | |
| 1851 | +				__('You do not have permission to %s API keys for this user.', 'give'), $process ), __('Error', 'give'), array( | |
| 1852 | 1852 | 'response' => 403, | 
| 1853 | - ) ); | |
| 1854 | -		} elseif ( ! current_user_can( 'manage_give_settings' ) ) { | |
| 1855 | - wp_die( sprintf( /* translators: %s: process */ | |
| 1856 | - __( 'You do not have permission to %s API keys for this user.', 'give' ), $process ), __( 'Error', 'give' ), array( | |
| 1853 | + )); | |
| 1854 | +		} elseif ( ! current_user_can('manage_give_settings')) { | |
| 1855 | + wp_die(sprintf( /* translators: %s: process */ | |
| 1856 | +				__('You do not have permission to %s API keys for this user.', 'give'), $process ), __('Error', 'give'), array( | |
| 1857 | 1857 | 'response' => 403, | 
| 1858 | - ) ); | |
| 1858 | + )); | |
| 1859 | 1859 | } | 
| 1860 | 1860 | |
| 1861 | -		switch ( $process ) { | |
| 1861 | +		switch ($process) { | |
| 1862 | 1862 | case 'generate': | 
| 1863 | -				if ( $this->generate_api_key( $user_id ) ) { | |
| 1864 | - Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) ); | |
| 1865 | - wp_redirect( add_query_arg( 'give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); | |
| 1863 | +				if ($this->generate_api_key($user_id)) { | |
| 1864 | +					Give_Cache::delete(Give_Cache::get_key('give_total_api_keys')); | |
| 1865 | +					wp_redirect(add_query_arg('give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); | |
| 1866 | 1866 | exit(); | 
| 1867 | 1867 |  				} else { | 
| 1868 | - wp_redirect( add_query_arg( 'give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); | |
| 1868 | +					wp_redirect(add_query_arg('give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); | |
| 1869 | 1869 | exit(); | 
| 1870 | 1870 | } | 
| 1871 | 1871 | break; | 
| 1872 | 1872 | case 'regenerate': | 
| 1873 | - $this->generate_api_key( $user_id, true ); | |
| 1874 | - Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) ); | |
| 1875 | - wp_redirect( add_query_arg( 'give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); | |
| 1873 | + $this->generate_api_key($user_id, true); | |
| 1874 | +				Give_Cache::delete(Give_Cache::get_key('give_total_api_keys')); | |
| 1875 | +				wp_redirect(add_query_arg('give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); | |
| 1876 | 1876 | exit(); | 
| 1877 | 1877 | break; | 
| 1878 | 1878 | case 'revoke': | 
| 1879 | - $this->revoke_api_key( $user_id ); | |
| 1880 | - Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) ); | |
| 1881 | - wp_redirect( add_query_arg( 'give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); | |
| 1879 | + $this->revoke_api_key($user_id); | |
| 1880 | +				Give_Cache::delete(Give_Cache::get_key('give_total_api_keys')); | |
| 1881 | +				wp_redirect(add_query_arg('give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); | |
| 1882 | 1882 | exit(); | 
| 1883 | 1883 | break; | 
| 1884 | 1884 | default; | 
| @@ -1897,59 +1897,59 @@ discard block | ||
| 1897 | 1897 | * | 
| 1898 | 1898 | * @return boolean True if (re)generated successfully, false otherwise. | 
| 1899 | 1899 | */ | 
| 1900 | -	public function generate_api_key( $user_id = 0, $regenerate = false ) { | |
| 1900 | +	public function generate_api_key($user_id = 0, $regenerate = false) { | |
| 1901 | 1901 | |
| 1902 | 1902 | // Bail out, if user doesn't exists. | 
| 1903 | -		if ( empty( $user_id ) ) { | |
| 1903 | +		if (empty($user_id)) { | |
| 1904 | 1904 | return false; | 
| 1905 | 1905 | } | 
| 1906 | 1906 | |
| 1907 | - $user = get_userdata( $user_id ); | |
| 1907 | + $user = get_userdata($user_id); | |
| 1908 | 1908 | |
| 1909 | 1909 | // Bail Out, if user object doesn't exists. | 
| 1910 | -		if ( ! $user ) { | |
| 1910 | +		if ( ! $user) { | |
| 1911 | 1911 | return false; | 
| 1912 | 1912 | } | 
| 1913 | 1913 | |
| 1914 | 1914 | $new_public_key = ''; | 
| 1915 | 1915 | $new_secret_key = ''; | 
| 1916 | 1916 | |
| 1917 | -		if( ! empty( $_POST['from'] ) && 'profile' === $_POST['from'] ) { | |
| 1917 | +		if ( ! empty($_POST['from']) && 'profile' === $_POST['from']) { | |
| 1918 | 1918 | // For User Profile Page. | 
| 1919 | -			if( ! empty( $_POST['give_set_api_key'] ) ) { | |
| 1919 | +			if ( ! empty($_POST['give_set_api_key'])) { | |
| 1920 | 1920 | // Generate API Key from User Profile page. | 
| 1921 | - $new_public_key = $this->generate_public_key( $user->user_email ); | |
| 1922 | - $new_secret_key = $this->generate_private_key( $user->ID ); | |
| 1923 | -			} elseif ( ! empty( $_POST['give_revoke_api_key'] ) ) { | |
| 1921 | + $new_public_key = $this->generate_public_key($user->user_email); | |
| 1922 | + $new_secret_key = $this->generate_private_key($user->ID); | |
| 1923 | +			} elseif ( ! empty($_POST['give_revoke_api_key'])) { | |
| 1924 | 1924 | // Revoke API Key from User Profile page. | 
| 1925 | - $this->revoke_api_key( $user->ID ); | |
| 1925 | + $this->revoke_api_key($user->ID); | |
| 1926 | 1926 |  			} else { | 
| 1927 | 1927 | return false; | 
| 1928 | 1928 | } | 
| 1929 | 1929 |  		} else { | 
| 1930 | 1930 | // For Tools > API page. | 
| 1931 | - $public_key = $this->get_user_public_key( $user_id ); | |
| 1931 | + $public_key = $this->get_user_public_key($user_id); | |
| 1932 | 1932 | |
| 1933 | -			if ( empty( $public_key ) && ! $regenerate ) { | |
| 1933 | +			if (empty($public_key) && ! $regenerate) { | |
| 1934 | 1934 | // Generating API for first time. | 
| 1935 | - $new_public_key = $this->generate_public_key( $user->user_email ); | |
| 1936 | - $new_secret_key = $this->generate_private_key( $user->ID ); | |
| 1937 | -			} elseif ( $public_key && $regenerate ) { | |
| 1935 | + $new_public_key = $this->generate_public_key($user->user_email); | |
| 1936 | + $new_secret_key = $this->generate_private_key($user->ID); | |
| 1937 | +			} elseif ($public_key && $regenerate) { | |
| 1938 | 1938 | // API Key already exists and Regenerating API Key. | 
| 1939 | - $this->revoke_api_key( $user->ID ); | |
| 1940 | - $new_public_key = $this->generate_public_key( $user->user_email ); | |
| 1941 | - $new_secret_key = $this->generate_private_key( $user->ID ); | |
| 1942 | -			} elseif ( ! empty( $public_key ) && ! $regenerate ) { | |
| 1939 | + $this->revoke_api_key($user->ID); | |
| 1940 | + $new_public_key = $this->generate_public_key($user->user_email); | |
| 1941 | + $new_secret_key = $this->generate_private_key($user->ID); | |
| 1942 | +			} elseif ( ! empty($public_key) && ! $regenerate) { | |
| 1943 | 1943 | // Doing nothing, when API Key exists but still try to generate again instead of regenerating. | 
| 1944 | 1944 | return false; | 
| 1945 | 1945 |  			} else { | 
| 1946 | 1946 | // Revoke API Key. | 
| 1947 | - $this->revoke_api_key( $user->ID ); | |
| 1947 | + $this->revoke_api_key($user->ID); | |
| 1948 | 1948 | } | 
| 1949 | 1949 | } | 
| 1950 | 1950 | |
| 1951 | - update_user_meta( $user_id, $new_public_key, 'give_user_public_key' ); | |
| 1952 | - update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' ); | |
| 1951 | + update_user_meta($user_id, $new_public_key, 'give_user_public_key'); | |
| 1952 | + update_user_meta($user_id, $new_secret_key, 'give_user_secret_key'); | |
| 1953 | 1953 | |
| 1954 | 1954 | return true; | 
| 1955 | 1955 | } | 
| @@ -1964,26 +1964,26 @@ discard block | ||
| 1964 | 1964 | * | 
| 1965 | 1965 | * @return bool | 
| 1966 | 1966 | */ | 
| 1967 | -	public function revoke_api_key( $user_id = 0 ) { | |
| 1967 | +	public function revoke_api_key($user_id = 0) { | |
| 1968 | 1968 | |
| 1969 | -		if ( empty( $user_id ) ) { | |
| 1969 | +		if (empty($user_id)) { | |
| 1970 | 1970 | return false; | 
| 1971 | 1971 | } | 
| 1972 | 1972 | |
| 1973 | - $user = get_userdata( $user_id ); | |
| 1973 | + $user = get_userdata($user_id); | |
| 1974 | 1974 | |
| 1975 | -		if ( ! $user ) { | |
| 1975 | +		if ( ! $user) { | |
| 1976 | 1976 | return false; | 
| 1977 | 1977 | } | 
| 1978 | 1978 | |
| 1979 | - $public_key = $this->get_user_public_key( $user_id ); | |
| 1980 | - $secret_key = $this->get_user_secret_key( $user_id ); | |
| 1981 | -		if ( ! empty( $public_key ) ) { | |
| 1982 | - Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_' . $public_key ) ) ); | |
| 1983 | - Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_public_key' . $user_id ) ) ); | |
| 1984 | - Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_secret_key' . $user_id ) ) ); | |
| 1985 | - delete_user_meta( $user_id, $public_key ); | |
| 1986 | - delete_user_meta( $user_id, $secret_key ); | |
| 1979 | + $public_key = $this->get_user_public_key($user_id); | |
| 1980 | + $secret_key = $this->get_user_secret_key($user_id); | |
| 1981 | +		if ( ! empty($public_key)) { | |
| 1982 | +			Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_'.$public_key))); | |
| 1983 | +			Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_public_key'.$user_id))); | |
| 1984 | +			Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_secret_key'.$user_id))); | |
| 1985 | + delete_user_meta($user_id, $public_key); | |
| 1986 | + delete_user_meta($user_id, $secret_key); | |
| 1987 | 1987 |  		} else { | 
| 1988 | 1988 | return false; | 
| 1989 | 1989 | } | 
| @@ -2005,9 +2005,9 @@ discard block | ||
| 2005 | 2005 | * | 
| 2006 | 2006 | * @return string | 
| 2007 | 2007 | */ | 
| 2008 | -	private function generate_public_key( $user_email = '' ) { | |
| 2009 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; | |
| 2010 | - $public = hash( 'md5', $user_email . $auth_key . date( 'U' ) ); | |
| 2008 | +	private function generate_public_key($user_email = '') { | |
| 2009 | +		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; | |
| 2010 | +		$public   = hash('md5', $user_email.$auth_key.date('U')); | |
| 2011 | 2011 | |
| 2012 | 2012 | return $public; | 
| 2013 | 2013 | } | 
| @@ -2022,9 +2022,9 @@ discard block | ||
| 2022 | 2022 | * | 
| 2023 | 2023 | * @return string | 
| 2024 | 2024 | */ | 
| 2025 | -	private function generate_private_key( $user_id = 0 ) { | |
| 2026 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; | |
| 2027 | - $secret = hash( 'md5', $user_id . $auth_key . date( 'U' ) ); | |
| 2025 | +	private function generate_private_key($user_id = 0) { | |
| 2026 | +		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; | |
| 2027 | +		$secret   = hash('md5', $user_id.$auth_key.date('U')); | |
| 2028 | 2028 | |
| 2029 | 2029 | return $secret; | 
| 2030 | 2030 | } | 
| @@ -2039,8 +2039,8 @@ discard block | ||
| 2039 | 2039 | * | 
| 2040 | 2040 | * @return string | 
| 2041 | 2041 | */ | 
| 2042 | -	public function get_token( $user_id = 0 ) { | |
| 2043 | - return hash( 'md5', $this->get_user_secret_key( $user_id ) . $this->get_user_public_key( $user_id ) ); | |
| 2042 | +	public function get_token($user_id = 0) { | |
| 2043 | +		return hash('md5', $this->get_user_secret_key($user_id).$this->get_user_public_key($user_id)); | |
| 2044 | 2044 | } | 
| 2045 | 2045 | |
| 2046 | 2046 | /** | 
| @@ -2054,9 +2054,9 @@ discard block | ||
| 2054 | 2054 | |
| 2055 | 2055 | // Default sales return | 
| 2056 | 2056 | $donations = array(); | 
| 2057 | - $donations['donations']['today'] = $this->stats->get_sales( 0, 'today' ); | |
| 2058 | - $donations['donations']['current_month'] = $this->stats->get_sales( 0, 'this_month' ); | |
| 2059 | - $donations['donations']['last_month'] = $this->stats->get_sales( 0, 'last_month' ); | |
| 2057 | + $donations['donations']['today'] = $this->stats->get_sales(0, 'today'); | |
| 2058 | + $donations['donations']['current_month'] = $this->stats->get_sales(0, 'this_month'); | |
| 2059 | + $donations['donations']['last_month'] = $this->stats->get_sales(0, 'last_month'); | |
| 2060 | 2060 | $donations['donations']['totals'] = give_get_total_donations(); | 
| 2061 | 2061 | |
| 2062 | 2062 | return $donations; | 
| @@ -2073,9 +2073,9 @@ discard block | ||
| 2073 | 2073 | |
| 2074 | 2074 | // Default earnings return | 
| 2075 | 2075 | $earnings = array(); | 
| 2076 | - $earnings['earnings']['today'] = $this->stats->get_earnings( 0, 'today' ); | |
| 2077 | - $earnings['earnings']['current_month'] = $this->stats->get_earnings( 0, 'this_month' ); | |
| 2078 | - $earnings['earnings']['last_month'] = $this->stats->get_earnings( 0, 'last_month' ); | |
| 2076 | + $earnings['earnings']['today'] = $this->stats->get_earnings(0, 'today'); | |
| 2077 | + $earnings['earnings']['current_month'] = $this->stats->get_earnings(0, 'this_month'); | |
| 2078 | + $earnings['earnings']['last_month'] = $this->stats->get_earnings(0, 'last_month'); | |
| 2079 | 2079 | $earnings['earnings']['totals'] = give_get_total_earnings(); | 
| 2080 | 2080 | |
| 2081 | 2081 | return $earnings; | 
| @@ -2095,25 +2095,25 @@ discard block | ||
| 2095 | 2095 | * | 
| 2096 | 2096 | * @return string The API key/secret for the user supplied | 
| 2097 | 2097 | */ | 
| 2098 | -	public function api_key_backwards_compat( $check, $object_id, $meta_key, $single ) { | |
| 2098 | +	public function api_key_backwards_compat($check, $object_id, $meta_key, $single) { | |
| 2099 | 2099 | |
| 2100 | -		if ( $meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key' ) { | |
| 2100 | +		if ($meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key') { | |
| 2101 | 2101 | return $check; | 
| 2102 | 2102 | } | 
| 2103 | 2103 | |
| 2104 | 2104 | $return = $check; | 
| 2105 | 2105 | |
| 2106 | -		switch ( $meta_key ) { | |
| 2106 | +		switch ($meta_key) { | |
| 2107 | 2107 | case 'give_user_public_key': | 
| 2108 | - $return = Give()->api->get_user_public_key( $object_id ); | |
| 2108 | + $return = Give()->api->get_user_public_key($object_id); | |
| 2109 | 2109 | break; | 
| 2110 | 2110 | case 'give_user_secret_key': | 
| 2111 | - $return = Give()->api->get_user_secret_key( $object_id ); | |
| 2111 | + $return = Give()->api->get_user_secret_key($object_id); | |
| 2112 | 2112 | break; | 
| 2113 | 2113 | } | 
| 2114 | 2114 | |
| 2115 | -		if ( ! $single ) { | |
| 2116 | - $return = array( $return ); | |
| 2115 | +		if ( ! $single) { | |
| 2116 | + $return = array($return); | |
| 2117 | 2117 | } | 
| 2118 | 2118 | |
| 2119 | 2119 | return $return; | 
| @@ -37,8 +37,8 @@ discard block | ||
| 37 | 37 | * @since 2.1.0 | 
| 38 | 38 | */ | 
| 39 | 39 |  	public function __construct() { | 
| 40 | - $this->direction = ( is_rtl() || isset( $_GET['d'] ) && 'rtl' === $_GET['d'] ) ? '.rtl' : ''; | |
| 41 | - $this->scripts_footer = give_is_setting_enabled( give_get_option( 'scripts_footer' ) ) ? true : false; | |
| 40 | + $this->direction = (is_rtl() || isset($_GET['d']) && 'rtl' === $_GET['d']) ? '.rtl' : ''; | |
| 41 | +		$this->scripts_footer = give_is_setting_enabled(give_get_option('scripts_footer')) ? true : false; | |
| 42 | 42 | $this->init(); | 
| 43 | 43 | } | 
| 44 | 44 | |
| @@ -49,20 +49,20 @@ discard block | ||
| 49 | 49 | */ | 
| 50 | 50 |  	public function init() { | 
| 51 | 51 | |
| 52 | - add_action( 'admin_enqueue_scripts', array( $this, 'register_styles' ) ); | |
| 53 | - add_action( 'admin_enqueue_scripts', array( $this, 'register_scripts' ) ); | |
| 54 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_styles' ) ); | |
| 55 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); | |
| 52 | +		add_action('admin_enqueue_scripts', array($this, 'register_styles')); | |
| 53 | +		add_action('admin_enqueue_scripts', array($this, 'register_scripts')); | |
| 54 | +		add_action('wp_enqueue_scripts', array($this, 'register_styles')); | |
| 55 | +		add_action('wp_enqueue_scripts', array($this, 'register_scripts')); | |
| 56 | 56 | |
| 57 | -		if ( is_admin() ) { | |
| 58 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); | |
| 59 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_styles' ) ); | |
| 60 | - add_action( 'enqueue_block_editor_assets', array( $this, 'gutenberg_admin_scripts' ) ); | |
| 61 | - add_action( 'admin_head', array( $this, 'global_admin_head' ) ); | |
| 57 | +		if (is_admin()) { | |
| 58 | +			add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); | |
| 59 | +			add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_styles')); | |
| 60 | +			add_action('enqueue_block_editor_assets', array($this, 'gutenberg_admin_scripts')); | |
| 61 | +			add_action('admin_head', array($this, 'global_admin_head')); | |
| 62 | 62 | |
| 63 | 63 |  		} else { | 
| 64 | - add_action( 'wp_enqueue_scripts', array( $this, 'public_enqueue_styles' ) ); | |
| 65 | - add_action( 'wp_enqueue_scripts', array( $this, 'public_enqueue_scripts' ) ); | |
| 64 | +			add_action('wp_enqueue_scripts', array($this, 'public_enqueue_styles')); | |
| 65 | +			add_action('wp_enqueue_scripts', array($this, 'public_enqueue_scripts')); | |
| 66 | 66 | } | 
| 67 | 67 | } | 
| 68 | 68 | |
| @@ -74,11 +74,11 @@ discard block | ||
| 74 | 74 |  	public function register_styles() { | 
| 75 | 75 | |
| 76 | 76 | // WP-admin. | 
| 77 | - wp_register_style( 'give-admin-styles', GIVE_PLUGIN_URL . 'assets/dist/css/admin' . $this->direction . '.css', array(), GIVE_VERSION ); | |
| 77 | +		wp_register_style('give-admin-styles', GIVE_PLUGIN_URL.'assets/dist/css/admin'.$this->direction.'.css', array(), GIVE_VERSION); | |
| 78 | 78 | |
| 79 | 79 | // Frontend. | 
| 80 | -		if ( give_is_setting_enabled( give_get_option( 'css' ) ) ) { | |
| 81 | - wp_register_style( 'give-styles', $this->get_frontend_stylesheet_uri(), array(), GIVE_VERSION, 'all' ); | |
| 80 | +		if (give_is_setting_enabled(give_get_option('css'))) { | |
| 81 | +			wp_register_style('give-styles', $this->get_frontend_stylesheet_uri(), array(), GIVE_VERSION, 'all'); | |
| 82 | 82 | } | 
| 83 | 83 | } | 
| 84 | 84 | |
| @@ -90,15 +90,15 @@ discard block | ||
| 90 | 90 |  	public function register_scripts() { | 
| 91 | 91 | |
| 92 | 92 | // WP-Admin. | 
| 93 | - wp_register_script( 'give-admin-scripts', GIVE_PLUGIN_URL . 'assets/dist/js/admin.js', array( | |
| 93 | +		wp_register_script('give-admin-scripts', GIVE_PLUGIN_URL.'assets/dist/js/admin.js', array( | |
| 94 | 94 | 'jquery', | 
| 95 | 95 | 'jquery-ui-datepicker', | 
| 96 | 96 | 'wp-color-picker', | 
| 97 | 97 | 'jquery-query', | 
| 98 | - ), GIVE_VERSION ); | |
| 98 | + ), GIVE_VERSION); | |
| 99 | 99 | |
| 100 | 100 | // Frontend. | 
| 101 | - wp_register_script( 'give', GIVE_PLUGIN_URL . 'assets/dist/js/give.js', array( 'jquery' ), GIVE_VERSION, $this->scripts_footer ); | |
| 101 | +		wp_register_script('give', GIVE_PLUGIN_URL.'assets/dist/js/give.js', array('jquery'), GIVE_VERSION, $this->scripts_footer); | |
| 102 | 102 | } | 
| 103 | 103 | |
| 104 | 104 | /** | 
| @@ -108,20 +108,20 @@ discard block | ||
| 108 | 108 | * | 
| 109 | 109 | * @param string $hook Page hook. | 
| 110 | 110 | */ | 
| 111 | -	public function admin_enqueue_styles( $hook ) { | |
| 111 | +	public function admin_enqueue_styles($hook) { | |
| 112 | 112 | |
| 113 | 113 | // Give Admin Only. | 
| 114 | -		if ( ! apply_filters( 'give_load_admin_styles', give_is_admin_page(), $hook ) ) { | |
| 114 | +		if ( ! apply_filters('give_load_admin_styles', give_is_admin_page(), $hook)) { | |
| 115 | 115 | return; | 
| 116 | 116 | } | 
| 117 | 117 | |
| 118 | 118 | // Give enqueues. | 
| 119 | - wp_enqueue_style( 'give-admin-styles' ); | |
| 120 | - wp_enqueue_style( 'give-admin-bar-notification' ); | |
| 119 | +		wp_enqueue_style('give-admin-styles'); | |
| 120 | +		wp_enqueue_style('give-admin-bar-notification'); | |
| 121 | 121 | |
| 122 | 122 | // WP Core enqueues. | 
| 123 | - wp_enqueue_style( 'wp-color-picker' ); | |
| 124 | - wp_enqueue_style( 'thickbox' ); // @TODO remove once we have modal API. | |
| 123 | +		wp_enqueue_style('wp-color-picker'); | |
| 124 | +		wp_enqueue_style('thickbox'); // @TODO remove once we have modal API. | |
| 125 | 125 | |
| 126 | 126 | } | 
| 127 | 127 | |
| @@ -132,21 +132,21 @@ discard block | ||
| 132 | 132 | * | 
| 133 | 133 | * @param string $hook Page hook. | 
| 134 | 134 | */ | 
| 135 | -	public function admin_enqueue_scripts( $hook ) { | |
| 135 | +	public function admin_enqueue_scripts($hook) { | |
| 136 | 136 | |
| 137 | 137 | // Give Admin Only. | 
| 138 | -		if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) { | |
| 138 | +		if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) { | |
| 139 | 139 | return; | 
| 140 | 140 | } | 
| 141 | 141 | |
| 142 | 142 | // WP Scripts. | 
| 143 | - wp_enqueue_script( 'wp-color-picker' ); | |
| 144 | - wp_enqueue_script( 'jquery-ui-datepicker' ); | |
| 145 | - wp_enqueue_script( 'thickbox' ); | |
| 143 | +		wp_enqueue_script('wp-color-picker'); | |
| 144 | +		wp_enqueue_script('jquery-ui-datepicker'); | |
| 145 | +		wp_enqueue_script('thickbox'); | |
| 146 | 146 | wp_enqueue_media(); | 
| 147 | 147 | |
| 148 | 148 | // Give admin scripts. | 
| 149 | - wp_enqueue_script( 'give-admin-scripts' ); | |
| 149 | +		wp_enqueue_script('give-admin-scripts'); | |
| 150 | 150 | |
| 151 | 151 | // Localize admin scripts | 
| 152 | 152 | $this->admin_localize_scripts(); | 
| @@ -166,111 +166,111 @@ discard block | ||
| 166 | 166 | $decimal_separator = give_get_price_decimal_separator(); | 
| 167 | 167 | |
| 168 | 168 | // Localize strings & variables for JS. | 
| 169 | - wp_localize_script( 'give-admin-scripts', 'give_vars', array( | |
| 170 | - 'post_id' => isset( $post->ID ) ? $post->ID : null, | |
| 169 | +		wp_localize_script('give-admin-scripts', 'give_vars', array( | |
| 170 | + 'post_id' => isset($post->ID) ? $post->ID : null, | |
| 171 | 171 | 'give_version' => GIVE_VERSION, | 
| 172 | 172 | 'thousands_separator' => $thousand_separator, | 
| 173 | 173 | 'decimal_separator' => $decimal_separator, | 
| 174 | - 'quick_edit_warning' => __( 'Not available for variable priced forms.', 'give' ), | |
| 175 | - 'delete_payment' => __( 'Are you sure you want to <strong>permanently</strong> delete this donation?', 'give' ), | |
| 176 | - 'delete_payment_note' => __( 'Are you sure you want to delete this note?', 'give' ), | |
| 177 | - 'revoke_api_key' => __( 'Are you sure you want to revoke this API key?', 'give' ), | |
| 178 | - 'regenerate_api_key' => __( 'Are you sure you want to regenerate this API key?', 'give' ), | |
| 179 | - 'resend_receipt' => __( 'Are you sure you want to resend the donation receipt?', 'give' ), | |
| 180 | - 'disconnect_user' => __( 'Are you sure you want to disconnect the user from this donor?', 'give' ), | |
| 181 | - 'one_option' => __( 'Choose a form', 'give' ), | |
| 182 | - 'one_or_more_option' => __( 'Choose one or more forms', 'give' ), | |
| 183 | - 'currency_sign' => give_currency_filter( '' ), | |
| 184 | - 'currency_pos' => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before', | |
| 174 | +			'quick_edit_warning'                => __('Not available for variable priced forms.', 'give'), | |
| 175 | +			'delete_payment'                    => __('Are you sure you want to <strong>permanently</strong> delete this donation?', 'give'), | |
| 176 | +			'delete_payment_note'               => __('Are you sure you want to delete this note?', 'give'), | |
| 177 | +			'revoke_api_key'                    => __('Are you sure you want to revoke this API key?', 'give'), | |
| 178 | +			'regenerate_api_key'                => __('Are you sure you want to regenerate this API key?', 'give'), | |
| 179 | +			'resend_receipt'                    => __('Are you sure you want to resend the donation receipt?', 'give'), | |
| 180 | +			'disconnect_user'                   => __('Are you sure you want to disconnect the user from this donor?', 'give'), | |
| 181 | +			'one_option'                        => __('Choose a form', 'give'), | |
| 182 | +			'one_or_more_option'                => __('Choose one or more forms', 'give'), | |
| 183 | +			'currency_sign'                     => give_currency_filter(''), | |
| 184 | + 'currency_pos' => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before', | |
| 185 | 185 | 'currency_decimals' => give_get_price_decimals(), | 
| 186 | - 'ok' => __( 'Ok', 'give' ), | |
| 187 | - 'cancel' => __( 'Cancel', 'give' ), | |
| 188 | - 'close' => __( 'Close', 'give' ), | |
| 189 | - 'confirm' => __( 'Confirm', 'give' ), | |
| 190 | - 'confirm_action' => __( 'Confirm Action', 'give' ), | |
| 191 | - 'confirm_deletion' => __( 'Confirm Deletion', 'give' ), | |
| 192 | - 'confirm_delete_donation' => __( 'Confirm Delete Donation', 'give' ), | |
| 193 | - 'confirm_resend' => __( 'Confirm re-send', 'give' ), | |
| 194 | - 'confirm_bulk_action' => __( 'Confirm bulk action', 'give' ), | |
| 195 | - 'restart_upgrade' => __( 'Do you want to restart the update process?', 'give' ), | |
| 196 | - 'restart_update' => __( 'It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give' ), | |
| 197 | - 'stop_upgrade' => __( 'Do you want to stop the update process now?', 'give' ), | |
| 198 | - 'import_failed' => __( 'Import failed', 'give' ), | |
| 199 | - 'flush_success' => __( 'Flush success', 'give' ), | |
| 200 | - 'flush_error' => __( 'Flush error', 'give' ), | |
| 201 | - 'batch_export_no_class' => __( 'You must choose a method.', 'give' ), | |
| 202 | - 'batch_export_no_reqs' => __( 'Required fields not completed.', 'give' ), | |
| 203 | - 'reset_stats_warn' => __( 'Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give' ), | |
| 204 | - 'delete_test_donor' => __( 'Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give' ), | |
| 205 | - 'delete_import_donor' => __( 'Are you sure you want to delete all the imported donors? This process will also delete imported donations as well.', 'give' ), | |
| 206 | - 'price_format_guide' => sprintf( __( 'Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give' ), $decimal_separator, $thousand_separator ), | |
| 186 | +			'ok'                                => __('Ok', 'give'), | |
| 187 | +			'cancel'                            => __('Cancel', 'give'), | |
| 188 | +			'close'                             => __('Close', 'give'), | |
| 189 | +			'confirm'                           => __('Confirm', 'give'), | |
| 190 | +			'confirm_action'                    => __('Confirm Action', 'give'), | |
| 191 | +			'confirm_deletion'                  => __('Confirm Deletion', 'give'), | |
| 192 | +			'confirm_delete_donation'           => __('Confirm Delete Donation', 'give'), | |
| 193 | +			'confirm_resend'                    => __('Confirm re-send', 'give'), | |
| 194 | +			'confirm_bulk_action'               => __('Confirm bulk action', 'give'), | |
| 195 | +			'restart_upgrade'                   => __('Do you want to restart the update process?', 'give'), | |
| 196 | +			'restart_update'                    => __('It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give'), | |
| 197 | +			'stop_upgrade'                      => __('Do you want to stop the update process now?', 'give'), | |
| 198 | +			'import_failed'                     => __('Import failed', 'give'), | |
| 199 | +			'flush_success'                     => __('Flush success', 'give'), | |
| 200 | +			'flush_error'                       => __('Flush error', 'give'), | |
| 201 | +			'batch_export_no_class'             => __('You must choose a method.', 'give'), | |
| 202 | +			'batch_export_no_reqs'              => __('Required fields not completed.', 'give'), | |
| 203 | +			'reset_stats_warn'                  => __('Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give'), | |
| 204 | +			'delete_test_donor'                 => __('Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give'), | |
| 205 | +			'delete_import_donor'               => __('Are you sure you want to delete all the imported donors? This process will also delete imported donations as well.', 'give'), | |
| 206 | +			'price_format_guide'                => sprintf(__('Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give'), $decimal_separator, $thousand_separator), | |
| 207 | 207 | /* translators : %s: Donation form options metabox */ | 
| 208 | - 'confirm_before_remove_row_text' => __( 'Do you want to delete this item?', 'give' ), | |
| 209 | - 'matched_success_failure_page' => __( 'You cannot set the success and failed pages to the same page', 'give' ), | |
| 210 | - 'dismiss_notice_text' => __( 'Dismiss this notice.', 'give' ), | |
| 211 | - 'search_placeholder' => __( 'Type to search all forms', 'give' ), | |
| 212 | - 'search_placeholder_donor' => __( 'Type to search all donors', 'give' ), | |
| 213 | - 'search_placeholder_country' => __( 'Type to search all countries', 'give' ), | |
| 214 | - 'search_placeholder_state' => __( 'Type to search all states/provinces', 'give' ), | |
| 215 | - 'unlock_donor_fields_title' => __( 'Action forbidden', 'give' ), | |
| 216 | - 'unlock_donor_fields_message' => __( 'To edit first name and last name, please go to user profile of the donor.', 'give' ), | |
| 217 | - 'remove_from_bulk_delete' => __( 'Remove from Bulk Delete', 'give' ), | |
| 208 | +			'confirm_before_remove_row_text'    => __('Do you want to delete this item?', 'give'), | |
| 209 | +			'matched_success_failure_page'      => __('You cannot set the success and failed pages to the same page', 'give'), | |
| 210 | +			'dismiss_notice_text'               => __('Dismiss this notice.', 'give'), | |
| 211 | +			'search_placeholder'                => __('Type to search all forms', 'give'), | |
| 212 | +			'search_placeholder_donor'          => __('Type to search all donors', 'give'), | |
| 213 | +			'search_placeholder_country'        => __('Type to search all countries', 'give'), | |
| 214 | +			'search_placeholder_state'          => __('Type to search all states/provinces', 'give'), | |
| 215 | +			'unlock_donor_fields_title'         => __('Action forbidden', 'give'), | |
| 216 | +			'unlock_donor_fields_message'               => __('To edit first name and last name, please go to user profile of the donor.', 'give'), | |
| 217 | +			'remove_from_bulk_delete'           => __('Remove from Bulk Delete', 'give'), | |
| 218 | 218 | 'donors_bulk_action' => array( | 
| 219 | 219 | 'no_donor_selected' => array( | 
| 220 | - 'title' => __( 'No donors selected', 'give' ), | |
| 221 | - 'desc' => __( 'You must choose at least one or more donors to delete.', 'give' ) | |
| 220 | +					'title' => __('No donors selected', 'give'), | |
| 221 | +					'desc'  => __('You must choose at least one or more donors to delete.', 'give') | |
| 222 | 222 | ), | 
| 223 | 223 | 'no_action_selected' => array( | 
| 224 | - 'title' => __( 'No action selected', 'give' ), | |
| 225 | - 'desc' => __( 'You must select a bulk action to proceed.', 'give' ), | |
| 224 | +					'title' => __('No action selected', 'give'), | |
| 225 | +					'desc'  => __('You must select a bulk action to proceed.', 'give'), | |
| 226 | 226 | ), | 
| 227 | 227 | ), | 
| 228 | 228 | 'donations_bulk_action' => array( | 
| 229 | 229 | 'titles' => array( | 
| 230 | - 'zero' => __( 'No payments selected', 'give' ), | |
| 230 | +					'zero' => __('No payments selected', 'give'), | |
| 231 | 231 | ), | 
| 232 | 232 | 'delete' => array( | 
| 233 | - 'zero' => __( 'You must choose at least one or more donations to delete.', 'give' ), | |
| 234 | - 'single' => __( 'Are you sure you want to permanently delete this donation?', 'give' ), | |
| 235 | -					'multiple' => __( 'Are you sure you want to permanently delete the selected {payment_count} donations?', 'give' ), | |
| 233 | +					'zero'     => __('You must choose at least one or more donations to delete.', 'give'), | |
| 234 | +					'single'   => __('Are you sure you want to permanently delete this donation?', 'give'), | |
| 235 | +					'multiple' => __('Are you sure you want to permanently delete the selected {payment_count} donations?', 'give'), | |
| 236 | 236 | ), | 
| 237 | 237 | 'resend-receipt' => array( | 
| 238 | - 'zero' => __( 'You must choose at least one or more recipients to resend the email receipt.', 'give' ), | |
| 239 | - 'single' => __( 'Are you sure you want to resend the email receipt to this recipient?', 'give' ), | |
| 240 | -					'multiple' => __( 'Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give' ), | |
| 238 | +					'zero'     => __('You must choose at least one or more recipients to resend the email receipt.', 'give'), | |
| 239 | +					'single'   => __('Are you sure you want to resend the email receipt to this recipient?', 'give'), | |
| 240 | +					'multiple' => __('Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give'), | |
| 241 | 241 | ), | 
| 242 | 242 | 'set-to-status' => array( | 
| 243 | -					'zero'     => __( 'You must choose at least one or more donations to set status to {status}.', 'give' ), | |
| 244 | -					'single'   => __( 'Are you sure you want to set status of this donation to {status}?', 'give' ), | |
| 245 | -					'multiple' => __( 'Are you sure you want to set status of {payment_count} donations to {status}?', 'give' ), | |
| 243 | +					'zero'     => __('You must choose at least one or more donations to set status to {status}.', 'give'), | |
| 244 | +					'single'   => __('Are you sure you want to set status of this donation to {status}?', 'give'), | |
| 245 | +					'multiple' => __('Are you sure you want to set status of {payment_count} donations to {status}?', 'give'), | |
| 246 | 246 | ), | 
| 247 | 247 | ), | 
| 248 | 248 | 'updates' => array( | 
| 249 | - 'ajax_error' => __( 'Please reload this page and try again', 'give' ), | |
| 249 | +				'ajax_error' => __('Please reload this page and try again', 'give'), | |
| 250 | 250 | ), | 
| 251 | 251 | 'metabox_fields' => array( | 
| 252 | 252 | 'media' => array( | 
| 253 | - 'button_title' => __( 'Choose Image', 'give' ), | |
| 253 | +					'button_title' => __('Choose Image', 'give'), | |
| 254 | 254 | ), | 
| 255 | 255 | 'file' => array( | 
| 256 | - 'button_title' => __( 'Choose File', 'give' ), | |
| 256 | +					'button_title' => __('Choose File', 'give'), | |
| 257 | 257 | ), | 
| 258 | 258 | ), | 
| 259 | 259 | 'chosen' => array( | 
| 260 | -				'no_results_msg'  => __( 'No results match {search_term}', 'give' ), | |
| 261 | -				'ajax_search_msg' => __( 'Searching results for match {search_term}', 'give' ), | |
| 260 | +				'no_results_msg'  => __('No results match {search_term}', 'give'), | |
| 261 | +				'ajax_search_msg' => __('Searching results for match {search_term}', 'give'), | |
| 262 | 262 | ), | 
| 263 | - 'db_update_confirmation_msg_button' => __( 'Run Updates', 'give' ), | |
| 264 | - 'db_update_confirmation_msg' => __( 'The following process will make updates to your site\'s database. Please create a database backup before proceeding with updates.', 'give' ), | |
| 265 | - 'error_message' => __( 'Something went wrong kindly try again!', 'give' ), | |
| 263 | +			'db_update_confirmation_msg_button' => __('Run Updates', 'give'), | |
| 264 | +			'db_update_confirmation_msg'        => __('The following process will make updates to your site\'s database. Please create a database backup before proceeding with updates.', 'give'), | |
| 265 | +			'error_message'                     => __('Something went wrong kindly try again!', 'give'), | |
| 266 | 266 | 'give_donation_import' => 'give_donation_import', | 
| 267 | 267 | 'core_settings_import' => 'give_core_settings_import', | 
| 268 | - 'setting_not_save_message' => __( 'Changes you made may not be saved.', 'give' ), | |
| 268 | +			'setting_not_save_message'          => __('Changes you made may not be saved.', 'give'), | |
| 269 | 269 | 'give_donation_amounts' => array( | 
| 270 | - 'minimum' => apply_filters( 'give_donation_minimum_limit', 1 ), | |
| 271 | - 'maximum' => apply_filters( 'give_donation_maximum_limit', 999999.99 ), | |
| 270 | +				'minimum' => apply_filters('give_donation_minimum_limit', 1), | |
| 271 | +				'maximum' => apply_filters('give_donation_maximum_limit', 999999.99), | |
| 272 | 272 | ), | 
| 273 | - ) ); | |
| 273 | + )); | |
| 274 | 274 | } | 
| 275 | 275 | |
| 276 | 276 | /** | 
| @@ -281,10 +281,10 @@ discard block | ||
| 281 | 281 | <style type="text/css" media="screen"> | 
| 282 | 282 |  			@font-face { | 
| 283 | 283 | font-family: 'give-icomoon'; | 
| 284 | -				src: url('<?php echo GIVE_PLUGIN_URL . 'assets/dist/fonts/icomoon.eot?ngjl88'; ?>'); | |
| 285 | -				src: url('<?php echo GIVE_PLUGIN_URL . 'assets/dist/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'), | |
| 286 | -				url('<?php echo GIVE_PLUGIN_URL . 'assets/dist/fonts/icomoon.woff?ngjl88'; ?>') format('woff'), | |
| 287 | -				url('<?php echo GIVE_PLUGIN_URL . 'assets/dist/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg'); | |
| 284 | +				src: url('<?php echo GIVE_PLUGIN_URL.'assets/dist/fonts/icomoon.eot?ngjl88'; ?>'); | |
| 285 | +				src: url('<?php echo GIVE_PLUGIN_URL.'assets/dist/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'), | |
| 286 | +				url('<?php echo GIVE_PLUGIN_URL.'assets/dist/fonts/icomoon.woff?ngjl88'; ?>') format('woff'), | |
| 287 | +				url('<?php echo GIVE_PLUGIN_URL.'assets/dist/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg'); | |
| 288 | 288 | font-weight: normal; | 
| 289 | 289 | font-style: normal; | 
| 290 | 290 | } | 
| @@ -307,7 +307,7 @@ discard block | ||
| 307 | 307 | * @since 2.1.0 | 
| 308 | 308 | */ | 
| 309 | 309 |  	public function public_enqueue_styles() { | 
| 310 | - wp_enqueue_style( 'give-styles' ); | |
| 310 | +		wp_enqueue_style('give-styles'); | |
| 311 | 311 | } | 
| 312 | 312 | |
| 313 | 313 | |
| @@ -317,7 +317,7 @@ discard block | ||
| 317 | 317 | * @since 2.1.0 | 
| 318 | 318 | */ | 
| 319 | 319 |  	public function public_enqueue_scripts() { | 
| 320 | - wp_enqueue_script( 'give' ); | |
| 320 | +		wp_enqueue_script('give'); | |
| 321 | 321 | |
| 322 | 322 | $this->public_localize_scripts(); | 
| 323 | 323 | } | 
| @@ -336,22 +336,22 @@ discard block | ||
| 336 | 336 | * | 
| 337 | 337 | * @return string $message Send notice message for email access. | 
| 338 | 338 | */ | 
| 339 | - $message = (string) apply_filters( 'give_email_access_mail_send_notice', __( 'Please check your email and click on the link to access your complete donation history.', 'give' ) ); | |
| 339 | +		$message = (string) apply_filters('give_email_access_mail_send_notice', __('Please check your email and click on the link to access your complete donation history.', 'give')); | |
| 340 | 340 | |
| 341 | - $localize_give_vars = apply_filters( 'give_global_script_vars', array( | |
| 341 | +		$localize_give_vars = apply_filters('give_global_script_vars', array( | |
| 342 | 342 | 'ajaxurl' => give_get_ajax_url(), | 
| 343 | - 'checkout_nonce' => wp_create_nonce( 'give_checkout_nonce' ), | |
| 343 | +			'checkout_nonce'             => wp_create_nonce('give_checkout_nonce'), | |
| 344 | 344 | // Do not use this nonce. Its deprecated. | 
| 345 | 345 | 'currency' => give_get_currency(), | 
| 346 | - 'currency_sign' => give_currency_filter( '' ), | |
| 346 | +			'currency_sign'              => give_currency_filter(''), | |
| 347 | 347 | 'currency_pos' => give_get_currency_position(), | 
| 348 | 348 | 'thousands_separator' => give_get_price_thousand_separator(), | 
| 349 | 349 | 'decimal_separator' => give_get_price_decimal_separator(), | 
| 350 | - 'no_gateway' => __( 'Please select a payment method.', 'give' ), | |
| 351 | - 'bad_minimum' => __( 'The minimum custom donation amount for this form is', 'give' ), | |
| 352 | - 'bad_maximum' => __( 'The maximum custom donation amount for this form is', 'give' ), | |
| 353 | - 'general_loading' => __( 'Loading...', 'give' ), | |
| 354 | - 'purchase_loading' => __( 'Please Wait...', 'give' ), | |
| 350 | +			'no_gateway'                 => __('Please select a payment method.', 'give'), | |
| 351 | +			'bad_minimum'                => __('The minimum custom donation amount for this form is', 'give'), | |
| 352 | +			'bad_maximum'                => __('The maximum custom donation amount for this form is', 'give'), | |
| 353 | +			'general_loading'            => __('Loading...', 'give'), | |
| 354 | +			'purchase_loading'           => __('Please Wait...', 'give'), | |
| 355 | 355 | 'number_decimals' => give_get_price_decimals(), | 
| 356 | 356 | 'give_version' => GIVE_VERSION, | 
| 357 | 357 | 'magnific_options' => apply_filters( | 
| @@ -365,30 +365,30 @@ discard block | ||
| 365 | 365 | 'give_form_translation_js', | 
| 366 | 366 | array( | 
| 367 | 367 | // Field name Validation message. | 
| 368 | - 'payment-mode' => __( 'Please select payment mode.', 'give' ), | |
| 369 | - 'give_first' => __( 'Please enter your first name.', 'give' ), | |
| 370 | - 'give_email' => __( 'Please enter a valid email address.', 'give' ), | |
| 371 | - 'give_user_login' => __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ), | |
| 372 | - 'give_user_pass' => __( 'Enter a password.', 'give' ), | |
| 373 | - 'give_user_pass_confirm' => __( 'Enter the password confirmation.', 'give' ), | |
| 374 | - 'give_agree_to_terms' => __( 'You must agree to the terms and conditions.', 'give' ), | |
| 368 | +					'payment-mode'           => __('Please select payment mode.', 'give'), | |
| 369 | +					'give_first'             => __('Please enter your first name.', 'give'), | |
| 370 | +					'give_email'             => __('Please enter a valid email address.', 'give'), | |
| 371 | +					'give_user_login'        => __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'), | |
| 372 | +					'give_user_pass'         => __('Enter a password.', 'give'), | |
| 373 | +					'give_user_pass_confirm' => __('Enter the password confirmation.', 'give'), | |
| 374 | +					'give_agree_to_terms'    => __('You must agree to the terms and conditions.', 'give'), | |
| 375 | 375 | ) | 
| 376 | 376 | ), | 
| 377 | 377 | 'confirm_email_sent_message' => $message, | 
| 378 | - 'ajax_vars' => apply_filters( 'give_global_ajax_vars', array( | |
| 378 | +			'ajax_vars'                  => apply_filters('give_global_ajax_vars', array( | |
| 379 | 379 | 'ajaxurl' => give_get_ajax_url(), | 
| 380 | - 'ajaxNonce' => wp_create_nonce( 'give_ajax_nonce' ), | |
| 381 | - 'loading' => __( 'Loading', 'give' ), | |
| 380 | +				'ajaxNonce'       => wp_create_nonce('give_ajax_nonce'), | |
| 381 | +				'loading'         => __('Loading', 'give'), | |
| 382 | 382 | // General loading message. | 
| 383 | - 'select_option' => __( 'Please select an option', 'give' ), | |
| 383 | +				'select_option'   => __('Please select an option', 'give'), | |
| 384 | 384 | // Variable pricing error with multi-donation option enabled. | 
| 385 | - 'default_gateway' => give_get_default_gateway( null ), | |
| 386 | - 'permalinks' => get_option( 'permalink_structure' ) ? '1' : '0', | |
| 385 | + 'default_gateway' => give_get_default_gateway(null), | |
| 386 | +				'permalinks'      => get_option('permalink_structure') ? '1' : '0', | |
| 387 | 387 | 'number_decimals' => give_get_price_decimals(), | 
| 388 | - ) ), | |
| 389 | - ) ); | |
| 388 | + )), | |
| 389 | + )); | |
| 390 | 390 | |
| 391 | - wp_localize_script( 'give', 'give_global_vars', $localize_give_vars ); | |
| 391 | +		wp_localize_script('give', 'give_global_vars', $localize_give_vars); | |
| 392 | 392 | |
| 393 | 393 | } | 
| 394 | 394 | |
| @@ -402,15 +402,15 @@ discard block | ||
| 402 | 402 | */ | 
| 403 | 403 |  	public function get_frontend_stylesheet_uri() { | 
| 404 | 404 | |
| 405 | - $file = 'give' . $this->direction . '.css'; | |
| 405 | + $file = 'give'.$this->direction.'.css'; | |
| 406 | 406 | $templates_dir = give_get_theme_template_dir_name(); | 
| 407 | 407 | |
| 408 | 408 | // Directory paths to CSS files to support checking via file_exists(). | 
| 409 | - $child_theme_style_sheet = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file; | |
| 410 | - $child_theme_style_sheet_2 = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give' . $this->direction . '.css'; | |
| 411 | - $parent_theme_style_sheet = trailingslashit( get_template_directory() ) . $templates_dir . $file; | |
| 412 | - $parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give' . $this->direction . '.css'; | |
| 413 | - $give_plugin_style_sheet = trailingslashit( GIVE_PLUGIN_DIR ) . 'assets/dist/css/' . $file; | |
| 409 | + $child_theme_style_sheet = trailingslashit(get_stylesheet_directory()).$templates_dir.$file; | |
| 410 | + $child_theme_style_sheet_2 = trailingslashit(get_stylesheet_directory()).$templates_dir.'give'.$this->direction.'.css'; | |
| 411 | + $parent_theme_style_sheet = trailingslashit(get_template_directory()).$templates_dir.$file; | |
| 412 | + $parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give'.$this->direction.'.css'; | |
| 413 | + $give_plugin_style_sheet = trailingslashit(GIVE_PLUGIN_DIR).'assets/dist/css/'.$file; | |
| 414 | 414 | $uri = false; | 
| 415 | 415 | |
| 416 | 416 | /** | 
| @@ -421,23 +421,23 @@ discard block | ||
| 421 | 421 | * c. followed by non minified version, even if SCRIPT_DEBUG is not enabled. This allows users to copy just give.css to their theme. | 
| 422 | 422 | * d. Finally, fallback to the standard Give version. This is the default styles included within the plugin. | 
| 423 | 423 | */ | 
| 424 | -		if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) { | |
| 425 | -			if ( ! empty( $nonmin ) ) { | |
| 426 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give' . $this->direction . '.css'; | |
| 424 | +		if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) { | |
| 425 | +			if ( ! empty($nonmin)) { | |
| 426 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give'.$this->direction.'.css'; | |
| 427 | 427 |  			} else { | 
| 428 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file; | |
| 428 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file; | |
| 429 | 429 | } | 
| 430 | -		} elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) { | |
| 431 | -			if ( ! empty( $nonmin ) ) { | |
| 432 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give' . $this->direction . '.css'; | |
| 430 | +		} elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) { | |
| 431 | +			if ( ! empty($nonmin)) { | |
| 432 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.'give'.$this->direction.'.css'; | |
| 433 | 433 |  			} else { | 
| 434 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file; | |
| 434 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.$file; | |
| 435 | 435 | } | 
| 436 | -		} elseif ( file_exists( $give_plugin_style_sheet ) ) { | |
| 437 | - $uri = trailingslashit( GIVE_PLUGIN_URL ) . 'assets/dist/css/' . $file; | |
| 436 | +		} elseif (file_exists($give_plugin_style_sheet)) { | |
| 437 | + $uri = trailingslashit(GIVE_PLUGIN_URL).'assets/dist/css/'.$file; | |
| 438 | 438 | } | 
| 439 | 439 | |
| 440 | - return apply_filters( 'give_get_stylesheet_uri', $uri ); | |
| 440 | +		return apply_filters('give_get_stylesheet_uri', $uri); | |
| 441 | 441 | |
| 442 | 442 | } | 
| 443 | 443 | |
| @@ -449,19 +449,19 @@ discard block | ||
| 449 | 449 | // Enqueue the bundled block JS file | 
| 450 | 450 | wp_enqueue_script( | 
| 451 | 451 | 'give-blocks-js', | 
| 452 | - GIVE_PLUGIN_URL . 'assets/dist/js/gutenberg.js', | |
| 453 | - array( 'wp-i18n', 'wp-element', 'wp-blocks', 'wp-components', 'wp-api' ), | |
| 452 | + GIVE_PLUGIN_URL.'assets/dist/js/gutenberg.js', | |
| 453 | +			array('wp-i18n', 'wp-element', 'wp-blocks', 'wp-components', 'wp-api'), | |
| 454 | 454 | GIVE_VERSION | 
| 455 | 455 | ); | 
| 456 | 456 | |
| 457 | 457 | // Enqueue public styles | 
| 458 | - wp_enqueue_style( 'give-styles' ); | |
| 458 | +		wp_enqueue_style('give-styles'); | |
| 459 | 459 | |
| 460 | 460 | // Enqueue the bundled block css file | 
| 461 | 461 | wp_enqueue_style( | 
| 462 | 462 | 'give-blocks-css', | 
| 463 | - GIVE_PLUGIN_URL . 'assets/dist/css/gutenberg.css', | |
| 464 | - array( 'wp-blocks' ), | |
| 463 | + GIVE_PLUGIN_URL.'assets/dist/css/gutenberg.css', | |
| 464 | +			array('wp-blocks'), | |
| 465 | 465 | GIVE_VERSION | 
| 466 | 466 | ); | 
| 467 | 467 | |