@@ -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,15 +254,15 @@ 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 | - $uri = ! empty( $give_options['failure_page'] ) ? trailingslashit( get_permalink( $give_options['failure_page'] ) ) : home_url(); |
|
| 261 | - if ( $extras ) { |
|
| 260 | + $uri = ! empty($give_options['failure_page']) ? trailingslashit(get_permalink($give_options['failure_page'])) : home_url(); |
|
| 261 | + if ($extras) { |
|
| 262 | 262 | $uri .= $extras; |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - return apply_filters( 'give_get_failed_transaction_uri', $uri ); |
|
| 265 | + return apply_filters('give_get_failed_transaction_uri', $uri); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | /** |
@@ -273,9 +273,9 @@ discard block |
||
| 273 | 273 | */ |
| 274 | 274 | function give_is_failed_transaction_page() { |
| 275 | 275 | $give_options = give_get_settings(); |
| 276 | - $ret = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false; |
|
| 276 | + $ret = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false; |
|
| 277 | 277 | |
| 278 | - return apply_filters( 'give_is_failure_page', $ret ); |
|
| 278 | + return apply_filters('give_is_failure_page', $ret); |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | /** |
@@ -287,18 +287,18 @@ discard block |
||
| 287 | 287 | */ |
| 288 | 288 | function give_listen_for_failed_payments() { |
| 289 | 289 | |
| 290 | - $failed_page = give_get_option( 'failure_page', 0 ); |
|
| 290 | + $failed_page = give_get_option('failure_page', 0); |
|
| 291 | 291 | |
| 292 | - if ( ! empty( $failed_page ) && is_page( $failed_page ) && ! empty( $_GET['payment-id'] ) ) { |
|
| 292 | + if ( ! empty($failed_page) && is_page($failed_page) && ! empty($_GET['payment-id'])) { |
|
| 293 | 293 | |
| 294 | - $payment_id = absint( $_GET['payment-id'] ); |
|
| 295 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 294 | + $payment_id = absint($_GET['payment-id']); |
|
| 295 | + give_update_payment_status($payment_id, 'failed'); |
|
| 296 | 296 | |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | -add_action( 'template_redirect', 'give_listen_for_failed_payments' ); |
|
| 301 | +add_action('template_redirect', 'give_listen_for_failed_payments'); |
|
| 302 | 302 | |
| 303 | 303 | /** |
| 304 | 304 | * Retrieve the Donation History page URI |
@@ -311,9 +311,9 @@ discard block |
||
| 311 | 311 | function give_get_history_page_uri() { |
| 312 | 312 | $give_options = give_get_settings(); |
| 313 | 313 | |
| 314 | - $history_page = isset( $give_options['history_page'] ) ? get_permalink( absint( $give_options['history_page'] ) ) : get_bloginfo( 'url' ); |
|
| 314 | + $history_page = isset($give_options['history_page']) ? get_permalink(absint($give_options['history_page'])) : get_bloginfo('url'); |
|
| 315 | 315 | |
| 316 | - return apply_filters( 'give_get_history_page_uri', $history_page ); |
|
| 316 | + return apply_filters('give_get_history_page_uri', $history_page); |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | /** |
@@ -326,11 +326,11 @@ discard block |
||
| 326 | 326 | * @since 1.0 |
| 327 | 327 | * @return bool |
| 328 | 328 | */ |
| 329 | -function give_field_is_required( $field = '', $form_id ) { |
|
| 329 | +function give_field_is_required($field = '', $form_id) { |
|
| 330 | 330 | |
| 331 | - $required_fields = give_get_required_fields( $form_id ); |
|
| 331 | + $required_fields = give_get_required_fields($form_id); |
|
| 332 | 332 | |
| 333 | - return array_key_exists( $field, $required_fields ); |
|
| 333 | + return array_key_exists($field, $required_fields); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | /** |
@@ -348,14 +348,14 @@ discard block |
||
| 348 | 348 | * |
| 349 | 349 | * @return void |
| 350 | 350 | */ |
| 351 | -function give_record_donation_in_log( $give_form_id = 0, $payment_id, $price_id = false, $donation_date = null ) { |
|
| 351 | +function give_record_donation_in_log($give_form_id = 0, $payment_id, $price_id = false, $donation_date = null) { |
|
| 352 | 352 | global $give_logs; |
| 353 | 353 | |
| 354 | 354 | $log_data = array( |
| 355 | 355 | 'post_parent' => $give_form_id, |
| 356 | 356 | 'log_type' => 'sale', |
| 357 | - 'post_date' => isset( $donation_date ) ? $donation_date : null, |
|
| 358 | - 'post_date_gmt' => isset( $donation_date ) ? $donation_date : null, |
|
| 357 | + 'post_date' => isset($donation_date) ? $donation_date : null, |
|
| 358 | + 'post_date_gmt' => isset($donation_date) ? $donation_date : null, |
|
| 359 | 359 | ); |
| 360 | 360 | |
| 361 | 361 | $log_meta = array( |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | 'price_id' => (int) $price_id, |
| 364 | 364 | ); |
| 365 | 365 | |
| 366 | - $give_logs->insert_log( $log_data, $log_meta ); |
|
| 366 | + $give_logs->insert_log($log_data, $log_meta); |
|
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | |
@@ -377,11 +377,11 @@ discard block |
||
| 377 | 377 | * |
| 378 | 378 | * @return bool|int |
| 379 | 379 | */ |
| 380 | -function give_increase_donation_count( $form_id = 0, $quantity = 1 ) { |
|
| 380 | +function give_increase_donation_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->increase_sales( $quantity ); |
|
| 384 | + return $form->increase_sales($quantity); |
|
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | /** |
@@ -394,11 +394,11 @@ discard block |
||
| 394 | 394 | * |
| 395 | 395 | * @return bool|int |
| 396 | 396 | */ |
| 397 | -function give_decrease_donation_count( $form_id = 0, $quantity = 1 ) { |
|
| 397 | +function give_decrease_donation_count($form_id = 0, $quantity = 1) { |
|
| 398 | 398 | $quantity = (int) $quantity; |
| 399 | - $form = new Give_Donate_Form( $form_id ); |
|
| 399 | + $form = new Give_Donate_Form($form_id); |
|
| 400 | 400 | |
| 401 | - return $form->decrease_sales( $quantity ); |
|
| 401 | + return $form->decrease_sales($quantity); |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | /** |
@@ -411,10 +411,10 @@ discard block |
||
| 411 | 411 | * |
| 412 | 412 | * @return bool|int |
| 413 | 413 | */ |
| 414 | -function give_increase_earnings( $give_form_id = 0, $amount ) { |
|
| 415 | - $form = new Give_Donate_Form( $give_form_id ); |
|
| 414 | +function give_increase_earnings($give_form_id = 0, $amount) { |
|
| 415 | + $form = new Give_Donate_Form($give_form_id); |
|
| 416 | 416 | |
| 417 | - return $form->increase_earnings( $amount ); |
|
| 417 | + return $form->increase_earnings($amount); |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | /** |
@@ -427,10 +427,10 @@ discard block |
||
| 427 | 427 | * |
| 428 | 428 | * @return bool|int |
| 429 | 429 | */ |
| 430 | -function give_decrease_earnings( $form_id = 0, $amount ) { |
|
| 431 | - $form = new Give_Donate_Form( $form_id ); |
|
| 430 | +function give_decrease_earnings($form_id = 0, $amount) { |
|
| 431 | + $form = new Give_Donate_Form($form_id); |
|
| 432 | 432 | |
| 433 | - return $form->decrease_earnings( $amount ); |
|
| 433 | + return $form->decrease_earnings($amount); |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | |
@@ -443,8 +443,8 @@ discard block |
||
| 443 | 443 | * |
| 444 | 444 | * @return int $earnings Earnings for a certain form |
| 445 | 445 | */ |
| 446 | -function give_get_form_earnings_stats( $form_id = 0 ) { |
|
| 447 | - $give_form = new Give_Donate_Form( $form_id ); |
|
| 446 | +function give_get_form_earnings_stats($form_id = 0) { |
|
| 447 | + $give_form = new Give_Donate_Form($form_id); |
|
| 448 | 448 | |
| 449 | 449 | return $give_form->earnings; |
| 450 | 450 | } |
@@ -459,8 +459,8 @@ discard block |
||
| 459 | 459 | * |
| 460 | 460 | * @return int $sales Amount of sales for a certain form |
| 461 | 461 | */ |
| 462 | -function give_get_form_sales_stats( $give_form_id = 0 ) { |
|
| 463 | - $give_form = new Give_Donate_Form( $give_form_id ); |
|
| 462 | +function give_get_form_sales_stats($give_form_id = 0) { |
|
| 463 | + $give_form = new Give_Donate_Form($give_form_id); |
|
| 464 | 464 | |
| 465 | 465 | return $give_form->sales; |
| 466 | 466 | } |
@@ -475,16 +475,16 @@ discard block |
||
| 475 | 475 | * |
| 476 | 476 | * @return float $sales Average monthly sales |
| 477 | 477 | */ |
| 478 | -function give_get_average_monthly_form_sales( $form_id = 0 ) { |
|
| 479 | - $sales = give_get_form_sales_stats( $form_id ); |
|
| 480 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
| 478 | +function give_get_average_monthly_form_sales($form_id = 0) { |
|
| 479 | + $sales = give_get_form_sales_stats($form_id); |
|
| 480 | + $release_date = get_post_field('post_date', $form_id); |
|
| 481 | 481 | |
| 482 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
| 482 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
| 483 | 483 | |
| 484 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
| 484 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
| 485 | 485 | |
| 486 | - if ( $months > 0 ) { |
|
| 487 | - $sales = ( $sales / $months ); |
|
| 486 | + if ($months > 0) { |
|
| 487 | + $sales = ($sales / $months); |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | return $sales; |
@@ -500,16 +500,16 @@ discard block |
||
| 500 | 500 | * |
| 501 | 501 | * @return float $earnings Average monthly earnings |
| 502 | 502 | */ |
| 503 | -function give_get_average_monthly_form_earnings( $form_id = 0 ) { |
|
| 504 | - $earnings = give_get_form_earnings_stats( $form_id ); |
|
| 505 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
| 503 | +function give_get_average_monthly_form_earnings($form_id = 0) { |
|
| 504 | + $earnings = give_get_form_earnings_stats($form_id); |
|
| 505 | + $release_date = get_post_field('post_date', $form_id); |
|
| 506 | 506 | |
| 507 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
| 507 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
| 508 | 508 | |
| 509 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
| 509 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
| 510 | 510 | |
| 511 | - if ( $months > 0 ) { |
|
| 512 | - $earnings = ( $earnings / $months ); |
|
| 511 | + if ($months > 0) { |
|
| 512 | + $earnings = ($earnings / $months); |
|
| 513 | 513 | } |
| 514 | 514 | |
| 515 | 515 | return $earnings < 0 ? 0 : $earnings; |
@@ -529,23 +529,23 @@ discard block |
||
| 529 | 529 | * |
| 530 | 530 | * @return string $price_name Name of the price option |
| 531 | 531 | */ |
| 532 | -function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0 ) { |
|
| 532 | +function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0) { |
|
| 533 | 533 | |
| 534 | - $prices = give_get_variable_prices( $form_id ); |
|
| 534 | + $prices = give_get_variable_prices($form_id); |
|
| 535 | 535 | $price_name = ''; |
| 536 | 536 | |
| 537 | - foreach ( $prices as $price ) { |
|
| 537 | + foreach ($prices as $price) { |
|
| 538 | 538 | |
| 539 | - if ( intval( $price['_give_id']['level_id'] ) == intval( $price_id ) ) { |
|
| 539 | + if (intval($price['_give_id']['level_id']) == intval($price_id)) { |
|
| 540 | 540 | |
| 541 | - $price_text = isset( $price['_give_text'] ) ? $price['_give_text'] : ''; |
|
| 542 | - $price_fallback = give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ), '', true ); |
|
| 543 | - $price_name = ! empty( $price_text ) ? $price_text : $price_fallback; |
|
| 541 | + $price_text = isset($price['_give_text']) ? $price['_give_text'] : ''; |
|
| 542 | + $price_fallback = give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false)), '', true); |
|
| 543 | + $price_name = ! empty($price_text) ? $price_text : $price_fallback; |
|
| 544 | 544 | |
| 545 | 545 | } |
| 546 | 546 | } |
| 547 | 547 | |
| 548 | - return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id ); |
|
| 548 | + return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id); |
|
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | |
@@ -559,25 +559,25 @@ discard block |
||
| 559 | 559 | * |
| 560 | 560 | * @return string $range A fully formatted price range |
| 561 | 561 | */ |
| 562 | -function give_price_range( $form_id = 0, $formatted = true ) { |
|
| 563 | - $low = give_get_lowest_price_option( $form_id ); |
|
| 564 | - $high = give_get_highest_price_option( $form_id ); |
|
| 565 | - $order_type = ! empty( $_REQUEST['order'] ) ? $_REQUEST['order'] : 'asc'; |
|
| 562 | +function give_price_range($form_id = 0, $formatted = true) { |
|
| 563 | + $low = give_get_lowest_price_option($form_id); |
|
| 564 | + $high = give_get_highest_price_option($form_id); |
|
| 565 | + $order_type = ! empty($_REQUEST['order']) ? $_REQUEST['order'] : 'asc'; |
|
| 566 | 566 | |
| 567 | 567 | $range = sprintf( |
| 568 | 568 | '<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>', |
| 569 | 569 | 'asc' === $order_type ? 'low' : 'high', |
| 570 | - 'asc' === $order_type ? give_currency_filter( give_format_amount( $low, array( 'sanitize' => false ) ) ) : give_currency_filter( give_format_amount( $high, array( 'sanitize' => false ) ) ), |
|
| 570 | + 'asc' === $order_type ? give_currency_filter(give_format_amount($low, array('sanitize' => false))) : give_currency_filter(give_format_amount($high, array('sanitize' => false))), |
|
| 571 | 571 | 'asc' === $order_type ? 'high' : 'low', |
| 572 | - 'asc' === $order_type ? give_currency_filter( give_format_amount( $high, array( 'sanitize' => false ) ) ) : give_currency_filter( give_format_amount( $low, array( 'sanitize' => false ) ) ) |
|
| 572 | + 'asc' === $order_type ? give_currency_filter(give_format_amount($high, array('sanitize' => false))) : give_currency_filter(give_format_amount($low, array('sanitize' => false))) |
|
| 573 | 573 | |
| 574 | 574 | ); |
| 575 | 575 | |
| 576 | - if( ! $formatted ) { |
|
| 577 | - $range = wp_strip_all_tags( $range ); |
|
| 576 | + if ( ! $formatted) { |
|
| 577 | + $range = wp_strip_all_tags($range); |
|
| 578 | 578 | } |
| 579 | 579 | |
| 580 | - return apply_filters( 'give_price_range', $range, $form_id, $low, $high ); |
|
| 580 | + return apply_filters('give_price_range', $range, $form_id, $low, $high); |
|
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | |
@@ -592,35 +592,35 @@ discard block |
||
| 592 | 592 | * |
| 593 | 593 | * @return int ID of the lowest price |
| 594 | 594 | */ |
| 595 | -function give_get_lowest_price_id( $form_id = 0 ) { |
|
| 595 | +function give_get_lowest_price_id($form_id = 0) { |
|
| 596 | 596 | |
| 597 | - if ( empty( $form_id ) ) { |
|
| 597 | + if (empty($form_id)) { |
|
| 598 | 598 | $form_id = get_the_ID(); |
| 599 | 599 | } |
| 600 | 600 | |
| 601 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
| 602 | - return give_get_form_price( $form_id ); |
|
| 601 | + if ( ! give_has_variable_prices($form_id)) { |
|
| 602 | + return give_get_form_price($form_id); |
|
| 603 | 603 | } |
| 604 | 604 | |
| 605 | - $prices = give_get_variable_prices( $form_id ); |
|
| 605 | + $prices = give_get_variable_prices($form_id); |
|
| 606 | 606 | |
| 607 | 607 | $min = $min_id = 0; |
| 608 | 608 | |
| 609 | - if ( ! empty( $prices ) ) { |
|
| 609 | + if ( ! empty($prices)) { |
|
| 610 | 610 | |
| 611 | - foreach ( $prices as $key => $price ) { |
|
| 611 | + foreach ($prices as $key => $price) { |
|
| 612 | 612 | |
| 613 | - if ( empty( $price['_give_amount'] ) ) { |
|
| 613 | + if (empty($price['_give_amount'])) { |
|
| 614 | 614 | continue; |
| 615 | 615 | } |
| 616 | 616 | |
| 617 | - if ( ! isset( $min ) ) { |
|
| 617 | + if ( ! isset($min)) { |
|
| 618 | 618 | $min = $price['_give_amount']; |
| 619 | 619 | } else { |
| 620 | - $min = min( $min, $price['_give_amount'] ); |
|
| 620 | + $min = min($min, $price['_give_amount']); |
|
| 621 | 621 | } |
| 622 | 622 | |
| 623 | - if ( $price['_give_amount'] == $min ) { |
|
| 623 | + if ($price['_give_amount'] == $min) { |
|
| 624 | 624 | $min_id = $price['_give_id']['level_id']; |
| 625 | 625 | } |
| 626 | 626 | } |
@@ -638,22 +638,22 @@ discard block |
||
| 638 | 638 | * |
| 639 | 639 | * @return float Amount of the lowest price |
| 640 | 640 | */ |
| 641 | -function give_get_lowest_price_option( $form_id = 0 ) { |
|
| 642 | - if ( empty( $form_id ) ) { |
|
| 641 | +function give_get_lowest_price_option($form_id = 0) { |
|
| 642 | + if (empty($form_id)) { |
|
| 643 | 643 | $form_id = get_the_ID(); |
| 644 | 644 | } |
| 645 | 645 | |
| 646 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
| 647 | - return give_get_form_price( $form_id ); |
|
| 646 | + if ( ! give_has_variable_prices($form_id)) { |
|
| 647 | + return give_get_form_price($form_id); |
|
| 648 | 648 | } |
| 649 | 649 | |
| 650 | - if ( ! ( $low = get_post_meta( $form_id, '_give_levels_minimum_amount', true ) ) ) { |
|
| 650 | + if ( ! ($low = get_post_meta($form_id, '_give_levels_minimum_amount', true))) { |
|
| 651 | 651 | // Backward compatibility. |
| 652 | - $prices = wp_list_pluck( give_get_variable_prices( $form_id ), '_give_amount' ); |
|
| 653 | - $low = ! empty( $prices ) ? min( $prices ) : 0; |
|
| 652 | + $prices = wp_list_pluck(give_get_variable_prices($form_id), '_give_amount'); |
|
| 653 | + $low = ! empty($prices) ? min($prices) : 0; |
|
| 654 | 654 | } |
| 655 | 655 | |
| 656 | - return give_maybe_sanitize_amount( $low ); |
|
| 656 | + return give_maybe_sanitize_amount($low); |
|
| 657 | 657 | } |
| 658 | 658 | |
| 659 | 659 | /** |
@@ -665,23 +665,23 @@ discard block |
||
| 665 | 665 | * |
| 666 | 666 | * @return float Amount of the highest price |
| 667 | 667 | */ |
| 668 | -function give_get_highest_price_option( $form_id = 0 ) { |
|
| 668 | +function give_get_highest_price_option($form_id = 0) { |
|
| 669 | 669 | |
| 670 | - if ( empty( $form_id ) ) { |
|
| 670 | + if (empty($form_id)) { |
|
| 671 | 671 | $form_id = get_the_ID(); |
| 672 | 672 | } |
| 673 | 673 | |
| 674 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
| 675 | - return give_get_form_price( $form_id ); |
|
| 674 | + if ( ! give_has_variable_prices($form_id)) { |
|
| 675 | + return give_get_form_price($form_id); |
|
| 676 | 676 | } |
| 677 | 677 | |
| 678 | - if ( ! ( $high = get_post_meta( $form_id, '_give_levels_maximum_amount', true ) ) ) { |
|
| 678 | + if ( ! ($high = get_post_meta($form_id, '_give_levels_maximum_amount', true))) { |
|
| 679 | 679 | // Backward compatibility. |
| 680 | - $prices = wp_list_pluck( give_get_variable_prices( $form_id ), '_give_amount' ); |
|
| 681 | - $high = ! empty( $prices ) ? max( $prices ) : 0; |
|
| 680 | + $prices = wp_list_pluck(give_get_variable_prices($form_id), '_give_amount'); |
|
| 681 | + $high = ! empty($prices) ? max($prices) : 0; |
|
| 682 | 682 | } |
| 683 | 683 | |
| 684 | - return give_maybe_sanitize_amount( $high ); |
|
| 684 | + return give_maybe_sanitize_amount($high); |
|
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | /** |
@@ -693,15 +693,15 @@ discard block |
||
| 693 | 693 | * |
| 694 | 694 | * @return mixed string|int Price of the form |
| 695 | 695 | */ |
| 696 | -function give_get_form_price( $form_id = 0 ) { |
|
| 696 | +function give_get_form_price($form_id = 0) { |
|
| 697 | 697 | |
| 698 | - if ( empty( $form_id ) ) { |
|
| 698 | + if (empty($form_id)) { |
|
| 699 | 699 | return false; |
| 700 | 700 | } |
| 701 | 701 | |
| 702 | - $form = new Give_Donate_Form( $form_id ); |
|
| 702 | + $form = new Give_Donate_Form($form_id); |
|
| 703 | 703 | |
| 704 | - return $form->__get( 'price' ); |
|
| 704 | + return $form->__get('price'); |
|
| 705 | 705 | } |
| 706 | 706 | |
| 707 | 707 | /** |
@@ -713,15 +713,15 @@ discard block |
||
| 713 | 713 | * |
| 714 | 714 | * @return mixed string|int Minimum price of the form |
| 715 | 715 | */ |
| 716 | -function give_get_form_minimum_price( $form_id = 0 ) { |
|
| 716 | +function give_get_form_minimum_price($form_id = 0) { |
|
| 717 | 717 | |
| 718 | - if ( empty( $form_id ) ) { |
|
| 718 | + if (empty($form_id)) { |
|
| 719 | 719 | return false; |
| 720 | 720 | } |
| 721 | 721 | |
| 722 | - $form = new Give_Donate_Form( $form_id ); |
|
| 722 | + $form = new Give_Donate_Form($form_id); |
|
| 723 | 723 | |
| 724 | - return $form->__get( 'minimum_price' ); |
|
| 724 | + return $form->__get('minimum_price'); |
|
| 725 | 725 | |
| 726 | 726 | } |
| 727 | 727 | |
@@ -736,48 +736,48 @@ discard block |
||
| 736 | 736 | * |
| 737 | 737 | * @return int $formatted_price |
| 738 | 738 | */ |
| 739 | -function give_price( $form_id = 0, $echo = true, $price_id = false ) { |
|
| 739 | +function give_price($form_id = 0, $echo = true, $price_id = false) { |
|
| 740 | 740 | $price = 0; |
| 741 | 741 | |
| 742 | - if ( empty( $form_id ) ) { |
|
| 742 | + if (empty($form_id)) { |
|
| 743 | 743 | $form_id = get_the_ID(); |
| 744 | 744 | } |
| 745 | 745 | |
| 746 | - if ( give_has_variable_prices( $form_id ) ) { |
|
| 746 | + if (give_has_variable_prices($form_id)) { |
|
| 747 | 747 | |
| 748 | - $prices = give_get_variable_prices( $form_id ); |
|
| 748 | + $prices = give_get_variable_prices($form_id); |
|
| 749 | 749 | |
| 750 | - if ( false !== $price_id ) { |
|
| 750 | + if (false !== $price_id) { |
|
| 751 | 751 | |
| 752 | 752 | // loop through multi-prices to see which is default |
| 753 | - foreach ( $prices as $price ) { |
|
| 753 | + foreach ($prices as $price) { |
|
| 754 | 754 | // this is the default price |
| 755 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
| 755 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
| 756 | 756 | $price = (float) $price['_give_amount']; |
| 757 | 757 | }; |
| 758 | 758 | } |
| 759 | 759 | } else { |
| 760 | 760 | |
| 761 | - $price = give_get_lowest_price_option( $form_id ); |
|
| 761 | + $price = give_get_lowest_price_option($form_id); |
|
| 762 | 762 | } |
| 763 | 763 | } else { |
| 764 | 764 | |
| 765 | - $price = give_get_form_price( $form_id ); |
|
| 765 | + $price = give_get_form_price($form_id); |
|
| 766 | 766 | } |
| 767 | 767 | |
| 768 | - $price = apply_filters( 'give_form_price', give_maybe_sanitize_amount( $price ), $form_id ); |
|
| 769 | - $formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>'; |
|
| 770 | - $formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price ); |
|
| 768 | + $price = apply_filters('give_form_price', give_maybe_sanitize_amount($price), $form_id); |
|
| 769 | + $formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>'; |
|
| 770 | + $formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price); |
|
| 771 | 771 | |
| 772 | - if ( $echo ) { |
|
| 772 | + if ($echo) { |
|
| 773 | 773 | echo $formatted_price; |
| 774 | 774 | } else { |
| 775 | 775 | return $formatted_price; |
| 776 | 776 | } |
| 777 | 777 | } |
| 778 | 778 | |
| 779 | -add_filter( 'give_form_price', 'give_format_amount', 10 ); |
|
| 780 | -add_filter( 'give_form_price', 'give_currency_filter', 20 ); |
|
| 779 | +add_filter('give_form_price', 'give_format_amount', 10); |
|
| 780 | +add_filter('give_form_price', 'give_currency_filter', 20); |
|
| 781 | 781 | |
| 782 | 782 | |
| 783 | 783 | /** |
@@ -790,19 +790,19 @@ discard block |
||
| 790 | 790 | * |
| 791 | 791 | * @return float $amount Amount of the price option |
| 792 | 792 | */ |
| 793 | -function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) { |
|
| 794 | - $prices = give_get_variable_prices( $form_id ); |
|
| 793 | +function give_get_price_option_amount($form_id = 0, $price_id = 0) { |
|
| 794 | + $prices = give_get_variable_prices($form_id); |
|
| 795 | 795 | |
| 796 | 796 | $amount = 0.00; |
| 797 | 797 | |
| 798 | - foreach ( $prices as $price ) { |
|
| 799 | - if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) { |
|
| 800 | - $amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00; |
|
| 798 | + foreach ($prices as $price) { |
|
| 799 | + if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] == $price_id) { |
|
| 800 | + $amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00; |
|
| 801 | 801 | break; |
| 802 | 802 | }; |
| 803 | 803 | } |
| 804 | 804 | |
| 805 | - return apply_filters( 'give_get_price_option_amount', give_maybe_sanitize_amount( $amount ), $form_id, $price_id ); |
|
| 805 | + return apply_filters('give_get_price_option_amount', give_maybe_sanitize_amount($amount), $form_id, $price_id); |
|
| 806 | 806 | } |
| 807 | 807 | |
| 808 | 808 | /** |
@@ -814,13 +814,13 @@ discard block |
||
| 814 | 814 | * |
| 815 | 815 | * @return mixed string|int Goal of the form |
| 816 | 816 | */ |
| 817 | -function give_get_form_goal( $form_id = 0 ) { |
|
| 817 | +function give_get_form_goal($form_id = 0) { |
|
| 818 | 818 | |
| 819 | - if ( empty( $form_id ) ) { |
|
| 819 | + if (empty($form_id)) { |
|
| 820 | 820 | return false; |
| 821 | 821 | } |
| 822 | 822 | |
| 823 | - $form = new Give_Donate_Form( $form_id ); |
|
| 823 | + $form = new Give_Donate_Form($form_id); |
|
| 824 | 824 | |
| 825 | 825 | return $form->goal; |
| 826 | 826 | |
@@ -836,27 +836,27 @@ discard block |
||
| 836 | 836 | * |
| 837 | 837 | * @return string $formatted_goal |
| 838 | 838 | */ |
| 839 | -function give_goal( $form_id = 0, $echo = true ) { |
|
| 839 | +function give_goal($form_id = 0, $echo = true) { |
|
| 840 | 840 | |
| 841 | - if ( empty( $form_id ) ) { |
|
| 841 | + if (empty($form_id)) { |
|
| 842 | 842 | $form_id = get_the_ID(); |
| 843 | 843 | } |
| 844 | 844 | |
| 845 | - $goal = give_get_form_goal( $form_id ); |
|
| 845 | + $goal = give_get_form_goal($form_id); |
|
| 846 | 846 | |
| 847 | - $goal = apply_filters( 'give_form_goal', give_maybe_sanitize_amount( $goal ), $form_id ); |
|
| 848 | - $formatted_goal = '<span class="give_price" id="give_price_' . $form_id . '">' . $goal . '</span>'; |
|
| 849 | - $formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal ); |
|
| 847 | + $goal = apply_filters('give_form_goal', give_maybe_sanitize_amount($goal), $form_id); |
|
| 848 | + $formatted_goal = '<span class="give_price" id="give_price_'.$form_id.'">'.$goal.'</span>'; |
|
| 849 | + $formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal); |
|
| 850 | 850 | |
| 851 | - if ( $echo ) { |
|
| 851 | + if ($echo) { |
|
| 852 | 852 | echo $formatted_goal; |
| 853 | 853 | } else { |
| 854 | 854 | return $formatted_goal; |
| 855 | 855 | } |
| 856 | 856 | } |
| 857 | 857 | |
| 858 | -add_filter( 'give_form_goal', 'give_format_amount', 10 ); |
|
| 859 | -add_filter( 'give_form_goal', 'give_currency_filter', 20 ); |
|
| 858 | +add_filter('give_form_goal', 'give_format_amount', 10); |
|
| 859 | +add_filter('give_form_goal', 'give_currency_filter', 20); |
|
| 860 | 860 | |
| 861 | 861 | |
| 862 | 862 | /** |
@@ -868,15 +868,15 @@ discard block |
||
| 868 | 868 | * |
| 869 | 869 | * @return bool $ret Whether or not the logged_in_only setting is set |
| 870 | 870 | */ |
| 871 | -function give_logged_in_only( $form_id ) { |
|
| 871 | +function give_logged_in_only($form_id) { |
|
| 872 | 872 | // If _give_logged_in_only is set to enable then guest can donate from that specific form. |
| 873 | 873 | // Otherwise it is member only donation form. |
| 874 | - $val = give_get_meta( $form_id, '_give_logged_in_only', true ); |
|
| 875 | - $val = ! empty( $val ) ? $val : 'enabled'; |
|
| 874 | + $val = give_get_meta($form_id, '_give_logged_in_only', true); |
|
| 875 | + $val = ! empty($val) ? $val : 'enabled'; |
|
| 876 | 876 | |
| 877 | - $ret = ! give_is_setting_enabled( $val ); |
|
| 877 | + $ret = ! give_is_setting_enabled($val); |
|
| 878 | 878 | |
| 879 | - return (bool) apply_filters( 'give_logged_in_only', $ret, $form_id ); |
|
| 879 | + return (bool) apply_filters('give_logged_in_only', $ret, $form_id); |
|
| 880 | 880 | } |
| 881 | 881 | |
| 882 | 882 | |
@@ -889,11 +889,11 @@ discard block |
||
| 889 | 889 | * |
| 890 | 890 | * @return string |
| 891 | 891 | */ |
| 892 | -function give_show_login_register_option( $form_id ) { |
|
| 892 | +function give_show_login_register_option($form_id) { |
|
| 893 | 893 | |
| 894 | - $show_register_form = give_get_meta( $form_id, '_give_show_register_form', true ); |
|
| 894 | + $show_register_form = give_get_meta($form_id, '_give_show_register_form', true); |
|
| 895 | 895 | |
| 896 | - return apply_filters( 'give_show_register_form', $show_register_form, $form_id ); |
|
| 896 | + return apply_filters('give_show_register_form', $show_register_form, $form_id); |
|
| 897 | 897 | |
| 898 | 898 | } |
| 899 | 899 | |
@@ -909,12 +909,12 @@ discard block |
||
| 909 | 909 | * |
| 910 | 910 | * @return array |
| 911 | 911 | */ |
| 912 | -function _give_get_prefill_form_field_values( $form_id ) { |
|
| 912 | +function _give_get_prefill_form_field_values($form_id) { |
|
| 913 | 913 | $logged_in_donor_info = array(); |
| 914 | 914 | |
| 915 | - if ( is_user_logged_in() ) : |
|
| 916 | - $donor_data = get_userdata( get_current_user_id() ); |
|
| 917 | - $donor_address = get_user_meta( get_current_user_id(), '_give_user_address', true ); |
|
| 915 | + if (is_user_logged_in()) : |
|
| 916 | + $donor_data = get_userdata(get_current_user_id()); |
|
| 917 | + $donor_address = get_user_meta(get_current_user_id(), '_give_user_address', true); |
|
| 918 | 918 | |
| 919 | 919 | $logged_in_donor_info = array( |
| 920 | 920 | // First name. |
@@ -927,42 +927,42 @@ discard block |
||
| 927 | 927 | 'give_email' => $donor_data->user_email, |
| 928 | 928 | |
| 929 | 929 | // Street address 1. |
| 930 | - 'card_address' => ( ! empty( $donor_address['line1'] ) ? $donor_address['line1'] : '' ), |
|
| 930 | + 'card_address' => ( ! empty($donor_address['line1']) ? $donor_address['line1'] : ''), |
|
| 931 | 931 | |
| 932 | 932 | // Street address 2. |
| 933 | - 'card_address_2' => ( ! empty( $donor_address['line2'] ) ? $donor_address['line2'] : '' ), |
|
| 933 | + 'card_address_2' => ( ! empty($donor_address['line2']) ? $donor_address['line2'] : ''), |
|
| 934 | 934 | |
| 935 | 935 | // Country. |
| 936 | - 'billing_country' => ( ! empty( $donor_address['country'] ) ? $donor_address['country'] : '' ), |
|
| 936 | + 'billing_country' => ( ! empty($donor_address['country']) ? $donor_address['country'] : ''), |
|
| 937 | 937 | |
| 938 | 938 | // State. |
| 939 | - 'card_state' => ( ! empty( $donor_address['state'] ) ? $donor_address['state'] : '' ), |
|
| 939 | + 'card_state' => ( ! empty($donor_address['state']) ? $donor_address['state'] : ''), |
|
| 940 | 940 | |
| 941 | 941 | // City. |
| 942 | - 'card_city' => ( ! empty( $donor_address['city'] ) ? $donor_address['city'] : '' ), |
|
| 942 | + 'card_city' => ( ! empty($donor_address['city']) ? $donor_address['city'] : ''), |
|
| 943 | 943 | |
| 944 | 944 | // Zipcode |
| 945 | - 'card_zip' => ( ! empty( $donor_address['zip'] ) ? $donor_address['zip'] : '' ), |
|
| 945 | + 'card_zip' => ( ! empty($donor_address['zip']) ? $donor_address['zip'] : ''), |
|
| 946 | 946 | ); |
| 947 | 947 | endif; |
| 948 | 948 | |
| 949 | 949 | // Bailout: Auto fill form field values only form form which donor is donating. |
| 950 | 950 | if ( |
| 951 | - empty( $_GET['form-id'] ) |
|
| 951 | + empty($_GET['form-id']) |
|
| 952 | 952 | || ! $form_id |
| 953 | - || ( $form_id !== absint( $_GET['form-id'] ) ) |
|
| 953 | + || ($form_id !== absint($_GET['form-id'])) |
|
| 954 | 954 | ) { |
| 955 | 955 | return $logged_in_donor_info; |
| 956 | 956 | } |
| 957 | 957 | |
| 958 | 958 | // Get purchase data. |
| 959 | - $give_purchase_data = Give()->session->get( 'give_purchase' ); |
|
| 959 | + $give_purchase_data = Give()->session->get('give_purchase'); |
|
| 960 | 960 | |
| 961 | 961 | // Get donor info from form data. |
| 962 | - $give_donor_info_in_session = empty( $give_purchase_data['post_data'] ) |
|
| 962 | + $give_donor_info_in_session = empty($give_purchase_data['post_data']) |
|
| 963 | 963 | ? array() |
| 964 | 964 | : $give_purchase_data['post_data']; |
| 965 | 965 | |
| 966 | 966 | // Output. |
| 967 | - return wp_parse_args( $give_donor_info_in_session, $logged_in_donor_info ); |
|
| 967 | + return wp_parse_args($give_donor_info_in_session, $logged_in_donor_info); |
|
| 968 | 968 | } |
@@ -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 | |
@@ -25,125 +25,125 @@ discard block |
||
| 25 | 25 | * |
| 26 | 26 | * @uses give_pdf |
| 27 | 27 | */ |
| 28 | -function give_generate_pdf( $data ) { |
|
| 28 | +function give_generate_pdf($data) { |
|
| 29 | 29 | |
| 30 | - if ( ! current_user_can( 'view_give_reports' ) ) { |
|
| 31 | - wp_die( __( 'You do not have permission to generate PDF sales reports.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 30 | + if ( ! current_user_can('view_give_reports')) { |
|
| 31 | + wp_die(__('You do not have permission to generate PDF sales reports.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'give_generate_pdf' ) ) { |
|
| 35 | - wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 34 | + if ( ! wp_verify_nonce($_GET['_wpnonce'], 'give_generate_pdf')) { |
|
| 35 | + wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/give_pdf.php'; |
|
| 38 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/give_pdf.php'; |
|
| 39 | 39 | |
| 40 | 40 | $daterange = utf8_decode( |
| 41 | 41 | sprintf( |
| 42 | 42 | /* translators: 1: start date 2: end date */ |
| 43 | - __( '%1$s to %2$s', 'give' ), |
|
| 44 | - date_i18n( give_date_format(), mktime( 0, 0, 0, 1, 1, date( 'Y' ) ) ), |
|
| 45 | - date_i18n( give_date_format() ) |
|
| 43 | + __('%1$s to %2$s', 'give'), |
|
| 44 | + date_i18n(give_date_format(), mktime(0, 0, 0, 1, 1, date('Y'))), |
|
| 45 | + date_i18n(give_date_format()) |
|
| 46 | 46 | ) |
| 47 | 47 | ); |
| 48 | 48 | |
| 49 | - $categories_enabled = give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ); |
|
| 50 | - $tags_enabled = give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ); |
|
| 49 | + $categories_enabled = give_is_setting_enabled(give_get_option('categories', 'disabled')); |
|
| 50 | + $tags_enabled = give_is_setting_enabled(give_get_option('tags', 'disabled')); |
|
| 51 | 51 | |
| 52 | - $pdf = new Give_PDF( 'L', 'mm', 'A', true, 'UTF-8', false ); |
|
| 53 | - $default_font = apply_filters( 'give_pdf_default_font', 'Helvetica' ); |
|
| 52 | + $pdf = new Give_PDF('L', 'mm', 'A', true, 'UTF-8', false); |
|
| 53 | + $default_font = apply_filters('give_pdf_default_font', 'Helvetica'); |
|
| 54 | 54 | $custom_font = 'dejavusans'; |
| 55 | 55 | $font_style = ''; |
| 56 | 56 | |
| 57 | - if ( in_array( give_get_currency(), array( 'RIAL', 'RUB' ) ) ) { |
|
| 58 | - TCPDF_FONTS::addTTFfont( GIVE_PLUGIN_DIR . '/includes/libraries/tcpdf/fonts/CODE2000.TTF', '' ); |
|
| 57 | + if (in_array(give_get_currency(), array('RIAL', 'RUB'))) { |
|
| 58 | + TCPDF_FONTS::addTTFfont(GIVE_PLUGIN_DIR.'/includes/libraries/tcpdf/fonts/CODE2000.TTF', ''); |
|
| 59 | 59 | $custom_font = 'CODE2000'; |
| 60 | 60 | $font_style = 'B'; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - $pdf->AddPage( 'L', 'A4' ); |
|
| 64 | - $pdf->setImageScale( 1.5 ); |
|
| 65 | - $pdf->SetTitle( utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ) ); |
|
| 66 | - $pdf->SetAuthor( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) ); |
|
| 67 | - $pdf->SetCreator( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) ); |
|
| 63 | + $pdf->AddPage('L', 'A4'); |
|
| 64 | + $pdf->setImageScale(1.5); |
|
| 65 | + $pdf->SetTitle(utf8_decode(__('Donation report for the current year for all forms', 'give'))); |
|
| 66 | + $pdf->SetAuthor(utf8_decode(__('Give - Democratizing Generosity', 'give'))); |
|
| 67 | + $pdf->SetCreator(utf8_decode(__('Give - Democratizing Generosity', 'give'))); |
|
| 68 | 68 | |
| 69 | - $pdf->Image( apply_filters( 'give_pdf_export_logo', GIVE_PLUGIN_URL . 'assets/images/give-logo-small.png' ), 247, 8 ); |
|
| 69 | + $pdf->Image(apply_filters('give_pdf_export_logo', GIVE_PLUGIN_URL.'assets/images/give-logo-small.png'), 247, 8); |
|
| 70 | 70 | |
| 71 | - $pdf->SetMargins( 8, 8, 8 ); |
|
| 72 | - $pdf->SetX( 8 ); |
|
| 71 | + $pdf->SetMargins(8, 8, 8); |
|
| 72 | + $pdf->SetX(8); |
|
| 73 | 73 | |
| 74 | - $pdf->SetFont( $default_font, '', 16 ); |
|
| 75 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
| 76 | - $pdf->Cell( 0, 3, utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ), 0, 2, 'L', false ); |
|
| 74 | + $pdf->SetFont($default_font, '', 16); |
|
| 75 | + $pdf->SetTextColor(50, 50, 50); |
|
| 76 | + $pdf->Cell(0, 3, utf8_decode(__('Donation report for the current year for all forms', 'give')), 0, 2, 'L', false); |
|
| 77 | 77 | |
| 78 | - $pdf->SetFont( $default_font, '', 13 ); |
|
| 79 | - $pdf->SetTextColor( 150, 150, 150 ); |
|
| 80 | - $pdf->Ln( 1 ); |
|
| 81 | - $pdf->Cell( 0, 6, utf8_decode( __( 'Date Range: ', 'give' ) ) . $daterange, 0, 2, 'L', false ); |
|
| 78 | + $pdf->SetFont($default_font, '', 13); |
|
| 79 | + $pdf->SetTextColor(150, 150, 150); |
|
| 80 | + $pdf->Ln(1); |
|
| 81 | + $pdf->Cell(0, 6, utf8_decode(__('Date Range: ', 'give')).$daterange, 0, 2, 'L', false); |
|
| 82 | 82 | $pdf->Ln(); |
| 83 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
| 84 | - $pdf->SetFont( $default_font, '', 14 ); |
|
| 85 | - $pdf->Cell( 0, 10, utf8_decode( __( 'Table View', 'give' ) ), 0, 2, 'L', false ); |
|
| 86 | - $pdf->SetFont( $default_font, '', 12 ); |
|
| 83 | + $pdf->SetTextColor(50, 50, 50); |
|
| 84 | + $pdf->SetFont($default_font, '', 14); |
|
| 85 | + $pdf->Cell(0, 10, utf8_decode(__('Table View', 'give')), 0, 2, 'L', false); |
|
| 86 | + $pdf->SetFont($default_font, '', 12); |
|
| 87 | 87 | |
| 88 | - $pdf->SetFillColor( 238, 238, 238 ); |
|
| 89 | - $pdf->SetTextColor( 0, 0, 0, 100 ); // Set Black color. |
|
| 90 | - $pdf->Cell( 50, 6, utf8_decode( __( 'Form Name', 'give' ) ), 1, 0, 'L', true ); |
|
| 91 | - $pdf->Cell( 50, 6, utf8_decode( __( 'Price', 'give' ) ), 1, 0, 'L', true ); |
|
| 88 | + $pdf->SetFillColor(238, 238, 238); |
|
| 89 | + $pdf->SetTextColor(0, 0, 0, 100); // Set Black color. |
|
| 90 | + $pdf->Cell(50, 6, utf8_decode(__('Form Name', 'give')), 1, 0, 'L', true); |
|
| 91 | + $pdf->Cell(50, 6, utf8_decode(__('Price', 'give')), 1, 0, 'L', true); |
|
| 92 | 92 | |
| 93 | 93 | // Display Categories Heading only, if user has opted for it. |
| 94 | - if ( $categories_enabled ) { |
|
| 95 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Categories', 'give' ) ), 1, 0, 'L', true ); |
|
| 94 | + if ($categories_enabled) { |
|
| 95 | + $pdf->Cell(45, 6, utf8_decode(__('Categories', 'give')), 1, 0, 'L', true); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | // Display Tags Heading only, if user has opted for it. |
| 99 | - if ( $tags_enabled ) { |
|
| 100 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Tags', 'give' ) ), 1, 0, 'L', true ); |
|
| 99 | + if ($tags_enabled) { |
|
| 100 | + $pdf->Cell(45, 6, utf8_decode(__('Tags', 'give')), 1, 0, 'L', true); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Number of Donations', 'give' ) ), 1, 0, 'L', true ); |
|
| 104 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Income to Date', 'give' ) ), 1, 1, 'L', true ); |
|
| 103 | + $pdf->Cell(45, 6, utf8_decode(__('Number of Donations', 'give')), 1, 0, 'L', true); |
|
| 104 | + $pdf->Cell(45, 6, utf8_decode(__('Income to Date', 'give')), 1, 1, 'L', true); |
|
| 105 | 105 | |
| 106 | 106 | // Set Custom Font to support various currencies. |
| 107 | - $pdf->SetFont( apply_filters( 'give_pdf_custom_font', $custom_font ), $font_style, 12 ); |
|
| 107 | + $pdf->SetFont(apply_filters('give_pdf_custom_font', $custom_font), $font_style, 12); |
|
| 108 | 108 | |
| 109 | - $year = date( 'Y' ); |
|
| 110 | - $give_forms = get_posts( array( |
|
| 109 | + $year = date('Y'); |
|
| 110 | + $give_forms = get_posts(array( |
|
| 111 | 111 | 'post_type' => 'give_forms', |
| 112 | 112 | 'year' => $year, |
| 113 | - 'posts_per_page' => - 1, |
|
| 113 | + 'posts_per_page' => -1, |
|
| 114 | 114 | 'supply_filter' => false, |
| 115 | - ) ); |
|
| 115 | + )); |
|
| 116 | 116 | |
| 117 | - if ( $give_forms ) { |
|
| 118 | - $pdf->SetWidths( array( 50, 50, 45, 45, 45, 45 ) ); |
|
| 117 | + if ($give_forms) { |
|
| 118 | + $pdf->SetWidths(array(50, 50, 45, 45, 45, 45)); |
|
| 119 | 119 | |
| 120 | - foreach ( $give_forms as $form ): |
|
| 121 | - $pdf->SetFillColor( 255, 255, 255 ); |
|
| 120 | + foreach ($give_forms as $form): |
|
| 121 | + $pdf->SetFillColor(255, 255, 255); |
|
| 122 | 122 | |
| 123 | 123 | $title = $form->post_title; |
| 124 | 124 | |
| 125 | - if ( give_has_variable_prices( $form->ID ) ) { |
|
| 126 | - $price = html_entity_decode( give_price_range( $form->ID, false ) ); |
|
| 125 | + if (give_has_variable_prices($form->ID)) { |
|
| 126 | + $price = html_entity_decode(give_price_range($form->ID, false)); |
|
| 127 | 127 | } else { |
| 128 | - $price = give_currency_filter( give_get_form_price( $form->ID ), '', true ); |
|
| 128 | + $price = give_currency_filter(give_get_form_price($form->ID), '', true); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | // Display Categories Data only, if user has opted for it. |
| 132 | 132 | $categories = array(); |
| 133 | - if ( $categories_enabled ) { |
|
| 134 | - $categories = get_the_term_list( $form->ID, 'give_forms_category', '', ', ', '' ); |
|
| 135 | - $categories = ! is_wp_error( $categories ) ? strip_tags( $categories ) : ''; |
|
| 133 | + if ($categories_enabled) { |
|
| 134 | + $categories = get_the_term_list($form->ID, 'give_forms_category', '', ', ', ''); |
|
| 135 | + $categories = ! is_wp_error($categories) ? strip_tags($categories) : ''; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | // Display Tags Data only, if user has opted for it. |
| 139 | 139 | $tags = array(); |
| 140 | - if ( $tags_enabled ) { |
|
| 141 | - $tags = get_the_term_list( $form->ID, 'give_forms_tag', '', ', ', '' ); |
|
| 142 | - $tags = ! is_wp_error( $tags ) ? strip_tags( $tags ) : ''; |
|
| 140 | + if ($tags_enabled) { |
|
| 141 | + $tags = get_the_term_list($form->ID, 'give_forms_tag', '', ', ', ''); |
|
| 142 | + $tags = ! is_wp_error($tags) ? strip_tags($tags) : ''; |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - $sales = give_get_form_sales_stats( $form->ID ); |
|
| 146 | - $earnings = give_currency_filter( give_format_amount( give_get_form_earnings_stats( $form->ID ), array( 'sanitize' => false, ) ), '', true ); |
|
| 145 | + $sales = give_get_form_sales_stats($form->ID); |
|
| 146 | + $earnings = give_currency_filter(give_format_amount(give_get_form_earnings_stats($form->ID), array('sanitize' => false,)), '', true); |
|
| 147 | 147 | |
| 148 | 148 | // This will help filter data before appending it to PDF Receipt. |
| 149 | 149 | $prepare_pdf_data = array(); |
@@ -151,53 +151,53 @@ discard block |
||
| 151 | 151 | $prepare_pdf_data[] = $price; |
| 152 | 152 | |
| 153 | 153 | // Append Categories Data only, if user has opted for it. |
| 154 | - if ( $categories_enabled ) { |
|
| 154 | + if ($categories_enabled) { |
|
| 155 | 155 | $prepare_pdf_data[] = $categories; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | // Append Tags Data only, if user has opted for it. |
| 159 | - if ( $tags_enabled ) { |
|
| 159 | + if ($tags_enabled) { |
|
| 160 | 160 | $prepare_pdf_data[] = $tags; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | $prepare_pdf_data[] = $sales; |
| 164 | 164 | $prepare_pdf_data[] = $earnings; |
| 165 | 165 | |
| 166 | - $pdf->Row( $prepare_pdf_data ); |
|
| 166 | + $pdf->Row($prepare_pdf_data); |
|
| 167 | 167 | |
| 168 | 168 | endforeach; |
| 169 | 169 | } else { |
| 170 | 170 | |
| 171 | 171 | // Fix: Minor Styling Alignment Issue for PDF. |
| 172 | - if ( $categories_enabled && $tags_enabled ) { |
|
| 172 | + if ($categories_enabled && $tags_enabled) { |
|
| 173 | 173 | $no_found_width = 280; |
| 174 | - } elseif ( $categories_enabled || $tags_enabled ) { |
|
| 174 | + } elseif ($categories_enabled || $tags_enabled) { |
|
| 175 | 175 | $no_found_width = 235; |
| 176 | 176 | } else { |
| 177 | 177 | $no_found_width = 190; |
| 178 | 178 | } |
| 179 | - $title = utf8_decode( __( 'No forms found.', 'give' ) ); |
|
| 180 | - $pdf->MultiCell( $no_found_width, 5, $title, 1, 'C', false, 1, '', '', true, 0, false, true, 0, 'T', false ); |
|
| 179 | + $title = utf8_decode(__('No forms found.', 'give')); |
|
| 180 | + $pdf->MultiCell($no_found_width, 5, $title, 1, 'C', false, 1, '', '', true, 0, false, true, 0, 'T', false); |
|
| 181 | 181 | }// End if(). |
| 182 | 182 | $pdf->Ln(); |
| 183 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
| 184 | - $pdf->SetFont( $default_font, '', 14 ); |
|
| 183 | + $pdf->SetTextColor(50, 50, 50); |
|
| 184 | + $pdf->SetFont($default_font, '', 14); |
|
| 185 | 185 | |
| 186 | 186 | // Output Graph on a new page. |
| 187 | - $pdf->AddPage( 'L', 'A4' ); |
|
| 188 | - $pdf->Cell( 0, 10, utf8_decode( __( 'Graph View', 'give' ) ), 0, 2, 'L', false ); |
|
| 189 | - $pdf->SetFont( $default_font, '', 12 ); |
|
| 187 | + $pdf->AddPage('L', 'A4'); |
|
| 188 | + $pdf->Cell(0, 10, utf8_decode(__('Graph View', 'give')), 0, 2, 'L', false); |
|
| 189 | + $pdf->SetFont($default_font, '', 12); |
|
| 190 | 190 | |
| 191 | - $image = html_entity_decode( urldecode( give_draw_chart_image() ) ); |
|
| 192 | - $image = str_replace( ' ', '%20', $image ); |
|
| 191 | + $image = html_entity_decode(urldecode(give_draw_chart_image())); |
|
| 192 | + $image = str_replace(' ', '%20', $image); |
|
| 193 | 193 | |
| 194 | - $pdf->SetX( 25 ); |
|
| 195 | - $pdf->Image( $image . '&file=.png' ); |
|
| 196 | - $pdf->Ln( 7 ); |
|
| 197 | - $pdf->Output( apply_filters( 'give_sales_earnings_pdf_export_filename', 'give-report-' . date_i18n( 'Y-m-d' ) ) . '.pdf', 'D' ); |
|
| 194 | + $pdf->SetX(25); |
|
| 195 | + $pdf->Image($image.'&file=.png'); |
|
| 196 | + $pdf->Ln(7); |
|
| 197 | + $pdf->Output(apply_filters('give_sales_earnings_pdf_export_filename', 'give-report-'.date_i18n('Y-m-d')).'.pdf', 'D'); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | -add_action( 'give_generate_pdf', 'give_generate_pdf' ); |
|
| 200 | +add_action('give_generate_pdf', 'give_generate_pdf'); |
|
| 201 | 201 | |
| 202 | 202 | /** |
| 203 | 203 | * Draws Chart for PDF Report. |
@@ -214,38 +214,38 @@ discard block |
||
| 214 | 214 | * @return string $chart->getUrl() URL for the Google Chart |
| 215 | 215 | */ |
| 216 | 216 | function give_draw_chart_image() { |
| 217 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/GoogleChart.php'; |
|
| 218 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php'; |
|
| 219 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php'; |
|
| 217 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/GoogleChart.php'; |
|
| 218 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php'; |
|
| 219 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php'; |
|
| 220 | 220 | |
| 221 | - $chart = new GoogleChart( 'lc', 900, 330 ); |
|
| 221 | + $chart = new GoogleChart('lc', 900, 330); |
|
| 222 | 222 | |
| 223 | 223 | $i = 1; |
| 224 | 224 | $earnings = ""; |
| 225 | 225 | $sales = ""; |
| 226 | 226 | |
| 227 | - while ( $i <= 12 ) : |
|
| 228 | - $earnings .= give_get_earnings_by_date( null, $i, date( 'Y' ) ) . ","; |
|
| 229 | - $sales .= give_get_sales_by_date( null, $i, date( 'Y' ) ) . ","; |
|
| 230 | - $i ++; |
|
| 227 | + while ($i <= 12) : |
|
| 228 | + $earnings .= give_get_earnings_by_date(null, $i, date('Y')).","; |
|
| 229 | + $sales .= give_get_sales_by_date(null, $i, date('Y')).","; |
|
| 230 | + $i++; |
|
| 231 | 231 | endwhile; |
| 232 | 232 | |
| 233 | - $earnings_array = explode( ",", $earnings ); |
|
| 234 | - $sales_array = explode( ",", $sales ); |
|
| 233 | + $earnings_array = explode(",", $earnings); |
|
| 234 | + $sales_array = explode(",", $sales); |
|
| 235 | 235 | |
| 236 | 236 | $i = 0; |
| 237 | - while ( $i <= 11 ) { |
|
| 238 | - if ( empty( $sales_array[ $i ] ) ) { |
|
| 239 | - $sales_array[ $i ] = 0; |
|
| 237 | + while ($i <= 11) { |
|
| 238 | + if (empty($sales_array[$i])) { |
|
| 239 | + $sales_array[$i] = 0; |
|
| 240 | 240 | } |
| 241 | - $i ++; |
|
| 241 | + $i++; |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | $min_earnings = 0; |
| 245 | - $max_earnings = max( $earnings_array ); |
|
| 246 | - $earnings_scale = round( $max_earnings, - 1 ); |
|
| 245 | + $max_earnings = max($earnings_array); |
|
| 246 | + $earnings_scale = round($max_earnings, - 1); |
|
| 247 | 247 | |
| 248 | - $data = new GoogleChartData( array( |
|
| 248 | + $data = new GoogleChartData(array( |
|
| 249 | 249 | $earnings_array[0], |
| 250 | 250 | $earnings_array[1], |
| 251 | 251 | $earnings_array[2], |
@@ -258,25 +258,25 @@ discard block |
||
| 258 | 258 | $earnings_array[9], |
| 259 | 259 | $earnings_array[10], |
| 260 | 260 | $earnings_array[11], |
| 261 | - ) ); |
|
| 261 | + )); |
|
| 262 | 262 | |
| 263 | - $data->setLegend( __( 'Income', 'give' ) ); |
|
| 264 | - $data->setColor( '1b58a3' ); |
|
| 265 | - $chart->addData( $data ); |
|
| 263 | + $data->setLegend(__('Income', 'give')); |
|
| 264 | + $data->setColor('1b58a3'); |
|
| 265 | + $chart->addData($data); |
|
| 266 | 266 | |
| 267 | - $shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE ); |
|
| 268 | - $shape_marker->setColor( '000000' ); |
|
| 269 | - $shape_marker->setSize( 7 ); |
|
| 270 | - $shape_marker->setBorder( 2 ); |
|
| 271 | - $shape_marker->setData( $data ); |
|
| 272 | - $chart->addMarker( $shape_marker ); |
|
| 267 | + $shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); |
|
| 268 | + $shape_marker->setColor('000000'); |
|
| 269 | + $shape_marker->setSize(7); |
|
| 270 | + $shape_marker->setBorder(2); |
|
| 271 | + $shape_marker->setData($data); |
|
| 272 | + $chart->addMarker($shape_marker); |
|
| 273 | 273 | |
| 274 | - $value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE ); |
|
| 275 | - $value_marker->setColor( '000000' ); |
|
| 276 | - $value_marker->setData( $data ); |
|
| 277 | - $chart->addMarker( $value_marker ); |
|
| 274 | + $value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE); |
|
| 275 | + $value_marker->setColor('000000'); |
|
| 276 | + $value_marker->setData($data); |
|
| 277 | + $chart->addMarker($value_marker); |
|
| 278 | 278 | |
| 279 | - $data = new GoogleChartData( array( |
|
| 279 | + $data = new GoogleChartData(array( |
|
| 280 | 280 | $sales_array[0], |
| 281 | 281 | $sales_array[1], |
| 282 | 282 | $sales_array[2], |
@@ -289,46 +289,46 @@ discard block |
||
| 289 | 289 | $sales_array[9], |
| 290 | 290 | $sales_array[10], |
| 291 | 291 | $sales_array[11], |
| 292 | - ) ); |
|
| 293 | - $data->setLegend( __( 'Donations', 'give' ) ); |
|
| 294 | - $data->setColor( 'ff6c1c' ); |
|
| 295 | - $chart->addData( $data ); |
|
| 296 | - |
|
| 297 | - $chart->setTitle( __( 'Donations by Month for all Give Forms', 'give' ), '336699', 18 ); |
|
| 298 | - |
|
| 299 | - $chart->setScale( 0, $max_earnings ); |
|
| 300 | - |
|
| 301 | - $y_axis = new GoogleChartAxis( 'y' ); |
|
| 302 | - $y_axis->setDrawTickMarks( true )->setLabels( array( 0, $max_earnings ) ); |
|
| 303 | - $chart->addAxis( $y_axis ); |
|
| 304 | - |
|
| 305 | - $x_axis = new GoogleChartAxis( 'x' ); |
|
| 306 | - $x_axis->setTickMarks( 5 ); |
|
| 307 | - $x_axis->setLabels( array( |
|
| 308 | - __( 'Jan', 'give' ), |
|
| 309 | - __( 'Feb', 'give' ), |
|
| 310 | - __( 'Mar', 'give' ), |
|
| 311 | - __( 'Apr', 'give' ), |
|
| 312 | - __( 'May', 'give' ), |
|
| 313 | - __( 'June', 'give' ), |
|
| 314 | - __( 'July', 'give' ), |
|
| 315 | - __( 'Aug', 'give' ), |
|
| 316 | - __( 'Sept', 'give' ), |
|
| 317 | - __( 'Oct', 'give' ), |
|
| 318 | - __( 'Nov', 'give' ), |
|
| 319 | - __( 'Dec', 'give' ), |
|
| 320 | - ) ); |
|
| 321 | - $chart->addAxis( $x_axis ); |
|
| 322 | - |
|
| 323 | - $shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE ); |
|
| 324 | - $shape_marker->setSize( 6 ); |
|
| 325 | - $shape_marker->setBorder( 2 ); |
|
| 326 | - $shape_marker->setData( $data ); |
|
| 327 | - $chart->addMarker( $shape_marker ); |
|
| 328 | - |
|
| 329 | - $value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE ); |
|
| 330 | - $value_marker->setData( $data ); |
|
| 331 | - $chart->addMarker( $value_marker ); |
|
| 292 | + )); |
|
| 293 | + $data->setLegend(__('Donations', 'give')); |
|
| 294 | + $data->setColor('ff6c1c'); |
|
| 295 | + $chart->addData($data); |
|
| 296 | + |
|
| 297 | + $chart->setTitle(__('Donations by Month for all Give Forms', 'give'), '336699', 18); |
|
| 298 | + |
|
| 299 | + $chart->setScale(0, $max_earnings); |
|
| 300 | + |
|
| 301 | + $y_axis = new GoogleChartAxis('y'); |
|
| 302 | + $y_axis->setDrawTickMarks(true)->setLabels(array(0, $max_earnings)); |
|
| 303 | + $chart->addAxis($y_axis); |
|
| 304 | + |
|
| 305 | + $x_axis = new GoogleChartAxis('x'); |
|
| 306 | + $x_axis->setTickMarks(5); |
|
| 307 | + $x_axis->setLabels(array( |
|
| 308 | + __('Jan', 'give'), |
|
| 309 | + __('Feb', 'give'), |
|
| 310 | + __('Mar', 'give'), |
|
| 311 | + __('Apr', 'give'), |
|
| 312 | + __('May', 'give'), |
|
| 313 | + __('June', 'give'), |
|
| 314 | + __('July', 'give'), |
|
| 315 | + __('Aug', 'give'), |
|
| 316 | + __('Sept', 'give'), |
|
| 317 | + __('Oct', 'give'), |
|
| 318 | + __('Nov', 'give'), |
|
| 319 | + __('Dec', 'give'), |
|
| 320 | + )); |
|
| 321 | + $chart->addAxis($x_axis); |
|
| 322 | + |
|
| 323 | + $shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); |
|
| 324 | + $shape_marker->setSize(6); |
|
| 325 | + $shape_marker->setBorder(2); |
|
| 326 | + $shape_marker->setData($data); |
|
| 327 | + $chart->addMarker($shape_marker); |
|
| 328 | + |
|
| 329 | + $value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE); |
|
| 330 | + $value_marker->setData($data); |
|
| 331 | + $chart->addMarker($value_marker); |
|
| 332 | 332 | |
| 333 | 333 | return $chart->getUrl(); |
| 334 | 334 | } |