| @@ -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 = get_post_meta( $args['form_id'], '_give_form_floating_labels', true ); | |
| 70 | +	if (empty($float_labels)) { | |
| 71 | + $float_labels = get_post_meta($args['form_id'], '_give_form_floating_labels', true); | |
| 72 | 72 | } | 
| 73 | 73 | |
| 74 | -	if ( empty( $float_labels ) ) { | |
| 75 | - $float_labels = give_get_option( 'enable_floatlabels' ) ? 'enabled' : 'disabled'; | |
| 74 | +	if (empty($float_labels)) { | |
| 75 | +		$float_labels = give_get_option('enable_floatlabels') ? 'enabled' : 'disabled'; | |
| 76 | 76 | } | 
| 77 | 77 | |
| 78 | - return ( $float_labels == 'enabled' ) ? true : false; | |
| 78 | + return ($float_labels == 'enabled') ? true : false; | |
| 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 | global $give_options; | 
| 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 | global $give_options; | 
| 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 | |
| @@ -162,20 +162,20 @@ discard block | ||
| 162 | 162 | * @since 1.0 | 
| 163 | 163 | * @return Void | 
| 164 | 164 | */ | 
| 165 | -function give_send_back_to_checkout( $args = array() ) { | |
| 165 | +function give_send_back_to_checkout($args = array()) { | |
| 166 | 166 | |
| 167 | - $url = isset( $_POST['give-current-url'] ) ? sanitize_text_field( $_POST['give-current-url'] ) : ''; | |
| 167 | + $url = isset($_POST['give-current-url']) ? sanitize_text_field($_POST['give-current-url']) : ''; | |
| 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 |  	} else { | 
| 173 | 173 | $form_id = 0; | 
| 174 | 174 | } | 
| 175 | 175 | |
| 176 | 176 | //Need a URL to continue. If none, redirect back to single form. | 
| 177 | -	if ( empty( $url ) ) { | |
| 178 | - wp_safe_redirect( get_permalink( $form_id ) ); | |
| 177 | +	if (empty($url)) { | |
| 178 | + wp_safe_redirect(get_permalink($form_id)); | |
| 179 | 179 | give_die(); | 
| 180 | 180 | } | 
| 181 | 181 | |
| @@ -184,36 +184,36 @@ discard block | ||
| 184 | 184 | ); | 
| 185 | 185 | |
| 186 | 186 | // Check for backward compatibility. | 
| 187 | -	if ( is_string( $args ) ) { | |
| 188 | - $args = str_replace( '?', '', $args ); | |
| 187 | +	if (is_string($args)) { | |
| 188 | +		$args = str_replace('?', '', $args); | |
| 189 | 189 | } | 
| 190 | 190 | |
| 191 | - $args = wp_parse_args( $args, $defaults ); | |
| 191 | + $args = wp_parse_args($args, $defaults); | |
| 192 | 192 | |
| 193 | 193 | // Merge URL query with $args to maintain third-party URL parameters after redirect. | 
| 194 | - $url_data = wp_parse_url( $url ); | |
| 194 | + $url_data = wp_parse_url($url); | |
| 195 | 195 | |
| 196 | 196 | //Check if an array to prevent notices before parsing. | 
| 197 | -	if ( isset( $url_data['query'] ) && ! empty( $url_data['query'] ) ) { | |
| 198 | - parse_str( $url_data['query'], $query ); | |
| 197 | +	if (isset($url_data['query']) && ! empty($url_data['query'])) { | |
| 198 | + parse_str($url_data['query'], $query); | |
| 199 | 199 | |
| 200 | 200 | //Precaution: don't allow any CC info. | 
| 201 | - unset( $query['card_number'] ); | |
| 202 | - unset( $query['card_cvc'] ); | |
| 201 | + unset($query['card_number']); | |
| 202 | + unset($query['card_cvc']); | |
| 203 | 203 | |
| 204 | 204 |  	} else { | 
| 205 | 205 | //No $url_data so pass empty array. | 
| 206 | 206 | $query = array(); | 
| 207 | 207 | } | 
| 208 | 208 | |
| 209 | - $new_query = array_merge( $args, $query ); | |
| 210 | - $new_query_string = http_build_query( $new_query ); | |
| 209 | + $new_query = array_merge($args, $query); | |
| 210 | + $new_query_string = http_build_query($new_query); | |
| 211 | 211 | |
| 212 | 212 | // Assemble URL parts. | 
| 213 | - $redirect = home_url( '/' . $url_data['path'] . '?' . $new_query_string . '#give-form-' . $form_id . '-wrap' ); | |
| 213 | +	$redirect = home_url('/'.$url_data['path'].'?'.$new_query_string.'#give-form-'.$form_id.'-wrap'); | |
| 214 | 214 | |
| 215 | 215 | //Redirect them. | 
| 216 | - wp_safe_redirect( apply_filters( 'give_send_back_to_checkout', $redirect, $args ) ); | |
| 216 | +	wp_safe_redirect(apply_filters('give_send_back_to_checkout', $redirect, $args)); | |
| 217 | 217 | give_die(); | 
| 218 | 218 | |
| 219 | 219 | } | 
| @@ -229,16 +229,16 @@ discard block | ||
| 229 | 229 | * @since 1.0 | 
| 230 | 230 | * @return string | 
| 231 | 231 | */ | 
| 232 | -function give_get_success_page_url( $query_string = null ) { | |
| 232 | +function give_get_success_page_url($query_string = null) { | |
| 233 | 233 | |
| 234 | - $success_page = give_get_option( 'success_page', 0 ); | |
| 235 | - $success_page = get_permalink( $success_page ); | |
| 234 | +	$success_page = give_get_option('success_page', 0); | |
| 235 | + $success_page = get_permalink($success_page); | |
| 236 | 236 | |
| 237 | -	if ( $query_string ) { | |
| 237 | +	if ($query_string) { | |
| 238 | 238 | $success_page .= $query_string; | 
| 239 | 239 | } | 
| 240 | 240 | |
| 241 | - return apply_filters( 'give_success_page_url', $success_page ); | |
| 241 | +	return apply_filters('give_success_page_url', $success_page); | |
| 242 | 242 | |
| 243 | 243 | } | 
| 244 | 244 | |
| @@ -252,15 +252,15 @@ discard block | ||
| 252 | 252 | * | 
| 253 | 253 | * @return mixed|void Full URL to the Transaction Failed page, if present, home page if it doesn't exist | 
| 254 | 254 | */ | 
| 255 | -function give_get_failed_transaction_uri( $extras = false ) { | |
| 255 | +function give_get_failed_transaction_uri($extras = false) { | |
| 256 | 256 | global $give_options; | 
| 257 | 257 | |
| 258 | - $uri = ! empty( $give_options['failure_page'] ) ? trailingslashit( get_permalink( $give_options['failure_page'] ) ) : home_url(); | |
| 259 | -	if ( $extras ) { | |
| 258 | + $uri = ! empty($give_options['failure_page']) ? trailingslashit(get_permalink($give_options['failure_page'])) : home_url(); | |
| 259 | +	if ($extras) { | |
| 260 | 260 | $uri .= $extras; | 
| 261 | 261 | } | 
| 262 | 262 | |
| 263 | - return apply_filters( 'give_get_failed_transaction_uri', $uri ); | |
| 263 | +	return apply_filters('give_get_failed_transaction_uri', $uri); | |
| 264 | 264 | } | 
| 265 | 265 | |
| 266 | 266 | /** | 
| @@ -271,9 +271,9 @@ discard block | ||
| 271 | 271 | */ | 
| 272 | 272 |  function give_is_failed_transaction_page() { | 
| 273 | 273 | global $give_options; | 
| 274 | - $ret = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false; | |
| 274 | + $ret = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false; | |
| 275 | 275 | |
| 276 | - return apply_filters( 'give_is_failure_page', $ret ); | |
| 276 | +	return apply_filters('give_is_failure_page', $ret); | |
| 277 | 277 | } | 
| 278 | 278 | |
| 279 | 279 | /** | 
| @@ -285,18 +285,18 @@ discard block | ||
| 285 | 285 | */ | 
| 286 | 286 |  function give_listen_for_failed_payments() { | 
| 287 | 287 | |
| 288 | - $failed_page = give_get_option( 'failure_page', 0 ); | |
| 288 | +	$failed_page = give_get_option('failure_page', 0); | |
| 289 | 289 | |
| 290 | -	if ( ! empty( $failed_page ) && is_page( $failed_page ) && ! empty( $_GET['payment-id'] ) ) { | |
| 290 | +	if ( ! empty($failed_page) && is_page($failed_page) && ! empty($_GET['payment-id'])) { | |
| 291 | 291 | |
| 292 | - $payment_id = absint( $_GET['payment-id'] ); | |
| 293 | - give_update_payment_status( $payment_id, 'failed' ); | |
| 292 | + $payment_id = absint($_GET['payment-id']); | |
| 293 | + give_update_payment_status($payment_id, 'failed'); | |
| 294 | 294 | |
| 295 | 295 | } | 
| 296 | 296 | |
| 297 | 297 | } | 
| 298 | 298 | |
| 299 | -add_action( 'template_redirect', 'give_listen_for_failed_payments' ); | |
| 299 | +add_action('template_redirect', 'give_listen_for_failed_payments'); | |
| 300 | 300 | |
| 301 | 301 | |
| 302 | 302 | /** | 
| @@ -309,11 +309,11 @@ discard block | ||
| 309 | 309 | * @since 1.0 | 
| 310 | 310 | * @return bool | 
| 311 | 311 | */ | 
| 312 | -function give_field_is_required( $field = '', $form_id ) { | |
| 312 | +function give_field_is_required($field = '', $form_id) { | |
| 313 | 313 | |
| 314 | - $required_fields = give_purchase_form_required_fields( $form_id ); | |
| 314 | + $required_fields = give_purchase_form_required_fields($form_id); | |
| 315 | 315 | |
| 316 | - return array_key_exists( $field, $required_fields ); | |
| 316 | + return array_key_exists($field, $required_fields); | |
| 317 | 317 | } | 
| 318 | 318 | |
| 319 | 319 | /** | 
| @@ -331,14 +331,14 @@ discard block | ||
| 331 | 331 | * | 
| 332 | 332 | * @return void | 
| 333 | 333 | */ | 
| 334 | -function give_record_sale_in_log( $give_form_id = 0, $payment_id, $price_id = false, $sale_date = null ) { | |
| 334 | +function give_record_sale_in_log($give_form_id = 0, $payment_id, $price_id = false, $sale_date = null) { | |
| 335 | 335 | global $give_logs; | 
| 336 | 336 | |
| 337 | 337 | $log_data = array( | 
| 338 | 338 | 'post_parent' => $give_form_id, | 
| 339 | 339 | 'log_type' => 'sale', | 
| 340 | - 'post_date' => isset( $sale_date ) ? $sale_date : null, | |
| 341 | - 'post_date_gmt' => isset( $sale_date ) ? $sale_date : null | |
| 340 | + 'post_date' => isset($sale_date) ? $sale_date : null, | |
| 341 | + 'post_date_gmt' => isset($sale_date) ? $sale_date : null | |
| 342 | 342 | ); | 
| 343 | 343 | |
| 344 | 344 | $log_meta = array( | 
| @@ -346,7 +346,7 @@ discard block | ||
| 346 | 346 | 'price_id' => (int) $price_id | 
| 347 | 347 | ); | 
| 348 | 348 | |
| 349 | - $give_logs->insert_log( $log_data, $log_meta ); | |
| 349 | + $give_logs->insert_log($log_data, $log_meta); | |
| 350 | 350 | } | 
| 351 | 351 | |
| 352 | 352 | |
| @@ -360,11 +360,11 @@ discard block | ||
| 360 | 360 | * | 
| 361 | 361 | * @return bool|int | 
| 362 | 362 | */ | 
| 363 | -function give_increase_purchase_count( $form_id = 0, $quantity = 1 ) { | |
| 363 | +function give_increase_purchase_count($form_id = 0, $quantity = 1) { | |
| 364 | 364 | $quantity = (int) $quantity; | 
| 365 | - $form = new Give_Donate_Form( $form_id ); | |
| 365 | + $form = new Give_Donate_Form($form_id); | |
| 366 | 366 | |
| 367 | - return $form->increase_sales( $quantity ); | |
| 367 | + return $form->increase_sales($quantity); | |
| 368 | 368 | } | 
| 369 | 369 | |
| 370 | 370 | /** | 
| @@ -377,11 +377,11 @@ discard block | ||
| 377 | 377 | * | 
| 378 | 378 | * @return bool|int | 
| 379 | 379 | */ | 
| 380 | -function give_decrease_purchase_count( $form_id = 0, $quantity = 1 ) { | |
| 380 | +function give_decrease_purchase_count($form_id = 0, $quantity = 1) { | |
| 381 | 381 | $quantity = (int) $quantity; | 
| 382 | - $form = new Give_Donate_Form( $form_id ); | |
| 382 | + $form = new Give_Donate_Form($form_id); | |
| 383 | 383 | |
| 384 | - return $form->decrease_sales( $quantity ); | |
| 384 | + return $form->decrease_sales($quantity); | |
| 385 | 385 | } | 
| 386 | 386 | |
| 387 | 387 | /** | 
| @@ -394,10 +394,10 @@ discard block | ||
| 394 | 394 | * | 
| 395 | 395 | * @return bool|int | 
| 396 | 396 | */ | 
| 397 | -function give_increase_earnings( $give_form_id = 0, $amount ) { | |
| 398 | - $form = new Give_Donate_Form( $give_form_id ); | |
| 397 | +function give_increase_earnings($give_form_id = 0, $amount) { | |
| 398 | + $form = new Give_Donate_Form($give_form_id); | |
| 399 | 399 | |
| 400 | - return $form->increase_earnings( $amount ); | |
| 400 | + return $form->increase_earnings($amount); | |
| 401 | 401 | } | 
| 402 | 402 | |
| 403 | 403 | /** | 
| @@ -410,10 +410,10 @@ discard block | ||
| 410 | 410 | * | 
| 411 | 411 | * @return bool|int | 
| 412 | 412 | */ | 
| 413 | -function give_decrease_earnings( $form_id = 0, $amount ) { | |
| 414 | - $form = new Give_Donate_Form( $form_id ); | |
| 413 | +function give_decrease_earnings($form_id = 0, $amount) { | |
| 414 | + $form = new Give_Donate_Form($form_id); | |
| 415 | 415 | |
| 416 | - return $form->decrease_earnings( $amount ); | |
| 416 | + return $form->decrease_earnings($amount); | |
| 417 | 417 | } | 
| 418 | 418 | |
| 419 | 419 | |
| @@ -426,8 +426,8 @@ discard block | ||
| 426 | 426 | * | 
| 427 | 427 | * @return int $earnings Earnings for a certain form | 
| 428 | 428 | */ | 
| 429 | -function give_get_form_earnings_stats( $form_id = 0 ) { | |
| 430 | - $give_form = new Give_Donate_Form( $form_id ); | |
| 429 | +function give_get_form_earnings_stats($form_id = 0) { | |
| 430 | + $give_form = new Give_Donate_Form($form_id); | |
| 431 | 431 | |
| 432 | 432 | return $give_form->earnings; | 
| 433 | 433 | } | 
| @@ -442,8 +442,8 @@ discard block | ||
| 442 | 442 | * | 
| 443 | 443 | * @return int $sales Amount of sales for a certain form | 
| 444 | 444 | */ | 
| 445 | -function give_get_form_sales_stats( $give_form_id = 0 ) { | |
| 446 | - $give_form = new Give_Donate_Form( $give_form_id ); | |
| 445 | +function give_get_form_sales_stats($give_form_id = 0) { | |
| 446 | + $give_form = new Give_Donate_Form($give_form_id); | |
| 447 | 447 | |
| 448 | 448 | return $give_form->sales; | 
| 449 | 449 | } | 
| @@ -458,16 +458,16 @@ discard block | ||
| 458 | 458 | * | 
| 459 | 459 | * @return float $sales Average monthly sales | 
| 460 | 460 | */ | 
| 461 | -function give_get_average_monthly_form_sales( $form_id = 0 ) { | |
| 462 | - $sales = give_get_form_sales_stats( $form_id ); | |
| 463 | - $release_date = get_post_field( 'post_date', $form_id ); | |
| 461 | +function give_get_average_monthly_form_sales($form_id = 0) { | |
| 462 | + $sales = give_get_form_sales_stats($form_id); | |
| 463 | +	$release_date = get_post_field('post_date', $form_id); | |
| 464 | 464 | |
| 465 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); | |
| 465 | +	$diff = abs(current_time('timestamp') - strtotime($release_date)); | |
| 466 | 466 | |
| 467 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication | |
| 467 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication | |
| 468 | 468 | |
| 469 | -	if ( $months > 0 ) { | |
| 470 | - $sales = ( $sales / $months ); | |
| 469 | +	if ($months > 0) { | |
| 470 | + $sales = ($sales / $months); | |
| 471 | 471 | } | 
| 472 | 472 | |
| 473 | 473 | return $sales; | 
| @@ -483,16 +483,16 @@ discard block | ||
| 483 | 483 | * | 
| 484 | 484 | * @return float $earnings Average monthly earnings | 
| 485 | 485 | */ | 
| 486 | -function give_get_average_monthly_form_earnings( $form_id = 0 ) { | |
| 487 | - $earnings = give_get_form_earnings_stats( $form_id ); | |
| 488 | - $release_date = get_post_field( 'post_date', $form_id ); | |
| 486 | +function give_get_average_monthly_form_earnings($form_id = 0) { | |
| 487 | + $earnings = give_get_form_earnings_stats($form_id); | |
| 488 | +	$release_date = get_post_field('post_date', $form_id); | |
| 489 | 489 | |
| 490 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); | |
| 490 | +	$diff = abs(current_time('timestamp') - strtotime($release_date)); | |
| 491 | 491 | |
| 492 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication | |
| 492 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication | |
| 493 | 493 | |
| 494 | -	if ( $months > 0 ) { | |
| 495 | - $earnings = ( $earnings / $months ); | |
| 494 | +	if ($months > 0) { | |
| 495 | + $earnings = ($earnings / $months); | |
| 496 | 496 | } | 
| 497 | 497 | |
| 498 | 498 | return $earnings < 0 ? 0 : $earnings; | 
| @@ -512,25 +512,25 @@ discard block | ||
| 512 | 512 | * | 
| 513 | 513 | * @return string $price_name Name of the price option | 
| 514 | 514 | */ | 
| 515 | -function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0 ) { | |
| 515 | +function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0) { | |
| 516 | 516 | |
| 517 | - $prices = give_get_variable_prices( $form_id ); | |
| 517 | + $prices = give_get_variable_prices($form_id); | |
| 518 | 518 | $price_name = ''; | 
| 519 | 519 | |
| 520 | -	foreach ( $prices as $price ) { | |
| 520 | +	foreach ($prices as $price) { | |
| 521 | 521 | |
| 522 | -		if ( intval( $price['_give_id']['level_id'] ) == intval( $price_id ) ) { | |
| 522 | +		if (intval($price['_give_id']['level_id']) == intval($price_id)) { | |
| 523 | 523 | |
| 524 | - $price_text = isset( $price['_give_text'] ) ? $price['_give_text'] : ''; | |
| 525 | - $price_fallback = give_currency_filter( give_format_amount( $price['_give_amount'] ) ); | |
| 526 | - $price_name = ! empty( $price_text ) ? $price_text : $price_fallback; | |
| 524 | + $price_text = isset($price['_give_text']) ? $price['_give_text'] : ''; | |
| 525 | + $price_fallback = give_currency_filter(give_format_amount($price['_give_amount'])); | |
| 526 | + $price_name = ! empty($price_text) ? $price_text : $price_fallback; | |
| 527 | 527 | |
| 528 | 528 | } | 
| 529 | 529 | |
| 530 | 530 | } | 
| 531 | 531 | |
| 532 | 532 | |
| 533 | - return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id ); | |
| 533 | +	return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id); | |
| 534 | 534 | } | 
| 535 | 535 | |
| 536 | 536 | |
| @@ -543,14 +543,14 @@ discard block | ||
| 543 | 543 | * | 
| 544 | 544 | * @return string $range A fully formatted price range | 
| 545 | 545 | */ | 
| 546 | -function give_price_range( $form_id = 0 ) { | |
| 547 | - $low = give_get_lowest_price_option( $form_id ); | |
| 548 | - $high = give_get_highest_price_option( $form_id ); | |
| 549 | - $range = '<span class="give_price_range_low">' . give_currency_filter( give_format_amount( $low ) ) . '</span>'; | |
| 546 | +function give_price_range($form_id = 0) { | |
| 547 | + $low = give_get_lowest_price_option($form_id); | |
| 548 | + $high = give_get_highest_price_option($form_id); | |
| 549 | + $range = '<span class="give_price_range_low">'.give_currency_filter(give_format_amount($low)).'</span>'; | |
| 550 | 550 | $range .= '<span class="give_price_range_sep"> – </span>'; | 
| 551 | - $range .= '<span class="give_price_range_high">' . give_currency_filter( give_format_amount( $high ) ) . '</span>'; | |
| 551 | + $range .= '<span class="give_price_range_high">'.give_currency_filter(give_format_amount($high)).'</span>'; | |
| 552 | 552 | |
| 553 | - return apply_filters( 'give_price_range', $range, $form_id, $low, $high ); | |
| 553 | +	return apply_filters('give_price_range', $range, $form_id, $low, $high); | |
| 554 | 554 | } | 
| 555 | 555 | |
| 556 | 556 | |
| @@ -565,36 +565,36 @@ discard block | ||
| 565 | 565 | * | 
| 566 | 566 | * @return int ID of the lowest price | 
| 567 | 567 | */ | 
| 568 | -function give_get_lowest_price_id( $form_id = 0 ) { | |
| 568 | +function give_get_lowest_price_id($form_id = 0) { | |
| 569 | 569 | |
| 570 | -	if ( empty( $form_id ) ) { | |
| 570 | +	if (empty($form_id)) { | |
| 571 | 571 | $form_id = get_the_ID(); | 
| 572 | 572 | } | 
| 573 | 573 | |
| 574 | -	if ( ! give_has_variable_prices( $form_id ) ) { | |
| 575 | - return give_get_form_price( $form_id ); | |
| 574 | +	if ( ! give_has_variable_prices($form_id)) { | |
| 575 | + return give_get_form_price($form_id); | |
| 576 | 576 | } | 
| 577 | 577 | |
| 578 | - $prices = give_get_variable_prices( $form_id ); | |
| 578 | + $prices = give_get_variable_prices($form_id); | |
| 579 | 579 | |
| 580 | 580 | $low = 0.00; | 
| 581 | 581 | $min_id = 1; | 
| 582 | 582 | |
| 583 | -	if ( ! empty( $prices ) ) { | |
| 583 | +	if ( ! empty($prices)) { | |
| 584 | 584 | |
| 585 | -		foreach ( $prices as $key => $price ) { | |
| 585 | +		foreach ($prices as $key => $price) { | |
| 586 | 586 | |
| 587 | -			if ( empty( $price['_give_amount'] ) ) { | |
| 587 | +			if (empty($price['_give_amount'])) { | |
| 588 | 588 | continue; | 
| 589 | 589 | } | 
| 590 | 590 | |
| 591 | -			if ( ! isset( $min ) ) { | |
| 591 | +			if ( ! isset($min)) { | |
| 592 | 592 | $min = $price['_give_amount']; | 
| 593 | 593 |  			} else { | 
| 594 | - $min = min( $min, $price['_give_amount'] ); | |
| 594 | + $min = min($min, $price['_give_amount']); | |
| 595 | 595 | } | 
| 596 | 596 | |
| 597 | -			if ( $price['_give_amount'] == $min ) { | |
| 597 | +			if ($price['_give_amount'] == $min) { | |
| 598 | 598 | $min_id = $price['_give_id']['level_id']; | 
| 599 | 599 | } | 
| 600 | 600 | } | 
| @@ -612,43 +612,43 @@ discard block | ||
| 612 | 612 | * | 
| 613 | 613 | * @return float Amount of the lowest price | 
| 614 | 614 | */ | 
| 615 | -function give_get_lowest_price_option( $form_id = 0 ) { | |
| 616 | -	if ( empty( $form_id ) ) { | |
| 615 | +function give_get_lowest_price_option($form_id = 0) { | |
| 616 | +	if (empty($form_id)) { | |
| 617 | 617 | $form_id = get_the_ID(); | 
| 618 | 618 | } | 
| 619 | 619 | |
| 620 | -	if ( ! give_has_variable_prices( $form_id ) ) { | |
| 621 | - return give_get_form_price( $form_id ); | |
| 620 | +	if ( ! give_has_variable_prices($form_id)) { | |
| 621 | + return give_get_form_price($form_id); | |
| 622 | 622 | } | 
| 623 | 623 | |
| 624 | - $prices = give_get_variable_prices( $form_id ); | |
| 624 | + $prices = give_get_variable_prices($form_id); | |
| 625 | 625 | |
| 626 | 626 | $low = 0.00; | 
| 627 | 627 | |
| 628 | -	if ( ! empty( $prices ) ) { | |
| 628 | +	if ( ! empty($prices)) { | |
| 629 | 629 | |
| 630 | -		foreach ( $prices as $key => $price ) { | |
| 630 | +		foreach ($prices as $key => $price) { | |
| 631 | 631 | |
| 632 | -			if ( empty( $price['_give_amount'] ) ) { | |
| 632 | +			if (empty($price['_give_amount'])) { | |
| 633 | 633 | continue; | 
| 634 | 634 | } | 
| 635 | 635 | |
| 636 | -			if ( ! isset( $min ) ) { | |
| 636 | +			if ( ! isset($min)) { | |
| 637 | 637 | $min = $price['_give_amount']; | 
| 638 | 638 |  			} else { | 
| 639 | - $min = min( $min, give_sanitize_amount( $price['_give_amount'] ) ); | |
| 639 | + $min = min($min, give_sanitize_amount($price['_give_amount'])); | |
| 640 | 640 | } | 
| 641 | 641 | |
| 642 | -			if ( $price['_give_amount'] == $min ) { | |
| 642 | +			if ($price['_give_amount'] == $min) { | |
| 643 | 643 | $min_id = $key; | 
| 644 | 644 | } | 
| 645 | 645 | } | 
| 646 | 646 | |
| 647 | - $low = $prices[ $min_id ]['_give_amount']; | |
| 647 | + $low = $prices[$min_id]['_give_amount']; | |
| 648 | 648 | |
| 649 | 649 | } | 
| 650 | 650 | |
| 651 | - return give_sanitize_amount( $low ); | |
| 651 | + return give_sanitize_amount($low); | |
| 652 | 652 | } | 
| 653 | 653 | |
| 654 | 654 | /** | 
| @@ -660,41 +660,41 @@ discard block | ||
| 660 | 660 | * | 
| 661 | 661 | * @return float Amount of the highest price | 
| 662 | 662 | */ | 
| 663 | -function give_get_highest_price_option( $form_id = 0 ) { | |
| 663 | +function give_get_highest_price_option($form_id = 0) { | |
| 664 | 664 | |
| 665 | -	if ( empty( $form_id ) ) { | |
| 665 | +	if (empty($form_id)) { | |
| 666 | 666 | $form_id = get_the_ID(); | 
| 667 | 667 | } | 
| 668 | 668 | |
| 669 | -	if ( ! give_has_variable_prices( $form_id ) ) { | |
| 670 | - return give_get_form_price( $form_id ); | |
| 669 | +	if ( ! give_has_variable_prices($form_id)) { | |
| 670 | + return give_get_form_price($form_id); | |
| 671 | 671 | } | 
| 672 | 672 | |
| 673 | - $prices = give_get_variable_prices( $form_id ); | |
| 673 | + $prices = give_get_variable_prices($form_id); | |
| 674 | 674 | |
| 675 | 675 | $high = 0.00; | 
| 676 | 676 | |
| 677 | -	if ( ! empty( $prices ) ) { | |
| 677 | +	if ( ! empty($prices)) { | |
| 678 | 678 | |
| 679 | 679 | $max = 0; | 
| 680 | 680 | |
| 681 | -		foreach ( $prices as $key => $price ) { | |
| 682 | -			if ( empty( $price['_give_amount'] ) ) { | |
| 681 | +		foreach ($prices as $key => $price) { | |
| 682 | +			if (empty($price['_give_amount'])) { | |
| 683 | 683 | continue; | 
| 684 | 684 | } | 
| 685 | - $give_amount = give_sanitize_amount( $price['_give_amount'] ); | |
| 685 | + $give_amount = give_sanitize_amount($price['_give_amount']); | |
| 686 | 686 | |
| 687 | - $max = max( $max, $give_amount ); | |
| 687 | + $max = max($max, $give_amount); | |
| 688 | 688 | |
| 689 | -			if ( $give_amount == $max ) { | |
| 689 | +			if ($give_amount == $max) { | |
| 690 | 690 | $max_id = $key; | 
| 691 | 691 | } | 
| 692 | 692 | } | 
| 693 | 693 | |
| 694 | - $high = $prices[ $max_id ]['_give_amount']; | |
| 694 | + $high = $prices[$max_id]['_give_amount']; | |
| 695 | 695 | } | 
| 696 | 696 | |
| 697 | - return give_sanitize_amount( $high ); | |
| 697 | + return give_sanitize_amount($high); | |
| 698 | 698 | } | 
| 699 | 699 | |
| 700 | 700 | /** | 
| @@ -706,15 +706,15 @@ discard block | ||
| 706 | 706 | * | 
| 707 | 707 | * @return mixed string|int Price of the form | 
| 708 | 708 | */ | 
| 709 | -function give_get_form_price( $form_id = 0 ) { | |
| 709 | +function give_get_form_price($form_id = 0) { | |
| 710 | 710 | |
| 711 | -	if ( empty( $form_id ) ) { | |
| 711 | +	if (empty($form_id)) { | |
| 712 | 712 | return false; | 
| 713 | 713 | } | 
| 714 | 714 | |
| 715 | - $form = new Give_Donate_Form( $form_id ); | |
| 715 | + $form = new Give_Donate_Form($form_id); | |
| 716 | 716 | |
| 717 | - return $form->__get( 'price' ); | |
| 717 | +	return $form->__get('price'); | |
| 718 | 718 | } | 
| 719 | 719 | |
| 720 | 720 | /** | 
| @@ -726,15 +726,15 @@ discard block | ||
| 726 | 726 | * | 
| 727 | 727 | * @return mixed string|int Minimum price of the form | 
| 728 | 728 | */ | 
| 729 | -function give_get_form_minimum_price( $form_id = 0 ) { | |
| 729 | +function give_get_form_minimum_price($form_id = 0) { | |
| 730 | 730 | |
| 731 | -	if ( empty( $form_id ) ) { | |
| 731 | +	if (empty($form_id)) { | |
| 732 | 732 | return false; | 
| 733 | 733 | } | 
| 734 | 734 | |
| 735 | - $form = new Give_Donate_Form( $form_id ); | |
| 735 | + $form = new Give_Donate_Form($form_id); | |
| 736 | 736 | |
| 737 | - return $form->__get( 'minimum_price' ); | |
| 737 | +	return $form->__get('minimum_price'); | |
| 738 | 738 | |
| 739 | 739 | } | 
| 740 | 740 | |
| @@ -749,52 +749,52 @@ discard block | ||
| 749 | 749 | * | 
| 750 | 750 | * @return int $formatted_price | 
| 751 | 751 | */ | 
| 752 | -function give_price( $form_id = 0, $echo = true, $price_id = false ) { | |
| 752 | +function give_price($form_id = 0, $echo = true, $price_id = false) { | |
| 753 | 753 | |
| 754 | -	if ( empty( $form_id ) ) { | |
| 754 | +	if (empty($form_id)) { | |
| 755 | 755 | $form_id = get_the_ID(); | 
| 756 | 756 | } | 
| 757 | 757 | |
| 758 | -	if ( give_has_variable_prices( $form_id ) ) { | |
| 758 | +	if (give_has_variable_prices($form_id)) { | |
| 759 | 759 | |
| 760 | - $prices = give_get_variable_prices( $form_id ); | |
| 760 | + $prices = give_get_variable_prices($form_id); | |
| 761 | 761 | |
| 762 | -		if ( false !== $price_id ) { | |
| 762 | +		if (false !== $price_id) { | |
| 763 | 763 | |
| 764 | 764 | //loop through multi-prices to see which is default | 
| 765 | -			foreach ( $prices as $price ) { | |
| 765 | +			foreach ($prices as $price) { | |
| 766 | 766 | //this is the default price | 
| 767 | -				if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { | |
| 767 | +				if (isset($price['_give_default']) && $price['_give_default'] === 'default') { | |
| 768 | 768 | $price = (float) $price['_give_amount']; | 
| 769 | 769 | }; | 
| 770 | 770 | } | 
| 771 | 771 | |
| 772 | 772 |  		} else { | 
| 773 | 773 | |
| 774 | - $price = give_get_lowest_price_option( $form_id ); | |
| 774 | + $price = give_get_lowest_price_option($form_id); | |
| 775 | 775 | } | 
| 776 | 776 | |
| 777 | - $price = give_sanitize_amount( $price ); | |
| 777 | + $price = give_sanitize_amount($price); | |
| 778 | 778 | |
| 779 | 779 |  	} else { | 
| 780 | 780 | |
| 781 | - $price = give_get_form_price( $form_id ); | |
| 781 | + $price = give_get_form_price($form_id); | |
| 782 | 782 | |
| 783 | 783 | } | 
| 784 | 784 | |
| 785 | - $price = apply_filters( 'give_form_price', give_sanitize_amount( $price ), $form_id ); | |
| 786 | - $formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>'; | |
| 787 | - $formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price ); | |
| 785 | +	$price           = apply_filters('give_form_price', give_sanitize_amount($price), $form_id); | |
| 786 | + $formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>'; | |
| 787 | +	$formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price); | |
| 788 | 788 | |
| 789 | -	if ( $echo ) { | |
| 789 | +	if ($echo) { | |
| 790 | 790 | echo $formatted_price; | 
| 791 | 791 |  	} else { | 
| 792 | 792 | return $formatted_price; | 
| 793 | 793 | } | 
| 794 | 794 | } | 
| 795 | 795 | |
| 796 | -add_filter( 'give_form_price', 'give_format_amount', 10 ); | |
| 797 | -add_filter( 'give_form_price', 'give_currency_filter', 20 ); | |
| 796 | +add_filter('give_form_price', 'give_format_amount', 10); | |
| 797 | +add_filter('give_form_price', 'give_currency_filter', 20); | |
| 798 | 798 | |
| 799 | 799 | |
| 800 | 800 | /** | 
| @@ -807,19 +807,19 @@ discard block | ||
| 807 | 807 | * | 
| 808 | 808 | * @return float $amount Amount of the price option | 
| 809 | 809 | */ | 
| 810 | -function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) { | |
| 811 | - $prices = give_get_variable_prices( $form_id ); | |
| 810 | +function give_get_price_option_amount($form_id = 0, $price_id = 0) { | |
| 811 | + $prices = give_get_variable_prices($form_id); | |
| 812 | 812 | |
| 813 | 813 | $amount = 0.00; | 
| 814 | 814 | |
| 815 | -	foreach ( $prices as $price ) { | |
| 816 | -		if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) { | |
| 817 | - $amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00; | |
| 815 | +	foreach ($prices as $price) { | |
| 816 | +		if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] == $price_id) { | |
| 817 | + $amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00; | |
| 818 | 818 | break; | 
| 819 | 819 | }; | 
| 820 | 820 | } | 
| 821 | 821 | |
| 822 | - return apply_filters( 'give_get_price_option_amount', give_sanitize_amount( $amount ), $form_id, $price_id ); | |
| 822 | +	return apply_filters('give_get_price_option_amount', give_sanitize_amount($amount), $form_id, $price_id); | |
| 823 | 823 | } | 
| 824 | 824 | |
| 825 | 825 | /** | 
| @@ -831,13 +831,13 @@ discard block | ||
| 831 | 831 | * | 
| 832 | 832 | * @return mixed string|int Goal of the form | 
| 833 | 833 | */ | 
| 834 | -function give_get_form_goal( $form_id = 0 ) { | |
| 834 | +function give_get_form_goal($form_id = 0) { | |
| 835 | 835 | |
| 836 | -	if ( empty( $form_id ) ) { | |
| 836 | +	if (empty($form_id)) { | |
| 837 | 837 | return false; | 
| 838 | 838 | } | 
| 839 | 839 | |
| 840 | - $form = new Give_Donate_Form( $form_id ); | |
| 840 | + $form = new Give_Donate_Form($form_id); | |
| 841 | 841 | |
| 842 | 842 | return $form->goal; | 
| 843 | 843 | |
| @@ -853,27 +853,27 @@ discard block | ||
| 853 | 853 | * | 
| 854 | 854 | * @return string $formatted_goal | 
| 855 | 855 | */ | 
| 856 | -function give_goal( $form_id = 0, $echo = true ) { | |
| 856 | +function give_goal($form_id = 0, $echo = true) { | |
| 857 | 857 | |
| 858 | -	if ( empty( $form_id ) ) { | |
| 858 | +	if (empty($form_id)) { | |
| 859 | 859 | $form_id = get_the_ID(); | 
| 860 | 860 | } | 
| 861 | 861 | |
| 862 | - $goal = give_get_form_goal( $form_id ); | |
| 862 | + $goal = give_get_form_goal($form_id); | |
| 863 | 863 | |
| 864 | - $goal = apply_filters( 'give_form_goal', give_sanitize_amount( $goal ), $form_id ); | |
| 865 | - $formatted_goal = '<span class="give_price" id="give_price_' . $form_id . '">' . $goal . '</span>'; | |
| 866 | - $formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal ); | |
| 864 | +	$goal           = apply_filters('give_form_goal', give_sanitize_amount($goal), $form_id); | |
| 865 | + $formatted_goal = '<span class="give_price" id="give_price_'.$form_id.'">'.$goal.'</span>'; | |
| 866 | +	$formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal); | |
| 867 | 867 | |
| 868 | -	if ( $echo ) { | |
| 868 | +	if ($echo) { | |
| 869 | 869 | echo $formatted_goal; | 
| 870 | 870 |  	} else { | 
| 871 | 871 | return $formatted_goal; | 
| 872 | 872 | } | 
| 873 | 873 | } | 
| 874 | 874 | |
| 875 | -add_filter( 'give_form_goal', 'give_format_amount', 10 ); | |
| 876 | -add_filter( 'give_form_goal', 'give_currency_filter', 20 ); | |
| 875 | +add_filter('give_form_goal', 'give_format_amount', 10); | |
| 876 | +add_filter('give_form_goal', 'give_currency_filter', 20); | |
| 877 | 877 | |
| 878 | 878 | |
| 879 | 879 | /** | 
| @@ -887,13 +887,13 @@ discard block | ||
| 887 | 887 | * | 
| 888 | 888 | * @return bool $ret Whether or not the logged_in_only setting is set | 
| 889 | 889 | */ | 
| 890 | -function give_logged_in_only( $form_id ) { | |
| 890 | +function give_logged_in_only($form_id) { | |
| 891 | 891 | |
| 892 | - $form_option = get_post_meta( $form_id, '_give_logged_in_only', true ); | |
| 892 | + $form_option = get_post_meta($form_id, '_give_logged_in_only', true); | |
| 893 | 893 | |
| 894 | - $ret = ! empty( $form_option ) ? $form_option : false; | |
| 894 | + $ret = ! empty($form_option) ? $form_option : false; | |
| 895 | 895 | |
| 896 | - return (bool) apply_filters( 'give_logged_in_only', $ret, $form_id ); | |
| 896 | +	return (bool) apply_filters('give_logged_in_only', $ret, $form_id); | |
| 897 | 897 | |
| 898 | 898 | } | 
| 899 | 899 | |
| @@ -907,10 +907,10 @@ discard block | ||
| 907 | 907 | * | 
| 908 | 908 | * @return string | 
| 909 | 909 | */ | 
| 910 | -function give_show_login_register_option( $form_id ) { | |
| 910 | +function give_show_login_register_option($form_id) { | |
| 911 | 911 | |
| 912 | - $show_register_form = get_post_meta( $form_id, '_give_show_register_form', true ); | |
| 912 | + $show_register_form = get_post_meta($form_id, '_give_show_register_form', true); | |
| 913 | 913 | |
| 914 | - return apply_filters( 'give_show_register_form', $show_register_form, $form_id ); | |
| 914 | +	return apply_filters('give_show_register_form', $show_register_form, $form_id); | |
| 915 | 915 | |
| 916 | 916 | } | 
| 917 | 917 | \ No newline at end of file |