@@ -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' && $typenow != 'give_campaigns' ) { |
|
| 26 | + if ($typenow != 'give_forms' && $typenow != 'give_campaigns') { |
|
| 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 | /** |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | $can_checkout = true; |
| 92 | 92 | |
| 93 | - return (bool) apply_filters( 'give_can_checkout', $can_checkout ); |
|
| 93 | + return (bool) apply_filters('give_can_checkout', $can_checkout); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -103,9 +103,9 @@ discard block |
||
| 103 | 103 | function give_get_success_page_uri() { |
| 104 | 104 | global $give_options; |
| 105 | 105 | |
| 106 | - $success_page = isset( $give_options['success_page'] ) ? get_permalink( absint( $give_options['success_page'] ) ) : get_bloginfo( 'url' ); |
|
| 106 | + $success_page = isset($give_options['success_page']) ? get_permalink(absint($give_options['success_page'])) : get_bloginfo('url'); |
|
| 107 | 107 | |
| 108 | - return apply_filters( 'give_get_success_page_uri', $success_page ); |
|
| 108 | + return apply_filters('give_get_success_page_uri', $success_page); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -116,9 +116,9 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | function give_is_success_page() { |
| 118 | 118 | global $give_options; |
| 119 | - $is_success_page = isset( $give_options['success_page'] ) ? is_page( $give_options['success_page'] ) : false; |
|
| 119 | + $is_success_page = isset($give_options['success_page']) ? is_page($give_options['success_page']) : false; |
|
| 120 | 120 | |
| 121 | - return apply_filters( 'give_is_success_page', $is_success_page ); |
|
| 121 | + return apply_filters('give_is_success_page', $is_success_page); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -132,17 +132,17 @@ discard block |
||
| 132 | 132 | * @since 1.0 |
| 133 | 133 | * @return void |
| 134 | 134 | */ |
| 135 | -function give_send_to_success_page( $query_string = null ) { |
|
| 135 | +function give_send_to_success_page($query_string = null) { |
|
| 136 | 136 | |
| 137 | 137 | $redirect = give_get_success_page_uri(); |
| 138 | 138 | |
| 139 | - if ( $query_string ) { |
|
| 139 | + if ($query_string) { |
|
| 140 | 140 | $redirect .= $query_string; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - $gateway = isset( $_REQUEST['give-gateway'] ) ? $_REQUEST['give-gateway'] : ''; |
|
| 143 | + $gateway = isset($_REQUEST['give-gateway']) ? $_REQUEST['give-gateway'] : ''; |
|
| 144 | 144 | |
| 145 | - wp_redirect( apply_filters( 'give_success_page_redirect', $redirect, $gateway, $query_string ) ); |
|
| 145 | + wp_redirect(apply_filters('give_success_page_redirect', $redirect, $gateway, $query_string)); |
|
| 146 | 146 | give_die(); |
| 147 | 147 | } |
| 148 | 148 | |
@@ -159,25 +159,25 @@ discard block |
||
| 159 | 159 | * @since 1.0 |
| 160 | 160 | * @return Void |
| 161 | 161 | */ |
| 162 | -function give_send_back_to_checkout( $args = array() ) { |
|
| 162 | +function give_send_back_to_checkout($args = array()) { |
|
| 163 | 163 | |
| 164 | - $redirect = ( isset( $_POST['give-current-url'] ) ) ? $_POST['give-current-url'] : ''; |
|
| 165 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : 0; |
|
| 164 | + $redirect = (isset($_POST['give-current-url'])) ? $_POST['give-current-url'] : ''; |
|
| 165 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : 0; |
|
| 166 | 166 | |
| 167 | 167 | $defaults = array( |
| 168 | 168 | 'form-id' => (int) $form_id |
| 169 | 169 | ); |
| 170 | 170 | |
| 171 | 171 | // Check for backward compatibility |
| 172 | - if ( is_string( $args ) ) { |
|
| 173 | - $args = str_replace( '?', '', $args ); |
|
| 172 | + if (is_string($args)) { |
|
| 173 | + $args = str_replace('?', '', $args); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - $args = wp_parse_args( $args, $defaults ); |
|
| 176 | + $args = wp_parse_args($args, $defaults); |
|
| 177 | 177 | |
| 178 | - $redirect = add_query_arg( $args, $redirect ) . '#give-form-' . $form_id . '-wrap'; |
|
| 178 | + $redirect = add_query_arg($args, $redirect).'#give-form-'.$form_id.'-wrap'; |
|
| 179 | 179 | |
| 180 | - wp_redirect( apply_filters( 'give_send_back_to_checkout', $redirect, $args ) ); |
|
| 180 | + wp_redirect(apply_filters('give_send_back_to_checkout', $redirect, $args)); |
|
| 181 | 181 | give_die(); |
| 182 | 182 | } |
| 183 | 183 | |
@@ -192,16 +192,16 @@ discard block |
||
| 192 | 192 | * @since 1.0 |
| 193 | 193 | * @return string |
| 194 | 194 | */ |
| 195 | -function give_get_success_page_url( $query_string = null ) { |
|
| 195 | +function give_get_success_page_url($query_string = null) { |
|
| 196 | 196 | |
| 197 | - $success_page = give_get_option( 'success_page', 0 ); |
|
| 198 | - $success_page = get_permalink( $success_page ); |
|
| 197 | + $success_page = give_get_option('success_page', 0); |
|
| 198 | + $success_page = get_permalink($success_page); |
|
| 199 | 199 | |
| 200 | - if ( $query_string ) { |
|
| 200 | + if ($query_string) { |
|
| 201 | 201 | $success_page .= $query_string; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - return apply_filters( 'give_success_page_url', $success_page ); |
|
| 204 | + return apply_filters('give_success_page_url', $success_page); |
|
| 205 | 205 | |
| 206 | 206 | } |
| 207 | 207 | |
@@ -215,15 +215,15 @@ discard block |
||
| 215 | 215 | * |
| 216 | 216 | * @return mixed|void Full URL to the Transaction Failed page, if present, home page if it doesn't exist |
| 217 | 217 | */ |
| 218 | -function give_get_failed_transaction_uri( $extras = false ) { |
|
| 218 | +function give_get_failed_transaction_uri($extras = false) { |
|
| 219 | 219 | global $give_options; |
| 220 | 220 | |
| 221 | - $uri = ! empty( $give_options['failure_page'] ) ? trailingslashit( get_permalink( $give_options['failure_page'] ) ) : home_url(); |
|
| 222 | - if ( $extras ) { |
|
| 221 | + $uri = ! empty($give_options['failure_page']) ? trailingslashit(get_permalink($give_options['failure_page'])) : home_url(); |
|
| 222 | + if ($extras) { |
|
| 223 | 223 | $uri .= $extras; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - return apply_filters( 'give_get_failed_transaction_uri', $uri ); |
|
| 226 | + return apply_filters('give_get_failed_transaction_uri', $uri); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | /** |
@@ -234,9 +234,9 @@ discard block |
||
| 234 | 234 | */ |
| 235 | 235 | function give_is_failed_transaction_page() { |
| 236 | 236 | global $give_options; |
| 237 | - $ret = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false; |
|
| 237 | + $ret = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false; |
|
| 238 | 238 | |
| 239 | - return apply_filters( 'give_is_failure_page', $ret ); |
|
| 239 | + return apply_filters('give_is_failure_page', $ret); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
@@ -248,18 +248,18 @@ discard block |
||
| 248 | 248 | */ |
| 249 | 249 | function give_listen_for_failed_payments() { |
| 250 | 250 | |
| 251 | - $failed_page = give_get_option( 'failure_page', 0 ); |
|
| 251 | + $failed_page = give_get_option('failure_page', 0); |
|
| 252 | 252 | |
| 253 | - if ( ! empty( $failed_page ) && is_page( $failed_page ) && ! empty( $_GET['payment-id'] ) ) { |
|
| 253 | + if ( ! empty($failed_page) && is_page($failed_page) && ! empty($_GET['payment-id'])) { |
|
| 254 | 254 | |
| 255 | - $payment_id = absint( $_GET['payment-id'] ); |
|
| 256 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 255 | + $payment_id = absint($_GET['payment-id']); |
|
| 256 | + give_update_payment_status($payment_id, 'failed'); |
|
| 257 | 257 | |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | -add_action( 'template_redirect', 'give_listen_for_failed_payments' ); |
|
| 262 | +add_action('template_redirect', 'give_listen_for_failed_payments'); |
|
| 263 | 263 | |
| 264 | 264 | |
| 265 | 265 | /** |
@@ -272,11 +272,11 @@ discard block |
||
| 272 | 272 | * @since 1.0 |
| 273 | 273 | * @return bool |
| 274 | 274 | */ |
| 275 | -function give_field_is_required( $field = '', $form_id ) { |
|
| 275 | +function give_field_is_required($field = '', $form_id) { |
|
| 276 | 276 | |
| 277 | - $required_fields = give_purchase_form_required_fields( $form_id ); |
|
| 277 | + $required_fields = give_purchase_form_required_fields($form_id); |
|
| 278 | 278 | |
| 279 | - return array_key_exists( $field, $required_fields ); |
|
| 279 | + return array_key_exists($field, $required_fields); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | /** |
@@ -286,9 +286,9 @@ discard block |
||
| 286 | 286 | * @return array |
| 287 | 287 | */ |
| 288 | 288 | function give_get_banned_emails() { |
| 289 | - $emails = array_map( 'trim', give_get_option( 'banned_emails', array() ) ); |
|
| 289 | + $emails = array_map('trim', give_get_option('banned_emails', array())); |
|
| 290 | 290 | |
| 291 | - return apply_filters( 'give_get_banned_emails', $emails ); |
|
| 291 | + return apply_filters('give_get_banned_emails', $emails); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | /** |
@@ -297,15 +297,15 @@ discard block |
||
| 297 | 297 | * @since 2.0 |
| 298 | 298 | * @return bool |
| 299 | 299 | */ |
| 300 | -function give_is_email_banned( $email = '' ) { |
|
| 300 | +function give_is_email_banned($email = '') { |
|
| 301 | 301 | |
| 302 | - if ( empty( $email ) ) { |
|
| 302 | + if (empty($email)) { |
|
| 303 | 303 | return false; |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - $ret = in_array( trim( $email ), give_get_banned_emails() ); |
|
| 306 | + $ret = in_array(trim($email), give_get_banned_emails()); |
|
| 307 | 307 | |
| 308 | - return apply_filters( 'give_is_email_banned', $ret, $email ); |
|
| 308 | + return apply_filters('give_is_email_banned', $ret, $email); |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | /** |
@@ -315,9 +315,9 @@ discard block |
||
| 315 | 315 | * @return bool True if enforce SSL is enabled, false otherwise |
| 316 | 316 | */ |
| 317 | 317 | function give_is_ssl_enforced() { |
| 318 | - $ssl_enforced = give_get_option( 'enforce_ssl', false ); |
|
| 318 | + $ssl_enforced = give_get_option('enforce_ssl', false); |
|
| 319 | 319 | |
| 320 | - return (bool) apply_filters( 'give_is_ssl_enforced', $ssl_enforced ); |
|
| 320 | + return (bool) apply_filters('give_is_ssl_enforced', $ssl_enforced); |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | /** |
@@ -328,17 +328,17 @@ discard block |
||
| 328 | 328 | * @return void |
| 329 | 329 | */ |
| 330 | 330 | function give_enforced_ssl_redirect_handler() { |
| 331 | - if ( ! give_is_ssl_enforced() || is_admin() || is_ssl() ) { |
|
| 331 | + if ( ! give_is_ssl_enforced() || is_admin() || is_ssl()) { |
|
| 332 | 332 | return; |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | - if ( isset( $_SERVER["HTTPS"] ) && $_SERVER["HTTPS"] == "on" ) { |
|
| 335 | + if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") { |
|
| 336 | 336 | return; |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | - $uri = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
| 339 | + $uri = 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; |
|
| 340 | 340 | |
| 341 | - wp_safe_redirect( $uri ); |
|
| 341 | + wp_safe_redirect($uri); |
|
| 342 | 342 | exit; |
| 343 | 343 | } |
| 344 | 344 | |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | * @return void |
| 352 | 352 | */ |
| 353 | 353 | function give_enforced_ssl_asset_handler() { |
| 354 | - if ( ! give_is_ssl_enforced() || is_admin() ) { |
|
| 354 | + if ( ! give_is_ssl_enforced() || is_admin()) { |
|
| 355 | 355 | return; |
| 356 | 356 | } |
| 357 | 357 | |
@@ -369,10 +369,10 @@ discard block |
||
| 369 | 369 | 'site_url' |
| 370 | 370 | ); |
| 371 | 371 | |
| 372 | - $filters = apply_filters( 'give_enforced_ssl_asset_filters', $filters ); |
|
| 372 | + $filters = apply_filters('give_enforced_ssl_asset_filters', $filters); |
|
| 373 | 373 | |
| 374 | - foreach ( $filters as $filter ) { |
|
| 375 | - add_filter( $filter, 'give_enforced_ssl_asset_filter', 1 ); |
|
| 374 | + foreach ($filters as $filter) { |
|
| 375 | + add_filter($filter, 'give_enforced_ssl_asset_filter', 1); |
|
| 376 | 376 | } |
| 377 | 377 | } |
| 378 | 378 | |
@@ -387,11 +387,11 @@ discard block |
||
| 387 | 387 | * |
| 388 | 388 | * @return mixed |
| 389 | 389 | */ |
| 390 | -function give_enforced_ssl_asset_filter( $content ) { |
|
| 390 | +function give_enforced_ssl_asset_filter($content) { |
|
| 391 | 391 | |
| 392 | - if ( is_array( $content ) ) { |
|
| 392 | + if (is_array($content)) { |
|
| 393 | 393 | |
| 394 | - $content = array_map( 'give_enforced_ssl_asset_filter', $content ); |
|
| 394 | + $content = array_map('give_enforced_ssl_asset_filter', $content); |
|
| 395 | 395 | |
| 396 | 396 | } else { |
| 397 | 397 | |
@@ -438,14 +438,14 @@ discard block |
||
| 438 | 438 | * |
| 439 | 439 | * @return void |
| 440 | 440 | */ |
| 441 | -function give_record_sale_in_log( $give_form_id = 0, $payment_id, $price_id = false, $sale_date = null ) { |
|
| 441 | +function give_record_sale_in_log($give_form_id = 0, $payment_id, $price_id = false, $sale_date = null) { |
|
| 442 | 442 | global $give_logs; |
| 443 | 443 | |
| 444 | 444 | $log_data = array( |
| 445 | 445 | 'post_parent' => $give_form_id, |
| 446 | 446 | 'log_type' => 'sale', |
| 447 | - 'post_date' => isset( $sale_date ) ? $sale_date : null, |
|
| 448 | - 'post_date_gmt' => isset( $sale_date ) ? $sale_date : null |
|
| 447 | + 'post_date' => isset($sale_date) ? $sale_date : null, |
|
| 448 | + 'post_date_gmt' => isset($sale_date) ? $sale_date : null |
|
| 449 | 449 | ); |
| 450 | 450 | |
| 451 | 451 | $log_meta = array( |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | 'price_id' => (int) $price_id |
| 454 | 454 | ); |
| 455 | 455 | |
| 456 | - $give_logs->insert_log( $log_data, $log_meta ); |
|
| 456 | + $give_logs->insert_log($log_data, $log_meta); |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | |
@@ -466,8 +466,8 @@ discard block |
||
| 466 | 466 | * |
| 467 | 467 | * @return bool|int |
| 468 | 468 | */ |
| 469 | -function give_increase_purchase_count( $give_form_id = 0 ) { |
|
| 470 | - $form = new Give_Donate_Form( $give_form_id ); |
|
| 469 | +function give_increase_purchase_count($give_form_id = 0) { |
|
| 470 | + $form = new Give_Donate_Form($give_form_id); |
|
| 471 | 471 | |
| 472 | 472 | return $form->increase_sales(); |
| 473 | 473 | } |
@@ -481,8 +481,8 @@ discard block |
||
| 481 | 481 | * |
| 482 | 482 | * @return bool|int |
| 483 | 483 | */ |
| 484 | -function give_decrease_purchase_count( $give_form_id = 0 ) { |
|
| 485 | - $form = new Give_Donate_Form( $give_form_id ); |
|
| 484 | +function give_decrease_purchase_count($give_form_id = 0) { |
|
| 485 | + $form = new Give_Donate_Form($give_form_id); |
|
| 486 | 486 | |
| 487 | 487 | return $form->decrease_sales(); |
| 488 | 488 | } |
@@ -497,10 +497,10 @@ discard block |
||
| 497 | 497 | * |
| 498 | 498 | * @return bool|int |
| 499 | 499 | */ |
| 500 | -function give_increase_earnings( $give_form_id = 0, $amount ) { |
|
| 501 | - $form = new Give_Donate_Form( $give_form_id ); |
|
| 500 | +function give_increase_earnings($give_form_id = 0, $amount) { |
|
| 501 | + $form = new Give_Donate_Form($give_form_id); |
|
| 502 | 502 | |
| 503 | - return $form->increase_earnings( $amount ); |
|
| 503 | + return $form->increase_earnings($amount); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | /** |
@@ -513,10 +513,10 @@ discard block |
||
| 513 | 513 | * |
| 514 | 514 | * @return bool|int |
| 515 | 515 | */ |
| 516 | -function give_decrease_earnings( $give_form_id = 0, $amount ) { |
|
| 517 | - $form = new Give_Donate_Form( $give_form_id ); |
|
| 516 | +function give_decrease_earnings($give_form_id = 0, $amount) { |
|
| 517 | + $form = new Give_Donate_Form($give_form_id); |
|
| 518 | 518 | |
| 519 | - return $form->decrease_earnings( $amount ); |
|
| 519 | + return $form->decrease_earnings($amount); |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | |
@@ -529,8 +529,8 @@ discard block |
||
| 529 | 529 | * |
| 530 | 530 | * @return int $earnings Earnings for a certain form |
| 531 | 531 | */ |
| 532 | -function give_get_form_earnings_stats( $give_form_id = 0 ) { |
|
| 533 | - $give_form = new Give_Donate_Form( $give_form_id ); |
|
| 532 | +function give_get_form_earnings_stats($give_form_id = 0) { |
|
| 533 | + $give_form = new Give_Donate_Form($give_form_id); |
|
| 534 | 534 | |
| 535 | 535 | return $give_form->earnings; |
| 536 | 536 | } |
@@ -545,8 +545,8 @@ discard block |
||
| 545 | 545 | * |
| 546 | 546 | * @return int $sales Amount of sales for a certain form |
| 547 | 547 | */ |
| 548 | -function give_get_form_sales_stats( $give_form_id = 0 ) { |
|
| 549 | - $give_form = new Give_Donate_Form( $give_form_id ); |
|
| 548 | +function give_get_form_sales_stats($give_form_id = 0) { |
|
| 549 | + $give_form = new Give_Donate_Form($give_form_id); |
|
| 550 | 550 | |
| 551 | 551 | return $give_form->sales; |
| 552 | 552 | } |
@@ -561,16 +561,16 @@ discard block |
||
| 561 | 561 | * |
| 562 | 562 | * @return float $sales Average monthly sales |
| 563 | 563 | */ |
| 564 | -function give_get_average_monthly_form_sales( $form_id = 0 ) { |
|
| 565 | - $sales = give_get_form_sales_stats( $form_id ); |
|
| 566 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
| 564 | +function give_get_average_monthly_form_sales($form_id = 0) { |
|
| 565 | + $sales = give_get_form_sales_stats($form_id); |
|
| 566 | + $release_date = get_post_field('post_date', $form_id); |
|
| 567 | 567 | |
| 568 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
| 568 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
| 569 | 569 | |
| 570 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
| 570 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
| 571 | 571 | |
| 572 | - if ( $months > 0 ) { |
|
| 573 | - $sales = ( $sales / $months ); |
|
| 572 | + if ($months > 0) { |
|
| 573 | + $sales = ($sales / $months); |
|
| 574 | 574 | } |
| 575 | 575 | |
| 576 | 576 | return $sales; |
@@ -586,16 +586,16 @@ discard block |
||
| 586 | 586 | * |
| 587 | 587 | * @return float $earnings Average monthly earnings |
| 588 | 588 | */ |
| 589 | -function give_get_average_monthly_form_earnings( $form_id = 0 ) { |
|
| 590 | - $earnings = give_get_form_earnings_stats( $form_id ); |
|
| 591 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
| 589 | +function give_get_average_monthly_form_earnings($form_id = 0) { |
|
| 590 | + $earnings = give_get_form_earnings_stats($form_id); |
|
| 591 | + $release_date = get_post_field('post_date', $form_id); |
|
| 592 | 592 | |
| 593 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
| 593 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
| 594 | 594 | |
| 595 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
| 595 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
| 596 | 596 | |
| 597 | - if ( $months > 0 ) { |
|
| 598 | - $earnings = ( $earnings / $months ); |
|
| 597 | + if ($months > 0) { |
|
| 598 | + $earnings = ($earnings / $months); |
|
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | return $earnings < 0 ? 0 : $earnings; |
@@ -615,21 +615,21 @@ discard block |
||
| 615 | 615 | * |
| 616 | 616 | * @return string $price_name Name of the price option |
| 617 | 617 | */ |
| 618 | -function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0 ) { |
|
| 618 | +function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0) { |
|
| 619 | 619 | |
| 620 | - $prices = give_get_variable_prices( $form_id ); |
|
| 620 | + $prices = give_get_variable_prices($form_id); |
|
| 621 | 621 | $price_name = ''; |
| 622 | 622 | |
| 623 | - foreach ( $prices as $price ) { |
|
| 623 | + foreach ($prices as $price) { |
|
| 624 | 624 | |
| 625 | - if ( intval( $price['_give_id']['level_id'] ) == intval( $price_id ) ) { |
|
| 626 | - $price_name = isset( $price['_give_text'] ) ? $price['_give_text'] : ''; |
|
| 625 | + if (intval($price['_give_id']['level_id']) == intval($price_id)) { |
|
| 626 | + $price_name = isset($price['_give_text']) ? $price['_give_text'] : ''; |
|
| 627 | 627 | } |
| 628 | 628 | |
| 629 | 629 | } |
| 630 | 630 | |
| 631 | 631 | |
| 632 | - return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id ); |
|
| 632 | + return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id); |
|
| 633 | 633 | } |
| 634 | 634 | |
| 635 | 635 | |
@@ -642,14 +642,14 @@ discard block |
||
| 642 | 642 | * |
| 643 | 643 | * @return string $range A fully formatted price range |
| 644 | 644 | */ |
| 645 | -function give_price_range( $form_id = 0 ) { |
|
| 646 | - $low = give_get_lowest_price_option( $form_id ); |
|
| 647 | - $high = give_get_highest_price_option( $form_id ); |
|
| 648 | - $range = '<span class="give_price_range_low">' . give_currency_filter( give_format_amount( $low ) ) . '</span>'; |
|
| 645 | +function give_price_range($form_id = 0) { |
|
| 646 | + $low = give_get_lowest_price_option($form_id); |
|
| 647 | + $high = give_get_highest_price_option($form_id); |
|
| 648 | + $range = '<span class="give_price_range_low">'.give_currency_filter(give_format_amount($low)).'</span>'; |
|
| 649 | 649 | $range .= '<span class="give_price_range_sep"> – </span>'; |
| 650 | - $range .= '<span class="give_price_range_high">' . give_currency_filter( give_format_amount( $high ) ) . '</span>'; |
|
| 650 | + $range .= '<span class="give_price_range_high">'.give_currency_filter(give_format_amount($high)).'</span>'; |
|
| 651 | 651 | |
| 652 | - return apply_filters( 'give_price_range', $range, $form_id, $low, $high ); |
|
| 652 | + return apply_filters('give_price_range', $range, $form_id, $low, $high); |
|
| 653 | 653 | } |
| 654 | 654 | |
| 655 | 655 | |
@@ -662,43 +662,43 @@ discard block |
||
| 662 | 662 | * |
| 663 | 663 | * @return float Amount of the lowest price |
| 664 | 664 | */ |
| 665 | -function give_get_lowest_price_option( $form_id = 0 ) { |
|
| 666 | - if ( empty( $form_id ) ) { |
|
| 665 | +function give_get_lowest_price_option($form_id = 0) { |
|
| 666 | + if (empty($form_id)) { |
|
| 667 | 667 | $form_id = get_the_ID(); |
| 668 | 668 | } |
| 669 | 669 | |
| 670 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
| 671 | - return give_get_form_price( $form_id ); |
|
| 670 | + if ( ! give_has_variable_prices($form_id)) { |
|
| 671 | + return give_get_form_price($form_id); |
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | - $prices = give_get_variable_prices( $form_id ); |
|
| 674 | + $prices = give_get_variable_prices($form_id); |
|
| 675 | 675 | |
| 676 | 676 | $low = 0.00; |
| 677 | 677 | |
| 678 | - if ( ! empty( $prices ) ) { |
|
| 678 | + if ( ! empty($prices)) { |
|
| 679 | 679 | |
| 680 | - foreach ( $prices as $key => $price ) { |
|
| 680 | + foreach ($prices as $key => $price) { |
|
| 681 | 681 | |
| 682 | - if ( empty( $price['_give_amount'] ) ) { |
|
| 682 | + if (empty($price['_give_amount'])) { |
|
| 683 | 683 | continue; |
| 684 | 684 | } |
| 685 | 685 | |
| 686 | - if ( ! isset( $min ) ) { |
|
| 686 | + if ( ! isset($min)) { |
|
| 687 | 687 | $min = $price['_give_amount']; |
| 688 | 688 | } else { |
| 689 | - $min = min( $min, give_sanitize_amount( $price['_give_amount'] ) ); |
|
| 689 | + $min = min($min, give_sanitize_amount($price['_give_amount'])); |
|
| 690 | 690 | } |
| 691 | 691 | |
| 692 | - if ( $price['_give_amount'] == $min ) { |
|
| 692 | + if ($price['_give_amount'] == $min) { |
|
| 693 | 693 | $min_id = $key; |
| 694 | 694 | } |
| 695 | 695 | } |
| 696 | 696 | |
| 697 | - $low = $prices[ $min_id ]['_give_amount']; |
|
| 697 | + $low = $prices[$min_id]['_give_amount']; |
|
| 698 | 698 | |
| 699 | 699 | } |
| 700 | 700 | |
| 701 | - return give_sanitize_amount( $low ); |
|
| 701 | + return give_sanitize_amount($low); |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | /** |
@@ -710,41 +710,41 @@ discard block |
||
| 710 | 710 | * |
| 711 | 711 | * @return float Amount of the highest price |
| 712 | 712 | */ |
| 713 | -function give_get_highest_price_option( $form_id = 0 ) { |
|
| 713 | +function give_get_highest_price_option($form_id = 0) { |
|
| 714 | 714 | |
| 715 | - if ( empty( $form_id ) ) { |
|
| 715 | + if (empty($form_id)) { |
|
| 716 | 716 | $form_id = get_the_ID(); |
| 717 | 717 | } |
| 718 | 718 | |
| 719 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
| 720 | - return give_get_form_price( $form_id ); |
|
| 719 | + if ( ! give_has_variable_prices($form_id)) { |
|
| 720 | + return give_get_form_price($form_id); |
|
| 721 | 721 | } |
| 722 | 722 | |
| 723 | - $prices = give_get_variable_prices( $form_id ); |
|
| 723 | + $prices = give_get_variable_prices($form_id); |
|
| 724 | 724 | |
| 725 | 725 | $high = 0.00; |
| 726 | 726 | |
| 727 | - if ( ! empty( $prices ) ) { |
|
| 727 | + if ( ! empty($prices)) { |
|
| 728 | 728 | |
| 729 | 729 | $max = 0; |
| 730 | 730 | |
| 731 | - foreach ( $prices as $key => $price ) { |
|
| 732 | - if ( empty( $price['_give_amount'] ) ) { |
|
| 731 | + foreach ($prices as $key => $price) { |
|
| 732 | + if (empty($price['_give_amount'])) { |
|
| 733 | 733 | continue; |
| 734 | 734 | } |
| 735 | - $give_amount = give_sanitize_amount( $price['_give_amount'] ); |
|
| 735 | + $give_amount = give_sanitize_amount($price['_give_amount']); |
|
| 736 | 736 | |
| 737 | - $max = max( $max, $give_amount ); |
|
| 737 | + $max = max($max, $give_amount); |
|
| 738 | 738 | |
| 739 | - if ( $give_amount == $max ) { |
|
| 739 | + if ($give_amount == $max) { |
|
| 740 | 740 | $max_id = $key; |
| 741 | 741 | } |
| 742 | 742 | } |
| 743 | 743 | |
| 744 | - $high = $prices[ $max_id ]['_give_amount']; |
|
| 744 | + $high = $prices[$max_id]['_give_amount']; |
|
| 745 | 745 | } |
| 746 | 746 | |
| 747 | - return give_sanitize_amount( $high ); |
|
| 747 | + return give_sanitize_amount($high); |
|
| 748 | 748 | } |
| 749 | 749 | |
| 750 | 750 | /** |
@@ -756,15 +756,15 @@ discard block |
||
| 756 | 756 | * |
| 757 | 757 | * @return mixed string|int Price of the form |
| 758 | 758 | */ |
| 759 | -function give_get_form_price( $form_id = 0 ) { |
|
| 759 | +function give_get_form_price($form_id = 0) { |
|
| 760 | 760 | |
| 761 | - if ( empty( $form_id ) ) { |
|
| 761 | + if (empty($form_id)) { |
|
| 762 | 762 | return false; |
| 763 | 763 | } |
| 764 | 764 | |
| 765 | - $form = new Give_Donate_Form( $form_id ); |
|
| 765 | + $form = new Give_Donate_Form($form_id); |
|
| 766 | 766 | |
| 767 | - return $form->__get( 'price' ); |
|
| 767 | + return $form->__get('price'); |
|
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | /** |
@@ -776,15 +776,15 @@ discard block |
||
| 776 | 776 | * |
| 777 | 777 | * @return mixed string|int Minimum price of the form |
| 778 | 778 | */ |
| 779 | -function give_get_form_minimum_price( $form_id = 0 ) { |
|
| 779 | +function give_get_form_minimum_price($form_id = 0) { |
|
| 780 | 780 | |
| 781 | - if ( empty( $form_id ) ) { |
|
| 781 | + if (empty($form_id)) { |
|
| 782 | 782 | return false; |
| 783 | 783 | } |
| 784 | 784 | |
| 785 | - $form = new Give_Donate_Form( $form_id ); |
|
| 785 | + $form = new Give_Donate_Form($form_id); |
|
| 786 | 786 | |
| 787 | - return $form->__get( 'minimum_price' ); |
|
| 787 | + return $form->__get('minimum_price'); |
|
| 788 | 788 | |
| 789 | 789 | } |
| 790 | 790 | |
@@ -799,52 +799,52 @@ discard block |
||
| 799 | 799 | * |
| 800 | 800 | * @return int $formatted_price |
| 801 | 801 | */ |
| 802 | -function give_price( $form_id = 0, $echo = true, $price_id = false ) { |
|
| 802 | +function give_price($form_id = 0, $echo = true, $price_id = false) { |
|
| 803 | 803 | |
| 804 | - if ( empty( $form_id ) ) { |
|
| 804 | + if (empty($form_id)) { |
|
| 805 | 805 | $form_id = get_the_ID(); |
| 806 | 806 | } |
| 807 | 807 | |
| 808 | - if ( give_has_variable_prices( $form_id ) ) { |
|
| 808 | + if (give_has_variable_prices($form_id)) { |
|
| 809 | 809 | |
| 810 | - $prices = give_get_variable_prices( $form_id ); |
|
| 810 | + $prices = give_get_variable_prices($form_id); |
|
| 811 | 811 | |
| 812 | - if ( false !== $price_id ) { |
|
| 812 | + if (false !== $price_id) { |
|
| 813 | 813 | |
| 814 | 814 | //loop through multi-prices to see which is default |
| 815 | - foreach ( $prices as $price ) { |
|
| 815 | + foreach ($prices as $price) { |
|
| 816 | 816 | //this is the default price |
| 817 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
| 817 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
| 818 | 818 | $price = (float) $price['_give_amount']; |
| 819 | 819 | }; |
| 820 | 820 | } |
| 821 | 821 | |
| 822 | 822 | } else { |
| 823 | 823 | |
| 824 | - $price = give_get_lowest_price_option( $form_id ); |
|
| 824 | + $price = give_get_lowest_price_option($form_id); |
|
| 825 | 825 | } |
| 826 | 826 | |
| 827 | - $price = give_sanitize_amount( $price ); |
|
| 827 | + $price = give_sanitize_amount($price); |
|
| 828 | 828 | |
| 829 | 829 | } else { |
| 830 | 830 | |
| 831 | - $price = give_get_form_price( $form_id ); |
|
| 831 | + $price = give_get_form_price($form_id); |
|
| 832 | 832 | |
| 833 | 833 | } |
| 834 | 834 | |
| 835 | - $price = apply_filters( 'give_form_price', give_sanitize_amount( $price ), $form_id ); |
|
| 836 | - $formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>'; |
|
| 837 | - $formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price ); |
|
| 835 | + $price = apply_filters('give_form_price', give_sanitize_amount($price), $form_id); |
|
| 836 | + $formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>'; |
|
| 837 | + $formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price); |
|
| 838 | 838 | |
| 839 | - if ( $echo ) { |
|
| 839 | + if ($echo) { |
|
| 840 | 840 | echo $formatted_price; |
| 841 | 841 | } else { |
| 842 | 842 | return $formatted_price; |
| 843 | 843 | } |
| 844 | 844 | } |
| 845 | 845 | |
| 846 | -add_filter( 'give_form_price', 'give_format_amount', 10 ); |
|
| 847 | -add_filter( 'give_form_price', 'give_currency_filter', 20 ); |
|
| 846 | +add_filter('give_form_price', 'give_format_amount', 10); |
|
| 847 | +add_filter('give_form_price', 'give_currency_filter', 20); |
|
| 848 | 848 | |
| 849 | 849 | |
| 850 | 850 | /** |
@@ -858,18 +858,18 @@ discard block |
||
| 858 | 858 | * |
| 859 | 859 | * @return float $amount Amount of the price option |
| 860 | 860 | */ |
| 861 | -function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) { |
|
| 862 | - $prices = give_get_variable_prices( $form_id ); |
|
| 861 | +function give_get_price_option_amount($form_id = 0, $price_id = 0) { |
|
| 862 | + $prices = give_get_variable_prices($form_id); |
|
| 863 | 863 | |
| 864 | 864 | $amount = 0.00; |
| 865 | 865 | |
| 866 | - foreach ( $prices as $price ) { |
|
| 867 | - if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] === $price_id ) { |
|
| 868 | - $amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00; |
|
| 866 | + foreach ($prices as $price) { |
|
| 867 | + if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] === $price_id) { |
|
| 868 | + $amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00; |
|
| 869 | 869 | }; |
| 870 | 870 | } |
| 871 | 871 | |
| 872 | - return apply_filters( 'give_get_price_option_amount', give_sanitize_amount( $amount ), $form_id, $price_id ); |
|
| 872 | + return apply_filters('give_get_price_option_amount', give_sanitize_amount($amount), $form_id, $price_id); |
|
| 873 | 873 | } |
| 874 | 874 | |
| 875 | 875 | /** |
@@ -881,13 +881,13 @@ discard block |
||
| 881 | 881 | * |
| 882 | 882 | * @return mixed string|int Goal of the form |
| 883 | 883 | */ |
| 884 | -function give_get_form_goal( $form_id = 0 ) { |
|
| 884 | +function give_get_form_goal($form_id = 0) { |
|
| 885 | 885 | |
| 886 | - if ( empty( $form_id ) ) { |
|
| 886 | + if (empty($form_id)) { |
|
| 887 | 887 | return false; |
| 888 | 888 | } |
| 889 | 889 | |
| 890 | - $form = new Give_Donate_Form( $form_id ); |
|
| 890 | + $form = new Give_Donate_Form($form_id); |
|
| 891 | 891 | |
| 892 | 892 | return $form->goal; |
| 893 | 893 | |
@@ -903,27 +903,27 @@ discard block |
||
| 903 | 903 | * |
| 904 | 904 | * @return string $formatted_goal |
| 905 | 905 | */ |
| 906 | -function give_goal( $form_id = 0, $echo = true ) { |
|
| 906 | +function give_goal($form_id = 0, $echo = true) { |
|
| 907 | 907 | |
| 908 | - if ( empty( $form_id ) ) { |
|
| 908 | + if (empty($form_id)) { |
|
| 909 | 909 | $form_id = get_the_ID(); |
| 910 | 910 | } |
| 911 | 911 | |
| 912 | - $goal = give_get_form_goal( $form_id ); |
|
| 912 | + $goal = give_get_form_goal($form_id); |
|
| 913 | 913 | |
| 914 | - $goal = apply_filters( 'give_form_goal', give_sanitize_amount( $goal ), $form_id ); |
|
| 915 | - $formatted_goal = '<span class="give_price" id="give_price_' . $form_id . '">' . $goal . '</span>'; |
|
| 916 | - $formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal ); |
|
| 914 | + $goal = apply_filters('give_form_goal', give_sanitize_amount($goal), $form_id); |
|
| 915 | + $formatted_goal = '<span class="give_price" id="give_price_'.$form_id.'">'.$goal.'</span>'; |
|
| 916 | + $formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal); |
|
| 917 | 917 | |
| 918 | - if ( $echo ) { |
|
| 918 | + if ($echo) { |
|
| 919 | 919 | echo $formatted_goal; |
| 920 | 920 | } else { |
| 921 | 921 | return $formatted_goal; |
| 922 | 922 | } |
| 923 | 923 | } |
| 924 | 924 | |
| 925 | -add_filter( 'give_form_goal', 'give_format_amount', 10 ); |
|
| 926 | -add_filter( 'give_form_goal', 'give_currency_filter', 20 ); |
|
| 925 | +add_filter('give_form_goal', 'give_format_amount', 10); |
|
| 926 | +add_filter('give_form_goal', 'give_currency_filter', 20); |
|
| 927 | 927 | |
| 928 | 928 | |
| 929 | 929 | /** |
@@ -933,13 +933,13 @@ discard block |
||
| 933 | 933 | * @global $give_options |
| 934 | 934 | * @return bool $ret Whether or not the logged_in_only setting is set |
| 935 | 935 | */ |
| 936 | -function give_logged_in_only( $form_id ) { |
|
| 936 | +function give_logged_in_only($form_id) { |
|
| 937 | 937 | |
| 938 | - $form_option = get_post_meta( $form_id, '_give_logged_in_only', true ); |
|
| 938 | + $form_option = get_post_meta($form_id, '_give_logged_in_only', true); |
|
| 939 | 939 | |
| 940 | - $ret = ! empty( $form_option ) ? $form_option : false; |
|
| 940 | + $ret = ! empty($form_option) ? $form_option : false; |
|
| 941 | 941 | |
| 942 | - return (bool) apply_filters( 'give_logged_in_only', $ret, $form_id ); |
|
| 942 | + return (bool) apply_filters('give_logged_in_only', $ret, $form_id); |
|
| 943 | 943 | |
| 944 | 944 | } |
| 945 | 945 | |
@@ -951,10 +951,10 @@ discard block |
||
| 951 | 951 | * |
| 952 | 952 | * @param $form_id |
| 953 | 953 | */ |
| 954 | -function give_show_login_register_option( $form_id ) { |
|
| 954 | +function give_show_login_register_option($form_id) { |
|
| 955 | 955 | |
| 956 | - $show_register_form = get_post_meta( $form_id, '_give_show_register_form', true ); |
|
| 956 | + $show_register_form = get_post_meta($form_id, '_give_show_register_form', true); |
|
| 957 | 957 | |
| 958 | - return apply_filters( 'give_show_register_form', $show_register_form, $form_id ); |
|
| 958 | + return apply_filters('give_show_register_form', $show_register_form, $form_id); |
|
| 959 | 959 | |
| 960 | 960 | } |
| 961 | 961 | \ No newline at end of file |