@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @access private |
| 23 | 23 | * @since 1.0 |
| 24 | - * @return void |
|
| 24 | + * @return false|null |
|
| 25 | 25 | */ |
| 26 | 26 | function give_process_purchase_form() { |
| 27 | 27 | |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | * |
| 327 | 327 | * @since 1.0.1 |
| 328 | 328 | * |
| 329 | - * @param $payment_mode |
|
| 329 | + * @param string $payment_mode |
|
| 330 | 330 | * |
| 331 | 331 | * @return mixed|void |
| 332 | 332 | */ |
@@ -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,34 +25,34 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | function give_process_purchase_form() { |
| 27 | 27 | |
| 28 | - do_action( 'give_pre_process_purchase' ); |
|
| 28 | + do_action('give_pre_process_purchase'); |
|
| 29 | 29 | |
| 30 | 30 | // Validate the form $_POST data |
| 31 | 31 | $valid_data = give_purchase_form_validate_fields(); |
| 32 | 32 | |
| 33 | 33 | // Allow themes and plugins to hook to errors |
| 34 | - do_action( 'give_checkout_error_checks', $valid_data, $_POST ); |
|
| 34 | + do_action('give_checkout_error_checks', $valid_data, $_POST); |
|
| 35 | 35 | |
| 36 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
| 36 | + $is_ajax = isset($_POST['give_ajax']); |
|
| 37 | 37 | |
| 38 | 38 | // Process the login form |
| 39 | - if ( isset( $_POST['give_login_submit'] ) ) { |
|
| 39 | + if (isset($_POST['give_login_submit'])) { |
|
| 40 | 40 | give_process_form_login(); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | // Validate the user |
| 44 | - $user = give_get_purchase_form_user( $valid_data ); |
|
| 44 | + $user = give_get_purchase_form_user($valid_data); |
|
| 45 | 45 | |
| 46 | - if ( give_get_errors() || ! $user ) { |
|
| 47 | - if ( $is_ajax ) { |
|
| 48 | - do_action( 'give_ajax_checkout_errors' ); |
|
| 46 | + if (give_get_errors() || ! $user) { |
|
| 47 | + if ($is_ajax) { |
|
| 48 | + do_action('give_ajax_checkout_errors'); |
|
| 49 | 49 | give_die(); |
| 50 | 50 | } else { |
| 51 | 51 | return false; |
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if ( $is_ajax ) { |
|
| 55 | + if ($is_ajax) { |
|
| 56 | 56 | echo 'success'; |
| 57 | 57 | give_die(); |
| 58 | 58 | } |
@@ -66,15 +66,15 @@ discard block |
||
| 66 | 66 | 'address' => $user['address'] |
| 67 | 67 | ); |
| 68 | 68 | |
| 69 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 69 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
| 70 | 70 | |
| 71 | 71 | // Setup purchase information |
| 72 | 72 | $purchase_data = array( |
| 73 | - 'price' => ( isset( $_POST['give-amount'] ) ? (float) apply_filters( 'give_donation_total', give_sanitize_amount( give_format_amount( $_POST['give-amount'] ) ) ) : '0.00' ), |
|
| 74 | - 'purchase_key' => strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ), |
|
| 73 | + 'price' => (isset($_POST['give-amount']) ? (float) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00'), |
|
| 74 | + 'purchase_key' => strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))), |
|
| 75 | 75 | 'user_email' => $user['user_email'], |
| 76 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
| 77 | - 'user_info' => stripslashes_deep( $user_info ), |
|
| 76 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
| 77 | + 'user_info' => stripslashes_deep($user_info), |
|
| 78 | 78 | 'post_data' => $_POST, |
| 79 | 79 | 'gateway' => $valid_data['gateway'], |
| 80 | 80 | 'card_info' => $valid_data['cc_info'] |
@@ -84,36 +84,36 @@ discard block |
||
| 84 | 84 | $valid_data['user'] = $user; |
| 85 | 85 | |
| 86 | 86 | // Allow themes and plugins to hook before the gateway |
| 87 | - do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data ); |
|
| 87 | + do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data); |
|
| 88 | 88 | |
| 89 | 89 | |
| 90 | - if ( ! $purchase_data['price'] ) { |
|
| 90 | + if ( ! $purchase_data['price']) { |
|
| 91 | 91 | // Revert to manual |
| 92 | 92 | $purchase_data['gateway'] = 'manual'; |
| 93 | 93 | $_POST['give-gateway'] = 'manual'; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | // Allow the purchase data to be modified before it is sent to the gateway |
| 97 | - $purchase_data = apply_filters( 'give_purchase_data_before_gateway', $purchase_data, $valid_data ); |
|
| 97 | + $purchase_data = apply_filters('give_purchase_data_before_gateway', $purchase_data, $valid_data); |
|
| 98 | 98 | |
| 99 | 99 | // Setup the data we're storing in the purchase session |
| 100 | 100 | $session_data = $purchase_data; |
| 101 | 101 | |
| 102 | 102 | // Make sure credit card numbers are never stored in sessions |
| 103 | - unset( $session_data['card_info']['card_number'] ); |
|
| 103 | + unset($session_data['card_info']['card_number']); |
|
| 104 | 104 | |
| 105 | 105 | // Used for showing data to non logged-in users after purchase, and for other plugins needing purchase data. |
| 106 | - give_set_purchase_session( $session_data ); |
|
| 106 | + give_set_purchase_session($session_data); |
|
| 107 | 107 | |
| 108 | 108 | // Send info to the gateway for payment processing |
| 109 | - give_send_to_gateway( $purchase_data['gateway'], $purchase_data ); |
|
| 109 | + give_send_to_gateway($purchase_data['gateway'], $purchase_data); |
|
| 110 | 110 | give_die(); |
| 111 | 111 | |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | -add_action( 'give_purchase', 'give_process_purchase_form' ); |
|
| 115 | -add_action( 'wp_ajax_give_process_checkout', 'give_process_purchase_form' ); |
|
| 116 | -add_action( 'wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form' ); |
|
| 114 | +add_action('give_purchase', 'give_process_purchase_form'); |
|
| 115 | +add_action('wp_ajax_give_process_checkout', 'give_process_purchase_form'); |
|
| 116 | +add_action('wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form'); |
|
| 117 | 117 | |
| 118 | 118 | /** |
| 119 | 119 | * Process the checkout login form |
@@ -124,32 +124,32 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | function give_process_form_login() { |
| 126 | 126 | |
| 127 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
| 127 | + $is_ajax = isset($_POST['give_ajax']); |
|
| 128 | 128 | |
| 129 | 129 | $user_data = give_purchase_form_validate_user_login(); |
| 130 | 130 | |
| 131 | - if ( give_get_errors() || $user_data['user_id'] < 1 ) { |
|
| 132 | - if ( $is_ajax ) { |
|
| 133 | - do_action( 'give_ajax_checkout_errors' ); |
|
| 131 | + if (give_get_errors() || $user_data['user_id'] < 1) { |
|
| 132 | + if ($is_ajax) { |
|
| 133 | + do_action('give_ajax_checkout_errors'); |
|
| 134 | 134 | give_die(); |
| 135 | 135 | } else { |
| 136 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
| 136 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
| 137 | 137 | exit; |
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] ); |
|
| 141 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']); |
|
| 142 | 142 | |
| 143 | - if ( $is_ajax ) { |
|
| 143 | + if ($is_ajax) { |
|
| 144 | 144 | echo 'success'; |
| 145 | 145 | give_die(); |
| 146 | 146 | } else { |
| 147 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
| 147 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | -add_action( 'wp_ajax_give_process_checkout_login', 'give_process_form_login' ); |
|
| 152 | -add_action( 'wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login' ); |
|
| 151 | +add_action('wp_ajax_give_process_checkout_login', 'give_process_form_login'); |
|
| 152 | +add_action('wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login'); |
|
| 153 | 153 | |
| 154 | 154 | /** |
| 155 | 155 | * Purchase Form Validate Fields |
@@ -163,43 +163,43 @@ discard block |
||
| 163 | 163 | global $give_options; |
| 164 | 164 | |
| 165 | 165 | // Check if there is $_POST |
| 166 | - if ( empty( $_POST ) ) { |
|
| 166 | + if (empty($_POST)) { |
|
| 167 | 167 | return false; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
| 170 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
| 171 | 171 | |
| 172 | 172 | // Start an array to collect valid data |
| 173 | 173 | $valid_data = array( |
| 174 | 174 | 'gateway' => give_purchase_form_validate_gateway(), // Gateway fallback |
| 175 | - 'need_new_user' => false, // New user flag |
|
| 176 | - 'need_user_login' => false, // Login user flag |
|
| 177 | - 'logged_user_data' => array(), // Logged user collected data |
|
| 178 | - 'new_user_data' => array(), // New user collected data |
|
| 179 | - 'login_user_data' => array(), // Login user collected data |
|
| 180 | - 'guest_user_data' => array(), // Guest user collected data |
|
| 175 | + 'need_new_user' => false, // New user flag |
|
| 176 | + 'need_user_login' => false, // Login user flag |
|
| 177 | + 'logged_user_data' => array(), // Logged user collected data |
|
| 178 | + 'new_user_data' => array(), // New user collected data |
|
| 179 | + 'login_user_data' => array(), // Login user collected data |
|
| 180 | + 'guest_user_data' => array(), // Guest user collected data |
|
| 181 | 181 | 'cc_info' => give_purchase_form_validate_cc() // Credit card info |
| 182 | 182 | ); |
| 183 | 183 | |
| 184 | 184 | // Validate agree to terms |
| 185 | - $terms_option = get_post_meta( $form_id, '_give_terms_option', true ); |
|
| 186 | - if ( isset( $terms_option ) && $terms_option === 'yes' ) { |
|
| 185 | + $terms_option = get_post_meta($form_id, '_give_terms_option', true); |
|
| 186 | + if (isset($terms_option) && $terms_option === 'yes') { |
|
| 187 | 187 | give_purchase_form_validate_agree_to_terms(); |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | //Validate amount is more than 0 |
| 191 | 191 | |
| 192 | 192 | |
| 193 | - if ( is_user_logged_in() ) { |
|
| 193 | + if (is_user_logged_in()) { |
|
| 194 | 194 | // Collect logged in user data |
| 195 | 195 | $valid_data['logged_in_user'] = give_purchase_form_validate_logged_in_user(); |
| 196 | - } else if ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) { |
|
| 196 | + } else if (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') { |
|
| 197 | 197 | // Set new user registration as required |
| 198 | 198 | $valid_data['need_new_user'] = true; |
| 199 | 199 | // Validate new user data |
| 200 | 200 | $valid_data['new_user_data'] = give_purchase_form_validate_new_user(); |
| 201 | 201 | // Check if login validation is needed |
| 202 | - } else if ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) { |
|
| 202 | + } else if (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') { |
|
| 203 | 203 | // Set user login as required |
| 204 | 204 | $valid_data['need_user_login'] = true; |
| 205 | 205 | // Validate users login info |
@@ -222,27 +222,27 @@ discard block |
||
| 222 | 222 | */ |
| 223 | 223 | function give_purchase_form_validate_gateway() { |
| 224 | 224 | |
| 225 | - $gateway = give_get_default_gateway( $_REQUEST['give-form-id'] ); |
|
| 225 | + $gateway = give_get_default_gateway($_REQUEST['give-form-id']); |
|
| 226 | 226 | |
| 227 | 227 | // Check if a gateway value is present |
| 228 | - if ( ! empty( $_REQUEST['give-gateway'] ) ) { |
|
| 228 | + if ( ! empty($_REQUEST['give-gateway'])) { |
|
| 229 | 229 | |
| 230 | - $gateway = sanitize_text_field( $_REQUEST['give-gateway'] ); |
|
| 230 | + $gateway = sanitize_text_field($_REQUEST['give-gateway']); |
|
| 231 | 231 | |
| 232 | 232 | //Is amount being donated in LIVE mode above 0.00? |
| 233 | - if ( '0.00' == $_REQUEST['give-amount'] && ! give_is_test_mode() ) { |
|
| 233 | + if ('0.00' == $_REQUEST['give-amount'] && ! give_is_test_mode()) { |
|
| 234 | 234 | |
| 235 | - give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) ); |
|
| 235 | + give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give')); |
|
| 236 | 236 | |
| 237 | 237 | } //Is this test mode zero donation? Let it through but set to manual gateway |
| 238 | - elseif ( '0.00' == $_REQUEST['give-amount'] && give_is_test_mode() ) { |
|
| 238 | + elseif ('0.00' == $_REQUEST['give-amount'] && give_is_test_mode()) { |
|
| 239 | 239 | |
| 240 | 240 | $gateway = 'manual'; |
| 241 | 241 | |
| 242 | 242 | } //Check if this gateway is active |
| 243 | - elseif ( ! give_is_gateway_active( $gateway ) ) { |
|
| 243 | + elseif ( ! give_is_gateway_active($gateway)) { |
|
| 244 | 244 | |
| 245 | - give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled', 'give' ) ); |
|
| 245 | + give_set_error('invalid_gateway', __('The selected payment gateway is not enabled', 'give')); |
|
| 246 | 246 | |
| 247 | 247 | } |
| 248 | 248 | |
@@ -261,9 +261,9 @@ discard block |
||
| 261 | 261 | */ |
| 262 | 262 | function give_purchase_form_validate_agree_to_terms() { |
| 263 | 263 | // Validate agree to terms |
| 264 | - if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) { |
|
| 264 | + if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) { |
|
| 265 | 265 | // User did not agree |
| 266 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms of use', 'give' ) ) ); |
|
| 266 | + give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms of use', 'give'))); |
|
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | |
@@ -277,47 +277,47 @@ discard block |
||
| 277 | 277 | * |
| 278 | 278 | * @return array |
| 279 | 279 | */ |
| 280 | -function give_purchase_form_required_fields( $form_id ) { |
|
| 280 | +function give_purchase_form_required_fields($form_id) { |
|
| 281 | 281 | |
| 282 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
| 282 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
| 283 | 283 | |
| 284 | 284 | $required_fields = array( |
| 285 | 285 | 'give_email' => array( |
| 286 | 286 | 'error_id' => 'invalid_email', |
| 287 | - 'error_message' => __( 'Please enter a valid email address', 'give' ) |
|
| 287 | + 'error_message' => __('Please enter a valid email address', 'give') |
|
| 288 | 288 | ), |
| 289 | 289 | 'give_first' => array( |
| 290 | 290 | 'error_id' => 'invalid_first_name', |
| 291 | - 'error_message' => __( 'Please enter your first name', 'give' ) |
|
| 291 | + 'error_message' => __('Please enter your first name', 'give') |
|
| 292 | 292 | ) |
| 293 | 293 | ); |
| 294 | 294 | |
| 295 | - $require_address = give_require_billing_address( $payment_mode ); |
|
| 295 | + $require_address = give_require_billing_address($payment_mode); |
|
| 296 | 296 | |
| 297 | - if ( $require_address ) { |
|
| 298 | - $required_fields['card_address'] = array( |
|
| 297 | + if ($require_address) { |
|
| 298 | + $required_fields['card_address'] = array( |
|
| 299 | 299 | 'error_id' => 'invalid_card_address', |
| 300 | - 'error_message' => __( 'Please enter your primary billing address', 'give' ) |
|
| 300 | + 'error_message' => __('Please enter your primary billing address', 'give') |
|
| 301 | 301 | ); |
| 302 | - $required_fields['card_zip'] = array( |
|
| 302 | + $required_fields['card_zip'] = array( |
|
| 303 | 303 | 'error_id' => 'invalid_zip_code', |
| 304 | - 'error_message' => __( 'Please enter your zip / postal code', 'give' ) |
|
| 304 | + 'error_message' => __('Please enter your zip / postal code', 'give') |
|
| 305 | 305 | ); |
| 306 | - $required_fields['card_city'] = array( |
|
| 306 | + $required_fields['card_city'] = array( |
|
| 307 | 307 | 'error_id' => 'invalid_city', |
| 308 | - 'error_message' => __( 'Please enter your billing city', 'give' ) |
|
| 308 | + 'error_message' => __('Please enter your billing city', 'give') |
|
| 309 | 309 | ); |
| 310 | 310 | $required_fields['billing_country'] = array( |
| 311 | 311 | 'error_id' => 'invalid_country', |
| 312 | - 'error_message' => __( 'Please select your billing country', 'give' ) |
|
| 312 | + 'error_message' => __('Please select your billing country', 'give') |
|
| 313 | 313 | ); |
| 314 | - $required_fields['card_state'] = array( |
|
| 314 | + $required_fields['card_state'] = array( |
|
| 315 | 315 | 'error_id' => 'invalid_state', |
| 316 | - 'error_message' => __( 'Please enter billing state / province', 'give' ) |
|
| 316 | + 'error_message' => __('Please enter billing state / province', 'give') |
|
| 317 | 317 | ); |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - return apply_filters( 'give_purchase_form_required_fields', $required_fields, $form_id ); |
|
| 320 | + return apply_filters('give_purchase_form_required_fields', $required_fields, $form_id); |
|
| 321 | 321 | |
| 322 | 322 | } |
| 323 | 323 | |
@@ -330,16 +330,16 @@ discard block |
||
| 330 | 330 | * |
| 331 | 331 | * @return mixed|void |
| 332 | 332 | */ |
| 333 | -function give_require_billing_address( $payment_mode ) { |
|
| 333 | +function give_require_billing_address($payment_mode) { |
|
| 334 | 334 | |
| 335 | 335 | $return = false; |
| 336 | 336 | |
| 337 | - if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { |
|
| 337 | + if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { |
|
| 338 | 338 | $return = true; |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | // Let payment gateways and other extensions determine if address fields should be required |
| 342 | - return apply_filters( 'give_require_billing_address', $return ); |
|
| 342 | + return apply_filters('give_require_billing_address', $return); |
|
| 343 | 343 | |
| 344 | 344 | } |
| 345 | 345 | |
@@ -353,43 +353,43 @@ discard block |
||
| 353 | 353 | function give_purchase_form_validate_logged_in_user() { |
| 354 | 354 | global $user_ID; |
| 355 | 355 | |
| 356 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
| 356 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
| 357 | 357 | |
| 358 | 358 | // Start empty array to collect valid user data |
| 359 | 359 | $valid_user_data = array( |
| 360 | 360 | // Assume there will be errors |
| 361 | - 'user_id' => - 1 |
|
| 361 | + 'user_id' => -1 |
|
| 362 | 362 | ); |
| 363 | 363 | |
| 364 | 364 | // Verify there is a user_ID |
| 365 | - if ( $user_ID > 0 ) { |
|
| 365 | + if ($user_ID > 0) { |
|
| 366 | 366 | // Get the logged in user data |
| 367 | - $user_data = get_userdata( $user_ID ); |
|
| 367 | + $user_data = get_userdata($user_ID); |
|
| 368 | 368 | |
| 369 | 369 | // Loop through required fields and show error messages |
| 370 | - foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) { |
|
| 371 | - if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
| 372 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
| 370 | + foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) { |
|
| 371 | + if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
| 372 | + give_set_error($value['error_id'], $value['error_message']); |
|
| 373 | 373 | } |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | // Verify data |
| 377 | - if ( $user_data ) { |
|
| 377 | + if ($user_data) { |
|
| 378 | 378 | // Collected logged in user data |
| 379 | 379 | $valid_user_data = array( |
| 380 | 380 | 'user_id' => $user_ID, |
| 381 | - 'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email, |
|
| 382 | - 'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name, |
|
| 383 | - 'user_last' => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name, |
|
| 381 | + 'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email, |
|
| 382 | + 'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name, |
|
| 383 | + 'user_last' => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name, |
|
| 384 | 384 | ); |
| 385 | 385 | |
| 386 | - if ( ! is_email( $valid_user_data['user_email'] ) ) { |
|
| 387 | - give_set_error( 'email_invalid', __( 'Invalid email', 'give' ) ); |
|
| 386 | + if ( ! is_email($valid_user_data['user_email'])) { |
|
| 387 | + give_set_error('email_invalid', __('Invalid email', 'give')); |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | } else { |
| 391 | 391 | // Set invalid user error |
| 392 | - give_set_error( 'invalid_user', __( 'The user information is invalid', 'give' ) ); |
|
| 392 | + give_set_error('invalid_user', __('The user information is invalid', 'give')); |
|
| 393 | 393 | } |
| 394 | 394 | } |
| 395 | 395 | |
@@ -407,92 +407,92 @@ discard block |
||
| 407 | 407 | function give_purchase_form_validate_new_user() { |
| 408 | 408 | $registering_new_user = false; |
| 409 | 409 | |
| 410 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
| 410 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
| 411 | 411 | |
| 412 | 412 | // Start an empty array to collect valid user data |
| 413 | 413 | $valid_user_data = array( |
| 414 | 414 | // Assume there will be errors |
| 415 | - 'user_id' => - 1, |
|
| 415 | + 'user_id' => -1, |
|
| 416 | 416 | // Get first name |
| 417 | - 'user_first' => isset( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : '', |
|
| 417 | + 'user_first' => isset($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : '', |
|
| 418 | 418 | // Get last name |
| 419 | - 'user_last' => isset( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : '', |
|
| 419 | + 'user_last' => isset($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : '', |
|
| 420 | 420 | ); |
| 421 | 421 | |
| 422 | 422 | // Check the new user's credentials against existing ones |
| 423 | - $user_login = isset( $_POST['give_user_login'] ) ? trim( $_POST['give_user_login'] ) : false; |
|
| 424 | - $user_email = isset( $_POST['give_email'] ) ? trim( $_POST['give_email'] ) : false; |
|
| 425 | - $user_pass = isset( $_POST['give_user_pass'] ) ? trim( $_POST['give_user_pass'] ) : false; |
|
| 426 | - $pass_confirm = isset( $_POST['give_user_pass_confirm'] ) ? trim( $_POST['give_user_pass_confirm'] ) : false; |
|
| 423 | + $user_login = isset($_POST['give_user_login']) ? trim($_POST['give_user_login']) : false; |
|
| 424 | + $user_email = isset($_POST['give_email']) ? trim($_POST['give_email']) : false; |
|
| 425 | + $user_pass = isset($_POST['give_user_pass']) ? trim($_POST['give_user_pass']) : false; |
|
| 426 | + $pass_confirm = isset($_POST['give_user_pass_confirm']) ? trim($_POST['give_user_pass_confirm']) : false; |
|
| 427 | 427 | |
| 428 | 428 | // Loop through required fields and show error messages |
| 429 | - foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) { |
|
| 430 | - if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
| 431 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
| 429 | + foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) { |
|
| 430 | + if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
| 431 | + give_set_error($value['error_id'], $value['error_message']); |
|
| 432 | 432 | } |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | // Check if we have an username to register |
| 436 | - if ( $user_login && strlen( $user_login ) > 0 ) { |
|
| 436 | + if ($user_login && strlen($user_login) > 0) { |
|
| 437 | 437 | $registering_new_user = true; |
| 438 | 438 | |
| 439 | 439 | // We have an user name, check if it already exists |
| 440 | - if ( username_exists( $user_login ) ) { |
|
| 440 | + if (username_exists($user_login)) { |
|
| 441 | 441 | // Username already registered |
| 442 | - give_set_error( 'username_unavailable', __( 'Username already taken', 'give' ) ); |
|
| 442 | + give_set_error('username_unavailable', __('Username already taken', 'give')); |
|
| 443 | 443 | // Check if it's valid |
| 444 | - } else if ( ! give_validate_username( $user_login ) ) { |
|
| 444 | + } else if ( ! give_validate_username($user_login)) { |
|
| 445 | 445 | // Invalid username |
| 446 | - if ( is_multisite() ) { |
|
| 447 | - give_set_error( 'username_invalid', __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed', 'give' ) ); |
|
| 446 | + if (is_multisite()) { |
|
| 447 | + give_set_error('username_invalid', __('Invalid username. Only lowercase letters (a-z) and numbers are allowed', 'give')); |
|
| 448 | 448 | } else { |
| 449 | - give_set_error( 'username_invalid', __( 'Invalid username', 'give' ) ); |
|
| 449 | + give_set_error('username_invalid', __('Invalid username', 'give')); |
|
| 450 | 450 | } |
| 451 | 451 | } else { |
| 452 | 452 | // All the checks have run and it's good to go |
| 453 | 453 | $valid_user_data['user_login'] = $user_login; |
| 454 | 454 | } |
| 455 | 455 | } else { |
| 456 | - if ( give_no_guest_checkout( $form_id ) ) { |
|
| 457 | - give_set_error( 'registration_required', __( 'You must register or login to complete your donation', 'give' ) ); |
|
| 456 | + if (give_no_guest_checkout($form_id)) { |
|
| 457 | + give_set_error('registration_required', __('You must register or login to complete your donation', 'give')); |
|
| 458 | 458 | } |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | // Check if we have an email to verify |
| 462 | - if ( $user_email && strlen( $user_email ) > 0 ) { |
|
| 462 | + if ($user_email && strlen($user_email) > 0) { |
|
| 463 | 463 | // Validate email |
| 464 | - if ( ! is_email( $user_email ) ) { |
|
| 465 | - give_set_error( 'email_invalid', __( 'Invalid email', 'give' ) ); |
|
| 464 | + if ( ! is_email($user_email)) { |
|
| 465 | + give_set_error('email_invalid', __('Invalid email', 'give')); |
|
| 466 | 466 | // Check if email exists |
| 467 | - } else if ( email_exists( $user_email ) && $registering_new_user ) { |
|
| 468 | - give_set_error( 'email_used', __( 'Email already used', 'give' ) ); |
|
| 467 | + } else if (email_exists($user_email) && $registering_new_user) { |
|
| 468 | + give_set_error('email_used', __('Email already used', 'give')); |
|
| 469 | 469 | } else { |
| 470 | 470 | // All the checks have run and it's good to go |
| 471 | 471 | $valid_user_data['user_email'] = $user_email; |
| 472 | 472 | } |
| 473 | 473 | } else { |
| 474 | 474 | // No email |
| 475 | - give_set_error( 'email_empty', __( 'Enter an email', 'give' ) ); |
|
| 475 | + give_set_error('email_empty', __('Enter an email', 'give')); |
|
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | // Check password |
| 479 | - if ( $user_pass && $pass_confirm ) { |
|
| 479 | + if ($user_pass && $pass_confirm) { |
|
| 480 | 480 | // Verify confirmation matches |
| 481 | - if ( $user_pass != $pass_confirm ) { |
|
| 481 | + if ($user_pass != $pass_confirm) { |
|
| 482 | 482 | // Passwords do not match |
| 483 | - give_set_error( 'password_mismatch', __( 'Passwords don\'t match', 'give' ) ); |
|
| 483 | + give_set_error('password_mismatch', __('Passwords don\'t match', 'give')); |
|
| 484 | 484 | } else { |
| 485 | 485 | // All is good to go |
| 486 | 486 | $valid_user_data['user_pass'] = $user_pass; |
| 487 | 487 | } |
| 488 | 488 | } else { |
| 489 | 489 | // Password or confirmation missing |
| 490 | - if ( ! $user_pass && $registering_new_user ) { |
|
| 490 | + if ( ! $user_pass && $registering_new_user) { |
|
| 491 | 491 | // The password is invalid |
| 492 | - give_set_error( 'password_empty', __( 'Enter a password', 'give' ) ); |
|
| 493 | - } else if ( ! $pass_confirm && $registering_new_user ) { |
|
| 492 | + give_set_error('password_empty', __('Enter a password', 'give')); |
|
| 493 | + } else if ( ! $pass_confirm && $registering_new_user) { |
|
| 494 | 494 | // Confirmation password is invalid |
| 495 | - give_set_error( 'confirmation_empty', __( 'Enter the password confirmation', 'give' ) ); |
|
| 495 | + give_set_error('confirmation_empty', __('Enter the password confirmation', 'give')); |
|
| 496 | 496 | } |
| 497 | 497 | } |
| 498 | 498 | |
@@ -511,34 +511,34 @@ discard block |
||
| 511 | 511 | // Start an array to collect valid user data |
| 512 | 512 | $valid_user_data = array( |
| 513 | 513 | // Assume there will be errors |
| 514 | - 'user_id' => - 1 |
|
| 514 | + 'user_id' => -1 |
|
| 515 | 515 | ); |
| 516 | 516 | |
| 517 | 517 | // Username |
| 518 | - if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) { |
|
| 519 | - give_set_error( 'must_log_in', __( 'You must login or register to complete your donation', 'give' ) ); |
|
| 518 | + if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') { |
|
| 519 | + give_set_error('must_log_in', __('You must login or register to complete your donation', 'give')); |
|
| 520 | 520 | |
| 521 | 521 | return $valid_user_data; |
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | // Get the user by login |
| 525 | - $user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) ); |
|
| 525 | + $user_data = get_user_by('login', strip_tags($_POST['give_user_login'])); |
|
| 526 | 526 | |
| 527 | 527 | // Check if user exists |
| 528 | - if ( $user_data ) { |
|
| 528 | + if ($user_data) { |
|
| 529 | 529 | // Get password |
| 530 | - $user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false; |
|
| 530 | + $user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false; |
|
| 531 | 531 | |
| 532 | 532 | // Check user_pass |
| 533 | - if ( $user_pass ) { |
|
| 533 | + if ($user_pass) { |
|
| 534 | 534 | // Check if password is valid |
| 535 | - if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { |
|
| 535 | + if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { |
|
| 536 | 536 | // Incorrect password |
| 537 | 537 | give_set_error( |
| 538 | 538 | 'password_incorrect', |
| 539 | 539 | sprintf( |
| 540 | - __( 'The password you entered is incorrect. %sReset Password%s', 'give' ), |
|
| 541 | - '<a href="' . wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ) . '" title="' . __( 'Lost Password', 'give' ) . '">', |
|
| 540 | + __('The password you entered is incorrect. %sReset Password%s', 'give'), |
|
| 541 | + '<a href="'.wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]").'" title="'.__('Lost Password', 'give').'">', |
|
| 542 | 542 | '</a>' |
| 543 | 543 | ) |
| 544 | 544 | ); |
@@ -556,11 +556,11 @@ discard block |
||
| 556 | 556 | } |
| 557 | 557 | } else { |
| 558 | 558 | // Empty password |
| 559 | - give_set_error( 'password_empty', __( 'Enter a password', 'give' ) ); |
|
| 559 | + give_set_error('password_empty', __('Enter a password', 'give')); |
|
| 560 | 560 | } |
| 561 | 561 | } else { |
| 562 | 562 | // no username |
| 563 | - give_set_error( 'username_incorrect', __( 'The username you entered does not exist', 'give' ) ); |
|
| 563 | + give_set_error('username_incorrect', __('The username you entered does not exist', 'give')); |
|
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | return $valid_user_data; |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | */ |
| 576 | 576 | function give_purchase_form_validate_guest_user() { |
| 577 | 577 | |
| 578 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
| 578 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
| 579 | 579 | |
| 580 | 580 | // Start an array to collect valid user data |
| 581 | 581 | $valid_user_data = array( |
@@ -584,32 +584,32 @@ discard block |
||
| 584 | 584 | ); |
| 585 | 585 | |
| 586 | 586 | // Show error message if user must be logged in |
| 587 | - if ( give_logged_in_only() ) { |
|
| 588 | - give_set_error( 'logged_in_only', __( 'You must be logged into an account to donation', 'give' ) ); |
|
| 587 | + if (give_logged_in_only()) { |
|
| 588 | + give_set_error('logged_in_only', __('You must be logged into an account to donation', 'give')); |
|
| 589 | 589 | } |
| 590 | 590 | |
| 591 | 591 | // Get the guest email |
| 592 | - $guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
| 592 | + $guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
| 593 | 593 | |
| 594 | 594 | // Check email |
| 595 | - if ( $guest_email && strlen( $guest_email ) > 0 ) { |
|
| 595 | + if ($guest_email && strlen($guest_email) > 0) { |
|
| 596 | 596 | // Validate email |
| 597 | - if ( ! is_email( $guest_email ) ) { |
|
| 597 | + if ( ! is_email($guest_email)) { |
|
| 598 | 598 | // Invalid email |
| 599 | - give_set_error( 'email_invalid', __( 'Invalid email', 'give' ) ); |
|
| 599 | + give_set_error('email_invalid', __('Invalid email', 'give')); |
|
| 600 | 600 | } else { |
| 601 | 601 | // All is good to go |
| 602 | 602 | $valid_user_data['user_email'] = $guest_email; |
| 603 | 603 | } |
| 604 | 604 | } else { |
| 605 | 605 | // No email |
| 606 | - give_set_error( 'email_empty', __( 'Enter an email', 'give' ) ); |
|
| 606 | + give_set_error('email_empty', __('Enter an email', 'give')); |
|
| 607 | 607 | } |
| 608 | 608 | |
| 609 | 609 | // Loop through required fields and show error messages |
| 610 | - foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) { |
|
| 611 | - if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
| 612 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
| 610 | + foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) { |
|
| 611 | + if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
| 612 | + give_set_error($value['error_id'], $value['error_message']); |
|
| 613 | 613 | } |
| 614 | 614 | } |
| 615 | 615 | |
@@ -625,42 +625,42 @@ discard block |
||
| 625 | 625 | * @since 1.0 |
| 626 | 626 | * @return integer |
| 627 | 627 | */ |
| 628 | -function give_register_and_login_new_user( $user_data = array() ) { |
|
| 628 | +function give_register_and_login_new_user($user_data = array()) { |
|
| 629 | 629 | // Verify the array |
| 630 | - if ( empty( $user_data ) ) { |
|
| 631 | - return - 1; |
|
| 630 | + if (empty($user_data)) { |
|
| 631 | + return -1; |
|
| 632 | 632 | } |
| 633 | 633 | |
| 634 | - if ( give_get_errors() ) { |
|
| 635 | - return - 1; |
|
| 634 | + if (give_get_errors()) { |
|
| 635 | + return -1; |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | - $user_args = apply_filters( 'give_insert_user_args', array( |
|
| 639 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '', |
|
| 640 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '', |
|
| 641 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '', |
|
| 642 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '', |
|
| 643 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '', |
|
| 644 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
| 645 | - 'role' => get_option( 'default_role' ) |
|
| 646 | - ), $user_data ); |
|
| 638 | + $user_args = apply_filters('give_insert_user_args', array( |
|
| 639 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', |
|
| 640 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', |
|
| 641 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', |
|
| 642 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', |
|
| 643 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', |
|
| 644 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
| 645 | + 'role' => get_option('default_role') |
|
| 646 | + ), $user_data); |
|
| 647 | 647 | |
| 648 | 648 | // Insert new user |
| 649 | - $user_id = wp_insert_user( $user_args ); |
|
| 649 | + $user_id = wp_insert_user($user_args); |
|
| 650 | 650 | |
| 651 | 651 | // Validate inserted user |
| 652 | - if ( is_wp_error( $user_id ) ) { |
|
| 653 | - return - 1; |
|
| 652 | + if (is_wp_error($user_id)) { |
|
| 653 | + return -1; |
|
| 654 | 654 | } |
| 655 | 655 | |
| 656 | 656 | // Allow themes and plugins to filter the user data |
| 657 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args ); |
|
| 657 | + $user_data = apply_filters('give_insert_user_data', $user_data, $user_args); |
|
| 658 | 658 | |
| 659 | 659 | // Allow themes and plugins to hook |
| 660 | - do_action( 'give_insert_user', $user_id, $user_data ); |
|
| 660 | + do_action('give_insert_user', $user_id, $user_data); |
|
| 661 | 661 | |
| 662 | 662 | // Login new user |
| 663 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] ); |
|
| 663 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']); |
|
| 664 | 664 | |
| 665 | 665 | // Return user id |
| 666 | 666 | return $user_id; |
@@ -675,27 +675,27 @@ discard block |
||
| 675 | 675 | * @since 1.0 |
| 676 | 676 | * @return array |
| 677 | 677 | */ |
| 678 | -function give_get_purchase_form_user( $valid_data = array() ) { |
|
| 678 | +function give_get_purchase_form_user($valid_data = array()) { |
|
| 679 | 679 | // Initialize user |
| 680 | 680 | $user = false; |
| 681 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
| 681 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
| 682 | 682 | |
| 683 | - if ( $is_ajax ) { |
|
| 683 | + if ($is_ajax) { |
|
| 684 | 684 | // Do not create or login the user during the ajax submission (check for errors only) |
| 685 | 685 | return true; |
| 686 | - } else if ( is_user_logged_in() ) { |
|
| 686 | + } else if (is_user_logged_in()) { |
|
| 687 | 687 | // Set the valid user as the logged in collected data |
| 688 | 688 | |
| 689 | 689 | $user = $valid_data['logged_in_user']; |
| 690 | - } else if ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) { |
|
| 690 | + } else if ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) { |
|
| 691 | 691 | // New user registration |
| 692 | - if ( $valid_data['need_new_user'] === true ) { |
|
| 692 | + if ($valid_data['need_new_user'] === true) { |
|
| 693 | 693 | // Set user |
| 694 | 694 | $user = $valid_data['new_user_data']; |
| 695 | 695 | // Register and login new user |
| 696 | - $user['user_id'] = give_register_and_login_new_user( $user ); |
|
| 696 | + $user['user_id'] = give_register_and_login_new_user($user); |
|
| 697 | 697 | // User login |
| 698 | - } else if ( $valid_data['need_user_login'] === true && ! $is_ajax ) { |
|
| 698 | + } else if ($valid_data['need_user_login'] === true && ! $is_ajax) { |
|
| 699 | 699 | |
| 700 | 700 | /* |
| 701 | 701 | * The login form is now processed in the give_process_purchase_login() function. |
@@ -710,48 +710,48 @@ discard block |
||
| 710 | 710 | // Set user |
| 711 | 711 | $user = $valid_data['login_user_data']; |
| 712 | 712 | // Login user |
| 713 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] ); |
|
| 713 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); |
|
| 714 | 714 | } |
| 715 | 715 | } |
| 716 | 716 | |
| 717 | 717 | // Check guest checkout |
| 718 | - if ( false === $user && false === give_no_guest_checkout( $_POST['give-form-id'] ) ) { |
|
| 718 | + if (false === $user && false === give_no_guest_checkout($_POST['give-form-id'])) { |
|
| 719 | 719 | // Set user |
| 720 | 720 | $user = $valid_data['guest_user_data']; |
| 721 | 721 | } |
| 722 | 722 | |
| 723 | 723 | // Verify we have an user |
| 724 | - if ( false === $user || empty( $user ) ) { |
|
| 724 | + if (false === $user || empty($user)) { |
|
| 725 | 725 | // Return false |
| 726 | 726 | return false; |
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | // Get user first name |
| 730 | - if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { |
|
| 731 | - $user['user_first'] = isset( $_POST["give_first"] ) ? strip_tags( trim( $_POST["give_first"] ) ) : ''; |
|
| 730 | + if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { |
|
| 731 | + $user['user_first'] = isset($_POST["give_first"]) ? strip_tags(trim($_POST["give_first"])) : ''; |
|
| 732 | 732 | } |
| 733 | 733 | |
| 734 | 734 | // Get user last name |
| 735 | - if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { |
|
| 736 | - $user['user_last'] = isset( $_POST["give_last"] ) ? strip_tags( trim( $_POST["give_last"] ) ) : ''; |
|
| 735 | + if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { |
|
| 736 | + $user['user_last'] = isset($_POST["give_last"]) ? strip_tags(trim($_POST["give_last"])) : ''; |
|
| 737 | 737 | } |
| 738 | 738 | |
| 739 | 739 | // Get the user's billing address details |
| 740 | 740 | $user['address'] = array(); |
| 741 | - $user['address']['line1'] = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false; |
|
| 742 | - $user['address']['line2'] = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false; |
|
| 743 | - $user['address']['city'] = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false; |
|
| 744 | - $user['address']['state'] = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false; |
|
| 745 | - $user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false; |
|
| 746 | - $user['address']['zip'] = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false; |
|
| 747 | - |
|
| 748 | - if ( empty( $user['address']['country'] ) ) { |
|
| 741 | + $user['address']['line1'] = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false; |
|
| 742 | + $user['address']['line2'] = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false; |
|
| 743 | + $user['address']['city'] = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false; |
|
| 744 | + $user['address']['state'] = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false; |
|
| 745 | + $user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false; |
|
| 746 | + $user['address']['zip'] = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false; |
|
| 747 | + |
|
| 748 | + if (empty($user['address']['country'])) { |
|
| 749 | 749 | $user['address'] = false; |
| 750 | 750 | } // Country will always be set if address fields are present |
| 751 | 751 | |
| 752 | - if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) { |
|
| 752 | + if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) { |
|
| 753 | 753 | // Store the address in the user's meta so the cart can be pre-populated with it on return purchases |
| 754 | - update_user_meta( $user['user_id'], '_give_user_address', $user['address'] ); |
|
| 754 | + update_user_meta($user['user_id'], '_give_user_address', $user['address']); |
|
| 755 | 755 | } |
| 756 | 756 | |
| 757 | 757 | // Return valid user |
@@ -770,16 +770,16 @@ discard block |
||
| 770 | 770 | $card_data = give_get_purchase_cc_info(); |
| 771 | 771 | |
| 772 | 772 | // Validate the card zip |
| 773 | - if ( ! empty( $card_data['card_zip'] ) ) { |
|
| 774 | - if ( ! give_purchase_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { |
|
| 775 | - give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid', 'give' ) ); |
|
| 773 | + if ( ! empty($card_data['card_zip'])) { |
|
| 774 | + if ( ! give_purchase_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { |
|
| 775 | + give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid', 'give')); |
|
| 776 | 776 | } |
| 777 | 777 | } |
| 778 | 778 | |
| 779 | 779 | //Ensure no spaces |
| 780 | - if ( ! empty( $card_data['card_number'] ) ) { |
|
| 781 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); //no "+" signs |
|
| 782 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces |
|
| 780 | + if ( ! empty($card_data['card_number'])) { |
|
| 781 | + $card_data['card_number'] = str_replace('+', '', $card_data['card_number']); //no "+" signs |
|
| 782 | + $card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces |
|
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | // This should validate card numbers at some point too |
@@ -795,17 +795,17 @@ discard block |
||
| 795 | 795 | */ |
| 796 | 796 | function give_get_purchase_cc_info() { |
| 797 | 797 | $cc_info = array(); |
| 798 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
| 799 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
| 800 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
| 801 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
| 802 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
| 803 | - $cc_info['card_address'] = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : ''; |
|
| 804 | - $cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : ''; |
|
| 805 | - $cc_info['card_city'] = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : ''; |
|
| 806 | - $cc_info['card_state'] = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : ''; |
|
| 807 | - $cc_info['card_country'] = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : ''; |
|
| 808 | - $cc_info['card_zip'] = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : ''; |
|
| 798 | + $cc_info['card_name'] = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : ''; |
|
| 799 | + $cc_info['card_number'] = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : ''; |
|
| 800 | + $cc_info['card_cvc'] = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : ''; |
|
| 801 | + $cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : ''; |
|
| 802 | + $cc_info['card_exp_year'] = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : ''; |
|
| 803 | + $cc_info['card_address'] = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : ''; |
|
| 804 | + $cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : ''; |
|
| 805 | + $cc_info['card_city'] = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : ''; |
|
| 806 | + $cc_info['card_state'] = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : ''; |
|
| 807 | + $cc_info['card_country'] = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : ''; |
|
| 808 | + $cc_info['card_zip'] = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : ''; |
|
| 809 | 809 | |
| 810 | 810 | // Return cc info |
| 811 | 811 | return $cc_info; |
@@ -821,14 +821,14 @@ discard block |
||
| 821 | 821 | * |
| 822 | 822 | * @return bool|mixed|void |
| 823 | 823 | */ |
| 824 | -function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
| 824 | +function give_purchase_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
| 825 | 825 | $ret = false; |
| 826 | 826 | |
| 827 | - if ( empty( $zip ) || empty( $country_code ) ) { |
|
| 827 | + if (empty($zip) || empty($country_code)) { |
|
| 828 | 828 | return $ret; |
| 829 | 829 | } |
| 830 | 830 | |
| 831 | - $country_code = strtoupper( $country_code ); |
|
| 831 | + $country_code = strtoupper($country_code); |
|
| 832 | 832 | |
| 833 | 833 | $zip_regex = array( |
| 834 | 834 | "AD" => "AD\d{3}", |
@@ -988,11 +988,11 @@ discard block |
||
| 988 | 988 | "ZM" => "\d{5}" |
| 989 | 989 | ); |
| 990 | 990 | |
| 991 | - if ( ! isset ( $zip_regex[ $country_code ] ) || preg_match( "/" . $zip_regex[ $country_code ] . "/i", $zip ) ) { |
|
| 991 | + if ( ! isset ($zip_regex[$country_code]) || preg_match("/".$zip_regex[$country_code]."/i", $zip)) { |
|
| 992 | 992 | $ret = true; |
| 993 | 993 | } |
| 994 | 994 | |
| 995 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code ); |
|
| 995 | + return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); |
|
| 996 | 996 | } |
| 997 | 997 | |
| 998 | 998 | |
@@ -1002,48 +1002,48 @@ discard block |
||
| 1002 | 1002 | * @since 1.0 |
| 1003 | 1003 | * @return void |
| 1004 | 1004 | */ |
| 1005 | -function give_check_purchase_email( $valid_data, $posted ) { |
|
| 1005 | +function give_check_purchase_email($valid_data, $posted) { |
|
| 1006 | 1006 | $is_banned = false; |
| 1007 | 1007 | $banned = give_get_banned_emails(); |
| 1008 | 1008 | |
| 1009 | - if ( empty( $banned ) ) { |
|
| 1009 | + if (empty($banned)) { |
|
| 1010 | 1010 | return; |
| 1011 | 1011 | } |
| 1012 | 1012 | |
| 1013 | - if ( is_user_logged_in() ) { |
|
| 1013 | + if (is_user_logged_in()) { |
|
| 1014 | 1014 | |
| 1015 | 1015 | // The user is logged in, check that their account email is not banned |
| 1016 | - $user_data = get_userdata( get_current_user_id() ); |
|
| 1017 | - if ( give_is_email_banned( $user_data->user_email ) ) { |
|
| 1016 | + $user_data = get_userdata(get_current_user_id()); |
|
| 1017 | + if (give_is_email_banned($user_data->user_email)) { |
|
| 1018 | 1018 | |
| 1019 | 1019 | $is_banned = true; |
| 1020 | 1020 | } |
| 1021 | 1021 | |
| 1022 | - if ( give_is_email_banned( $posted['give_email'] ) ) { |
|
| 1022 | + if (give_is_email_banned($posted['give_email'])) { |
|
| 1023 | 1023 | $is_banned = true; |
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | - } elseif ( isset( $posted['give-purchase-var'] ) && $posted['give-purchase-var'] == 'needs-to-login' ) { |
|
| 1026 | + } elseif (isset($posted['give-purchase-var']) && $posted['give-purchase-var'] == 'needs-to-login') { |
|
| 1027 | 1027 | |
| 1028 | 1028 | // The user is logging in, check that their email is not banned |
| 1029 | - $user_data = get_user_by( 'login', $posted['give_user_login'] ); |
|
| 1030 | - if ( $user_data && give_is_email_banned( $user_data->user_email ) ) { |
|
| 1029 | + $user_data = get_user_by('login', $posted['give_user_login']); |
|
| 1030 | + if ($user_data && give_is_email_banned($user_data->user_email)) { |
|
| 1031 | 1031 | $is_banned = true; |
| 1032 | 1032 | } |
| 1033 | 1033 | |
| 1034 | 1034 | } else { |
| 1035 | 1035 | |
| 1036 | 1036 | // Guest purchase, check that the email is not banned |
| 1037 | - if ( give_is_email_banned( $posted['give_email'] ) ) { |
|
| 1037 | + if (give_is_email_banned($posted['give_email'])) { |
|
| 1038 | 1038 | $is_banned = true; |
| 1039 | 1039 | } |
| 1040 | 1040 | |
| 1041 | 1041 | } |
| 1042 | 1042 | |
| 1043 | - if ( $is_banned ) { |
|
| 1043 | + if ($is_banned) { |
|
| 1044 | 1044 | // Set an error and give the donor a general error (don't alert them that they were banned) |
| 1045 | - give_set_error( 'email_banned', __( 'An internal error has occurred, please try again or contact support.', 'give' ) ); |
|
| 1045 | + give_set_error('email_banned', __('An internal error has occurred, please try again or contact support.', 'give')); |
|
| 1046 | 1046 | } |
| 1047 | 1047 | } |
| 1048 | 1048 | |
| 1049 | -add_action( 'give_checkout_error_checks', 'give_check_purchase_email', 10, 2 ); |
|
| 1049 | +add_action('give_checkout_error_checks', 'give_check_purchase_email', 10, 2); |
|
@@ -270,7 +270,7 @@ |
||
| 270 | 270 | * @access public |
| 271 | 271 | * @since 1.0 |
| 272 | 272 | * |
| 273 | - * @param $username string - the username to validate |
|
| 273 | + * @param string $username string - the username to validate |
|
| 274 | 274 | * |
| 275 | 275 | * @return bool |
| 276 | 276 | */ |
@@ -1,15 +1,15 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * User Functions |
|
| 4 | - * |
|
| 5 | - * Functions related to users / donors |
|
| 6 | - * |
|
| 7 | - * @package Give |
|
| 8 | - * @subpackage Functions |
|
| 9 | - * @copyright Copyright (c) 2015, WordImpress |
|
| 10 | - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
| 11 | - * @since 1.0 |
|
| 12 | - */ |
|
| 3 | + * User Functions |
|
| 4 | + * |
|
| 5 | + * Functions related to users / donors |
|
| 6 | + * |
|
| 7 | + * @package Give |
|
| 8 | + * @subpackage Functions |
|
| 9 | + * @copyright Copyright (c) 2015, WordImpress |
|
| 10 | + * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
| 11 | + * @since 1.0 |
|
| 12 | + */ |
|
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly |
| 15 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -30,36 +30,36 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return bool|object List of all user purchases |
| 32 | 32 | */ |
| 33 | -function give_get_users_purchases( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) { |
|
| 33 | +function give_get_users_purchases($user = 0, $number = 20, $pagination = false, $status = 'complete') { |
|
| 34 | 34 | |
| 35 | - if ( empty( $user ) ) { |
|
| 35 | + if (empty($user)) { |
|
| 36 | 36 | $user = get_current_user_id(); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - if ( 0 === $user ) { |
|
| 39 | + if (0 === $user) { |
|
| 40 | 40 | return false; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | $status = $status === 'complete' ? 'publish' : $status; |
| 44 | 44 | |
| 45 | - if ( $pagination ) { |
|
| 46 | - if ( get_query_var( 'paged' ) ) { |
|
| 47 | - $paged = get_query_var( 'paged' ); |
|
| 48 | - } else if ( get_query_var( 'page' ) ) { |
|
| 49 | - $paged = get_query_var( 'page' ); |
|
| 45 | + if ($pagination) { |
|
| 46 | + if (get_query_var('paged')) { |
|
| 47 | + $paged = get_query_var('paged'); |
|
| 48 | + } else if (get_query_var('page')) { |
|
| 49 | + $paged = get_query_var('page'); |
|
| 50 | 50 | } else { |
| 51 | 51 | $paged = 1; |
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - $args = apply_filters( 'give_get_users_purchases_args', array( |
|
| 55 | + $args = apply_filters('give_get_users_purchases_args', array( |
|
| 56 | 56 | 'user' => $user, |
| 57 | 57 | 'number' => $number, |
| 58 | 58 | 'status' => $status, |
| 59 | 59 | 'orderby' => 'date' |
| 60 | - ) ); |
|
| 60 | + )); |
|
| 61 | 61 | |
| 62 | - if ( $pagination ) { |
|
| 62 | + if ($pagination) { |
|
| 63 | 63 | |
| 64 | 64 | $args['page'] = $paged; |
| 65 | 65 | |
@@ -69,20 +69,20 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
| 73 | - $customer = new Give_Customer( $user, $by_user_id ); |
|
| 72 | + $by_user_id = is_numeric($user) ? true : false; |
|
| 73 | + $customer = new Give_Customer($user, $by_user_id); |
|
| 74 | 74 | |
| 75 | - if ( ! empty( $customer->payment_ids ) ) { |
|
| 75 | + if ( ! empty($customer->payment_ids)) { |
|
| 76 | 76 | |
| 77 | - unset( $args['user'] ); |
|
| 78 | - $args['post__in'] = array_map( 'absint', explode( ',', $customer->payment_ids ) ); |
|
| 77 | + unset($args['user']); |
|
| 78 | + $args['post__in'] = array_map('absint', explode(',', $customer->payment_ids)); |
|
| 79 | 79 | |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - $purchases = give_get_payments( apply_filters( 'give_get_users_purchases_args', $args ) ); |
|
| 82 | + $purchases = give_get_payments(apply_filters('give_get_users_purchases_args', $args)); |
|
| 83 | 83 | |
| 84 | 84 | // No purchases |
| 85 | - if ( ! $purchases ) { |
|
| 85 | + if ( ! $purchases) { |
|
| 86 | 86 | return false; |
| 87 | 87 | } |
| 88 | 88 | |
@@ -101,64 +101,64 @@ discard block |
||
| 101 | 101 | * |
| 102 | 102 | * @return bool|object List of unique forms purchased by user |
| 103 | 103 | */ |
| 104 | -function give_get_users_completed_donations( $user = 0, $status = 'complete' ) { |
|
| 105 | - if ( empty( $user ) ) { |
|
| 104 | +function give_get_users_completed_donations($user = 0, $status = 'complete') { |
|
| 105 | + if (empty($user)) { |
|
| 106 | 106 | $user = get_current_user_id(); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - if ( empty( $user ) ) { |
|
| 109 | + if (empty($user)) { |
|
| 110 | 110 | return false; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
| 113 | + $by_user_id = is_numeric($user) ? true : false; |
|
| 114 | 114 | |
| 115 | - $customer = new Give_Customer( $user, $by_user_id ); |
|
| 115 | + $customer = new Give_Customer($user, $by_user_id); |
|
| 116 | 116 | |
| 117 | - if ( empty( $customer->payment_ids ) ) { |
|
| 117 | + if (empty($customer->payment_ids)) { |
|
| 118 | 118 | return false; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | // Get all the items purchased |
| 122 | - $payment_ids = array_reverse( explode( ',', $customer->payment_ids ) ); |
|
| 123 | - $limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 ); |
|
| 124 | - if ( ! empty( $limit_payments ) ) { |
|
| 125 | - $payment_ids = array_slice( $payment_ids, 0, $limit_payments ); |
|
| 122 | + $payment_ids = array_reverse(explode(',', $customer->payment_ids)); |
|
| 123 | + $limit_payments = apply_filters('give_users_completed_donations_payments', 50); |
|
| 124 | + if ( ! empty($limit_payments)) { |
|
| 125 | + $payment_ids = array_slice($payment_ids, 0, $limit_payments); |
|
| 126 | 126 | } |
| 127 | 127 | $donation_data = array(); |
| 128 | - foreach ( $payment_ids as $payment_id ) { |
|
| 129 | - $donation_data[] = give_get_payment_meta( $payment_id ); |
|
| 128 | + foreach ($payment_ids as $payment_id) { |
|
| 129 | + $donation_data[] = give_get_payment_meta($payment_id); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - if ( empty( $donation_data ) ) { |
|
| 132 | + if (empty($donation_data)) { |
|
| 133 | 133 | return false; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // Grab only the post ids "form_id" of the forms purchased on this order |
| 137 | 137 | $completed_donations_ids = array(); |
| 138 | - foreach ( $donation_data as $purchase_meta ) { |
|
| 138 | + foreach ($donation_data as $purchase_meta) { |
|
| 139 | 139 | $completed_donations_ids[] = $purchase_meta['form_id']; |
| 140 | 140 | } |
| 141 | - if ( empty( $completed_donations_ids ) ) { |
|
| 141 | + if (empty($completed_donations_ids)) { |
|
| 142 | 142 | return false; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | // Only include each product purchased once |
| 146 | - $form_ids = array_unique( $completed_donations_ids ); |
|
| 146 | + $form_ids = array_unique($completed_donations_ids); |
|
| 147 | 147 | |
| 148 | 148 | // Make sure we still have some products and a first item |
| 149 | - if ( empty ( $form_ids ) || ! isset( $form_ids[0] ) ) { |
|
| 149 | + if (empty ($form_ids) || ! isset($form_ids[0])) { |
|
| 150 | 150 | return false; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - $post_type = get_post_type( $form_ids[0] ); |
|
| 153 | + $post_type = get_post_type($form_ids[0]); |
|
| 154 | 154 | |
| 155 | - $args = apply_filters( 'give_get_users_completed_donations_args', array( |
|
| 155 | + $args = apply_filters('give_get_users_completed_donations_args', array( |
|
| 156 | 156 | 'include' => $form_ids, |
| 157 | 157 | 'post_type' => $post_type, |
| 158 | - 'posts_per_page' => - 1 |
|
| 159 | - ) ); |
|
| 158 | + 'posts_per_page' => -1 |
|
| 159 | + )); |
|
| 160 | 160 | |
| 161 | - return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) ); |
|
| 161 | + return apply_filters('give_users_completed_donations_list', get_posts($args)); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | |
@@ -174,12 +174,12 @@ discard block |
||
| 174 | 174 | * |
| 175 | 175 | * @return bool - true if has purchased, false other wise. |
| 176 | 176 | */ |
| 177 | -function give_has_purchases( $user_id = null ) { |
|
| 178 | - if ( empty( $user_id ) ) { |
|
| 177 | +function give_has_purchases($user_id = null) { |
|
| 178 | + if (empty($user_id)) { |
|
| 179 | 179 | $user_id = get_current_user_id(); |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - if ( give_get_users_purchases( $user_id, 1 ) ) { |
|
| 182 | + if (give_get_users_purchases($user_id, 1)) { |
|
| 183 | 183 | return true; // User has at least one purchase |
| 184 | 184 | } |
| 185 | 185 | |
@@ -200,27 +200,27 @@ discard block |
||
| 200 | 200 | * |
| 201 | 201 | * @return array |
| 202 | 202 | */ |
| 203 | -function give_get_purchase_stats_by_user( $user = '' ) { |
|
| 203 | +function give_get_purchase_stats_by_user($user = '') { |
|
| 204 | 204 | |
| 205 | - if ( is_email( $user ) ) { |
|
| 205 | + if (is_email($user)) { |
|
| 206 | 206 | |
| 207 | 207 | $field = 'email'; |
| 208 | 208 | |
| 209 | - } elseif ( is_numeric( $user ) ) { |
|
| 209 | + } elseif (is_numeric($user)) { |
|
| 210 | 210 | |
| 211 | 211 | $field = 'user_id'; |
| 212 | 212 | |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - $customer = Give()->customers->get_customer_by( $field, $user ); |
|
| 215 | + $customer = Give()->customers->get_customer_by($field, $user); |
|
| 216 | 216 | |
| 217 | - $customer = new Give_Customer( $customer->id ); |
|
| 217 | + $customer = new Give_Customer($customer->id); |
|
| 218 | 218 | |
| 219 | 219 | $stats = array(); |
| 220 | - $stats['purchases'] = absint( $customer->purchase_count ); |
|
| 221 | - $stats['total_spent'] = give_sanitize_amount( $customer->purchase_value ); |
|
| 220 | + $stats['purchases'] = absint($customer->purchase_count); |
|
| 221 | + $stats['total_spent'] = give_sanitize_amount($customer->purchase_value); |
|
| 222 | 222 | |
| 223 | - return (array) apply_filters( 'give_donation_stats_by_user', $stats, $user ); |
|
| 223 | + return (array) apply_filters('give_donation_stats_by_user', $stats, $user); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | |
@@ -236,14 +236,14 @@ discard block |
||
| 236 | 236 | * |
| 237 | 237 | * @return int - the total number of purchases |
| 238 | 238 | */ |
| 239 | -function give_count_purchases_of_customer( $user = null ) { |
|
| 240 | - if ( empty( $user ) ) { |
|
| 239 | +function give_count_purchases_of_customer($user = null) { |
|
| 240 | + if (empty($user)) { |
|
| 241 | 241 | $user = get_current_user_id(); |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | - $stats = give_get_purchase_stats_by_user( $user ); |
|
| 244 | + $stats = give_get_purchase_stats_by_user($user); |
|
| 245 | 245 | |
| 246 | - return isset( $stats['purchases'] ) ? $stats['purchases'] : 0; |
|
| 246 | + return isset($stats['purchases']) ? $stats['purchases'] : 0; |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** |
@@ -256,9 +256,9 @@ discard block |
||
| 256 | 256 | * |
| 257 | 257 | * @return float - the total amount the user has spent |
| 258 | 258 | */ |
| 259 | -function give_purchase_total_of_user( $user = null ) { |
|
| 259 | +function give_purchase_total_of_user($user = null) { |
|
| 260 | 260 | |
| 261 | - $stats = give_get_purchase_stats_by_user( $user ); |
|
| 261 | + $stats = give_get_purchase_stats_by_user($user); |
|
| 262 | 262 | |
| 263 | 263 | return $stats['total_spent']; |
| 264 | 264 | } |
@@ -274,11 +274,11 @@ discard block |
||
| 274 | 274 | * |
| 275 | 275 | * @return bool |
| 276 | 276 | */ |
| 277 | -function give_validate_username( $username ) { |
|
| 278 | - $sanitized = sanitize_user( $username, false ); |
|
| 279 | - $valid = ( $sanitized == $username ); |
|
| 277 | +function give_validate_username($username) { |
|
| 278 | + $sanitized = sanitize_user($username, false); |
|
| 279 | + $valid = ($sanitized == $username); |
|
| 280 | 280 | |
| 281 | - return (bool) apply_filters( 'give_validate_username', $valid, $username ); |
|
| 281 | + return (bool) apply_filters('give_validate_username', $valid, $username); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | |
@@ -295,32 +295,32 @@ discard block |
||
| 295 | 295 | * |
| 296 | 296 | * @return void |
| 297 | 297 | */ |
| 298 | -function give_add_past_purchases_to_new_user( $user_id ) { |
|
| 298 | +function give_add_past_purchases_to_new_user($user_id) { |
|
| 299 | 299 | |
| 300 | - $email = get_the_author_meta( 'user_email', $user_id ); |
|
| 300 | + $email = get_the_author_meta('user_email', $user_id); |
|
| 301 | 301 | |
| 302 | - $payments = give_get_payments( array( 's' => $email ) ); |
|
| 302 | + $payments = give_get_payments(array('s' => $email)); |
|
| 303 | 303 | |
| 304 | - if ( $payments ) { |
|
| 305 | - foreach ( $payments as $payment ) { |
|
| 306 | - if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) { |
|
| 304 | + if ($payments) { |
|
| 305 | + foreach ($payments as $payment) { |
|
| 306 | + if (intval(give_get_payment_user_id($payment->ID)) > 0) { |
|
| 307 | 307 | continue; |
| 308 | 308 | } // This payment already associated with an account |
| 309 | 309 | |
| 310 | - $meta = give_get_payment_meta( $payment->ID ); |
|
| 311 | - $meta['user_info'] = maybe_unserialize( $meta['user_info'] ); |
|
| 310 | + $meta = give_get_payment_meta($payment->ID); |
|
| 311 | + $meta['user_info'] = maybe_unserialize($meta['user_info']); |
|
| 312 | 312 | $meta['user_info']['id'] = $user_id; |
| 313 | 313 | $meta['user_info'] = $meta['user_info']; |
| 314 | 314 | |
| 315 | 315 | // Store the updated user ID in the payment meta |
| 316 | - give_update_payment_meta( $payment->ID, '_give_payment_meta', $meta ); |
|
| 317 | - give_update_payment_meta( $payment->ID, '_give_payment_user_id', $user_id ); |
|
| 316 | + give_update_payment_meta($payment->ID, '_give_payment_meta', $meta); |
|
| 317 | + give_update_payment_meta($payment->ID, '_give_payment_user_id', $user_id); |
|
| 318 | 318 | } |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | -add_action( 'user_register', 'give_add_past_purchases_to_new_user' ); |
|
| 323 | +add_action('user_register', 'give_add_past_purchases_to_new_user'); |
|
| 324 | 324 | |
| 325 | 325 | |
| 326 | 326 | /** |
@@ -342,34 +342,34 @@ discard block |
||
| 342 | 342 | * @since 1.0 |
| 343 | 343 | * @return array - The donor's address, if any |
| 344 | 344 | */ |
| 345 | -function give_get_donor_address( $user_id = 0 ) { |
|
| 346 | - if ( empty( $user_id ) ) { |
|
| 345 | +function give_get_donor_address($user_id = 0) { |
|
| 346 | + if (empty($user_id)) { |
|
| 347 | 347 | $user_id = get_current_user_id(); |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | - $address = get_user_meta( $user_id, '_give_user_address', true ); |
|
| 350 | + $address = get_user_meta($user_id, '_give_user_address', true); |
|
| 351 | 351 | |
| 352 | - if ( ! isset( $address['line1'] ) ) { |
|
| 352 | + if ( ! isset($address['line1'])) { |
|
| 353 | 353 | $address['line1'] = ''; |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - if ( ! isset( $address['line2'] ) ) { |
|
| 356 | + if ( ! isset($address['line2'])) { |
|
| 357 | 357 | $address['line2'] = ''; |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - if ( ! isset( $address['city'] ) ) { |
|
| 360 | + if ( ! isset($address['city'])) { |
|
| 361 | 361 | $address['city'] = ''; |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | - if ( ! isset( $address['zip'] ) ) { |
|
| 364 | + if ( ! isset($address['zip'])) { |
|
| 365 | 365 | $address['zip'] = ''; |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - if ( ! isset( $address['country'] ) ) { |
|
| 368 | + if ( ! isset($address['country'])) { |
|
| 369 | 369 | $address['country'] = ''; |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - if ( ! isset( $address['state'] ) ) { |
|
| 372 | + if ( ! isset($address['state'])) { |
|
| 373 | 373 | $address['state'] = ''; |
| 374 | 374 | } |
| 375 | 375 | |
@@ -383,13 +383,13 @@ discard block |
||
| 383 | 383 | * @since 1.0 |
| 384 | 384 | * @return void |
| 385 | 385 | */ |
| 386 | -function give_new_user_notification( $user_id = 0, $user_data = array() ) { |
|
| 386 | +function give_new_user_notification($user_id = 0, $user_data = array()) { |
|
| 387 | 387 | |
| 388 | - if ( empty( $user_id ) || empty( $user_data ) ) { |
|
| 388 | + if (empty($user_id) || empty($user_data)) { |
|
| 389 | 389 | return; |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - wp_new_user_notification( $user_id, __( '[Password entered during donation]', 'give' ) ); |
|
| 392 | + wp_new_user_notification($user_id, __('[Password entered during donation]', 'give')); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | -add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 ); |
|
| 395 | +add_action('give_insert_user', 'give_new_user_notification', 10, 2); |
|
@@ -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,12 +23,12 @@ discard block |
||
| 23 | 23 | * @return void |
| 24 | 24 | */ |
| 25 | 25 | function give_get_actions() { |
| 26 | - if ( isset( $_GET['give_action'] ) ) { |
|
| 27 | - do_action( 'give_' . $_GET['give_action'], $_GET ); |
|
| 26 | + if (isset($_GET['give_action'])) { |
|
| 27 | + do_action('give_'.$_GET['give_action'], $_GET); |
|
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | -add_action( 'init', 'give_get_actions' ); |
|
| 31 | +add_action('init', 'give_get_actions'); |
|
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * Hooks Give actions, when present in the $_POST superglobal. Every give_action |
@@ -39,9 +39,9 @@ discard block |
||
| 39 | 39 | * @return void |
| 40 | 40 | */ |
| 41 | 41 | function give_post_actions() { |
| 42 | - if ( isset( $_POST['give_action'] ) ) { |
|
| 43 | - do_action( 'give_' . $_POST['give_action'], $_POST ); |
|
| 42 | + if (isset($_POST['give_action'])) { |
|
| 43 | + do_action('give_'.$_POST['give_action'], $_POST); |
|
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | -add_action( 'init', 'give_post_actions' ); |
|
| 48 | 47 | \ No newline at end of file |
| 48 | +add_action('init', 'give_post_actions'); |
|
| 49 | 49 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -25,12 +25,12 @@ discard block |
||
| 25 | 25 | function give_add_ons_page() { |
| 26 | 26 | ob_start(); ?> |
| 27 | 27 | <div class="wrap" id="give-add-ons"> |
| 28 | - <h2><?php _e( 'Give Add-ons', 'give' ); ?> |
|
| 29 | - — <a href="https://givewp.com/addons/" class="button-primary give-view-addons-all" title="<?php _e( 'Browse All Extensions', 'give' ); ?>" target="_blank"><?php _e( 'View All Add-ons', 'give' ); ?> |
|
| 28 | + <h2><?php _e('Give Add-ons', 'give'); ?> |
|
| 29 | + — <a href="https://givewp.com/addons/" class="button-primary give-view-addons-all" title="<?php _e('Browse All Extensions', 'give'); ?>" target="_blank"><?php _e('View All Add-ons', 'give'); ?> |
|
| 30 | 30 | <span class="dashicons dashicons-external"></span></a> |
| 31 | 31 | </h2> |
| 32 | 32 | |
| 33 | - <p><?php _e( 'The following Add-ons extend the functionality of Give.', 'give' ); ?></p> |
|
| 33 | + <p><?php _e('The following Add-ons extend the functionality of Give.', 'give'); ?></p> |
|
| 34 | 34 | <?php echo give_add_ons_get_feed(); ?> |
| 35 | 35 | </div> |
| 36 | 36 | <?php |
@@ -48,18 +48,18 @@ discard block |
||
| 48 | 48 | function give_add_ons_get_feed() { |
| 49 | 49 | |
| 50 | 50 | $addons_debug = false; //set to true to debug |
| 51 | - $cache = get_transient( 'give_add_ons_feed' ); |
|
| 51 | + $cache = get_transient('give_add_ons_feed'); |
|
| 52 | 52 | |
| 53 | - if ( $cache === false || $addons_debug === true && WP_DEBUG === true ) { |
|
| 54 | - $feed = wp_remote_get( 'https://givewp.com/downloads/feed/', array( 'sslverify' => false ) ); |
|
| 53 | + if ($cache === false || $addons_debug === true && WP_DEBUG === true) { |
|
| 54 | + $feed = wp_remote_get('https://givewp.com/downloads/feed/', array('sslverify' => false)); |
|
| 55 | 55 | |
| 56 | - if ( ! is_wp_error( $feed ) ) { |
|
| 57 | - if ( isset( $feed['body'] ) && strlen( $feed['body'] ) > 0 ) { |
|
| 58 | - $cache = wp_remote_retrieve_body( $feed ); |
|
| 59 | - set_transient( 'give_add_ons_feed', $cache, 3600 ); |
|
| 56 | + if ( ! is_wp_error($feed)) { |
|
| 57 | + if (isset($feed['body']) && strlen($feed['body']) > 0) { |
|
| 58 | + $cache = wp_remote_retrieve_body($feed); |
|
| 59 | + set_transient('give_add_ons_feed', $cache, 3600); |
|
| 60 | 60 | } |
| 61 | 61 | } else { |
| 62 | - $cache = '<div class="error"><p>' . __( 'There was an error retrieving the Give Add-ons list from the server. Please try again later.', 'give' ) . '</div>'; |
|
| 62 | + $cache = '<div class="error"><p>'.__('There was an error retrieving the Give Add-ons list from the server. Please try again later.', 'give').'</div>'; |
|
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | |
@@ -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 | |
@@ -22,13 +22,13 @@ discard block |
||
| 22 | 22 | * @return void |
| 23 | 23 | */ |
| 24 | 24 | function give_process_actions() { |
| 25 | - if ( isset( $_POST['give-action'] ) ) { |
|
| 26 | - do_action( 'give_' . $_POST['give-action'], $_POST ); |
|
| 25 | + if (isset($_POST['give-action'])) { |
|
| 26 | + do_action('give_'.$_POST['give-action'], $_POST); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - if ( isset( $_GET['give-action'] ) ) { |
|
| 30 | - do_action( 'give_' . $_GET['give-action'], $_GET ); |
|
| 29 | + if (isset($_GET['give-action'])) { |
|
| 30 | + do_action('give_'.$_GET['give-action'], $_GET); |
|
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | -add_action( 'admin_init', 'give_process_actions' ); |
|
| 35 | 34 | \ No newline at end of file |
| 35 | +add_action('admin_init', 'give_process_actions'); |
|
| 36 | 36 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -24,11 +24,11 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @return string |
| 26 | 26 | */ |
| 27 | -function give_admin_rate_us( $footer_text ) { |
|
| 27 | +function give_admin_rate_us($footer_text) { |
|
| 28 | 28 | global $typenow; |
| 29 | 29 | |
| 30 | - if ( $typenow == 'give_forms' ) { |
|
| 31 | - $rate_text = sprintf( __( 'If you like <strong>Give</strong> please leave us a %s★★★★★%s rating. It takes a minute and helps a lot. Thanks in advance!', 'give' ), '<a href="https://wordpress.org/support/view/plugin-reviews/give?filter=5#postform" target="_blank" class="give-rating-link" data-rated="' . __( 'Thanks :)', 'give' ) . '">', '</a>' ); |
|
| 30 | + if ($typenow == 'give_forms') { |
|
| 31 | + $rate_text = sprintf(__('If you like <strong>Give</strong> please leave us a %s★★★★★%s rating. It takes a minute and helps a lot. Thanks in advance!', 'give'), '<a href="https://wordpress.org/support/view/plugin-reviews/give?filter=5#postform" target="_blank" class="give-rating-link" data-rated="'.__('Thanks :)', 'give').'">', '</a>'); |
|
| 32 | 32 | |
| 33 | 33 | return $rate_text; |
| 34 | 34 | } else { |
@@ -36,4 +36,4 @@ discard block |
||
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | -add_filter( 'admin_footer_text', 'give_admin_rate_us' ); |
|
| 39 | +add_filter('admin_footer_text', 'give_admin_rate_us'); |
|
@@ -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 | |
@@ -34,31 +34,31 @@ discard block |
||
| 34 | 34 | // $give_campaigns_page = add_submenu_page( 'edit.php?post_type=give_forms', $give_campaigns->labels->menu_name, $give_campaigns->labels->add_new, 'edit_' . $give_campaigns->capability_type . 's', 'post-new.php?post_type=give_campaigns', null ); |
| 35 | 35 | |
| 36 | 36 | //Payments |
| 37 | - $give_payment = get_post_type_object( 'give_payment' ); |
|
| 38 | - $give_payments_page = add_submenu_page( 'edit.php?post_type=give_forms', $give_payment->labels->name, $give_payment->labels->menu_name, 'edit_give_payments', 'give-payment-history', 'give_payment_history_page' ); |
|
| 37 | + $give_payment = get_post_type_object('give_payment'); |
|
| 38 | + $give_payments_page = add_submenu_page('edit.php?post_type=give_forms', $give_payment->labels->name, $give_payment->labels->menu_name, 'edit_give_payments', 'give-payment-history', 'give_payment_history_page'); |
|
| 39 | 39 | |
| 40 | 40 | //Donors |
| 41 | - $give_donors_page = add_submenu_page( 'edit.php?post_type=give_forms', __( 'Donors', 'give' ), __( 'Donors', 'give' ), 'view_give_reports', 'give-donors', 'give_customers_page' ); |
|
| 41 | + $give_donors_page = add_submenu_page('edit.php?post_type=give_forms', __('Donors', 'give'), __('Donors', 'give'), 'view_give_reports', 'give-donors', 'give_customers_page'); |
|
| 42 | 42 | |
| 43 | 43 | //Reports |
| 44 | - $give_reports_page = add_submenu_page( 'edit.php?post_type=give_forms', __( 'Donation Reports', 'give' ), __( 'Reports', 'give' ), 'view_give_reports', 'give-reports', 'give_reports_page' ); |
|
| 44 | + $give_reports_page = add_submenu_page('edit.php?post_type=give_forms', __('Donation Reports', 'give'), __('Reports', 'give'), 'view_give_reports', 'give-reports', 'give_reports_page'); |
|
| 45 | 45 | |
| 46 | 46 | //Settings |
| 47 | - $give_settings_page = add_submenu_page( 'edit.php?post_type=give_forms', __( 'Give Settings', 'give' ), __( 'Settings', 'give' ), 'manage_give_settings', 'give-settings', array( |
|
| 47 | + $give_settings_page = add_submenu_page('edit.php?post_type=give_forms', __('Give Settings', 'give'), __('Settings', 'give'), 'manage_give_settings', 'give-settings', array( |
|
| 48 | 48 | Give()->give_settings, |
| 49 | 49 | 'admin_page_display' |
| 50 | - ) ); |
|
| 50 | + )); |
|
| 51 | 51 | |
| 52 | 52 | //Add-ons |
| 53 | - $give_add_ons_page = add_submenu_page( 'edit.php?post_type=give_forms', __( 'Give Add-ons', 'give' ), __( 'Add-ons', 'give' ), 'install_plugins', 'give-addons', 'give_add_ons_page' ); |
|
| 53 | + $give_add_ons_page = add_submenu_page('edit.php?post_type=give_forms', __('Give Add-ons', 'give'), __('Add-ons', 'give'), 'install_plugins', 'give-addons', 'give_add_ons_page'); |
|
| 54 | 54 | |
| 55 | 55 | //Upgrades |
| 56 | - $give_upgrades_screen = add_submenu_page( null, __( 'Give Upgrades', 'give' ), __( 'Give Upgrades', 'give' ), 'manage_give_settings', 'give-upgrades', 'give_upgrades_screen' ); |
|
| 56 | + $give_upgrades_screen = add_submenu_page(null, __('Give Upgrades', 'give'), __('Give Upgrades', 'give'), 'manage_give_settings', 'give-upgrades', 'give_upgrades_screen'); |
|
| 57 | 57 | |
| 58 | 58 | |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | -add_action( 'admin_menu', 'give_add_options_links', 10 ); |
|
| 61 | +add_action('admin_menu', 'give_add_options_links', 10); |
|
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | 64 | * Determines whether the current admin page is a Give admin page. |
@@ -73,224 +73,224 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * @return bool True if Give admin page. |
| 75 | 75 | */ |
| 76 | -function give_is_admin_page( $passed_page = '', $passed_view = '' ) { |
|
| 76 | +function give_is_admin_page($passed_page = '', $passed_view = '') { |
|
| 77 | 77 | |
| 78 | 78 | global $pagenow, $typenow; |
| 79 | 79 | |
| 80 | 80 | $found = false; |
| 81 | - $post_type = isset( $_GET['post_type'] ) ? strtolower( $_GET['post_type'] ) : false; |
|
| 82 | - $action = isset( $_GET['action'] ) ? strtolower( $_GET['action'] ) : false; |
|
| 83 | - $taxonomy = isset( $_GET['taxonomy'] ) ? strtolower( $_GET['taxonomy'] ) : false; |
|
| 84 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
| 85 | - $view = isset( $_GET['view'] ) ? strtolower( $_GET['view'] ) : false; |
|
| 86 | - $tab = isset( $_GET['tab'] ) ? strtolower( $_GET['tab'] ) : false; |
|
| 81 | + $post_type = isset($_GET['post_type']) ? strtolower($_GET['post_type']) : false; |
|
| 82 | + $action = isset($_GET['action']) ? strtolower($_GET['action']) : false; |
|
| 83 | + $taxonomy = isset($_GET['taxonomy']) ? strtolower($_GET['taxonomy']) : false; |
|
| 84 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
| 85 | + $view = isset($_GET['view']) ? strtolower($_GET['view']) : false; |
|
| 86 | + $tab = isset($_GET['tab']) ? strtolower($_GET['tab']) : false; |
|
| 87 | 87 | |
| 88 | - switch ( $passed_page ) { |
|
| 88 | + switch ($passed_page) { |
|
| 89 | 89 | case 'give_forms': |
| 90 | - switch ( $passed_view ) { |
|
| 90 | + switch ($passed_view) { |
|
| 91 | 91 | case 'list-table': |
| 92 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' ) { |
|
| 92 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php') { |
|
| 93 | 93 | $found = true; |
| 94 | 94 | } |
| 95 | 95 | break; |
| 96 | 96 | case 'edit': |
| 97 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'post.php' ) { |
|
| 97 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'post.php') { |
|
| 98 | 98 | $found = true; |
| 99 | 99 | } |
| 100 | 100 | break; |
| 101 | 101 | case 'new': |
| 102 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'post-new.php' ) { |
|
| 102 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'post-new.php') { |
|
| 103 | 103 | $found = true; |
| 104 | 104 | } |
| 105 | 105 | break; |
| 106 | 106 | default: |
| 107 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) || 'give_forms' === $post_type || ( 'post-new.php' == $pagenow && 'give_forms' === $post_type ) ) { |
|
| 107 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) || 'give_forms' === $post_type || ('post-new.php' == $pagenow && 'give_forms' === $post_type)) { |
|
| 108 | 108 | $found = true; |
| 109 | 109 | } |
| 110 | 110 | break; |
| 111 | 111 | } |
| 112 | 112 | break; |
| 113 | 113 | case 'categories': |
| 114 | - switch ( $passed_view ) { |
|
| 114 | + switch ($passed_view) { |
|
| 115 | 115 | case 'list-table': |
| 116 | 116 | case 'new': |
| 117 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_category' === $taxonomy ) { |
|
| 117 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_category' === $taxonomy) { |
|
| 118 | 118 | $found = true; |
| 119 | 119 | } |
| 120 | 120 | break; |
| 121 | 121 | case 'edit': |
| 122 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_category' === $taxonomy ) { |
|
| 122 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_category' === $taxonomy) { |
|
| 123 | 123 | $found = true; |
| 124 | 124 | } |
| 125 | 125 | break; |
| 126 | 126 | default: |
| 127 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'give_forms_category' === $taxonomy ) { |
|
| 127 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'give_forms_category' === $taxonomy) { |
|
| 128 | 128 | $found = true; |
| 129 | 129 | } |
| 130 | 130 | break; |
| 131 | 131 | } |
| 132 | 132 | break; |
| 133 | 133 | case 'tags': |
| 134 | - switch ( $passed_view ) { |
|
| 134 | + switch ($passed_view) { |
|
| 135 | 135 | case 'list-table': |
| 136 | 136 | case 'new': |
| 137 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_tag' === $taxonomy ) { |
|
| 137 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_tag' === $taxonomy) { |
|
| 138 | 138 | $found = true; |
| 139 | 139 | } |
| 140 | 140 | break; |
| 141 | 141 | case 'edit': |
| 142 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_tag' === $taxonomy ) { |
|
| 142 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_tag' === $taxonomy) { |
|
| 143 | 143 | $found = true; |
| 144 | 144 | } |
| 145 | 145 | break; |
| 146 | 146 | default: |
| 147 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'give_forms_tag' === $taxonomy ) { |
|
| 147 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'give_forms_tag' === $taxonomy) { |
|
| 148 | 148 | $found = true; |
| 149 | 149 | } |
| 150 | 150 | break; |
| 151 | 151 | } |
| 152 | 152 | break; |
| 153 | 153 | case 'payments': |
| 154 | - switch ( $passed_view ) { |
|
| 154 | + switch ($passed_view) { |
|
| 155 | 155 | case 'list-table': |
| 156 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page && false === $view ) { |
|
| 156 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-payment-history' === $page && false === $view) { |
|
| 157 | 157 | $found = true; |
| 158 | 158 | } |
| 159 | 159 | break; |
| 160 | 160 | case 'edit': |
| 161 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page && 'view-order-details' === $view ) { |
|
| 161 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-payment-history' === $page && 'view-order-details' === $view) { |
|
| 162 | 162 | $found = true; |
| 163 | 163 | } |
| 164 | 164 | break; |
| 165 | 165 | default: |
| 166 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page ) { |
|
| 166 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-payment-history' === $page) { |
|
| 167 | 167 | $found = true; |
| 168 | 168 | } |
| 169 | 169 | break; |
| 170 | 170 | } |
| 171 | 171 | break; |
| 172 | 172 | case 'reports': |
| 173 | - switch ( $passed_view ) { |
|
| 173 | + switch ($passed_view) { |
|
| 174 | 174 | // If you want to do something like enqueue a script on a particular report's duration, look at $_GET[ 'range' ] |
| 175 | 175 | case 'earnings': |
| 176 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && ( 'earnings' === $view || '-1' === $view || false === $view ) ) { |
|
| 176 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && ('earnings' === $view || '-1' === $view || false === $view)) { |
|
| 177 | 177 | $found = true; |
| 178 | 178 | } |
| 179 | 179 | break; |
| 180 | 180 | case 'donors': |
| 181 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'customers' === $view ) { |
|
| 181 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'customers' === $view) { |
|
| 182 | 182 | $found = true; |
| 183 | 183 | } |
| 184 | 184 | break; |
| 185 | 185 | case 'gateways': |
| 186 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'gateways' === $view ) { |
|
| 186 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'gateways' === $view) { |
|
| 187 | 187 | $found = true; |
| 188 | 188 | } |
| 189 | 189 | break; |
| 190 | 190 | case 'export': |
| 191 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'export' === $view ) { |
|
| 191 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'export' === $view) { |
|
| 192 | 192 | $found = true; |
| 193 | 193 | } |
| 194 | 194 | break; |
| 195 | 195 | case 'logs': |
| 196 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'logs' === $view ) { |
|
| 196 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'logs' === $view) { |
|
| 197 | 197 | $found = true; |
| 198 | 198 | } |
| 199 | 199 | break; |
| 200 | 200 | default: |
| 201 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page ) { |
|
| 201 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page) { |
|
| 202 | 202 | $found = true; |
| 203 | 203 | } |
| 204 | 204 | break; |
| 205 | 205 | } |
| 206 | 206 | break; |
| 207 | 207 | case 'settings': |
| 208 | - switch ( $passed_view ) { |
|
| 208 | + switch ($passed_view) { |
|
| 209 | 209 | case 'general': |
| 210 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && ( 'general' === $tab || false === $tab ) ) { |
|
| 210 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && ('general' === $tab || false === $tab)) { |
|
| 211 | 211 | $found = true; |
| 212 | 212 | } |
| 213 | 213 | break; |
| 214 | 214 | case 'gateways': |
| 215 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'gateways' === $tab ) { |
|
| 215 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'gateways' === $tab) { |
|
| 216 | 216 | $found = true; |
| 217 | 217 | } |
| 218 | 218 | break; |
| 219 | 219 | case 'emails': |
| 220 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'emails' === $tab ) { |
|
| 220 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'emails' === $tab) { |
|
| 221 | 221 | $found = true; |
| 222 | 222 | } |
| 223 | 223 | break; |
| 224 | 224 | case 'display': |
| 225 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'display' === $tab ) { |
|
| 225 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'display' === $tab) { |
|
| 226 | 226 | $found = true; |
| 227 | 227 | } |
| 228 | 228 | break; |
| 229 | 229 | case 'licenses': |
| 230 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'licenses' === $tab ) { |
|
| 230 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'licenses' === $tab) { |
|
| 231 | 231 | $found = true; |
| 232 | 232 | } |
| 233 | 233 | break; |
| 234 | 234 | case 'api': |
| 235 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'api' === $tab ) { |
|
| 235 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'api' === $tab) { |
|
| 236 | 236 | $found = true; |
| 237 | 237 | } |
| 238 | 238 | break; |
| 239 | 239 | case 'advanced': |
| 240 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'advanced' === $tab ) { |
|
| 240 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'advanced' === $tab) { |
|
| 241 | 241 | $found = true; |
| 242 | 242 | } |
| 243 | 243 | break; |
| 244 | 244 | case 'system_info': |
| 245 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'system_info' === $tab ) { |
|
| 245 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'system_info' === $tab) { |
|
| 246 | 246 | $found = true; |
| 247 | 247 | } |
| 248 | 248 | break; |
| 249 | 249 | default: |
| 250 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page ) { |
|
| 250 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page) { |
|
| 251 | 251 | $found = true; |
| 252 | 252 | } |
| 253 | 253 | break; |
| 254 | 254 | } |
| 255 | 255 | break; |
| 256 | 256 | case 'addons': |
| 257 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-addons' === $page ) { |
|
| 257 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-addons' === $page) { |
|
| 258 | 258 | $found = true; |
| 259 | 259 | } |
| 260 | 260 | break; |
| 261 | 261 | case 'donors': |
| 262 | - switch ( $passed_view ) { |
|
| 262 | + switch ($passed_view) { |
|
| 263 | 263 | case 'list-table': |
| 264 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && false === $view ) { |
|
| 264 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page && false === $view) { |
|
| 265 | 265 | $found = true; |
| 266 | 266 | } |
| 267 | 267 | break; |
| 268 | 268 | case 'overview': |
| 269 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && 'overview' === $view ) { |
|
| 269 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page && 'overview' === $view) { |
|
| 270 | 270 | $found = true; |
| 271 | 271 | } |
| 272 | 272 | break; |
| 273 | 273 | case 'notes': |
| 274 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && 'notes' === $view ) { |
|
| 274 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page && 'notes' === $view) { |
|
| 275 | 275 | $found = true; |
| 276 | 276 | } |
| 277 | 277 | break; |
| 278 | 278 | default: |
| 279 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page ) { |
|
| 279 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page) { |
|
| 280 | 280 | $found = true; |
| 281 | 281 | } |
| 282 | 282 | break; |
| 283 | 283 | } |
| 284 | 284 | break; |
| 285 | 285 | case 'reports': |
| 286 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page ) { |
|
| 286 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page) { |
|
| 287 | 287 | $found = true; |
| 288 | 288 | } |
| 289 | 289 | break; |
| 290 | 290 | default: |
| 291 | 291 | global $give_payments_page, $give_settings_page, $give_reports_page, $give_system_info_page, $give_add_ons_page, $give_settings_export, $give_upgrades_screen, $give_customers_page; |
| 292 | 292 | |
| 293 | - $admin_pages = apply_filters( 'give_admin_pages', array( |
|
| 293 | + $admin_pages = apply_filters('give_admin_pages', array( |
|
| 294 | 294 | $give_payments_page, |
| 295 | 295 | $give_settings_page, |
| 296 | 296 | $give_reports_page, |
@@ -299,18 +299,18 @@ discard block |
||
| 299 | 299 | $give_upgrades_screen, |
| 300 | 300 | $give_settings_export, |
| 301 | 301 | $give_customers_page |
| 302 | - ) ); |
|
| 303 | - if ( 'give_forms' == $typenow || 'index.php' == $pagenow || 'post-new.php' == $pagenow || 'post.php' == $pagenow ) { |
|
| 302 | + )); |
|
| 303 | + if ('give_forms' == $typenow || 'index.php' == $pagenow || 'post-new.php' == $pagenow || 'post.php' == $pagenow) { |
|
| 304 | 304 | $found = true; |
| 305 | - if ( 'give-upgrades' === $page ) { |
|
| 305 | + if ('give-upgrades' === $page) { |
|
| 306 | 306 | $found = false; |
| 307 | 307 | } |
| 308 | - } elseif ( in_array( $pagenow, $admin_pages ) ) { |
|
| 308 | + } elseif (in_array($pagenow, $admin_pages)) { |
|
| 309 | 309 | $found = true; |
| 310 | 310 | } |
| 311 | 311 | break; |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - return (bool) apply_filters( 'give_is_admin_page', $found, $page, $view, $passed_page, $passed_view ); |
|
| 314 | + return (bool) apply_filters('give_is_admin_page', $found, $page, $view, $passed_page, $passed_view); |
|
| 315 | 315 | |
| 316 | 316 | } |
| 317 | 317 | \ No newline at end of file |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | |
| 11 | 11 | // Exit if accessed directly |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; |
| 14 | 14 | } |
| 15 | 15 | |
@@ -24,12 +24,12 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @param $_banner_details |
| 26 | 26 | */ |
| 27 | - function __construct( $_banner_details ) { |
|
| 27 | + function __construct($_banner_details) { |
|
| 28 | 28 | |
| 29 | 29 | global $current_user; |
| 30 | 30 | $this->banner_details = $_banner_details; |
| 31 | - $this->test_mode = ( $this->banner_details['testing'] == 'true' ) ? true : false; |
|
| 32 | - $this->nag_meta_key = 'give_addon_activation_ignore_' . sanitize_title( $this->banner_details['name'] ); |
|
| 31 | + $this->test_mode = ($this->banner_details['testing'] == 'true') ? true : false; |
|
| 32 | + $this->nag_meta_key = 'give_addon_activation_ignore_'.sanitize_title($this->banner_details['name']); |
|
| 33 | 33 | |
| 34 | 34 | //Get current user |
| 35 | 35 | $this->user_id = $current_user->ID; |
@@ -48,13 +48,13 @@ discard block |
||
| 48 | 48 | public function init() { |
| 49 | 49 | |
| 50 | 50 | //Testing? |
| 51 | - if ( $this->test_mode ) { |
|
| 52 | - delete_user_meta( $this->user_id, $this->nag_meta_key ); |
|
| 51 | + if ($this->test_mode) { |
|
| 52 | + delete_user_meta($this->user_id, $this->nag_meta_key); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | //Get the current page to add the notice to |
| 56 | - add_action( 'current_screen', array( $this, 'give_addon_notice_ignore' ) ); |
|
| 57 | - add_action( 'admin_notices', array( $this, 'give_addon_activation_admin_notice' ) ); |
|
| 56 | + add_action('current_screen', array($this, 'give_addon_notice_ignore')); |
|
| 57 | + add_action('admin_notices', array($this, 'give_addon_activation_admin_notice')); |
|
| 58 | 58 | |
| 59 | 59 | |
| 60 | 60 | } |
@@ -69,13 +69,13 @@ discard block |
||
| 69 | 69 | global $pagenow; |
| 70 | 70 | |
| 71 | 71 | //Make sure we're on the plugins page. |
| 72 | - if ( $pagenow !== 'plugins.php' ) { |
|
| 72 | + if ($pagenow !== 'plugins.php') { |
|
| 73 | 73 | return false; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | // If the user hasn't already dismissed our alert, |
| 77 | 77 | // Output the activation banner |
| 78 | - if ( ! get_user_meta( $this->user_id, $this->nag_meta_key ) ) { ?> |
|
| 78 | + if ( ! get_user_meta($this->user_id, $this->nag_meta_key)) { ?> |
|
| 79 | 79 | |
| 80 | 80 | <!-- * I output inline styles here |
| 81 | 81 | * because there's no reason to keep these |
@@ -152,12 +152,12 @@ discard block |
||
| 152 | 152 | <img src="<?php echo GIVE_PLUGIN_URL; ?>assets/images/svg/give-icon-full-circle.svg" class="give-logo" /> |
| 153 | 153 | |
| 154 | 154 | <!-- Your Message --> |
| 155 | - <h3><?php echo sprintf( __( 'Thank you for installing Give\'s %1$s%2$s%3$s Add-on!', 'give' ), '<span>', $this->banner_details['name'], '</span>' ); ?></h3> |
|
| 155 | + <h3><?php echo sprintf(__('Thank you for installing Give\'s %1$s%2$s%3$s Add-on!', 'give'), '<span>', $this->banner_details['name'], '</span>'); ?></h3> |
|
| 156 | 156 | |
| 157 | 157 | <a href="<?php |
| 158 | 158 | //The Dismiss Button |
| 159 | - $nag_admin_dismiss_url = 'plugins.php?' . $this->nag_meta_key . '=0'; |
|
| 160 | - echo admin_url( $nag_admin_dismiss_url ); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a> |
|
| 159 | + $nag_admin_dismiss_url = 'plugins.php?'.$this->nag_meta_key.'=0'; |
|
| 160 | + echo admin_url($nag_admin_dismiss_url); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a> |
|
| 161 | 161 | |
| 162 | 162 | <!-- * Now we output a few "actions" |
| 163 | 163 | * that the user can take from here --> |
@@ -165,24 +165,24 @@ discard block |
||
| 165 | 165 | <div class="alert-actions"> |
| 166 | 166 | |
| 167 | 167 | <?php //Point them to your settings page |
| 168 | - if ( isset( $this->banner_details['settings_url'] ) ) { ?> |
|
| 168 | + if (isset($this->banner_details['settings_url'])) { ?> |
|
| 169 | 169 | <a href="<?php echo $this->banner_details['settings_url']; ?>"> |
| 170 | - <span class="dashicons dashicons-admin-settings"></span><?php _e( 'Go to Settings', 'give' ); ?> |
|
| 170 | + <span class="dashicons dashicons-admin-settings"></span><?php _e('Go to Settings', 'give'); ?> |
|
| 171 | 171 | </a> |
| 172 | 172 | <?php } ?> |
| 173 | 173 | |
| 174 | 174 | <?php |
| 175 | 175 | // Show them how to configure the Addon |
| 176 | - if ( isset( $this->banner_details['documentation_url'] ) ) { ?> |
|
| 177 | - <a href="<?php echo $this->banner_details['documentation_url'] ?>" target="_blank"><span class="dashicons dashicons-media-text"></span><?php echo sprintf( __( 'Documentation: %1$s Add-on', 'give' ), $this->banner_details['name'] ); ?> |
|
| 176 | + if (isset($this->banner_details['documentation_url'])) { ?> |
|
| 177 | + <a href="<?php echo $this->banner_details['documentation_url'] ?>" target="_blank"><span class="dashicons dashicons-media-text"></span><?php echo sprintf(__('Documentation: %1$s Add-on', 'give'), $this->banner_details['name']); ?> |
|
| 178 | 178 | </a> |
| 179 | 179 | <?php } ?> |
| 180 | 180 | <?php |
| 181 | 181 | //Let them signup for plugin updates |
| 182 | - if ( isset( $this->banner_details['support_url'] ) ) { ?> |
|
| 182 | + if (isset($this->banner_details['support_url'])) { ?> |
|
| 183 | 183 | |
| 184 | 184 | <a href="<?php echo $this->banner_details['support_url'] ?>" target="_blank"> |
| 185 | - <span class="dashicons dashicons-sos"></span><?php _e( 'Get Support', 'give' ); ?> |
|
| 185 | + <span class="dashicons dashicons-sos"></span><?php _e('Get Support', 'give'); ?> |
|
| 186 | 186 | </a> |
| 187 | 187 | |
| 188 | 188 | <?php } ?> |
@@ -203,13 +203,13 @@ discard block |
||
| 203 | 203 | /* If user clicks to ignore the notice, add that to their user meta the banner then checks whether this tag exists already or not. |
| 204 | 204 | * See here: http://codex.wordpress.org/Function_Reference/add_user_meta |
| 205 | 205 | */ |
| 206 | - if ( isset( $_GET[ $this->nag_meta_key ] ) && '0' == $_GET[ $this->nag_meta_key ] ) { |
|
| 206 | + if (isset($_GET[$this->nag_meta_key]) && '0' == $_GET[$this->nag_meta_key]) { |
|
| 207 | 207 | |
| 208 | 208 | //Get the global user |
| 209 | 209 | global $current_user; |
| 210 | 210 | $user_id = $current_user->ID; |
| 211 | 211 | |
| 212 | - add_user_meta( $user_id, $this->nag_meta_key, 'true', true ); |
|
| 212 | + add_user_meta($user_id, $this->nag_meta_key, 'true', true); |
|
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | |
@@ -1,13 +1,13 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Customer (Donor) Reports Table Class |
|
| 4 | - * |
|
| 5 | - * @package Give |
|
| 6 | - * @subpackage Admin/Reports |
|
| 7 | - * @copyright Copyright (c) 2015, WordImpress |
|
| 8 | - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
| 9 | - * @since 1.0 |
|
| 10 | - */ |
|
| 3 | + * Customer (Donor) Reports Table Class |
|
| 4 | + * |
|
| 5 | + * @package Give |
|
| 6 | + * @subpackage Admin/Reports |
|
| 7 | + * @copyright Copyright (c) 2015, WordImpress |
|
| 8 | + * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
| 9 | + * @since 1.0 |
|
| 10 | + */ |
|
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | 13 | if ( ! defined( 'ABSPATH' ) ) { |
@@ -115,8 +115,8 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | case 'num_purchases' : |
| 117 | 117 | $value = '<a href="' . |
| 118 | - admin_url( '/edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $item['email'] ) |
|
| 119 | - ) . '">' . esc_html( $item['num_purchases'] ) . '</a>'; |
|
| 118 | + admin_url( '/edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $item['email'] ) |
|
| 119 | + ) . '">' . esc_html( $item['num_purchases'] ) . '</a>'; |
|
| 120 | 120 | break; |
| 121 | 121 | |
| 122 | 122 | case 'amount_spent' : |
@@ -10,13 +10,13 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // Load WP_List_Table if not loaded |
| 18 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
| 19 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
| 18 | +if ( ! class_exists('WP_List_Table')) { |
|
| 19 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -62,11 +62,11 @@ discard block |
||
| 62 | 62 | global $status, $page; |
| 63 | 63 | |
| 64 | 64 | // Set parent defaults |
| 65 | - parent::__construct( array( |
|
| 66 | - 'singular' => __( 'Donor', 'give' ), // Singular name of the listed records |
|
| 67 | - 'plural' => __( 'Donors', 'give' ), // Plural name of the listed records |
|
| 65 | + parent::__construct(array( |
|
| 66 | + 'singular' => __('Donor', 'give'), // Singular name of the listed records |
|
| 67 | + 'plural' => __('Donors', 'give'), // Plural name of the listed records |
|
| 68 | 68 | 'ajax' => false // Does this table support ajax? |
| 69 | - ) ); |
|
| 69 | + )); |
|
| 70 | 70 | |
| 71 | 71 | } |
| 72 | 72 | |
@@ -81,20 +81,20 @@ discard block |
||
| 81 | 81 | * |
| 82 | 82 | * @return void |
| 83 | 83 | */ |
| 84 | - public function search_box( $text, $input_id ) { |
|
| 85 | - $input_id = $input_id . '-search-input'; |
|
| 84 | + public function search_box($text, $input_id) { |
|
| 85 | + $input_id = $input_id.'-search-input'; |
|
| 86 | 86 | |
| 87 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
| 88 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
| 87 | + if ( ! empty($_REQUEST['orderby'])) { |
|
| 88 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
| 89 | 89 | } |
| 90 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
| 91 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
| 90 | + if ( ! empty($_REQUEST['order'])) { |
|
| 91 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
| 92 | 92 | } |
| 93 | 93 | ?> |
| 94 | 94 | <p class="search-box"> |
| 95 | 95 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
| 96 | 96 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
| 97 | - <?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?> |
|
| 97 | + <?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?> |
|
| 98 | 98 | </p> |
| 99 | 99 | <?php |
| 100 | 100 | } |
@@ -110,41 +110,41 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @return string Column Name |
| 112 | 112 | */ |
| 113 | - public function column_default( $item, $column_name ) { |
|
| 114 | - switch ( $column_name ) { |
|
| 113 | + public function column_default($item, $column_name) { |
|
| 114 | + switch ($column_name) { |
|
| 115 | 115 | |
| 116 | 116 | case 'num_purchases' : |
| 117 | - $value = '<a href="' . |
|
| 118 | - admin_url( '/edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $item['email'] ) |
|
| 119 | - ) . '">' . esc_html( $item['num_purchases'] ) . '</a>'; |
|
| 117 | + $value = '<a href="'. |
|
| 118 | + admin_url('/edit.php?post_type=give_forms&page=give-payment-history&user='.urlencode($item['email']) |
|
| 119 | + ).'">'.esc_html($item['num_purchases']).'</a>'; |
|
| 120 | 120 | break; |
| 121 | 121 | |
| 122 | 122 | case 'amount_spent' : |
| 123 | - $value = give_currency_filter( give_format_amount( $item[ $column_name ] ) ); |
|
| 123 | + $value = give_currency_filter(give_format_amount($item[$column_name])); |
|
| 124 | 124 | break; |
| 125 | 125 | |
| 126 | 126 | case 'date_created' : |
| 127 | - $value = date_i18n( get_option( 'date_format' ), strtotime( $item['date_created'] ) ); |
|
| 127 | + $value = date_i18n(get_option('date_format'), strtotime($item['date_created'])); |
|
| 128 | 128 | break; |
| 129 | 129 | |
| 130 | 130 | default: |
| 131 | - $value = isset( $item[ $column_name ] ) ? $item[ $column_name ] : null; |
|
| 131 | + $value = isset($item[$column_name]) ? $item[$column_name] : null; |
|
| 132 | 132 | break; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - return apply_filters( 'give_report_column_' . $column_name, $value, $item['id'] ); |
|
| 135 | + return apply_filters('give_report_column_'.$column_name, $value, $item['id']); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - public function column_name( $item ) { |
|
| 139 | - $name = '#' . $item['id'] . ' '; |
|
| 140 | - $name .= ! empty( $item['name'] ) ? $item['name'] : '<em>' . __( 'Unnamed Donor', 'give' ) . '</em>'; |
|
| 141 | - $view_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $item['id'] ); |
|
| 138 | + public function column_name($item) { |
|
| 139 | + $name = '#'.$item['id'].' '; |
|
| 140 | + $name .= ! empty($item['name']) ? $item['name'] : '<em>'.__('Unnamed Donor', 'give').'</em>'; |
|
| 141 | + $view_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$item['id']); |
|
| 142 | 142 | $actions = array( |
| 143 | - 'view' => sprintf( __( '<a href="%s">View Donor</a>', 'give' ), $view_url ), |
|
| 144 | - 'delete' => sprintf( __( '<a href="%s">Delete</a>', 'give' ), admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $item['id'] ) ) |
|
| 143 | + 'view' => sprintf(__('<a href="%s">View Donor</a>', 'give'), $view_url), |
|
| 144 | + 'delete' => sprintf(__('<a href="%s">Delete</a>', 'give'), admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$item['id'])) |
|
| 145 | 145 | ); |
| 146 | 146 | |
| 147 | - return '<a href="' . esc_url( $view_url ) . '">' . $name . '</a>' . $this->row_actions( $actions ); |
|
| 147 | + return '<a href="'.esc_url($view_url).'">'.$name.'</a>'.$this->row_actions($actions); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -156,14 +156,14 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | public function get_columns() { |
| 158 | 158 | $columns = array( |
| 159 | - 'name' => __( 'Name', 'give' ), |
|
| 160 | - 'email' => __( 'Email', 'give' ), |
|
| 161 | - 'num_purchases' => __( 'Donations', 'give' ), |
|
| 162 | - 'amount_spent' => __( 'Total Donated', 'give' ), |
|
| 163 | - 'date_created' => __( 'Date Created', 'give' ) |
|
| 159 | + 'name' => __('Name', 'give'), |
|
| 160 | + 'email' => __('Email', 'give'), |
|
| 161 | + 'num_purchases' => __('Donations', 'give'), |
|
| 162 | + 'amount_spent' => __('Total Donated', 'give'), |
|
| 163 | + 'date_created' => __('Date Created', 'give') |
|
| 164 | 164 | ); |
| 165 | 165 | |
| 166 | - return apply_filters( 'give_report_customer_columns', $columns ); |
|
| 166 | + return apply_filters('give_report_customer_columns', $columns); |
|
| 167 | 167 | |
| 168 | 168 | } |
| 169 | 169 | |
@@ -176,10 +176,10 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | public function get_sortable_columns() { |
| 178 | 178 | return array( |
| 179 | - 'date_created' => array( 'date_created', true ), |
|
| 180 | - 'name' => array( 'name', true ), |
|
| 181 | - 'num_purchases' => array( 'purchase_count', false ), |
|
| 182 | - 'amount_spent' => array( 'purchase_value', false ), |
|
| 179 | + 'date_created' => array('date_created', true), |
|
| 180 | + 'name' => array('name', true), |
|
| 181 | + 'num_purchases' => array('purchase_count', false), |
|
| 182 | + 'amount_spent' => array('purchase_value', false), |
|
| 183 | 183 | ); |
| 184 | 184 | } |
| 185 | 185 | |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | * @since 1.0 |
| 191 | 191 | * @return void |
| 192 | 192 | */ |
| 193 | - public function bulk_actions( $which = '' ) { |
|
| 193 | + public function bulk_actions($which = '') { |
|
| 194 | 194 | // These aren't really bulk actions but this outputs the markup in the right place |
| 195 | 195 | } |
| 196 | 196 | |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | * @return int Current page number |
| 203 | 203 | */ |
| 204 | 204 | public function get_paged() { |
| 205 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
| 205 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | /** |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | * @return mixed string If search is present, false otherwise |
| 214 | 214 | */ |
| 215 | 215 | public function get_search() { |
| 216 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
| 216 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | /** |
@@ -230,10 +230,10 @@ discard block |
||
| 230 | 230 | |
| 231 | 231 | $data = array(); |
| 232 | 232 | $paged = $this->get_paged(); |
| 233 | - $offset = $this->per_page * ( $paged - 1 ); |
|
| 233 | + $offset = $this->per_page * ($paged - 1); |
|
| 234 | 234 | $search = $this->get_search(); |
| 235 | - $order = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC'; |
|
| 236 | - $orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id'; |
|
| 235 | + $order = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC'; |
|
| 236 | + $orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id'; |
|
| 237 | 237 | |
| 238 | 238 | $args = array( |
| 239 | 239 | 'number' => $this->per_page, |
@@ -242,21 +242,21 @@ discard block |
||
| 242 | 242 | 'orderby' => $orderby |
| 243 | 243 | ); |
| 244 | 244 | |
| 245 | - if ( is_email( $search ) ) { |
|
| 245 | + if (is_email($search)) { |
|
| 246 | 246 | $args['email'] = $search; |
| 247 | - } elseif ( is_numeric( $search ) ) { |
|
| 247 | + } elseif (is_numeric($search)) { |
|
| 248 | 248 | $args['id'] = $search; |
| 249 | 249 | } else { |
| 250 | 250 | $args['name'] = $search; |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - $customers = Give()->customers->get_customers( $args ); |
|
| 253 | + $customers = Give()->customers->get_customers($args); |
|
| 254 | 254 | |
| 255 | - if ( $customers ) { |
|
| 255 | + if ($customers) { |
|
| 256 | 256 | |
| 257 | - foreach ( $customers as $customer ) { |
|
| 257 | + foreach ($customers as $customer) { |
|
| 258 | 258 | |
| 259 | - $user_id = ! empty( $customer->user_id ) ? intval( $customer->user_id ) : 0; |
|
| 259 | + $user_id = ! empty($customer->user_id) ? intval($customer->user_id) : 0; |
|
| 260 | 260 | |
| 261 | 261 | $data[] = array( |
| 262 | 262 | 'id' => $customer->id, |
@@ -290,16 +290,16 @@ discard block |
||
| 290 | 290 | $hidden = array(); // No hidden columns |
| 291 | 291 | $sortable = $this->get_sortable_columns(); |
| 292 | 292 | |
| 293 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
| 293 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
| 294 | 294 | |
| 295 | 295 | $this->items = $this->reports_data(); |
| 296 | 296 | |
| 297 | 297 | $this->total = give_count_total_customers(); |
| 298 | 298 | |
| 299 | - $this->set_pagination_args( array( |
|
| 299 | + $this->set_pagination_args(array( |
|
| 300 | 300 | 'total_items' => $this->total, |
| 301 | 301 | 'per_page' => $this->per_page, |
| 302 | - 'total_pages' => ceil( $this->total / $this->per_page ) |
|
| 303 | - ) ); |
|
| 302 | + 'total_pages' => ceil($this->total / $this->per_page) |
|
| 303 | + )); |
|
| 304 | 304 | } |
| 305 | 305 | } |
| 306 | 306 | \ No newline at end of file |