@@ -206,6 +206,7 @@ |
||
206 | 206 | * Set Donor Data |
207 | 207 | * |
208 | 208 | * @param $donor |
209 | + * @param integer $i |
|
209 | 210 | */ |
210 | 211 | private function set_donor_data( $i, $data, $donor ) { |
211 | 212 |
@@ -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 | |
@@ -46,16 +46,16 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @param array $request The Form Data passed into the batch processing |
48 | 48 | */ |
49 | - public function set_properties( $request ) { |
|
49 | + public function set_properties($request) { |
|
50 | 50 | |
51 | 51 | //Set data from form submission |
52 | - if ( isset( $_POST['form'] ) ) { |
|
53 | - parse_str( $_POST['form'], $this->data ); |
|
52 | + if (isset($_POST['form'])) { |
|
53 | + parse_str($_POST['form'], $this->data); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | $this->form = $this->data['forms']; |
57 | 57 | |
58 | - $this->price_id = ! empty( $request['give_price_option'] ) && 0 !== $request['give_price_option'] ? absint( $request['give_price_option'] ) : null; |
|
58 | + $this->price_id = ! empty($request['give_price_option']) && 0 !== $request['give_price_option'] ? absint($request['give_price_option']) : null; |
|
59 | 59 | |
60 | 60 | } |
61 | 61 | |
@@ -70,36 +70,36 @@ discard block |
||
70 | 70 | |
71 | 71 | $cols = array(); |
72 | 72 | |
73 | - $columns = isset( $this->data['give_export_option'] ) ? $this->data['give_export_option'] : array(); |
|
73 | + $columns = isset($this->data['give_export_option']) ? $this->data['give_export_option'] : array(); |
|
74 | 74 | |
75 | - if ( empty( $columns ) ) { |
|
75 | + if (empty($columns)) { |
|
76 | 76 | return false; |
77 | 77 | } |
78 | - if ( ! empty( $columns['full_name'] ) ) { |
|
79 | - $cols['full_name'] = esc_html__( 'Full Name', 'give' ); |
|
78 | + if ( ! empty($columns['full_name'])) { |
|
79 | + $cols['full_name'] = esc_html__('Full Name', 'give'); |
|
80 | 80 | } |
81 | - if ( ! empty( $columns['email'] ) ) { |
|
82 | - $cols['email'] = esc_html__( 'Email Address', 'give' ); |
|
81 | + if ( ! empty($columns['email'])) { |
|
82 | + $cols['email'] = esc_html__('Email Address', 'give'); |
|
83 | 83 | } |
84 | - if ( ! empty( $columns['address'] ) ) { |
|
85 | - $cols['address_line1'] = esc_html__( 'Address', 'give' ); |
|
86 | - $cols['address_line2'] = esc_html__( 'Address (Line 2)', 'give' ); |
|
87 | - $cols['address_city'] = esc_html__( 'City', 'give' ); |
|
88 | - $cols['address_state'] = esc_html__( 'State', 'give' ); |
|
89 | - $cols['address_zip'] = esc_html__( 'Zip', 'give' ); |
|
90 | - $cols['address_country'] = esc_html__( 'Country', 'give' ); |
|
84 | + if ( ! empty($columns['address'])) { |
|
85 | + $cols['address_line1'] = esc_html__('Address', 'give'); |
|
86 | + $cols['address_line2'] = esc_html__('Address (Line 2)', 'give'); |
|
87 | + $cols['address_city'] = esc_html__('City', 'give'); |
|
88 | + $cols['address_state'] = esc_html__('State', 'give'); |
|
89 | + $cols['address_zip'] = esc_html__('Zip', 'give'); |
|
90 | + $cols['address_country'] = esc_html__('Country', 'give'); |
|
91 | 91 | } |
92 | - if ( ! empty( $columns['userid'] ) ) { |
|
93 | - $cols['userid'] = esc_html__( 'User ID', 'give' ); |
|
92 | + if ( ! empty($columns['userid'])) { |
|
93 | + $cols['userid'] = esc_html__('User ID', 'give'); |
|
94 | 94 | } |
95 | - if ( ! empty( $columns['date_first_donated'] ) ) { |
|
96 | - $cols['date_first_donated'] = esc_html__( 'First Donation Date', 'give' ); |
|
95 | + if ( ! empty($columns['date_first_donated'])) { |
|
96 | + $cols['date_first_donated'] = esc_html__('First Donation Date', 'give'); |
|
97 | 97 | } |
98 | - if ( ! empty( $columns['donations'] ) ) { |
|
99 | - $cols['donations'] = esc_html__( 'Number of Donations', 'give' ); |
|
98 | + if ( ! empty($columns['donations'])) { |
|
99 | + $cols['donations'] = esc_html__('Number of Donations', 'give'); |
|
100 | 100 | } |
101 | - if ( ! empty( $columns['donation_sum'] ) ) { |
|
102 | - $cols['donation_sum'] = esc_html__( 'Sum of Donations', 'give' ); |
|
101 | + if ( ! empty($columns['donation_sum'])) { |
|
102 | + $cols['donation_sum'] = esc_html__('Sum of Donations', 'give'); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | return $cols; |
@@ -119,20 +119,20 @@ discard block |
||
119 | 119 | |
120 | 120 | $i = 0; |
121 | 121 | |
122 | - if ( ! empty( $this->form ) ) { |
|
122 | + if ( ! empty($this->form)) { |
|
123 | 123 | |
124 | 124 | // Export donors of a specific product |
125 | 125 | global $give_logs; |
126 | 126 | |
127 | 127 | $args = array( |
128 | - 'post_parent' => absint( $this->form ), |
|
128 | + 'post_parent' => absint($this->form), |
|
129 | 129 | 'log_type' => 'sale', |
130 | 130 | 'posts_per_page' => 30, |
131 | 131 | 'paged' => $this->step |
132 | 132 | ); |
133 | 133 | |
134 | 134 | //Check for price option |
135 | - if ( null !== $this->price_id ) { |
|
135 | + if (null !== $this->price_id) { |
|
136 | 136 | $args['meta_query'] = array( |
137 | 137 | array( |
138 | 138 | 'key' => '_give_log_price_id', |
@@ -141,33 +141,33 @@ discard block |
||
141 | 141 | ); |
142 | 142 | } |
143 | 143 | |
144 | - $logs = $give_logs->get_connected_logs( $args ); |
|
144 | + $logs = $give_logs->get_connected_logs($args); |
|
145 | 145 | |
146 | - if ( $logs ) { |
|
147 | - foreach ( $logs as $log ) { |
|
148 | - $payment_id = get_post_meta( $log->ID, '_give_log_payment_id', true ); |
|
149 | - $payment = new Give_Payment( $payment_id ); |
|
150 | - $donor = Give()->customers->get_customer_by( 'id', $payment->customer_id ); |
|
151 | - $data[] = $this->set_donor_data( $i, $data, $donor ); |
|
152 | - $i ++; |
|
146 | + if ($logs) { |
|
147 | + foreach ($logs as $log) { |
|
148 | + $payment_id = get_post_meta($log->ID, '_give_log_payment_id', true); |
|
149 | + $payment = new Give_Payment($payment_id); |
|
150 | + $donor = Give()->customers->get_customer_by('id', $payment->customer_id); |
|
151 | + $data[] = $this->set_donor_data($i, $data, $donor); |
|
152 | + $i++; |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
156 | 156 | } else { |
157 | 157 | |
158 | 158 | // Export all customers |
159 | - $offset = 30 * ( $this->step - 1 ); |
|
160 | - $donors = Give()->customers->get_customers( array( 'number' => 30, 'offset' => $offset ) ); |
|
159 | + $offset = 30 * ($this->step - 1); |
|
160 | + $donors = Give()->customers->get_customers(array('number' => 30, 'offset' => $offset)); |
|
161 | 161 | |
162 | - foreach ( $donors as $donor ) { |
|
162 | + foreach ($donors as $donor) { |
|
163 | 163 | |
164 | - $data[] = $this->set_donor_data( $i, $data, $donor ); |
|
165 | - $i ++; |
|
164 | + $data[] = $this->set_donor_data($i, $data, $donor); |
|
165 | + $i++; |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 | |
169 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
170 | - $data = apply_filters( 'give_export_get_data_' . $this->export_type, $data ); |
|
169 | + $data = apply_filters('give_export_get_data', $data); |
|
170 | + $data = apply_filters('give_export_get_data_'.$this->export_type, $data); |
|
171 | 171 | |
172 | 172 | return $data; |
173 | 173 | } |
@@ -183,19 +183,19 @@ discard block |
||
183 | 183 | $percentage = 0; |
184 | 184 | |
185 | 185 | // We can't count the number when getting them for a specific form |
186 | - if ( empty( $this->form ) ) { |
|
186 | + if (empty($this->form)) { |
|
187 | 187 | |
188 | 188 | $total = Give()->customers->count(); |
189 | 189 | |
190 | - if ( $total > 0 ) { |
|
190 | + if ($total > 0) { |
|
191 | 191 | |
192 | - $percentage = ( ( 30 * $this->step ) / $total ) * 100; |
|
192 | + $percentage = ((30 * $this->step) / $total) * 100; |
|
193 | 193 | |
194 | 194 | } |
195 | 195 | |
196 | 196 | } |
197 | 197 | |
198 | - if ( $percentage > 100 ) { |
|
198 | + if ($percentage > 100) { |
|
199 | 199 | $percentage = 100; |
200 | 200 | } |
201 | 201 | |
@@ -207,46 +207,46 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @param $donor |
209 | 209 | */ |
210 | - private function set_donor_data( $i, $data, $donor ) { |
|
210 | + private function set_donor_data($i, $data, $donor) { |
|
211 | 211 | |
212 | 212 | $columns = $this->csv_cols(); |
213 | 213 | |
214 | 214 | //Set address variable |
215 | 215 | $address = ''; |
216 | - if ( isset( $donor->user_id ) && $donor->user_id > 0 ) { |
|
217 | - $address = give_get_donor_address( $donor->user_id ); |
|
216 | + if (isset($donor->user_id) && $donor->user_id > 0) { |
|
217 | + $address = give_get_donor_address($donor->user_id); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | //Set columns |
221 | - if ( ! empty( $columns['full_name'] ) ) { |
|
222 | - $data[ $i ]['full_name'] = $donor->name; |
|
221 | + if ( ! empty($columns['full_name'])) { |
|
222 | + $data[$i]['full_name'] = $donor->name; |
|
223 | 223 | } |
224 | - if ( ! empty( $columns['email'] ) ) { |
|
225 | - $data[ $i ]['email'] = $donor->email; |
|
224 | + if ( ! empty($columns['email'])) { |
|
225 | + $data[$i]['email'] = $donor->email; |
|
226 | 226 | } |
227 | - if ( ! empty( $columns['address_line1'] ) ) { |
|
227 | + if ( ! empty($columns['address_line1'])) { |
|
228 | 228 | |
229 | - $data[ $i ]['address_line1'] = isset( $address['line1'] ) ? $address['line1'] : ''; |
|
230 | - $data[ $i ]['address_line2'] = isset( $address['line2'] ) ? $address['line2'] : ''; |
|
231 | - $data[ $i ]['address_city'] = isset( $address['city'] ) ? $address['city'] : ''; |
|
232 | - $data[ $i ]['address_state'] = isset( $address['state'] ) ? $address['state'] : ''; |
|
233 | - $data[ $i ]['address_zip'] = isset( $address['zip'] ) ? $address['zip'] : ''; |
|
234 | - $data[ $i ]['address_country'] = isset( $address['country'] ) ? $address['country'] : ''; |
|
229 | + $data[$i]['address_line1'] = isset($address['line1']) ? $address['line1'] : ''; |
|
230 | + $data[$i]['address_line2'] = isset($address['line2']) ? $address['line2'] : ''; |
|
231 | + $data[$i]['address_city'] = isset($address['city']) ? $address['city'] : ''; |
|
232 | + $data[$i]['address_state'] = isset($address['state']) ? $address['state'] : ''; |
|
233 | + $data[$i]['address_zip'] = isset($address['zip']) ? $address['zip'] : ''; |
|
234 | + $data[$i]['address_country'] = isset($address['country']) ? $address['country'] : ''; |
|
235 | 235 | } |
236 | - if ( ! empty( $columns['userid'] ) ) { |
|
237 | - $data[ $i ]['userid'] = ! empty( $donor->user_id ) ? $donor->user_id : ''; |
|
236 | + if ( ! empty($columns['userid'])) { |
|
237 | + $data[$i]['userid'] = ! empty($donor->user_id) ? $donor->user_id : ''; |
|
238 | 238 | } |
239 | - if ( ! empty( $columns['date_first_donated'] ) ) { |
|
240 | - $data[ $i ]['date_first_donated'] = date_i18n( get_option( 'date_format' ), strtotime( $donor->date_created ) ); |
|
239 | + if ( ! empty($columns['date_first_donated'])) { |
|
240 | + $data[$i]['date_first_donated'] = date_i18n(get_option('date_format'), strtotime($donor->date_created)); |
|
241 | 241 | } |
242 | - if ( ! empty( $columns['donations'] ) ) { |
|
243 | - $data[ $i ]['donations'] = $donor->purchase_count; |
|
242 | + if ( ! empty($columns['donations'])) { |
|
243 | + $data[$i]['donations'] = $donor->purchase_count; |
|
244 | 244 | } |
245 | - if ( ! empty( $columns['donation_sum'] ) ) { |
|
246 | - $data[ $i ]['donation_sum'] = give_format_amount( $donor->purchase_value ); |
|
245 | + if ( ! empty($columns['donation_sum'])) { |
|
246 | + $data[$i]['donation_sum'] = give_format_amount($donor->purchase_value); |
|
247 | 247 | } |
248 | 248 | |
249 | - return $data[ $i ]; |
|
249 | + return $data[$i]; |
|
250 | 250 | |
251 | 251 | } |
252 | 252 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | |
24 | 24 | global $typenow; |
25 | 25 | |
26 | - if ( $typenow != 'give_forms' ) { |
|
26 | + if ($typenow != 'give_forms') { |
|
27 | 27 | return true; |
28 | 28 | } |
29 | 29 | |
30 | 30 | return false; |
31 | 31 | } |
32 | 32 | |
33 | -add_filter( 'give_shortcode_button_condition', 'give_shortcode_button_condition' ); |
|
33 | +add_filter('give_shortcode_button_condition', 'give_shortcode_button_condition'); |
|
34 | 34 | |
35 | 35 | |
36 | 36 | /** |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return int|false |
42 | 42 | */ |
43 | -function get_form_id_from_args( $args ) { |
|
43 | +function get_form_id_from_args($args) { |
|
44 | 44 | |
45 | - if ( isset( $args['form_id'] ) && $args['form_id'] != 0 ) { |
|
45 | + if (isset($args['form_id']) && $args['form_id'] != 0) { |
|
46 | 46 | |
47 | - return intval( $args['form_id'] ); |
|
47 | + return intval($args['form_id']); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | return false; |
@@ -59,23 +59,23 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return bool |
61 | 61 | */ |
62 | -function give_is_float_labels_enabled( $args ) { |
|
62 | +function give_is_float_labels_enabled($args) { |
|
63 | 63 | |
64 | 64 | $float_labels = ''; |
65 | 65 | |
66 | - if ( ! empty( $args['float_labels'] ) ) { |
|
66 | + if ( ! empty($args['float_labels'])) { |
|
67 | 67 | $float_labels = $args['float_labels']; |
68 | 68 | } |
69 | 69 | |
70 | - if ( empty( $float_labels ) ) { |
|
71 | - $float_labels = get_post_meta( $args['form_id'], '_give_form_floating_labels', true ); |
|
70 | + if (empty($float_labels)) { |
|
71 | + $float_labels = get_post_meta($args['form_id'], '_give_form_floating_labels', true); |
|
72 | 72 | } |
73 | 73 | |
74 | - if ( empty( $float_labels ) ) { |
|
75 | - $float_labels = give_get_option( 'enable_floatlabels' ) ? 'enabled' : 'disabled'; |
|
74 | + if (empty($float_labels)) { |
|
75 | + $float_labels = give_get_option('enable_floatlabels') ? 'enabled' : 'disabled'; |
|
76 | 76 | } |
77 | 77 | |
78 | - return ( $float_labels == 'enabled' ) ? true : false; |
|
78 | + return ($float_labels == 'enabled') ? true : false; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | $can_checkout = true; |
92 | 92 | |
93 | - return (bool) apply_filters( 'give_can_checkout', $can_checkout ); |
|
93 | + return (bool) apply_filters('give_can_checkout', $can_checkout); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | function give_get_success_page_uri() { |
104 | 104 | global $give_options; |
105 | 105 | |
106 | - $success_page = isset( $give_options['success_page'] ) ? get_permalink( absint( $give_options['success_page'] ) ) : get_bloginfo( 'url' ); |
|
106 | + $success_page = isset($give_options['success_page']) ? get_permalink(absint($give_options['success_page'])) : get_bloginfo('url'); |
|
107 | 107 | |
108 | - return apply_filters( 'give_get_success_page_uri', $success_page ); |
|
108 | + return apply_filters('give_get_success_page_uri', $success_page); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | */ |
117 | 117 | function give_is_success_page() { |
118 | 118 | global $give_options; |
119 | - $is_success_page = isset( $give_options['success_page'] ) ? is_page( $give_options['success_page'] ) : false; |
|
119 | + $is_success_page = isset($give_options['success_page']) ? is_page($give_options['success_page']) : false; |
|
120 | 120 | |
121 | - return apply_filters( 'give_is_success_page', $is_success_page ); |
|
121 | + return apply_filters('give_is_success_page', $is_success_page); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -132,17 +132,17 @@ discard block |
||
132 | 132 | * @since 1.0 |
133 | 133 | * @return void |
134 | 134 | */ |
135 | -function give_send_to_success_page( $query_string = null ) { |
|
135 | +function give_send_to_success_page($query_string = null) { |
|
136 | 136 | |
137 | 137 | $redirect = give_get_success_page_uri(); |
138 | 138 | |
139 | - if ( $query_string ) { |
|
139 | + if ($query_string) { |
|
140 | 140 | $redirect .= $query_string; |
141 | 141 | } |
142 | 142 | |
143 | - $gateway = isset( $_REQUEST['give-gateway'] ) ? $_REQUEST['give-gateway'] : ''; |
|
143 | + $gateway = isset($_REQUEST['give-gateway']) ? $_REQUEST['give-gateway'] : ''; |
|
144 | 144 | |
145 | - wp_redirect( apply_filters( 'give_success_page_redirect', $redirect, $gateway, $query_string ) ); |
|
145 | + wp_redirect(apply_filters('give_success_page_redirect', $redirect, $gateway, $query_string)); |
|
146 | 146 | give_die(); |
147 | 147 | } |
148 | 148 | |
@@ -159,25 +159,25 @@ discard block |
||
159 | 159 | * @since 1.0 |
160 | 160 | * @return Void |
161 | 161 | */ |
162 | -function give_send_back_to_checkout( $args = array() ) { |
|
162 | +function give_send_back_to_checkout($args = array()) { |
|
163 | 163 | |
164 | - $redirect = ( isset( $_POST['give-current-url'] ) ) ? $_POST['give-current-url'] : ''; |
|
165 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : 0; |
|
164 | + $redirect = (isset($_POST['give-current-url'])) ? $_POST['give-current-url'] : ''; |
|
165 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : 0; |
|
166 | 166 | |
167 | 167 | $defaults = array( |
168 | 168 | 'form-id' => (int) $form_id |
169 | 169 | ); |
170 | 170 | |
171 | 171 | // Check for backward compatibility |
172 | - if ( is_string( $args ) ) { |
|
173 | - $args = str_replace( '?', '', $args ); |
|
172 | + if (is_string($args)) { |
|
173 | + $args = str_replace('?', '', $args); |
|
174 | 174 | } |
175 | 175 | |
176 | - $args = wp_parse_args( $args, $defaults ); |
|
176 | + $args = wp_parse_args($args, $defaults); |
|
177 | 177 | |
178 | - $redirect = add_query_arg( $args, $redirect ) . '#give-form-' . $form_id . '-wrap'; |
|
178 | + $redirect = add_query_arg($args, $redirect).'#give-form-'.$form_id.'-wrap'; |
|
179 | 179 | |
180 | - wp_redirect( apply_filters( 'give_send_back_to_checkout', $redirect, $args ) ); |
|
180 | + wp_redirect(apply_filters('give_send_back_to_checkout', $redirect, $args)); |
|
181 | 181 | give_die(); |
182 | 182 | } |
183 | 183 | |
@@ -192,16 +192,16 @@ discard block |
||
192 | 192 | * @since 1.0 |
193 | 193 | * @return string |
194 | 194 | */ |
195 | -function give_get_success_page_url( $query_string = null ) { |
|
195 | +function give_get_success_page_url($query_string = null) { |
|
196 | 196 | |
197 | - $success_page = give_get_option( 'success_page', 0 ); |
|
198 | - $success_page = get_permalink( $success_page ); |
|
197 | + $success_page = give_get_option('success_page', 0); |
|
198 | + $success_page = get_permalink($success_page); |
|
199 | 199 | |
200 | - if ( $query_string ) { |
|
200 | + if ($query_string) { |
|
201 | 201 | $success_page .= $query_string; |
202 | 202 | } |
203 | 203 | |
204 | - return apply_filters( 'give_success_page_url', $success_page ); |
|
204 | + return apply_filters('give_success_page_url', $success_page); |
|
205 | 205 | |
206 | 206 | } |
207 | 207 | |
@@ -215,15 +215,15 @@ discard block |
||
215 | 215 | * |
216 | 216 | * @return mixed|void Full URL to the Transaction Failed page, if present, home page if it doesn't exist |
217 | 217 | */ |
218 | -function give_get_failed_transaction_uri( $extras = false ) { |
|
218 | +function give_get_failed_transaction_uri($extras = false) { |
|
219 | 219 | global $give_options; |
220 | 220 | |
221 | - $uri = ! empty( $give_options['failure_page'] ) ? trailingslashit( get_permalink( $give_options['failure_page'] ) ) : home_url(); |
|
222 | - if ( $extras ) { |
|
221 | + $uri = ! empty($give_options['failure_page']) ? trailingslashit(get_permalink($give_options['failure_page'])) : home_url(); |
|
222 | + if ($extras) { |
|
223 | 223 | $uri .= $extras; |
224 | 224 | } |
225 | 225 | |
226 | - return apply_filters( 'give_get_failed_transaction_uri', $uri ); |
|
226 | + return apply_filters('give_get_failed_transaction_uri', $uri); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -234,9 +234,9 @@ discard block |
||
234 | 234 | */ |
235 | 235 | function give_is_failed_transaction_page() { |
236 | 236 | global $give_options; |
237 | - $ret = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false; |
|
237 | + $ret = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false; |
|
238 | 238 | |
239 | - return apply_filters( 'give_is_failure_page', $ret ); |
|
239 | + return apply_filters('give_is_failure_page', $ret); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
@@ -248,18 +248,18 @@ discard block |
||
248 | 248 | */ |
249 | 249 | function give_listen_for_failed_payments() { |
250 | 250 | |
251 | - $failed_page = give_get_option( 'failure_page', 0 ); |
|
251 | + $failed_page = give_get_option('failure_page', 0); |
|
252 | 252 | |
253 | - if ( ! empty( $failed_page ) && is_page( $failed_page ) && ! empty( $_GET['payment-id'] ) ) { |
|
253 | + if ( ! empty($failed_page) && is_page($failed_page) && ! empty($_GET['payment-id'])) { |
|
254 | 254 | |
255 | - $payment_id = absint( $_GET['payment-id'] ); |
|
256 | - give_update_payment_status( $payment_id, 'failed' ); |
|
255 | + $payment_id = absint($_GET['payment-id']); |
|
256 | + give_update_payment_status($payment_id, 'failed'); |
|
257 | 257 | |
258 | 258 | } |
259 | 259 | |
260 | 260 | } |
261 | 261 | |
262 | -add_action( 'template_redirect', 'give_listen_for_failed_payments' ); |
|
262 | +add_action('template_redirect', 'give_listen_for_failed_payments'); |
|
263 | 263 | |
264 | 264 | |
265 | 265 | /** |
@@ -272,11 +272,11 @@ discard block |
||
272 | 272 | * @since 1.0 |
273 | 273 | * @return bool |
274 | 274 | */ |
275 | -function give_field_is_required( $field = '', $form_id ) { |
|
275 | +function give_field_is_required($field = '', $form_id) { |
|
276 | 276 | |
277 | - $required_fields = give_purchase_form_required_fields( $form_id ); |
|
277 | + $required_fields = give_purchase_form_required_fields($form_id); |
|
278 | 278 | |
279 | - return array_key_exists( $field, $required_fields ); |
|
279 | + return array_key_exists($field, $required_fields); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | /** |
@@ -294,14 +294,14 @@ discard block |
||
294 | 294 | * |
295 | 295 | * @return void |
296 | 296 | */ |
297 | -function give_record_sale_in_log( $give_form_id = 0, $payment_id, $price_id = false, $sale_date = null ) { |
|
297 | +function give_record_sale_in_log($give_form_id = 0, $payment_id, $price_id = false, $sale_date = null) { |
|
298 | 298 | global $give_logs; |
299 | 299 | |
300 | 300 | $log_data = array( |
301 | 301 | 'post_parent' => $give_form_id, |
302 | 302 | 'log_type' => 'sale', |
303 | - 'post_date' => isset( $sale_date ) ? $sale_date : null, |
|
304 | - 'post_date_gmt' => isset( $sale_date ) ? $sale_date : null |
|
303 | + 'post_date' => isset($sale_date) ? $sale_date : null, |
|
304 | + 'post_date_gmt' => isset($sale_date) ? $sale_date : null |
|
305 | 305 | ); |
306 | 306 | |
307 | 307 | $log_meta = array( |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | 'price_id' => (int) $price_id |
310 | 310 | ); |
311 | 311 | |
312 | - $give_logs->insert_log( $log_data, $log_meta ); |
|
312 | + $give_logs->insert_log($log_data, $log_meta); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | |
@@ -323,11 +323,11 @@ discard block |
||
323 | 323 | * |
324 | 324 | * @return bool|int |
325 | 325 | */ |
326 | -function give_increase_purchase_count( $form_id = 0, $quantity = 1 ) { |
|
326 | +function give_increase_purchase_count($form_id = 0, $quantity = 1) { |
|
327 | 327 | $quantity = (int) $quantity; |
328 | - $form = new Give_Donate_Form( $form_id ); |
|
328 | + $form = new Give_Donate_Form($form_id); |
|
329 | 329 | |
330 | - return $form->increase_sales( $quantity ); |
|
330 | + return $form->increase_sales($quantity); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
@@ -340,11 +340,11 @@ discard block |
||
340 | 340 | * |
341 | 341 | * @return bool|int |
342 | 342 | */ |
343 | -function give_decrease_purchase_count( $form_id = 0, $quantity = 1 ) { |
|
343 | +function give_decrease_purchase_count($form_id = 0, $quantity = 1) { |
|
344 | 344 | $quantity = (int) $quantity; |
345 | - $form = new Give_Donate_Form( $form_id ); |
|
345 | + $form = new Give_Donate_Form($form_id); |
|
346 | 346 | |
347 | - return $form->decrease_sales( $quantity ); |
|
347 | + return $form->decrease_sales($quantity); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -357,10 +357,10 @@ discard block |
||
357 | 357 | * |
358 | 358 | * @return bool|int |
359 | 359 | */ |
360 | -function give_increase_earnings( $give_form_id = 0, $amount ) { |
|
361 | - $form = new Give_Donate_Form( $give_form_id ); |
|
360 | +function give_increase_earnings($give_form_id = 0, $amount) { |
|
361 | + $form = new Give_Donate_Form($give_form_id); |
|
362 | 362 | |
363 | - return $form->increase_earnings( $amount ); |
|
363 | + return $form->increase_earnings($amount); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | /** |
@@ -373,10 +373,10 @@ discard block |
||
373 | 373 | * |
374 | 374 | * @return bool|int |
375 | 375 | */ |
376 | -function give_decrease_earnings( $form_id = 0, $amount ) { |
|
377 | - $form = new Give_Donate_Form( $form_id ); |
|
376 | +function give_decrease_earnings($form_id = 0, $amount) { |
|
377 | + $form = new Give_Donate_Form($form_id); |
|
378 | 378 | |
379 | - return $form->decrease_earnings( $amount ); |
|
379 | + return $form->decrease_earnings($amount); |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | |
@@ -389,8 +389,8 @@ discard block |
||
389 | 389 | * |
390 | 390 | * @return int $earnings Earnings for a certain form |
391 | 391 | */ |
392 | -function give_get_form_earnings_stats( $form_id = 0 ) { |
|
393 | - $give_form = new Give_Donate_Form( $form_id ); |
|
392 | +function give_get_form_earnings_stats($form_id = 0) { |
|
393 | + $give_form = new Give_Donate_Form($form_id); |
|
394 | 394 | |
395 | 395 | return $give_form->earnings; |
396 | 396 | } |
@@ -405,8 +405,8 @@ discard block |
||
405 | 405 | * |
406 | 406 | * @return int $sales Amount of sales for a certain form |
407 | 407 | */ |
408 | -function give_get_form_sales_stats( $give_form_id = 0 ) { |
|
409 | - $give_form = new Give_Donate_Form( $give_form_id ); |
|
408 | +function give_get_form_sales_stats($give_form_id = 0) { |
|
409 | + $give_form = new Give_Donate_Form($give_form_id); |
|
410 | 410 | |
411 | 411 | return $give_form->sales; |
412 | 412 | } |
@@ -421,16 +421,16 @@ discard block |
||
421 | 421 | * |
422 | 422 | * @return float $sales Average monthly sales |
423 | 423 | */ |
424 | -function give_get_average_monthly_form_sales( $form_id = 0 ) { |
|
425 | - $sales = give_get_form_sales_stats( $form_id ); |
|
426 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
424 | +function give_get_average_monthly_form_sales($form_id = 0) { |
|
425 | + $sales = give_get_form_sales_stats($form_id); |
|
426 | + $release_date = get_post_field('post_date', $form_id); |
|
427 | 427 | |
428 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
428 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
429 | 429 | |
430 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
430 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
431 | 431 | |
432 | - if ( $months > 0 ) { |
|
433 | - $sales = ( $sales / $months ); |
|
432 | + if ($months > 0) { |
|
433 | + $sales = ($sales / $months); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | return $sales; |
@@ -446,16 +446,16 @@ discard block |
||
446 | 446 | * |
447 | 447 | * @return float $earnings Average monthly earnings |
448 | 448 | */ |
449 | -function give_get_average_monthly_form_earnings( $form_id = 0 ) { |
|
450 | - $earnings = give_get_form_earnings_stats( $form_id ); |
|
451 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
449 | +function give_get_average_monthly_form_earnings($form_id = 0) { |
|
450 | + $earnings = give_get_form_earnings_stats($form_id); |
|
451 | + $release_date = get_post_field('post_date', $form_id); |
|
452 | 452 | |
453 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
453 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
454 | 454 | |
455 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
455 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
456 | 456 | |
457 | - if ( $months > 0 ) { |
|
458 | - $earnings = ( $earnings / $months ); |
|
457 | + if ($months > 0) { |
|
458 | + $earnings = ($earnings / $months); |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | return $earnings < 0 ? 0 : $earnings; |
@@ -475,25 +475,25 @@ discard block |
||
475 | 475 | * |
476 | 476 | * @return string $price_name Name of the price option |
477 | 477 | */ |
478 | -function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0 ) { |
|
478 | +function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0) { |
|
479 | 479 | |
480 | - $prices = give_get_variable_prices( $form_id ); |
|
480 | + $prices = give_get_variable_prices($form_id); |
|
481 | 481 | $price_name = ''; |
482 | 482 | |
483 | - foreach ( $prices as $price ) { |
|
483 | + foreach ($prices as $price) { |
|
484 | 484 | |
485 | - if ( intval( $price['_give_id']['level_id'] ) == intval( $price_id ) ) { |
|
485 | + if (intval($price['_give_id']['level_id']) == intval($price_id)) { |
|
486 | 486 | |
487 | - $price_text = isset( $price['_give_text'] ) ? $price['_give_text'] : ''; |
|
488 | - $price_fallback = give_currency_filter( give_format_amount( $price['_give_amount'] ) ); |
|
489 | - $price_name = ! empty( $price_text ) ? $price_text : $price_fallback; |
|
487 | + $price_text = isset($price['_give_text']) ? $price['_give_text'] : ''; |
|
488 | + $price_fallback = give_currency_filter(give_format_amount($price['_give_amount'])); |
|
489 | + $price_name = ! empty($price_text) ? $price_text : $price_fallback; |
|
490 | 490 | |
491 | 491 | } |
492 | 492 | |
493 | 493 | } |
494 | 494 | |
495 | 495 | |
496 | - return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id ); |
|
496 | + return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id); |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | |
@@ -506,14 +506,14 @@ discard block |
||
506 | 506 | * |
507 | 507 | * @return string $range A fully formatted price range |
508 | 508 | */ |
509 | -function give_price_range( $form_id = 0 ) { |
|
510 | - $low = give_get_lowest_price_option( $form_id ); |
|
511 | - $high = give_get_highest_price_option( $form_id ); |
|
512 | - $range = '<span class="give_price_range_low">' . give_currency_filter( give_format_amount( $low ) ) . '</span>'; |
|
509 | +function give_price_range($form_id = 0) { |
|
510 | + $low = give_get_lowest_price_option($form_id); |
|
511 | + $high = give_get_highest_price_option($form_id); |
|
512 | + $range = '<span class="give_price_range_low">'.give_currency_filter(give_format_amount($low)).'</span>'; |
|
513 | 513 | $range .= '<span class="give_price_range_sep"> – </span>'; |
514 | - $range .= '<span class="give_price_range_high">' . give_currency_filter( give_format_amount( $high ) ) . '</span>'; |
|
514 | + $range .= '<span class="give_price_range_high">'.give_currency_filter(give_format_amount($high)).'</span>'; |
|
515 | 515 | |
516 | - return apply_filters( 'give_price_range', $range, $form_id, $low, $high ); |
|
516 | + return apply_filters('give_price_range', $range, $form_id, $low, $high); |
|
517 | 517 | } |
518 | 518 | |
519 | 519 | |
@@ -528,36 +528,36 @@ discard block |
||
528 | 528 | * |
529 | 529 | * @return int ID of the lowest price |
530 | 530 | */ |
531 | -function give_get_lowest_price_id( $form_id = 0 ) { |
|
531 | +function give_get_lowest_price_id($form_id = 0) { |
|
532 | 532 | |
533 | - if ( empty( $form_id ) ) { |
|
533 | + if (empty($form_id)) { |
|
534 | 534 | $form_id = get_the_ID(); |
535 | 535 | } |
536 | 536 | |
537 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
538 | - return give_get_form_price( $form_id ); |
|
537 | + if ( ! give_has_variable_prices($form_id)) { |
|
538 | + return give_get_form_price($form_id); |
|
539 | 539 | } |
540 | 540 | |
541 | - $prices = give_get_variable_prices( $form_id ); |
|
541 | + $prices = give_get_variable_prices($form_id); |
|
542 | 542 | |
543 | 543 | $low = 0.00; |
544 | 544 | $min_id = 1; |
545 | 545 | |
546 | - if ( ! empty( $prices ) ) { |
|
546 | + if ( ! empty($prices)) { |
|
547 | 547 | |
548 | - foreach ( $prices as $key => $price ) { |
|
548 | + foreach ($prices as $key => $price) { |
|
549 | 549 | |
550 | - if ( empty( $price['_give_amount'] ) ) { |
|
550 | + if (empty($price['_give_amount'])) { |
|
551 | 551 | continue; |
552 | 552 | } |
553 | 553 | |
554 | - if ( ! isset( $min ) ) { |
|
554 | + if ( ! isset($min)) { |
|
555 | 555 | $min = $price['_give_amount']; |
556 | 556 | } else { |
557 | - $min = min( $min, $price['_give_amount'] ); |
|
557 | + $min = min($min, $price['_give_amount']); |
|
558 | 558 | } |
559 | 559 | |
560 | - if ( $price['_give_amount'] == $min ) { |
|
560 | + if ($price['_give_amount'] == $min) { |
|
561 | 561 | $min_id = $price['_give_id']['level_id']; |
562 | 562 | } |
563 | 563 | } |
@@ -575,43 +575,43 @@ discard block |
||
575 | 575 | * |
576 | 576 | * @return float Amount of the lowest price |
577 | 577 | */ |
578 | -function give_get_lowest_price_option( $form_id = 0 ) { |
|
579 | - if ( empty( $form_id ) ) { |
|
578 | +function give_get_lowest_price_option($form_id = 0) { |
|
579 | + if (empty($form_id)) { |
|
580 | 580 | $form_id = get_the_ID(); |
581 | 581 | } |
582 | 582 | |
583 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
584 | - return give_get_form_price( $form_id ); |
|
583 | + if ( ! give_has_variable_prices($form_id)) { |
|
584 | + return give_get_form_price($form_id); |
|
585 | 585 | } |
586 | 586 | |
587 | - $prices = give_get_variable_prices( $form_id ); |
|
587 | + $prices = give_get_variable_prices($form_id); |
|
588 | 588 | |
589 | 589 | $low = 0.00; |
590 | 590 | |
591 | - if ( ! empty( $prices ) ) { |
|
591 | + if ( ! empty($prices)) { |
|
592 | 592 | |
593 | - foreach ( $prices as $key => $price ) { |
|
593 | + foreach ($prices as $key => $price) { |
|
594 | 594 | |
595 | - if ( empty( $price['_give_amount'] ) ) { |
|
595 | + if (empty($price['_give_amount'])) { |
|
596 | 596 | continue; |
597 | 597 | } |
598 | 598 | |
599 | - if ( ! isset( $min ) ) { |
|
599 | + if ( ! isset($min)) { |
|
600 | 600 | $min = $price['_give_amount']; |
601 | 601 | } else { |
602 | - $min = min( $min, give_sanitize_amount( $price['_give_amount'] ) ); |
|
602 | + $min = min($min, give_sanitize_amount($price['_give_amount'])); |
|
603 | 603 | } |
604 | 604 | |
605 | - if ( $price['_give_amount'] == $min ) { |
|
605 | + if ($price['_give_amount'] == $min) { |
|
606 | 606 | $min_id = $key; |
607 | 607 | } |
608 | 608 | } |
609 | 609 | |
610 | - $low = $prices[ $min_id ]['_give_amount']; |
|
610 | + $low = $prices[$min_id]['_give_amount']; |
|
611 | 611 | |
612 | 612 | } |
613 | 613 | |
614 | - return give_sanitize_amount( $low ); |
|
614 | + return give_sanitize_amount($low); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | /** |
@@ -623,41 +623,41 @@ discard block |
||
623 | 623 | * |
624 | 624 | * @return float Amount of the highest price |
625 | 625 | */ |
626 | -function give_get_highest_price_option( $form_id = 0 ) { |
|
626 | +function give_get_highest_price_option($form_id = 0) { |
|
627 | 627 | |
628 | - if ( empty( $form_id ) ) { |
|
628 | + if (empty($form_id)) { |
|
629 | 629 | $form_id = get_the_ID(); |
630 | 630 | } |
631 | 631 | |
632 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
633 | - return give_get_form_price( $form_id ); |
|
632 | + if ( ! give_has_variable_prices($form_id)) { |
|
633 | + return give_get_form_price($form_id); |
|
634 | 634 | } |
635 | 635 | |
636 | - $prices = give_get_variable_prices( $form_id ); |
|
636 | + $prices = give_get_variable_prices($form_id); |
|
637 | 637 | |
638 | 638 | $high = 0.00; |
639 | 639 | |
640 | - if ( ! empty( $prices ) ) { |
|
640 | + if ( ! empty($prices)) { |
|
641 | 641 | |
642 | 642 | $max = 0; |
643 | 643 | |
644 | - foreach ( $prices as $key => $price ) { |
|
645 | - if ( empty( $price['_give_amount'] ) ) { |
|
644 | + foreach ($prices as $key => $price) { |
|
645 | + if (empty($price['_give_amount'])) { |
|
646 | 646 | continue; |
647 | 647 | } |
648 | - $give_amount = give_sanitize_amount( $price['_give_amount'] ); |
|
648 | + $give_amount = give_sanitize_amount($price['_give_amount']); |
|
649 | 649 | |
650 | - $max = max( $max, $give_amount ); |
|
650 | + $max = max($max, $give_amount); |
|
651 | 651 | |
652 | - if ( $give_amount == $max ) { |
|
652 | + if ($give_amount == $max) { |
|
653 | 653 | $max_id = $key; |
654 | 654 | } |
655 | 655 | } |
656 | 656 | |
657 | - $high = $prices[ $max_id ]['_give_amount']; |
|
657 | + $high = $prices[$max_id]['_give_amount']; |
|
658 | 658 | } |
659 | 659 | |
660 | - return give_sanitize_amount( $high ); |
|
660 | + return give_sanitize_amount($high); |
|
661 | 661 | } |
662 | 662 | |
663 | 663 | /** |
@@ -669,15 +669,15 @@ discard block |
||
669 | 669 | * |
670 | 670 | * @return mixed string|int Price of the form |
671 | 671 | */ |
672 | -function give_get_form_price( $form_id = 0 ) { |
|
672 | +function give_get_form_price($form_id = 0) { |
|
673 | 673 | |
674 | - if ( empty( $form_id ) ) { |
|
674 | + if (empty($form_id)) { |
|
675 | 675 | return false; |
676 | 676 | } |
677 | 677 | |
678 | - $form = new Give_Donate_Form( $form_id ); |
|
678 | + $form = new Give_Donate_Form($form_id); |
|
679 | 679 | |
680 | - return $form->__get( 'price' ); |
|
680 | + return $form->__get('price'); |
|
681 | 681 | } |
682 | 682 | |
683 | 683 | /** |
@@ -689,15 +689,15 @@ discard block |
||
689 | 689 | * |
690 | 690 | * @return mixed string|int Minimum price of the form |
691 | 691 | */ |
692 | -function give_get_form_minimum_price( $form_id = 0 ) { |
|
692 | +function give_get_form_minimum_price($form_id = 0) { |
|
693 | 693 | |
694 | - if ( empty( $form_id ) ) { |
|
694 | + if (empty($form_id)) { |
|
695 | 695 | return false; |
696 | 696 | } |
697 | 697 | |
698 | - $form = new Give_Donate_Form( $form_id ); |
|
698 | + $form = new Give_Donate_Form($form_id); |
|
699 | 699 | |
700 | - return $form->__get( 'minimum_price' ); |
|
700 | + return $form->__get('minimum_price'); |
|
701 | 701 | |
702 | 702 | } |
703 | 703 | |
@@ -712,52 +712,52 @@ discard block |
||
712 | 712 | * |
713 | 713 | * @return int $formatted_price |
714 | 714 | */ |
715 | -function give_price( $form_id = 0, $echo = true, $price_id = false ) { |
|
715 | +function give_price($form_id = 0, $echo = true, $price_id = false) { |
|
716 | 716 | |
717 | - if ( empty( $form_id ) ) { |
|
717 | + if (empty($form_id)) { |
|
718 | 718 | $form_id = get_the_ID(); |
719 | 719 | } |
720 | 720 | |
721 | - if ( give_has_variable_prices( $form_id ) ) { |
|
721 | + if (give_has_variable_prices($form_id)) { |
|
722 | 722 | |
723 | - $prices = give_get_variable_prices( $form_id ); |
|
723 | + $prices = give_get_variable_prices($form_id); |
|
724 | 724 | |
725 | - if ( false !== $price_id ) { |
|
725 | + if (false !== $price_id) { |
|
726 | 726 | |
727 | 727 | //loop through multi-prices to see which is default |
728 | - foreach ( $prices as $price ) { |
|
728 | + foreach ($prices as $price) { |
|
729 | 729 | //this is the default price |
730 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
730 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
731 | 731 | $price = (float) $price['_give_amount']; |
732 | 732 | }; |
733 | 733 | } |
734 | 734 | |
735 | 735 | } else { |
736 | 736 | |
737 | - $price = give_get_lowest_price_option( $form_id ); |
|
737 | + $price = give_get_lowest_price_option($form_id); |
|
738 | 738 | } |
739 | 739 | |
740 | - $price = give_sanitize_amount( $price ); |
|
740 | + $price = give_sanitize_amount($price); |
|
741 | 741 | |
742 | 742 | } else { |
743 | 743 | |
744 | - $price = give_get_form_price( $form_id ); |
|
744 | + $price = give_get_form_price($form_id); |
|
745 | 745 | |
746 | 746 | } |
747 | 747 | |
748 | - $price = apply_filters( 'give_form_price', give_sanitize_amount( $price ), $form_id ); |
|
749 | - $formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>'; |
|
750 | - $formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price ); |
|
748 | + $price = apply_filters('give_form_price', give_sanitize_amount($price), $form_id); |
|
749 | + $formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>'; |
|
750 | + $formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price); |
|
751 | 751 | |
752 | - if ( $echo ) { |
|
752 | + if ($echo) { |
|
753 | 753 | echo $formatted_price; |
754 | 754 | } else { |
755 | 755 | return $formatted_price; |
756 | 756 | } |
757 | 757 | } |
758 | 758 | |
759 | -add_filter( 'give_form_price', 'give_format_amount', 10 ); |
|
760 | -add_filter( 'give_form_price', 'give_currency_filter', 20 ); |
|
759 | +add_filter('give_form_price', 'give_format_amount', 10); |
|
760 | +add_filter('give_form_price', 'give_currency_filter', 20); |
|
761 | 761 | |
762 | 762 | |
763 | 763 | /** |
@@ -771,18 +771,18 @@ discard block |
||
771 | 771 | * |
772 | 772 | * @return float $amount Amount of the price option |
773 | 773 | */ |
774 | -function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) { |
|
775 | - $prices = give_get_variable_prices( $form_id ); |
|
774 | +function give_get_price_option_amount($form_id = 0, $price_id = 0) { |
|
775 | + $prices = give_get_variable_prices($form_id); |
|
776 | 776 | |
777 | 777 | $amount = 0.00; |
778 | 778 | |
779 | - foreach ( $prices as $price ) { |
|
780 | - if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) { |
|
781 | - $amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00; |
|
779 | + foreach ($prices as $price) { |
|
780 | + if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] == $price_id) { |
|
781 | + $amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00; |
|
782 | 782 | }; |
783 | 783 | } |
784 | 784 | |
785 | - return apply_filters( 'give_get_price_option_amount', give_sanitize_amount( $amount ), $form_id, $price_id ); |
|
785 | + return apply_filters('give_get_price_option_amount', give_sanitize_amount($amount), $form_id, $price_id); |
|
786 | 786 | } |
787 | 787 | |
788 | 788 | /** |
@@ -794,13 +794,13 @@ discard block |
||
794 | 794 | * |
795 | 795 | * @return mixed string|int Goal of the form |
796 | 796 | */ |
797 | -function give_get_form_goal( $form_id = 0 ) { |
|
797 | +function give_get_form_goal($form_id = 0) { |
|
798 | 798 | |
799 | - if ( empty( $form_id ) ) { |
|
799 | + if (empty($form_id)) { |
|
800 | 800 | return false; |
801 | 801 | } |
802 | 802 | |
803 | - $form = new Give_Donate_Form( $form_id ); |
|
803 | + $form = new Give_Donate_Form($form_id); |
|
804 | 804 | |
805 | 805 | return $form->goal; |
806 | 806 | |
@@ -816,27 +816,27 @@ discard block |
||
816 | 816 | * |
817 | 817 | * @return string $formatted_goal |
818 | 818 | */ |
819 | -function give_goal( $form_id = 0, $echo = true ) { |
|
819 | +function give_goal($form_id = 0, $echo = true) { |
|
820 | 820 | |
821 | - if ( empty( $form_id ) ) { |
|
821 | + if (empty($form_id)) { |
|
822 | 822 | $form_id = get_the_ID(); |
823 | 823 | } |
824 | 824 | |
825 | - $goal = give_get_form_goal( $form_id ); |
|
825 | + $goal = give_get_form_goal($form_id); |
|
826 | 826 | |
827 | - $goal = apply_filters( 'give_form_goal', give_sanitize_amount( $goal ), $form_id ); |
|
828 | - $formatted_goal = '<span class="give_price" id="give_price_' . $form_id . '">' . $goal . '</span>'; |
|
829 | - $formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal ); |
|
827 | + $goal = apply_filters('give_form_goal', give_sanitize_amount($goal), $form_id); |
|
828 | + $formatted_goal = '<span class="give_price" id="give_price_'.$form_id.'">'.$goal.'</span>'; |
|
829 | + $formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal); |
|
830 | 830 | |
831 | - if ( $echo ) { |
|
831 | + if ($echo) { |
|
832 | 832 | echo $formatted_goal; |
833 | 833 | } else { |
834 | 834 | return $formatted_goal; |
835 | 835 | } |
836 | 836 | } |
837 | 837 | |
838 | -add_filter( 'give_form_goal', 'give_format_amount', 10 ); |
|
839 | -add_filter( 'give_form_goal', 'give_currency_filter', 20 ); |
|
838 | +add_filter('give_form_goal', 'give_format_amount', 10); |
|
839 | +add_filter('give_form_goal', 'give_currency_filter', 20); |
|
840 | 840 | |
841 | 841 | |
842 | 842 | /** |
@@ -846,13 +846,13 @@ discard block |
||
846 | 846 | * @global $give_options |
847 | 847 | * @return bool $ret Whether or not the logged_in_only setting is set |
848 | 848 | */ |
849 | -function give_logged_in_only( $form_id ) { |
|
849 | +function give_logged_in_only($form_id) { |
|
850 | 850 | |
851 | - $form_option = get_post_meta( $form_id, '_give_logged_in_only', true ); |
|
851 | + $form_option = get_post_meta($form_id, '_give_logged_in_only', true); |
|
852 | 852 | |
853 | - $ret = ! empty( $form_option ) ? $form_option : false; |
|
853 | + $ret = ! empty($form_option) ? $form_option : false; |
|
854 | 854 | |
855 | - return (bool) apply_filters( 'give_logged_in_only', $ret, $form_id ); |
|
855 | + return (bool) apply_filters('give_logged_in_only', $ret, $form_id); |
|
856 | 856 | |
857 | 857 | } |
858 | 858 | |
@@ -864,10 +864,10 @@ discard block |
||
864 | 864 | * |
865 | 865 | * @param $form_id |
866 | 866 | */ |
867 | -function give_show_login_register_option( $form_id ) { |
|
867 | +function give_show_login_register_option($form_id) { |
|
868 | 868 | |
869 | - $show_register_form = get_post_meta( $form_id, '_give_show_register_form', true ); |
|
869 | + $show_register_form = get_post_meta($form_id, '_give_show_register_form', true); |
|
870 | 870 | |
871 | - return apply_filters( 'give_show_register_form', $show_register_form, $form_id ); |
|
871 | + return apply_filters('give_show_register_form', $show_register_form, $form_id); |
|
872 | 872 | |
873 | 873 | } |
874 | 874 | \ No newline at end of file |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | * Used to redirect a user back to the purchase |
157 | 157 | * page if there are errors present. |
158 | 158 | * |
159 | - * @param array $args |
|
159 | + * @param string $args |
|
160 | 160 | * |
161 | 161 | * @access public |
162 | 162 | * @since 1.0 |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | * |
691 | 691 | * @param int $form_id ID number of the form to retrieve the minimum price for |
692 | 692 | * |
693 | - * @return mixed string|int Minimum price of the form |
|
693 | + * @return string string|int Minimum price of the form |
|
694 | 694 | */ |
695 | 695 | function give_get_form_minimum_price( $form_id = 0 ) { |
696 | 696 |
@@ -781,7 +781,7 @@ |
||
781 | 781 | foreach ( $prices as $price ) { |
782 | 782 | if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) { |
783 | 783 | $amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00; |
784 | - break; |
|
784 | + break; |
|
785 | 785 | }; |
786 | 786 | } |
787 | 787 |
@@ -65,7 +65,7 @@ |
||
65 | 65 | * |
66 | 66 | * @since 1.0 |
67 | 67 | * @uses Give_Session::get() |
68 | - * @return mixed array if errors are present, false if none found |
|
68 | + * @return string array if errors are present, false if none found |
|
69 | 69 | */ |
70 | 70 | function give_get_errors() { |
71 | 71 | return Give()->session->get( 'give_errors' ); |
@@ -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 | |
@@ -29,33 +29,33 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @return void |
31 | 31 | */ |
32 | -function give_print_errors( $form_id ) { |
|
32 | +function give_print_errors($form_id) { |
|
33 | 33 | |
34 | 34 | $errors = give_get_errors(); |
35 | 35 | |
36 | - $request_form_id = isset( $_REQUEST['form-id'] ) ? intval( $_REQUEST['form-id'] ) : 0; |
|
36 | + $request_form_id = isset($_REQUEST['form-id']) ? intval($_REQUEST['form-id']) : 0; |
|
37 | 37 | |
38 | 38 | //Sanity checks first: Ensure that gateway returned errors display on the appropriate form |
39 | - if ( ! isset( $_POST['give_ajax'] ) && $request_form_id !== $form_id ) { |
|
39 | + if ( ! isset($_POST['give_ajax']) && $request_form_id !== $form_id) { |
|
40 | 40 | return; |
41 | 41 | } |
42 | 42 | |
43 | - if ( $errors ) { |
|
44 | - $classes = apply_filters( 'give_error_class', array( |
|
43 | + if ($errors) { |
|
44 | + $classes = apply_filters('give_error_class', array( |
|
45 | 45 | 'give_errors' |
46 | - ) ); |
|
47 | - echo '<div class="' . implode( ' ', $classes ) . '">'; |
|
46 | + )); |
|
47 | + echo '<div class="'.implode(' ', $classes).'">'; |
|
48 | 48 | // Loop error codes and display errors |
49 | - foreach ( $errors as $error_id => $error ) { |
|
50 | - echo '<div class="give_error" id="give_error_' . $error_id . '"><p><strong>' . esc_html__( 'Error', 'give' ) . '</strong>: ' . $error . '</p></div>'; |
|
49 | + foreach ($errors as $error_id => $error) { |
|
50 | + echo '<div class="give_error" id="give_error_'.$error_id.'"><p><strong>'.esc_html__('Error', 'give').'</strong>: '.$error.'</p></div>'; |
|
51 | 51 | } |
52 | 52 | echo '</div>'; |
53 | 53 | give_clear_errors(); |
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | -add_action( 'give_purchase_form_before_personal_info', 'give_print_errors' ); |
|
58 | -add_action( 'give_ajax_checkout_errors', 'give_print_errors' ); |
|
57 | +add_action('give_purchase_form_before_personal_info', 'give_print_errors'); |
|
58 | +add_action('give_ajax_checkout_errors', 'give_print_errors'); |
|
59 | 59 | |
60 | 60 | /** |
61 | 61 | * Get Errors |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @return mixed array if errors are present, false if none found |
69 | 69 | */ |
70 | 70 | function give_get_errors() { |
71 | - return Give()->session->get( 'give_errors' ); |
|
71 | + return Give()->session->get('give_errors'); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -84,13 +84,13 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return void |
86 | 86 | */ |
87 | -function give_set_error( $error_id, $error_message ) { |
|
87 | +function give_set_error($error_id, $error_message) { |
|
88 | 88 | $errors = give_get_errors(); |
89 | - if ( ! $errors ) { |
|
89 | + if ( ! $errors) { |
|
90 | 90 | $errors = array(); |
91 | 91 | } |
92 | - $errors[ $error_id ] = $error_message; |
|
93 | - Give()->session->set( 'give_errors', $errors ); |
|
92 | + $errors[$error_id] = $error_message; |
|
93 | + Give()->session->set('give_errors', $errors); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @return void |
102 | 102 | */ |
103 | 103 | function give_clear_errors() { |
104 | - Give()->session->set( 'give_errors', null ); |
|
104 | + Give()->session->set('give_errors', null); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @return string |
116 | 116 | */ |
117 | -function give_unset_error( $error_id ) { |
|
117 | +function give_unset_error($error_id) { |
|
118 | 118 | $errors = give_get_errors(); |
119 | - if ( $errors ) { |
|
120 | - unset( $errors[ $error_id ] ); |
|
121 | - Give()->session->set( 'give_errors', $errors ); |
|
119 | + if ($errors) { |
|
120 | + unset($errors[$error_id]); |
|
121 | + Give()->session->set('give_errors', $errors); |
|
122 | 122 | } |
123 | 123 | } |
124 | 124 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @return void |
130 | 130 | */ |
131 | 131 | function _give_die_handler() { |
132 | - if ( defined( 'GIVE_UNIT_TESTS' ) ) { |
|
132 | + if (defined('GIVE_UNIT_TESTS')) { |
|
133 | 133 | return '_give_die_handler'; |
134 | 134 | } else { |
135 | 135 | die(); |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | * @since 1.0 |
145 | 145 | * @return void |
146 | 146 | */ |
147 | -function give_die( $message = '', $title = '', $status = 400 ) { |
|
148 | - add_filter( 'wp_die_ajax_handler', '_give_die_handler', 10, 3 ); |
|
149 | - add_filter( 'wp_die_handler', '_give_die_handler', 10, 3 ); |
|
150 | - wp_die( $message, $title, array( 'response' => $status ) ); |
|
147 | +function give_die($message = '', $title = '', $status = 400) { |
|
148 | + add_filter('wp_die_ajax_handler', '_give_die_handler', 10, 3); |
|
149 | + add_filter('wp_die_handler', '_give_die_handler', 10, 3); |
|
150 | + wp_die($message, $title, array('response' => $status)); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @return string $error |
164 | 164 | */ |
165 | -function give_output_error( $message, $echo = true, $error_id = 'warning' ) { |
|
166 | - $error = '<div class="give_errors" id="give_error_' . $error_id . '"><p class="give_error give_' . $error_id . '">' . $message . '</p></div>'; |
|
165 | +function give_output_error($message, $echo = true, $error_id = 'warning') { |
|
166 | + $error = '<div class="give_errors" id="give_error_'.$error_id.'"><p class="give_error give_'.$error_id.'">'.$message.'</p></div>'; |
|
167 | 167 | |
168 | - if ( $echo ) { |
|
168 | + if ($echo) { |
|
169 | 169 | echo $error; |
170 | 170 | } else { |
171 | 171 | return $error; |
@@ -33,20 +33,20 @@ discard block |
||
33 | 33 | $login_redirect = add_query_arg('give-login-success', 'true', give_get_current_page_url()); |
34 | 34 | } |
35 | 35 | |
36 | - if ( empty( $logout_redirect ) ) { |
|
37 | - $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() ); |
|
38 | - } |
|
36 | + if ( empty( $logout_redirect ) ) { |
|
37 | + $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() ); |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | - // Add user_logout action to logout url. |
|
42 | - $logout_redirect = add_query_arg( |
|
43 | - array( |
|
44 | - 'give_action' => 'user_logout', |
|
45 | - 'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ), |
|
46 | - 'give_logout_redirect' => urlencode( $logout_redirect ) |
|
47 | - ), |
|
48 | - home_url('/') |
|
49 | - ); |
|
41 | + // Add user_logout action to logout url. |
|
42 | + $logout_redirect = add_query_arg( |
|
43 | + array( |
|
44 | + 'give_action' => 'user_logout', |
|
45 | + 'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ), |
|
46 | + 'give_logout_redirect' => urlencode( $logout_redirect ) |
|
47 | + ), |
|
48 | + home_url('/') |
|
49 | + ); |
|
50 | 50 | |
51 | 51 | $give_login_redirect = $login_redirect; |
52 | 52 | $give_logout_redirect = $logout_redirect; |
@@ -136,23 +136,23 @@ discard block |
||
136 | 136 | * @return void |
137 | 137 | */ |
138 | 138 | function give_process_user_logout( $data ) { |
139 | - if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) { |
|
139 | + if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) { |
|
140 | 140 | |
141 | - // Prevent occurring of any custom action on wp_logout. |
|
142 | - remove_all_actions( 'wp_logout' ); |
|
141 | + // Prevent occurring of any custom action on wp_logout. |
|
142 | + remove_all_actions( 'wp_logout' ); |
|
143 | 143 | |
144 | - // Before logout give action. |
|
145 | - do_action( 'give_before_user_logout' ); |
|
144 | + // Before logout give action. |
|
145 | + do_action( 'give_before_user_logout' ); |
|
146 | 146 | |
147 | - // Logout user. |
|
148 | - wp_logout(); |
|
147 | + // Logout user. |
|
148 | + wp_logout(); |
|
149 | 149 | |
150 | - // After logout give action. |
|
151 | - do_action( 'give_after_user_logout' ); |
|
150 | + // After logout give action. |
|
151 | + do_action( 'give_after_user_logout' ); |
|
152 | 152 | |
153 | - wp_redirect( $data['give_logout_redirect'] ); |
|
154 | - give_die(); |
|
155 | - } |
|
153 | + wp_redirect( $data['give_logout_redirect'] ); |
|
154 | + give_die(); |
|
155 | + } |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | add_action( 'give_user_logout', 'give_process_user_logout' ); |
@@ -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 | |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return string Login form |
28 | 28 | */ |
29 | -function give_login_form( $login_redirect = '', $logout_redirect = '' ) { |
|
30 | - global $give_login_redirect, $give_logout_redirect;; |
|
29 | +function give_login_form($login_redirect = '', $logout_redirect = '') { |
|
30 | + global $give_login_redirect, $give_logout_redirect; ; |
|
31 | 31 | |
32 | - if ( empty( $login_redirect ) ) { |
|
32 | + if (empty($login_redirect)) { |
|
33 | 33 | $login_redirect = add_query_arg('give-login-success', 'true', give_get_current_page_url()); |
34 | 34 | } |
35 | 35 | |
36 | - if ( empty( $logout_redirect ) ) { |
|
37 | - $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() ); |
|
36 | + if (empty($logout_redirect)) { |
|
37 | + $logout_redirect = add_query_arg('give-logout-success', 'true', give_get_current_page_url()); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | $logout_redirect = add_query_arg( |
43 | 43 | array( |
44 | 44 | 'give_action' => 'user_logout', |
45 | - 'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ), |
|
46 | - 'give_logout_redirect' => urlencode( $logout_redirect ) |
|
45 | + 'give_logout_nonce' => wp_create_nonce('give-logout-nonce'), |
|
46 | + 'give_logout_redirect' => urlencode($logout_redirect) |
|
47 | 47 | ), |
48 | 48 | home_url('/') |
49 | 49 | ); |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | |
54 | 54 | ob_start(); |
55 | 55 | |
56 | - give_get_template_part( 'shortcode', 'login' ); |
|
56 | + give_get_template_part('shortcode', 'login'); |
|
57 | 57 | |
58 | - return apply_filters( 'give_login_form', ob_get_clean() ); |
|
58 | + return apply_filters('give_login_form', ob_get_clean()); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @return string Register form |
71 | 71 | */ |
72 | -function give_register_form( $redirect = '' ) { |
|
72 | +function give_register_form($redirect = '') { |
|
73 | 73 | global $give_options, $give_register_redirect; |
74 | 74 | |
75 | - if ( empty( $redirect ) ) { |
|
75 | + if (empty($redirect)) { |
|
76 | 76 | $redirect = give_get_current_page_url(); |
77 | 77 | } |
78 | 78 | |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | |
81 | 81 | ob_start(); |
82 | 82 | |
83 | - if ( ! is_user_logged_in() ) { |
|
84 | - give_get_template_part( 'shortcode', 'register' ); |
|
83 | + if ( ! is_user_logged_in()) { |
|
84 | + give_get_template_part('shortcode', 'register'); |
|
85 | 85 | } |
86 | 86 | |
87 | - return apply_filters( 'give_register_form', ob_get_clean() ); |
|
87 | + return apply_filters('give_register_form', ob_get_clean()); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -96,34 +96,34 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @return void |
98 | 98 | */ |
99 | -function give_process_login_form( $data ) { |
|
100 | - if ( wp_verify_nonce( $data['give_login_nonce'], 'give-login-nonce' ) ) { |
|
101 | - $user_data = get_user_by( 'login', $data['give_user_login'] ); |
|
102 | - if ( ! $user_data ) { |
|
103 | - $user_data = get_user_by( 'email', $data['give_user_login'] ); |
|
99 | +function give_process_login_form($data) { |
|
100 | + if (wp_verify_nonce($data['give_login_nonce'], 'give-login-nonce')) { |
|
101 | + $user_data = get_user_by('login', $data['give_user_login']); |
|
102 | + if ( ! $user_data) { |
|
103 | + $user_data = get_user_by('email', $data['give_user_login']); |
|
104 | 104 | } |
105 | - if ( $user_data ) { |
|
105 | + if ($user_data) { |
|
106 | 106 | $user_ID = $user_data->ID; |
107 | 107 | $user_email = $user_data->user_email; |
108 | - if ( wp_check_password( $data['give_user_pass'], $user_data->user_pass, $user_data->ID ) ) { |
|
109 | - give_log_user_in( $user_data->ID, $data['give_user_login'], $data['give_user_pass'] ); |
|
108 | + if (wp_check_password($data['give_user_pass'], $user_data->user_pass, $user_data->ID)) { |
|
109 | + give_log_user_in($user_data->ID, $data['give_user_login'], $data['give_user_pass']); |
|
110 | 110 | } else { |
111 | - give_set_error( 'password_incorrect', esc_html__( 'The password you entered is incorrect.', 'give' ) ); |
|
111 | + give_set_error('password_incorrect', esc_html__('The password you entered is incorrect.', 'give')); |
|
112 | 112 | } |
113 | 113 | } else { |
114 | - give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) ); |
|
114 | + give_set_error('username_incorrect', esc_html__('The username you entered does not exist.', 'give')); |
|
115 | 115 | } |
116 | 116 | // Check for errors and redirect if none present |
117 | 117 | $errors = give_get_errors(); |
118 | - if ( ! $errors ) { |
|
119 | - $redirect = apply_filters( 'give_login_redirect', $data['give_login_redirect'], $user_ID ); |
|
120 | - wp_redirect( $redirect ); |
|
118 | + if ( ! $errors) { |
|
119 | + $redirect = apply_filters('give_login_redirect', $data['give_login_redirect'], $user_ID); |
|
120 | + wp_redirect($redirect); |
|
121 | 121 | give_die(); |
122 | 122 | } |
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | -add_action( 'give_user_login', 'give_process_login_form' ); |
|
126 | +add_action('give_user_login', 'give_process_login_form'); |
|
127 | 127 | |
128 | 128 | |
129 | 129 | /** |
@@ -135,27 +135,27 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @return void |
137 | 137 | */ |
138 | -function give_process_user_logout( $data ) { |
|
139 | - if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) { |
|
138 | +function give_process_user_logout($data) { |
|
139 | + if (wp_verify_nonce($data['give_logout_nonce'], 'give-logout-nonce') && is_user_logged_in()) { |
|
140 | 140 | |
141 | 141 | // Prevent occurring of any custom action on wp_logout. |
142 | - remove_all_actions( 'wp_logout' ); |
|
142 | + remove_all_actions('wp_logout'); |
|
143 | 143 | |
144 | 144 | // Before logout give action. |
145 | - do_action( 'give_before_user_logout' ); |
|
145 | + do_action('give_before_user_logout'); |
|
146 | 146 | |
147 | 147 | // Logout user. |
148 | 148 | wp_logout(); |
149 | 149 | |
150 | 150 | // After logout give action. |
151 | - do_action( 'give_after_user_logout' ); |
|
151 | + do_action('give_after_user_logout'); |
|
152 | 152 | |
153 | - wp_redirect( $data['give_logout_redirect'] ); |
|
153 | + wp_redirect($data['give_logout_redirect']); |
|
154 | 154 | give_die(); |
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
158 | -add_action( 'give_user_logout', 'give_process_user_logout' ); |
|
158 | +add_action('give_user_logout', 'give_process_user_logout'); |
|
159 | 159 | |
160 | 160 | /** |
161 | 161 | * Log User In |
@@ -168,15 +168,15 @@ discard block |
||
168 | 168 | * |
169 | 169 | * @return void |
170 | 170 | */ |
171 | -function give_log_user_in( $user_id, $user_login, $user_pass ) { |
|
172 | - if ( $user_id < 1 ) { |
|
171 | +function give_log_user_in($user_id, $user_login, $user_pass) { |
|
172 | + if ($user_id < 1) { |
|
173 | 173 | return; |
174 | 174 | } |
175 | 175 | |
176 | - wp_set_auth_cookie( $user_id ); |
|
177 | - wp_set_current_user( $user_id, $user_login ); |
|
178 | - do_action( 'wp_login', $user_login, get_userdata( $user_id ) ); |
|
179 | - do_action( 'give_log_user_in', $user_id, $user_login, $user_pass ); |
|
176 | + wp_set_auth_cookie($user_id); |
|
177 | + wp_set_current_user($user_id, $user_login); |
|
178 | + do_action('wp_login', $user_login, get_userdata($user_id)); |
|
179 | + do_action('give_log_user_in', $user_id, $user_login, $user_pass); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | |
@@ -189,70 +189,70 @@ discard block |
||
189 | 189 | * |
190 | 190 | * @return void |
191 | 191 | */ |
192 | -function give_process_register_form( $data ) { |
|
192 | +function give_process_register_form($data) { |
|
193 | 193 | |
194 | - if ( is_user_logged_in() ) { |
|
194 | + if (is_user_logged_in()) { |
|
195 | 195 | return; |
196 | 196 | } |
197 | 197 | |
198 | - if ( empty( $_POST['give_register_submit'] ) ) { |
|
198 | + if (empty($_POST['give_register_submit'])) { |
|
199 | 199 | return; |
200 | 200 | } |
201 | 201 | |
202 | - do_action( 'give_pre_process_register_form' ); |
|
202 | + do_action('give_pre_process_register_form'); |
|
203 | 203 | |
204 | - if ( empty( $data['give_user_login'] ) ) { |
|
205 | - give_set_error( 'empty_username', esc_html__( 'Invalid username.', 'give' ) ); |
|
204 | + if (empty($data['give_user_login'])) { |
|
205 | + give_set_error('empty_username', esc_html__('Invalid username.', 'give')); |
|
206 | 206 | } |
207 | 207 | |
208 | - if ( username_exists( $data['give_user_login'] ) ) { |
|
209 | - give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) ); |
|
208 | + if (username_exists($data['give_user_login'])) { |
|
209 | + give_set_error('username_unavailable', esc_html__('Username already taken.', 'give')); |
|
210 | 210 | } |
211 | 211 | |
212 | - if ( ! validate_username( $data['give_user_login'] ) ) { |
|
213 | - give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) ); |
|
212 | + if ( ! validate_username($data['give_user_login'])) { |
|
213 | + give_set_error('username_invalid', esc_html__('Invalid username.', 'give')); |
|
214 | 214 | } |
215 | 215 | |
216 | - if ( email_exists( $data['give_user_email'] ) ) { |
|
217 | - give_set_error( 'email_unavailable', esc_html__( 'Email address already taken.', 'give' ) ); |
|
216 | + if (email_exists($data['give_user_email'])) { |
|
217 | + give_set_error('email_unavailable', esc_html__('Email address already taken.', 'give')); |
|
218 | 218 | } |
219 | 219 | |
220 | - if ( empty( $data['give_user_email'] ) || ! is_email( $data['give_user_email'] ) ) { |
|
221 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
220 | + if (empty($data['give_user_email']) || ! is_email($data['give_user_email'])) { |
|
221 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
222 | 222 | } |
223 | 223 | |
224 | - if ( ! empty( $data['give_payment_email'] ) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email( $data['give_payment_email'] ) ) { |
|
225 | - give_set_error( 'payment_email_invalid', esc_html__( 'Invalid payment email.', 'give' ) ); |
|
224 | + if ( ! empty($data['give_payment_email']) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email($data['give_payment_email'])) { |
|
225 | + give_set_error('payment_email_invalid', esc_html__('Invalid payment email.', 'give')); |
|
226 | 226 | } |
227 | 227 | |
228 | - if ( empty( $_POST['give_user_pass'] ) ) { |
|
229 | - give_set_error( 'empty_password', esc_html__( 'Please enter a password.', 'give' ) ); |
|
228 | + if (empty($_POST['give_user_pass'])) { |
|
229 | + give_set_error('empty_password', esc_html__('Please enter a password.', 'give')); |
|
230 | 230 | } |
231 | 231 | |
232 | - if ( ( ! empty( $_POST['give_user_pass'] ) && empty( $_POST['give_user_pass2'] ) ) || ( $_POST['give_user_pass'] !== $_POST['give_user_pass2'] ) ) { |
|
233 | - give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) ); |
|
232 | + if (( ! empty($_POST['give_user_pass']) && empty($_POST['give_user_pass2'])) || ($_POST['give_user_pass'] !== $_POST['give_user_pass2'])) { |
|
233 | + give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give')); |
|
234 | 234 | } |
235 | 235 | |
236 | - do_action( 'give_process_register_form' ); |
|
236 | + do_action('give_process_register_form'); |
|
237 | 237 | |
238 | 238 | // Check for errors and redirect if none present |
239 | 239 | $errors = give_get_errors(); |
240 | 240 | |
241 | - if ( empty( $errors ) ) { |
|
241 | + if (empty($errors)) { |
|
242 | 242 | |
243 | - $redirect = apply_filters( 'give_register_redirect', $data['give_redirect'] ); |
|
243 | + $redirect = apply_filters('give_register_redirect', $data['give_redirect']); |
|
244 | 244 | |
245 | - give_register_and_login_new_user( array( |
|
245 | + give_register_and_login_new_user(array( |
|
246 | 246 | 'user_login' => $data['give_user_login'], |
247 | 247 | 'user_pass' => $data['give_user_pass'], |
248 | 248 | 'user_email' => $data['give_user_email'], |
249 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
250 | - 'role' => get_option( 'default_role' ) |
|
251 | - ) ); |
|
249 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
250 | + 'role' => get_option('default_role') |
|
251 | + )); |
|
252 | 252 | |
253 | - wp_redirect( $redirect ); |
|
253 | + wp_redirect($redirect); |
|
254 | 254 | give_die(); |
255 | 255 | } |
256 | 256 | } |
257 | 257 | |
258 | -add_action( 'give_user_register', 'give_process_register_form' ); |
|
259 | 258 | \ No newline at end of file |
259 | +add_action('give_user_register', 'give_process_register_form'); |
|
260 | 260 | \ No newline at end of file |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | //validate display_style and float_labels value |
93 | 93 | if ( ( $key == 'display_style' && ! in_array( $value, array( 'onpage', 'reveal', 'modal' ) ) ) |
94 | - || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) ) |
|
94 | + || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) ) |
|
95 | 95 | ) { |
96 | 96 | |
97 | 97 | $atts[ $key ] = ''; |
@@ -169,15 +169,15 @@ discard block |
||
169 | 169 | */ |
170 | 170 | function give_login_form_shortcode( $atts, $content = null ) { |
171 | 171 | $atts = shortcode_atts( array( |
172 | - // Add backward compatibility for redirect attribute. |
|
173 | - 'redirect' => '', |
|
172 | + // Add backward compatibility for redirect attribute. |
|
173 | + 'redirect' => '', |
|
174 | 174 | |
175 | 175 | 'login-redirect' => '', |
176 | 176 | 'logout-redirect' => '', |
177 | 177 | ), $atts, 'give_login' ); |
178 | 178 | |
179 | - // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute. |
|
180 | - $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect' ] ) ? $atts['redirect'] : '' ); |
|
179 | + // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute. |
|
180 | + $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect' ] ) ? $atts['redirect'] : '' ); |
|
181 | 181 | |
182 | 182 | return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] ); |
183 | 183 | } |
@@ -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,28 +25,28 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_donation_history() { |
27 | 27 | |
28 | - $email_access = give_get_option( 'email_access' ); |
|
28 | + $email_access = give_get_option('email_access'); |
|
29 | 29 | |
30 | 30 | //Is user logged in? Does a session exist? Does an email-access token exist? |
31 | - if ( is_user_logged_in() || Give()->session->get_session_expiration() !== false || ( $email_access == 'on' && Give()->email_access->token_exists ) ) { |
|
31 | + if (is_user_logged_in() || Give()->session->get_session_expiration() !== false || ($email_access == 'on' && Give()->email_access->token_exists)) { |
|
32 | 32 | ob_start(); |
33 | - give_get_template_part( 'history', 'donations' ); |
|
33 | + give_get_template_part('history', 'donations'); |
|
34 | 34 | |
35 | 35 | return ob_get_clean(); |
36 | 36 | } //Is Email-based access enabled? |
37 | - elseif ( $email_access == 'on' ) { |
|
37 | + elseif ($email_access == 'on') { |
|
38 | 38 | |
39 | 39 | ob_start(); |
40 | - give_get_template_part( 'email', 'login-form' ); |
|
40 | + give_get_template_part('email', 'login-form'); |
|
41 | 41 | |
42 | 42 | return ob_get_clean(); |
43 | 43 | } else { |
44 | - $message = esc_html__( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' ); |
|
45 | - echo apply_filters( 'give_donation_history_nonuser_message', give_output_error( $message, false ), $message ); |
|
44 | + $message = esc_html__('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give'); |
|
45 | + echo apply_filters('give_donation_history_nonuser_message', give_output_error($message, false), $message); |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | -add_shortcode( 'donation_history', 'give_donation_history' ); |
|
49 | +add_shortcode('donation_history', 'give_donation_history'); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Donation Form Shortcode |
@@ -60,53 +60,53 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @return string |
62 | 62 | */ |
63 | -function give_form_shortcode( $atts, $content = null ) { |
|
64 | - $atts = shortcode_atts( array( |
|
63 | +function give_form_shortcode($atts, $content = null) { |
|
64 | + $atts = shortcode_atts(array( |
|
65 | 65 | 'id' => '', |
66 | 66 | 'show_title' => true, |
67 | 67 | 'show_goal' => true, |
68 | 68 | 'show_content' => '', |
69 | 69 | 'float_labels' => '', |
70 | 70 | 'display_style' => '', |
71 | - ), $atts, 'give_form' ); |
|
71 | + ), $atts, 'give_form'); |
|
72 | 72 | |
73 | - foreach ( $atts as $key => $value ) { |
|
73 | + foreach ($atts as $key => $value) { |
|
74 | 74 | //convert shortcode_atts values to booleans |
75 | - if ( $key == 'show_title' ) { |
|
76 | - $atts[ $key ] = filter_var( $atts[ $key ], FILTER_VALIDATE_BOOLEAN ); |
|
77 | - } elseif ( $key == 'show_goal' ) { |
|
78 | - $atts[ $key ] = filter_var( $atts[ $key ], FILTER_VALIDATE_BOOLEAN ); |
|
75 | + if ($key == 'show_title') { |
|
76 | + $atts[$key] = filter_var($atts[$key], FILTER_VALIDATE_BOOLEAN); |
|
77 | + } elseif ($key == 'show_goal') { |
|
78 | + $atts[$key] = filter_var($atts[$key], FILTER_VALIDATE_BOOLEAN); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | //validate show_content value |
82 | - if ( $key == 'show_content' ) { |
|
83 | - if ( ! in_array( $value, array( 'none', 'above', 'below' ) ) ) { |
|
84 | - $atts[ $key ] = ''; |
|
85 | - } else if ( $value == 'above' ) { |
|
86 | - $atts[ $key ] = 'give_pre_form'; |
|
87 | - } else if ( $value == 'below' ) { |
|
88 | - $atts[ $key ] = 'give_post_form'; |
|
82 | + if ($key == 'show_content') { |
|
83 | + if ( ! in_array($value, array('none', 'above', 'below'))) { |
|
84 | + $atts[$key] = ''; |
|
85 | + } else if ($value == 'above') { |
|
86 | + $atts[$key] = 'give_pre_form'; |
|
87 | + } else if ($value == 'below') { |
|
88 | + $atts[$key] = 'give_post_form'; |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | 92 | //validate display_style and float_labels value |
93 | - if ( ( $key == 'display_style' && ! in_array( $value, array( 'onpage', 'reveal', 'modal' ) ) ) |
|
94 | - || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) ) |
|
93 | + if (($key == 'display_style' && ! in_array($value, array('onpage', 'reveal', 'modal'))) |
|
94 | + || ($key == 'float_labels' && ! in_array($value, array('enabled', 'disabled'))) |
|
95 | 95 | ) { |
96 | 96 | |
97 | - $atts[ $key ] = ''; |
|
97 | + $atts[$key] = ''; |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | 101 | //get the Give Form |
102 | 102 | ob_start(); |
103 | - give_get_donation_form( $atts ); |
|
103 | + give_get_donation_form($atts); |
|
104 | 104 | $final_output = ob_get_clean(); |
105 | 105 | |
106 | - return apply_filters( 'give_donate_form', $final_output, $atts ); |
|
106 | + return apply_filters('give_donate_form', $final_output, $atts); |
|
107 | 107 | } |
108 | 108 | |
109 | -add_shortcode( 'give_form', 'give_form_shortcode' ); |
|
109 | +add_shortcode('give_form', 'give_form_shortcode'); |
|
110 | 110 | |
111 | 111 | /** |
112 | 112 | * Donation Form Goal Shortcode |
@@ -120,37 +120,37 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @return string |
122 | 122 | */ |
123 | -function give_goal_shortcode( $atts, $content = null ) { |
|
124 | - $atts = shortcode_atts( array( |
|
123 | +function give_goal_shortcode($atts, $content = null) { |
|
124 | + $atts = shortcode_atts(array( |
|
125 | 125 | 'id' => '', |
126 | 126 | 'show_text' => true, |
127 | 127 | 'show_bar' => true, |
128 | - ), $atts, 'give_goal' ); |
|
128 | + ), $atts, 'give_goal'); |
|
129 | 129 | |
130 | 130 | |
131 | 131 | //get the Give Form |
132 | 132 | ob_start(); |
133 | 133 | |
134 | 134 | //Sanity check 1: ensure there is an ID Provided |
135 | - if ( empty( $atts['id'] ) ) { |
|
136 | - give_output_error( esc_html__( 'Error: No Donation form ID for the shortcode provided.', 'give' ), true ); |
|
135 | + if (empty($atts['id'])) { |
|
136 | + give_output_error(esc_html__('Error: No Donation form ID for the shortcode provided.', 'give'), true); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | //Sanity check 2: Check that this form even has Goals enabled |
140 | - $goal_option = get_post_meta( $atts['id'], '_give_goal_option', true ); |
|
141 | - if ( empty( $goal_option ) || $goal_option !== 'yes' ) { |
|
142 | - give_output_error( esc_html__( 'Error: This form does not have Goals enabled.', 'give' ), true ); |
|
140 | + $goal_option = get_post_meta($atts['id'], '_give_goal_option', true); |
|
141 | + if (empty($goal_option) || $goal_option !== 'yes') { |
|
142 | + give_output_error(esc_html__('Error: This form does not have Goals enabled.', 'give'), true); |
|
143 | 143 | } else { |
144 | 144 | //Passed all sanity checks: output Goal |
145 | - give_show_goal_progress( $atts['id'], $atts ); |
|
145 | + give_show_goal_progress($atts['id'], $atts); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | $final_output = ob_get_clean(); |
149 | 149 | |
150 | - return apply_filters( 'give_goal_shortcode_output', $final_output, $atts ); |
|
150 | + return apply_filters('give_goal_shortcode_output', $final_output, $atts); |
|
151 | 151 | } |
152 | 152 | |
153 | -add_shortcode( 'give_goal', 'give_goal_shortcode' ); |
|
153 | +add_shortcode('give_goal', 'give_goal_shortcode'); |
|
154 | 154 | |
155 | 155 | |
156 | 156 | /** |
@@ -167,22 +167,22 @@ discard block |
||
167 | 167 | * @uses give_login_form() |
168 | 168 | * @return string |
169 | 169 | */ |
170 | -function give_login_form_shortcode( $atts, $content = null ) { |
|
171 | - $atts = shortcode_atts( array( |
|
170 | +function give_login_form_shortcode($atts, $content = null) { |
|
171 | + $atts = shortcode_atts(array( |
|
172 | 172 | // Add backward compatibility for redirect attribute. |
173 | 173 | 'redirect' => '', |
174 | 174 | |
175 | 175 | 'login-redirect' => '', |
176 | 176 | 'logout-redirect' => '', |
177 | - ), $atts, 'give_login' ); |
|
177 | + ), $atts, 'give_login'); |
|
178 | 178 | |
179 | 179 | // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute. |
180 | - $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect' ] ) ? $atts['redirect'] : '' ); |
|
180 | + $atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : ''); |
|
181 | 181 | |
182 | - return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] ); |
|
182 | + return give_login_form($atts['login-redirect'], $atts['logout-redirect']); |
|
183 | 183 | } |
184 | 184 | |
185 | -add_shortcode( 'give_login', 'give_login_form_shortcode' ); |
|
185 | +add_shortcode('give_login', 'give_login_form_shortcode'); |
|
186 | 186 | |
187 | 187 | /** |
188 | 188 | * Register Shortcode |
@@ -197,15 +197,15 @@ discard block |
||
197 | 197 | * @uses give_register_form() |
198 | 198 | * @return string |
199 | 199 | */ |
200 | -function give_register_form_shortcode( $atts, $content = null ) { |
|
201 | - $atts = shortcode_atts( array( |
|
200 | +function give_register_form_shortcode($atts, $content = null) { |
|
201 | + $atts = shortcode_atts(array( |
|
202 | 202 | 'redirect' => '', |
203 | - ), $atts, 'give_register' ); |
|
203 | + ), $atts, 'give_register'); |
|
204 | 204 | |
205 | - return give_register_form( $atts['redirect'] ); |
|
205 | + return give_register_form($atts['redirect']); |
|
206 | 206 | } |
207 | 207 | |
208 | -add_shortcode( 'give_register', 'give_register_form_shortcode' ); |
|
208 | +add_shortcode('give_register', 'give_register_form_shortcode'); |
|
209 | 209 | |
210 | 210 | |
211 | 211 | /** |
@@ -220,62 +220,62 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @return string |
222 | 222 | */ |
223 | -function give_receipt_shortcode( $atts, $content = null ) { |
|
223 | +function give_receipt_shortcode($atts, $content = null) { |
|
224 | 224 | |
225 | 225 | global $give_receipt_args, $payment; |
226 | 226 | |
227 | - $give_receipt_args = shortcode_atts( array( |
|
228 | - 'error' => esc_html__( 'Sorry, you are missing the payment key to view this donation receipt.', 'give' ), |
|
227 | + $give_receipt_args = shortcode_atts(array( |
|
228 | + 'error' => esc_html__('Sorry, you are missing the payment key to view this donation receipt.', 'give'), |
|
229 | 229 | 'price' => true, |
230 | 230 | 'donor' => true, |
231 | 231 | 'date' => true, |
232 | 232 | 'payment_key' => false, |
233 | 233 | 'payment_method' => true, |
234 | 234 | 'payment_id' => true |
235 | - ), $atts, 'give_receipt' ); |
|
235 | + ), $atts, 'give_receipt'); |
|
236 | 236 | |
237 | 237 | //set $session var |
238 | 238 | $session = give_get_purchase_session(); |
239 | 239 | |
240 | 240 | //set payment key var |
241 | - if ( isset( $_GET['payment_key'] ) ) { |
|
242 | - $payment_key = urldecode( $_GET['payment_key'] ); |
|
243 | - } elseif ( $session ) { |
|
241 | + if (isset($_GET['payment_key'])) { |
|
242 | + $payment_key = urldecode($_GET['payment_key']); |
|
243 | + } elseif ($session) { |
|
244 | 244 | $payment_key = $session['purchase_key']; |
245 | - } elseif ( $give_receipt_args['payment_key'] ) { |
|
245 | + } elseif ($give_receipt_args['payment_key']) { |
|
246 | 246 | $payment_key = $give_receipt_args['payment_key']; |
247 | 247 | } |
248 | 248 | |
249 | - $email_access = give_get_option( 'email_access' ); |
|
249 | + $email_access = give_get_option('email_access'); |
|
250 | 250 | |
251 | 251 | // No payment_key found & Email Access is Turned on: |
252 | - if ( ! isset( $payment_key ) && $email_access == 'on' && ! Give()->email_access->token_exists ) { |
|
252 | + if ( ! isset($payment_key) && $email_access == 'on' && ! Give()->email_access->token_exists) { |
|
253 | 253 | |
254 | 254 | ob_start(); |
255 | 255 | |
256 | - give_get_template_part( 'email-login-form' ); |
|
256 | + give_get_template_part('email-login-form'); |
|
257 | 257 | |
258 | 258 | return ob_get_clean(); |
259 | 259 | |
260 | - } elseif ( ! isset( $payment_key ) ) { |
|
260 | + } elseif ( ! isset($payment_key)) { |
|
261 | 261 | |
262 | - return give_output_error( $give_receipt_args['error'], false, 'error' ); |
|
262 | + return give_output_error($give_receipt_args['error'], false, 'error'); |
|
263 | 263 | |
264 | 264 | } |
265 | 265 | |
266 | - $payment_id = give_get_purchase_id_by_key( $payment_key ); |
|
267 | - $user_can_view = give_can_view_receipt( $payment_key ); |
|
266 | + $payment_id = give_get_purchase_id_by_key($payment_key); |
|
267 | + $user_can_view = give_can_view_receipt($payment_key); |
|
268 | 268 | |
269 | 269 | // Key was provided, but user is logged out. Offer them the ability to login and view the receipt |
270 | - if ( ! $user_can_view && $email_access == 'on' && ! Give()->email_access->token_exists ) { |
|
270 | + if ( ! $user_can_view && $email_access == 'on' && ! Give()->email_access->token_exists) { |
|
271 | 271 | |
272 | 272 | ob_start(); |
273 | 273 | |
274 | - give_get_template_part( 'email-login-form' ); |
|
274 | + give_get_template_part('email-login-form'); |
|
275 | 275 | |
276 | 276 | return ob_get_clean(); |
277 | 277 | |
278 | - } elseif ( ! $user_can_view ) { |
|
278 | + } elseif ( ! $user_can_view) { |
|
279 | 279 | |
280 | 280 | global $give_login_redirect; |
281 | 281 | |
@@ -283,9 +283,9 @@ discard block |
||
283 | 283 | |
284 | 284 | ob_start(); |
285 | 285 | |
286 | - give_output_error( apply_filters( 'give_must_be_logged_in_error_message', esc_html__( 'You must be logged in to view this donation payment receipt.', 'give' ) ) ); |
|
286 | + give_output_error(apply_filters('give_must_be_logged_in_error_message', esc_html__('You must be logged in to view this donation payment receipt.', 'give'))); |
|
287 | 287 | |
288 | - give_get_template_part( 'shortcode', 'login' ); |
|
288 | + give_get_template_part('shortcode', 'login'); |
|
289 | 289 | |
290 | 290 | $login_form = ob_get_clean(); |
291 | 291 | |
@@ -302,13 +302,13 @@ discard block |
||
302 | 302 | * Or if user is logged in and the user can view sensitive shop data |
303 | 303 | * |
304 | 304 | */ |
305 | - if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) { |
|
306 | - return give_output_error( $give_receipt_args['error'], false, 'error' ); |
|
305 | + if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) { |
|
306 | + return give_output_error($give_receipt_args['error'], false, 'error'); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | ob_start(); |
310 | 310 | |
311 | - give_get_template_part( 'shortcode', 'receipt' ); |
|
311 | + give_get_template_part('shortcode', 'receipt'); |
|
312 | 312 | |
313 | 313 | $display = ob_get_clean(); |
314 | 314 | |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | |
318 | 318 | } |
319 | 319 | |
320 | -add_shortcode( 'give_receipt', 'give_receipt_shortcode' ); |
|
320 | +add_shortcode('give_receipt', 'give_receipt_shortcode'); |
|
321 | 321 | |
322 | 322 | /** |
323 | 323 | * Profile Editor Shortcode |
@@ -337,18 +337,18 @@ discard block |
||
337 | 337 | * |
338 | 338 | * @return string Output generated from the profile editor |
339 | 339 | */ |
340 | -function give_profile_editor_shortcode( $atts, $content = null ) { |
|
340 | +function give_profile_editor_shortcode($atts, $content = null) { |
|
341 | 341 | |
342 | 342 | ob_start(); |
343 | 343 | |
344 | - give_get_template_part( 'shortcode', 'profile-editor' ); |
|
344 | + give_get_template_part('shortcode', 'profile-editor'); |
|
345 | 345 | |
346 | 346 | $display = ob_get_clean(); |
347 | 347 | |
348 | 348 | return $display; |
349 | 349 | } |
350 | 350 | |
351 | -add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' ); |
|
351 | +add_shortcode('give_profile_editor', 'give_profile_editor_shortcode'); |
|
352 | 352 | |
353 | 353 | /** |
354 | 354 | * Process Profile Updater Form |
@@ -361,30 +361,30 @@ discard block |
||
361 | 361 | * |
362 | 362 | * @return bool |
363 | 363 | */ |
364 | -function give_process_profile_editor_updates( $data ) { |
|
364 | +function give_process_profile_editor_updates($data) { |
|
365 | 365 | // Profile field change request |
366 | - if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) { |
|
366 | + if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) { |
|
367 | 367 | return false; |
368 | 368 | } |
369 | 369 | |
370 | 370 | // Nonce security |
371 | - if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) { |
|
371 | + if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) { |
|
372 | 372 | return false; |
373 | 373 | } |
374 | 374 | |
375 | 375 | $user_id = get_current_user_id(); |
376 | - $old_user_data = get_userdata( $user_id ); |
|
377 | - |
|
378 | - $display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name; |
|
379 | - $first_name = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name; |
|
380 | - $last_name = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name; |
|
381 | - $email = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email; |
|
382 | - $line1 = ( isset( $data['give_address_line1'] ) ? sanitize_text_field( $data['give_address_line1'] ) : '' ); |
|
383 | - $line2 = ( isset( $data['give_address_line2'] ) ? sanitize_text_field( $data['give_address_line2'] ) : '' ); |
|
384 | - $city = ( isset( $data['give_address_city'] ) ? sanitize_text_field( $data['give_address_city'] ) : '' ); |
|
385 | - $state = ( isset( $data['give_address_state'] ) ? sanitize_text_field( $data['give_address_state'] ) : '' ); |
|
386 | - $zip = ( isset( $data['give_address_zip'] ) ? sanitize_text_field( $data['give_address_zip'] ) : '' ); |
|
387 | - $country = ( isset( $data['give_address_country'] ) ? sanitize_text_field( $data['give_address_country'] ) : '' ); |
|
376 | + $old_user_data = get_userdata($user_id); |
|
377 | + |
|
378 | + $display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name; |
|
379 | + $first_name = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name; |
|
380 | + $last_name = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name; |
|
381 | + $email = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email; |
|
382 | + $line1 = (isset($data['give_address_line1']) ? sanitize_text_field($data['give_address_line1']) : ''); |
|
383 | + $line2 = (isset($data['give_address_line2']) ? sanitize_text_field($data['give_address_line2']) : ''); |
|
384 | + $city = (isset($data['give_address_city']) ? sanitize_text_field($data['give_address_city']) : ''); |
|
385 | + $state = (isset($data['give_address_state']) ? sanitize_text_field($data['give_address_state']) : ''); |
|
386 | + $zip = (isset($data['give_address_zip']) ? sanitize_text_field($data['give_address_zip']) : ''); |
|
387 | + $country = (isset($data['give_address_country']) ? sanitize_text_field($data['give_address_country']) : ''); |
|
388 | 388 | |
389 | 389 | $userdata = array( |
390 | 390 | 'ID' => $user_id, |
@@ -404,45 +404,45 @@ discard block |
||
404 | 404 | 'country' => $country |
405 | 405 | ); |
406 | 406 | |
407 | - do_action( 'give_pre_update_user_profile', $user_id, $userdata ); |
|
407 | + do_action('give_pre_update_user_profile', $user_id, $userdata); |
|
408 | 408 | |
409 | 409 | // New password |
410 | - if ( ! empty( $data['give_new_user_pass1'] ) ) { |
|
411 | - if ( $data['give_new_user_pass1'] !== $data['give_new_user_pass2'] ) { |
|
412 | - give_set_error( 'password_mismatch', esc_html__( 'The passwords you entered do not match. Please try again.', 'give' ) ); |
|
410 | + if ( ! empty($data['give_new_user_pass1'])) { |
|
411 | + if ($data['give_new_user_pass1'] !== $data['give_new_user_pass2']) { |
|
412 | + give_set_error('password_mismatch', esc_html__('The passwords you entered do not match. Please try again.', 'give')); |
|
413 | 413 | } else { |
414 | 414 | $userdata['user_pass'] = $data['give_new_user_pass1']; |
415 | 415 | } |
416 | 416 | } |
417 | 417 | |
418 | 418 | // Make sure the new email doesn't belong to another user |
419 | - if ( $email != $old_user_data->user_email ) { |
|
420 | - if ( email_exists( $email ) ) { |
|
421 | - give_set_error( 'email_exists', esc_html__( 'The email you entered belongs to another user. Please use another.', 'give' ) ); |
|
419 | + if ($email != $old_user_data->user_email) { |
|
420 | + if (email_exists($email)) { |
|
421 | + give_set_error('email_exists', esc_html__('The email you entered belongs to another user. Please use another.', 'give')); |
|
422 | 422 | } |
423 | 423 | } |
424 | 424 | |
425 | 425 | // Check for errors |
426 | 426 | $errors = give_get_errors(); |
427 | 427 | |
428 | - if ( $errors ) { |
|
428 | + if ($errors) { |
|
429 | 429 | // Send back to the profile editor if there are errors |
430 | - wp_redirect( $data['give_redirect'] ); |
|
430 | + wp_redirect($data['give_redirect']); |
|
431 | 431 | give_die(); |
432 | 432 | } |
433 | 433 | |
434 | 434 | // Update the user |
435 | - $meta = update_user_meta( $user_id, '_give_user_address', $address ); |
|
436 | - $updated = wp_update_user( $userdata ); |
|
435 | + $meta = update_user_meta($user_id, '_give_user_address', $address); |
|
436 | + $updated = wp_update_user($userdata); |
|
437 | 437 | |
438 | - if ( $updated ) { |
|
439 | - do_action( 'give_user_profile_updated', $user_id, $userdata ); |
|
440 | - wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) ); |
|
438 | + if ($updated) { |
|
439 | + do_action('give_user_profile_updated', $user_id, $userdata); |
|
440 | + wp_redirect(add_query_arg('updated', 'true', $data['give_redirect'])); |
|
441 | 441 | give_die(); |
442 | 442 | } |
443 | 443 | |
444 | 444 | return false; |
445 | 445 | } |
446 | 446 | |
447 | -add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' ); |
|
447 | +add_action('give_edit_user_profile', 'give_process_profile_editor_updates'); |
|
448 | 448 |
@@ -182,7 +182,7 @@ |
||
182 | 182 | * |
183 | 183 | * @param array $data Array of attributes for a donation form |
184 | 184 | * |
185 | - * @return mixed false if data isn't passed and class not instantiated for creation, or New Form ID |
|
185 | + * @return boolean false if data isn't passed and class not instantiated for creation, or New Form ID |
|
186 | 186 | */ |
187 | 187 | public function create( $data = array() ) { |
188 | 188 |
@@ -463,31 +463,31 @@ |
||
463 | 463 | |
464 | 464 | } |
465 | 465 | |
466 | - /** |
|
467 | - * Get if form type set or not. |
|
468 | - * |
|
469 | - * @since 1.6 |
|
470 | - * @return bool true if form type is 'multi' and false otherwise. |
|
471 | - */ |
|
472 | - public function is_set_type_donation_form() { |
|
473 | - $form_type = $this->get_type(); |
|
474 | - |
|
475 | - return ( 'set' === $form_type ? true : false ); |
|
476 | - |
|
477 | - } |
|
478 | - |
|
479 | - /** |
|
480 | - * Get if form type multi or not. |
|
481 | - * |
|
482 | - * @since 1.6 |
|
483 | - * @return bool true if form type is 'multi' and false otherwise. |
|
484 | - */ |
|
485 | - public function is_multi_type_donation_form() { |
|
486 | - $form_type = $this->get_type(); |
|
487 | - |
|
488 | - return ( 'multi' === $form_type ? true : false ); |
|
489 | - |
|
490 | - } |
|
466 | + /** |
|
467 | + * Get if form type set or not. |
|
468 | + * |
|
469 | + * @since 1.6 |
|
470 | + * @return bool true if form type is 'multi' and false otherwise. |
|
471 | + */ |
|
472 | + public function is_set_type_donation_form() { |
|
473 | + $form_type = $this->get_type(); |
|
474 | + |
|
475 | + return ( 'set' === $form_type ? true : false ); |
|
476 | + |
|
477 | + } |
|
478 | + |
|
479 | + /** |
|
480 | + * Get if form type multi or not. |
|
481 | + * |
|
482 | + * @since 1.6 |
|
483 | + * @return bool true if form type is 'multi' and false otherwise. |
|
484 | + */ |
|
485 | + public function is_multi_type_donation_form() { |
|
486 | + $form_type = $this->get_type(); |
|
487 | + |
|
488 | + return ( 'multi' === $form_type ? true : false ); |
|
489 | + |
|
490 | + } |
|
491 | 491 | |
492 | 492 | /** |
493 | 493 | * Retrieve the sale count for the donation form |
@@ -100,12 +100,12 @@ discard block |
||
100 | 100 | * @param bool $_id |
101 | 101 | * @param array $_args |
102 | 102 | */ |
103 | - public function __construct( $_id = false, $_args = array() ) { |
|
103 | + public function __construct($_id = false, $_args = array()) { |
|
104 | 104 | |
105 | 105 | |
106 | - $donation_form = WP_Post::get_instance( $_id ); |
|
106 | + $donation_form = WP_Post::get_instance($_id); |
|
107 | 107 | |
108 | - return $this->setup_donation_form( $donation_form ); |
|
108 | + return $this->setup_donation_form($donation_form); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -119,23 +119,23 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @return bool If the setup was successful or not |
121 | 121 | */ |
122 | - private function setup_donation_form( $donation_form ) { |
|
122 | + private function setup_donation_form($donation_form) { |
|
123 | 123 | |
124 | - if ( ! is_object( $donation_form ) ) { |
|
124 | + if ( ! is_object($donation_form)) { |
|
125 | 125 | return false; |
126 | 126 | } |
127 | 127 | |
128 | - if ( ! is_a( $donation_form, 'WP_Post' ) ) { |
|
128 | + if ( ! is_a($donation_form, 'WP_Post')) { |
|
129 | 129 | return false; |
130 | 130 | } |
131 | 131 | |
132 | - if ( 'give_forms' !== $donation_form->post_type ) { |
|
132 | + if ('give_forms' !== $donation_form->post_type) { |
|
133 | 133 | return false; |
134 | 134 | } |
135 | 135 | |
136 | - foreach ( $donation_form as $key => $value ) { |
|
136 | + foreach ($donation_form as $key => $value) { |
|
137 | 137 | |
138 | - switch ( $key ) { |
|
138 | + switch ($key) { |
|
139 | 139 | |
140 | 140 | default: |
141 | 141 | $this->$key = $value; |
@@ -159,16 +159,16 @@ discard block |
||
159 | 159 | * @return mixed |
160 | 160 | * @throws Exception |
161 | 161 | */ |
162 | - public function __get( $key ) { |
|
162 | + public function __get($key) { |
|
163 | 163 | |
164 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
164 | + if (method_exists($this, 'get_'.$key)) { |
|
165 | 165 | |
166 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
166 | + return call_user_func(array($this, 'get_'.$key)); |
|
167 | 167 | |
168 | 168 | } else { |
169 | 169 | |
170 | 170 | /* translators: %s: property key */ |
171 | - return new WP_Error( 'give-form-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); |
|
171 | + return new WP_Error('give-form-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key)); |
|
172 | 172 | |
173 | 173 | } |
174 | 174 | |
@@ -184,30 +184,30 @@ discard block |
||
184 | 184 | * |
185 | 185 | * @return mixed false if data isn't passed and class not instantiated for creation, or New Form ID |
186 | 186 | */ |
187 | - public function create( $data = array() ) { |
|
187 | + public function create($data = array()) { |
|
188 | 188 | |
189 | - if ( $this->id != 0 ) { |
|
189 | + if ($this->id != 0) { |
|
190 | 190 | return false; |
191 | 191 | } |
192 | 192 | |
193 | 193 | $defaults = array( |
194 | 194 | 'post_type' => 'give_forms', |
195 | 195 | 'post_status' => 'draft', |
196 | - 'post_title' => esc_html__( 'New Donation Form', 'give' ) |
|
196 | + 'post_title' => esc_html__('New Donation Form', 'give') |
|
197 | 197 | ); |
198 | 198 | |
199 | - $args = wp_parse_args( $data, $defaults ); |
|
199 | + $args = wp_parse_args($data, $defaults); |
|
200 | 200 | |
201 | 201 | /** |
202 | 202 | * Fired before a donation form is created |
203 | 203 | * |
204 | 204 | * @param array $args The post object arguments used for creation. |
205 | 205 | */ |
206 | - do_action( 'give_form_pre_create', $args ); |
|
206 | + do_action('give_form_pre_create', $args); |
|
207 | 207 | |
208 | - $id = wp_insert_post( $args, true ); |
|
208 | + $id = wp_insert_post($args, true); |
|
209 | 209 | |
210 | - $donation_form = WP_Post::get_instance( $id ); |
|
210 | + $donation_form = WP_Post::get_instance($id); |
|
211 | 211 | |
212 | 212 | /** |
213 | 213 | * Fired after a donation form is created |
@@ -215,9 +215,9 @@ discard block |
||
215 | 215 | * @param int $id The post ID of the created item. |
216 | 216 | * @param array $args The post object arguments used for creation. |
217 | 217 | */ |
218 | - do_action( 'give_form_post_create', $id, $args ); |
|
218 | + do_action('give_form_post_create', $id, $args); |
|
219 | 219 | |
220 | - return $this->setup_donation_form( $donation_form ); |
|
220 | + return $this->setup_donation_form($donation_form); |
|
221 | 221 | |
222 | 222 | } |
223 | 223 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * @return string Name of the donation form |
241 | 241 | */ |
242 | 242 | public function get_name() { |
243 | - return get_the_title( $this->ID ); |
|
243 | + return get_the_title($this->ID); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -251,13 +251,13 @@ discard block |
||
251 | 251 | */ |
252 | 252 | public function get_price() { |
253 | 253 | |
254 | - if ( ! isset( $this->price ) ) { |
|
254 | + if ( ! isset($this->price)) { |
|
255 | 255 | |
256 | - $this->price = get_post_meta( $this->ID, '_give_set_price', true ); |
|
256 | + $this->price = get_post_meta($this->ID, '_give_set_price', true); |
|
257 | 257 | |
258 | - if ( $this->price ) { |
|
258 | + if ($this->price) { |
|
259 | 259 | |
260 | - $this->price = give_sanitize_amount( $this->price ); |
|
260 | + $this->price = give_sanitize_amount($this->price); |
|
261 | 261 | |
262 | 262 | } else { |
263 | 263 | |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | * @param string $price The donation form price. |
276 | 276 | * @param string|int $id The form ID. |
277 | 277 | */ |
278 | - return apply_filters( 'give_get_set_price', $this->price, $this->ID ); |
|
278 | + return apply_filters('give_get_set_price', $this->price, $this->ID); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -286,14 +286,14 @@ discard block |
||
286 | 286 | */ |
287 | 287 | public function get_minimum_price() { |
288 | 288 | |
289 | - if ( ! isset( $this->minimum_price ) ) { |
|
289 | + if ( ! isset($this->minimum_price)) { |
|
290 | 290 | |
291 | - $allow_custom_amount = get_post_meta( $this->ID, '_give_custom_amount', true ); |
|
292 | - $this->minimum_price = get_post_meta( $this->ID, '_give_custom_amount_minimum', true ); |
|
291 | + $allow_custom_amount = get_post_meta($this->ID, '_give_custom_amount', true); |
|
292 | + $this->minimum_price = get_post_meta($this->ID, '_give_custom_amount_minimum', true); |
|
293 | 293 | |
294 | - if ( $allow_custom_amount != 'no' && $this->minimum_price ) { |
|
294 | + if ($allow_custom_amount != 'no' && $this->minimum_price) { |
|
295 | 295 | |
296 | - $this->minimum_price = give_sanitize_amount( $this->minimum_price ); |
|
296 | + $this->minimum_price = give_sanitize_amount($this->minimum_price); |
|
297 | 297 | |
298 | 298 | } else { |
299 | 299 | |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | |
304 | 304 | } |
305 | 305 | |
306 | - return apply_filters( 'give_get_set_minimum_price', $this->minimum_price, $this->ID ); |
|
306 | + return apply_filters('give_get_set_minimum_price', $this->minimum_price, $this->ID); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -314,9 +314,9 @@ discard block |
||
314 | 314 | */ |
315 | 315 | public function get_prices() { |
316 | 316 | |
317 | - if ( ! isset( $this->prices ) ) { |
|
317 | + if ( ! isset($this->prices)) { |
|
318 | 318 | |
319 | - $this->prices = get_post_meta( $this->ID, '_give_donation_levels', true ); |
|
319 | + $this->prices = get_post_meta($this->ID, '_give_donation_levels', true); |
|
320 | 320 | |
321 | 321 | } |
322 | 322 | |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * @param array $prices The array of mulit-level prices. |
329 | 329 | * @param int|string The ID of the form. |
330 | 330 | */ |
331 | - return apply_filters( 'give_get_donation_levels', $this->prices, $this->ID ); |
|
331 | + return apply_filters('give_get_donation_levels', $this->prices, $this->ID); |
|
332 | 332 | |
333 | 333 | } |
334 | 334 | |
@@ -340,13 +340,13 @@ discard block |
||
340 | 340 | */ |
341 | 341 | public function get_goal() { |
342 | 342 | |
343 | - if ( ! isset( $this->goal ) ) { |
|
343 | + if ( ! isset($this->goal)) { |
|
344 | 344 | |
345 | - $this->goal = get_post_meta( $this->ID, '_give_set_goal', true ); |
|
345 | + $this->goal = get_post_meta($this->ID, '_give_set_goal', true); |
|
346 | 346 | |
347 | - if ( $this->goal ) { |
|
347 | + if ($this->goal) { |
|
348 | 348 | |
349 | - $this->goal = give_sanitize_amount( $this->goal ); |
|
349 | + $this->goal = give_sanitize_amount($this->goal); |
|
350 | 350 | |
351 | 351 | } else { |
352 | 352 | |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | |
357 | 357 | } |
358 | 358 | |
359 | - return apply_filters( 'give_get_set_goal', $this->goal, $this->ID ); |
|
359 | + return apply_filters('give_get_set_goal', $this->goal, $this->ID); |
|
360 | 360 | |
361 | 361 | } |
362 | 362 | |
@@ -368,10 +368,10 @@ discard block |
||
368 | 368 | */ |
369 | 369 | public function is_single_price_mode() { |
370 | 370 | |
371 | - $option = get_post_meta( $this->ID, '_give_price_options_mode', true ); |
|
371 | + $option = get_post_meta($this->ID, '_give_price_options_mode', true); |
|
372 | 372 | $ret = 0; |
373 | 373 | |
374 | - if ( empty( $option ) || $option === 'set' ) { |
|
374 | + if (empty($option) || $option === 'set') { |
|
375 | 375 | $ret = 1; |
376 | 376 | } |
377 | 377 | |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * @param bool $ret Is donation form in single price mode? |
384 | 384 | * @param int|string The ID of the donation form. |
385 | 385 | */ |
386 | - return (bool) apply_filters( 'give_single_price_option_mode', $ret, $this->ID ); |
|
386 | + return (bool) apply_filters('give_single_price_option_mode', $ret, $this->ID); |
|
387 | 387 | |
388 | 388 | } |
389 | 389 | |
@@ -395,10 +395,10 @@ discard block |
||
395 | 395 | */ |
396 | 396 | public function is_custom_price_mode() { |
397 | 397 | |
398 | - $option = get_post_meta( $this->ID, '_give_custom_amount', true ); |
|
398 | + $option = get_post_meta($this->ID, '_give_custom_amount', true); |
|
399 | 399 | $ret = 0; |
400 | 400 | |
401 | - if ( $option === 'yes' ) { |
|
401 | + if ($option === 'yes') { |
|
402 | 402 | $ret = 1; |
403 | 403 | } |
404 | 404 | |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | * @param bool $ret Is donation form in custom price mode? |
411 | 411 | * @param int|string The ID of the donation form. |
412 | 412 | */ |
413 | - return (bool) apply_filters( 'give_custom_price_option_mode', $ret, $this->ID ); |
|
413 | + return (bool) apply_filters('give_custom_price_option_mode', $ret, $this->ID); |
|
414 | 414 | |
415 | 415 | } |
416 | 416 | |
@@ -424,10 +424,10 @@ discard block |
||
424 | 424 | */ |
425 | 425 | public function has_variable_prices() { |
426 | 426 | |
427 | - $option = get_post_meta( $this->ID, '_give_price_option', true ); |
|
427 | + $option = get_post_meta($this->ID, '_give_price_option', true); |
|
428 | 428 | $ret = 0; |
429 | 429 | |
430 | - if ( $option === 'multi' ) { |
|
430 | + if ($option === 'multi') { |
|
431 | 431 | $ret = 1; |
432 | 432 | } |
433 | 433 | |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | * @param bool $ret Does donation form have variable prices? |
438 | 438 | * @param int|string The ID of the donation form. |
439 | 439 | */ |
440 | - return (bool) apply_filters( 'give_has_variable_prices', $ret, $this->ID ); |
|
440 | + return (bool) apply_filters('give_has_variable_prices', $ret, $this->ID); |
|
441 | 441 | |
442 | 442 | } |
443 | 443 | |
@@ -449,17 +449,17 @@ discard block |
||
449 | 449 | */ |
450 | 450 | public function get_type() { |
451 | 451 | |
452 | - if ( ! isset( $this->type ) ) { |
|
452 | + if ( ! isset($this->type)) { |
|
453 | 453 | |
454 | - $this->type = get_post_meta( $this->ID, '_give_price_option', true ); |
|
454 | + $this->type = get_post_meta($this->ID, '_give_price_option', true); |
|
455 | 455 | |
456 | - if ( empty( $this->type ) ) { |
|
456 | + if (empty($this->type)) { |
|
457 | 457 | $this->type = 'set'; |
458 | 458 | } |
459 | 459 | |
460 | 460 | } |
461 | 461 | |
462 | - return apply_filters( 'give_get_form_type', $this->type, $this->ID ); |
|
462 | + return apply_filters('give_get_form_type', $this->type, $this->ID); |
|
463 | 463 | |
464 | 464 | } |
465 | 465 | |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | public function is_set_type_donation_form() { |
473 | 473 | $form_type = $this->get_type(); |
474 | 474 | |
475 | - return ( 'set' === $form_type ? true : false ); |
|
475 | + return ('set' === $form_type ? true : false); |
|
476 | 476 | |
477 | 477 | } |
478 | 478 | |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | public function is_multi_type_donation_form() { |
486 | 486 | $form_type = $this->get_type(); |
487 | 487 | |
488 | - return ( 'multi' === $form_type ? true : false ); |
|
488 | + return ('multi' === $form_type ? true : false); |
|
489 | 489 | |
490 | 490 | } |
491 | 491 | |
@@ -497,15 +497,15 @@ discard block |
||
497 | 497 | */ |
498 | 498 | public function get_sales() { |
499 | 499 | |
500 | - if ( ! isset( $this->sales ) ) { |
|
500 | + if ( ! isset($this->sales)) { |
|
501 | 501 | |
502 | - if ( '' == get_post_meta( $this->ID, '_give_form_sales', true ) ) { |
|
503 | - add_post_meta( $this->ID, '_give_form_sales', 0 ); |
|
502 | + if ('' == get_post_meta($this->ID, '_give_form_sales', true)) { |
|
503 | + add_post_meta($this->ID, '_give_form_sales', 0); |
|
504 | 504 | } // End if |
505 | 505 | |
506 | - $this->sales = get_post_meta( $this->ID, '_give_form_sales', true ); |
|
506 | + $this->sales = get_post_meta($this->ID, '_give_form_sales', true); |
|
507 | 507 | |
508 | - if ( $this->sales < 0 ) { |
|
508 | + if ($this->sales < 0) { |
|
509 | 509 | // Never let sales be less than zero |
510 | 510 | $this->sales = 0; |
511 | 511 | } |
@@ -525,13 +525,13 @@ discard block |
||
525 | 525 | * |
526 | 526 | * @return int|false New number of total sales |
527 | 527 | */ |
528 | - public function increase_sales( $quantity = 1 ) { |
|
528 | + public function increase_sales($quantity = 1) { |
|
529 | 529 | |
530 | - $sales = give_get_form_sales_stats( $this->ID ); |
|
531 | - $quantity = absint( $quantity ); |
|
530 | + $sales = give_get_form_sales_stats($this->ID); |
|
531 | + $quantity = absint($quantity); |
|
532 | 532 | $total_sales = $sales + $quantity; |
533 | 533 | |
534 | - if ( $this->update_meta( '_give_form_sales', $total_sales ) ) { |
|
534 | + if ($this->update_meta('_give_form_sales', $total_sales)) { |
|
535 | 535 | |
536 | 536 | $this->sales = $total_sales; |
537 | 537 | |
@@ -551,17 +551,17 @@ discard block |
||
551 | 551 | * |
552 | 552 | * @return int|false New number of total sales |
553 | 553 | */ |
554 | - public function decrease_sales( $quantity = 1 ) { |
|
554 | + public function decrease_sales($quantity = 1) { |
|
555 | 555 | |
556 | - $sales = give_get_form_sales_stats( $this->ID ); |
|
556 | + $sales = give_get_form_sales_stats($this->ID); |
|
557 | 557 | |
558 | 558 | // Only decrease if not already zero |
559 | - if ( $sales > 0 ) { |
|
559 | + if ($sales > 0) { |
|
560 | 560 | |
561 | - $quantity = absint( $quantity ); |
|
561 | + $quantity = absint($quantity); |
|
562 | 562 | $total_sales = $sales - $quantity; |
563 | 563 | |
564 | - if ( $this->update_meta( '_give_form_sales', $total_sales ) ) { |
|
564 | + if ($this->update_meta('_give_form_sales', $total_sales)) { |
|
565 | 565 | |
566 | 566 | $this->sales = $sales; |
567 | 567 | |
@@ -583,15 +583,15 @@ discard block |
||
583 | 583 | */ |
584 | 584 | public function get_earnings() { |
585 | 585 | |
586 | - if ( ! isset( $this->earnings ) ) { |
|
586 | + if ( ! isset($this->earnings)) { |
|
587 | 587 | |
588 | - if ( '' == get_post_meta( $this->ID, '_give_form_earnings', true ) ) { |
|
589 | - add_post_meta( $this->ID, '_give_form_earnings', 0 ); |
|
588 | + if ('' == get_post_meta($this->ID, '_give_form_earnings', true)) { |
|
589 | + add_post_meta($this->ID, '_give_form_earnings', 0); |
|
590 | 590 | } |
591 | 591 | |
592 | - $this->earnings = get_post_meta( $this->ID, '_give_form_earnings', true ); |
|
592 | + $this->earnings = get_post_meta($this->ID, '_give_form_earnings', true); |
|
593 | 593 | |
594 | - if ( $this->earnings < 0 ) { |
|
594 | + if ($this->earnings < 0) { |
|
595 | 595 | // Never let earnings be less than zero |
596 | 596 | $this->earnings = 0; |
597 | 597 | } |
@@ -611,12 +611,12 @@ discard block |
||
611 | 611 | * |
612 | 612 | * @return float|false |
613 | 613 | */ |
614 | - public function increase_earnings( $amount = 0 ) { |
|
614 | + public function increase_earnings($amount = 0) { |
|
615 | 615 | |
616 | - $earnings = give_get_form_earnings_stats( $this->ID ); |
|
616 | + $earnings = give_get_form_earnings_stats($this->ID); |
|
617 | 617 | $new_amount = $earnings + (float) $amount; |
618 | 618 | |
619 | - if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) { |
|
619 | + if ($this->update_meta('_give_form_earnings', $new_amount)) { |
|
620 | 620 | |
621 | 621 | $this->earnings = $new_amount; |
622 | 622 | |
@@ -634,16 +634,16 @@ discard block |
||
634 | 634 | * @since 1.0 |
635 | 635 | * @return float|false |
636 | 636 | */ |
637 | - public function decrease_earnings( $amount ) { |
|
637 | + public function decrease_earnings($amount) { |
|
638 | 638 | |
639 | - $earnings = give_get_form_earnings_stats( $this->ID ); |
|
639 | + $earnings = give_get_form_earnings_stats($this->ID); |
|
640 | 640 | |
641 | - if ( $earnings > 0 ) { |
|
641 | + if ($earnings > 0) { |
|
642 | 642 | // Only decrease if greater than zero |
643 | 643 | $new_amount = $earnings - (float) $amount; |
644 | 644 | |
645 | 645 | |
646 | - if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) { |
|
646 | + if ($this->update_meta('_give_form_earnings', $new_amount)) { |
|
647 | 647 | |
648 | 648 | $this->earnings = $new_amount; |
649 | 649 | |
@@ -663,22 +663,22 @@ discard block |
||
663 | 663 | * @since 1.0 |
664 | 664 | * @return bool |
665 | 665 | */ |
666 | - public function is_free( $price_id = false ) { |
|
666 | + public function is_free($price_id = false) { |
|
667 | 667 | |
668 | 668 | $is_free = false; |
669 | - $variable_pricing = give_has_variable_prices( $this->ID ); |
|
669 | + $variable_pricing = give_has_variable_prices($this->ID); |
|
670 | 670 | |
671 | - if ( $variable_pricing && ! is_null( $price_id ) && $price_id !== false ) { |
|
672 | - $price = give_get_price_option_amount( $this->ID, $price_id ); |
|
673 | - } elseif ( ! $variable_pricing ) { |
|
674 | - $price = get_post_meta( $this->ID, '_give_set_price', true ); |
|
671 | + if ($variable_pricing && ! is_null($price_id) && $price_id !== false) { |
|
672 | + $price = give_get_price_option_amount($this->ID, $price_id); |
|
673 | + } elseif ( ! $variable_pricing) { |
|
674 | + $price = get_post_meta($this->ID, '_give_set_price', true); |
|
675 | 675 | } |
676 | 676 | |
677 | - if ( isset( $price ) && (float) $price == 0 ) { |
|
677 | + if (isset($price) && (float) $price == 0) { |
|
678 | 678 | $is_free = true; |
679 | 679 | } |
680 | 680 | |
681 | - return (bool) apply_filters( 'give_is_free_donation', $is_free, $this->ID, $price_id ); |
|
681 | + return (bool) apply_filters('give_is_free_donation', $is_free, $this->ID, $price_id); |
|
682 | 682 | |
683 | 683 | } |
684 | 684 | |
@@ -695,9 +695,9 @@ discard block |
||
695 | 695 | */ |
696 | 696 | public function is_close_donation_form() { |
697 | 697 | return ( |
698 | - 'yes' === get_post_meta( $this->ID, '_give_goal_option', true ) ) |
|
699 | - && ( 'yes' === get_post_meta( $this->ID, '_give_close_form_when_goal_achieved', true ) ) |
|
700 | - && ( $this->get_goal() <= $this->get_earnings() |
|
698 | + 'yes' === get_post_meta($this->ID, '_give_goal_option', true) ) |
|
699 | + && ('yes' === get_post_meta($this->ID, '_give_close_form_when_goal_achieved', true)) |
|
700 | + && ($this->get_goal() <= $this->get_earnings() |
|
701 | 701 | ); |
702 | 702 | } |
703 | 703 | |
@@ -713,29 +713,29 @@ discard block |
||
713 | 713 | * |
714 | 714 | * @return bool The result of the update query |
715 | 715 | */ |
716 | - private function update_meta( $meta_key = '', $meta_value = '' ) { |
|
716 | + private function update_meta($meta_key = '', $meta_value = '') { |
|
717 | 717 | |
718 | 718 | /* @var WPDB $wpdb */ |
719 | 719 | global $wpdb; |
720 | 720 | |
721 | - if ( empty( $meta_key ) || empty( $meta_value ) ) { |
|
721 | + if (empty($meta_key) || empty($meta_value)) { |
|
722 | 722 | return false; |
723 | 723 | } |
724 | 724 | |
725 | 725 | // Make sure if it needs to be serialized, we do |
726 | - $meta_value = maybe_serialize( $meta_value ); |
|
726 | + $meta_value = maybe_serialize($meta_value); |
|
727 | 727 | |
728 | - if ( is_numeric( $meta_value ) ) { |
|
729 | - $value_type = is_float( $meta_value ) ? '%f' : '%d'; |
|
728 | + if (is_numeric($meta_value)) { |
|
729 | + $value_type = is_float($meta_value) ? '%f' : '%d'; |
|
730 | 730 | } else { |
731 | 731 | $value_type = "'%s'"; |
732 | 732 | } |
733 | 733 | |
734 | - $sql = $wpdb->prepare( "UPDATE $wpdb->postmeta SET meta_value = $value_type WHERE post_id = $this->ID AND meta_key = '%s'", $meta_value, $meta_key ); |
|
734 | + $sql = $wpdb->prepare("UPDATE $wpdb->postmeta SET meta_value = $value_type WHERE post_id = $this->ID AND meta_key = '%s'", $meta_value, $meta_key); |
|
735 | 735 | |
736 | - if ( $wpdb->query( $sql ) ) { |
|
736 | + if ($wpdb->query($sql)) { |
|
737 | 737 | |
738 | - clean_post_cache( $this->ID ); |
|
738 | + clean_post_cache($this->ID); |
|
739 | 739 | |
740 | 740 | return true; |
741 | 741 |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | * @param array $log_data Log entry data |
215 | 215 | * @param array $log_meta Log entry meta |
216 | 216 | * |
217 | - * @return bool True if successful, false otherwise |
|
217 | + * @return boolean|null True if successful, false otherwise |
|
218 | 218 | */ |
219 | 219 | public function update_log( $log_data = array(), $log_meta = array() ) { |
220 | 220 | |
@@ -392,13 +392,13 @@ discard block |
||
392 | 392 | * @param string $title |
393 | 393 | * @param string $message |
394 | 394 | * @param int $parent |
395 | - * @param null $type |
|
395 | + * @param string $type |
|
396 | 396 | * |
397 | 397 | * @global $give_logs GIVE Logs Object |
398 | 398 | * |
399 | 399 | * @uses Give_Logging::add() |
400 | 400 | * |
401 | - * @return mixed ID of the new log entry |
|
401 | + * @return integer ID of the new log entry |
|
402 | 402 | */ |
403 | 403 | function give_record_log( $title = '', $message = '', $parent = 0, $type = null ) { |
404 | 404 | /* @var Give_Logging $give_logs */ |
@@ -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 | |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function __construct() { |
32 | 32 | // Create the log post type |
33 | - add_action( 'init', array( $this, 'register_post_type' ), 1 ); |
|
33 | + add_action('init', array($this, 'register_post_type'), 1); |
|
34 | 34 | |
35 | 35 | // Create types taxonomy and default types |
36 | - add_action( 'init', array( $this, 'register_taxonomy' ), 1 ); |
|
36 | + add_action('init', array($this, 'register_taxonomy'), 1); |
|
37 | 37 | |
38 | 38 | } |
39 | 39 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | public function register_post_type() { |
48 | 48 | /* Logs post type */ |
49 | 49 | $log_args = array( |
50 | - 'labels' => array( 'name' => esc_html__( 'Logs', 'give' ) ), |
|
50 | + 'labels' => array('name' => esc_html__('Logs', 'give')), |
|
51 | 51 | 'public' => false, |
52 | 52 | 'exclude_from_search' => true, |
53 | 53 | 'publicly_queryable' => false, |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | 'query_var' => false, |
56 | 56 | 'rewrite' => false, |
57 | 57 | 'capability_type' => 'post', |
58 | - 'supports' => array( 'title', 'editor' ), |
|
58 | + 'supports' => array('title', 'editor'), |
|
59 | 59 | 'can_export' => true |
60 | 60 | ); |
61 | 61 | |
62 | - register_post_type( 'give_log', $log_args ); |
|
62 | + register_post_type('give_log', $log_args); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @return void |
73 | 73 | */ |
74 | 74 | public function register_taxonomy() { |
75 | - register_taxonomy( 'give_log_type', 'give_log', array( 'public' => false ) ); |
|
75 | + register_taxonomy('give_log_type', 'give_log', array('public' => false)); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | 'api_request' |
92 | 92 | ); |
93 | 93 | |
94 | - return apply_filters( 'give_log_types', $terms ); |
|
94 | + return apply_filters('give_log_types', $terms); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @return bool Whether log type is valid |
109 | 109 | */ |
110 | - function valid_type( $type ) { |
|
111 | - return in_array( $type, $this->log_types() ); |
|
110 | + function valid_type($type) { |
|
111 | + return in_array($type, $this->log_types()); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return int Log ID |
130 | 130 | */ |
131 | - public function add( $title = '', $message = '', $parent = 0, $type = null ) { |
|
131 | + public function add($title = '', $message = '', $parent = 0, $type = null) { |
|
132 | 132 | $log_data = array( |
133 | 133 | 'post_title' => $title, |
134 | 134 | 'post_content' => $message, |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | 'log_type' => $type |
137 | 137 | ); |
138 | 138 | |
139 | - return $this->insert_log( $log_data ); |
|
139 | + return $this->insert_log($log_data); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -152,12 +152,12 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return array Array of the connected logs |
154 | 154 | */ |
155 | - public function get_logs( $object_id = 0, $type = null, $paged = null ) { |
|
156 | - return $this->get_connected_logs( array( |
|
155 | + public function get_logs($object_id = 0, $type = null, $paged = null) { |
|
156 | + return $this->get_connected_logs(array( |
|
157 | 157 | 'post_parent' => $object_id, |
158 | 158 | 'paged' => $paged, |
159 | 159 | 'log_type' => $type |
160 | - ) ); |
|
160 | + )); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return int The ID of the newly created log item |
174 | 174 | */ |
175 | - function insert_log( $log_data = array(), $log_meta = array() ) { |
|
175 | + function insert_log($log_data = array(), $log_meta = array()) { |
|
176 | 176 | $defaults = array( |
177 | 177 | 'post_type' => 'give_log', |
178 | 178 | 'post_status' => 'publish', |
@@ -181,26 +181,26 @@ discard block |
||
181 | 181 | 'log_type' => false |
182 | 182 | ); |
183 | 183 | |
184 | - $args = wp_parse_args( $log_data, $defaults ); |
|
184 | + $args = wp_parse_args($log_data, $defaults); |
|
185 | 185 | |
186 | - do_action( 'give_pre_insert_log', $log_data, $log_meta ); |
|
186 | + do_action('give_pre_insert_log', $log_data, $log_meta); |
|
187 | 187 | |
188 | 188 | // Store the log entry |
189 | - $log_id = wp_insert_post( $args ); |
|
189 | + $log_id = wp_insert_post($args); |
|
190 | 190 | |
191 | 191 | // Set the log type, if any |
192 | - if ( $log_data['log_type'] && $this->valid_type( $log_data['log_type'] ) ) { |
|
193 | - wp_set_object_terms( $log_id, $log_data['log_type'], 'give_log_type', false ); |
|
192 | + if ($log_data['log_type'] && $this->valid_type($log_data['log_type'])) { |
|
193 | + wp_set_object_terms($log_id, $log_data['log_type'], 'give_log_type', false); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | // Set log meta, if any |
197 | - if ( $log_id && ! empty( $log_meta ) ) { |
|
198 | - foreach ( (array) $log_meta as $key => $meta ) { |
|
199 | - update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta ); |
|
197 | + if ($log_id && ! empty($log_meta)) { |
|
198 | + foreach ((array) $log_meta as $key => $meta) { |
|
199 | + update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta); |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | - do_action( 'give_post_insert_log', $log_id, $log_data, $log_meta ); |
|
203 | + do_action('give_post_insert_log', $log_id, $log_data, $log_meta); |
|
204 | 204 | |
205 | 205 | return $log_id; |
206 | 206 | } |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @return bool True if successful, false otherwise |
218 | 218 | */ |
219 | - public function update_log( $log_data = array(), $log_meta = array() ) { |
|
219 | + public function update_log($log_data = array(), $log_meta = array()) { |
|
220 | 220 | |
221 | - do_action( 'give_pre_update_log', $log_data, $log_meta ); |
|
221 | + do_action('give_pre_update_log', $log_data, $log_meta); |
|
222 | 222 | |
223 | 223 | $defaults = array( |
224 | 224 | 'post_type' => 'give_log', |
@@ -226,20 +226,20 @@ discard block |
||
226 | 226 | 'post_parent' => 0 |
227 | 227 | ); |
228 | 228 | |
229 | - $args = wp_parse_args( $log_data, $defaults ); |
|
229 | + $args = wp_parse_args($log_data, $defaults); |
|
230 | 230 | |
231 | 231 | // Store the log entry |
232 | - $log_id = wp_update_post( $args ); |
|
232 | + $log_id = wp_update_post($args); |
|
233 | 233 | |
234 | - if ( $log_id && ! empty( $log_meta ) ) { |
|
235 | - foreach ( (array) $log_meta as $key => $meta ) { |
|
236 | - if ( ! empty( $meta ) ) { |
|
237 | - update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta ); |
|
234 | + if ($log_id && ! empty($log_meta)) { |
|
235 | + foreach ((array) $log_meta as $key => $meta) { |
|
236 | + if ( ! empty($meta)) { |
|
237 | + update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta); |
|
238 | 238 | } |
239 | 239 | } |
240 | 240 | } |
241 | 241 | |
242 | - do_action( 'give_post_update_log', $log_id, $log_data, $log_meta ); |
|
242 | + do_action('give_post_update_log', $log_id, $log_data, $log_meta); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
@@ -254,19 +254,19 @@ discard block |
||
254 | 254 | * |
255 | 255 | * @return mixed array if logs were found, false otherwise |
256 | 256 | */ |
257 | - public function get_connected_logs( $args = array() ) { |
|
257 | + public function get_connected_logs($args = array()) { |
|
258 | 258 | |
259 | 259 | $defaults = array( |
260 | 260 | 'post_type' => 'give_log', |
261 | 261 | 'posts_per_page' => 20, |
262 | 262 | 'post_status' => 'publish', |
263 | - 'paged' => get_query_var( 'paged' ), |
|
263 | + 'paged' => get_query_var('paged'), |
|
264 | 264 | 'log_type' => false |
265 | 265 | ); |
266 | 266 | |
267 | - $query_args = wp_parse_args( $args, $defaults ); |
|
267 | + $query_args = wp_parse_args($args, $defaults); |
|
268 | 268 | |
269 | - if ( $query_args['log_type'] && $this->valid_type( $query_args['log_type'] ) ) { |
|
269 | + if ($query_args['log_type'] && $this->valid_type($query_args['log_type'])) { |
|
270 | 270 | $query_args['tax_query'] = array( |
271 | 271 | array( |
272 | 272 | 'taxonomy' => 'give_log_type', |
@@ -276,9 +276,9 @@ discard block |
||
276 | 276 | ); |
277 | 277 | } |
278 | 278 | |
279 | - $logs = get_posts( $query_args ); |
|
279 | + $logs = get_posts($query_args); |
|
280 | 280 | |
281 | - if ( $logs ) { |
|
281 | + if ($logs) { |
|
282 | 282 | return $logs; |
283 | 283 | } |
284 | 284 | |
@@ -299,17 +299,17 @@ discard block |
||
299 | 299 | * |
300 | 300 | * @return int Log count |
301 | 301 | */ |
302 | - public function get_log_count( $object_id = 0, $type = null, $meta_query = null, $date_query = null ) { |
|
302 | + public function get_log_count($object_id = 0, $type = null, $meta_query = null, $date_query = null) { |
|
303 | 303 | |
304 | 304 | $query_args = array( |
305 | 305 | 'post_parent' => $object_id, |
306 | 306 | 'post_type' => 'give_log', |
307 | - 'posts_per_page' => - 1, |
|
307 | + 'posts_per_page' => -1, |
|
308 | 308 | 'post_status' => 'publish', |
309 | 309 | 'fields' => 'ids', |
310 | 310 | ); |
311 | 311 | |
312 | - if ( ! empty( $type ) && $this->valid_type( $type ) ) { |
|
312 | + if ( ! empty($type) && $this->valid_type($type)) { |
|
313 | 313 | $query_args['tax_query'] = array( |
314 | 314 | array( |
315 | 315 | 'taxonomy' => 'give_log_type', |
@@ -319,15 +319,15 @@ discard block |
||
319 | 319 | ); |
320 | 320 | } |
321 | 321 | |
322 | - if ( ! empty( $meta_query ) ) { |
|
322 | + if ( ! empty($meta_query)) { |
|
323 | 323 | $query_args['meta_query'] = $meta_query; |
324 | 324 | } |
325 | 325 | |
326 | - if ( ! empty( $date_query ) ) { |
|
326 | + if ( ! empty($date_query)) { |
|
327 | 327 | $query_args['date_query'] = $date_query; |
328 | 328 | } |
329 | 329 | |
330 | - $logs = new WP_Query( $query_args ); |
|
330 | + $logs = new WP_Query($query_args); |
|
331 | 331 | |
332 | 332 | return (int) $logs->post_count; |
333 | 333 | } |
@@ -345,16 +345,16 @@ discard block |
||
345 | 345 | * |
346 | 346 | * @return void |
347 | 347 | */ |
348 | - public function delete_logs( $object_id = 0, $type = null, $meta_query = null ) { |
|
348 | + public function delete_logs($object_id = 0, $type = null, $meta_query = null) { |
|
349 | 349 | $query_args = array( |
350 | 350 | 'post_parent' => $object_id, |
351 | 351 | 'post_type' => 'give_log', |
352 | - 'posts_per_page' => - 1, |
|
352 | + 'posts_per_page' => -1, |
|
353 | 353 | 'post_status' => 'publish', |
354 | 354 | 'fields' => 'ids' |
355 | 355 | ); |
356 | 356 | |
357 | - if ( ! empty( $type ) && $this->valid_type( $type ) ) { |
|
357 | + if ( ! empty($type) && $this->valid_type($type)) { |
|
358 | 358 | $query_args['tax_query'] = array( |
359 | 359 | array( |
360 | 360 | 'taxonomy' => 'give_log_type', |
@@ -364,15 +364,15 @@ discard block |
||
364 | 364 | ); |
365 | 365 | } |
366 | 366 | |
367 | - if ( ! empty( $meta_query ) ) { |
|
367 | + if ( ! empty($meta_query)) { |
|
368 | 368 | $query_args['meta_query'] = $meta_query; |
369 | 369 | } |
370 | 370 | |
371 | - $logs = get_posts( $query_args ); |
|
371 | + $logs = get_posts($query_args); |
|
372 | 372 | |
373 | - if ( $logs ) { |
|
374 | - foreach ( $logs as $log ) { |
|
375 | - wp_delete_post( $log, true ); |
|
373 | + if ($logs) { |
|
374 | + foreach ($logs as $log) { |
|
375 | + wp_delete_post($log, true); |
|
376 | 376 | } |
377 | 377 | } |
378 | 378 | } |
@@ -400,9 +400,9 @@ discard block |
||
400 | 400 | * |
401 | 401 | * @return mixed ID of the new log entry |
402 | 402 | */ |
403 | -function give_record_log( $title = '', $message = '', $parent = 0, $type = null ) { |
|
403 | +function give_record_log($title = '', $message = '', $parent = 0, $type = null) { |
|
404 | 404 | global $give_logs; |
405 | - $log = $give_logs->add( $title, $message, $parent, $type ); |
|
405 | + $log = $give_logs->add($title, $message, $parent, $type); |
|
406 | 406 | |
407 | 407 | return $log; |
408 | 408 | } |
409 | 409 | \ 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 | |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return bool true if has variable prices, false otherwise |
25 | 25 | */ |
26 | -function give_has_variable_prices( $form_id = 0 ) { |
|
26 | +function give_has_variable_prices($form_id = 0) { |
|
27 | 27 | |
28 | - if ( empty( $form_id ) ) { |
|
28 | + if (empty($form_id)) { |
|
29 | 29 | return false; |
30 | 30 | } |
31 | 31 | |
32 | - $form = new Give_Donate_Form( $form_id ); |
|
32 | + $form = new Give_Donate_Form($form_id); |
|
33 | 33 | |
34 | 34 | return $form->has_variable_prices(); |
35 | 35 | } |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return array Variable prices |
46 | 46 | */ |
47 | -function give_get_variable_prices( $form_id = 0 ) { |
|
47 | +function give_get_variable_prices($form_id = 0) { |
|
48 | 48 | |
49 | - if ( empty( $form_id ) ) { |
|
49 | + if (empty($form_id)) { |
|
50 | 50 | return false; |
51 | 51 | } |
52 | 52 | |
53 | - $form = new Give_Donate_Form( $form_id ); |
|
53 | + $form = new Give_Donate_Form($form_id); |
|
54 | 54 | |
55 | 55 | return $form->prices; |
56 | 56 | |
@@ -67,13 +67,13 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return string $default_price |
69 | 69 | */ |
70 | -function give_get_default_multilevel_amount( $form_id ) { |
|
70 | +function give_get_default_multilevel_amount($form_id) { |
|
71 | 71 | $default_price = '1.00'; |
72 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
72 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
73 | 73 | |
74 | - foreach ( $prices as $price ) { |
|
74 | + foreach ($prices as $price) { |
|
75 | 75 | |
76 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
76 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
77 | 77 | $default_price = $price['_give_amount']; |
78 | 78 | } |
79 | 79 | |
@@ -94,15 +94,15 @@ discard block |
||
94 | 94 | * @return string $default_price |
95 | 95 | * @since 1.0 |
96 | 96 | */ |
97 | -function give_get_default_form_amount( $form_id ) { |
|
97 | +function give_get_default_form_amount($form_id) { |
|
98 | 98 | |
99 | - if ( give_has_variable_prices( $form_id ) ) { |
|
99 | + if (give_has_variable_prices($form_id)) { |
|
100 | 100 | |
101 | - $default_amount = give_get_default_multilevel_amount( $form_id ); |
|
101 | + $default_amount = give_get_default_multilevel_amount($form_id); |
|
102 | 102 | |
103 | 103 | } else { |
104 | 104 | |
105 | - $default_amount = get_post_meta( $form_id, '_give_set_price', true ); |
|
105 | + $default_amount = get_post_meta($form_id, '_give_set_price', true); |
|
106 | 106 | |
107 | 107 | } |
108 | 108 | |
@@ -123,13 +123,13 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @return bool |
125 | 125 | */ |
126 | -function give_is_custom_price_mode( $form_id = 0 ) { |
|
126 | +function give_is_custom_price_mode($form_id = 0) { |
|
127 | 127 | |
128 | - if ( empty( $form_id ) ) { |
|
128 | + if (empty($form_id)) { |
|
129 | 129 | return false; |
130 | 130 | } |
131 | 131 | |
132 | - $form = new Give_Donate_Form( $form_id ); |
|
132 | + $form = new Give_Donate_Form($form_id); |
|
133 | 133 | |
134 | 134 | return $form->is_custom_price_mode(); |
135 | 135 | } |
136 | 136 | \ No newline at end of file |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | // Retrieve the payment ID |
38 | 38 | $payment_id = absint( $data['give_payment_id'] ); |
39 | 39 | |
40 | - /* @var Give_Payment $payment */ |
|
40 | + /* @var Give_Payment $payment */ |
|
41 | 41 | $payment = new Give_Payment( $payment_id ); |
42 | 42 | |
43 | 43 | // Retrieve existing payment meta |
@@ -151,9 +151,9 @@ discard block |
||
151 | 151 | $previous_customer->remove_payment( $payment_id, false ); |
152 | 152 | $customer->attach_payment( $payment_id, false ); |
153 | 153 | |
154 | - // Reduce previous user donation count and amoount. |
|
155 | - $previous_customer->decrease_purchase_count(); |
|
156 | - $previous_customer->decrease_value( $curr_total ); |
|
154 | + // Reduce previous user donation count and amoount. |
|
155 | + $previous_customer->decrease_purchase_count(); |
|
156 | + $previous_customer->decrease_value( $curr_total ); |
|
157 | 157 | |
158 | 158 | // If purchase was completed and not ever refunded, adjust stats of new customers. |
159 | 159 | if ( 'revoked' == $status || 'publish' == $status ) { |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | } else{ |
166 | 166 | // Update user donation stat. |
167 | 167 | $customer->update_donation_value( $curr_total, $new_total ); |
168 | - } |
|
168 | + } |
|
169 | 169 | |
170 | 170 | // Set new meta values |
171 | 171 | $payment->user_id = $customer->user_id; |
@@ -206,76 +206,76 @@ discard block |
||
206 | 206 | |
207 | 207 | $payment->save(); |
208 | 208 | |
209 | - // Get new give form ID. |
|
210 | - $new_form_id = absint( $data['forms'] ); |
|
211 | - $current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) ); |
|
209 | + // Get new give form ID. |
|
210 | + $new_form_id = absint( $data['forms'] ); |
|
211 | + $current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) ); |
|
212 | 212 | |
213 | - // We are adding payment transfer code in last to remove any conflict with above functionality. |
|
214 | - // For example: above code will automatically handle form stat (increase/decrease) when payment status changes. |
|
215 | - /* Check if user want to transfer current payment to new give form id. */ |
|
216 | - if( $new_form_id != $current_form_id ) { |
|
213 | + // We are adding payment transfer code in last to remove any conflict with above functionality. |
|
214 | + // For example: above code will automatically handle form stat (increase/decrease) when payment status changes. |
|
215 | + /* Check if user want to transfer current payment to new give form id. */ |
|
216 | + if( $new_form_id != $current_form_id ) { |
|
217 | 217 | |
218 | - // Get new give form title. |
|
219 | - $new_form_title = get_the_title( $new_form_id ); |
|
218 | + // Get new give form title. |
|
219 | + $new_form_title = get_the_title( $new_form_id ); |
|
220 | 220 | |
221 | - // Update new give form data in payment data. |
|
222 | - $payment_meta = $payment->get_meta(); |
|
223 | - $payment_meta['form_title'] = $new_form_title; |
|
224 | - $payment_meta['form_id'] = $new_form_id; |
|
221 | + // Update new give form data in payment data. |
|
222 | + $payment_meta = $payment->get_meta(); |
|
223 | + $payment_meta['form_title'] = $new_form_title; |
|
224 | + $payment_meta['form_id'] = $new_form_id; |
|
225 | 225 | |
226 | - // Update price id post meta data for set donation form. |
|
227 | - if( ! give_has_variable_prices( $new_form_id ) ) { |
|
228 | - $payment_meta['price_id'] = ''; |
|
229 | - } |
|
226 | + // Update price id post meta data for set donation form. |
|
227 | + if( ! give_has_variable_prices( $new_form_id ) ) { |
|
228 | + $payment_meta['price_id'] = ''; |
|
229 | + } |
|
230 | 230 | |
231 | - // Update payment give form meta data. |
|
232 | - $payment->update_meta( '_give_payment_form_id', $new_form_id ); |
|
233 | - $payment->update_meta( '_give_payment_form_title', $new_form_title ); |
|
234 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
231 | + // Update payment give form meta data. |
|
232 | + $payment->update_meta( '_give_payment_form_id', $new_form_id ); |
|
233 | + $payment->update_meta( '_give_payment_form_title', $new_form_title ); |
|
234 | + $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
235 | 235 | |
236 | - // Update price id payment metadata. |
|
237 | - if( ! give_has_variable_prices( $new_form_id ) ) { |
|
238 | - $payment->update_meta( '_give_payment_price_id', '' ); |
|
239 | - } |
|
236 | + // Update price id payment metadata. |
|
237 | + if( ! give_has_variable_prices( $new_form_id ) ) { |
|
238 | + $payment->update_meta( '_give_payment_price_id', '' ); |
|
239 | + } |
|
240 | 240 | |
241 | 241 | |
242 | - // If purchase was completed and not ever refunded, adjust stats of forms |
|
243 | - if ( 'revoked' == $status || 'publish' == $status ) { |
|
242 | + // If purchase was completed and not ever refunded, adjust stats of forms |
|
243 | + if ( 'revoked' == $status || 'publish' == $status ) { |
|
244 | 244 | |
245 | - // Decrease sale of old give form. For other payment status |
|
246 | - $current_form = new Give_Donate_Form( $current_form_id ); |
|
247 | - $current_form->decrease_sales(); |
|
248 | - $current_form->decrease_earnings( $curr_total ); |
|
245 | + // Decrease sale of old give form. For other payment status |
|
246 | + $current_form = new Give_Donate_Form( $current_form_id ); |
|
247 | + $current_form->decrease_sales(); |
|
248 | + $current_form->decrease_earnings( $curr_total ); |
|
249 | 249 | |
250 | - // Increase sale of new give form. |
|
251 | - $new_form = new Give_Donate_Form($new_form_id); |
|
252 | - $new_form->increase_sales(); |
|
253 | - $new_form->increase_earnings($new_total); |
|
254 | - } |
|
250 | + // Increase sale of new give form. |
|
251 | + $new_form = new Give_Donate_Form($new_form_id); |
|
252 | + $new_form->increase_sales(); |
|
253 | + $new_form->increase_earnings($new_total); |
|
254 | + } |
|
255 | 255 | |
256 | - // Re setup payment to update new meta value in object. |
|
257 | - $payment->update_payment_setup( $payment->ID ); |
|
258 | - } |
|
256 | + // Re setup payment to update new meta value in object. |
|
257 | + $payment->update_payment_setup( $payment->ID ); |
|
258 | + } |
|
259 | 259 | |
260 | - // Update price id if current form is variable form. |
|
261 | - if( ! empty( $data['give-variable-price'] ) && give_has_variable_prices( $payment->form_id ) ) { |
|
260 | + // Update price id if current form is variable form. |
|
261 | + if( ! empty( $data['give-variable-price'] ) && give_has_variable_prices( $payment->form_id ) ) { |
|
262 | 262 | |
263 | - // Get payment meta data. |
|
264 | - $payment_meta = $payment->get_meta(); |
|
263 | + // Get payment meta data. |
|
264 | + $payment_meta = $payment->get_meta(); |
|
265 | 265 | |
266 | - // Set payment id to empty string if variable price id is negative ( i.e. custom amount feature enabled ). |
|
267 | - $data['give-variable-price'] = ( 'custom' === $data['give-variable-price'] ) ? 'custom' : ( 0 < $data['give-variable-price'] ) ? $data['give-variable-price'] : ''; |
|
266 | + // Set payment id to empty string if variable price id is negative ( i.e. custom amount feature enabled ). |
|
267 | + $data['give-variable-price'] = ( 'custom' === $data['give-variable-price'] ) ? 'custom' : ( 0 < $data['give-variable-price'] ) ? $data['give-variable-price'] : ''; |
|
268 | 268 | |
269 | - // Update payment meta data. |
|
270 | - $payment_meta['price_id'] = $data['give-variable-price']; |
|
269 | + // Update payment meta data. |
|
270 | + $payment_meta['price_id'] = $data['give-variable-price']; |
|
271 | 271 | |
272 | - // Update payment give form meta data. |
|
273 | - $payment->update_meta( '_give_payment_price_id', $data['give-variable-price'] ); |
|
274 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
272 | + // Update payment give form meta data. |
|
273 | + $payment->update_meta( '_give_payment_price_id', $data['give-variable-price'] ); |
|
274 | + $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
275 | 275 | |
276 | - // Re setup payment to update new meta value in object. |
|
277 | - $payment->update_payment_setup( $payment->ID ); |
|
278 | - } |
|
276 | + // Re setup payment to update new meta value in object. |
|
277 | + $payment->update_payment_setup( $payment->ID ); |
|
278 | + } |
|
279 | 279 | |
280 | 280 | do_action( 'give_updated_edited_purchase', $payment_id ); |
281 | 281 |
@@ -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 | |
@@ -26,109 +26,109 @@ discard block |
||
26 | 26 | * @return void |
27 | 27 | * |
28 | 28 | */ |
29 | -function give_update_payment_details( $data ) { |
|
29 | +function give_update_payment_details($data) { |
|
30 | 30 | |
31 | - if ( ! current_user_can( 'edit_give_payments', $data['give_payment_id'] ) ) { |
|
32 | - wp_die( esc_html__( 'You do not have permission to edit payment records.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
31 | + if ( ! current_user_can('edit_give_payments', $data['give_payment_id'])) { |
|
32 | + wp_die(esc_html__('You do not have permission to edit payment records.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
33 | 33 | } |
34 | 34 | |
35 | - check_admin_referer( 'give_update_payment_details_nonce' ); |
|
35 | + check_admin_referer('give_update_payment_details_nonce'); |
|
36 | 36 | |
37 | 37 | // Retrieve the payment ID |
38 | - $payment_id = absint( $data['give_payment_id'] ); |
|
38 | + $payment_id = absint($data['give_payment_id']); |
|
39 | 39 | |
40 | 40 | /* @var Give_Payment $payment */ |
41 | - $payment = new Give_Payment( $payment_id ); |
|
41 | + $payment = new Give_Payment($payment_id); |
|
42 | 42 | |
43 | 43 | // Retrieve existing payment meta |
44 | 44 | $meta = $payment->get_meta(); |
45 | 45 | $user_info = $payment->user_info; |
46 | 46 | |
47 | 47 | $status = $data['give-payment-status']; |
48 | - $date = sanitize_text_field( $data['give-payment-date'] ); |
|
49 | - $hour = sanitize_text_field( $data['give-payment-time-hour'] ); |
|
48 | + $date = sanitize_text_field($data['give-payment-date']); |
|
49 | + $hour = sanitize_text_field($data['give-payment-time-hour']); |
|
50 | 50 | |
51 | 51 | // Restrict to our high and low |
52 | - if ( $hour > 23 ) { |
|
52 | + if ($hour > 23) { |
|
53 | 53 | $hour = 23; |
54 | - } elseif ( $hour < 0 ) { |
|
54 | + } elseif ($hour < 0) { |
|
55 | 55 | $hour = 00; |
56 | 56 | } |
57 | 57 | |
58 | - $minute = sanitize_text_field( $data['give-payment-time-min'] ); |
|
58 | + $minute = sanitize_text_field($data['give-payment-time-min']); |
|
59 | 59 | |
60 | 60 | // Restrict to our high and low |
61 | - if ( $minute > 59 ) { |
|
61 | + if ($minute > 59) { |
|
62 | 62 | $minute = 59; |
63 | - } elseif ( $minute < 0 ) { |
|
63 | + } elseif ($minute < 0) { |
|
64 | 64 | $minute = 00; |
65 | 65 | } |
66 | 66 | |
67 | - $address = array_map( 'trim', $data['give-payment-address'][0] ); |
|
67 | + $address = array_map('trim', $data['give-payment-address'][0]); |
|
68 | 68 | |
69 | - $curr_total = give_sanitize_amount( $payment->total ); |
|
70 | - $new_total = give_sanitize_amount( $data['give-payment-total'] ); |
|
71 | - $date = date( 'Y-m-d', strtotime( $date ) ) . ' ' . $hour . ':' . $minute . ':00'; |
|
69 | + $curr_total = give_sanitize_amount($payment->total); |
|
70 | + $new_total = give_sanitize_amount($data['give-payment-total']); |
|
71 | + $date = date('Y-m-d', strtotime($date)).' '.$hour.':'.$minute.':00'; |
|
72 | 72 | |
73 | - $curr_customer_id = sanitize_text_field( $data['give-current-customer'] ); |
|
74 | - $new_customer_id = sanitize_text_field( $data['customer-id'] ); |
|
73 | + $curr_customer_id = sanitize_text_field($data['give-current-customer']); |
|
74 | + $new_customer_id = sanitize_text_field($data['customer-id']); |
|
75 | 75 | |
76 | - do_action( 'give_update_edited_purchase', $payment_id ); |
|
76 | + do_action('give_update_edited_purchase', $payment_id); |
|
77 | 77 | |
78 | 78 | $payment->date = $date; |
79 | 79 | $updated = $payment->save(); |
80 | 80 | |
81 | - if ( 0 === $updated ) { |
|
82 | - wp_die( esc_html__( 'Error Updating Payment.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
81 | + if (0 === $updated) { |
|
82 | + wp_die(esc_html__('Error Updating Payment.', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | |
86 | 86 | $customer_changed = false; |
87 | 87 | |
88 | - if ( isset( $data['give-new-customer'] ) && $data['give-new-customer'] == '1' ) { |
|
88 | + if (isset($data['give-new-customer']) && $data['give-new-customer'] == '1') { |
|
89 | 89 | |
90 | - $email = isset( $data['give-new-customer-email'] ) ? sanitize_text_field( $data['give-new-customer-email'] ) : ''; |
|
91 | - $names = isset( $data['give-new-customer-name'] ) ? sanitize_text_field( $data['give-new-customer-name'] ) : ''; |
|
90 | + $email = isset($data['give-new-customer-email']) ? sanitize_text_field($data['give-new-customer-email']) : ''; |
|
91 | + $names = isset($data['give-new-customer-name']) ? sanitize_text_field($data['give-new-customer-name']) : ''; |
|
92 | 92 | |
93 | - if ( empty( $email ) || empty( $names ) ) { |
|
94 | - wp_die( esc_html__( 'New Customers require a name and email address.', 'give' ) ); |
|
93 | + if (empty($email) || empty($names)) { |
|
94 | + wp_die(esc_html__('New Customers require a name and email address.', 'give')); |
|
95 | 95 | } |
96 | 96 | |
97 | - $customer = new Give_Customer( $email ); |
|
98 | - if ( empty( $customer->id ) ) { |
|
99 | - $customer_data = array( 'name' => $names, 'email' => $email ); |
|
100 | - $user_id = email_exists( $email ); |
|
101 | - if ( false !== $user_id ) { |
|
97 | + $customer = new Give_Customer($email); |
|
98 | + if (empty($customer->id)) { |
|
99 | + $customer_data = array('name' => $names, 'email' => $email); |
|
100 | + $user_id = email_exists($email); |
|
101 | + if (false !== $user_id) { |
|
102 | 102 | $customer_data['user_id'] = $user_id; |
103 | 103 | } |
104 | 104 | |
105 | - if ( ! $customer->create( $customer_data ) ) { |
|
105 | + if ( ! $customer->create($customer_data)) { |
|
106 | 106 | // Failed to crete the new donor, assume the previous donor |
107 | 107 | $customer_changed = false; |
108 | - $customer = new Give_Customer( $curr_customer_id ); |
|
109 | - give_set_error( 'give-payment-new-customer-fail', esc_html__( 'Error creating new donor.', 'give' ) ); |
|
108 | + $customer = new Give_Customer($curr_customer_id); |
|
109 | + give_set_error('give-payment-new-customer-fail', esc_html__('Error creating new donor.', 'give')); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
113 | 113 | $new_customer_id = $customer->id; |
114 | 114 | |
115 | - $previous_customer = new Give_Customer( $curr_customer_id ); |
|
115 | + $previous_customer = new Give_Customer($curr_customer_id); |
|
116 | 116 | |
117 | 117 | $customer_changed = true; |
118 | 118 | |
119 | - } elseif ( $curr_customer_id !== $new_customer_id ) { |
|
119 | + } elseif ($curr_customer_id !== $new_customer_id) { |
|
120 | 120 | |
121 | - $customer = new Give_Customer( $new_customer_id ); |
|
121 | + $customer = new Give_Customer($new_customer_id); |
|
122 | 122 | $email = $customer->email; |
123 | 123 | $names = $customer->name; |
124 | 124 | |
125 | - $previous_customer = new Give_Customer( $curr_customer_id ); |
|
125 | + $previous_customer = new Give_Customer($curr_customer_id); |
|
126 | 126 | |
127 | 127 | $customer_changed = true; |
128 | 128 | |
129 | 129 | } else { |
130 | 130 | |
131 | - $customer = new Give_Customer( $curr_customer_id ); |
|
131 | + $customer = new Give_Customer($curr_customer_id); |
|
132 | 132 | $email = $customer->email; |
133 | 133 | $names = $customer->name; |
134 | 134 | |
@@ -136,35 +136,35 @@ discard block |
||
136 | 136 | |
137 | 137 | |
138 | 138 | // Setup first and last name from input values |
139 | - $names = explode( ' ', $names ); |
|
140 | - $first_name = ! empty( $names[0] ) ? $names[0] : ''; |
|
139 | + $names = explode(' ', $names); |
|
140 | + $first_name = ! empty($names[0]) ? $names[0] : ''; |
|
141 | 141 | $last_name = ''; |
142 | - if ( ! empty( $names[1] ) ) { |
|
143 | - unset( $names[0] ); |
|
144 | - $last_name = implode( ' ', $names ); |
|
142 | + if ( ! empty($names[1])) { |
|
143 | + unset($names[0]); |
|
144 | + $last_name = implode(' ', $names); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | |
148 | - if ( $customer_changed ) { |
|
148 | + if ($customer_changed) { |
|
149 | 149 | |
150 | 150 | // Remove the stats and payment from the previous customer and attach it to the new customer |
151 | - $previous_customer->remove_payment( $payment_id, false ); |
|
152 | - $customer->attach_payment( $payment_id, false ); |
|
151 | + $previous_customer->remove_payment($payment_id, false); |
|
152 | + $customer->attach_payment($payment_id, false); |
|
153 | 153 | |
154 | 154 | // Reduce previous user donation count and amoount. |
155 | 155 | $previous_customer->decrease_purchase_count(); |
156 | - $previous_customer->decrease_value( $curr_total ); |
|
156 | + $previous_customer->decrease_value($curr_total); |
|
157 | 157 | |
158 | 158 | // If purchase was completed and not ever refunded, adjust stats of new customers. |
159 | - if ( 'revoked' == $status || 'publish' == $status ) { |
|
159 | + if ('revoked' == $status || 'publish' == $status) { |
|
160 | 160 | $customer->increase_purchase_count(); |
161 | - $customer->increase_value( $new_total ); |
|
161 | + $customer->increase_value($new_total); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | $payment->customer_id = $customer->id; |
165 | - } else{ |
|
165 | + } else { |
|
166 | 166 | // Update user donation stat. |
167 | - $customer->update_donation_value( $curr_total, $new_total ); |
|
167 | + $customer->update_donation_value($curr_total, $new_total); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | // Set new meta values |
@@ -177,10 +177,10 @@ discard block |
||
177 | 177 | |
178 | 178 | |
179 | 179 | // Check for payment notes |
180 | - if ( ! empty( $data['give-payment-note'] ) ) { |
|
180 | + if ( ! empty($data['give-payment-note'])) { |
|
181 | 181 | |
182 | - $note = wp_kses( $data['give-payment-note'], array() ); |
|
183 | - give_insert_payment_note( $payment_id, $note ); |
|
182 | + $note = wp_kses($data['give-payment-note'], array()); |
|
183 | + give_insert_payment_note($payment_id, $note); |
|
184 | 184 | |
185 | 185 | } |
186 | 186 | |
@@ -188,17 +188,17 @@ discard block |
||
188 | 188 | $payment->status = $status; |
189 | 189 | |
190 | 190 | // Adjust total store earnings if the payment total has been changed |
191 | - if ( $new_total !== $curr_total && ( 'publish' == $status || 'revoked' == $status ) ) { |
|
191 | + if ($new_total !== $curr_total && ('publish' == $status || 'revoked' == $status)) { |
|
192 | 192 | |
193 | - if ( $new_total > $curr_total ) { |
|
193 | + if ($new_total > $curr_total) { |
|
194 | 194 | // Increase if our new total is higher |
195 | 195 | $difference = $new_total - $curr_total; |
196 | - give_increase_total_earnings( $difference ); |
|
196 | + give_increase_total_earnings($difference); |
|
197 | 197 | |
198 | - } elseif ( $curr_total > $new_total ) { |
|
198 | + } elseif ($curr_total > $new_total) { |
|
199 | 199 | // Decrease if our new total is lower |
200 | 200 | $difference = $curr_total - $new_total; |
201 | - give_decrease_total_earnings( $difference ); |
|
201 | + give_decrease_total_earnings($difference); |
|
202 | 202 | |
203 | 203 | } |
204 | 204 | |
@@ -207,16 +207,16 @@ discard block |
||
207 | 207 | $payment->save(); |
208 | 208 | |
209 | 209 | // Get new give form ID. |
210 | - $new_form_id = absint( $data['forms'] ); |
|
211 | - $current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) ); |
|
210 | + $new_form_id = absint($data['forms']); |
|
211 | + $current_form_id = absint($payment->get_meta('_give_payment_form_id')); |
|
212 | 212 | |
213 | 213 | // We are adding payment transfer code in last to remove any conflict with above functionality. |
214 | 214 | // For example: above code will automatically handle form stat (increase/decrease) when payment status changes. |
215 | 215 | /* Check if user want to transfer current payment to new give form id. */ |
216 | - if( $new_form_id != $current_form_id ) { |
|
216 | + if ($new_form_id != $current_form_id) { |
|
217 | 217 | |
218 | 218 | // Get new give form title. |
219 | - $new_form_title = get_the_title( $new_form_id ); |
|
219 | + $new_form_title = get_the_title($new_form_id); |
|
220 | 220 | |
221 | 221 | // Update new give form data in payment data. |
222 | 222 | $payment_meta = $payment->get_meta(); |
@@ -224,28 +224,28 @@ discard block |
||
224 | 224 | $payment_meta['form_id'] = $new_form_id; |
225 | 225 | |
226 | 226 | // Update price id post meta data for set donation form. |
227 | - if( ! give_has_variable_prices( $new_form_id ) ) { |
|
227 | + if ( ! give_has_variable_prices($new_form_id)) { |
|
228 | 228 | $payment_meta['price_id'] = ''; |
229 | 229 | } |
230 | 230 | |
231 | 231 | // Update payment give form meta data. |
232 | - $payment->update_meta( '_give_payment_form_id', $new_form_id ); |
|
233 | - $payment->update_meta( '_give_payment_form_title', $new_form_title ); |
|
234 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
232 | + $payment->update_meta('_give_payment_form_id', $new_form_id); |
|
233 | + $payment->update_meta('_give_payment_form_title', $new_form_title); |
|
234 | + $payment->update_meta('_give_payment_meta', $payment_meta); |
|
235 | 235 | |
236 | 236 | // Update price id payment metadata. |
237 | - if( ! give_has_variable_prices( $new_form_id ) ) { |
|
238 | - $payment->update_meta( '_give_payment_price_id', '' ); |
|
237 | + if ( ! give_has_variable_prices($new_form_id)) { |
|
238 | + $payment->update_meta('_give_payment_price_id', ''); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | |
242 | 242 | // If purchase was completed and not ever refunded, adjust stats of forms |
243 | - if ( 'revoked' == $status || 'publish' == $status ) { |
|
243 | + if ('revoked' == $status || 'publish' == $status) { |
|
244 | 244 | |
245 | 245 | // Decrease sale of old give form. For other payment status |
246 | - $current_form = new Give_Donate_Form( $current_form_id ); |
|
246 | + $current_form = new Give_Donate_Form($current_form_id); |
|
247 | 247 | $current_form->decrease_sales(); |
248 | - $current_form->decrease_earnings( $curr_total ); |
|
248 | + $current_form->decrease_earnings($curr_total); |
|
249 | 249 | |
250 | 250 | // Increase sale of new give form. |
251 | 251 | $new_form = new Give_Donate_Form($new_form_id); |
@@ -254,36 +254,36 @@ discard block |
||
254 | 254 | } |
255 | 255 | |
256 | 256 | // Re setup payment to update new meta value in object. |
257 | - $payment->update_payment_setup( $payment->ID ); |
|
257 | + $payment->update_payment_setup($payment->ID); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | // Update price id if current form is variable form. |
261 | - if( ! empty( $data['give-variable-price'] ) && give_has_variable_prices( $payment->form_id ) ) { |
|
261 | + if ( ! empty($data['give-variable-price']) && give_has_variable_prices($payment->form_id)) { |
|
262 | 262 | |
263 | 263 | // Get payment meta data. |
264 | 264 | $payment_meta = $payment->get_meta(); |
265 | 265 | |
266 | 266 | // Set payment id to empty string if variable price id is negative ( i.e. custom amount feature enabled ). |
267 | - $data['give-variable-price'] = ( 'custom' === $data['give-variable-price'] ) ? 'custom' : ( 0 < $data['give-variable-price'] ) ? $data['give-variable-price'] : ''; |
|
267 | + $data['give-variable-price'] = ('custom' === $data['give-variable-price']) ? 'custom' : (0 < $data['give-variable-price']) ? $data['give-variable-price'] : ''; |
|
268 | 268 | |
269 | 269 | // Update payment meta data. |
270 | 270 | $payment_meta['price_id'] = $data['give-variable-price']; |
271 | 271 | |
272 | 272 | // Update payment give form meta data. |
273 | - $payment->update_meta( '_give_payment_price_id', $data['give-variable-price'] ); |
|
274 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
273 | + $payment->update_meta('_give_payment_price_id', $data['give-variable-price']); |
|
274 | + $payment->update_meta('_give_payment_meta', $payment_meta); |
|
275 | 275 | |
276 | 276 | // Re setup payment to update new meta value in object. |
277 | - $payment->update_payment_setup( $payment->ID ); |
|
277 | + $payment->update_payment_setup($payment->ID); |
|
278 | 278 | } |
279 | 279 | |
280 | - do_action( 'give_updated_edited_purchase', $payment_id ); |
|
280 | + do_action('give_updated_edited_purchase', $payment_id); |
|
281 | 281 | |
282 | - wp_safe_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-updated&id=' . $payment_id ) ); |
|
282 | + wp_safe_redirect(admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-updated&id='.$payment_id)); |
|
283 | 283 | exit; |
284 | 284 | } |
285 | 285 | |
286 | -add_action( 'give_update_payment_details', 'give_update_payment_details' ); |
|
286 | +add_action('give_update_payment_details', 'give_update_payment_details'); |
|
287 | 287 | |
288 | 288 | /** |
289 | 289 | * Trigger a Purchase Deletion |
@@ -294,48 +294,48 @@ discard block |
||
294 | 294 | * |
295 | 295 | * @return void |
296 | 296 | */ |
297 | -function give_trigger_purchase_delete( $data ) { |
|
298 | - if ( wp_verify_nonce( $data['_wpnonce'], 'give_payment_nonce' ) ) { |
|
297 | +function give_trigger_purchase_delete($data) { |
|
298 | + if (wp_verify_nonce($data['_wpnonce'], 'give_payment_nonce')) { |
|
299 | 299 | |
300 | - $payment_id = absint( $data['purchase_id'] ); |
|
300 | + $payment_id = absint($data['purchase_id']); |
|
301 | 301 | |
302 | - if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) { |
|
303 | - wp_die( esc_html__( 'You do not have permission to edit payment records.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
302 | + if ( ! current_user_can('edit_give_payments', $payment_id)) { |
|
303 | + wp_die(esc_html__('You do not have permission to edit payment records.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
304 | 304 | } |
305 | 305 | |
306 | - give_delete_purchase( $payment_id ); |
|
307 | - wp_redirect( admin_url( '/edit.php?post_type=give_forms&page=give-payment-history&give-message=payment_deleted' ) ); |
|
306 | + give_delete_purchase($payment_id); |
|
307 | + wp_redirect(admin_url('/edit.php?post_type=give_forms&page=give-payment-history&give-message=payment_deleted')); |
|
308 | 308 | give_die(); |
309 | 309 | } |
310 | 310 | } |
311 | 311 | |
312 | -add_action( 'give_delete_payment', 'give_trigger_purchase_delete' ); |
|
312 | +add_action('give_delete_payment', 'give_trigger_purchase_delete'); |
|
313 | 313 | |
314 | 314 | /** |
315 | 315 | * AJAX Store Payment Note |
316 | 316 | */ |
317 | 317 | function give_ajax_store_payment_note() { |
318 | 318 | |
319 | - $payment_id = absint( $_POST['payment_id'] ); |
|
320 | - $note = wp_kses( $_POST['note'], array() ); |
|
319 | + $payment_id = absint($_POST['payment_id']); |
|
320 | + $note = wp_kses($_POST['note'], array()); |
|
321 | 321 | |
322 | - if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) { |
|
323 | - wp_die( esc_html__( 'You do not have permission to edit payment records.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
322 | + if ( ! current_user_can('edit_give_payments', $payment_id)) { |
|
323 | + wp_die(esc_html__('You do not have permission to edit payment records.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
324 | 324 | } |
325 | 325 | |
326 | - if ( empty( $payment_id ) ) { |
|
327 | - die( '-1' ); |
|
326 | + if (empty($payment_id)) { |
|
327 | + die('-1'); |
|
328 | 328 | } |
329 | 329 | |
330 | - if ( empty( $note ) ) { |
|
331 | - die( '-1' ); |
|
330 | + if (empty($note)) { |
|
331 | + die('-1'); |
|
332 | 332 | } |
333 | 333 | |
334 | - $note_id = give_insert_payment_note( $payment_id, $note ); |
|
335 | - die( give_get_payment_note_html( $note_id ) ); |
|
334 | + $note_id = give_insert_payment_note($payment_id, $note); |
|
335 | + die(give_get_payment_note_html($note_id)); |
|
336 | 336 | } |
337 | 337 | |
338 | -add_action( 'wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note' ); |
|
338 | +add_action('wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note'); |
|
339 | 339 | |
340 | 340 | /** |
341 | 341 | * Triggers a payment note deletion without ajax |
@@ -346,24 +346,24 @@ discard block |
||
346 | 346 | * |
347 | 347 | * @return void |
348 | 348 | */ |
349 | -function give_trigger_payment_note_deletion( $data ) { |
|
349 | +function give_trigger_payment_note_deletion($data) { |
|
350 | 350 | |
351 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_delete_payment_note_' . $data['note_id'] ) ) { |
|
351 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give_delete_payment_note_'.$data['note_id'])) { |
|
352 | 352 | return; |
353 | 353 | } |
354 | 354 | |
355 | - if ( ! current_user_can( 'edit_give_payments', $data['payment_id'] ) ) { |
|
356 | - wp_die( esc_html__( 'You do not have permission to edit payment records.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
355 | + if ( ! current_user_can('edit_give_payments', $data['payment_id'])) { |
|
356 | + wp_die(esc_html__('You do not have permission to edit payment records.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
357 | 357 | } |
358 | 358 | |
359 | - $edit_order_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-note-deleted&id=' . absint( $data['payment_id'] ) ); |
|
359 | + $edit_order_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-note-deleted&id='.absint($data['payment_id'])); |
|
360 | 360 | |
361 | - give_delete_payment_note( $data['note_id'], $data['payment_id'] ); |
|
361 | + give_delete_payment_note($data['note_id'], $data['payment_id']); |
|
362 | 362 | |
363 | - wp_redirect( $edit_order_url ); |
|
363 | + wp_redirect($edit_order_url); |
|
364 | 364 | } |
365 | 365 | |
366 | -add_action( 'give_delete_payment_note', 'give_trigger_payment_note_deletion' ); |
|
366 | +add_action('give_delete_payment_note', 'give_trigger_payment_note_deletion'); |
|
367 | 367 | |
368 | 368 | /** |
369 | 369 | * Delete a payment note deletion with ajax |
@@ -374,16 +374,16 @@ discard block |
||
374 | 374 | */ |
375 | 375 | function give_ajax_delete_payment_note() { |
376 | 376 | |
377 | - if ( ! current_user_can( 'edit_give_payments', $_POST['payment_id'] ) ) { |
|
378 | - wp_die( esc_html__( 'You do not have permission to edit payment records.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
377 | + if ( ! current_user_can('edit_give_payments', $_POST['payment_id'])) { |
|
378 | + wp_die(esc_html__('You do not have permission to edit payment records.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
379 | 379 | } |
380 | 380 | |
381 | - if ( give_delete_payment_note( $_POST['note_id'], $_POST['payment_id'] ) ) { |
|
382 | - die( '1' ); |
|
381 | + if (give_delete_payment_note($_POST['note_id'], $_POST['payment_id'])) { |
|
382 | + die('1'); |
|
383 | 383 | } else { |
384 | - die( '-1' ); |
|
384 | + die('-1'); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | } |
388 | 388 | |
389 | -add_action( 'wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note' ); |
|
390 | 389 | \ No newline at end of file |
390 | +add_action('wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note'); |
|
391 | 391 | \ No newline at end of file |