@@ -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 | */ |
@@ -1070,58 +1070,58 @@ |
||
1070 | 1070 | * @return bool |
1071 | 1071 | */ |
1072 | 1072 | function give_validate_multi_donation_form_level( $valid_data, $data ) { |
1073 | - /* @var Give_Donate_Form $form*/ |
|
1074 | - $form = new Give_Donate_Form( $data['give-form-id'] ); |
|
1073 | + /* @var Give_Donate_Form $form*/ |
|
1074 | + $form = new Give_Donate_Form( $data['give-form-id'] ); |
|
1075 | 1075 | |
1076 | - $donation_level_matched = false; |
|
1076 | + $donation_level_matched = false; |
|
1077 | 1077 | |
1078 | - if( $form->is_multi_type_donation_form() ) { |
|
1078 | + if( $form->is_multi_type_donation_form() ) { |
|
1079 | 1079 | |
1080 | - // Bailout. |
|
1081 | - if( ! ( $variable_prices = $form->get_prices() ) ) { |
|
1082 | - return false; |
|
1083 | - } |
|
1080 | + // Bailout. |
|
1081 | + if( ! ( $variable_prices = $form->get_prices() ) ) { |
|
1082 | + return false; |
|
1083 | + } |
|
1084 | 1084 | |
1085 | - // Sanitize donation amount. |
|
1086 | - $data['give-amount'] = give_sanitize_amount( $data['give-amount'] ); |
|
1085 | + // Sanitize donation amount. |
|
1086 | + $data['give-amount'] = give_sanitize_amount( $data['give-amount'] ); |
|
1087 | 1087 | |
1088 | - // Get number of decimals. |
|
1089 | - $default_decimals = give_get_price_decimals(); |
|
1088 | + // Get number of decimals. |
|
1089 | + $default_decimals = give_get_price_decimals(); |
|
1090 | 1090 | |
1091 | - if( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ){ |
|
1092 | - return true; |
|
1093 | - } |
|
1091 | + if( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ){ |
|
1092 | + return true; |
|
1093 | + } |
|
1094 | 1094 | |
1095 | 1095 | |
1096 | - // Find correct donation level from all donation levels. |
|
1097 | - foreach ( $variable_prices as $variable_price ) { |
|
1098 | - // Sanitize level amount. |
|
1099 | - $variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals ); |
|
1100 | - |
|
1101 | - // Set first match donation level ID. |
|
1102 | - if( $data['give-amount'] === $variable_price['_give_amount'] ) { |
|
1103 | - $_POST['give-price-id'] = $variable_price['_give_id']['level_id']; |
|
1104 | - $donation_level_matched = true; |
|
1105 | - break; |
|
1106 | - } |
|
1107 | - } |
|
1108 | - |
|
1109 | - // If donation amount is not find in donation levels then check if form has custom donation feature enable or not. |
|
1110 | - // If yes then set price id to custom if amount is greater then custom minimum amount (if any). |
|
1111 | - if( |
|
1112 | - ! $donation_level_matched |
|
1113 | - && ( 'yes' === get_post_meta( $data['give-form-id'], '_give_custom_amount', true ) ) |
|
1114 | - ) { |
|
1115 | - // Sanitize custom minimum amount. |
|
1116 | - $custom_minimum_amount = give_sanitize_amount( get_post_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals ); |
|
1117 | - |
|
1118 | - if( $data['give-amount'] >= $custom_minimum_amount ) { |
|
1119 | - $_POST['give-price-id'] = 'custom'; |
|
1120 | - $donation_level_matched = true; |
|
1121 | - } |
|
1122 | - } |
|
1123 | - } |
|
1124 | - |
|
1125 | - return ( $donation_level_matched ? true : false ); |
|
1096 | + // Find correct donation level from all donation levels. |
|
1097 | + foreach ( $variable_prices as $variable_price ) { |
|
1098 | + // Sanitize level amount. |
|
1099 | + $variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals ); |
|
1100 | + |
|
1101 | + // Set first match donation level ID. |
|
1102 | + if( $data['give-amount'] === $variable_price['_give_amount'] ) { |
|
1103 | + $_POST['give-price-id'] = $variable_price['_give_id']['level_id']; |
|
1104 | + $donation_level_matched = true; |
|
1105 | + break; |
|
1106 | + } |
|
1107 | + } |
|
1108 | + |
|
1109 | + // If donation amount is not find in donation levels then check if form has custom donation feature enable or not. |
|
1110 | + // If yes then set price id to custom if amount is greater then custom minimum amount (if any). |
|
1111 | + if( |
|
1112 | + ! $donation_level_matched |
|
1113 | + && ( 'yes' === get_post_meta( $data['give-form-id'], '_give_custom_amount', true ) ) |
|
1114 | + ) { |
|
1115 | + // Sanitize custom minimum amount. |
|
1116 | + $custom_minimum_amount = give_sanitize_amount( get_post_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals ); |
|
1117 | + |
|
1118 | + if( $data['give-amount'] >= $custom_minimum_amount ) { |
|
1119 | + $_POST['give-price-id'] = 'custom'; |
|
1120 | + $donation_level_matched = true; |
|
1121 | + } |
|
1122 | + } |
|
1123 | + } |
|
1124 | + |
|
1125 | + return ( $donation_level_matched ? true : false ); |
|
1126 | 1126 | } |
1127 | 1127 | add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 ); |
1128 | 1128 | \ 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,27 +25,27 @@ 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 ( false === $valid_data || give_get_errors() || ! $user ) { |
|
47 | - if ( $is_ajax ) { |
|
48 | - do_action( 'give_ajax_checkout_errors' ); |
|
46 | + if (false === $valid_data || 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; |
@@ -53,17 +53,17 @@ discard block |
||
53 | 53 | } |
54 | 54 | |
55 | 55 | //If AJAX send back success to proceed with form submission |
56 | - if ( $is_ajax ) { |
|
56 | + if ($is_ajax) { |
|
57 | 57 | echo 'success'; |
58 | 58 | give_die(); |
59 | 59 | } |
60 | 60 | |
61 | 61 | //After AJAX: Setup session if not using php_sessions |
62 | - if ( ! Give()->session->use_php_sessions() ) { |
|
62 | + if ( ! Give()->session->use_php_sessions()) { |
|
63 | 63 | //Double-check that set_cookie is publicly accessible; |
64 | 64 | // we're using a slightly modified class-wp-sessions.php |
65 | - $session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' ); |
|
66 | - if ( $session_reflection->isPublic() ) { |
|
65 | + $session_reflection = new ReflectionMethod('WP_Session', 'set_cookie'); |
|
66 | + if ($session_reflection->isPublic()) { |
|
67 | 67 | // Manually set the cookie. |
68 | 68 | Give()->session->init()->set_cookie(); |
69 | 69 | } |
@@ -78,18 +78,18 @@ discard block |
||
78 | 78 | 'address' => $user['address'] |
79 | 79 | ); |
80 | 80 | |
81 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
81 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
82 | 82 | |
83 | - $price = isset( $_POST['give-amount'] ) ? (float) apply_filters( 'give_donation_total', give_sanitize_amount( give_format_amount( $_POST['give-amount'] ) ) ) : '0.00'; |
|
84 | - $purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); |
|
83 | + $price = isset($_POST['give-amount']) ? (float) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00'; |
|
84 | + $purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); |
|
85 | 85 | |
86 | 86 | // Setup purchase information |
87 | 87 | $purchase_data = array( |
88 | 88 | 'price' => $price, |
89 | 89 | 'purchase_key' => $purchase_key, |
90 | 90 | 'user_email' => $user['user_email'], |
91 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
92 | - 'user_info' => stripslashes_deep( $user_info ), |
|
91 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
92 | + 'user_info' => stripslashes_deep($user_info), |
|
93 | 93 | 'post_data' => $_POST, |
94 | 94 | 'gateway' => $valid_data['gateway'], |
95 | 95 | 'card_info' => $valid_data['cc_info'] |
@@ -99,37 +99,37 @@ discard block |
||
99 | 99 | $valid_data['user'] = $user; |
100 | 100 | |
101 | 101 | // Allow themes and plugins to hook before the gateway |
102 | - do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data ); |
|
102 | + do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data); |
|
103 | 103 | |
104 | 104 | //Sanity check for price |
105 | - if ( ! $purchase_data['price'] ) { |
|
105 | + if ( ! $purchase_data['price']) { |
|
106 | 106 | // Revert to manual |
107 | 107 | $purchase_data['gateway'] = 'manual'; |
108 | 108 | $_POST['give-gateway'] = 'manual'; |
109 | 109 | } |
110 | 110 | |
111 | 111 | // Allow the purchase data to be modified before it is sent to the gateway |
112 | - $purchase_data = apply_filters( 'give_purchase_data_before_gateway', $purchase_data, $valid_data ); |
|
112 | + $purchase_data = apply_filters('give_purchase_data_before_gateway', $purchase_data, $valid_data); |
|
113 | 113 | |
114 | 114 | // Setup the data we're storing in the purchase session |
115 | 115 | $session_data = $purchase_data; |
116 | 116 | |
117 | 117 | // Make sure credit card numbers are never stored in sessions |
118 | - unset( $session_data['card_info']['card_number'] ); |
|
119 | - unset( $session_data['post_data']['card_number'] ); |
|
118 | + unset($session_data['card_info']['card_number']); |
|
119 | + unset($session_data['post_data']['card_number']); |
|
120 | 120 | |
121 | 121 | // Used for showing data to non logged-in users after purchase, and for other plugins needing purchase data. |
122 | - give_set_purchase_session( $session_data ); |
|
122 | + give_set_purchase_session($session_data); |
|
123 | 123 | |
124 | 124 | // Send info to the gateway for payment processing |
125 | - give_send_to_gateway( $purchase_data['gateway'], $purchase_data ); |
|
125 | + give_send_to_gateway($purchase_data['gateway'], $purchase_data); |
|
126 | 126 | give_die(); |
127 | 127 | |
128 | 128 | } |
129 | 129 | |
130 | -add_action( 'give_purchase', 'give_process_purchase_form' ); |
|
131 | -add_action( 'wp_ajax_give_process_checkout', 'give_process_purchase_form' ); |
|
132 | -add_action( 'wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form' ); |
|
130 | +add_action('give_purchase', 'give_process_purchase_form'); |
|
131 | +add_action('wp_ajax_give_process_checkout', 'give_process_purchase_form'); |
|
132 | +add_action('wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form'); |
|
133 | 133 | |
134 | 134 | /** |
135 | 135 | * Process the checkout login form |
@@ -140,32 +140,32 @@ discard block |
||
140 | 140 | */ |
141 | 141 | function give_process_form_login() { |
142 | 142 | |
143 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
143 | + $is_ajax = isset($_POST['give_ajax']); |
|
144 | 144 | |
145 | 145 | $user_data = give_purchase_form_validate_user_login(); |
146 | 146 | |
147 | - if ( give_get_errors() || $user_data['user_id'] < 1 ) { |
|
148 | - if ( $is_ajax ) { |
|
149 | - do_action( 'give_ajax_checkout_errors' ); |
|
147 | + if (give_get_errors() || $user_data['user_id'] < 1) { |
|
148 | + if ($is_ajax) { |
|
149 | + do_action('give_ajax_checkout_errors'); |
|
150 | 150 | give_die(); |
151 | 151 | } else { |
152 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
152 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
153 | 153 | exit; |
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
157 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] ); |
|
157 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']); |
|
158 | 158 | |
159 | - if ( $is_ajax ) { |
|
159 | + if ($is_ajax) { |
|
160 | 160 | echo 'success'; |
161 | 161 | give_die(); |
162 | 162 | } else { |
163 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
163 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
164 | 164 | } |
165 | 165 | } |
166 | 166 | |
167 | -add_action( 'wp_ajax_give_process_checkout_login', 'give_process_form_login' ); |
|
168 | -add_action( 'wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login' ); |
|
167 | +add_action('wp_ajax_give_process_checkout_login', 'give_process_form_login'); |
|
168 | +add_action('wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login'); |
|
169 | 169 | |
170 | 170 | /** |
171 | 171 | * Purchase Form Validate Fields |
@@ -177,45 +177,45 @@ discard block |
||
177 | 177 | function give_purchase_form_validate_fields() { |
178 | 178 | |
179 | 179 | // Check if there is $_POST |
180 | - if ( empty( $_POST ) ) { |
|
180 | + if (empty($_POST)) { |
|
181 | 181 | return false; |
182 | 182 | } |
183 | 183 | |
184 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
184 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
185 | 185 | |
186 | 186 | // Start an array to collect valid data |
187 | 187 | $valid_data = array( |
188 | 188 | 'gateway' => give_purchase_form_validate_gateway(), // Gateway fallback (amount is validated here) |
189 | - 'need_new_user' => false, // New user flag |
|
190 | - 'need_user_login' => false, // Login user flag |
|
191 | - 'logged_user_data' => array(), // Logged user collected data |
|
192 | - 'new_user_data' => array(), // New user collected data |
|
193 | - 'login_user_data' => array(), // Login user collected data |
|
194 | - 'guest_user_data' => array(), // Guest user collected data |
|
189 | + 'need_new_user' => false, // New user flag |
|
190 | + 'need_user_login' => false, // Login user flag |
|
191 | + 'logged_user_data' => array(), // Logged user collected data |
|
192 | + 'new_user_data' => array(), // New user collected data |
|
193 | + 'login_user_data' => array(), // Login user collected data |
|
194 | + 'guest_user_data' => array(), // Guest user collected data |
|
195 | 195 | 'cc_info' => give_purchase_form_validate_cc() // Credit card info |
196 | 196 | ); |
197 | 197 | |
198 | 198 | //Validate Honeypot First |
199 | - if ( ! empty( $_POST['give-honeypot'] ) ) { |
|
200 | - give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) ); |
|
199 | + if ( ! empty($_POST['give-honeypot'])) { |
|
200 | + give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give')); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | // Validate agree to terms |
204 | - $terms_option = get_post_meta( $form_id, '_give_terms_option', true ); |
|
205 | - if ( isset( $terms_option ) && $terms_option === 'yes' ) { |
|
204 | + $terms_option = get_post_meta($form_id, '_give_terms_option', true); |
|
205 | + if (isset($terms_option) && $terms_option === 'yes') { |
|
206 | 206 | give_purchase_form_validate_agree_to_terms(); |
207 | 207 | } |
208 | 208 | |
209 | - if ( is_user_logged_in() ) { |
|
209 | + if (is_user_logged_in()) { |
|
210 | 210 | // Collect logged in user data |
211 | 211 | $valid_data['logged_in_user'] = give_purchase_form_validate_logged_in_user(); |
212 | - } else if ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) { |
|
212 | + } else if (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') { |
|
213 | 213 | // Set new user registration as required |
214 | 214 | $valid_data['need_new_user'] = true; |
215 | 215 | // Validate new user data |
216 | 216 | $valid_data['new_user_data'] = give_purchase_form_validate_new_user(); |
217 | 217 | // Check if login validation is needed |
218 | - } else if ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) { |
|
218 | + } else if (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') { |
|
219 | 219 | // Set user login as required |
220 | 220 | $valid_data['need_user_login'] = true; |
221 | 221 | // Validate users login info |
@@ -240,41 +240,41 @@ discard block |
||
240 | 240 | */ |
241 | 241 | function give_purchase_form_validate_gateway() { |
242 | 242 | |
243 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
244 | - $amount = isset( $_REQUEST['give-amount'] ) ? give_sanitize_amount( $_REQUEST['give-amount'] ) : 0; |
|
245 | - $gateway = give_get_default_gateway( $form_id ); |
|
243 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
244 | + $amount = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0; |
|
245 | + $gateway = give_get_default_gateway($form_id); |
|
246 | 246 | |
247 | 247 | // Check if a gateway value is present |
248 | - if ( ! empty( $_REQUEST['give-gateway'] ) ) { |
|
248 | + if ( ! empty($_REQUEST['give-gateway'])) { |
|
249 | 249 | |
250 | - $gateway = sanitize_text_field( $_REQUEST['give-gateway'] ); |
|
250 | + $gateway = sanitize_text_field($_REQUEST['give-gateway']); |
|
251 | 251 | |
252 | 252 | //Is amount being donated in LIVE mode 0.00? If so, error: |
253 | - if ( $amount == 0 && ! give_is_test_mode() ) { |
|
253 | + if ($amount == 0 && ! give_is_test_mode()) { |
|
254 | 254 | |
255 | - give_set_error( 'invalid_donation_amount', esc_html__( 'Please insert a valid donation amount.', 'give' ) ); |
|
255 | + give_set_error('invalid_donation_amount', esc_html__('Please insert a valid donation amount.', 'give')); |
|
256 | 256 | |
257 | 257 | } //Check for a minimum custom amount |
258 | - elseif ( ! give_verify_minimum_price() ) { |
|
258 | + elseif ( ! give_verify_minimum_price()) { |
|
259 | 259 | |
260 | 260 | give_set_error( |
261 | 261 | 'invalid_donation_minimum', |
262 | 262 | sprintf( |
263 | 263 | /* translators: %s: minimum donation amount */ |
264 | - esc_html__( 'This form has a minimum donation amount of %s.', 'give' ), |
|
265 | - give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ) ) ) |
|
264 | + esc_html__('This form has a minimum donation amount of %s.', 'give'), |
|
265 | + give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id))) |
|
266 | 266 | ) |
267 | 267 | ); |
268 | 268 | |
269 | 269 | } //Is this test mode zero donation? Let it through but set to manual gateway |
270 | - elseif ( $amount == 0 && give_is_test_mode() ) { |
|
270 | + elseif ($amount == 0 && give_is_test_mode()) { |
|
271 | 271 | |
272 | 272 | $gateway = 'manual'; |
273 | 273 | |
274 | 274 | } //Check if this gateway is active |
275 | - elseif ( ! give_is_gateway_active( $gateway ) ) { |
|
275 | + elseif ( ! give_is_gateway_active($gateway)) { |
|
276 | 276 | |
277 | - give_set_error( 'invalid_gateway', esc_html__( 'The selected payment gateway is not enabled.', 'give' ) ); |
|
277 | + give_set_error('invalid_gateway', esc_html__('The selected payment gateway is not enabled.', 'give')); |
|
278 | 278 | |
279 | 279 | } |
280 | 280 | |
@@ -293,23 +293,23 @@ discard block |
||
293 | 293 | */ |
294 | 294 | function give_verify_minimum_price() { |
295 | 295 | |
296 | - $amount = give_sanitize_amount( $_REQUEST['give-amount'] ); |
|
297 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
298 | - $price_id = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : 0; |
|
299 | - $variable_prices = give_has_variable_prices( $form_id ); |
|
296 | + $amount = give_sanitize_amount($_REQUEST['give-amount']); |
|
297 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
298 | + $price_id = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : 0; |
|
299 | + $variable_prices = give_has_variable_prices($form_id); |
|
300 | 300 | |
301 | - if ( $variable_prices && ! empty( $price_id ) ) { |
|
301 | + if ($variable_prices && ! empty($price_id)) { |
|
302 | 302 | |
303 | - $price_level_amount = give_get_price_option_amount( $form_id, $price_id ); |
|
303 | + $price_level_amount = give_get_price_option_amount($form_id, $price_id); |
|
304 | 304 | |
305 | - if ( $price_level_amount == $amount ) { |
|
305 | + if ($price_level_amount == $amount) { |
|
306 | 306 | return true; |
307 | 307 | } |
308 | 308 | } |
309 | 309 | |
310 | - $minimum = give_get_form_minimum_price( $form_id ); |
|
310 | + $minimum = give_get_form_minimum_price($form_id); |
|
311 | 311 | |
312 | - if ( $minimum > $amount ) { |
|
312 | + if ($minimum > $amount) { |
|
313 | 313 | return false; |
314 | 314 | } |
315 | 315 | |
@@ -325,9 +325,9 @@ discard block |
||
325 | 325 | */ |
326 | 326 | function give_purchase_form_validate_agree_to_terms() { |
327 | 327 | // Validate agree to terms |
328 | - if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) { |
|
328 | + if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) { |
|
329 | 329 | // User did not agree |
330 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', esc_html__( 'You must agree to the terms of use.', 'give' ) ) ); |
|
330 | + give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', esc_html__('You must agree to the terms of use.', 'give'))); |
|
331 | 331 | } |
332 | 332 | } |
333 | 333 | |
@@ -341,47 +341,47 @@ discard block |
||
341 | 341 | * |
342 | 342 | * @return array |
343 | 343 | */ |
344 | -function give_purchase_form_required_fields( $form_id ) { |
|
344 | +function give_purchase_form_required_fields($form_id) { |
|
345 | 345 | |
346 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
346 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
347 | 347 | |
348 | 348 | $required_fields = array( |
349 | 349 | 'give_email' => array( |
350 | 350 | 'error_id' => 'invalid_email', |
351 | - 'error_message' => esc_html__( 'Please enter a valid email address.', 'give' ) |
|
351 | + 'error_message' => esc_html__('Please enter a valid email address.', 'give') |
|
352 | 352 | ), |
353 | 353 | 'give_first' => array( |
354 | 354 | 'error_id' => 'invalid_first_name', |
355 | - 'error_message' => esc_html__( 'Please enter your first name.', 'give' ) |
|
355 | + 'error_message' => esc_html__('Please enter your first name.', 'give') |
|
356 | 356 | ) |
357 | 357 | ); |
358 | 358 | |
359 | - $require_address = give_require_billing_address( $payment_mode ); |
|
359 | + $require_address = give_require_billing_address($payment_mode); |
|
360 | 360 | |
361 | - if ( $require_address ) { |
|
362 | - $required_fields['card_address'] = array( |
|
361 | + if ($require_address) { |
|
362 | + $required_fields['card_address'] = array( |
|
363 | 363 | 'error_id' => 'invalid_card_address', |
364 | - 'error_message' => esc_html__( 'Please enter your primary billing address.', 'give' ) |
|
364 | + 'error_message' => esc_html__('Please enter your primary billing address.', 'give') |
|
365 | 365 | ); |
366 | - $required_fields['card_zip'] = array( |
|
366 | + $required_fields['card_zip'] = array( |
|
367 | 367 | 'error_id' => 'invalid_zip_code', |
368 | - 'error_message' => esc_html__( 'Please enter your zip / postal code.', 'give' ) |
|
368 | + 'error_message' => esc_html__('Please enter your zip / postal code.', 'give') |
|
369 | 369 | ); |
370 | - $required_fields['card_city'] = array( |
|
370 | + $required_fields['card_city'] = array( |
|
371 | 371 | 'error_id' => 'invalid_city', |
372 | - 'error_message' => esc_html__( 'Please enter your billing city.', 'give' ) |
|
372 | + 'error_message' => esc_html__('Please enter your billing city.', 'give') |
|
373 | 373 | ); |
374 | 374 | $required_fields['billing_country'] = array( |
375 | 375 | 'error_id' => 'invalid_country', |
376 | - 'error_message' => esc_html__( 'Please select your billing country.', 'give' ) |
|
376 | + 'error_message' => esc_html__('Please select your billing country.', 'give') |
|
377 | 377 | ); |
378 | - $required_fields['card_state'] = array( |
|
378 | + $required_fields['card_state'] = array( |
|
379 | 379 | 'error_id' => 'invalid_state', |
380 | - 'error_message' => esc_html__( 'Please enter billing state / province.', 'give' ) |
|
380 | + 'error_message' => esc_html__('Please enter billing state / province.', 'give') |
|
381 | 381 | ); |
382 | 382 | } |
383 | 383 | |
384 | - return apply_filters( 'give_purchase_form_required_fields', $required_fields, $form_id ); |
|
384 | + return apply_filters('give_purchase_form_required_fields', $required_fields, $form_id); |
|
385 | 385 | |
386 | 386 | } |
387 | 387 | |
@@ -394,16 +394,16 @@ discard block |
||
394 | 394 | * |
395 | 395 | * @return mixed|void |
396 | 396 | */ |
397 | -function give_require_billing_address( $payment_mode ) { |
|
397 | +function give_require_billing_address($payment_mode) { |
|
398 | 398 | |
399 | 399 | $return = false; |
400 | 400 | |
401 | - if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { |
|
401 | + if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { |
|
402 | 402 | $return = true; |
403 | 403 | } |
404 | 404 | |
405 | 405 | // Let payment gateways and other extensions determine if address fields should be required |
406 | - return apply_filters( 'give_require_billing_address', $return ); |
|
406 | + return apply_filters('give_require_billing_address', $return); |
|
407 | 407 | |
408 | 408 | } |
409 | 409 | |
@@ -417,43 +417,43 @@ discard block |
||
417 | 417 | function give_purchase_form_validate_logged_in_user() { |
418 | 418 | global $user_ID; |
419 | 419 | |
420 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
420 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
421 | 421 | |
422 | 422 | // Start empty array to collect valid user data |
423 | 423 | $valid_user_data = array( |
424 | 424 | // Assume there will be errors |
425 | - 'user_id' => - 1 |
|
425 | + 'user_id' => -1 |
|
426 | 426 | ); |
427 | 427 | |
428 | 428 | // Verify there is a user_ID |
429 | - if ( $user_ID > 0 ) { |
|
429 | + if ($user_ID > 0) { |
|
430 | 430 | // Get the logged in user data |
431 | - $user_data = get_userdata( $user_ID ); |
|
431 | + $user_data = get_userdata($user_ID); |
|
432 | 432 | |
433 | 433 | // Loop through required fields and show error messages |
434 | - foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) { |
|
435 | - if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
436 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
434 | + foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) { |
|
435 | + if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
436 | + give_set_error($value['error_id'], $value['error_message']); |
|
437 | 437 | } |
438 | 438 | } |
439 | 439 | |
440 | 440 | // Verify data |
441 | - if ( $user_data ) { |
|
441 | + if ($user_data) { |
|
442 | 442 | // Collected logged in user data |
443 | 443 | $valid_user_data = array( |
444 | 444 | 'user_id' => $user_ID, |
445 | - 'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email, |
|
446 | - 'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name, |
|
447 | - 'user_last' => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name, |
|
445 | + 'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email, |
|
446 | + 'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name, |
|
447 | + 'user_last' => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name, |
|
448 | 448 | ); |
449 | 449 | |
450 | - if ( ! is_email( $valid_user_data['user_email'] ) ) { |
|
451 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email', 'give' ) ); |
|
450 | + if ( ! is_email($valid_user_data['user_email'])) { |
|
451 | + give_set_error('email_invalid', esc_html__('Invalid email', 'give')); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | } else { |
455 | 455 | // Set invalid user error |
456 | - give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) ); |
|
456 | + give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give')); |
|
457 | 457 | } |
458 | 458 | } |
459 | 459 | |
@@ -471,90 +471,90 @@ discard block |
||
471 | 471 | function give_purchase_form_validate_new_user() { |
472 | 472 | |
473 | 473 | $registering_new_user = false; |
474 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
474 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
475 | 475 | |
476 | 476 | // Start an empty array to collect valid user data |
477 | 477 | $valid_user_data = array( |
478 | 478 | // Assume there will be errors |
479 | - 'user_id' => - 1, |
|
479 | + 'user_id' => -1, |
|
480 | 480 | // Get first name |
481 | - 'user_first' => isset( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : '', |
|
481 | + 'user_first' => isset($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : '', |
|
482 | 482 | // Get last name |
483 | - 'user_last' => isset( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : '', |
|
483 | + 'user_last' => isset($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : '', |
|
484 | 484 | ); |
485 | 485 | |
486 | 486 | // Check the new user's credentials against existing ones |
487 | - $user_login = isset( $_POST['give_user_login'] ) ? trim( $_POST['give_user_login'] ) : false; |
|
488 | - $user_email = isset( $_POST['give_email'] ) ? trim( $_POST['give_email'] ) : false; |
|
489 | - $user_pass = isset( $_POST['give_user_pass'] ) ? trim( $_POST['give_user_pass'] ) : false; |
|
490 | - $pass_confirm = isset( $_POST['give_user_pass_confirm'] ) ? trim( $_POST['give_user_pass_confirm'] ) : false; |
|
487 | + $user_login = isset($_POST['give_user_login']) ? trim($_POST['give_user_login']) : false; |
|
488 | + $user_email = isset($_POST['give_email']) ? trim($_POST['give_email']) : false; |
|
489 | + $user_pass = isset($_POST['give_user_pass']) ? trim($_POST['give_user_pass']) : false; |
|
490 | + $pass_confirm = isset($_POST['give_user_pass_confirm']) ? trim($_POST['give_user_pass_confirm']) : false; |
|
491 | 491 | |
492 | 492 | // Loop through required fields and show error messages |
493 | - foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) { |
|
494 | - if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
495 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
493 | + foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) { |
|
494 | + if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
495 | + give_set_error($value['error_id'], $value['error_message']); |
|
496 | 496 | } |
497 | 497 | } |
498 | 498 | |
499 | 499 | // Check if we have an username to register |
500 | - if ( $user_login && strlen( $user_login ) > 0 ) { |
|
500 | + if ($user_login && strlen($user_login) > 0) { |
|
501 | 501 | $registering_new_user = true; |
502 | 502 | |
503 | 503 | // We have an user name, check if it already exists |
504 | - if ( username_exists( $user_login ) ) { |
|
504 | + if (username_exists($user_login)) { |
|
505 | 505 | // Username already registered |
506 | - give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) ); |
|
506 | + give_set_error('username_unavailable', esc_html__('Username already taken.', 'give')); |
|
507 | 507 | // Check if it's valid |
508 | - } else if ( ! give_validate_username( $user_login ) ) { |
|
508 | + } else if ( ! give_validate_username($user_login)) { |
|
509 | 509 | // Invalid username |
510 | - if ( is_multisite() ) { |
|
511 | - give_set_error( 'username_invalid', esc_html__( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) ); |
|
510 | + if (is_multisite()) { |
|
511 | + give_set_error('username_invalid', esc_html__('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give')); |
|
512 | 512 | } else { |
513 | - give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) ); |
|
513 | + give_set_error('username_invalid', esc_html__('Invalid username.', 'give')); |
|
514 | 514 | } |
515 | 515 | } else { |
516 | 516 | // All the checks have run and it's good to go |
517 | 517 | $valid_user_data['user_login'] = $user_login; |
518 | 518 | } |
519 | - } elseif ( give_logged_in_only( $form_id ) ) { |
|
520 | - give_set_error( 'registration_required', esc_html__( 'You must register or login to complete your donation.', 'give' ) ); |
|
519 | + } elseif (give_logged_in_only($form_id)) { |
|
520 | + give_set_error('registration_required', esc_html__('You must register or login to complete your donation.', 'give')); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | // Check if we have an email to verify |
524 | - if ( $user_email && strlen( $user_email ) > 0 ) { |
|
524 | + if ($user_email && strlen($user_email) > 0) { |
|
525 | 525 | // Validate email |
526 | - if ( ! is_email( $user_email ) ) { |
|
527 | - give_set_error( 'email_invalid', esc_html__( 'Sorry, that email is invalid.', 'give' ) ); |
|
526 | + if ( ! is_email($user_email)) { |
|
527 | + give_set_error('email_invalid', esc_html__('Sorry, that email is invalid.', 'give')); |
|
528 | 528 | // Check if email exists |
529 | - } else if ( email_exists( $user_email ) && $registering_new_user ) { |
|
530 | - give_set_error( 'email_used', esc_html__( 'Sorry, that email already active for another user.', 'give' ) ); |
|
529 | + } else if (email_exists($user_email) && $registering_new_user) { |
|
530 | + give_set_error('email_used', esc_html__('Sorry, that email already active for another user.', 'give')); |
|
531 | 531 | } else { |
532 | 532 | // All the checks have run and it's good to go |
533 | 533 | $valid_user_data['user_email'] = $user_email; |
534 | 534 | } |
535 | 535 | } else { |
536 | 536 | // No email |
537 | - give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) ); |
|
537 | + give_set_error('email_empty', esc_html__('Enter an email.', 'give')); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | // Check password |
541 | - if ( $user_pass && $pass_confirm ) { |
|
541 | + if ($user_pass && $pass_confirm) { |
|
542 | 542 | // Verify confirmation matches |
543 | - if ( $user_pass != $pass_confirm ) { |
|
543 | + if ($user_pass != $pass_confirm) { |
|
544 | 544 | // Passwords do not match |
545 | - give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) ); |
|
545 | + give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give')); |
|
546 | 546 | } else { |
547 | 547 | // All is good to go |
548 | 548 | $valid_user_data['user_pass'] = $user_pass; |
549 | 549 | } |
550 | 550 | } else { |
551 | 551 | // Password or confirmation missing |
552 | - if ( ! $user_pass && $registering_new_user ) { |
|
552 | + if ( ! $user_pass && $registering_new_user) { |
|
553 | 553 | // The password is invalid |
554 | - give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) ); |
|
555 | - } else if ( ! $pass_confirm && $registering_new_user ) { |
|
554 | + give_set_error('password_empty', esc_html__('Enter a password.', 'give')); |
|
555 | + } else if ( ! $pass_confirm && $registering_new_user) { |
|
556 | 556 | // Confirmation password is invalid |
557 | - give_set_error( 'confirmation_empty', esc_html__( 'Enter the password confirmation.', 'give' ) ); |
|
557 | + give_set_error('confirmation_empty', esc_html__('Enter the password confirmation.', 'give')); |
|
558 | 558 | } |
559 | 559 | } |
560 | 560 | |
@@ -573,36 +573,36 @@ discard block |
||
573 | 573 | // Start an array to collect valid user data |
574 | 574 | $valid_user_data = array( |
575 | 575 | // Assume there will be errors |
576 | - 'user_id' => - 1 |
|
576 | + 'user_id' => -1 |
|
577 | 577 | ); |
578 | 578 | |
579 | 579 | // Username |
580 | - if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) { |
|
581 | - give_set_error( 'must_log_in', esc_html__( 'You must login or register to complete your donation.', 'give' ) ); |
|
580 | + if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') { |
|
581 | + give_set_error('must_log_in', esc_html__('You must login or register to complete your donation.', 'give')); |
|
582 | 582 | |
583 | 583 | return $valid_user_data; |
584 | 584 | } |
585 | 585 | |
586 | 586 | // Get the user by login |
587 | - $user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) ); |
|
587 | + $user_data = get_user_by('login', strip_tags($_POST['give_user_login'])); |
|
588 | 588 | |
589 | 589 | // Check if user exists |
590 | - if ( $user_data ) { |
|
590 | + if ($user_data) { |
|
591 | 591 | // Get password |
592 | - $user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false; |
|
592 | + $user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false; |
|
593 | 593 | |
594 | 594 | // Check user_pass |
595 | - if ( $user_pass ) { |
|
595 | + if ($user_pass) { |
|
596 | 596 | // Check if password is valid |
597 | - if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { |
|
597 | + if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { |
|
598 | 598 | // Incorrect password |
599 | 599 | give_set_error( |
600 | 600 | 'password_incorrect', |
601 | 601 | sprintf( |
602 | 602 | '%1$s <a href="%2$s">%3$s</a>', |
603 | - esc_html__( 'The password you entered is incorrect.', 'give' ), |
|
604 | - wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ), |
|
605 | - esc_html__( 'Reset Password', 'give' ) |
|
603 | + esc_html__('The password you entered is incorrect.', 'give'), |
|
604 | + wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"), |
|
605 | + esc_html__('Reset Password', 'give') |
|
606 | 606 | ) |
607 | 607 | ); |
608 | 608 | // All is correct |
@@ -619,11 +619,11 @@ discard block |
||
619 | 619 | } |
620 | 620 | } else { |
621 | 621 | // Empty password |
622 | - give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) ); |
|
622 | + give_set_error('password_empty', esc_html__('Enter a password.', 'give')); |
|
623 | 623 | } |
624 | 624 | } else { |
625 | 625 | // no username |
626 | - give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) ); |
|
626 | + give_set_error('username_incorrect', esc_html__('The username you entered does not exist.', 'give')); |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | return $valid_user_data; |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | */ |
639 | 639 | function give_purchase_form_validate_guest_user() { |
640 | 640 | |
641 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
641 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
642 | 642 | |
643 | 643 | // Start an array to collect valid user data |
644 | 644 | $valid_user_data = array( |
@@ -647,32 +647,32 @@ discard block |
||
647 | 647 | ); |
648 | 648 | |
649 | 649 | // Show error message if user must be logged in |
650 | - if ( give_logged_in_only( $form_id ) ) { |
|
651 | - give_set_error( 'logged_in_only', esc_html__( 'You must be logged into to donate.', 'give' ) ); |
|
650 | + if (give_logged_in_only($form_id)) { |
|
651 | + give_set_error('logged_in_only', esc_html__('You must be logged into to donate.', 'give')); |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | // Get the guest email |
655 | - $guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
655 | + $guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
656 | 656 | |
657 | 657 | // Check email |
658 | - if ( $guest_email && strlen( $guest_email ) > 0 ) { |
|
658 | + if ($guest_email && strlen($guest_email) > 0) { |
|
659 | 659 | // Validate email |
660 | - if ( ! is_email( $guest_email ) ) { |
|
660 | + if ( ! is_email($guest_email)) { |
|
661 | 661 | // Invalid email |
662 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
662 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
663 | 663 | } else { |
664 | 664 | // All is good to go |
665 | 665 | $valid_user_data['user_email'] = $guest_email; |
666 | 666 | } |
667 | 667 | } else { |
668 | 668 | // No email |
669 | - give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) ); |
|
669 | + give_set_error('email_empty', esc_html__('Enter an email.', 'give')); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | // Loop through required fields and show error messages |
673 | - foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) { |
|
674 | - if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
675 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
673 | + foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) { |
|
674 | + if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
675 | + give_set_error($value['error_id'], $value['error_message']); |
|
676 | 676 | } |
677 | 677 | } |
678 | 678 | |
@@ -688,42 +688,42 @@ discard block |
||
688 | 688 | * @since 1.0 |
689 | 689 | * @return integer |
690 | 690 | */ |
691 | -function give_register_and_login_new_user( $user_data = array() ) { |
|
691 | +function give_register_and_login_new_user($user_data = array()) { |
|
692 | 692 | // Verify the array |
693 | - if ( empty( $user_data ) ) { |
|
694 | - return - 1; |
|
693 | + if (empty($user_data)) { |
|
694 | + return -1; |
|
695 | 695 | } |
696 | 696 | |
697 | - if ( give_get_errors() ) { |
|
698 | - return - 1; |
|
697 | + if (give_get_errors()) { |
|
698 | + return -1; |
|
699 | 699 | } |
700 | 700 | |
701 | - $user_args = apply_filters( 'give_insert_user_args', array( |
|
702 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '', |
|
703 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '', |
|
704 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '', |
|
705 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '', |
|
706 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '', |
|
707 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
708 | - 'role' => get_option( 'default_role' ) |
|
709 | - ), $user_data ); |
|
701 | + $user_args = apply_filters('give_insert_user_args', array( |
|
702 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', |
|
703 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', |
|
704 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', |
|
705 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', |
|
706 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', |
|
707 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
708 | + 'role' => get_option('default_role') |
|
709 | + ), $user_data); |
|
710 | 710 | |
711 | 711 | // Insert new user |
712 | - $user_id = wp_insert_user( $user_args ); |
|
712 | + $user_id = wp_insert_user($user_args); |
|
713 | 713 | |
714 | 714 | // Validate inserted user |
715 | - if ( is_wp_error( $user_id ) ) { |
|
716 | - return - 1; |
|
715 | + if (is_wp_error($user_id)) { |
|
716 | + return -1; |
|
717 | 717 | } |
718 | 718 | |
719 | 719 | // Allow themes and plugins to filter the user data |
720 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args ); |
|
720 | + $user_data = apply_filters('give_insert_user_data', $user_data, $user_args); |
|
721 | 721 | |
722 | 722 | // Allow themes and plugins to hook |
723 | - do_action( 'give_insert_user', $user_id, $user_data ); |
|
723 | + do_action('give_insert_user', $user_id, $user_data); |
|
724 | 724 | |
725 | 725 | // Login new user |
726 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] ); |
|
726 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']); |
|
727 | 727 | |
728 | 728 | // Return user id |
729 | 729 | return $user_id; |
@@ -738,27 +738,27 @@ discard block |
||
738 | 738 | * @since 1.0 |
739 | 739 | * @return array |
740 | 740 | */ |
741 | -function give_get_purchase_form_user( $valid_data = array() ) { |
|
741 | +function give_get_purchase_form_user($valid_data = array()) { |
|
742 | 742 | |
743 | 743 | // Initialize user |
744 | 744 | $user = false; |
745 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
745 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
746 | 746 | |
747 | - if ( $is_ajax ) { |
|
747 | + if ($is_ajax) { |
|
748 | 748 | // Do not create or login the user during the ajax submission (check for errors only) |
749 | 749 | return true; |
750 | - } else if ( is_user_logged_in() ) { |
|
750 | + } else if (is_user_logged_in()) { |
|
751 | 751 | // Set the valid user as the logged in collected data |
752 | 752 | $user = $valid_data['logged_in_user']; |
753 | - } else if ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) { |
|
753 | + } else if ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) { |
|
754 | 754 | // New user registration |
755 | - if ( $valid_data['need_new_user'] === true ) { |
|
755 | + if ($valid_data['need_new_user'] === true) { |
|
756 | 756 | // Set user |
757 | 757 | $user = $valid_data['new_user_data']; |
758 | 758 | // Register and login new user |
759 | - $user['user_id'] = give_register_and_login_new_user( $user ); |
|
759 | + $user['user_id'] = give_register_and_login_new_user($user); |
|
760 | 760 | // User login |
761 | - } else if ( $valid_data['need_user_login'] === true && ! $is_ajax ) { |
|
761 | + } else if ($valid_data['need_user_login'] === true && ! $is_ajax) { |
|
762 | 762 | |
763 | 763 | /* |
764 | 764 | * The login form is now processed in the give_process_purchase_login() function. |
@@ -773,48 +773,48 @@ discard block |
||
773 | 773 | // Set user |
774 | 774 | $user = $valid_data['login_user_data']; |
775 | 775 | // Login user |
776 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] ); |
|
776 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); |
|
777 | 777 | } |
778 | 778 | } |
779 | 779 | |
780 | 780 | // Check guest checkout |
781 | - if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) { |
|
781 | + if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) { |
|
782 | 782 | // Set user |
783 | 783 | $user = $valid_data['guest_user_data']; |
784 | 784 | } |
785 | 785 | |
786 | 786 | // Verify we have an user |
787 | - if ( false === $user || empty( $user ) ) { |
|
787 | + if (false === $user || empty($user)) { |
|
788 | 788 | // Return false |
789 | 789 | return false; |
790 | 790 | } |
791 | 791 | |
792 | 792 | // Get user first name |
793 | - if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { |
|
794 | - $user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : ''; |
|
793 | + if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { |
|
794 | + $user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : ''; |
|
795 | 795 | } |
796 | 796 | |
797 | 797 | // Get user last name |
798 | - if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { |
|
799 | - $user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : ''; |
|
798 | + if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { |
|
799 | + $user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : ''; |
|
800 | 800 | } |
801 | 801 | |
802 | 802 | // Get the user's billing address details |
803 | 803 | $user['address'] = array(); |
804 | - $user['address']['line1'] = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false; |
|
805 | - $user['address']['line2'] = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false; |
|
806 | - $user['address']['city'] = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false; |
|
807 | - $user['address']['state'] = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false; |
|
808 | - $user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false; |
|
809 | - $user['address']['zip'] = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false; |
|
810 | - |
|
811 | - if ( empty( $user['address']['country'] ) ) { |
|
804 | + $user['address']['line1'] = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false; |
|
805 | + $user['address']['line2'] = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false; |
|
806 | + $user['address']['city'] = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false; |
|
807 | + $user['address']['state'] = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false; |
|
808 | + $user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false; |
|
809 | + $user['address']['zip'] = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false; |
|
810 | + |
|
811 | + if (empty($user['address']['country'])) { |
|
812 | 812 | $user['address'] = false; |
813 | 813 | } // Country will always be set if address fields are present |
814 | 814 | |
815 | - if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) { |
|
815 | + if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) { |
|
816 | 816 | // Store the address in the user's meta so the donation form can be pre-populated with it on return purchases |
817 | - update_user_meta( $user['user_id'], '_give_user_address', $user['address'] ); |
|
817 | + update_user_meta($user['user_id'], '_give_user_address', $user['address']); |
|
818 | 818 | } |
819 | 819 | |
820 | 820 | // Return valid user |
@@ -833,16 +833,16 @@ discard block |
||
833 | 833 | $card_data = give_get_purchase_cc_info(); |
834 | 834 | |
835 | 835 | // Validate the card zip |
836 | - if ( ! empty( $card_data['card_zip'] ) ) { |
|
837 | - if ( ! give_purchase_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { |
|
838 | - give_set_error( 'invalid_cc_zip', esc_html__( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) ); |
|
836 | + if ( ! empty($card_data['card_zip'])) { |
|
837 | + if ( ! give_purchase_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { |
|
838 | + give_set_error('invalid_cc_zip', esc_html__('The zip / postal code you entered for your billing address is invalid.', 'give')); |
|
839 | 839 | } |
840 | 840 | } |
841 | 841 | |
842 | 842 | //Ensure no spaces |
843 | - if ( ! empty( $card_data['card_number'] ) ) { |
|
844 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); //no "+" signs |
|
845 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces |
|
843 | + if ( ! empty($card_data['card_number'])) { |
|
844 | + $card_data['card_number'] = str_replace('+', '', $card_data['card_number']); //no "+" signs |
|
845 | + $card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | // This should validate card numbers at some point too |
@@ -858,17 +858,17 @@ discard block |
||
858 | 858 | */ |
859 | 859 | function give_get_purchase_cc_info() { |
860 | 860 | $cc_info = array(); |
861 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
862 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
863 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
864 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
865 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
866 | - $cc_info['card_address'] = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : ''; |
|
867 | - $cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : ''; |
|
868 | - $cc_info['card_city'] = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : ''; |
|
869 | - $cc_info['card_state'] = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : ''; |
|
870 | - $cc_info['card_country'] = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : ''; |
|
871 | - $cc_info['card_zip'] = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : ''; |
|
861 | + $cc_info['card_name'] = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : ''; |
|
862 | + $cc_info['card_number'] = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : ''; |
|
863 | + $cc_info['card_cvc'] = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : ''; |
|
864 | + $cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : ''; |
|
865 | + $cc_info['card_exp_year'] = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : ''; |
|
866 | + $cc_info['card_address'] = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : ''; |
|
867 | + $cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : ''; |
|
868 | + $cc_info['card_city'] = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : ''; |
|
869 | + $cc_info['card_state'] = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : ''; |
|
870 | + $cc_info['card_country'] = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : ''; |
|
871 | + $cc_info['card_zip'] = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : ''; |
|
872 | 872 | |
873 | 873 | // Return cc info |
874 | 874 | return $cc_info; |
@@ -884,14 +884,14 @@ discard block |
||
884 | 884 | * |
885 | 885 | * @return bool|mixed|void |
886 | 886 | */ |
887 | -function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
887 | +function give_purchase_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
888 | 888 | $ret = false; |
889 | 889 | |
890 | - if ( empty( $zip ) || empty( $country_code ) ) { |
|
890 | + if (empty($zip) || empty($country_code)) { |
|
891 | 891 | return $ret; |
892 | 892 | } |
893 | 893 | |
894 | - $country_code = strtoupper( $country_code ); |
|
894 | + $country_code = strtoupper($country_code); |
|
895 | 895 | |
896 | 896 | $zip_regex = array( |
897 | 897 | "AD" => "AD\d{3}", |
@@ -1051,11 +1051,11 @@ discard block |
||
1051 | 1051 | "ZM" => "\d{5}" |
1052 | 1052 | ); |
1053 | 1053 | |
1054 | - if ( ! isset ( $zip_regex[ $country_code ] ) || preg_match( "/" . $zip_regex[ $country_code ] . "/i", $zip ) ) { |
|
1054 | + if ( ! isset ($zip_regex[$country_code]) || preg_match("/".$zip_regex[$country_code]."/i", $zip)) { |
|
1055 | 1055 | $ret = true; |
1056 | 1056 | } |
1057 | 1057 | |
1058 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code ); |
|
1058 | + return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); |
|
1059 | 1059 | } |
1060 | 1060 | |
1061 | 1061 | |
@@ -1069,37 +1069,37 @@ discard block |
||
1069 | 1069 | * |
1070 | 1070 | * @return bool |
1071 | 1071 | */ |
1072 | -function give_validate_multi_donation_form_level( $valid_data, $data ) { |
|
1072 | +function give_validate_multi_donation_form_level($valid_data, $data) { |
|
1073 | 1073 | /* @var Give_Donate_Form $form*/ |
1074 | - $form = new Give_Donate_Form( $data['give-form-id'] ); |
|
1074 | + $form = new Give_Donate_Form($data['give-form-id']); |
|
1075 | 1075 | |
1076 | 1076 | $donation_level_matched = false; |
1077 | 1077 | |
1078 | - if( $form->is_multi_type_donation_form() ) { |
|
1078 | + if ($form->is_multi_type_donation_form()) { |
|
1079 | 1079 | |
1080 | 1080 | // Bailout. |
1081 | - if( ! ( $variable_prices = $form->get_prices() ) ) { |
|
1081 | + if ( ! ($variable_prices = $form->get_prices())) { |
|
1082 | 1082 | return false; |
1083 | 1083 | } |
1084 | 1084 | |
1085 | 1085 | // Sanitize donation amount. |
1086 | - $data['give-amount'] = give_sanitize_amount( $data['give-amount'] ); |
|
1086 | + $data['give-amount'] = give_sanitize_amount($data['give-amount']); |
|
1087 | 1087 | |
1088 | 1088 | // Get number of decimals. |
1089 | 1089 | $default_decimals = give_get_price_decimals(); |
1090 | 1090 | |
1091 | - if( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ){ |
|
1091 | + if ($data['give-amount'] === give_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']), $default_decimals)) { |
|
1092 | 1092 | return true; |
1093 | 1093 | } |
1094 | 1094 | |
1095 | 1095 | |
1096 | 1096 | // Find correct donation level from all donation levels. |
1097 | - foreach ( $variable_prices as $variable_price ) { |
|
1097 | + foreach ($variable_prices as $variable_price) { |
|
1098 | 1098 | // Sanitize level amount. |
1099 | - $variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals ); |
|
1099 | + $variable_price['_give_amount'] = give_sanitize_amount($variable_price['_give_amount'], $default_decimals); |
|
1100 | 1100 | |
1101 | 1101 | // Set first match donation level ID. |
1102 | - if( $data['give-amount'] === $variable_price['_give_amount'] ) { |
|
1102 | + if ($data['give-amount'] === $variable_price['_give_amount']) { |
|
1103 | 1103 | $_POST['give-price-id'] = $variable_price['_give_id']['level_id']; |
1104 | 1104 | $donation_level_matched = true; |
1105 | 1105 | break; |
@@ -1108,20 +1108,20 @@ discard block |
||
1108 | 1108 | |
1109 | 1109 | // If donation amount is not find in donation levels then check if form has custom donation feature enable or not. |
1110 | 1110 | // If yes then set price id to custom if amount is greater then custom minimum amount (if any). |
1111 | - if( |
|
1111 | + if ( |
|
1112 | 1112 | ! $donation_level_matched |
1113 | - && ( 'yes' === get_post_meta( $data['give-form-id'], '_give_custom_amount', true ) ) |
|
1113 | + && ('yes' === get_post_meta($data['give-form-id'], '_give_custom_amount', true)) |
|
1114 | 1114 | ) { |
1115 | 1115 | // Sanitize custom minimum amount. |
1116 | - $custom_minimum_amount = give_sanitize_amount( get_post_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals ); |
|
1116 | + $custom_minimum_amount = give_sanitize_amount(get_post_meta($data['give-form-id'], '_give_custom_amount_minimum', true), $default_decimals); |
|
1117 | 1117 | |
1118 | - if( $data['give-amount'] >= $custom_minimum_amount ) { |
|
1118 | + if ($data['give-amount'] >= $custom_minimum_amount) { |
|
1119 | 1119 | $_POST['give-price-id'] = 'custom'; |
1120 | - $donation_level_matched = true; |
|
1120 | + $donation_level_matched = true; |
|
1121 | 1121 | } |
1122 | 1122 | } |
1123 | 1123 | } |
1124 | 1124 | |
1125 | - return ( $donation_level_matched ? true : false ); |
|
1125 | + return ($donation_level_matched ? true : false); |
|
1126 | 1126 | } |
1127 | -add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 ); |
|
1128 | 1127 | \ No newline at end of file |
1128 | +add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2); |
|
1129 | 1129 | \ No newline at end of file |
@@ -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 | */ |
@@ -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 && ! Give()->email_access->token_exists ) { |
|
39 | + if (0 === $user && ! Give()->email_access->token_exists) { |
|
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,65 +101,65 @@ 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[] = isset($purchase_meta['form_id']) ? $purchase_meta['form_id'] : ''; |
140 | 140 | } |
141 | 141 | |
142 | - if ( empty( $completed_donations_ids ) ) { |
|
142 | + if (empty($completed_donations_ids)) { |
|
143 | 143 | return false; |
144 | 144 | } |
145 | 145 | |
146 | 146 | // Only include each product purchased once |
147 | - $form_ids = array_unique( $completed_donations_ids ); |
|
147 | + $form_ids = array_unique($completed_donations_ids); |
|
148 | 148 | |
149 | 149 | // Make sure we still have some products and a first item |
150 | - if ( empty ( $form_ids ) || ! isset( $form_ids[0] ) ) { |
|
150 | + if (empty ($form_ids) || ! isset($form_ids[0])) { |
|
151 | 151 | return false; |
152 | 152 | } |
153 | 153 | |
154 | - $post_type = get_post_type( $form_ids[0] ); |
|
154 | + $post_type = get_post_type($form_ids[0]); |
|
155 | 155 | |
156 | - $args = apply_filters( 'give_get_users_completed_donations_args', array( |
|
156 | + $args = apply_filters('give_get_users_completed_donations_args', array( |
|
157 | 157 | 'include' => $form_ids, |
158 | 158 | 'post_type' => $post_type, |
159 | - 'posts_per_page' => - 1 |
|
160 | - ) ); |
|
159 | + 'posts_per_page' => -1 |
|
160 | + )); |
|
161 | 161 | |
162 | - return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) ); |
|
162 | + return apply_filters('give_users_completed_donations_list', get_posts($args)); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
@@ -175,12 +175,12 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return bool - true if has purchased, false other wise. |
177 | 177 | */ |
178 | -function give_has_purchases( $user_id = null ) { |
|
179 | - if ( empty( $user_id ) ) { |
|
178 | +function give_has_purchases($user_id = null) { |
|
179 | + if (empty($user_id)) { |
|
180 | 180 | $user_id = get_current_user_id(); |
181 | 181 | } |
182 | 182 | |
183 | - if ( give_get_users_purchases( $user_id, 1 ) ) { |
|
183 | + if (give_get_users_purchases($user_id, 1)) { |
|
184 | 184 | return true; // User has at least one purchase |
185 | 185 | } |
186 | 186 | |
@@ -200,32 +200,32 @@ 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 | 215 | $stats = array(); |
216 | - $customer = Give()->customers->get_customer_by( $field, $user ); |
|
216 | + $customer = Give()->customers->get_customer_by($field, $user); |
|
217 | 217 | |
218 | - if ( $customer ) { |
|
218 | + if ($customer) { |
|
219 | 219 | |
220 | - $customer = new Give_Customer( $customer->id ); |
|
220 | + $customer = new Give_Customer($customer->id); |
|
221 | 221 | |
222 | - $stats['purchases'] = absint( $customer->purchase_count ); |
|
223 | - $stats['total_spent'] = give_sanitize_amount( $customer->purchase_value ); |
|
222 | + $stats['purchases'] = absint($customer->purchase_count); |
|
223 | + $stats['total_spent'] = give_sanitize_amount($customer->purchase_value); |
|
224 | 224 | |
225 | 225 | } |
226 | 226 | |
227 | 227 | |
228 | - return (array) apply_filters( 'give_purchase_stats_by_user', $stats, $user ); |
|
228 | + return (array) apply_filters('give_purchase_stats_by_user', $stats, $user); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | |
@@ -241,22 +241,22 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @return int - the total number of purchases |
243 | 243 | */ |
244 | -function give_count_purchases_of_customer( $user = null ) { |
|
244 | +function give_count_purchases_of_customer($user = null) { |
|
245 | 245 | |
246 | 246 | //Logged in? |
247 | - if ( empty( $user ) ) { |
|
247 | + if (empty($user)) { |
|
248 | 248 | $user = get_current_user_id(); |
249 | 249 | } |
250 | 250 | |
251 | 251 | //Email access? |
252 | - if ( empty( $user ) && Give()->email_access->token_email ) { |
|
252 | + if (empty($user) && Give()->email_access->token_email) { |
|
253 | 253 | $user = Give()->email_access->token_email; |
254 | 254 | } |
255 | 255 | |
256 | 256 | |
257 | - $stats = ! empty( $user ) ? give_get_purchase_stats_by_user( $user ) : false; |
|
257 | + $stats = ! empty($user) ? give_get_purchase_stats_by_user($user) : false; |
|
258 | 258 | |
259 | - return isset( $stats['purchases'] ) ? $stats['purchases'] : 0; |
|
259 | + return isset($stats['purchases']) ? $stats['purchases'] : 0; |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -269,9 +269,9 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @return float - the total amount the user has spent |
271 | 271 | */ |
272 | -function give_purchase_total_of_user( $user = null ) { |
|
272 | +function give_purchase_total_of_user($user = null) { |
|
273 | 273 | |
274 | - $stats = give_get_purchase_stats_by_user( $user ); |
|
274 | + $stats = give_get_purchase_stats_by_user($user); |
|
275 | 275 | |
276 | 276 | return $stats['total_spent']; |
277 | 277 | } |
@@ -287,11 +287,11 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @return bool |
289 | 289 | */ |
290 | -function give_validate_username( $username ) { |
|
291 | - $sanitized = sanitize_user( $username, false ); |
|
292 | - $valid = ( $sanitized == $username ); |
|
290 | +function give_validate_username($username) { |
|
291 | + $sanitized = sanitize_user($username, false); |
|
292 | + $valid = ($sanitized == $username); |
|
293 | 293 | |
294 | - return (bool) apply_filters( 'give_validate_username', $valid, $username ); |
|
294 | + return (bool) apply_filters('give_validate_username', $valid, $username); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | |
@@ -308,32 +308,32 @@ discard block |
||
308 | 308 | * |
309 | 309 | * @return void |
310 | 310 | */ |
311 | -function give_add_past_purchases_to_new_user( $user_id ) { |
|
311 | +function give_add_past_purchases_to_new_user($user_id) { |
|
312 | 312 | |
313 | - $email = get_the_author_meta( 'user_email', $user_id ); |
|
313 | + $email = get_the_author_meta('user_email', $user_id); |
|
314 | 314 | |
315 | - $payments = give_get_payments( array( 's' => $email ) ); |
|
315 | + $payments = give_get_payments(array('s' => $email)); |
|
316 | 316 | |
317 | - if ( $payments ) { |
|
318 | - foreach ( $payments as $payment ) { |
|
319 | - if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) { |
|
317 | + if ($payments) { |
|
318 | + foreach ($payments as $payment) { |
|
319 | + if (intval(give_get_payment_user_id($payment->ID)) > 0) { |
|
320 | 320 | continue; |
321 | 321 | } // This payment already associated with an account |
322 | 322 | |
323 | - $meta = give_get_payment_meta( $payment->ID ); |
|
324 | - $meta['user_info'] = maybe_unserialize( $meta['user_info'] ); |
|
323 | + $meta = give_get_payment_meta($payment->ID); |
|
324 | + $meta['user_info'] = maybe_unserialize($meta['user_info']); |
|
325 | 325 | $meta['user_info']['id'] = $user_id; |
326 | 326 | $meta['user_info'] = $meta['user_info']; |
327 | 327 | |
328 | 328 | // Store the updated user ID in the payment meta |
329 | - give_update_payment_meta( $payment->ID, '_give_payment_meta', $meta ); |
|
330 | - give_update_payment_meta( $payment->ID, '_give_payment_user_id', $user_id ); |
|
329 | + give_update_payment_meta($payment->ID, '_give_payment_meta', $meta); |
|
330 | + give_update_payment_meta($payment->ID, '_give_payment_user_id', $user_id); |
|
331 | 331 | } |
332 | 332 | } |
333 | 333 | |
334 | 334 | } |
335 | 335 | |
336 | -add_action( 'user_register', 'give_add_past_purchases_to_new_user' ); |
|
336 | +add_action('user_register', 'give_add_past_purchases_to_new_user'); |
|
337 | 337 | |
338 | 338 | |
339 | 339 | /** |
@@ -355,34 +355,34 @@ discard block |
||
355 | 355 | * @since 1.0 |
356 | 356 | * @return array - The donor's address, if any |
357 | 357 | */ |
358 | -function give_get_donor_address( $user_id = 0 ) { |
|
359 | - if ( empty( $user_id ) ) { |
|
358 | +function give_get_donor_address($user_id = 0) { |
|
359 | + if (empty($user_id)) { |
|
360 | 360 | $user_id = get_current_user_id(); |
361 | 361 | } |
362 | 362 | |
363 | - $address = get_user_meta( $user_id, '_give_user_address', true ); |
|
363 | + $address = get_user_meta($user_id, '_give_user_address', true); |
|
364 | 364 | |
365 | - if ( ! isset( $address['line1'] ) ) { |
|
365 | + if ( ! isset($address['line1'])) { |
|
366 | 366 | $address['line1'] = ''; |
367 | 367 | } |
368 | 368 | |
369 | - if ( ! isset( $address['line2'] ) ) { |
|
369 | + if ( ! isset($address['line2'])) { |
|
370 | 370 | $address['line2'] = ''; |
371 | 371 | } |
372 | 372 | |
373 | - if ( ! isset( $address['city'] ) ) { |
|
373 | + if ( ! isset($address['city'])) { |
|
374 | 374 | $address['city'] = ''; |
375 | 375 | } |
376 | 376 | |
377 | - if ( ! isset( $address['zip'] ) ) { |
|
377 | + if ( ! isset($address['zip'])) { |
|
378 | 378 | $address['zip'] = ''; |
379 | 379 | } |
380 | 380 | |
381 | - if ( ! isset( $address['country'] ) ) { |
|
381 | + if ( ! isset($address['country'])) { |
|
382 | 382 | $address['country'] = ''; |
383 | 383 | } |
384 | 384 | |
385 | - if ( ! isset( $address['state'] ) ) { |
|
385 | + if ( ! isset($address['state'])) { |
|
386 | 386 | $address['state'] = ''; |
387 | 387 | } |
388 | 388 | |
@@ -402,42 +402,42 @@ discard block |
||
402 | 402 | * |
403 | 403 | * @return void |
404 | 404 | */ |
405 | -function give_new_user_notification( $user_id = 0, $user_data = array() ) { |
|
405 | +function give_new_user_notification($user_id = 0, $user_data = array()) { |
|
406 | 406 | |
407 | - if ( empty( $user_id ) || empty( $user_data ) ) { |
|
407 | + if (empty($user_id) || empty($user_data)) { |
|
408 | 408 | return; |
409 | 409 | } |
410 | - $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
410 | + $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
411 | 411 | |
412 | 412 | /* translators: %s: site name */ |
413 | - $message = sprintf( esc_attr__( 'New user registration on your site %s:' ), $blogname ) . "\r\n\r\n"; |
|
413 | + $message = sprintf(esc_attr__('New user registration on your site %s:'), $blogname)."\r\n\r\n"; |
|
414 | 414 | /* translators: %s: user login */ |
415 | - $message .= sprintf( esc_attr__( 'Username: %s' ), $user_data['user_login'] ) . "\r\n\r\n"; |
|
415 | + $message .= sprintf(esc_attr__('Username: %s'), $user_data['user_login'])."\r\n\r\n"; |
|
416 | 416 | /* translators: %s: user email */ |
417 | - $message .= sprintf( esc_attr__( 'E-mail: %s' ), $user_data['user_email'] ) . "\r\n"; |
|
417 | + $message .= sprintf(esc_attr__('E-mail: %s'), $user_data['user_email'])."\r\n"; |
|
418 | 418 | |
419 | 419 | @wp_mail( |
420 | - get_option( 'admin_email' ), |
|
420 | + get_option('admin_email'), |
|
421 | 421 | sprintf( |
422 | 422 | /* translators: %s: site name */ |
423 | - esc_attr__( '[%s] New User Registration' ), |
|
423 | + esc_attr__('[%s] New User Registration'), |
|
424 | 424 | $blogname |
425 | 425 | ), |
426 | 426 | $message |
427 | 427 | ); |
428 | 428 | |
429 | 429 | /* translators: %s: user login */ |
430 | - $message = sprintf( esc_attr__( 'Username: %s' ), $user_data['user_login'] ) . "\r\n"; |
|
430 | + $message = sprintf(esc_attr__('Username: %s'), $user_data['user_login'])."\r\n"; |
|
431 | 431 | /* translators: %s: paswword */ |
432 | - $message .= sprintf( esc_attr__( 'Password: %s' ), esc_attr__( '[Password entered during donation]', 'give' ) ) . "\r\n"; |
|
432 | + $message .= sprintf(esc_attr__('Password: %s'), esc_attr__('[Password entered during donation]', 'give'))."\r\n"; |
|
433 | 433 | |
434 | - $message .= '<a href="' . wp_login_url() . '"> ' . esc_attr__( 'Click Here to Login »', 'give' ) . '</a>' . "\r\n"; |
|
434 | + $message .= '<a href="'.wp_login_url().'"> '.esc_attr__('Click Here to Login »', 'give').'</a>'."\r\n"; |
|
435 | 435 | |
436 | 436 | wp_mail( |
437 | 437 | $user_data['user_email'], |
438 | 438 | sprintf( |
439 | 439 | /* translators: %s: site name */ |
440 | - esc_attr__( '[%s] Your username and password' ), |
|
440 | + esc_attr__('[%s] Your username and password'), |
|
441 | 441 | $blogname |
442 | 442 | ), |
443 | 443 | $message |
@@ -445,4 +445,4 @@ discard block |
||
445 | 445 | |
446 | 446 | } |
447 | 447 | |
448 | -add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 ); |
|
448 | +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 | |
@@ -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,9 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
13 | +if ( ! defined( 'ABSPATH' ) ) { |
|
14 | + exit; |
|
15 | +} |
|
14 | 16 | |
15 | 17 | /** |
16 | 18 | * Payment History Page |
@@ -63,11 +65,13 @@ discard block |
||
63 | 65 | */ |
64 | 66 | function give_view_order_details_title( $admin_title, $title ) { |
65 | 67 | |
66 | - if ( 'give_forms_page_give-payment-history' != get_current_screen()->base ) |
|
67 | - return $admin_title; |
|
68 | + if ( 'give_forms_page_give-payment-history' != get_current_screen()->base ) { |
|
69 | + return $admin_title; |
|
70 | + } |
|
68 | 71 | |
69 | - if( ! isset( $_GET['give-action'] ) ) |
|
70 | - return $admin_title; |
|
72 | + if( ! isset( $_GET['give-action'] ) ) { |
|
73 | + return $admin_title; |
|
74 | + } |
|
71 | 75 | |
72 | 76 | switch( $_GET['give-action'] ) : |
73 | 77 | |
@@ -99,11 +103,13 @@ discard block |
||
99 | 103 | function give_override_edit_post_for_payment_link( $url, $post_id = 0, $context ) { |
100 | 104 | |
101 | 105 | $post = get_post( $post_id ); |
102 | - if( ! $post ) |
|
103 | - return $url; |
|
106 | + if( ! $post ) { |
|
107 | + return $url; |
|
108 | + } |
|
104 | 109 | |
105 | - if( 'give_payment' != $post->post_type ) |
|
106 | - return $url; |
|
110 | + if( 'give_payment' != $post->post_type ) { |
|
111 | + return $url; |
|
112 | + } |
|
107 | 113 | |
108 | 114 | $url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $post_id ); |
109 | 115 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
13 | +if ( ! defined('ABSPATH')) exit; |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Payment History Page |
@@ -24,12 +24,12 @@ discard block |
||
24 | 24 | function give_payment_history_page() { |
25 | 25 | global $give_options; |
26 | 26 | |
27 | - $give_payment = get_post_type_object( 'give_payment' ); |
|
27 | + $give_payment = get_post_type_object('give_payment'); |
|
28 | 28 | |
29 | - if ( isset( $_GET['view'] ) && 'view-order-details' == $_GET['view'] ) { |
|
30 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/view-order-details.php'; |
|
29 | + if (isset($_GET['view']) && 'view-order-details' == $_GET['view']) { |
|
30 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/view-order-details.php'; |
|
31 | 31 | } else { |
32 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/class-payments-table.php'; |
|
32 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/class-payments-table.php'; |
|
33 | 33 | $payments_table = new Give_Payment_History_Table(); |
34 | 34 | $payments_table->prepare_items(); |
35 | 35 | ?> |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @since 1.0 |
45 | 45 | */ |
46 | - do_action( 'give_payments_page_top' ); |
|
46 | + do_action('give_payments_page_top'); |
|
47 | 47 | ?> |
48 | 48 | |
49 | - <form id="give-payments-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>"> |
|
49 | + <form id="give-payments-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>"> |
|
50 | 50 | <input type="hidden" name="post_type" value="give_forms" /> |
51 | 51 | <input type="hidden" name="page" value="give-payment-history" /> |
52 | 52 | <?php $payments_table->views() ?> |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @since 1.0 |
62 | 62 | */ |
63 | - do_action( 'give_payments_page_bottom' ); |
|
63 | + do_action('give_payments_page_bottom'); |
|
64 | 64 | ?> |
65 | 65 | |
66 | 66 | </div> |
@@ -77,27 +77,27 @@ discard block |
||
77 | 77 | * @param $title |
78 | 78 | * @return string |
79 | 79 | */ |
80 | -function give_view_order_details_title( $admin_title, $title ) { |
|
80 | +function give_view_order_details_title($admin_title, $title) { |
|
81 | 81 | |
82 | - if ( 'give_forms_page_give-payment-history' != get_current_screen()->base ) |
|
82 | + if ('give_forms_page_give-payment-history' != get_current_screen()->base) |
|
83 | 83 | return $admin_title; |
84 | 84 | |
85 | - if( ! isset( $_GET['give-action'] ) ) |
|
85 | + if ( ! isset($_GET['give-action'])) |
|
86 | 86 | return $admin_title; |
87 | 87 | |
88 | - switch( $_GET['give-action'] ) : |
|
88 | + switch ($_GET['give-action']) : |
|
89 | 89 | |
90 | 90 | case 'view-order-details' : |
91 | 91 | $title = sprintf( |
92 | 92 | /* translators: %s: admin title */ |
93 | - esc_html__( 'View Donation Details - %s', 'give' ), |
|
93 | + esc_html__('View Donation Details - %s', 'give'), |
|
94 | 94 | $admin_title |
95 | 95 | ); |
96 | 96 | break; |
97 | 97 | case 'edit-payment' : |
98 | 98 | $title = sprintf( |
99 | 99 | /* translators: %s: admin title */ |
100 | - esc_html__( 'Edit Payment - %s', 'give' ), |
|
100 | + esc_html__('Edit Payment - %s', 'give'), |
|
101 | 101 | $admin_title |
102 | 102 | ); |
103 | 103 | break; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | return $title; |
110 | 110 | } |
111 | -add_filter( 'admin_title', 'give_view_order_details_title', 10, 2 ); |
|
111 | +add_filter('admin_title', 'give_view_order_details_title', 10, 2); |
|
112 | 112 | |
113 | 113 | /** |
114 | 114 | * Intercept default Edit post links for Give payments and rewrite them to the View Order Details screen |
@@ -120,17 +120,17 @@ discard block |
||
120 | 120 | * @param $context |
121 | 121 | * @return string |
122 | 122 | */ |
123 | -function give_override_edit_post_for_payment_link( $url, $post_id = 0, $context ) { |
|
123 | +function give_override_edit_post_for_payment_link($url, $post_id = 0, $context) { |
|
124 | 124 | |
125 | - $post = get_post( $post_id ); |
|
126 | - if( ! $post ) |
|
125 | + $post = get_post($post_id); |
|
126 | + if ( ! $post) |
|
127 | 127 | return $url; |
128 | 128 | |
129 | - if( 'give_payment' != $post->post_type ) |
|
129 | + if ('give_payment' != $post->post_type) |
|
130 | 130 | return $url; |
131 | 131 | |
132 | - $url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $post_id ); |
|
132 | + $url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$post_id); |
|
133 | 133 | |
134 | 134 | return $url; |
135 | 135 | } |
136 | -add_filter( 'get_edit_post_link', 'give_override_edit_post_for_payment_link', 10, 3 ); |
|
136 | +add_filter('get_edit_post_link', 'give_override_edit_post_for_payment_link', 10, 3); |
@@ -440,8 +440,10 @@ |
||
440 | 440 | echo give_get_payment_note_html( $note, $payment_id ); |
441 | 441 | |
442 | 442 | endforeach; |
443 | - else : |
|
443 | + else { |
|
444 | + : |
|
444 | 445 | $no_notes_display = ''; |
446 | + } |
|
445 | 447 | endif; |
446 | 448 | echo '<p class="give-no-payment-notes"' . $no_notes_display . '>' . __( 'No payment notes', 'give' ) . '</p>'; |
447 | 449 | ?> |
@@ -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 | |
@@ -20,27 +20,27 @@ discard block |
||
20 | 20 | * @since 1.0 |
21 | 21 | * @return void |
22 | 22 | */ |
23 | -if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
24 | - wp_die( esc_html__( 'Donation ID not supplied. Please try again.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
23 | +if ( ! isset($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
24 | + wp_die(esc_html__('Donation ID not supplied. Please try again.', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | // Setup the variables |
28 | -$payment_id = absint( $_GET['id'] ); |
|
29 | -$payment = new Give_Payment( $payment_id ); |
|
28 | +$payment_id = absint($_GET['id']); |
|
29 | +$payment = new Give_Payment($payment_id); |
|
30 | 30 | |
31 | 31 | // Sanity check... fail if purchase ID is invalid |
32 | 32 | $payment_exists = $payment->ID; |
33 | -if ( empty( $payment_exists ) ) { |
|
34 | - wp_die( esc_html__( 'The specified ID does not belong to a payment. Please try again.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
33 | +if (empty($payment_exists)) { |
|
34 | + wp_die(esc_html__('The specified ID does not belong to a payment. Please try again.', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | $number = $payment->number; |
38 | 38 | $payment_meta = $payment->get_meta(); |
39 | -$transaction_id = esc_attr( $payment->transaction_id ); |
|
39 | +$transaction_id = esc_attr($payment->transaction_id); |
|
40 | 40 | $user_id = $payment->user_id; |
41 | 41 | $customer_id = $payment->customer_id; |
42 | -$payment_date = strtotime( $payment->date ); |
|
43 | -$user_info = give_get_payment_meta_user_info( $payment_id ); |
|
42 | +$payment_date = strtotime($payment->date); |
|
43 | +$user_info = give_get_payment_meta_user_info($payment_id); |
|
44 | 44 | $address = $payment->address; |
45 | 45 | $gateway = $payment->gateway; |
46 | 46 | $currency_code = $payment->currency; |
@@ -53,75 +53,75 @@ discard block |
||
53 | 53 | <h1 id="transaction-details-heading"><?php |
54 | 54 | printf( |
55 | 55 | /* translators: %s: payment number */ |
56 | - esc_html__( 'Payment %s', 'give' ), |
|
56 | + esc_html__('Payment %s', 'give'), |
|
57 | 57 | $number |
58 | 58 | ); |
59 | - if ( $payment_mode == 'test' ) { |
|
60 | - echo '<span id="test-payment-label" class="give-item-label give-item-label-orange" data-tooltip="' . esc_attr__( 'This payment was made in Test Mode', 'give' ) . '" data-tooltip-my-position="center left" data-tooltip-target-position="center right">' . esc_html__( 'Test Payment', 'give' ) . '</span>'; |
|
59 | + if ($payment_mode == 'test') { |
|
60 | + echo '<span id="test-payment-label" class="give-item-label give-item-label-orange" data-tooltip="'.esc_attr__('This payment was made in Test Mode', 'give').'" data-tooltip-my-position="center left" data-tooltip-target-position="center right">'.esc_html__('Test Payment', 'give').'</span>'; |
|
61 | 61 | } |
62 | 62 | ?></h1> |
63 | 63 | |
64 | - <?php do_action( 'give_view_order_details_before', $payment_id ); ?> |
|
64 | + <?php do_action('give_view_order_details_before', $payment_id); ?> |
|
65 | 65 | <form id="give-edit-order-form" method="post"> |
66 | - <?php do_action( 'give_view_order_details_form_top', $payment_id ); ?> |
|
66 | + <?php do_action('give_view_order_details_form_top', $payment_id); ?> |
|
67 | 67 | <div id="poststuff"> |
68 | 68 | <div id="give-dashboard-widgets-wrap"> |
69 | 69 | <div id="post-body" class="metabox-holder columns-2"> |
70 | 70 | <div id="postbox-container-1" class="postbox-container"> |
71 | 71 | <div id="side-sortables" class="meta-box-sortables ui-sortable"> |
72 | 72 | |
73 | - <?php do_action( 'give_view_order_details_sidebar_before', $payment_id ); ?> |
|
73 | + <?php do_action('give_view_order_details_sidebar_before', $payment_id); ?> |
|
74 | 74 | |
75 | 75 | <div id="give-order-update" class="postbox give-order-data"> |
76 | 76 | |
77 | 77 | <h3 class="hndle"> |
78 | - <span><?php esc_html_e( 'Update Payment', 'give' ); ?></span> |
|
78 | + <span><?php esc_html_e('Update Payment', 'give'); ?></span> |
|
79 | 79 | </h3> |
80 | 80 | |
81 | 81 | <div class="inside"> |
82 | 82 | <div class="give-admin-box"> |
83 | 83 | |
84 | - <?php do_action( 'give_view_order_details_totals_before', $payment_id ); ?> |
|
84 | + <?php do_action('give_view_order_details_totals_before', $payment_id); ?> |
|
85 | 85 | |
86 | 86 | <div class="give-admin-box-inside"> |
87 | 87 | <p> |
88 | - <span class="label"><?php esc_html_e( 'Status:', 'give' ); ?></span> |
|
88 | + <span class="label"><?php esc_html_e('Status:', 'give'); ?></span> |
|
89 | 89 | <select name="give-payment-status" class="medium-text"> |
90 | - <?php foreach ( give_get_payment_statuses() as $key => $status ) : ?> |
|
91 | - <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $payment->status, $key, true ); ?>><?php echo esc_html( $status ); ?></option> |
|
90 | + <?php foreach (give_get_payment_statuses() as $key => $status) : ?> |
|
91 | + <option value="<?php echo esc_attr($key); ?>"<?php selected($payment->status, $key, true); ?>><?php echo esc_html($status); ?></option> |
|
92 | 92 | <?php endforeach; ?> |
93 | 93 | </select> |
94 | - <span class="give-donation-status status-<?php echo sanitize_title( $payment->status ); ?>"><span class="give-donation-status-icon"></span></span> |
|
94 | + <span class="give-donation-status status-<?php echo sanitize_title($payment->status); ?>"><span class="give-donation-status-icon"></span></span> |
|
95 | 95 | </p> |
96 | 96 | </div> |
97 | 97 | |
98 | 98 | <div class="give-admin-box-inside"> |
99 | 99 | <p> |
100 | - <span class="label"><?php esc_html_e( 'Date:', 'give' ); ?></span> |
|
101 | - <input type="text" name="give-payment-date" value="<?php echo esc_attr( date( 'm/d/Y', $payment_date ) ); ?>" class="medium-text give_datepicker"/> |
|
100 | + <span class="label"><?php esc_html_e('Date:', 'give'); ?></span> |
|
101 | + <input type="text" name="give-payment-date" value="<?php echo esc_attr(date('m/d/Y', $payment_date)); ?>" class="medium-text give_datepicker"/> |
|
102 | 102 | </p> |
103 | 103 | </div> |
104 | 104 | |
105 | 105 | <div class="give-admin-box-inside"> |
106 | 106 | <p> |
107 | - <span class="label"><?php esc_html_e( 'Time:', 'give' ); ?></span> |
|
108 | - <input type="number" step="1" max="24" name="give-payment-time-hour" value="<?php echo esc_attr( date_i18n( 'H', $payment_date ) ); ?>" class="small-text give-payment-time-hour"/> : |
|
109 | - <input type="number" step="1" max="59" name="give-payment-time-min" value="<?php echo esc_attr( date( 'i', $payment_date ) ); ?>" class="small-text give-payment-time-min"/> |
|
107 | + <span class="label"><?php esc_html_e('Time:', 'give'); ?></span> |
|
108 | + <input type="number" step="1" max="24" name="give-payment-time-hour" value="<?php echo esc_attr(date_i18n('H', $payment_date)); ?>" class="small-text give-payment-time-hour"/> : |
|
109 | + <input type="number" step="1" max="59" name="give-payment-time-min" value="<?php echo esc_attr(date('i', $payment_date)); ?>" class="small-text give-payment-time-min"/> |
|
110 | 110 | </p> |
111 | 111 | </div> |
112 | 112 | |
113 | - <?php do_action( 'give_view_order_details_update_inner', $payment_id ); ?> |
|
113 | + <?php do_action('give_view_order_details_update_inner', $payment_id); ?> |
|
114 | 114 | |
115 | 115 | <?php |
116 | 116 | //@TODO: Fees |
117 | - $fees = give_get_payment_fees( $payment_id ); |
|
118 | - if ( ! empty( $fees ) ) : ?> |
|
117 | + $fees = give_get_payment_fees($payment_id); |
|
118 | + if ( ! empty($fees)) : ?> |
|
119 | 119 | <div class="give-order-fees give-admin-box-inside"> |
120 | - <p class="strong"><?php esc_html_e( 'Fees', 'give' ); ?>:</p> |
|
120 | + <p class="strong"><?php esc_html_e('Fees', 'give'); ?>:</p> |
|
121 | 121 | <ul class="give-payment-fees"> |
122 | - <?php foreach ( $fees as $fee ) : ?> |
|
122 | + <?php foreach ($fees as $fee) : ?> |
|
123 | 123 | <li> |
124 | - <span class="fee-label"><?php echo $fee['label'] . ':</span> ' . '<span class="fee-amount" data-fee="' . esc_attr( $fee['amount'] ) . '">' . give_currency_filter( $fee['amount'], $currency_code ); ?></span> |
|
124 | + <span class="fee-label"><?php echo $fee['label'].':</span> '.'<span class="fee-amount" data-fee="'.esc_attr($fee['amount']).'">'.give_currency_filter($fee['amount'], $currency_code); ?></span> |
|
125 | 125 | </li> |
126 | 126 | <?php endforeach; ?> |
127 | 127 | </ul> |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | |
132 | 132 | <div class="give-order-payment give-admin-box-inside"> |
133 | 133 | <p> |
134 | - <span class="label"><?php esc_html_e( 'Total Donation', 'give' ); ?>:</span> |
|
135 | - <?php echo give_currency_symbol( $payment->currency ); ?> <input name="give-payment-total" type="text" class="small-text give-price-field" value="<?php echo esc_attr( give_format_decimal( give_get_payment_amount( $payment_id ) ) ); ?>"/> |
|
134 | + <span class="label"><?php esc_html_e('Total Donation', 'give'); ?>:</span> |
|
135 | + <?php echo give_currency_symbol($payment->currency); ?> <input name="give-payment-total" type="text" class="small-text give-price-field" value="<?php echo esc_attr(give_format_decimal(give_get_payment_amount($payment_id))); ?>"/> |
|
136 | 136 | </p> |
137 | 137 | </div> |
138 | 138 | |
139 | - <?php do_action( 'give_view_order_details_totals_after', $payment_id ); ?> |
|
139 | + <?php do_action('give_view_order_details_totals_after', $payment_id); ?> |
|
140 | 140 | |
141 | 141 | </div> |
142 | 142 | <!-- /.give-admin-box --> |
@@ -145,20 +145,20 @@ discard block |
||
145 | 145 | <!-- /.inside --> |
146 | 146 | |
147 | 147 | <div class="give-order-update-box give-admin-box"> |
148 | - <?php do_action( 'give_view_order_details_update_before', $payment_id ); ?> |
|
148 | + <?php do_action('give_view_order_details_update_before', $payment_id); ?> |
|
149 | 149 | <div id="major-publishing-actions"> |
150 | 150 | <div id="publishing-action"> |
151 | - <input type="submit" class="button button-primary right" value="<?php esc_attr_e( 'Save Payment', 'give' ); ?>"/> |
|
152 | - <?php if ( give_is_payment_complete( $payment_id ) ) : ?> |
|
153 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
151 | + <input type="submit" class="button button-primary right" value="<?php esc_attr_e('Save Payment', 'give'); ?>"/> |
|
152 | + <?php if (give_is_payment_complete($payment_id)) : ?> |
|
153 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
154 | 154 | 'give-action' => 'email_links', |
155 | 155 | 'purchase_id' => $payment_id |
156 | - ) ) ); ?>" id="give-resend-receipt" class="button-secondary right"><?php esc_html_e( 'Resend Receipt', 'give' ); ?></a> |
|
156 | + ))); ?>" id="give-resend-receipt" class="button-secondary right"><?php esc_html_e('Resend Receipt', 'give'); ?></a> |
|
157 | 157 | <?php endif; ?> |
158 | 158 | </div> |
159 | 159 | <div class="clear"></div> |
160 | 160 | </div> |
161 | - <?php do_action( 'give_view_order_details_update_after', $payment_id ); ?> |
|
161 | + <?php do_action('give_view_order_details_update_after', $payment_id); ?> |
|
162 | 162 | </div> |
163 | 163 | <!-- /.give-order-update-box --> |
164 | 164 | |
@@ -168,55 +168,55 @@ discard block |
||
168 | 168 | <div id="give-order-details" class="postbox give-order-data"> |
169 | 169 | |
170 | 170 | <h3 class="hndle"> |
171 | - <span><?php esc_html_e( 'Payment Meta', 'give' ); ?></span> |
|
171 | + <span><?php esc_html_e('Payment Meta', 'give'); ?></span> |
|
172 | 172 | </h3> |
173 | 173 | |
174 | 174 | <div class="inside"> |
175 | 175 | <div class="give-admin-box"> |
176 | 176 | |
177 | - <?php do_action( 'give_view_order_details_payment_meta_before', $payment_id ); ?> |
|
177 | + <?php do_action('give_view_order_details_payment_meta_before', $payment_id); ?> |
|
178 | 178 | |
179 | 179 | <?php |
180 | - $gateway = give_get_payment_gateway( $payment_id ); |
|
181 | - if ( $gateway ) : ?> |
|
180 | + $gateway = give_get_payment_gateway($payment_id); |
|
181 | + if ($gateway) : ?> |
|
182 | 182 | <div class="give-order-gateway give-admin-box-inside"> |
183 | 183 | <p> |
184 | - <span class="label"><?php esc_html_e( 'Gateway:', 'give' ); ?></span> |
|
185 | - <?php echo give_get_gateway_admin_label( $gateway ); ?> |
|
184 | + <span class="label"><?php esc_html_e('Gateway:', 'give'); ?></span> |
|
185 | + <?php echo give_get_gateway_admin_label($gateway); ?> |
|
186 | 186 | </p> |
187 | 187 | </div> |
188 | 188 | <?php endif; ?> |
189 | 189 | |
190 | 190 | <div class="give-order-payment-key give-admin-box-inside"> |
191 | 191 | <p> |
192 | - <span class="label"><?php esc_html_e( 'Key:', 'give' ); ?></span> |
|
193 | - <span><?php echo give_get_payment_key( $payment_id ); ?></span> |
|
192 | + <span class="label"><?php esc_html_e('Key:', 'give'); ?></span> |
|
193 | + <span><?php echo give_get_payment_key($payment_id); ?></span> |
|
194 | 194 | </p> |
195 | 195 | </div> |
196 | 196 | |
197 | 197 | <div class="give-order-ip give-admin-box-inside"> |
198 | 198 | <p> |
199 | - <span class="label"><?php esc_html_e( 'IP:', 'give' ); ?></span> |
|
200 | - <span><?php echo esc_html( give_get_payment_user_ip( $payment_id ) ); ?></span> |
|
199 | + <span class="label"><?php esc_html_e('IP:', 'give'); ?></span> |
|
200 | + <span><?php echo esc_html(give_get_payment_user_ip($payment_id)); ?></span> |
|
201 | 201 | </p> |
202 | 202 | </div> |
203 | 203 | |
204 | - <?php if ( $transaction_id ) : ?> |
|
204 | + <?php if ($transaction_id) : ?> |
|
205 | 205 | <div class="give-order-tx-id give-admin-box-inside"> |
206 | 206 | <p> |
207 | - <span class="label"><?php esc_html_e( 'Transaction ID:', 'give' ); ?></span> |
|
208 | - <span><?php echo apply_filters( 'give_payment_details_transaction_id-' . $gateway, $transaction_id, $payment_id ); ?></span> |
|
207 | + <span class="label"><?php esc_html_e('Transaction ID:', 'give'); ?></span> |
|
208 | + <span><?php echo apply_filters('give_payment_details_transaction_id-'.$gateway, $transaction_id, $payment_id); ?></span> |
|
209 | 209 | </p> |
210 | 210 | </div> |
211 | 211 | <?php endif; ?> |
212 | 212 | |
213 | 213 | <div class="give-admin-box-inside"> |
214 | - <p><?php $purchase_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( esc_attr( give_get_payment_user_email( $payment_id ) ) ) ); ?> |
|
215 | - <a href="<?php echo $purchase_url; ?>"><?php esc_html_e( 'View all donations for this donor »', 'give' ); ?></a> |
|
214 | + <p><?php $purchase_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.urlencode(esc_attr(give_get_payment_user_email($payment_id)))); ?> |
|
215 | + <a href="<?php echo $purchase_url; ?>"><?php esc_html_e('View all donations for this donor »', 'give'); ?></a> |
|
216 | 216 | </p> |
217 | 217 | </div> |
218 | 218 | |
219 | - <?php do_action( 'give_view_order_details_payment_meta_after', $payment_id ); ?> |
|
219 | + <?php do_action('give_view_order_details_payment_meta_after', $payment_id); ?> |
|
220 | 220 | |
221 | 221 | </div> |
222 | 222 | <!-- /.column-container --> |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | </div> |
228 | 228 | <!-- /#give-order-data --> |
229 | 229 | |
230 | - <?php do_action( 'give_view_order_details_sidebar_after', $payment_id ); ?> |
|
230 | + <?php do_action('give_view_order_details_sidebar_after', $payment_id); ?> |
|
231 | 231 | |
232 | 232 | </div> |
233 | 233 | <!-- /#side-sortables --> |
@@ -238,12 +238,12 @@ discard block |
||
238 | 238 | |
239 | 239 | <div id="normal-sortables" class="meta-box-sortables ui-sortable"> |
240 | 240 | |
241 | - <?php do_action( 'give_view_order_details_main_before', $payment_id ); ?> |
|
241 | + <?php do_action('give_view_order_details_main_before', $payment_id); ?> |
|
242 | 242 | |
243 | 243 | <?php $column_count = 'columns-3'; ?> |
244 | 244 | <div id="give-donation-overview" class="postbox <?php echo $column_count; ?>"> |
245 | 245 | <h3 class="hndle"> |
246 | - <span><?php esc_html_e( 'Donation Information', 'give' ); ?></span> |
|
246 | + <span><?php esc_html_e('Donation Information', 'give'); ?></span> |
|
247 | 247 | </h3> |
248 | 248 | |
249 | 249 | <div class="inside"> |
@@ -251,32 +251,32 @@ discard block |
||
251 | 251 | <table style="width:100%;"> |
252 | 252 | <thead> |
253 | 253 | <tr> |
254 | - <?php do_action( 'give_donation_details_thead_before', $payment_id ); ?> |
|
255 | - <th><?php esc_html_e( 'Donation Form ID', 'give' ) ?></th> |
|
256 | - <th><?php esc_html_e( 'Donation Form Title', 'give' ) ?></th> |
|
257 | - <th><?php esc_html_e( 'Donation Level', 'give' ) ?></th> |
|
258 | - <th><?php esc_html_e( 'Donation Date', 'give' ) ?></th> |
|
259 | - <th><?php esc_html_e( 'Total Donation', 'give' ) ?></th> |
|
260 | - <?php do_action( 'give_donation_details_thead_after', $payment_id ); ?> |
|
254 | + <?php do_action('give_donation_details_thead_before', $payment_id); ?> |
|
255 | + <th><?php esc_html_e('Donation Form ID', 'give') ?></th> |
|
256 | + <th><?php esc_html_e('Donation Form Title', 'give') ?></th> |
|
257 | + <th><?php esc_html_e('Donation Level', 'give') ?></th> |
|
258 | + <th><?php esc_html_e('Donation Date', 'give') ?></th> |
|
259 | + <th><?php esc_html_e('Total Donation', 'give') ?></th> |
|
260 | + <?php do_action('give_donation_details_thead_after', $payment_id); ?> |
|
261 | 261 | </tr> |
262 | 262 | </thead> |
263 | 263 | <tr> |
264 | - <?php do_action( 'give_donation_details_tbody_before', $payment_id ); ?> |
|
264 | + <?php do_action('give_donation_details_tbody_before', $payment_id); ?> |
|
265 | 265 | <td> |
266 | 266 | <?php echo $payment_meta['form_id']; ?> |
267 | 267 | </td> |
268 | 268 | <td> |
269 | - <?php give_get_form_dropdown( array( |
|
269 | + <?php give_get_form_dropdown(array( |
|
270 | 270 | 'id' => $payment_meta['form_id'], |
271 | 271 | 'selected' => $payment_meta['form_id'], |
272 | 272 | 'chosen' => true |
273 | - ), true ); ?> |
|
273 | + ), true); ?> |
|
274 | 274 | </td> |
275 | 275 | <td> |
276 | 276 | <?php |
277 | - $var_prices = give_has_variable_prices( $payment_meta['form_id'] ); |
|
278 | - if ( empty( $var_prices ) ) { |
|
279 | - echo esc_html__( 'n/a', 'give' ); |
|
277 | + $var_prices = give_has_variable_prices($payment_meta['form_id']); |
|
278 | + if (empty($var_prices)) { |
|
279 | + echo esc_html__('n/a', 'give'); |
|
280 | 280 | } else { |
281 | 281 | // Variable price dropdown options. |
282 | 282 | $variable_price_dropdown_option = array( |
@@ -288,20 +288,20 @@ discard block |
||
288 | 288 | ); |
289 | 289 | |
290 | 290 | // Render variable prices select tag html. |
291 | - give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true ); |
|
291 | + give_get_form_variable_price_dropdown($variable_price_dropdown_option, true); |
|
292 | 292 | } |
293 | 293 | ?> |
294 | 294 | </td> |
295 | 295 | <td> |
296 | 296 | <?php |
297 | 297 | //Transaction Date |
298 | - $date_format = get_option( 'date_format' ); |
|
299 | - echo date_i18n( $date_format, $payment_date ); |
|
298 | + $date_format = get_option('date_format'); |
|
299 | + echo date_i18n($date_format, $payment_date); |
|
300 | 300 | ?> |
301 | 301 | </td> |
302 | 302 | <td> |
303 | - <?php echo esc_html( give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ) ); ?></td> |
|
304 | - <?php do_action( 'give_donation_details_tbody_after', $payment_id ); ?> |
|
303 | + <?php echo esc_html(give_currency_filter(give_format_amount(give_get_payment_amount($payment_id)))); ?></td> |
|
304 | + <?php do_action('give_donation_details_tbody_after', $payment_id); ?> |
|
305 | 305 | |
306 | 306 | </tr> |
307 | 307 | </table> |
@@ -313,64 +313,64 @@ discard block |
||
313 | 313 | </div> |
314 | 314 | <!-- /#give-donation-overview --> |
315 | 315 | |
316 | - <?php do_action( 'give_view_order_details_files_after', $payment_id ); ?> |
|
316 | + <?php do_action('give_view_order_details_files_after', $payment_id); ?> |
|
317 | 317 | |
318 | - <?php do_action( 'give_view_order_details_billing_before', $payment_id ); ?> |
|
318 | + <?php do_action('give_view_order_details_billing_before', $payment_id); ?> |
|
319 | 319 | |
320 | 320 | |
321 | 321 | <div id="give-customer-details" class="postbox"> |
322 | 322 | <h3 class="hndle"> |
323 | - <span><?php esc_html_e( 'Donor Details', 'give' ); ?></span> |
|
323 | + <span><?php esc_html_e('Donor Details', 'give'); ?></span> |
|
324 | 324 | </h3> |
325 | 325 | |
326 | 326 | <div class="inside give-clearfix"> |
327 | 327 | |
328 | - <?php $customer = new Give_Customer( $customer_id ); ?> |
|
328 | + <?php $customer = new Give_Customer($customer_id); ?> |
|
329 | 329 | |
330 | 330 | <div class="column-container customer-info"> |
331 | 331 | <div class="column"> |
332 | - <?php echo Give()->html->donor_dropdown( array( |
|
332 | + <?php echo Give()->html->donor_dropdown(array( |
|
333 | 333 | 'selected' => $customer->id, |
334 | 334 | 'name' => 'customer-id' |
335 | - ) ); ?> |
|
335 | + )); ?> |
|
336 | 336 | </div> |
337 | 337 | <div class="column"> |
338 | 338 | <input type="hidden" name="give-current-customer" value="<?php echo $customer->id; ?>"/> |
339 | 339 | </div> |
340 | 340 | <div class="column"> |
341 | - <?php if ( ! empty( $customer->id ) ) : ?> |
|
342 | - <?php $customer_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ); ?> |
|
343 | - <a href="<?php echo $customer_url; ?>" title="<?php esc_attr_e( 'View Donor Details', 'give' ); ?>"><?php esc_html_e( 'View Donor Details', 'give' ); ?></a> |
|
341 | + <?php if ( ! empty($customer->id)) : ?> |
|
342 | + <?php $customer_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id); ?> |
|
343 | + <a href="<?php echo $customer_url; ?>" title="<?php esc_attr_e('View Donor Details', 'give'); ?>"><?php esc_html_e('View Donor Details', 'give'); ?></a> |
|
344 | 344 | | |
345 | 345 | <?php endif; ?> |
346 | - <a href="#new" class="give-payment-new-customer" title="<?php esc_attr_e( 'New Donor', 'give' ); ?>"><?php esc_html_e( 'New Donor', 'give' ); ?></a> |
|
346 | + <a href="#new" class="give-payment-new-customer" title="<?php esc_attr_e('New Donor', 'give'); ?>"><?php esc_html_e('New Donor', 'give'); ?></a> |
|
347 | 347 | </div> |
348 | 348 | </div> |
349 | 349 | |
350 | 350 | <div class="column-container new-customer" style="display: none"> |
351 | 351 | <div class="column"> |
352 | - <label for="give-new-customer-name"><?php esc_html_e( 'Name:', 'give' ); ?></label> |
|
352 | + <label for="give-new-customer-name"><?php esc_html_e('Name:', 'give'); ?></label> |
|
353 | 353 | <input id="give-new-customer-name" type="text" name="give-new-customer-name" value="" class="medium-text"/> |
354 | 354 | </div> |
355 | 355 | <div class="column"> |
356 | - <label for="give-new-customer-email"><?php esc_html_e( 'Email:', 'give' ); ?></label> |
|
356 | + <label for="give-new-customer-email"><?php esc_html_e('Email:', 'give'); ?></label> |
|
357 | 357 | <input id="give-new-customer-email" type="email" name="give-new-customer-email" value="" class="medium-text"/> |
358 | 358 | </div> |
359 | 359 | <div class="column"> |
360 | 360 | <input type="hidden" id="give-new-customer" name="give-new-customer" value="0"/> |
361 | - <a href="#cancel" class="give-payment-new-customer-cancel give-delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a> |
|
361 | + <a href="#cancel" class="give-payment-new-customer-cancel give-delete"><?php esc_html_e('Cancel', 'give'); ?></a> |
|
362 | 362 | </div> |
363 | 363 | <div class="column"> |
364 | 364 | <small> |
365 | - <em>*<?php esc_html_e( 'Click "Save Payment" to create new donor', 'give' ); ?></em> |
|
365 | + <em>*<?php esc_html_e('Click "Save Payment" to create new donor', 'give'); ?></em> |
|
366 | 366 | </small> |
367 | 367 | </div> |
368 | 368 | </div> |
369 | 369 | |
370 | 370 | <?php |
371 | 371 | // The give_payment_personal_details_list hook is left here for backwards compatibility |
372 | - do_action( 'give_payment_personal_details_list', $payment_meta, $user_info ); |
|
373 | - do_action( 'give_payment_view_details', $payment_id ); |
|
372 | + do_action('give_payment_personal_details_list', $payment_meta, $user_info); |
|
373 | + do_action('give_payment_view_details', $payment_id); |
|
374 | 374 | ?> |
375 | 375 | |
376 | 376 | </div> |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | |
382 | 382 | <div id="give-billing-details" class="postbox"> |
383 | 383 | <h3 class="hndle"> |
384 | - <span><?php esc_html_e( 'Billing Address', 'give' ); ?></span> |
|
384 | + <span><?php esc_html_e('Billing Address', 'give'); ?></span> |
|
385 | 385 | </h3> |
386 | 386 | |
387 | 387 | <div class="inside give-clearfix"> |
@@ -392,62 +392,62 @@ discard block |
||
392 | 392 | <div class="data column-container"> |
393 | 393 | <div class="column"> |
394 | 394 | <div class="give-wrap-address-line1"> |
395 | - <label for="give-payment-address-line1" class="order-data-address"><?php esc_html_e( 'Street Address Line 1:', 'give' ); ?></label> |
|
396 | - <input id="give-payment-address-line1" type="text" name="give-payment-address[0][line1]" value="<?php echo esc_attr( $address['line1'] ); ?>" class="medium-text"/> |
|
395 | + <label for="give-payment-address-line1" class="order-data-address"><?php esc_html_e('Street Address Line 1:', 'give'); ?></label> |
|
396 | + <input id="give-payment-address-line1" type="text" name="give-payment-address[0][line1]" value="<?php echo esc_attr($address['line1']); ?>" class="medium-text"/> |
|
397 | 397 | </div> |
398 | 398 | |
399 | 399 | <div class="give-wrap-address-line2"> |
400 | - <label for="give-payment-address-line2" class="order-data-address-line"><?php esc_html_e( 'Street Address Line 2:', 'give' ); ?></label> |
|
401 | - <input id="give-payment-address-line2" type="text" name="give-payment-address[0][line2]" value="<?php echo esc_attr( $address['line2'] ); ?>" class="medium-text"/> |
|
400 | + <label for="give-payment-address-line2" class="order-data-address-line"><?php esc_html_e('Street Address Line 2:', 'give'); ?></label> |
|
401 | + <input id="give-payment-address-line2" type="text" name="give-payment-address[0][line2]" value="<?php echo esc_attr($address['line2']); ?>" class="medium-text"/> |
|
402 | 402 | </div> |
403 | 403 | |
404 | 404 | </div> |
405 | 405 | <div class="column"> |
406 | 406 | <div class="give-wrap-address-city"> |
407 | - <label for="give-payment-address-city" class="order-data-address-line"><?php esc_html_e( 'City:', 'give' ); ?></label> |
|
408 | - <input id="give-payment-address-city" type="text" name="give-payment-address[0][city]" value="<?php echo esc_attr( $address['city'] ); ?>" class="medium-text"/> |
|
407 | + <label for="give-payment-address-city" class="order-data-address-line"><?php esc_html_e('City:', 'give'); ?></label> |
|
408 | + <input id="give-payment-address-city" type="text" name="give-payment-address[0][city]" value="<?php echo esc_attr($address['city']); ?>" class="medium-text"/> |
|
409 | 409 | |
410 | 410 | </div> |
411 | 411 | |
412 | 412 | <div class="give-wrap-address-zip"> |
413 | - <label for="give-payment-address-zip" class="order-data-address-line"><?php esc_html_e( 'Zip / Postal Code:', 'give' ); ?></label> |
|
414 | - <input id="give-payment-address-zip" type="text" name="give-payment-address[0][zip]" value="<?php echo esc_attr( $address['zip'] ); ?>" class="medium-text"/> |
|
413 | + <label for="give-payment-address-zip" class="order-data-address-line"><?php esc_html_e('Zip / Postal Code:', 'give'); ?></label> |
|
414 | + <input id="give-payment-address-zip" type="text" name="give-payment-address[0][zip]" value="<?php echo esc_attr($address['zip']); ?>" class="medium-text"/> |
|
415 | 415 | |
416 | 416 | </div> |
417 | 417 | </div> |
418 | 418 | <div class="column"> |
419 | 419 | <div id="give-order-address-country-wrap"> |
420 | - <label class="order-data-address-line"><?php esc_html_e( 'Country:', 'give' ); ?></label> |
|
420 | + <label class="order-data-address-line"><?php esc_html_e('Country:', 'give'); ?></label> |
|
421 | 421 | <?php |
422 | - echo Give()->html->select( array( |
|
422 | + echo Give()->html->select(array( |
|
423 | 423 | 'options' => give_get_country_list(), |
424 | 424 | 'name' => 'give-payment-address[0][country]', |
425 | 425 | 'selected' => $address['country'], |
426 | 426 | 'show_option_all' => false, |
427 | 427 | 'show_option_none' => false, |
428 | 428 | 'chosen' => true, |
429 | - 'placeholder' => esc_attr__( 'Select a country', 'give' ) |
|
430 | - ) ); |
|
429 | + 'placeholder' => esc_attr__('Select a country', 'give') |
|
430 | + )); |
|
431 | 431 | ?> |
432 | 432 | </div> |
433 | 433 | |
434 | 434 | <div id="give-order-address-state-wrap"> |
435 | - <label for="give-payment-address-state" class="order-data-address-line"><?php esc_html_e( 'State / Province:', 'give' ); ?></label> |
|
435 | + <label for="give-payment-address-state" class="order-data-address-line"><?php esc_html_e('State / Province:', 'give'); ?></label> |
|
436 | 436 | <?php |
437 | - $states = give_get_states( $address['country'] ); |
|
438 | - if ( ! empty( $states ) ) { |
|
439 | - echo Give()->html->select( array( |
|
437 | + $states = give_get_states($address['country']); |
|
438 | + if ( ! empty($states)) { |
|
439 | + echo Give()->html->select(array( |
|
440 | 440 | 'options' => $states, |
441 | 441 | 'name' => 'give-payment-address[0][state]', |
442 | 442 | 'selected' => $address['state'], |
443 | 443 | 'show_option_all' => false, |
444 | 444 | 'show_option_none' => false, |
445 | 445 | 'chosen' => true, |
446 | - 'placeholder' => esc_attr__( 'Select a state', 'give' ) |
|
447 | - ) ); |
|
446 | + 'placeholder' => esc_attr__('Select a state', 'give') |
|
447 | + )); |
|
448 | 448 | } else { |
449 | 449 | ?> |
450 | - <input id="give-payment-address-state" type="text" name="give-payment-address[0][state]" value="<?php echo esc_attr( $address['state'] ); ?>" class="medium-text"/> |
|
450 | + <input id="give-payment-address-state" type="text" name="give-payment-address[0][state]" value="<?php echo esc_attr($address['state']); ?>" class="medium-text"/> |
|
451 | 451 | <?php |
452 | 452 | } ?> |
453 | 453 | </div> |
@@ -457,38 +457,38 @@ discard block |
||
457 | 457 | </div> |
458 | 458 | <!-- /#give-order-address --> |
459 | 459 | |
460 | - <?php do_action( 'give_payment_billing_details', $payment_id ); ?> |
|
460 | + <?php do_action('give_payment_billing_details', $payment_id); ?> |
|
461 | 461 | |
462 | 462 | </div> |
463 | 463 | <!-- /.inside --> |
464 | 464 | </div> |
465 | 465 | <!-- /#give-billing-details --> |
466 | 466 | |
467 | - <?php do_action( 'give_view_order_details_billing_after', $payment_id ); ?> |
|
467 | + <?php do_action('give_view_order_details_billing_after', $payment_id); ?> |
|
468 | 468 | |
469 | 469 | <div id="give-payment-notes" class="postbox"> |
470 | - <h3 class="hndle"><span><?php esc_html_e( 'Payment Notes', 'give' ); ?></span></h3> |
|
470 | + <h3 class="hndle"><span><?php esc_html_e('Payment Notes', 'give'); ?></span></h3> |
|
471 | 471 | |
472 | 472 | <div class="inside"> |
473 | 473 | <div id="give-payment-notes-inner"> |
474 | 474 | <?php |
475 | - $notes = give_get_payment_notes( $payment_id ); |
|
476 | - if ( ! empty( $notes ) ) : |
|
475 | + $notes = give_get_payment_notes($payment_id); |
|
476 | + if ( ! empty($notes)) : |
|
477 | 477 | $no_notes_display = ' style="display:none;"'; |
478 | - foreach ( $notes as $note ) : |
|
478 | + foreach ($notes as $note) : |
|
479 | 479 | |
480 | - echo give_get_payment_note_html( $note, $payment_id ); |
|
480 | + echo give_get_payment_note_html($note, $payment_id); |
|
481 | 481 | |
482 | 482 | endforeach; |
483 | 483 | else : |
484 | 484 | $no_notes_display = ''; |
485 | 485 | endif; |
486 | - echo '<p class="give-no-payment-notes"' . $no_notes_display . '>' . esc_html__( 'No payment notes', 'give' ) . '</p>'; ?> |
|
486 | + echo '<p class="give-no-payment-notes"'.$no_notes_display.'>'.esc_html__('No payment notes', 'give').'</p>'; ?> |
|
487 | 487 | </div> |
488 | 488 | <textarea name="give-payment-note" id="give-payment-note" class="large-text"></textarea> |
489 | 489 | |
490 | 490 | <div class="give-clearfix"> |
491 | - <button id="give-add-payment-note" class="button button-secondary button-small" data-payment-id="<?php echo absint( $payment_id ); ?>"><?php esc_html_e( 'Add Note', 'give' ); ?></button> |
|
491 | + <button id="give-add-payment-note" class="button button-secondary button-small" data-payment-id="<?php echo absint($payment_id); ?>"><?php esc_html_e('Add Note', 'give'); ?></button> |
|
492 | 492 | </div> |
493 | 493 | |
494 | 494 | </div> |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | </div> |
497 | 497 | <!-- /#give-payment-notes --> |
498 | 498 | |
499 | - <?php do_action( 'give_view_order_details_main_after', $payment_id ); ?> |
|
499 | + <?php do_action('give_view_order_details_main_after', $payment_id); ?> |
|
500 | 500 | </div> |
501 | 501 | <!-- /#normal-sortables --> |
502 | 502 | </div> |
@@ -507,10 +507,10 @@ discard block |
||
507 | 507 | <!-- #give-dashboard-widgets-wrap --> |
508 | 508 | </div> |
509 | 509 | <!-- /#post-stuff --> |
510 | - <?php do_action( 'give_view_order_details_form_bottom', $payment_id ); ?> |
|
511 | - <?php wp_nonce_field( 'give_update_payment_details_nonce' ); ?> |
|
512 | - <input type="hidden" name="give_payment_id" value="<?php echo esc_attr( $payment_id ); ?>"/> |
|
510 | + <?php do_action('give_view_order_details_form_bottom', $payment_id); ?> |
|
511 | + <?php wp_nonce_field('give_update_payment_details_nonce'); ?> |
|
512 | + <input type="hidden" name="give_payment_id" value="<?php echo esc_attr($payment_id); ?>"/> |
|
513 | 513 | <input type="hidden" name="give_action" value="update_payment_details"/> |
514 | 514 | </form> |
515 | - <?php do_action( 'give_view_order_details_after', $payment_id ); ?> |
|
515 | + <?php do_action('give_view_order_details_after', $payment_id); ?> |
|
516 | 516 | </div><!-- /.wrap --> |
@@ -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 | |
@@ -78,15 +78,15 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @since 1.0 |
80 | 80 | */ |
81 | - public function __construct( $_data ) { |
|
81 | + public function __construct($_data) { |
|
82 | 82 | |
83 | 83 | $this->data = $_data; |
84 | 84 | |
85 | 85 | // Generate unique ID |
86 | - $this->id = md5( rand() ); |
|
86 | + $this->id = md5(rand()); |
|
87 | 87 | |
88 | 88 | // Setup default options; |
89 | - $this->options = apply_filters( 'give_graph_args', array( |
|
89 | + $this->options = apply_filters('give_graph_args', array( |
|
90 | 90 | 'y_mode' => null, |
91 | 91 | 'x_mode' => null, |
92 | 92 | 'y_decimals' => 0, |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | 'bars' => true, |
104 | 104 | 'lines' => false, |
105 | 105 | 'points' => true |
106 | - ) ); |
|
106 | + )); |
|
107 | 107 | |
108 | 108 | } |
109 | 109 | |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | * |
116 | 116 | * @since 1.0 |
117 | 117 | */ |
118 | - public function set( $key, $value ) { |
|
119 | - $this->options[ $key ] = $value; |
|
118 | + public function set($key, $value) { |
|
119 | + $this->options[$key] = $value; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @since 1.0 |
128 | 128 | */ |
129 | - public function get( $key ) { |
|
130 | - return isset( $this->options[ $key ] ) ? $this->options[ $key ] : false; |
|
129 | + public function get($key) { |
|
130 | + return isset($this->options[$key]) ? $this->options[$key] : false; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @since 1.0 |
137 | 137 | */ |
138 | 138 | public function get_data() { |
139 | - return apply_filters( 'give_get_graph_data', $this->data, $this ); |
|
139 | + return apply_filters('give_get_graph_data', $this->data, $this); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -146,19 +146,19 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function load_scripts() { |
148 | 148 | // Use minified libraries if SCRIPT_DEBUG is turned off |
149 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
149 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
150 | 150 | |
151 | - wp_register_script( 'jquery-flot-orderbars', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.orderBars' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION ); |
|
152 | - wp_enqueue_script( 'jquery-flot-orderbars' ); |
|
151 | + wp_register_script('jquery-flot-orderbars', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.orderBars'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION); |
|
152 | + wp_enqueue_script('jquery-flot-orderbars'); |
|
153 | 153 | |
154 | - wp_register_script( 'jquery-flot-time', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.time' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION ); |
|
155 | - wp_enqueue_script( 'jquery-flot-time' ); |
|
154 | + wp_register_script('jquery-flot-time', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.time'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION); |
|
155 | + wp_enqueue_script('jquery-flot-time'); |
|
156 | 156 | |
157 | - wp_register_script( 'jquery-flot-resize', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.resize' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION ); |
|
158 | - wp_enqueue_script( 'jquery-flot-resize' ); |
|
157 | + wp_register_script('jquery-flot-resize', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.resize'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION); |
|
158 | + wp_enqueue_script('jquery-flot-resize'); |
|
159 | 159 | |
160 | - wp_register_script( 'jquery-flot', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot' . $suffix . '.js', false, GIVE_VERSION ); |
|
161 | - wp_enqueue_script( 'jquery-flot' ); |
|
160 | + wp_register_script('jquery-flot', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot'.$suffix.'.js', false, GIVE_VERSION); |
|
161 | + wp_enqueue_script('jquery-flot'); |
|
162 | 162 | |
163 | 163 | } |
164 | 164 | |
@@ -185,13 +185,13 @@ discard block |
||
185 | 185 | [ |
186 | 186 | <?php |
187 | 187 | $order = 0; |
188 | - foreach( $this->get_data() as $label => $data ) : |
|
188 | + foreach ($this->get_data() as $label => $data) : |
|
189 | 189 | ?> |
190 | 190 | { |
191 | - label : "<?php echo esc_attr( $label ); ?>", |
|
192 | - id : "<?php echo sanitize_key( $label ); ?>", |
|
191 | + label : "<?php echo esc_attr($label); ?>", |
|
192 | + id : "<?php echo sanitize_key($label); ?>", |
|
193 | 193 | // data format is: [ point on x, value on y ] |
194 | - data : [<?php foreach( $data as $point ) { echo '[' . implode( ',', $point ) . '],'; } ?>], |
|
194 | + data : [<?php foreach ($data as $point) { echo '['.implode(',', $point).'],'; } ?>], |
|
195 | 195 | points: { |
196 | 196 | show: <?php echo $this->options['points'] ? 'true' : 'false'; ?>, |
197 | 197 | }, |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | fill : true, |
207 | 207 | fillColor: {colors: [{opacity: 0.4}, {opacity: 0.1}]} |
208 | 208 | }, |
209 | - <?php if( $this->options[ 'multiple_y_axes' ] ) : ?> |
|
209 | + <?php if ($this->options['multiple_y_axes']) : ?> |
|
210 | 210 | yaxis : <?php echo $yaxis_count; ?> |
211 | 211 | <?php endif; ?> |
212 | 212 | |
@@ -220,10 +220,10 @@ discard block |
||
220 | 220 | grid: { |
221 | 221 | show : true, |
222 | 222 | aboveData : false, |
223 | - color : "<?php echo $this->options[ 'color' ]; ?>", |
|
224 | - backgroundColor: "<?php echo $this->options[ 'bgcolor' ]; ?>", |
|
225 | - borderColor : "<?php echo $this->options[ 'bordercolor' ]; ?>", |
|
226 | - borderWidth : <?php echo absint( $this->options[ 'borderwidth' ] ); ?>, |
|
223 | + color : "<?php echo $this->options['color']; ?>", |
|
224 | + backgroundColor: "<?php echo $this->options['bgcolor']; ?>", |
|
225 | + borderColor : "<?php echo $this->options['bordercolor']; ?>", |
|
226 | + borderWidth : <?php echo absint($this->options['borderwidth']); ?>, |
|
227 | 227 | clickable : false, |
228 | 228 | hoverable : true |
229 | 229 | }, |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | mode : "<?php echo $this->options['x_mode']; ?>", |
235 | 235 | timeFormat : "<?php echo $this->options['x_mode'] == 'time' ? $this->options['time_format'] : ''; ?>", |
236 | 236 | tickSize : "<?php echo $this->options['x_mode'] == 'time' ? '' : 1; ?>", |
237 | - <?php if( $this->options['x_mode'] != 'time' ) : ?> |
|
237 | + <?php if ($this->options['x_mode'] != 'time') : ?> |
|
238 | 238 | tickDecimals: <?php echo $this->options['x_decimals']; ?> |
239 | 239 | <?php endif; ?> |
240 | 240 | }, |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | min : 0, |
244 | 244 | mode : "<?php echo $this->options['y_mode']; ?>", |
245 | 245 | timeFormat : "<?php echo $this->options['y_mode'] == 'time' ? $this->options['time_format'] : ''; ?>", |
246 | - <?php if( $this->options['y_mode'] != 'time' ) : ?> |
|
246 | + <?php if ($this->options['y_mode'] != 'time') : ?> |
|
247 | 247 | tickDecimals: <?php echo $this->options['y_decimals']; ?> |
248 | 248 | <?php endif; ?> |
249 | 249 | } |
@@ -303,9 +303,9 @@ discard block |
||
303 | 303 | * @since 1.0 |
304 | 304 | */ |
305 | 305 | public function display() { |
306 | - do_action( 'give_before_graph', $this ); |
|
306 | + do_action('give_before_graph', $this); |
|
307 | 307 | echo $this->build_graph(); |
308 | - do_action( 'give_after_graph', $this ); |
|
308 | + do_action('give_after_graph', $this); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | } |
@@ -124,8 +124,10 @@ |
||
124 | 124 | |
125 | 125 | $pdf->Row( array( $title, $price, $categories, $tags, $sales, $earnings ) ); |
126 | 126 | endforeach; |
127 | - else: |
|
127 | + else { |
|
128 | + : |
|
128 | 129 | $pdf->SetWidths( array( 280 ) ); |
130 | + } |
|
129 | 131 | $title = utf8_decode( sprintf( __( 'No %s found.', 'give' ), give_get_forms_label_plural() ) ); |
130 | 132 | $pdf->Row( array( $title ) ); |
131 | 133 | endif; |
@@ -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,82 +25,82 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @uses give_pdf |
27 | 27 | */ |
28 | -function give_generate_pdf( $data ) { |
|
28 | +function give_generate_pdf($data) { |
|
29 | 29 | |
30 | - if ( ! current_user_can( 'view_give_reports' ) ) { |
|
31 | - wp_die( esc_html__( 'You do not have permission to generate PDF sales reports.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
30 | + if ( ! current_user_can('view_give_reports')) { |
|
31 | + wp_die(esc_html__('You do not have permission to generate PDF sales reports.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
32 | 32 | } |
33 | 33 | |
34 | - if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'give_generate_pdf' ) ) { |
|
35 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
34 | + if ( ! wp_verify_nonce($_GET['_wpnonce'], 'give_generate_pdf')) { |
|
35 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
36 | 36 | } |
37 | 37 | |
38 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/fpdf/fpdf.php'; |
|
39 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/fpdf/give_pdf.php'; |
|
38 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/fpdf/fpdf.php'; |
|
39 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/fpdf/give_pdf.php'; |
|
40 | 40 | |
41 | 41 | $daterange = utf8_decode( |
42 | 42 | sprintf( |
43 | 43 | /* translators: 1: start date 2: end date */ |
44 | - esc_html__( '%1$s to %2$s', 'give' ), |
|
45 | - date_i18n( get_option( 'date_format' ), mktime( 0, 0, 0, 1, 1, date( 'Y' ) ) ), |
|
46 | - date_i18n( get_option( 'date_format' ) ) |
|
44 | + esc_html__('%1$s to %2$s', 'give'), |
|
45 | + date_i18n(get_option('date_format'), mktime(0, 0, 0, 1, 1, date('Y'))), |
|
46 | + date_i18n(get_option('date_format')) |
|
47 | 47 | ) |
48 | 48 | ); |
49 | 49 | |
50 | 50 | $pdf = new give_pdf(); |
51 | - $pdf->AddPage( 'L', 'A4' ); |
|
51 | + $pdf->AddPage('L', 'A4'); |
|
52 | 52 | |
53 | - $pdf->SetTitle( utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ) ); |
|
54 | - $pdf->SetAuthor( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) ); |
|
55 | - $pdf->SetCreator( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) ); |
|
53 | + $pdf->SetTitle(utf8_decode(__('Donation report for the current year for all forms', 'give'))); |
|
54 | + $pdf->SetAuthor(utf8_decode(__('Give - Democratizing Generosity', 'give'))); |
|
55 | + $pdf->SetCreator(utf8_decode(__('Give - Democratizing Generosity', 'give'))); |
|
56 | 56 | |
57 | - $pdf->Image( apply_filters( 'give_pdf_export_logo', GIVE_PLUGIN_URL . 'assets/images/give-logo-small.png' ), 247, 8 ); |
|
57 | + $pdf->Image(apply_filters('give_pdf_export_logo', GIVE_PLUGIN_URL.'assets/images/give-logo-small.png'), 247, 8); |
|
58 | 58 | |
59 | - $pdf->SetMargins( 8, 8, 8 ); |
|
60 | - $pdf->SetX( 8 ); |
|
59 | + $pdf->SetMargins(8, 8, 8); |
|
60 | + $pdf->SetX(8); |
|
61 | 61 | |
62 | - $pdf->SetFont( 'Helvetica', '', 16 ); |
|
63 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
64 | - $pdf->Cell( 0, 3, utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ), 0, 2, 'L', false ); |
|
62 | + $pdf->SetFont('Helvetica', '', 16); |
|
63 | + $pdf->SetTextColor(50, 50, 50); |
|
64 | + $pdf->Cell(0, 3, utf8_decode(__('Donation report for the current year for all forms', 'give')), 0, 2, 'L', false); |
|
65 | 65 | |
66 | - $pdf->SetFont( 'Helvetica', '', 13 ); |
|
66 | + $pdf->SetFont('Helvetica', '', 13); |
|
67 | 67 | $pdf->Ln(); |
68 | - $pdf->SetTextColor( 150, 150, 150 ); |
|
69 | - $pdf->Cell( 0, 6, utf8_decode( __( 'Date Range: ', 'give' ) ) . $daterange, 0, 2, 'L', false ); |
|
68 | + $pdf->SetTextColor(150, 150, 150); |
|
69 | + $pdf->Cell(0, 6, utf8_decode(__('Date Range: ', 'give')).$daterange, 0, 2, 'L', false); |
|
70 | 70 | $pdf->Ln(); |
71 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
72 | - $pdf->SetFont( 'Helvetica', '', 14 ); |
|
73 | - $pdf->Cell( 0, 10, utf8_decode( __( 'Table View', 'give' ) ), 0, 2, 'L', false ); |
|
74 | - $pdf->SetFont( 'Helvetica', '', 12 ); |
|
71 | + $pdf->SetTextColor(50, 50, 50); |
|
72 | + $pdf->SetFont('Helvetica', '', 14); |
|
73 | + $pdf->Cell(0, 10, utf8_decode(__('Table View', 'give')), 0, 2, 'L', false); |
|
74 | + $pdf->SetFont('Helvetica', '', 12); |
|
75 | 75 | |
76 | - $pdf->SetFillColor( 238, 238, 238 ); |
|
77 | - $pdf->Cell( 70, 6, utf8_decode( __( 'Form Name', 'give' ) ), 1, 0, 'L', true ); |
|
78 | - $pdf->Cell( 30, 6, utf8_decode( __( 'Price', 'give' ) ), 1, 0, 'L', true ); |
|
79 | - $pdf->Cell( 50, 6, utf8_decode( __( 'Categories', 'give' ) ), 1, 0, 'L', true ); |
|
80 | - $pdf->Cell( 50, 6, utf8_decode( __( 'Tags', 'give' ) ), 1, 0, 'L', true ); |
|
81 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Number of Donations', 'give' ) ), 1, 0, 'L', true ); |
|
82 | - $pdf->Cell( 35, 6, utf8_decode( __( 'Income to Date', 'give' ) ), 1, 1, 'L', true ); |
|
76 | + $pdf->SetFillColor(238, 238, 238); |
|
77 | + $pdf->Cell(70, 6, utf8_decode(__('Form Name', 'give')), 1, 0, 'L', true); |
|
78 | + $pdf->Cell(30, 6, utf8_decode(__('Price', 'give')), 1, 0, 'L', true); |
|
79 | + $pdf->Cell(50, 6, utf8_decode(__('Categories', 'give')), 1, 0, 'L', true); |
|
80 | + $pdf->Cell(50, 6, utf8_decode(__('Tags', 'give')), 1, 0, 'L', true); |
|
81 | + $pdf->Cell(45, 6, utf8_decode(__('Number of Donations', 'give')), 1, 0, 'L', true); |
|
82 | + $pdf->Cell(35, 6, utf8_decode(__('Income to Date', 'give')), 1, 1, 'L', true); |
|
83 | 83 | |
84 | - $year = date( 'Y' ); |
|
85 | - $give_forms = get_posts( array( 'post_type' => 'give_forms', 'year' => $year, 'posts_per_page' => - 1 ) ); |
|
84 | + $year = date('Y'); |
|
85 | + $give_forms = get_posts(array('post_type' => 'give_forms', 'year' => $year, 'posts_per_page' => -1)); |
|
86 | 86 | |
87 | - if ( $give_forms ): |
|
88 | - $pdf->SetWidths( array( 70, 30, 50, 50, 45, 35 ) ); |
|
87 | + if ($give_forms): |
|
88 | + $pdf->SetWidths(array(70, 30, 50, 50, 45, 35)); |
|
89 | 89 | |
90 | - foreach ( $give_forms as $form ): |
|
91 | - $pdf->SetFillColor( 255, 255, 255 ); |
|
90 | + foreach ($give_forms as $form): |
|
91 | + $pdf->SetFillColor(255, 255, 255); |
|
92 | 92 | |
93 | 93 | $title = $form->post_title; |
94 | 94 | |
95 | - if ( give_has_variable_prices( $form->ID ) ) { |
|
95 | + if (give_has_variable_prices($form->ID)) { |
|
96 | 96 | |
97 | - $prices = give_get_variable_prices( $form->ID ); |
|
97 | + $prices = give_get_variable_prices($form->ID); |
|
98 | 98 | |
99 | 99 | $first = $prices[0]['_give_amount']; |
100 | - $last = array_pop( $prices ); |
|
100 | + $last = array_pop($prices); |
|
101 | 101 | $last = $last['_give_amount']; |
102 | 102 | |
103 | - if ( $first < $last ) { |
|
103 | + if ($first < $last) { |
|
104 | 104 | $min = $first; |
105 | 105 | $max = $last; |
106 | 106 | } else { |
@@ -108,57 +108,57 @@ discard block |
||
108 | 108 | $max = $first; |
109 | 109 | } |
110 | 110 | |
111 | - $price = html_entity_decode( give_currency_filter( give_format_amount( $min ) ) . ' - ' . give_currency_filter( give_format_amount( $max ) ) ); |
|
111 | + $price = html_entity_decode(give_currency_filter(give_format_amount($min)).' - '.give_currency_filter(give_format_amount($max))); |
|
112 | 112 | } else { |
113 | - $price = html_entity_decode( give_currency_filter( give_get_form_price( $form->ID ) ) ); |
|
113 | + $price = html_entity_decode(give_currency_filter(give_get_form_price($form->ID))); |
|
114 | 114 | } |
115 | 115 | |
116 | - $categories = get_the_term_list( $form->ID, 'give_forms_category', '', ', ', '' ); |
|
117 | - $categories = ! is_wp_error( $categories ) ? strip_tags( $categories ) : ''; |
|
116 | + $categories = get_the_term_list($form->ID, 'give_forms_category', '', ', ', ''); |
|
117 | + $categories = ! is_wp_error($categories) ? strip_tags($categories) : ''; |
|
118 | 118 | |
119 | - $tags = get_the_term_list( $form->ID, 'give_forms_tag', '', ', ', '' ); |
|
120 | - $tags = ! is_wp_error( $tags ) ? strip_tags( $tags ) : ''; |
|
119 | + $tags = get_the_term_list($form->ID, 'give_forms_tag', '', ', ', ''); |
|
120 | + $tags = ! is_wp_error($tags) ? strip_tags($tags) : ''; |
|
121 | 121 | |
122 | - $sales = give_get_form_sales_stats( $form->ID ); |
|
123 | - $link = get_permalink( $form->ID ); |
|
124 | - $earnings = html_entity_decode( give_currency_filter( give_get_form_earnings_stats( $form->ID ) ) ); |
|
122 | + $sales = give_get_form_sales_stats($form->ID); |
|
123 | + $link = get_permalink($form->ID); |
|
124 | + $earnings = html_entity_decode(give_currency_filter(give_get_form_earnings_stats($form->ID))); |
|
125 | 125 | |
126 | - if ( function_exists( 'iconv' ) ) { |
|
126 | + if (function_exists('iconv')) { |
|
127 | 127 | // Ensure characters like euro; are properly converted. |
128 | - $price = iconv( 'UTF-8', 'windows-1252', utf8_encode( $price ) ); |
|
129 | - $earnings = iconv( 'UTF-8', 'windows-1252', utf8_encode( $earnings ) ); |
|
128 | + $price = iconv('UTF-8', 'windows-1252', utf8_encode($price)); |
|
129 | + $earnings = iconv('UTF-8', 'windows-1252', utf8_encode($earnings)); |
|
130 | 130 | } |
131 | 131 | |
132 | - $pdf->Row( array( $title, $price, $categories, $tags, $sales, $earnings ) ); |
|
132 | + $pdf->Row(array($title, $price, $categories, $tags, $sales, $earnings)); |
|
133 | 133 | endforeach; |
134 | 134 | else: |
135 | - $pdf->SetWidths( array( 280 ) ); |
|
135 | + $pdf->SetWidths(array(280)); |
|
136 | 136 | $title = utf8_decode( |
137 | 137 | sprintf( |
138 | 138 | /* translators: %s: form plural label */ |
139 | - esc_html__( 'No %s found.', 'give' ), |
|
139 | + esc_html__('No %s found.', 'give'), |
|
140 | 140 | give_get_forms_label_plural() |
141 | 141 | ) |
142 | 142 | ); |
143 | - $pdf->Row( array( $title ) ); |
|
143 | + $pdf->Row(array($title)); |
|
144 | 144 | endif; |
145 | 145 | |
146 | 146 | $pdf->Ln(); |
147 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
148 | - $pdf->SetFont( 'Helvetica', '', 14 ); |
|
149 | - $pdf->Cell( 0, 10, utf8_decode( __( 'Graph View', 'give' ) ), 0, 2, 'L', false ); |
|
150 | - $pdf->SetFont( 'Helvetica', '', 12 ); |
|
151 | - |
|
152 | - $image = html_entity_decode( urldecode( give_draw_chart_image() ) ); |
|
153 | - $image = str_replace( ' ', '%20', $image ); |
|
154 | - |
|
155 | - $pdf->SetX( 25 ); |
|
156 | - $pdf->Image( $image . '&file=.png' ); |
|
157 | - $pdf->Ln( 7 ); |
|
158 | - $pdf->Output( apply_filters( 'give_sales_earnings_pdf_export_filename', 'give-report-' . date_i18n( 'Y-m-d' ) ) . '.pdf', 'D' ); |
|
147 | + $pdf->SetTextColor(50, 50, 50); |
|
148 | + $pdf->SetFont('Helvetica', '', 14); |
|
149 | + $pdf->Cell(0, 10, utf8_decode(__('Graph View', 'give')), 0, 2, 'L', false); |
|
150 | + $pdf->SetFont('Helvetica', '', 12); |
|
151 | + |
|
152 | + $image = html_entity_decode(urldecode(give_draw_chart_image())); |
|
153 | + $image = str_replace(' ', '%20', $image); |
|
154 | + |
|
155 | + $pdf->SetX(25); |
|
156 | + $pdf->Image($image.'&file=.png'); |
|
157 | + $pdf->Ln(7); |
|
158 | + $pdf->Output(apply_filters('give_sales_earnings_pdf_export_filename', 'give-report-'.date_i18n('Y-m-d')).'.pdf', 'D'); |
|
159 | 159 | } |
160 | 160 | |
161 | -add_action( 'give_generate_pdf', 'give_generate_pdf' ); |
|
161 | +add_action('give_generate_pdf', 'give_generate_pdf'); |
|
162 | 162 | |
163 | 163 | /** |
164 | 164 | * Draws Chart for PDF Report. |
@@ -175,38 +175,38 @@ discard block |
||
175 | 175 | * @return string $chart->getUrl() URL for the Google Chart |
176 | 176 | */ |
177 | 177 | function give_draw_chart_image() { |
178 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/GoogleChart.php'; |
|
179 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php'; |
|
180 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php'; |
|
178 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/GoogleChart.php'; |
|
179 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php'; |
|
180 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php'; |
|
181 | 181 | |
182 | - $chart = new GoogleChart( 'lc', 900, 330 ); |
|
182 | + $chart = new GoogleChart('lc', 900, 330); |
|
183 | 183 | |
184 | 184 | $i = 1; |
185 | 185 | $earnings = ""; |
186 | 186 | $sales = ""; |
187 | 187 | |
188 | - while ( $i <= 12 ) : |
|
189 | - $earnings .= give_get_earnings_by_date( null, $i, date( 'Y' ) ) . ","; |
|
190 | - $sales .= give_get_sales_by_date( null, $i, date( 'Y' ) ) . ","; |
|
191 | - $i ++; |
|
188 | + while ($i <= 12) : |
|
189 | + $earnings .= give_get_earnings_by_date(null, $i, date('Y')).","; |
|
190 | + $sales .= give_get_sales_by_date(null, $i, date('Y')).","; |
|
191 | + $i++; |
|
192 | 192 | endwhile; |
193 | 193 | |
194 | - $earnings_array = explode( ",", $earnings ); |
|
195 | - $sales_array = explode( ",", $sales ); |
|
194 | + $earnings_array = explode(",", $earnings); |
|
195 | + $sales_array = explode(",", $sales); |
|
196 | 196 | |
197 | 197 | $i = 0; |
198 | - while ( $i <= 11 ) { |
|
199 | - if ( empty( $sales_array[ $i ] ) ) { |
|
200 | - $sales_array[ $i ] = 0; |
|
198 | + while ($i <= 11) { |
|
199 | + if (empty($sales_array[$i])) { |
|
200 | + $sales_array[$i] = 0; |
|
201 | 201 | } |
202 | - $i ++; |
|
202 | + $i++; |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | $min_earnings = 0; |
206 | - $max_earnings = max( $earnings_array ); |
|
207 | - $earnings_scale = round( $max_earnings, - 1 ); |
|
206 | + $max_earnings = max($earnings_array); |
|
207 | + $earnings_scale = round($max_earnings, - 1); |
|
208 | 208 | |
209 | - $data = new GoogleChartData( array( |
|
209 | + $data = new GoogleChartData(array( |
|
210 | 210 | $earnings_array[0], |
211 | 211 | $earnings_array[1], |
212 | 212 | $earnings_array[2], |
@@ -219,25 +219,25 @@ discard block |
||
219 | 219 | $earnings_array[9], |
220 | 220 | $earnings_array[10], |
221 | 221 | $earnings_array[11] |
222 | - ) ); |
|
222 | + )); |
|
223 | 223 | |
224 | - $data->setLegend( esc_html__( 'Income', 'give' ) ); |
|
225 | - $data->setColor( '1b58a3' ); |
|
226 | - $chart->addData( $data ); |
|
224 | + $data->setLegend(esc_html__('Income', 'give')); |
|
225 | + $data->setColor('1b58a3'); |
|
226 | + $chart->addData($data); |
|
227 | 227 | |
228 | - $shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE ); |
|
229 | - $shape_marker->setColor( '000000' ); |
|
230 | - $shape_marker->setSize( 7 ); |
|
231 | - $shape_marker->setBorder( 2 ); |
|
232 | - $shape_marker->setData( $data ); |
|
233 | - $chart->addMarker( $shape_marker ); |
|
228 | + $shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); |
|
229 | + $shape_marker->setColor('000000'); |
|
230 | + $shape_marker->setSize(7); |
|
231 | + $shape_marker->setBorder(2); |
|
232 | + $shape_marker->setData($data); |
|
233 | + $chart->addMarker($shape_marker); |
|
234 | 234 | |
235 | - $value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE ); |
|
236 | - $value_marker->setColor( '000000' ); |
|
237 | - $value_marker->setData( $data ); |
|
238 | - $chart->addMarker( $value_marker ); |
|
235 | + $value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE); |
|
236 | + $value_marker->setColor('000000'); |
|
237 | + $value_marker->setData($data); |
|
238 | + $chart->addMarker($value_marker); |
|
239 | 239 | |
240 | - $data = new GoogleChartData( array( |
|
240 | + $data = new GoogleChartData(array( |
|
241 | 241 | $sales_array[0], |
242 | 242 | $sales_array[1], |
243 | 243 | $sales_array[2], |
@@ -250,46 +250,46 @@ discard block |
||
250 | 250 | $sales_array[9], |
251 | 251 | $sales_array[10], |
252 | 252 | $sales_array[11] |
253 | - ) ); |
|
254 | - $data->setLegend( esc_html__( 'Donations', 'give' ) ); |
|
255 | - $data->setColor( 'ff6c1c' ); |
|
256 | - $chart->addData( $data ); |
|
257 | - |
|
258 | - $chart->setTitle( esc_html__( 'Donations by Month for all Give Forms', 'give' ), '336699', 18 ); |
|
259 | - |
|
260 | - $chart->setScale( 0, $max_earnings ); |
|
261 | - |
|
262 | - $y_axis = new GoogleChartAxis( 'y' ); |
|
263 | - $y_axis->setDrawTickMarks( true )->setLabels( array( 0, $max_earnings ) ); |
|
264 | - $chart->addAxis( $y_axis ); |
|
265 | - |
|
266 | - $x_axis = new GoogleChartAxis( 'x' ); |
|
267 | - $x_axis->setTickMarks( 5 ); |
|
268 | - $x_axis->setLabels( array( |
|
269 | - esc_html__( 'Jan', 'give' ), |
|
270 | - esc_html__( 'Feb', 'give' ), |
|
271 | - esc_html__( 'Mar', 'give' ), |
|
272 | - esc_html__( 'Apr', 'give' ), |
|
273 | - esc_html__( 'May', 'give' ), |
|
274 | - esc_html__( 'June', 'give' ), |
|
275 | - esc_html__( 'July', 'give' ), |
|
276 | - esc_html__( 'Aug', 'give' ), |
|
277 | - esc_html__( 'Sept', 'give' ), |
|
278 | - esc_html__( 'Oct', 'give' ), |
|
279 | - esc_html__( 'Nov', 'give' ), |
|
280 | - esc_html__( 'Dec', 'give' ) |
|
281 | - ) ); |
|
282 | - $chart->addAxis( $x_axis ); |
|
283 | - |
|
284 | - $shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE ); |
|
285 | - $shape_marker->setSize( 6 ); |
|
286 | - $shape_marker->setBorder( 2 ); |
|
287 | - $shape_marker->setData( $data ); |
|
288 | - $chart->addMarker( $shape_marker ); |
|
289 | - |
|
290 | - $value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE ); |
|
291 | - $value_marker->setData( $data ); |
|
292 | - $chart->addMarker( $value_marker ); |
|
253 | + )); |
|
254 | + $data->setLegend(esc_html__('Donations', 'give')); |
|
255 | + $data->setColor('ff6c1c'); |
|
256 | + $chart->addData($data); |
|
257 | + |
|
258 | + $chart->setTitle(esc_html__('Donations by Month for all Give Forms', 'give'), '336699', 18); |
|
259 | + |
|
260 | + $chart->setScale(0, $max_earnings); |
|
261 | + |
|
262 | + $y_axis = new GoogleChartAxis('y'); |
|
263 | + $y_axis->setDrawTickMarks(true)->setLabels(array(0, $max_earnings)); |
|
264 | + $chart->addAxis($y_axis); |
|
265 | + |
|
266 | + $x_axis = new GoogleChartAxis('x'); |
|
267 | + $x_axis->setTickMarks(5); |
|
268 | + $x_axis->setLabels(array( |
|
269 | + esc_html__('Jan', 'give'), |
|
270 | + esc_html__('Feb', 'give'), |
|
271 | + esc_html__('Mar', 'give'), |
|
272 | + esc_html__('Apr', 'give'), |
|
273 | + esc_html__('May', 'give'), |
|
274 | + esc_html__('June', 'give'), |
|
275 | + esc_html__('July', 'give'), |
|
276 | + esc_html__('Aug', 'give'), |
|
277 | + esc_html__('Sept', 'give'), |
|
278 | + esc_html__('Oct', 'give'), |
|
279 | + esc_html__('Nov', 'give'), |
|
280 | + esc_html__('Dec', 'give') |
|
281 | + )); |
|
282 | + $chart->addAxis($x_axis); |
|
283 | + |
|
284 | + $shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); |
|
285 | + $shape_marker->setSize(6); |
|
286 | + $shape_marker->setBorder(2); |
|
287 | + $shape_marker->setData($data); |
|
288 | + $chart->addMarker($shape_marker); |
|
289 | + |
|
290 | + $value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE); |
|
291 | + $value_marker->setData($data); |
|
292 | + $chart->addMarker($value_marker); |
|
293 | 293 | |
294 | 294 | return $chart->getUrl(); |
295 | 295 | } |
@@ -10,7 +10,7 @@ |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
13 | +if ( ! defined('ABSPATH')) exit; |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Give_API_V1 Class |
@@ -10,7 +10,9 @@ |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
13 | +if ( ! defined( 'ABSPATH' ) ) { |
|
14 | + exit; |
|
15 | +} |
|
14 | 16 | |
15 | 17 | /** |
16 | 18 | * Give_API_V1 Class |
@@ -97,10 +97,10 @@ |
||
97 | 97 | |
98 | 98 | //Single Form settings varies compared to the Global default settings |
99 | 99 | if ( ! empty( $form_default ) && |
100 | - $form_id !== null && |
|
101 | - $default !== $form_default && |
|
102 | - $form_default !== 'global' && |
|
103 | - give_is_gateway_active( $form_default ) |
|
100 | + $form_id !== null && |
|
101 | + $default !== $form_default && |
|
102 | + $form_default !== 'global' && |
|
103 | + give_is_gateway_active( $form_default ) |
|
104 | 104 | ) { |
105 | 105 | $default = $form_default; |
106 | 106 | } |
@@ -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,16 +24,16 @@ discard block |
||
24 | 24 | // Default, built-in gateways |
25 | 25 | $gateways = array( |
26 | 26 | 'paypal' => array( |
27 | - 'admin_label' => esc_html__( 'PayPal Standard', 'give' ), |
|
28 | - 'checkout_label' => esc_html__( 'PayPal', 'give' ), |
|
27 | + 'admin_label' => esc_html__('PayPal Standard', 'give'), |
|
28 | + 'checkout_label' => esc_html__('PayPal', 'give'), |
|
29 | 29 | ), |
30 | 30 | 'manual' => array( |
31 | - 'admin_label' => esc_html__( 'Test Payment', 'give' ), |
|
32 | - 'checkout_label' => esc_html__( 'Test Payment', 'give' ) |
|
31 | + 'admin_label' => esc_html__('Test Payment', 'give'), |
|
32 | + 'checkout_label' => esc_html__('Test Payment', 'give') |
|
33 | 33 | ), |
34 | 34 | ); |
35 | 35 | |
36 | - return apply_filters( 'give_payment_gateways', $gateways ); |
|
36 | + return apply_filters('give_payment_gateways', $gateways); |
|
37 | 37 | |
38 | 38 | } |
39 | 39 | |
@@ -47,20 +47,20 @@ discard block |
||
47 | 47 | |
48 | 48 | $gateways = give_get_payment_gateways(); |
49 | 49 | |
50 | - $enabled = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' ); |
|
50 | + $enabled = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways'); |
|
51 | 51 | |
52 | 52 | $gateway_list = array(); |
53 | 53 | |
54 | - foreach ( $gateways as $key => $gateway ) { |
|
55 | - if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) { |
|
56 | - $gateway_list[ $key ] = $gateway; |
|
54 | + foreach ($gateways as $key => $gateway) { |
|
55 | + if (isset($enabled[$key]) && $enabled[$key] == 1) { |
|
56 | + $gateway_list[$key] = $gateway; |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
60 | 60 | // Set order of payment gateway in list. |
61 | - $gateway_list = give_get_ordered_payment_gateways( $gateway_list ); |
|
61 | + $gateway_list = give_get_ordered_payment_gateways($gateway_list); |
|
62 | 62 | |
63 | - return apply_filters( 'give_enabled_payment_gateways', $gateway_list ); |
|
63 | + return apply_filters('give_enabled_payment_gateways', $gateway_list); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -72,12 +72,12 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @return boolean true if enabled, false otherwise |
74 | 74 | */ |
75 | -function give_is_gateway_active( $gateway ) { |
|
75 | +function give_is_gateway_active($gateway) { |
|
76 | 76 | $gateways = give_get_enabled_payment_gateways(); |
77 | 77 | |
78 | - $ret = array_key_exists( $gateway, $gateways ); |
|
78 | + $ret = array_key_exists($gateway, $gateways); |
|
79 | 79 | |
80 | - return apply_filters( 'give_is_gateway_active', $ret, $gateway, $gateways ); |
|
80 | + return apply_filters('give_is_gateway_active', $ret, $gateway, $gateways); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -90,24 +90,24 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return string Gateway ID |
92 | 92 | */ |
93 | -function give_get_default_gateway( $form_id ) { |
|
93 | +function give_get_default_gateway($form_id) { |
|
94 | 94 | |
95 | 95 | global $give_options; |
96 | 96 | |
97 | - $default = isset( $give_options['default_gateway'] ) && give_is_gateway_active( $give_options['default_gateway'] ) ? $give_options['default_gateway'] : 'paypal'; |
|
98 | - $form_default = get_post_meta( $form_id, '_give_default_gateway', true ); |
|
97 | + $default = isset($give_options['default_gateway']) && give_is_gateway_active($give_options['default_gateway']) ? $give_options['default_gateway'] : 'paypal'; |
|
98 | + $form_default = get_post_meta($form_id, '_give_default_gateway', true); |
|
99 | 99 | |
100 | 100 | //Single Form settings varies compared to the Global default settings |
101 | - if ( ! empty( $form_default ) && |
|
101 | + if ( ! empty($form_default) && |
|
102 | 102 | $form_id !== null && |
103 | 103 | $default !== $form_default && |
104 | 104 | $form_default !== 'global' && |
105 | - give_is_gateway_active( $form_default ) |
|
105 | + give_is_gateway_active($form_default) |
|
106 | 106 | ) { |
107 | 107 | $default = $form_default; |
108 | 108 | } |
109 | 109 | |
110 | - return apply_filters( 'give_default_gateway', $default ); |
|
110 | + return apply_filters('give_default_gateway', $default); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -119,18 +119,18 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @return string Gateway admin label |
121 | 121 | */ |
122 | -function give_get_gateway_admin_label( $gateway ) { |
|
122 | +function give_get_gateway_admin_label($gateway) { |
|
123 | 123 | $gateways = give_get_enabled_payment_gateways(); |
124 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway; |
|
125 | - $payment = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false; |
|
124 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway; |
|
125 | + $payment = isset($_GET['id']) ? absint($_GET['id']) : false; |
|
126 | 126 | |
127 | - if ( $gateway == 'manual' && $payment ) { |
|
128 | - if ( give_get_payment_amount( $payment ) == 0 ) { |
|
129 | - $label = esc_html__( 'Test Donation', 'give' ); |
|
127 | + if ($gateway == 'manual' && $payment) { |
|
128 | + if (give_get_payment_amount($payment) == 0) { |
|
129 | + $label = esc_html__('Test Donation', 'give'); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
133 | - return apply_filters( 'give_gateway_admin_label', $label, $gateway ); |
|
133 | + return apply_filters('give_gateway_admin_label', $label, $gateway); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -142,15 +142,15 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @return string Checkout label for the gateway |
144 | 144 | */ |
145 | -function give_get_gateway_checkout_label( $gateway ) { |
|
145 | +function give_get_gateway_checkout_label($gateway) { |
|
146 | 146 | $gateways = give_get_enabled_payment_gateways(); |
147 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway; |
|
147 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway; |
|
148 | 148 | |
149 | - if ( $gateway == 'manual' ) { |
|
150 | - $label = esc_html__( 'Test Donation', 'give' ); |
|
149 | + if ($gateway == 'manual') { |
|
150 | + $label = esc_html__('Test Donation', 'give'); |
|
151 | 151 | } |
152 | 152 | |
153 | - return apply_filters( 'give_gateway_checkout_label', $label, $gateway ); |
|
153 | + return apply_filters('give_gateway_checkout_label', $label, $gateway); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -162,11 +162,11 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @return array Options the gateway supports |
164 | 164 | */ |
165 | -function give_get_gateway_supports( $gateway ) { |
|
165 | +function give_get_gateway_supports($gateway) { |
|
166 | 166 | $gateways = give_get_enabled_payment_gateways(); |
167 | - $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array(); |
|
167 | + $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array(); |
|
168 | 168 | |
169 | - return apply_filters( 'give_gateway_supports', $supports, $gateway ); |
|
169 | + return apply_filters('give_gateway_supports', $supports, $gateway); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -179,12 +179,12 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @return void |
181 | 181 | */ |
182 | -function give_send_to_gateway( $gateway, $payment_data ) { |
|
182 | +function give_send_to_gateway($gateway, $payment_data) { |
|
183 | 183 | |
184 | - $payment_data['gateway_nonce'] = wp_create_nonce( 'give-gateway' ); |
|
184 | + $payment_data['gateway_nonce'] = wp_create_nonce('give-gateway'); |
|
185 | 185 | |
186 | 186 | // $gateway must match the ID used when registering the gateway |
187 | - do_action( 'give_gateway_' . $gateway, $payment_data ); |
|
187 | + do_action('give_gateway_'.$gateway, $payment_data); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | |
@@ -201,32 +201,32 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @return string $enabled_gateway The slug of the gateway |
203 | 203 | */ |
204 | -function give_get_chosen_gateway( $form_id ) { |
|
204 | +function give_get_chosen_gateway($form_id) { |
|
205 | 205 | $gateways = give_get_enabled_payment_gateways(); |
206 | - $request_form_id = isset( $_REQUEST['give_form_id'] ) ? $_REQUEST['give_form_id'] : 0; |
|
207 | - if ( empty( $request_form_id ) ) { |
|
208 | - $request_form_id = isset( $_REQUEST['form-id'] ) ? $_REQUEST['form-id'] : 0; |
|
206 | + $request_form_id = isset($_REQUEST['give_form_id']) ? $_REQUEST['give_form_id'] : 0; |
|
207 | + if (empty($request_form_id)) { |
|
208 | + $request_form_id = isset($_REQUEST['form-id']) ? $_REQUEST['form-id'] : 0; |
|
209 | 209 | } |
210 | - $chosen = give_get_default_gateway( $form_id ); |
|
210 | + $chosen = give_get_default_gateway($form_id); |
|
211 | 211 | $enabled_gateway = ''; |
212 | 212 | |
213 | 213 | //Take into account request Form ID args |
214 | - if ( ! empty( $request_form_id ) && $form_id == $request_form_id ) { |
|
215 | - $chosen = isset( $_REQUEST['payment-mode'] ) ? $_REQUEST['payment-mode'] : ''; |
|
214 | + if ( ! empty($request_form_id) && $form_id == $request_form_id) { |
|
215 | + $chosen = isset($_REQUEST['payment-mode']) ? $_REQUEST['payment-mode'] : ''; |
|
216 | 216 | } |
217 | 217 | |
218 | - if ( $chosen ) { |
|
219 | - $enabled_gateway = urldecode( $chosen ); |
|
220 | - } else if ( count( $gateways ) >= 1 && ! $chosen ) { |
|
221 | - foreach ( $gateways as $gateway_id => $gateway ): |
|
218 | + if ($chosen) { |
|
219 | + $enabled_gateway = urldecode($chosen); |
|
220 | + } else if (count($gateways) >= 1 && ! $chosen) { |
|
221 | + foreach ($gateways as $gateway_id => $gateway): |
|
222 | 222 | $enabled_gateway = $gateway_id; |
223 | 223 | endforeach; |
224 | 224 | } else { |
225 | - $enabled_gateway = give_get_default_gateway( $form_id ); |
|
225 | + $enabled_gateway = give_get_default_gateway($form_id); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | |
229 | - return apply_filters( 'give_chosen_gateway', $enabled_gateway ); |
|
229 | + return apply_filters('give_chosen_gateway', $enabled_gateway); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -243,8 +243,8 @@ discard block |
||
243 | 243 | * |
244 | 244 | * @return int ID of the new log entry |
245 | 245 | */ |
246 | -function give_record_gateway_error( $title = '', $message = '', $parent = 0 ) { |
|
247 | - return give_record_log( $title, $message, $parent, 'gateway_error' ); |
|
246 | +function give_record_gateway_error($title = '', $message = '', $parent = 0) { |
|
247 | + return give_record_log($title, $message, $parent, 'gateway_error'); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * |
258 | 258 | * @return int |
259 | 259 | */ |
260 | -function give_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
|
260 | +function give_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') { |
|
261 | 261 | |
262 | 262 | $ret = 0; |
263 | 263 | $args = array( |
@@ -269,9 +269,9 @@ discard block |
||
269 | 269 | 'fields' => 'ids' |
270 | 270 | ); |
271 | 271 | |
272 | - $payments = new WP_Query( $args ); |
|
272 | + $payments = new WP_Query($args); |
|
273 | 273 | |
274 | - if ( $payments ) { |
|
274 | + if ($payments) { |
|
275 | 275 | $ret = $payments->post_count; |
276 | 276 | } |
277 | 277 | |
@@ -288,27 +288,27 @@ discard block |
||
288 | 288 | * |
289 | 289 | * @return array $gateways All the available gateways |
290 | 290 | */ |
291 | -function give_get_ordered_payment_gateways( $gateways ) { |
|
291 | +function give_get_ordered_payment_gateways($gateways) { |
|
292 | 292 | |
293 | 293 | // Get gateways setting. |
294 | - $gateways_setting = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' ); |
|
294 | + $gateways_setting = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways'); |
|
295 | 295 | |
296 | 296 | // Return from here if we do not have gateways setting. |
297 | - if ( empty( $gateways_setting ) ) { |
|
297 | + if (empty($gateways_setting)) { |
|
298 | 298 | return $gateways; |
299 | 299 | } |
300 | 300 | |
301 | 301 | // Reverse array to order payment gateways. |
302 | - $gateways_setting = array_reverse( $gateways_setting ); |
|
302 | + $gateways_setting = array_reverse($gateways_setting); |
|
303 | 303 | |
304 | 304 | // Reorder gateways array |
305 | - foreach ( $gateways_setting as $gateway_key => $value ) { |
|
305 | + foreach ($gateways_setting as $gateway_key => $value) { |
|
306 | 306 | |
307 | - $new_gateway_value = isset( $gateways[ $gateway_key ] ) ? $gateways[ $gateway_key ] : ''; |
|
308 | - unset( $gateways[ $gateway_key ] ); |
|
307 | + $new_gateway_value = isset($gateways[$gateway_key]) ? $gateways[$gateway_key] : ''; |
|
308 | + unset($gateways[$gateway_key]); |
|
309 | 309 | |
310 | - if ( ! empty( $new_gateway_value ) ) { |
|
311 | - $gateways = array_merge( array( $gateway_key => $new_gateway_value ), $gateways ); |
|
310 | + if ( ! empty($new_gateway_value)) { |
|
311 | + $gateways = array_merge(array($gateway_key => $new_gateway_value), $gateways); |
|
312 | 312 | } |
313 | 313 | } |
314 | 314 | |
@@ -319,5 +319,5 @@ discard block |
||
319 | 319 | * |
320 | 320 | * @param array $gateways All the available gateways |
321 | 321 | */ |
322 | - return apply_filters( 'give_payment_gateways_order', $gateways ); |
|
322 | + return apply_filters('give_payment_gateways_order', $gateways); |
|
323 | 323 | } |