@@ -673,7 +673,7 @@ |
||
673 | 673 | |
674 | 674 | <div id="<?php echo $setting['id']; ?>" |
675 | 675 | class="panel give_options_panel<?php echo( $show_first_tab_content ? '' : ' give-hidden' ); |
676 | - $show_first_tab_content = false; ?>"> |
|
676 | + $show_first_tab_content = false; ?>"> |
|
677 | 677 | <?php if ( ! empty( $setting['fields'] ) ) : ?> |
678 | 678 | <?php foreach ( $setting['fields'] as $field ) : ?> |
679 | 679 | <?php give_render_field( $field ); ?> |
@@ -46,24 +46,24 @@ discard block |
||
46 | 46 | */ |
47 | 47 | function __construct() { |
48 | 48 | $this->metabox_id = 'give-metabox-form-data'; |
49 | - $this->metabox_label = esc_html__( 'Donation Form Options', 'give' ); |
|
49 | + $this->metabox_label = esc_html__('Donation Form Options', 'give'); |
|
50 | 50 | |
51 | 51 | // Setup. |
52 | - add_action( 'admin_init', array( $this, 'setup' ) ); |
|
52 | + add_action('admin_init', array($this, 'setup')); |
|
53 | 53 | |
54 | 54 | // Add metabox. |
55 | - add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ), 30 ); |
|
55 | + add_action('add_meta_boxes', array($this, 'add_meta_box'), 30); |
|
56 | 56 | |
57 | 57 | // Load required scripts. |
58 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_script' ) ); |
|
58 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_script')); |
|
59 | 59 | |
60 | 60 | // Save form meta. |
61 | - add_action( 'save_post_give_forms', array( $this, 'save' ), 10, 2 ); |
|
61 | + add_action('save_post_give_forms', array($this, 'save'), 10, 2); |
|
62 | 62 | |
63 | 63 | // cmb2 old setting loaders. |
64 | 64 | // add_filter( 'give_metabox_form_data_settings', array( $this, 'cmb2_metabox_settings' ) ); |
65 | 65 | // Add offline donations options. |
66 | - add_filter( 'give_metabox_form_data_settings', array( $this, 'add_offline_donations_setting_tab' ), 0, 1 ); |
|
66 | + add_filter('give_metabox_form_data_settings', array($this, 'add_offline_donations_setting_tab'), 0, 1); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -86,18 +86,18 @@ discard block |
||
86 | 86 | */ |
87 | 87 | function get_settings() { |
88 | 88 | $post_id = give_get_admin_post_id(); |
89 | - $price = give_get_form_price( $post_id ); |
|
90 | - $custom_amount_minimum = give_get_form_minimum_price( $post_id ); |
|
91 | - $goal = give_get_form_goal( $post_id ); |
|
89 | + $price = give_get_form_price($post_id); |
|
90 | + $custom_amount_minimum = give_get_form_minimum_price($post_id); |
|
91 | + $goal = give_get_form_goal($post_id); |
|
92 | 92 | |
93 | 93 | // No empty prices - min. 1.00 for new forms |
94 | - if ( empty( $price ) && is_null( $post_id ) ) { |
|
95 | - $price = esc_attr( give_format_decimal( '1.00' ) ); |
|
94 | + if (empty($price) && is_null($post_id)) { |
|
95 | + $price = esc_attr(give_format_decimal('1.00')); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | // Min. $1.00 for new forms |
99 | - if ( empty( $custom_amount_minimum ) ) { |
|
100 | - $custom_amount_minimum = esc_attr( give_format_decimal( '1.00' ) ); |
|
99 | + if (empty($custom_amount_minimum)) { |
|
100 | + $custom_amount_minimum = esc_attr(give_format_decimal('1.00')); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | // Start with an underscore to hide fields from custom fields list |
@@ -107,215 +107,215 @@ discard block |
||
107 | 107 | /** |
108 | 108 | * Repeatable Field Groups |
109 | 109 | */ |
110 | - 'form_field_options' => apply_filters( 'give_forms_field_options', array( |
|
110 | + 'form_field_options' => apply_filters('give_forms_field_options', array( |
|
111 | 111 | 'id' => 'form_field_options', |
112 | - 'title' => esc_html__( 'Donation Options', 'give' ), |
|
112 | + 'title' => esc_html__('Donation Options', 'give'), |
|
113 | 113 | 'icon-html' => '<span class="give-icon give-icon-heart"></span>', |
114 | - 'fields' => apply_filters( 'give_forms_donation_form_metabox_fields', array( |
|
114 | + 'fields' => apply_filters('give_forms_donation_form_metabox_fields', array( |
|
115 | 115 | // Donation Option |
116 | 116 | array( |
117 | - 'name' => esc_html__( 'Donation Option', 'give' ), |
|
118 | - 'description' => esc_html__( 'Do you want this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give' ), |
|
119 | - 'id' => $prefix . 'price_option', |
|
117 | + 'name' => esc_html__('Donation Option', 'give'), |
|
118 | + 'description' => esc_html__('Do you want this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give'), |
|
119 | + 'id' => $prefix.'price_option', |
|
120 | 120 | 'type' => 'radio_inline', |
121 | 121 | 'default' => 'set', |
122 | - 'options' => apply_filters( 'give_forms_price_options', array( |
|
123 | - 'set' => esc_html__( 'Set Donation', 'give' ), |
|
124 | - 'multi' => esc_html__( 'Multi-level Donation', 'give' ), |
|
125 | - ) ), |
|
122 | + 'options' => apply_filters('give_forms_price_options', array( |
|
123 | + 'set' => esc_html__('Set Donation', 'give'), |
|
124 | + 'multi' => esc_html__('Multi-level Donation', 'give'), |
|
125 | + )), |
|
126 | 126 | ), |
127 | 127 | array( |
128 | - 'name' => esc_html__( 'Set Donation', 'give' ), |
|
129 | - 'description' => esc_html__( 'This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give' ), |
|
130 | - 'id' => $prefix . 'set_price', |
|
128 | + 'name' => esc_html__('Set Donation', 'give'), |
|
129 | + 'description' => esc_html__('This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give'), |
|
130 | + 'id' => $prefix.'set_price', |
|
131 | 131 | 'type' => 'text_small', |
132 | 132 | 'data_type' => 'price', |
133 | 133 | 'attributes' => array( |
134 | - 'placeholder' => give_format_decimal( '1.00' ), |
|
135 | - 'value' => give_format_decimal( $price ), |
|
134 | + 'placeholder' => give_format_decimal('1.00'), |
|
135 | + 'value' => give_format_decimal($price), |
|
136 | 136 | 'class' => 'give-money-field', |
137 | 137 | ), |
138 | 138 | ), |
139 | 139 | // Display Style |
140 | 140 | array( |
141 | - 'name' => esc_html__( 'Display Style', 'give' ), |
|
142 | - 'description' => esc_html__( 'Set how the donations levels will display on the form.', 'give' ), |
|
143 | - 'id' => $prefix . 'display_style', |
|
141 | + 'name' => esc_html__('Display Style', 'give'), |
|
142 | + 'description' => esc_html__('Set how the donations levels will display on the form.', 'give'), |
|
143 | + 'id' => $prefix.'display_style', |
|
144 | 144 | 'type' => 'radio_inline', |
145 | 145 | 'default' => 'buttons', |
146 | 146 | 'options' => array( |
147 | - 'buttons' => esc_html__( 'Buttons', 'give' ), |
|
148 | - 'radios' => esc_html__( 'Radios', 'give' ), |
|
149 | - 'dropdown' => esc_html__( 'Dropdown', 'give' ), |
|
147 | + 'buttons' => esc_html__('Buttons', 'give'), |
|
148 | + 'radios' => esc_html__('Radios', 'give'), |
|
149 | + 'dropdown' => esc_html__('Dropdown', 'give'), |
|
150 | 150 | ), |
151 | 151 | ), |
152 | 152 | // Custom Amount |
153 | 153 | array( |
154 | - 'name' => esc_html__( 'Custom Amount', 'give' ), |
|
155 | - 'description' => esc_html__( 'Do you want the user to be able to input their own donation amount?', 'give' ), |
|
156 | - 'id' => $prefix . 'custom_amount', |
|
154 | + 'name' => esc_html__('Custom Amount', 'give'), |
|
155 | + 'description' => esc_html__('Do you want the user to be able to input their own donation amount?', 'give'), |
|
156 | + 'id' => $prefix.'custom_amount', |
|
157 | 157 | 'type' => 'radio_inline', |
158 | 158 | 'default' => 'disabled', |
159 | 159 | 'options' => array( |
160 | - 'enabled' => esc_html__( 'Enabled', 'give' ), |
|
161 | - 'disabled' => esc_html__( 'Disabled', 'give' ), |
|
160 | + 'enabled' => esc_html__('Enabled', 'give'), |
|
161 | + 'disabled' => esc_html__('Disabled', 'give'), |
|
162 | 162 | ), |
163 | 163 | ), |
164 | 164 | array( |
165 | - 'name' => esc_html__( 'Minimum Amount', 'give' ), |
|
166 | - 'description' => esc_html__( 'Enter the minimum custom donation amount.', 'give' ), |
|
167 | - 'id' => $prefix . 'custom_amount_minimum', |
|
165 | + 'name' => esc_html__('Minimum Amount', 'give'), |
|
166 | + 'description' => esc_html__('Enter the minimum custom donation amount.', 'give'), |
|
167 | + 'id' => $prefix.'custom_amount_minimum', |
|
168 | 168 | 'type' => 'text_small', |
169 | 169 | 'data_type' => 'price', |
170 | 170 | 'attributes' => array( |
171 | - 'placeholder' => give_format_decimal( '1.00' ), |
|
172 | - 'value' => give_format_decimal( $custom_amount_minimum ), |
|
171 | + 'placeholder' => give_format_decimal('1.00'), |
|
172 | + 'value' => give_format_decimal($custom_amount_minimum), |
|
173 | 173 | 'class' => 'give-money-field', |
174 | 174 | ), |
175 | 175 | ), |
176 | 176 | array( |
177 | - 'name' => esc_html__( 'Custom Amount Text', 'give' ), |
|
178 | - 'description' => esc_html__( 'This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give' ), |
|
179 | - 'id' => $prefix . 'custom_amount_text', |
|
177 | + 'name' => esc_html__('Custom Amount Text', 'give'), |
|
178 | + 'description' => esc_html__('This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give'), |
|
179 | + 'id' => $prefix.'custom_amount_text', |
|
180 | 180 | 'type' => 'text_medium', |
181 | 181 | 'attributes' => array( |
182 | 182 | 'rows' => 3, |
183 | - 'placeholder' => esc_attr__( 'Give a Custom Amount', 'give' ), |
|
183 | + 'placeholder' => esc_attr__('Give a Custom Amount', 'give'), |
|
184 | 184 | ), |
185 | 185 | ), |
186 | 186 | // Donation Levels: Repeatable CMB2 Group |
187 | 187 | array( |
188 | - 'id' => $prefix . 'donation_levels', |
|
188 | + 'id' => $prefix.'donation_levels', |
|
189 | 189 | 'type' => 'group', |
190 | 190 | 'options' => array( |
191 | - 'add_button' => esc_html__( 'Add Level', 'give' ), |
|
192 | - 'header_title' => esc_html__( 'Donation Level', 'give' ), |
|
191 | + 'add_button' => esc_html__('Add Level', 'give'), |
|
192 | + 'header_title' => esc_html__('Donation Level', 'give'), |
|
193 | 193 | 'remove_button' => '<span class="dashicons dashicons-no"></span>', |
194 | 194 | ), |
195 | 195 | // Fields array works the same, except id's only need to be unique for this group. |
196 | 196 | // Prefix is not needed. |
197 | - 'fields' => apply_filters( 'give_donation_levels_table_row', array( |
|
197 | + 'fields' => apply_filters('give_donation_levels_table_row', array( |
|
198 | 198 | array( |
199 | - 'name' => esc_html__( 'ID', 'give' ), |
|
200 | - 'id' => $prefix . 'id', |
|
199 | + 'name' => esc_html__('ID', 'give'), |
|
200 | + 'id' => $prefix.'id', |
|
201 | 201 | 'type' => 'levels_id', |
202 | 202 | ), |
203 | 203 | array( |
204 | - 'name' => esc_html__( 'Amount', 'give' ), |
|
205 | - 'id' => $prefix . 'amount', |
|
204 | + 'name' => esc_html__('Amount', 'give'), |
|
205 | + 'id' => $prefix.'amount', |
|
206 | 206 | 'type' => 'text_small', |
207 | 207 | 'data_type' => 'price', |
208 | 208 | 'attributes' => array( |
209 | - 'placeholder' => give_format_decimal( '1.00' ), |
|
209 | + 'placeholder' => give_format_decimal('1.00'), |
|
210 | 210 | 'class' => 'give-money-field', |
211 | 211 | ), |
212 | 212 | ), |
213 | 213 | array( |
214 | - 'name' => esc_html__( 'Text', 'give' ), |
|
215 | - 'id' => $prefix . 'text', |
|
214 | + 'name' => esc_html__('Text', 'give'), |
|
215 | + 'id' => $prefix.'text', |
|
216 | 216 | 'type' => 'text', |
217 | 217 | 'attributes' => array( |
218 | - 'placeholder' => esc_html__( 'Donation Level', 'give' ), |
|
218 | + 'placeholder' => esc_html__('Donation Level', 'give'), |
|
219 | 219 | 'class' => 'give-multilevel-text-field', |
220 | 220 | ), |
221 | 221 | ), |
222 | 222 | array( |
223 | - 'name' => esc_html__( 'Default', 'give' ), |
|
224 | - 'id' => $prefix . 'default', |
|
223 | + 'name' => esc_html__('Default', 'give'), |
|
224 | + 'id' => $prefix.'default', |
|
225 | 225 | 'type' => 'give_default_radio_inline', |
226 | 226 | ), |
227 | - ) ), |
|
227 | + )), |
|
228 | 228 | ), |
229 | 229 | array( |
230 | 230 | 'name' => 'donation_options_docs', |
231 | 231 | 'type' => 'docs_link', |
232 | 232 | 'url' => 'http://docs.givewp.com/form-donation-options', |
233 | - 'title' => esc_html__( 'Donation Options', 'give' ), |
|
233 | + 'title' => esc_html__('Donation Options', 'give'), |
|
234 | 234 | ), |
235 | 235 | ), |
236 | 236 | $post_id |
237 | 237 | ), |
238 | - ) ), |
|
238 | + )), |
|
239 | 239 | |
240 | 240 | /** |
241 | 241 | * Display Options |
242 | 242 | */ |
243 | - 'form_display_options' => apply_filters( 'give_form_display_options', array( |
|
243 | + 'form_display_options' => apply_filters('give_form_display_options', array( |
|
244 | 244 | 'id' => 'form_display_options', |
245 | - 'title' => esc_html__( 'Form Display', 'give' ), |
|
245 | + 'title' => esc_html__('Form Display', 'give'), |
|
246 | 246 | 'icon-html' => '<span class="give-icon give-icon-display"></span>', |
247 | - 'fields' => apply_filters( 'give_forms_display_options_metabox_fields', array( |
|
247 | + 'fields' => apply_filters('give_forms_display_options_metabox_fields', array( |
|
248 | 248 | array( |
249 | - 'name' => esc_html__( 'Display Options', 'give' ), |
|
250 | - 'desc' => sprintf( __( 'How would you like to display donation information for this form?', 'give' ), '#' ), |
|
251 | - 'id' => $prefix . 'payment_display', |
|
249 | + 'name' => esc_html__('Display Options', 'give'), |
|
250 | + 'desc' => sprintf(__('How would you like to display donation information for this form?', 'give'), '#'), |
|
251 | + 'id' => $prefix.'payment_display', |
|
252 | 252 | 'type' => 'radio_inline', |
253 | 253 | 'options' => array( |
254 | - 'onpage' => esc_html__( 'All Fields', 'give' ), |
|
255 | - 'modal' => esc_html__( 'Modal', 'give' ), |
|
256 | - 'reveal' => esc_html__( 'Reveal', 'give' ), |
|
257 | - 'button' => esc_html__( 'Button', 'give' ), |
|
254 | + 'onpage' => esc_html__('All Fields', 'give'), |
|
255 | + 'modal' => esc_html__('Modal', 'give'), |
|
256 | + 'reveal' => esc_html__('Reveal', 'give'), |
|
257 | + 'button' => esc_html__('Button', 'give'), |
|
258 | 258 | ), |
259 | 259 | 'default' => 'onpage', |
260 | 260 | ), |
261 | 261 | array( |
262 | - 'id' => $prefix . 'reveal_label', |
|
263 | - 'name' => esc_html__( 'Continue Button', 'give' ), |
|
264 | - 'desc' => esc_html__( 'The button label for displaying the additional payment fields.', 'give' ), |
|
262 | + 'id' => $prefix.'reveal_label', |
|
263 | + 'name' => esc_html__('Continue Button', 'give'), |
|
264 | + 'desc' => esc_html__('The button label for displaying the additional payment fields.', 'give'), |
|
265 | 265 | 'type' => 'text_small', |
266 | 266 | 'attributes' => array( |
267 | - 'placeholder' => esc_attr__( 'Donate Now', 'give' ), |
|
267 | + 'placeholder' => esc_attr__('Donate Now', 'give'), |
|
268 | 268 | ), |
269 | 269 | ), |
270 | 270 | array( |
271 | - 'id' => $prefix . 'checkout_label', |
|
272 | - 'name' => esc_html__( 'Submit Button', 'give' ), |
|
273 | - 'desc' => esc_html__( 'The button label for completing a donation.', 'give' ), |
|
271 | + 'id' => $prefix.'checkout_label', |
|
272 | + 'name' => esc_html__('Submit Button', 'give'), |
|
273 | + 'desc' => esc_html__('The button label for completing a donation.', 'give'), |
|
274 | 274 | 'type' => 'text_small', |
275 | 275 | 'attributes' => array( |
276 | - 'placeholder' => esc_html__( 'Donate Now', 'give' ), |
|
276 | + 'placeholder' => esc_html__('Donate Now', 'give'), |
|
277 | 277 | ), |
278 | 278 | ), |
279 | 279 | array( |
280 | - 'name' => esc_html__( 'Default Gateway', 'give' ), |
|
281 | - 'desc' => esc_html__( 'By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give' ), |
|
282 | - 'id' => $prefix . 'default_gateway', |
|
280 | + 'name' => esc_html__('Default Gateway', 'give'), |
|
281 | + 'desc' => esc_html__('By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give'), |
|
282 | + 'id' => $prefix.'default_gateway', |
|
283 | 283 | 'type' => 'default_gateway', |
284 | 284 | ), |
285 | 285 | array( |
286 | - 'name' => esc_html__( 'Guest Donations', 'give' ), |
|
287 | - 'desc' => esc_html__( 'Do you want to allow non-logged-in users to make donations?', 'give' ), |
|
288 | - 'id' => $prefix . 'logged_in_only', |
|
286 | + 'name' => esc_html__('Guest Donations', 'give'), |
|
287 | + 'desc' => esc_html__('Do you want to allow non-logged-in users to make donations?', 'give'), |
|
288 | + 'id' => $prefix.'logged_in_only', |
|
289 | 289 | 'type' => 'radio_inline', |
290 | 290 | 'default' => 'enabled', |
291 | 291 | 'options' => array( |
292 | - 'enabled' => esc_html__( 'Enabled', 'give' ), |
|
293 | - 'disabled' => esc_html__( 'Disabled', 'give' ), |
|
292 | + 'enabled' => esc_html__('Enabled', 'give'), |
|
293 | + 'disabled' => esc_html__('Disabled', 'give'), |
|
294 | 294 | ), |
295 | 295 | ), |
296 | 296 | array( |
297 | - 'name' => esc_html__( 'Registration', 'give' ), |
|
298 | - 'desc' => esc_html__( 'Display the registration and login forms in the payment section for non-logged-in users.', 'give' ), |
|
299 | - 'id' => $prefix . 'show_register_form', |
|
297 | + 'name' => esc_html__('Registration', 'give'), |
|
298 | + 'desc' => esc_html__('Display the registration and login forms in the payment section for non-logged-in users.', 'give'), |
|
299 | + 'id' => $prefix.'show_register_form', |
|
300 | 300 | 'type' => 'radio', |
301 | 301 | 'options' => array( |
302 | - 'none' => esc_html__( 'None', 'give' ), |
|
303 | - 'registration' => esc_html__( 'Registration', 'give' ), |
|
304 | - 'login' => esc_html__( 'Login', 'give' ), |
|
305 | - 'both' => esc_html__( 'Registration + Login', 'give' ), |
|
302 | + 'none' => esc_html__('None', 'give'), |
|
303 | + 'registration' => esc_html__('Registration', 'give'), |
|
304 | + 'login' => esc_html__('Login', 'give'), |
|
305 | + 'both' => esc_html__('Registration + Login', 'give'), |
|
306 | 306 | ), |
307 | 307 | 'default' => 'none', |
308 | 308 | ), |
309 | 309 | array( |
310 | - 'name' => esc_html__( 'Floating Labels', 'give' ), |
|
310 | + 'name' => esc_html__('Floating Labels', 'give'), |
|
311 | 311 | /* translators: %s: forms http://docs.givewp.com/form-floating-labels */ |
312 | - 'desc' => sprintf( __( 'Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form. Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give' ), esc_url( 'http://docs.givewp.com/form-floating-labels' ) ), |
|
313 | - 'id' => $prefix . 'form_floating_labels', |
|
312 | + 'desc' => sprintf(__('Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form. Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give'), esc_url('http://docs.givewp.com/form-floating-labels')), |
|
313 | + 'id' => $prefix.'form_floating_labels', |
|
314 | 314 | 'type' => 'radio_inline', |
315 | 315 | 'options' => array( |
316 | - 'global' => esc_html__( 'Global Option', 'give' ), |
|
317 | - 'enabled' => esc_html__( 'Enabled', 'give' ), |
|
318 | - 'disabled' => esc_html__( 'Disabled', 'give' ), |
|
316 | + 'global' => esc_html__('Global Option', 'give'), |
|
317 | + 'enabled' => esc_html__('Enabled', 'give'), |
|
318 | + 'disabled' => esc_html__('Disabled', 'give'), |
|
319 | 319 | ), |
320 | 320 | 'default' => 'global', |
321 | 321 | ), |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | 'name' => 'form_display_docs', |
324 | 324 | 'type' => 'docs_link', |
325 | 325 | 'url' => 'http://docs.givewp.com/form-display-options', |
326 | - 'title' => esc_html__( 'Form Display', 'give' ), |
|
326 | + 'title' => esc_html__('Form Display', 'give'), |
|
327 | 327 | ), |
328 | 328 | ), |
329 | 329 | $post_id |
@@ -334,193 +334,193 @@ discard block |
||
334 | 334 | /** |
335 | 335 | * Donation Goals |
336 | 336 | */ |
337 | - 'donation_goal_options' => apply_filters( 'give_donation_goal_options', array( |
|
337 | + 'donation_goal_options' => apply_filters('give_donation_goal_options', array( |
|
338 | 338 | 'id' => 'donation_goal_options', |
339 | - 'title' => esc_html__( 'Donation Goal', 'give' ), |
|
339 | + 'title' => esc_html__('Donation Goal', 'give'), |
|
340 | 340 | 'icon-html' => '<span class="give-icon give-icon-target"></span>', |
341 | - 'fields' => apply_filters( 'give_forms_donation_goal_metabox_fields', array( |
|
341 | + 'fields' => apply_filters('give_forms_donation_goal_metabox_fields', array( |
|
342 | 342 | // Goals |
343 | 343 | array( |
344 | - 'name' => esc_html__( 'Donation Goal', 'give' ), |
|
345 | - 'description' => esc_html__( 'Do you want to set a donation goal for this form?', 'give' ), |
|
346 | - 'id' => $prefix . 'goal_option', |
|
344 | + 'name' => esc_html__('Donation Goal', 'give'), |
|
345 | + 'description' => esc_html__('Do you want to set a donation goal for this form?', 'give'), |
|
346 | + 'id' => $prefix.'goal_option', |
|
347 | 347 | 'type' => 'radio_inline', |
348 | 348 | 'default' => 'disabled', |
349 | 349 | 'options' => array( |
350 | - 'enabled' => esc_html__( 'Enabled', 'give' ), |
|
351 | - 'disabled' => esc_html__( 'Disabled', 'give' ), |
|
350 | + 'enabled' => esc_html__('Enabled', 'give'), |
|
351 | + 'disabled' => esc_html__('Disabled', 'give'), |
|
352 | 352 | ), |
353 | 353 | ), |
354 | 354 | array( |
355 | - 'name' => esc_html__( 'Goal Amount', 'give' ), |
|
356 | - 'description' => esc_html__( 'This is the monetary goal amount you want to reach for this form.', 'give' ), |
|
357 | - 'id' => $prefix . 'set_goal', |
|
355 | + 'name' => esc_html__('Goal Amount', 'give'), |
|
356 | + 'description' => esc_html__('This is the monetary goal amount you want to reach for this form.', 'give'), |
|
357 | + 'id' => $prefix.'set_goal', |
|
358 | 358 | 'type' => 'text_small', |
359 | 359 | 'data_type' => 'price', |
360 | 360 | 'attributes' => array( |
361 | - 'placeholder' => give_format_decimal( '0.00' ), |
|
362 | - 'value' => give_format_decimal( $goal ), |
|
361 | + 'placeholder' => give_format_decimal('0.00'), |
|
362 | + 'value' => give_format_decimal($goal), |
|
363 | 363 | 'class' => 'give-money-field', |
364 | 364 | ), |
365 | 365 | ), |
366 | 366 | |
367 | 367 | array( |
368 | - 'name' => esc_html__( 'Goal Format', 'give' ), |
|
369 | - 'description' => esc_html__( 'Do you want to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded".', 'give' ), |
|
370 | - 'id' => $prefix . 'goal_format', |
|
368 | + 'name' => esc_html__('Goal Format', 'give'), |
|
369 | + 'description' => esc_html__('Do you want to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded".', 'give'), |
|
370 | + 'id' => $prefix.'goal_format', |
|
371 | 371 | 'type' => 'radio_inline', |
372 | 372 | 'default' => 'amount', |
373 | 373 | 'options' => array( |
374 | - 'amount' => esc_html__( 'Amount', 'give' ), |
|
375 | - 'percentage' => esc_html__( 'Percentage', 'give' ), |
|
374 | + 'amount' => esc_html__('Amount', 'give'), |
|
375 | + 'percentage' => esc_html__('Percentage', 'give'), |
|
376 | 376 | ), |
377 | 377 | ), |
378 | 378 | array( |
379 | - 'name' => esc_html__( 'Progress Bar Color', 'give' ), |
|
380 | - 'desc' => esc_html__( 'Customize the color of the goal progress bar.', 'give' ), |
|
381 | - 'id' => $prefix . 'goal_color', |
|
379 | + 'name' => esc_html__('Progress Bar Color', 'give'), |
|
380 | + 'desc' => esc_html__('Customize the color of the goal progress bar.', 'give'), |
|
381 | + 'id' => $prefix.'goal_color', |
|
382 | 382 | 'type' => 'colorpicker', |
383 | 383 | 'default' => '#2bc253', |
384 | 384 | ), |
385 | 385 | |
386 | 386 | array( |
387 | - 'name' => esc_html__( 'Close Form', 'give' ), |
|
388 | - 'desc' => esc_html__( 'Do you want to close the donation forms and stop accepting donations once this goal has been met?', 'give' ), |
|
389 | - 'id' => $prefix . 'close_form_when_goal_achieved', |
|
387 | + 'name' => esc_html__('Close Form', 'give'), |
|
388 | + 'desc' => esc_html__('Do you want to close the donation forms and stop accepting donations once this goal has been met?', 'give'), |
|
389 | + 'id' => $prefix.'close_form_when_goal_achieved', |
|
390 | 390 | 'type' => 'radio_inline', |
391 | 391 | 'default' => 'disabled', |
392 | 392 | 'options' => array( |
393 | - 'enabled' => esc_html__( 'Enabled', 'give' ), |
|
394 | - 'disabled' => esc_html__( 'Disabled', 'give' ), |
|
393 | + 'enabled' => esc_html__('Enabled', 'give'), |
|
394 | + 'disabled' => esc_html__('Disabled', 'give'), |
|
395 | 395 | ), |
396 | 396 | ), |
397 | 397 | array( |
398 | - 'name' => esc_html__( 'Goal Achieved Message', 'give' ), |
|
399 | - 'desc' => esc_html__( 'Do you want to display a custom message when the goal is closed? If none is provided the default message will be displayed', 'give' ), |
|
400 | - 'id' => $prefix . 'form_goal_achieved_message', |
|
398 | + 'name' => esc_html__('Goal Achieved Message', 'give'), |
|
399 | + 'desc' => esc_html__('Do you want to display a custom message when the goal is closed? If none is provided the default message will be displayed', 'give'), |
|
400 | + 'id' => $prefix.'form_goal_achieved_message', |
|
401 | 401 | 'type' => 'textarea', |
402 | 402 | 'attributes' => array( |
403 | - 'placeholder' => esc_attr__( 'Thank you to all our donors, we have met our fundraising goal.', 'give' ), |
|
403 | + 'placeholder' => esc_attr__('Thank you to all our donors, we have met our fundraising goal.', 'give'), |
|
404 | 404 | ), |
405 | 405 | ), |
406 | 406 | array( |
407 | 407 | 'name' => 'donation_goal_docs', |
408 | 408 | 'type' => 'docs_link', |
409 | 409 | 'url' => 'http://docs.givewp.com/form-donation-goal', |
410 | - 'title' => esc_html__( 'Donation Goal', 'give' ), |
|
410 | + 'title' => esc_html__('Donation Goal', 'give'), |
|
411 | 411 | ), |
412 | 412 | ), |
413 | 413 | $post_id |
414 | 414 | ), |
415 | - ) ), |
|
415 | + )), |
|
416 | 416 | |
417 | 417 | /** |
418 | 418 | * Content Field |
419 | 419 | */ |
420 | - 'form_content_options' => apply_filters( 'give_forms_content_options', array( |
|
420 | + 'form_content_options' => apply_filters('give_forms_content_options', array( |
|
421 | 421 | 'id' => 'form_content_options', |
422 | - 'title' => esc_html__( 'Form Content', 'give' ), |
|
422 | + 'title' => esc_html__('Form Content', 'give'), |
|
423 | 423 | 'icon-html' => '<span class="give-icon give-icon-edit"></span>', |
424 | - 'fields' => apply_filters( 'give_forms_content_options_metabox_fields', array( |
|
424 | + 'fields' => apply_filters('give_forms_content_options_metabox_fields', array( |
|
425 | 425 | |
426 | 426 | // Donation content. |
427 | 427 | array( |
428 | - 'name' => esc_html__( 'Display Content', 'give' ), |
|
429 | - 'description' => esc_html__( 'Do you want to add custom content to this form?', 'give' ), |
|
430 | - 'id' => $prefix . 'display_content', |
|
428 | + 'name' => esc_html__('Display Content', 'give'), |
|
429 | + 'description' => esc_html__('Do you want to add custom content to this form?', 'give'), |
|
430 | + 'id' => $prefix.'display_content', |
|
431 | 431 | 'type' => 'radio_inline', |
432 | 432 | 'options' => array( |
433 | - 'enabled' => esc_html__( 'Enabled', 'give' ), |
|
434 | - 'disabled' => esc_html__( 'Disabled', 'give' ), |
|
433 | + 'enabled' => esc_html__('Enabled', 'give'), |
|
434 | + 'disabled' => esc_html__('Disabled', 'give'), |
|
435 | 435 | ), |
436 | 436 | 'default' => 'disabled', |
437 | 437 | ), |
438 | 438 | |
439 | 439 | // Content placement. |
440 | 440 | array( |
441 | - 'name' => esc_html__( 'Content Placement', 'give' ), |
|
442 | - 'description' => esc_html__( 'This option controls where the content appears within the donation form.', 'give' ), |
|
443 | - 'id' => $prefix . 'content_placement', |
|
441 | + 'name' => esc_html__('Content Placement', 'give'), |
|
442 | + 'description' => esc_html__('This option controls where the content appears within the donation form.', 'give'), |
|
443 | + 'id' => $prefix.'content_placement', |
|
444 | 444 | 'type' => 'radio_inline', |
445 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
446 | - 'give_pre_form' => esc_html__( 'Above fields', 'give' ), |
|
447 | - 'give_post_form' => esc_html__( 'Below fields', 'give' ), |
|
445 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
446 | + 'give_pre_form' => esc_html__('Above fields', 'give'), |
|
447 | + 'give_post_form' => esc_html__('Below fields', 'give'), |
|
448 | 448 | ) |
449 | 449 | ), |
450 | 450 | 'default' => 'give_pre_form', |
451 | 451 | ), |
452 | 452 | array( |
453 | - 'name' => esc_html__( 'Content', 'give' ), |
|
454 | - 'description' => esc_html__( 'This content will display on the single give form page.', 'give' ), |
|
455 | - 'id' => $prefix . 'form_content', |
|
453 | + 'name' => esc_html__('Content', 'give'), |
|
454 | + 'description' => esc_html__('This content will display on the single give form page.', 'give'), |
|
455 | + 'id' => $prefix.'form_content', |
|
456 | 456 | 'type' => 'wysiwyg', |
457 | 457 | ), |
458 | 458 | array( |
459 | 459 | 'name' => 'form_content_docs', |
460 | 460 | 'type' => 'docs_link', |
461 | 461 | 'url' => 'http://docs.givewp.com/form-content', |
462 | - 'title' => esc_html__( 'Form Content', 'give' ), |
|
462 | + 'title' => esc_html__('Form Content', 'give'), |
|
463 | 463 | ), |
464 | 464 | ), |
465 | 465 | $post_id |
466 | 466 | ), |
467 | - ) ), |
|
467 | + )), |
|
468 | 468 | |
469 | 469 | /** |
470 | 470 | * Terms & Conditions |
471 | 471 | */ |
472 | - 'form_terms_options' => apply_filters( 'give_forms_terms_options', array( |
|
472 | + 'form_terms_options' => apply_filters('give_forms_terms_options', array( |
|
473 | 473 | 'id' => 'form_terms_options', |
474 | - 'title' => esc_html__( 'Terms & Conditions', 'give' ), |
|
474 | + 'title' => esc_html__('Terms & Conditions', 'give'), |
|
475 | 475 | 'icon-html' => '<span class="give-icon give-icon-checklist"></span>', |
476 | - 'fields' => apply_filters( 'give_forms_terms_options_metabox_fields', array( |
|
476 | + 'fields' => apply_filters('give_forms_terms_options_metabox_fields', array( |
|
477 | 477 | // Donation Option |
478 | 478 | array( |
479 | - 'name' => esc_html__( 'Terms & Conditions', 'give' ), |
|
480 | - 'description' => esc_html__( 'Do you want to require the donor to accept terms prior to being able to complete their donation?', 'give' ), |
|
481 | - 'id' => $prefix . 'terms_option', |
|
479 | + 'name' => esc_html__('Terms & Conditions', 'give'), |
|
480 | + 'description' => esc_html__('Do you want to require the donor to accept terms prior to being able to complete their donation?', 'give'), |
|
481 | + 'id' => $prefix.'terms_option', |
|
482 | 482 | 'type' => 'radio_inline', |
483 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
484 | - 'global' => esc_html__( 'Global Option', 'give' ), |
|
485 | - 'enabled' => esc_html__( 'Customize', 'give' ), |
|
486 | - 'disabled' => esc_html__( 'Disable', 'give' ), |
|
483 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
484 | + 'global' => esc_html__('Global Option', 'give'), |
|
485 | + 'enabled' => esc_html__('Customize', 'give'), |
|
486 | + 'disabled' => esc_html__('Disable', 'give'), |
|
487 | 487 | ) |
488 | 488 | ), |
489 | 489 | 'default' => 'global', |
490 | 490 | ), |
491 | 491 | array( |
492 | - 'id' => $prefix . 'agree_label', |
|
493 | - 'name' => esc_html__( 'Agreement Label', 'give' ), |
|
494 | - 'desc' => esc_html__( 'The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give' ), |
|
492 | + 'id' => $prefix.'agree_label', |
|
493 | + 'name' => esc_html__('Agreement Label', 'give'), |
|
494 | + 'desc' => esc_html__('The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give'), |
|
495 | 495 | 'type' => 'text', |
496 | 496 | 'size' => 'regular', |
497 | 497 | 'attributes' => array( |
498 | - 'placeholder' => esc_attr__( 'Agree to Terms?', 'give' ), |
|
498 | + 'placeholder' => esc_attr__('Agree to Terms?', 'give'), |
|
499 | 499 | ), |
500 | 500 | ), |
501 | 501 | array( |
502 | - 'id' => $prefix . 'agree_text', |
|
503 | - 'name' => esc_html__( 'Agreement Text', 'give' ), |
|
504 | - 'desc' => esc_html__( 'This is the actual text which the user will have to agree to in order to make a donation.', 'give' ), |
|
502 | + 'id' => $prefix.'agree_text', |
|
503 | + 'name' => esc_html__('Agreement Text', 'give'), |
|
504 | + 'desc' => esc_html__('This is the actual text which the user will have to agree to in order to make a donation.', 'give'), |
|
505 | 505 | 'type' => 'wysiwyg', |
506 | 506 | ), |
507 | 507 | array( |
508 | 508 | 'name' => 'terms_docs', |
509 | 509 | 'type' => 'docs_link', |
510 | 510 | 'url' => 'http://docs.givewp.com/form-terms', |
511 | - 'title' => esc_html__( 'Terms & Conditions', 'give' ), |
|
511 | + 'title' => esc_html__('Terms & Conditions', 'give'), |
|
512 | 512 | ), |
513 | 513 | ), |
514 | 514 | $post_id |
515 | 515 | ), |
516 | - ) ), |
|
516 | + )), |
|
517 | 517 | ); |
518 | 518 | |
519 | 519 | |
520 | 520 | /** |
521 | 521 | * Filter the metabox tabbed panel settings. |
522 | 522 | */ |
523 | - $settings = apply_filters( 'give_metabox_form_data_settings', $settings, $post_id ); |
|
523 | + $settings = apply_filters('give_metabox_form_data_settings', $settings, $post_id); |
|
524 | 524 | |
525 | 525 | // Output. |
526 | 526 | return $settings; |
@@ -536,8 +536,8 @@ discard block |
||
536 | 536 | add_meta_box( |
537 | 537 | $this->get_metabox_ID(), |
538 | 538 | $this->get_metabox_label(), |
539 | - array( $this, 'output' ), |
|
540 | - array( 'give_forms' ), |
|
539 | + array($this, 'output'), |
|
540 | + array('give_forms'), |
|
541 | 541 | 'normal', |
542 | 542 | 'high' |
543 | 543 | ); |
@@ -553,9 +553,9 @@ discard block |
||
553 | 553 | function enqueue_script() { |
554 | 554 | global $post; |
555 | 555 | |
556 | - if ( is_object( $post ) && 'give_forms' === $post->post_type ) { |
|
557 | - wp_enqueue_style( 'wp-color-picker' ); |
|
558 | - wp_enqueue_script( 'wp-color-picker' ); |
|
556 | + if (is_object($post) && 'give_forms' === $post->post_type) { |
|
557 | + wp_enqueue_style('wp-color-picker'); |
|
558 | + wp_enqueue_script('wp-color-picker'); |
|
559 | 559 | } |
560 | 560 | } |
561 | 561 | |
@@ -589,32 +589,32 @@ discard block |
||
589 | 589 | public function get_tabs() { |
590 | 590 | $tabs = array(); |
591 | 591 | |
592 | - if ( ! empty( $this->settings ) ) { |
|
593 | - foreach ( $this->settings as $setting ) { |
|
594 | - if ( ! isset( $setting['id'] ) || ! isset( $setting['title'] ) ) { |
|
592 | + if ( ! empty($this->settings)) { |
|
593 | + foreach ($this->settings as $setting) { |
|
594 | + if ( ! isset($setting['id']) || ! isset($setting['title'])) { |
|
595 | 595 | continue; |
596 | 596 | } |
597 | 597 | $tab = array( |
598 | 598 | 'id' => $setting['id'], |
599 | 599 | 'label' => $setting['title'], |
600 | - 'icon-html' => ( ! empty( $setting['icon-html'] ) ? $setting['icon-html'] : '' ), |
|
600 | + 'icon-html' => ( ! empty($setting['icon-html']) ? $setting['icon-html'] : ''), |
|
601 | 601 | ); |
602 | 602 | |
603 | - if ( $this->has_sub_tab( $setting ) ) { |
|
604 | - if ( empty( $setting['sub-fields'] ) ) { |
|
603 | + if ($this->has_sub_tab($setting)) { |
|
604 | + if (empty($setting['sub-fields'])) { |
|
605 | 605 | $tab = array(); |
606 | 606 | } else { |
607 | - foreach ( $setting['sub-fields'] as $sub_fields ) { |
|
607 | + foreach ($setting['sub-fields'] as $sub_fields) { |
|
608 | 608 | $tab['sub-fields'][] = array( |
609 | 609 | 'id' => $sub_fields['id'], |
610 | 610 | 'label' => $sub_fields['title'], |
611 | - 'icon-html' => ( ! empty( $sub_fields['icon-html'] ) ? $sub_fields['icon-html'] : '' ), |
|
611 | + 'icon-html' => ( ! empty($sub_fields['icon-html']) ? $sub_fields['icon-html'] : ''), |
|
612 | 612 | ); |
613 | 613 | } |
614 | 614 | } |
615 | 615 | } |
616 | 616 | |
617 | - if ( ! empty( $tab ) ) { |
|
617 | + if ( ! empty($tab)) { |
|
618 | 618 | $tabs[] = $tab; |
619 | 619 | } |
620 | 620 | } |
@@ -631,27 +631,27 @@ discard block |
||
631 | 631 | */ |
632 | 632 | public function output() { |
633 | 633 | // Bailout. |
634 | - if ( $form_data_tabs = $this->get_tabs() ) { |
|
635 | - wp_nonce_field( 'give_save_form_meta', 'give_form_meta_nonce' ); |
|
634 | + if ($form_data_tabs = $this->get_tabs()) { |
|
635 | + wp_nonce_field('give_save_form_meta', 'give_form_meta_nonce'); |
|
636 | 636 | ?> |
637 | 637 | <div class="give-metabox-panel-wrap"> |
638 | 638 | <ul class="give-form-data-tabs give-metabox-tabs"> |
639 | - <?php foreach ( $form_data_tabs as $index => $form_data_tab ) : ?> |
|
640 | - <li class="<?php echo "{$form_data_tab['id']}_tab" . ( ! $index ? ' active' : '' ) . ( $this->has_sub_tab( $form_data_tab ) ? ' has-sub-fields' : '' ); ?>"> |
|
639 | + <?php foreach ($form_data_tabs as $index => $form_data_tab) : ?> |
|
640 | + <li class="<?php echo "{$form_data_tab['id']}_tab".( ! $index ? ' active' : '').($this->has_sub_tab($form_data_tab) ? ' has-sub-fields' : ''); ?>"> |
|
641 | 641 | <a href="#<?php echo $form_data_tab['id']; ?>"> |
642 | - <?php if ( ! empty( $form_data_tab['icon-html'] ) ) : ?> |
|
642 | + <?php if ( ! empty($form_data_tab['icon-html'])) : ?> |
|
643 | 643 | <?php echo $form_data_tab['icon-html']; ?> |
644 | 644 | <?php else : ?> |
645 | 645 | <span class="give-icon give-icon-default"></span> |
646 | 646 | <?php endif; ?> |
647 | 647 | <span class="give-label"><?php echo $form_data_tab['label']; ?></span> |
648 | 648 | </a> |
649 | - <?php if ( $this->has_sub_tab( $form_data_tab ) ) : ?> |
|
649 | + <?php if ($this->has_sub_tab($form_data_tab)) : ?> |
|
650 | 650 | <ul class="give-metabox-sub-tabs give-hidden"> |
651 | - <?php foreach ( $form_data_tab['sub-fields'] as $sub_tab ) : ?> |
|
651 | + <?php foreach ($form_data_tab['sub-fields'] as $sub_tab) : ?> |
|
652 | 652 | <li class="<?php echo "{$sub_tab['id']}_tab"; ?>"> |
653 | 653 | <a href="#<?php echo $sub_tab['id']; ?>"> |
654 | - <?php if ( ! empty( $sub_tab['icon-html'] ) ) : ?> |
|
654 | + <?php if ( ! empty($sub_tab['icon-html'])) : ?> |
|
655 | 655 | <?php echo $sub_tab['icon-html']; ?> |
656 | 656 | <?php else : ?> |
657 | 657 | <span class="give-icon give-icon-default"></span> |
@@ -667,30 +667,30 @@ discard block |
||
667 | 667 | </ul> |
668 | 668 | |
669 | 669 | <?php $show_first_tab_content = true; ?> |
670 | - <?php foreach ( $this->settings as $setting ) : ?> |
|
671 | - <?php if ( ! $this->has_sub_tab( $setting ) ) : ?> |
|
672 | - <?php do_action( "give_before_{$setting['id']}_settings" ); ?> |
|
670 | + <?php foreach ($this->settings as $setting) : ?> |
|
671 | + <?php if ( ! $this->has_sub_tab($setting)) : ?> |
|
672 | + <?php do_action("give_before_{$setting['id']}_settings"); ?> |
|
673 | 673 | |
674 | 674 | <div id="<?php echo $setting['id']; ?>" |
675 | - class="panel give_options_panel<?php echo( $show_first_tab_content ? '' : ' give-hidden' ); |
|
675 | + class="panel give_options_panel<?php echo($show_first_tab_content ? '' : ' give-hidden'); |
|
676 | 676 | $show_first_tab_content = false; ?>"> |
677 | - <?php if ( ! empty( $setting['fields'] ) ) : ?> |
|
678 | - <?php foreach ( $setting['fields'] as $field ) : ?> |
|
679 | - <?php give_render_field( $field ); ?> |
|
677 | + <?php if ( ! empty($setting['fields'])) : ?> |
|
678 | + <?php foreach ($setting['fields'] as $field) : ?> |
|
679 | + <?php give_render_field($field); ?> |
|
680 | 680 | <?php endforeach; ?> |
681 | 681 | <?php endif; ?> |
682 | 682 | </div> |
683 | 683 | |
684 | - <?php do_action( "give_after_{$setting['id']}_settings" ); ?> |
|
684 | + <?php do_action("give_after_{$setting['id']}_settings"); ?> |
|
685 | 685 | <?php else: ?> |
686 | - <?php if ( $this->has_sub_tab( $setting ) ) : ?> |
|
687 | - <?php if ( ! empty( $setting['sub-fields'] ) ) : ?> |
|
688 | - <?php foreach ( $setting['sub-fields'] as $index => $sub_fields ) : ?> |
|
686 | + <?php if ($this->has_sub_tab($setting)) : ?> |
|
687 | + <?php if ( ! empty($setting['sub-fields'])) : ?> |
|
688 | + <?php foreach ($setting['sub-fields'] as $index => $sub_fields) : ?> |
|
689 | 689 | <div id="<?php echo $sub_fields['id']; ?>" |
690 | 690 | class="panel give_options_panel give-hidden"> |
691 | - <?php if ( ! empty( $sub_fields['fields'] ) ) : ?> |
|
692 | - <?php foreach ( $sub_fields['fields'] as $sub_field ) : ?> |
|
693 | - <?php give_render_field( $sub_field ); ?> |
|
691 | + <?php if ( ! empty($sub_fields['fields'])) : ?> |
|
692 | + <?php foreach ($sub_fields['fields'] as $sub_field) : ?> |
|
693 | + <?php give_render_field($sub_field); ?> |
|
694 | 694 | <?php endforeach; ?> |
695 | 695 | <?php endif; ?> |
696 | 696 | </div> |
@@ -714,9 +714,9 @@ discard block |
||
714 | 714 | * |
715 | 715 | * @return bool |
716 | 716 | */ |
717 | - private function has_sub_tab( $field_setting ) { |
|
717 | + private function has_sub_tab($field_setting) { |
|
718 | 718 | $has_sub_tab = false; |
719 | - if ( array_key_exists( 'sub-fields', $field_setting ) ) { |
|
719 | + if (array_key_exists('sub-fields', $field_setting)) { |
|
720 | 720 | $has_sub_tab = true; |
721 | 721 | } |
722 | 722 | |
@@ -730,13 +730,13 @@ discard block |
||
730 | 730 | * @return array |
731 | 731 | */ |
732 | 732 | function cmb2_metabox_settings() { |
733 | - $all_cmb2_settings = apply_filters( 'cmb2_meta_boxes', array() ); |
|
733 | + $all_cmb2_settings = apply_filters('cmb2_meta_boxes', array()); |
|
734 | 734 | $give_forms_settings = $all_cmb2_settings; |
735 | 735 | |
736 | 736 | // Filter settings: Use only give forms related settings. |
737 | - foreach ( $all_cmb2_settings as $index => $setting ) { |
|
738 | - if ( ! in_array( 'give_forms', $setting['object_types'] ) ) { |
|
739 | - unset( $give_forms_settings[ $index ] ); |
|
737 | + foreach ($all_cmb2_settings as $index => $setting) { |
|
738 | + if ( ! in_array('give_forms', $setting['object_types'])) { |
|
739 | + unset($give_forms_settings[$index]); |
|
740 | 740 | } |
741 | 741 | } |
742 | 742 | |
@@ -754,114 +754,114 @@ discard block |
||
754 | 754 | * |
755 | 755 | * @return void |
756 | 756 | */ |
757 | - public function save( $post_id, $post ) { |
|
757 | + public function save($post_id, $post) { |
|
758 | 758 | |
759 | 759 | // $post_id and $post are required. |
760 | - if ( empty( $post_id ) || empty( $post ) ) { |
|
760 | + if (empty($post_id) || empty($post)) { |
|
761 | 761 | return; |
762 | 762 | } |
763 | 763 | |
764 | 764 | // Don't save meta boxes for revisions or autosaves. |
765 | - if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
765 | + if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
766 | 766 | return; |
767 | 767 | } |
768 | 768 | |
769 | 769 | // Check the nonce. |
770 | - if ( empty( $_POST['give_form_meta_nonce'] ) || ! wp_verify_nonce( $_POST['give_form_meta_nonce'], 'give_save_form_meta' ) ) { |
|
770 | + if (empty($_POST['give_form_meta_nonce']) || ! wp_verify_nonce($_POST['give_form_meta_nonce'], 'give_save_form_meta')) { |
|
771 | 771 | return; |
772 | 772 | } |
773 | 773 | |
774 | 774 | // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
775 | - if ( empty( $_POST['post_ID'] ) || $_POST['post_ID'] != $post_id ) { |
|
775 | + if (empty($_POST['post_ID']) || $_POST['post_ID'] != $post_id) { |
|
776 | 776 | return; |
777 | 777 | } |
778 | 778 | |
779 | 779 | // Check user has permission to edit. |
780 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
780 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
781 | 781 | return; |
782 | 782 | } |
783 | 783 | |
784 | 784 | // Fire action before saving form meta. |
785 | - do_action( 'give_pre_process_give_forms_meta', $post_id, $post ); |
|
785 | + do_action('give_pre_process_give_forms_meta', $post_id, $post); |
|
786 | 786 | |
787 | 787 | /** |
788 | 788 | * Filter the meta key to save. |
789 | 789 | * Third party addon developer can remove there meta keys from this array to handle saving data on there own. |
790 | 790 | */ |
791 | - $form_meta_keys = apply_filters( 'give_process_form_meta_keys', $this->get_meta_keys_from_settings() ); |
|
791 | + $form_meta_keys = apply_filters('give_process_form_meta_keys', $this->get_meta_keys_from_settings()); |
|
792 | 792 | |
793 | 793 | // Save form meta data. |
794 | - if ( ! empty( $form_meta_keys ) ) { |
|
795 | - foreach ( $form_meta_keys as $form_meta_key ) { |
|
794 | + if ( ! empty($form_meta_keys)) { |
|
795 | + foreach ($form_meta_keys as $form_meta_key) { |
|
796 | 796 | |
797 | 797 | // Set default value for checkbox fields. |
798 | 798 | if ( |
799 | - ! isset( $_POST[ $form_meta_key ] ) |
|
800 | - && ( 'checkbox' === $this->get_field_type( $form_meta_key ) ) |
|
799 | + ! isset($_POST[$form_meta_key]) |
|
800 | + && ('checkbox' === $this->get_field_type($form_meta_key)) |
|
801 | 801 | ) { |
802 | - $_POST[ $form_meta_key ] = ''; |
|
802 | + $_POST[$form_meta_key] = ''; |
|
803 | 803 | } |
804 | 804 | |
805 | - if ( isset( $_POST[ $form_meta_key ] ) ) { |
|
806 | - if ( $field_type = $this->get_field_type( $form_meta_key ) ) { |
|
807 | - switch ( $field_type ) { |
|
805 | + if (isset($_POST[$form_meta_key])) { |
|
806 | + if ($field_type = $this->get_field_type($form_meta_key)) { |
|
807 | + switch ($field_type) { |
|
808 | 808 | case 'textarea': |
809 | 809 | case 'wysiwyg': |
810 | - $form_meta_value = wp_kses_post( $_POST[ $form_meta_key ] ); |
|
811 | - update_post_meta( $post_id, $form_meta_key, $form_meta_value ); |
|
810 | + $form_meta_value = wp_kses_post($_POST[$form_meta_key]); |
|
811 | + update_post_meta($post_id, $form_meta_key, $form_meta_value); |
|
812 | 812 | break; |
813 | 813 | |
814 | 814 | case 'group': |
815 | 815 | $form_meta_value = array(); |
816 | 816 | |
817 | - foreach ( $_POST[ $form_meta_key ] as $index => $group ) { |
|
817 | + foreach ($_POST[$form_meta_key] as $index => $group) { |
|
818 | 818 | |
819 | 819 | // Do not save template input field values. |
820 | - if ( '{{row-count-placeholder}}' === $index ) { |
|
820 | + if ('{{row-count-placeholder}}' === $index) { |
|
821 | 821 | continue; |
822 | 822 | } |
823 | 823 | |
824 | 824 | $group_meta_value = array(); |
825 | - foreach ( $group as $field_id => $field_value ) { |
|
826 | - switch ( $this->get_field_type( $field_id, $form_meta_key ) ) { |
|
825 | + foreach ($group as $field_id => $field_value) { |
|
826 | + switch ($this->get_field_type($field_id, $form_meta_key)) { |
|
827 | 827 | case 'wysiwyg': |
828 | - $group_meta_value[ $field_id ] = wp_kses_post( $field_value ); |
|
828 | + $group_meta_value[$field_id] = wp_kses_post($field_value); |
|
829 | 829 | break; |
830 | 830 | |
831 | 831 | default: |
832 | - $group_meta_value[ $field_id ] = give_clean( $field_value ); |
|
832 | + $group_meta_value[$field_id] = give_clean($field_value); |
|
833 | 833 | } |
834 | 834 | } |
835 | 835 | |
836 | - if ( ! empty( $group_meta_value ) ) { |
|
837 | - $form_meta_value[ $index ] = $group_meta_value; |
|
836 | + if ( ! empty($group_meta_value)) { |
|
837 | + $form_meta_value[$index] = $group_meta_value; |
|
838 | 838 | } |
839 | 839 | } |
840 | 840 | |
841 | 841 | |
842 | 842 | // Arrange repeater field keys in order. |
843 | - $form_meta_value = array_values( $form_meta_value ); |
|
843 | + $form_meta_value = array_values($form_meta_value); |
|
844 | 844 | |
845 | 845 | // Save data. |
846 | - update_post_meta( $post_id, $form_meta_key, $form_meta_value ); |
|
846 | + update_post_meta($post_id, $form_meta_key, $form_meta_value); |
|
847 | 847 | break; |
848 | 848 | |
849 | 849 | default: |
850 | - $form_meta_value = give_clean( $_POST[ $form_meta_key ] ); |
|
850 | + $form_meta_value = give_clean($_POST[$form_meta_key]); |
|
851 | 851 | |
852 | 852 | // Save data. |
853 | - update_post_meta( $post_id, $form_meta_key, $form_meta_value ); |
|
853 | + update_post_meta($post_id, $form_meta_key, $form_meta_value); |
|
854 | 854 | } |
855 | 855 | |
856 | 856 | // Fire after saving form meta key. |
857 | - do_action( "give_save_{$form_meta_key}", $form_meta_key, $form_meta_value, $post_id, $post ); |
|
857 | + do_action("give_save_{$form_meta_key}", $form_meta_key, $form_meta_value, $post_id, $post); |
|
858 | 858 | } |
859 | 859 | } |
860 | 860 | } |
861 | 861 | } |
862 | 862 | |
863 | 863 | // Fire action after saving form meta. |
864 | - do_action( 'give_post_process_give_forms_meta', $post_id, $post ); |
|
864 | + do_action('give_post_process_give_forms_meta', $post_id, $post); |
|
865 | 865 | } |
866 | 866 | |
867 | 867 | |
@@ -874,10 +874,10 @@ discard block |
||
874 | 874 | * |
875 | 875 | * @return string |
876 | 876 | */ |
877 | - private function get_field_id( $field ) { |
|
877 | + private function get_field_id($field) { |
|
878 | 878 | $field_id = ''; |
879 | 879 | |
880 | - if ( array_key_exists( 'id', $field ) ) { |
|
880 | + if (array_key_exists('id', $field)) { |
|
881 | 881 | $field_id = $field['id']; |
882 | 882 | |
883 | 883 | } |
@@ -894,12 +894,12 @@ discard block |
||
894 | 894 | * |
895 | 895 | * @return array |
896 | 896 | */ |
897 | - private function get_fields_id( $setting ) { |
|
897 | + private function get_fields_id($setting) { |
|
898 | 898 | $meta_keys = array(); |
899 | 899 | |
900 | - if ( ! empty( $setting ) ) { |
|
901 | - foreach ( $setting['fields'] as $field ) { |
|
902 | - if ( $field_id = $this->get_field_id( $field ) ) { |
|
900 | + if ( ! empty($setting)) { |
|
901 | + foreach ($setting['fields'] as $field) { |
|
902 | + if ($field_id = $this->get_field_id($field)) { |
|
903 | 903 | $meta_keys[] = $field_id; |
904 | 904 | } |
905 | 905 | } |
@@ -917,14 +917,14 @@ discard block |
||
917 | 917 | * |
918 | 918 | * @return array |
919 | 919 | */ |
920 | - private function get_sub_fields_id( $setting ) { |
|
920 | + private function get_sub_fields_id($setting) { |
|
921 | 921 | $meta_keys = array(); |
922 | 922 | |
923 | - if ( $this->has_sub_tab( $setting ) && ! empty( $setting['sub-fields'] ) ) { |
|
924 | - foreach ( $setting['sub-fields'] as $fields ) { |
|
925 | - if ( ! empty( $fields['fields'] ) ) { |
|
926 | - foreach ( $fields['fields'] as $field ) { |
|
927 | - if ( $field_id = $this->get_field_id( $field ) ) { |
|
923 | + if ($this->has_sub_tab($setting) && ! empty($setting['sub-fields'])) { |
|
924 | + foreach ($setting['sub-fields'] as $fields) { |
|
925 | + if ( ! empty($fields['fields'])) { |
|
926 | + foreach ($fields['fields'] as $field) { |
|
927 | + if ($field_id = $this->get_field_id($field)) { |
|
928 | 928 | $meta_keys[] = $field_id; |
929 | 929 | } |
930 | 930 | } |
@@ -945,14 +945,14 @@ discard block |
||
945 | 945 | private function get_meta_keys_from_settings() { |
946 | 946 | $meta_keys = array(); |
947 | 947 | |
948 | - foreach ( $this->settings as $setting ) { |
|
949 | - if ( $this->has_sub_tab( $setting ) ) { |
|
950 | - $meta_key = $this->get_sub_fields_id( $setting ); |
|
948 | + foreach ($this->settings as $setting) { |
|
949 | + if ($this->has_sub_tab($setting)) { |
|
950 | + $meta_key = $this->get_sub_fields_id($setting); |
|
951 | 951 | } else { |
952 | - $meta_key = $this->get_fields_id( $setting ); |
|
952 | + $meta_key = $this->get_fields_id($setting); |
|
953 | 953 | } |
954 | 954 | |
955 | - $meta_keys = array_merge( $meta_keys, $meta_key ); |
|
955 | + $meta_keys = array_merge($meta_keys, $meta_key); |
|
956 | 956 | } |
957 | 957 | |
958 | 958 | return $meta_keys; |
@@ -969,10 +969,10 @@ discard block |
||
969 | 969 | * |
970 | 970 | * @return string |
971 | 971 | */ |
972 | - function get_field_type( $field_id, $group_id = '' ) { |
|
973 | - $field = $this->get_setting_field( $field_id, $group_id ); |
|
972 | + function get_field_type($field_id, $group_id = '') { |
|
973 | + $field = $this->get_setting_field($field_id, $group_id); |
|
974 | 974 | |
975 | - $type = array_key_exists( 'type', $field ) |
|
975 | + $type = array_key_exists('type', $field) |
|
976 | 976 | ? $field['type'] |
977 | 977 | : ''; |
978 | 978 | |
@@ -990,12 +990,12 @@ discard block |
||
990 | 990 | * |
991 | 991 | * @return array |
992 | 992 | */ |
993 | - private function get_field( $setting, $field_id ) { |
|
993 | + private function get_field($setting, $field_id) { |
|
994 | 994 | $setting_field = array(); |
995 | 995 | |
996 | - if ( ! empty( $setting['fields'] ) ) { |
|
997 | - foreach ( $setting['fields'] as $field ) { |
|
998 | - if ( array_key_exists( 'id', $field ) && $field['id'] === $field_id ) { |
|
996 | + if ( ! empty($setting['fields'])) { |
|
997 | + foreach ($setting['fields'] as $field) { |
|
998 | + if (array_key_exists('id', $field) && $field['id'] === $field_id) { |
|
999 | 999 | $setting_field = $field; |
1000 | 1000 | break; |
1001 | 1001 | } |
@@ -1015,12 +1015,12 @@ discard block |
||
1015 | 1015 | * |
1016 | 1016 | * @return array |
1017 | 1017 | */ |
1018 | - private function get_sub_field( $setting, $field_id ) { |
|
1018 | + private function get_sub_field($setting, $field_id) { |
|
1019 | 1019 | $setting_field = array(); |
1020 | 1020 | |
1021 | - if ( ! empty( $setting['sub-fields'] ) ) { |
|
1022 | - foreach ( $setting['sub-fields'] as $fields ) { |
|
1023 | - if ( $field = $this->get_field( $fields, $field_id ) ) { |
|
1021 | + if ( ! empty($setting['sub-fields'])) { |
|
1022 | + foreach ($setting['sub-fields'] as $fields) { |
|
1023 | + if ($field = $this->get_field($fields, $field_id)) { |
|
1024 | 1024 | $setting_field = $field; |
1025 | 1025 | break; |
1026 | 1026 | } |
@@ -1040,17 +1040,17 @@ discard block |
||
1040 | 1040 | * |
1041 | 1041 | * @return array |
1042 | 1042 | */ |
1043 | - function get_setting_field( $field_id, $group_id = '' ) { |
|
1043 | + function get_setting_field($field_id, $group_id = '') { |
|
1044 | 1044 | $setting_field = array(); |
1045 | 1045 | |
1046 | 1046 | $_field_id = $field_id; |
1047 | - $field_id = empty( $group_id ) ? $field_id : $group_id; |
|
1047 | + $field_id = empty($group_id) ? $field_id : $group_id; |
|
1048 | 1048 | |
1049 | - if ( ! empty( $this->settings ) ) { |
|
1050 | - foreach ( $this->settings as $setting ) { |
|
1049 | + if ( ! empty($this->settings)) { |
|
1050 | + foreach ($this->settings as $setting) { |
|
1051 | 1051 | if ( |
1052 | - ( $this->has_sub_tab( $setting ) && ( $setting_field = $this->get_sub_field( $setting, $field_id ) ) ) |
|
1053 | - || ( $setting_field = $this->get_field( $setting, $field_id ) ) |
|
1052 | + ($this->has_sub_tab($setting) && ($setting_field = $this->get_sub_field($setting, $field_id))) |
|
1053 | + || ($setting_field = $this->get_field($setting, $field_id)) |
|
1054 | 1054 | ) { |
1055 | 1055 | break; |
1056 | 1056 | } |
@@ -1059,9 +1059,9 @@ discard block |
||
1059 | 1059 | |
1060 | 1060 | |
1061 | 1061 | // Get field from group. |
1062 | - if ( ! empty( $group_id ) ) { |
|
1063 | - foreach ( $setting_field['fields'] as $field ) { |
|
1064 | - if ( array_key_exists( 'id', $field ) && $field['id'] === $_field_id ) { |
|
1062 | + if ( ! empty($group_id)) { |
|
1063 | + foreach ($setting_field['fields'] as $field) { |
|
1064 | + if (array_key_exists('id', $field) && $field['id'] === $_field_id) { |
|
1065 | 1065 | $setting_field = $field; |
1066 | 1066 | } |
1067 | 1067 | } |
@@ -1080,14 +1080,14 @@ discard block |
||
1080 | 1080 | * |
1081 | 1081 | * @return mixed |
1082 | 1082 | */ |
1083 | - function add_offline_donations_setting_tab( $settings ) { |
|
1084 | - if ( give_is_gateway_active( 'offline' ) ) { |
|
1085 | - $settings['offline_donations_options'] = apply_filters( 'give_forms_offline_donations_options', array( |
|
1083 | + function add_offline_donations_setting_tab($settings) { |
|
1084 | + if (give_is_gateway_active('offline')) { |
|
1085 | + $settings['offline_donations_options'] = apply_filters('give_forms_offline_donations_options', array( |
|
1086 | 1086 | 'id' => 'offline_donations_options', |
1087 | - 'title' => esc_html__( 'Offline Donations', 'give' ), |
|
1087 | + 'title' => esc_html__('Offline Donations', 'give'), |
|
1088 | 1088 | 'icon-html' => '<span class="give-icon give-icon-purse"></span>', |
1089 | - 'fields' => apply_filters( 'give_forms_offline_donations_metabox_fields', array() ), |
|
1090 | - ) ); |
|
1089 | + 'fields' => apply_filters('give_forms_offline_donations_metabox_fields', array()), |
|
1090 | + )); |
|
1091 | 1091 | } |
1092 | 1092 | |
1093 | 1093 | return $settings; |
@@ -641,9 +641,12 @@ discard block |
||
641 | 641 | <a href="#<?php echo $form_data_tab['id']; ?>"> |
642 | 642 | <?php if ( ! empty( $form_data_tab['icon-html'] ) ) : ?> |
643 | 643 | <?php echo $form_data_tab['icon-html']; ?> |
644 | - <?php else : ?> |
|
644 | + <?php else { |
|
645 | + : ?> |
|
645 | 646 | <span class="give-icon give-icon-default"></span> |
646 | - <?php endif; ?> |
|
647 | + <?php endif; |
|
648 | +} |
|
649 | +?> |
|
647 | 650 | <span class="give-label"><?php echo $form_data_tab['label']; ?></span> |
648 | 651 | </a> |
649 | 652 | <?php if ( $this->has_sub_tab( $form_data_tab ) ) : ?> |
@@ -653,9 +656,12 @@ discard block |
||
653 | 656 | <a href="#<?php echo $sub_tab['id']; ?>"> |
654 | 657 | <?php if ( ! empty( $sub_tab['icon-html'] ) ) : ?> |
655 | 658 | <?php echo $sub_tab['icon-html']; ?> |
656 | - <?php else : ?> |
|
659 | + <?php else { |
|
660 | + : ?> |
|
657 | 661 | <span class="give-icon give-icon-default"></span> |
658 | - <?php endif; ?> |
|
662 | + <?php endif; |
|
663 | +} |
|
664 | +?> |
|
659 | 665 | <span class="give-label"><?php echo $sub_tab['label']; ?></span> |
660 | 666 | </a> |
661 | 667 | </li> |
@@ -682,11 +688,14 @@ discard block |
||
682 | 688 | </div> |
683 | 689 | |
684 | 690 | <?php do_action( "give_after_{$setting['id']}_settings" ); ?> |
685 | - <?php else: ?> |
|
691 | + <?php else { |
|
692 | + : ?> |
|
686 | 693 | <?php if ( $this->has_sub_tab( $setting ) ) : ?> |
687 | 694 | <?php if ( ! empty( $setting['sub-fields'] ) ) : ?> |
688 | 695 | <?php foreach ( $setting['sub-fields'] as $index => $sub_fields ) : ?> |
689 | - <div id="<?php echo $sub_fields['id']; ?>" |
|
696 | + <div id="<?php echo $sub_fields['id']; |
|
697 | +} |
|
698 | +?>" |
|
690 | 699 | class="panel give_options_panel give-hidden"> |
691 | 700 | <?php if ( ! empty( $sub_fields['fields'] ) ) : ?> |
692 | 701 | <?php foreach ( $sub_fields['fields'] as $sub_field ) : ?> |
@@ -185,8 +185,8 @@ |
||
185 | 185 | |
186 | 186 | case 'num_donations' : |
187 | 187 | $value = '<a href="' . |
188 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $item['email'] ) |
|
189 | - ) . '">' . esc_html( $item['num_donations'] ) . '</a>'; |
|
188 | + admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $item['email'] ) |
|
189 | + ) . '">' . esc_html( $item['num_donations'] ) . '</a>'; |
|
190 | 190 | break; |
191 | 191 | |
192 | 192 | case 'amount_spent' : |
@@ -10,13 +10,13 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
17 | 17 | // Load WP_List_Table if not loaded |
18 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
19 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
18 | +if ( ! class_exists('WP_List_Table')) { |
|
19 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | public function __construct() { |
62 | 62 | |
63 | 63 | // Set parent defaults |
64 | - parent::__construct( array( |
|
65 | - 'singular' => esc_html__( 'Donor', 'give' ), // Singular name of the listed records |
|
66 | - 'plural' => esc_html__( 'Donors', 'give' ), // Plural name of the listed records |
|
64 | + parent::__construct(array( |
|
65 | + 'singular' => esc_html__('Donor', 'give'), // Singular name of the listed records |
|
66 | + 'plural' => esc_html__('Donors', 'give'), // Plural name of the listed records |
|
67 | 67 | 'ajax' => false // Does this table support ajax? |
68 | - ) ); |
|
68 | + )); |
|
69 | 69 | |
70 | 70 | } |
71 | 71 | |
@@ -80,20 +80,20 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return void |
82 | 82 | */ |
83 | - public function search_box( $text, $input_id ) { |
|
84 | - $input_id = $input_id . '-search-input'; |
|
83 | + public function search_box($text, $input_id) { |
|
84 | + $input_id = $input_id.'-search-input'; |
|
85 | 85 | |
86 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
87 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
86 | + if ( ! empty($_REQUEST['orderby'])) { |
|
87 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
88 | 88 | } |
89 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
90 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
89 | + if ( ! empty($_REQUEST['order'])) { |
|
90 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
91 | 91 | } |
92 | 92 | ?> |
93 | 93 | <p class="search-box" role="search"> |
94 | 94 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
95 | 95 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/> |
96 | - <?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?> |
|
96 | + <?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?> |
|
97 | 97 | </p> |
98 | 98 | <?php |
99 | 99 | } |
@@ -109,29 +109,29 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @return string Column Name. |
111 | 111 | */ |
112 | - public function column_default( $item, $column_name ) { |
|
113 | - switch ( $column_name ) { |
|
112 | + public function column_default($item, $column_name) { |
|
113 | + switch ($column_name) { |
|
114 | 114 | |
115 | 115 | case 'num_donations' : |
116 | - $value = '<a href="' . |
|
117 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $item['email'] ) |
|
118 | - ) . '">' . esc_html( $item['num_donations'] ) . '</a>'; |
|
116 | + $value = '<a href="'. |
|
117 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.urlencode($item['email']) |
|
118 | + ).'">'.esc_html($item['num_donations']).'</a>'; |
|
119 | 119 | break; |
120 | 120 | |
121 | 121 | case 'amount_spent' : |
122 | - $value = give_currency_filter( give_format_amount( $item[ $column_name ] ) ); |
|
122 | + $value = give_currency_filter(give_format_amount($item[$column_name])); |
|
123 | 123 | break; |
124 | 124 | |
125 | 125 | case 'date_created' : |
126 | - $value = date_i18n( give_date_format(), strtotime( $item['date_created'] ) ); |
|
126 | + $value = date_i18n(give_date_format(), strtotime($item['date_created'])); |
|
127 | 127 | break; |
128 | 128 | |
129 | 129 | default: |
130 | - $value = isset( $item[ $column_name ] ) ? $item[ $column_name ] : null; |
|
130 | + $value = isset($item[$column_name]) ? $item[$column_name] : null; |
|
131 | 131 | break; |
132 | 132 | } |
133 | 133 | |
134 | - return apply_filters( "give_report_column_{$column_name}", $value, $item['id'] ); |
|
134 | + return apply_filters("give_report_column_{$column_name}", $value, $item['id']); |
|
135 | 135 | |
136 | 136 | } |
137 | 137 | |
@@ -142,13 +142,13 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @return string |
144 | 144 | */ |
145 | - public function column_name( $item ) { |
|
146 | - $name = '#' . $item['id'] . ' '; |
|
147 | - $name .= ! empty( $item['name'] ) ? $item['name'] : '<em>' . esc_html__( 'Unnamed Donor', 'give' ) . '</em>'; |
|
148 | - $view_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $item['id'] ); |
|
149 | - $actions = $this->get_row_actions( $item ); |
|
145 | + public function column_name($item) { |
|
146 | + $name = '#'.$item['id'].' '; |
|
147 | + $name .= ! empty($item['name']) ? $item['name'] : '<em>'.esc_html__('Unnamed Donor', 'give').'</em>'; |
|
148 | + $view_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$item['id']); |
|
149 | + $actions = $this->get_row_actions($item); |
|
150 | 150 | |
151 | - return '<a href="' . esc_url( $view_url ) . '">' . $name . '</a>' . $this->row_actions( $actions ); |
|
151 | + return '<a href="'.esc_url($view_url).'">'.$name.'</a>'.$this->row_actions($actions); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -160,14 +160,14 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function get_columns() { |
162 | 162 | $columns = array( |
163 | - 'name' => esc_html__( 'Name', 'give' ), |
|
164 | - 'email' => esc_html__( 'Email', 'give' ), |
|
165 | - 'num_donations' => esc_html__( 'Donations', 'give' ), |
|
166 | - 'amount_spent' => esc_html__( 'Total Donated', 'give' ), |
|
167 | - 'date_created' => esc_html__( 'Date Created', 'give' ) |
|
163 | + 'name' => esc_html__('Name', 'give'), |
|
164 | + 'email' => esc_html__('Email', 'give'), |
|
165 | + 'num_donations' => esc_html__('Donations', 'give'), |
|
166 | + 'amount_spent' => esc_html__('Total Donated', 'give'), |
|
167 | + 'date_created' => esc_html__('Date Created', 'give') |
|
168 | 168 | ); |
169 | 169 | |
170 | - return apply_filters( 'give_report_customer_columns', $columns ); |
|
170 | + return apply_filters('give_report_customer_columns', $columns); |
|
171 | 171 | |
172 | 172 | } |
173 | 173 | |
@@ -181,13 +181,13 @@ discard block |
||
181 | 181 | public function get_sortable_columns() { |
182 | 182 | |
183 | 183 | $columns = array( |
184 | - 'date_created' => array( 'date_created', true ), |
|
185 | - 'name' => array( 'name', true ), |
|
186 | - 'num_donations' => array( 'purchase_count', false ), |
|
187 | - 'amount_spent' => array( 'purchase_value', false ), |
|
184 | + 'date_created' => array('date_created', true), |
|
185 | + 'name' => array('name', true), |
|
186 | + 'num_donations' => array('purchase_count', false), |
|
187 | + 'amount_spent' => array('purchase_value', false), |
|
188 | 188 | ); |
189 | 189 | |
190 | - return apply_filters( 'give_report_sortable_customer_columns', $columns ); |
|
190 | + return apply_filters('give_report_sortable_customer_columns', $columns); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
@@ -200,34 +200,34 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return array An array of action links. |
202 | 202 | */ |
203 | - public function get_row_actions( $item ) { |
|
203 | + public function get_row_actions($item) { |
|
204 | 204 | |
205 | 205 | $actions = array( |
206 | 206 | |
207 | 207 | 'view' => sprintf( |
208 | 208 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
209 | - admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $item['id'] ), |
|
210 | - sprintf( esc_attr__( 'View "%s"', 'give' ), $item['name'] ), |
|
211 | - esc_html__( 'View Donor', 'give' ) |
|
209 | + admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$item['id']), |
|
210 | + sprintf(esc_attr__('View "%s"', 'give'), $item['name']), |
|
211 | + esc_html__('View Donor', 'give') |
|
212 | 212 | ), |
213 | 213 | |
214 | 214 | 'notes' => sprintf( |
215 | 215 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
216 | - admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $item['id'] ), |
|
217 | - sprintf( esc_attr__( 'Notes for "%s"', 'give' ), $item['name'] ), |
|
218 | - esc_html__( 'Notes', 'give' ) |
|
216 | + admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$item['id']), |
|
217 | + sprintf(esc_attr__('Notes for "%s"', 'give'), $item['name']), |
|
218 | + esc_html__('Notes', 'give') |
|
219 | 219 | ), |
220 | 220 | |
221 | 221 | 'delete' => sprintf( |
222 | 222 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
223 | - admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $item['id'] ), |
|
224 | - sprintf( esc_attr__( 'Delete "%s"', 'give' ), $item['name'] ), |
|
225 | - esc_html__( 'Delete', 'give' ) |
|
223 | + admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$item['id']), |
|
224 | + sprintf(esc_attr__('Delete "%s"', 'give'), $item['name']), |
|
225 | + esc_html__('Delete', 'give') |
|
226 | 226 | ) |
227 | 227 | |
228 | 228 | ); |
229 | 229 | |
230 | - return apply_filters( 'give_donor_row_actions', $actions, $item ); |
|
230 | + return apply_filters('give_donor_row_actions', $actions, $item); |
|
231 | 231 | |
232 | 232 | } |
233 | 233 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @since 1.0 |
242 | 242 | * @return void |
243 | 243 | */ |
244 | - public function bulk_actions( $which = '' ) { |
|
244 | + public function bulk_actions($which = '') { |
|
245 | 245 | // These aren't really bulk actions but this outputs the markup in the right place. |
246 | 246 | } |
247 | 247 | |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * @return int Current page number. |
254 | 254 | */ |
255 | 255 | public function get_paged() { |
256 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
256 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | * @return mixed string If search is present, false otherwise. |
265 | 265 | */ |
266 | 266 | public function get_search() { |
267 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
267 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | /** |
@@ -281,13 +281,13 @@ discard block |
||
281 | 281 | |
282 | 282 | // Get donor query. |
283 | 283 | $args = $this->get_donor_query(); |
284 | - $customers = Give()->customers->get_customers( $args ); |
|
284 | + $customers = Give()->customers->get_customers($args); |
|
285 | 285 | |
286 | - if ( $customers ) { |
|
286 | + if ($customers) { |
|
287 | 287 | |
288 | - foreach ( $customers as $customer ) { |
|
288 | + foreach ($customers as $customer) { |
|
289 | 289 | |
290 | - $user_id = ! empty( $customer->user_id ) ? intval( $customer->user_id ) : 0; |
|
290 | + $user_id = ! empty($customer->user_id) ? intval($customer->user_id) : 0; |
|
291 | 291 | |
292 | 292 | $data[] = array( |
293 | 293 | 'id' => $customer->id, |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | } |
302 | 302 | } |
303 | 303 | |
304 | - return apply_filters( 'give_donors_column_query_data', $data ); |
|
304 | + return apply_filters('give_donors_column_query_data', $data); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | /** |
@@ -315,9 +315,9 @@ discard block |
||
315 | 315 | $_donor_query = $this->get_donor_query(); |
316 | 316 | |
317 | 317 | $_donor_query['number'] = - 1; |
318 | - $donors = Give()->customers->get_customers( $_donor_query ); |
|
318 | + $donors = Give()->customers->get_customers($_donor_query); |
|
319 | 319 | |
320 | - return count( $donors ); |
|
320 | + return count($donors); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | /** |
@@ -329,10 +329,10 @@ discard block |
||
329 | 329 | */ |
330 | 330 | public function get_donor_query() { |
331 | 331 | $paged = $this->get_paged(); |
332 | - $offset = $this->per_page * ( $paged - 1 ); |
|
332 | + $offset = $this->per_page * ($paged - 1); |
|
333 | 333 | $search = $this->get_search(); |
334 | - $order = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC'; |
|
335 | - $orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id'; |
|
334 | + $order = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC'; |
|
335 | + $orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id'; |
|
336 | 336 | |
337 | 337 | $args = array( |
338 | 338 | 'number' => $this->per_page, |
@@ -341,10 +341,10 @@ discard block |
||
341 | 341 | 'orderby' => $orderby, |
342 | 342 | ); |
343 | 343 | |
344 | - if ( $search ) { |
|
345 | - if ( is_email( $search ) ) { |
|
344 | + if ($search) { |
|
345 | + if (is_email($search)) { |
|
346 | 346 | $args['email'] = $search; |
347 | - } elseif ( is_numeric( $search ) ) { |
|
347 | + } elseif (is_numeric($search)) { |
|
348 | 348 | $args['id'] = $search; |
349 | 349 | } else { |
350 | 350 | $args['name'] = $search; |
@@ -371,16 +371,16 @@ discard block |
||
371 | 371 | $hidden = array(); // No hidden columns |
372 | 372 | $sortable = $this->get_sortable_columns(); |
373 | 373 | |
374 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
374 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
375 | 375 | |
376 | 376 | $this->items = $this->donor_data(); |
377 | 377 | |
378 | 378 | $this->total = $this->get_donor_count(); |
379 | 379 | |
380 | - $this->set_pagination_args( array( |
|
380 | + $this->set_pagination_args(array( |
|
381 | 381 | 'total_items' => $this->total, |
382 | 382 | 'per_page' => $this->per_page, |
383 | - 'total_pages' => ceil( $this->total / $this->per_page ) |
|
384 | - ) ); |
|
383 | + 'total_pages' => ceil($this->total / $this->per_page) |
|
384 | + )); |
|
385 | 385 | } |
386 | 386 | } |
387 | 387 | \ No newline at end of file |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_Gateways' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_Gateways')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_Gateways. |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function __construct() { |
29 | 29 | $this->id = 'gateways'; |
30 | - $this->label = esc_html__( 'Payment Gateways', 'give' ); |
|
30 | + $this->label = esc_html__('Payment Gateways', 'give'); |
|
31 | 31 | |
32 | 32 | $this->default_tab = 'gateways-settings'; |
33 | 33 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $settings = array(); |
45 | 45 | $current_section = give_get_current_setting_section(); |
46 | 46 | |
47 | - switch ( $current_section ) { |
|
47 | + switch ($current_section) { |
|
48 | 48 | case 'paypal-standard': |
49 | 49 | $settings = array( |
50 | 50 | // Section 2: Paypal Standard. |
@@ -53,44 +53,44 @@ discard block |
||
53 | 53 | 'id' => 'give_title_gateway_settings_2', |
54 | 54 | ), |
55 | 55 | array( |
56 | - 'name' => esc_html__( 'PayPal Email', 'give' ), |
|
57 | - 'desc' => esc_html__( 'Enter your PayPal account\'s email.', 'give' ), |
|
56 | + 'name' => esc_html__('PayPal Email', 'give'), |
|
57 | + 'desc' => esc_html__('Enter your PayPal account\'s email.', 'give'), |
|
58 | 58 | 'id' => 'paypal_email', |
59 | 59 | 'type' => 'email', |
60 | 60 | ), |
61 | 61 | array( |
62 | - 'name' => esc_html__( 'PayPal Page Style', 'give' ), |
|
63 | - 'desc' => esc_html__( 'Enter the name of the PayPal page style to use, or leave blank to use the default.', 'give' ), |
|
62 | + 'name' => esc_html__('PayPal Page Style', 'give'), |
|
63 | + 'desc' => esc_html__('Enter the name of the PayPal page style to use, or leave blank to use the default.', 'give'), |
|
64 | 64 | 'id' => 'paypal_page_style', |
65 | 65 | 'type' => 'text', |
66 | 66 | ), |
67 | 67 | array( |
68 | - 'name' => esc_html__( 'PayPal Transaction Type', 'give' ), |
|
69 | - 'desc' => esc_html__( 'Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give' ), |
|
68 | + 'name' => esc_html__('PayPal Transaction Type', 'give'), |
|
69 | + 'desc' => esc_html__('Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give'), |
|
70 | 70 | 'id' => 'paypal_button_type', |
71 | 71 | 'type' => 'radio_inline', |
72 | 72 | 'options' => array( |
73 | - 'donation' => esc_html__( 'Donation', 'give' ), |
|
74 | - 'standard' => esc_html__( 'Standard Transaction', 'give' ) |
|
73 | + 'donation' => esc_html__('Donation', 'give'), |
|
74 | + 'standard' => esc_html__('Standard Transaction', 'give') |
|
75 | 75 | ), |
76 | 76 | 'default' => 'donation', |
77 | 77 | ), |
78 | 78 | array( |
79 | - 'name' => esc_html__( 'PayPal IPN Verification', 'give' ), |
|
80 | - 'desc' => esc_html__( 'If donations are not getting marked as complete, use a slightly less secure method of verifying donations.', 'give' ), |
|
79 | + 'name' => esc_html__('PayPal IPN Verification', 'give'), |
|
80 | + 'desc' => esc_html__('If donations are not getting marked as complete, use a slightly less secure method of verifying donations.', 'give'), |
|
81 | 81 | 'id' => 'paypal_verification', |
82 | 82 | 'type' => 'radio_inline', |
83 | 83 | 'default' => 'enabled', |
84 | 84 | 'options' => array( |
85 | - 'enabled' => __( 'Enabled', 'give' ), |
|
86 | - 'disabled' => __( 'Disabled', 'give' ), |
|
85 | + 'enabled' => __('Enabled', 'give'), |
|
86 | + 'disabled' => __('Disabled', 'give'), |
|
87 | 87 | ) |
88 | 88 | ), |
89 | 89 | array( |
90 | - 'name' => esc_html__( 'PayPal Standard Gateway Settings Docs Link', 'give' ), |
|
90 | + 'name' => esc_html__('PayPal Standard Gateway Settings Docs Link', 'give'), |
|
91 | 91 | 'id' => 'paypal_standard_gateway_settings_docs_link', |
92 | - 'url' => esc_url( 'http://docs.givewp.com/settings-gateway-paypal-standard' ), |
|
93 | - 'title' => __( 'PayPal Standard Gateway Settings', 'give' ), |
|
92 | + 'url' => esc_url('http://docs.givewp.com/settings-gateway-paypal-standard'), |
|
93 | + 'title' => __('PayPal Standard Gateway Settings', 'give'), |
|
94 | 94 | 'type' => 'give_docs_link', |
95 | 95 | ), |
96 | 96 | array( |
@@ -108,19 +108,19 @@ discard block |
||
108 | 108 | 'id' => 'give_title_gateway_settings_3', |
109 | 109 | ), |
110 | 110 | array( |
111 | - 'name' => esc_html__( 'Collect Billing Details', 'give' ), |
|
112 | - 'desc' => esc_html__( 'Enable to request billing details for offline donations. Will appear above offline donation instructions. Can be enabled/disabled per form.', 'give' ), |
|
111 | + 'name' => esc_html__('Collect Billing Details', 'give'), |
|
112 | + 'desc' => esc_html__('Enable to request billing details for offline donations. Will appear above offline donation instructions. Can be enabled/disabled per form.', 'give'), |
|
113 | 113 | 'id' => 'give_offline_donation_enable_billing_fields', |
114 | 114 | 'type' => 'radio_inline', |
115 | 115 | 'default' => 'disabled', |
116 | 116 | 'options' => array( |
117 | - 'enabled' => __( 'Enabled', 'give' ), |
|
118 | - 'disabled' => __( 'Disabled', 'give' ) |
|
117 | + 'enabled' => __('Enabled', 'give'), |
|
118 | + 'disabled' => __('Disabled', 'give') |
|
119 | 119 | ) |
120 | 120 | ), |
121 | 121 | array( |
122 | - 'name' => esc_html__( 'Offline Donation Instructions', 'give' ), |
|
123 | - 'desc' => esc_html__( 'The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give' ), |
|
122 | + 'name' => esc_html__('Offline Donation Instructions', 'give'), |
|
123 | + 'desc' => esc_html__('The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give'), |
|
124 | 124 | 'id' => 'global_offline_donation_content', |
125 | 125 | 'default' => give_get_default_offline_donation_content(), |
126 | 126 | 'type' => 'wysiwyg', |
@@ -129,15 +129,15 @@ discard block |
||
129 | 129 | ) |
130 | 130 | ), |
131 | 131 | array( |
132 | - 'name' => esc_html__( 'Offline Donation Email Instructions Subject', 'give' ), |
|
133 | - 'desc' => esc_html__( 'Enter the subject line for the donation receipt email.', 'give' ), |
|
132 | + 'name' => esc_html__('Offline Donation Email Instructions Subject', 'give'), |
|
133 | + 'desc' => esc_html__('Enter the subject line for the donation receipt email.', 'give'), |
|
134 | 134 | 'id' => 'offline_donation_subject', |
135 | - 'default' => esc_attr__( '{donation} - Offline Donation Instructions', 'give' ), |
|
135 | + 'default' => esc_attr__('{donation} - Offline Donation Instructions', 'give'), |
|
136 | 136 | 'type' => 'text' |
137 | 137 | ), |
138 | 138 | array( |
139 | - 'name' => esc_html__( 'Offline Donation Email Instructions', 'give' ), |
|
140 | - 'desc' => esc_html__( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ) . ' ' . __( 'Available template tags:', 'give' ) . give_get_emails_tags_list(), |
|
139 | + 'name' => esc_html__('Offline Donation Email Instructions', 'give'), |
|
140 | + 'desc' => esc_html__('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give').' '.__('Available template tags:', 'give').give_get_emails_tags_list(), |
|
141 | 141 | 'id' => 'global_offline_donation_email', |
142 | 142 | 'default' => give_get_default_offline_donation_email_content(), |
143 | 143 | 'type' => 'wysiwyg', |
@@ -146,10 +146,10 @@ discard block |
||
146 | 146 | ) |
147 | 147 | ), |
148 | 148 | array( |
149 | - 'name' => esc_html__( 'Offline Donations Settings Docs Link', 'give' ), |
|
149 | + 'name' => esc_html__('Offline Donations Settings Docs Link', 'give'), |
|
150 | 150 | 'id' => 'offline_gateway_settings_docs_link', |
151 | - 'url' => esc_url( 'http://docs.givewp.com/settings-gateway-offline-donations' ), |
|
152 | - 'title' => __( 'Offline Gateway Settings', 'give' ), |
|
151 | + 'url' => esc_url('http://docs.givewp.com/settings-gateway-offline-donations'), |
|
152 | + 'title' => __('Offline Gateway Settings', 'give'), |
|
153 | 153 | 'type' => 'give_docs_link', |
154 | 154 | ), |
155 | 155 | array( |
@@ -167,33 +167,33 @@ discard block |
||
167 | 167 | 'type' => 'title' |
168 | 168 | ), |
169 | 169 | array( |
170 | - 'name' => esc_html__( 'Test Mode', 'give' ), |
|
171 | - 'desc' => esc_html__( 'While in test mode no live donations are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give' ), |
|
170 | + 'name' => esc_html__('Test Mode', 'give'), |
|
171 | + 'desc' => esc_html__('While in test mode no live donations are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give'), |
|
172 | 172 | 'id' => 'test_mode', |
173 | 173 | 'type' => 'radio_inline', |
174 | 174 | 'default' => 'disabled', |
175 | 175 | 'options' => array( |
176 | - 'enabled' => __( 'Enabled', 'give' ), |
|
177 | - 'disabled' => __( 'Disabled', 'give' ), |
|
176 | + 'enabled' => __('Enabled', 'give'), |
|
177 | + 'disabled' => __('Disabled', 'give'), |
|
178 | 178 | ) |
179 | 179 | ), |
180 | 180 | array( |
181 | - 'name' => esc_html__( 'Enabled Gateways', 'give' ), |
|
182 | - 'desc' => esc_html__( 'Enable your payment gateway. Can be ordered by dragging.', 'give' ), |
|
181 | + 'name' => esc_html__('Enabled Gateways', 'give'), |
|
182 | + 'desc' => esc_html__('Enable your payment gateway. Can be ordered by dragging.', 'give'), |
|
183 | 183 | 'id' => 'gateways', |
184 | 184 | 'type' => 'enabled_gateways' |
185 | 185 | ), |
186 | 186 | array( |
187 | - 'name' => esc_html__( 'Default Gateway', 'give' ), |
|
188 | - 'desc' => esc_html__( 'The gateway that will be selected by default.', 'give' ), |
|
187 | + 'name' => esc_html__('Default Gateway', 'give'), |
|
188 | + 'desc' => esc_html__('The gateway that will be selected by default.', 'give'), |
|
189 | 189 | 'id' => 'default_gateway', |
190 | 190 | 'type' => 'default_gateway' |
191 | 191 | ), |
192 | 192 | array( |
193 | - 'name' => esc_html__( 'Gateways Docs Link', 'give' ), |
|
193 | + 'name' => esc_html__('Gateways Docs Link', 'give'), |
|
194 | 194 | 'id' => 'gateway_settings_docs_link', |
195 | - 'url' => esc_url( 'http://docs.givewp.com/settings-gateways' ), |
|
196 | - 'title' => __( 'Gateway Settings', 'give' ), |
|
195 | + 'url' => esc_url('http://docs.givewp.com/settings-gateways'), |
|
196 | + 'title' => __('Gateway Settings', 'give'), |
|
197 | 197 | 'type' => 'give_docs_link', |
198 | 198 | ), |
199 | 199 | array( |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * Filter the payment gateways settings. |
209 | 209 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 |
210 | 210 | */ |
211 | - $settings = apply_filters( 'give_settings_gateways', $settings ); |
|
211 | + $settings = apply_filters('give_settings_gateways', $settings); |
|
212 | 212 | |
213 | 213 | /** |
214 | 214 | * Filter the settings. |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | * |
218 | 218 | * @param array $settings |
219 | 219 | */ |
220 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
220 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
221 | 221 | |
222 | 222 | // Output. |
223 | 223 | return $settings; |
@@ -231,12 +231,12 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public function get_sections() { |
233 | 233 | $sections = array( |
234 | - 'gateways-settings' => esc_html__( 'Gateways', 'give' ), |
|
235 | - 'paypal-standard' => esc_html__( 'Paypal Standard', 'give' ), |
|
236 | - 'offline-donations' => esc_html__( 'Offline', 'give' ) |
|
234 | + 'gateways-settings' => esc_html__('Gateways', 'give'), |
|
235 | + 'paypal-standard' => esc_html__('Paypal Standard', 'give'), |
|
236 | + 'offline-donations' => esc_html__('Offline', 'give') |
|
237 | 237 | ); |
238 | 238 | |
239 | - return apply_filters( 'give_get_sections_' . $this->id, $sections ); |
|
239 | + return apply_filters('give_get_sections_'.$this->id, $sections); |
|
240 | 240 | } |
241 | 241 | } |
242 | 242 |
@@ -249,10 +249,10 @@ |
||
249 | 249 | $admin_message .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n\n"; |
250 | 250 | |
251 | 251 | $admin_message .= sprintf( |
252 | - '<a href="%1$s">%2$s</a>', |
|
253 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment_id ), |
|
254 | - __( 'Click Here to View and/or Update Donation Details', 'give' ) |
|
255 | - ) . "\n\n"; |
|
252 | + '<a href="%1$s">%2$s</a>', |
|
253 | + admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment_id ), |
|
254 | + __( 'Click Here to View and/or Update Donation Details', 'give' ) |
|
255 | + ) . "\n\n"; |
|
256 | 256 | |
257 | 257 | $admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id ); |
258 | 258 | $admin_message = give_do_email_tags( $admin_message, $payment_id ); |
@@ -18,17 +18,17 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return array |
20 | 20 | */ |
21 | -function give_offline_register_gateway( $gateways ) { |
|
21 | +function give_offline_register_gateway($gateways) { |
|
22 | 22 | // Format: ID => Name |
23 | 23 | $gateways['offline'] = array( |
24 | - 'admin_label' => esc_attr__( 'Offline Donation', 'give' ), |
|
25 | - 'checkout_label' => esc_attr__( 'Offline Donation', 'give' ) |
|
24 | + 'admin_label' => esc_attr__('Offline Donation', 'give'), |
|
25 | + 'checkout_label' => esc_attr__('Offline Donation', 'give') |
|
26 | 26 | ); |
27 | 27 | |
28 | 28 | return $gateways; |
29 | 29 | } |
30 | 30 | |
31 | -add_filter( 'give_payment_gateways', 'give_offline_register_gateway', 1 ); |
|
31 | +add_filter('give_payment_gateways', 'give_offline_register_gateway', 1); |
|
32 | 32 | |
33 | 33 | |
34 | 34 | /** |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return void |
42 | 42 | */ |
43 | -function give_offline_payment_cc_form( $form_id ) { |
|
43 | +function give_offline_payment_cc_form($form_id) { |
|
44 | 44 | // Get offline payment instruction. |
45 | - $offline_instructions = give_get_offline_payment_instruction( $form_id, true ); |
|
45 | + $offline_instructions = give_get_offline_payment_instruction($form_id, true); |
|
46 | 46 | |
47 | 47 | ob_start(); |
48 | 48 | |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @param int $form_id Give form id. |
55 | 55 | */ |
56 | - do_action( 'give_before_offline_info_fields', $form_id ); |
|
56 | + do_action('give_before_offline_info_fields', $form_id); |
|
57 | 57 | ?> |
58 | 58 | <fieldset id="give_offline_payment_info"> |
59 | - <?php echo stripslashes( $offline_instructions ); ?> |
|
59 | + <?php echo stripslashes($offline_instructions); ?> |
|
60 | 60 | </fieldset> |
61 | 61 | <?php |
62 | 62 | /** |
@@ -66,35 +66,35 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @param int $form_id Give form id. |
68 | 68 | */ |
69 | - do_action( 'give_after_offline_info_fields', $form_id ); |
|
69 | + do_action('give_after_offline_info_fields', $form_id); |
|
70 | 70 | |
71 | 71 | echo ob_get_clean(); |
72 | 72 | } |
73 | 73 | |
74 | -add_action( 'give_offline_cc_form', 'give_offline_payment_cc_form' ); |
|
74 | +add_action('give_offline_cc_form', 'give_offline_payment_cc_form'); |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Give Offline Billing Field |
78 | 78 | * |
79 | 79 | * @param $form_id |
80 | 80 | */ |
81 | -function give_offline_billing_fields( $form_id ) { |
|
81 | +function give_offline_billing_fields($form_id) { |
|
82 | 82 | //Enable Default CC fields (billing info) |
83 | - $post_offline_cc_fields = get_post_meta( $form_id, '_give_offline_donation_enable_billing_fields_single', true ); |
|
84 | - $post_offline_customize_option = get_post_meta( $form_id, '_give_customize_offline_donations', true ); |
|
83 | + $post_offline_cc_fields = get_post_meta($form_id, '_give_offline_donation_enable_billing_fields_single', true); |
|
84 | + $post_offline_customize_option = get_post_meta($form_id, '_give_customize_offline_donations', true); |
|
85 | 85 | |
86 | - $global_offline_cc_fields = give_get_option( 'give_offline_donation_enable_billing_fields' ); |
|
86 | + $global_offline_cc_fields = give_get_option('give_offline_donation_enable_billing_fields'); |
|
87 | 87 | |
88 | 88 | //Output CC Address fields if global option is on and user hasn't elected to customize this form's offline donation options |
89 | 89 | if ( |
90 | - ( give_is_setting_enabled( $post_offline_customize_option, 'global' ) && give_is_setting_enabled( $global_offline_cc_fields ) ) |
|
91 | - || ( give_is_setting_enabled( $post_offline_customize_option, 'enabled' ) && give_is_setting_enabled( $post_offline_cc_fields ) ) |
|
90 | + (give_is_setting_enabled($post_offline_customize_option, 'global') && give_is_setting_enabled($global_offline_cc_fields)) |
|
91 | + || (give_is_setting_enabled($post_offline_customize_option, 'enabled') && give_is_setting_enabled($post_offline_cc_fields)) |
|
92 | 92 | ) { |
93 | - give_default_cc_address_fields( $form_id ); |
|
93 | + give_default_cc_address_fields($form_id); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
97 | -add_action( 'give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1 ); |
|
97 | +add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1); |
|
98 | 98 | |
99 | 99 | /** |
100 | 100 | * Process the payment |
@@ -105,16 +105,16 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return void |
107 | 107 | */ |
108 | -function give_offline_process_payment( $purchase_data ) { |
|
108 | +function give_offline_process_payment($purchase_data) { |
|
109 | 109 | |
110 | - $purchase_summary = give_get_purchase_summary( $purchase_data ); |
|
110 | + $purchase_summary = give_get_purchase_summary($purchase_data); |
|
111 | 111 | |
112 | 112 | // setup the payment details |
113 | 113 | $payment_data = array( |
114 | 114 | 'price' => $purchase_data['price'], |
115 | 115 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
116 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
117 | - 'give_price_id' => isset( $purchase_data['post_data']['give-price-id'] ) ? $purchase_data['post_data']['give-price-id'] : '', |
|
116 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
117 | + 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', |
|
118 | 118 | 'date' => $purchase_data['date'], |
119 | 119 | 'user_email' => $purchase_data['user_email'], |
120 | 120 | 'purchase_key' => $purchase_data['purchase_key'], |
@@ -126,20 +126,20 @@ discard block |
||
126 | 126 | |
127 | 127 | |
128 | 128 | // record the pending payment |
129 | - $payment = give_insert_payment( $payment_data ); |
|
129 | + $payment = give_insert_payment($payment_data); |
|
130 | 130 | |
131 | - if ( $payment ) { |
|
132 | - give_offline_send_admin_notice( $payment ); |
|
133 | - give_offline_send_donor_instructions( $payment ); |
|
131 | + if ($payment) { |
|
132 | + give_offline_send_admin_notice($payment); |
|
133 | + give_offline_send_donor_instructions($payment); |
|
134 | 134 | give_send_to_success_page(); |
135 | 135 | } else { |
136 | 136 | // if errors are present, send the user back to the donation form so they can be corrected |
137 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
137 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | } |
141 | 141 | |
142 | -add_action( 'give_gateway_offline', 'give_offline_process_payment' ); |
|
142 | +add_action('give_gateway_offline', 'give_offline_process_payment'); |
|
143 | 143 | |
144 | 144 | |
145 | 145 | /** |
@@ -152,59 +152,59 @@ discard block |
||
152 | 152 | * @since 1.0 |
153 | 153 | * @return void |
154 | 154 | */ |
155 | -function give_offline_send_donor_instructions( $payment_id = 0 ) { |
|
155 | +function give_offline_send_donor_instructions($payment_id = 0) { |
|
156 | 156 | |
157 | - $payment_data = give_get_payment_meta( $payment_id ); |
|
158 | - $post_offline_customization_option = get_post_meta( $payment_data['form_id'], '_give_customize_offline_donations', true ); |
|
157 | + $payment_data = give_get_payment_meta($payment_id); |
|
158 | + $post_offline_customization_option = get_post_meta($payment_data['form_id'], '_give_customize_offline_donations', true); |
|
159 | 159 | |
160 | 160 | //Customize email content depending on whether the single form has been customized |
161 | - $email_content = give_get_option( 'global_offline_donation_email' ); |
|
161 | + $email_content = give_get_option('global_offline_donation_email'); |
|
162 | 162 | |
163 | - if ( give_is_setting_enabled( $post_offline_customization_option, 'enabled' ) ) { |
|
164 | - $email_content = get_post_meta( $payment_data['form_id'], '_give_offline_donation_email', true ); |
|
163 | + if (give_is_setting_enabled($post_offline_customization_option, 'enabled')) { |
|
164 | + $email_content = get_post_meta($payment_data['form_id'], '_give_offline_donation_email', true); |
|
165 | 165 | } |
166 | 166 | |
167 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
167 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
168 | 168 | |
169 | 169 | /** |
170 | 170 | * Filters the from name. |
171 | 171 | * |
172 | 172 | * @since 1.7 |
173 | 173 | */ |
174 | - $from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data ); |
|
174 | + $from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data); |
|
175 | 175 | |
176 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
176 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
177 | 177 | |
178 | 178 | /** |
179 | 179 | * Filters the from email. |
180 | 180 | * |
181 | 181 | * @since 1.7 |
182 | 182 | */ |
183 | - $from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data ); |
|
183 | + $from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data); |
|
184 | 184 | |
185 | - $to_email = give_get_payment_user_email( $payment_id ); |
|
185 | + $to_email = give_get_payment_user_email($payment_id); |
|
186 | 186 | |
187 | - $subject = give_get_option( 'offline_donation_subject', __( 'Offline Donation Instructions', 'give' ) ); |
|
188 | - if ( give_is_setting_enabled( $post_offline_customization_option, 'enabled' ) ) { |
|
189 | - $subject = get_post_meta( $payment_data['form_id'], '_give_offline_donation_subject', true ); |
|
187 | + $subject = give_get_option('offline_donation_subject', __('Offline Donation Instructions', 'give')); |
|
188 | + if (give_is_setting_enabled($post_offline_customization_option, 'enabled')) { |
|
189 | + $subject = get_post_meta($payment_data['form_id'], '_give_offline_donation_subject', true); |
|
190 | 190 | } |
191 | 191 | |
192 | - $subject = apply_filters( 'give_offline_donation_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
193 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
192 | + $subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id); |
|
193 | + $subject = give_do_email_tags($subject, $payment_id); |
|
194 | 194 | |
195 | - $attachments = apply_filters( 'give_offline_donation_attachments', array(), $payment_id, $payment_data ); |
|
196 | - $message = give_do_email_tags( $email_content, $payment_id ); |
|
195 | + $attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data); |
|
196 | + $message = give_do_email_tags($email_content, $payment_id); |
|
197 | 197 | |
198 | 198 | $emails = Give()->emails; |
199 | 199 | |
200 | - $emails->__set( 'from_name', $from_name ); |
|
201 | - $emails->__set( 'from_email', $from_email ); |
|
202 | - $emails->__set( 'heading', __( 'Offline Donation Instructions', 'give' ) ); |
|
200 | + $emails->__set('from_name', $from_name); |
|
201 | + $emails->__set('from_email', $from_email); |
|
202 | + $emails->__set('heading', __('Offline Donation Instructions', 'give')); |
|
203 | 203 | |
204 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data ); |
|
205 | - $emails->__set( 'headers', $headers ); |
|
204 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); |
|
205 | + $emails->__set('headers', $headers); |
|
206 | 206 | |
207 | - $emails->send( $to_email, $subject, $message, $attachments ); |
|
207 | + $emails->send($to_email, $subject, $message, $attachments); |
|
208 | 208 | |
209 | 209 | } |
210 | 210 | |
@@ -221,52 +221,52 @@ discard block |
||
221 | 221 | * @return void |
222 | 222 | * |
223 | 223 | */ |
224 | -function give_offline_send_admin_notice( $payment_id = 0 ) { |
|
224 | +function give_offline_send_admin_notice($payment_id = 0) { |
|
225 | 225 | |
226 | 226 | /* Send an email notification to the admin */ |
227 | 227 | $admin_email = give_get_admin_notice_emails(); |
228 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
228 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
229 | 229 | |
230 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) { |
|
231 | - $user_data = get_userdata( $user_info['id'] ); |
|
230 | + if (isset($user_info['id']) && $user_info['id'] > 0) { |
|
231 | + $user_data = get_userdata($user_info['id']); |
|
232 | 232 | $name = $user_data->display_name; |
233 | - } elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) { |
|
234 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
233 | + } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { |
|
234 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
235 | 235 | } else { |
236 | 236 | $name = $user_info['email']; |
237 | 237 | } |
238 | 238 | |
239 | - $amount = give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ); |
|
239 | + $amount = give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))); |
|
240 | 240 | |
241 | - $admin_subject = apply_filters( 'give_offline_admin_donation_notification_subject', __( 'New Pending Donation', 'give' ), $payment_id ); |
|
241 | + $admin_subject = apply_filters('give_offline_admin_donation_notification_subject', __('New Pending Donation', 'give'), $payment_id); |
|
242 | 242 | |
243 | - $admin_message = __( 'Dear Admin,', 'give' ) . "\n\n"; |
|
244 | - $admin_message .= __( 'An offline donation has been made on your website:', 'give' ) . ' ' . get_bloginfo( 'name' ) . ' '; |
|
245 | - $admin_message .= __( 'Hooray! The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give' ) . "\n\n"; |
|
243 | + $admin_message = __('Dear Admin,', 'give')."\n\n"; |
|
244 | + $admin_message .= __('An offline donation has been made on your website:', 'give').' '.get_bloginfo('name').' '; |
|
245 | + $admin_message .= __('Hooray! The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give')."\n\n"; |
|
246 | 246 | |
247 | 247 | |
248 | - $admin_message .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n"; |
|
249 | - $admin_message .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n\n"; |
|
248 | + $admin_message .= '<strong>'.__('Donor:', 'give').'</strong> {fullname}'."\n"; |
|
249 | + $admin_message .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n\n"; |
|
250 | 250 | |
251 | 251 | $admin_message .= sprintf( |
252 | 252 | '<a href="%1$s">%2$s</a>', |
253 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment_id ), |
|
254 | - __( 'Click Here to View and/or Update Donation Details', 'give' ) |
|
255 | - ) . "\n\n"; |
|
253 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$payment_id), |
|
254 | + __('Click Here to View and/or Update Donation Details', 'give') |
|
255 | + )."\n\n"; |
|
256 | 256 | |
257 | - $admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id ); |
|
258 | - $admin_message = give_do_email_tags( $admin_message, $payment_id ); |
|
257 | + $admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id); |
|
258 | + $admin_message = give_do_email_tags($admin_message, $payment_id); |
|
259 | 259 | |
260 | - $attachments = apply_filters( 'give_offline_admin_donation_notification_attachments', array(), $payment_id ); |
|
261 | - $admin_headers = apply_filters( 'give_offline_admin_donation_notification_headers', array(), $payment_id ); |
|
260 | + $attachments = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id); |
|
261 | + $admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id); |
|
262 | 262 | |
263 | 263 | //Send Email |
264 | 264 | $emails = Give()->emails; |
265 | - if ( ! empty( $admin_headers ) ) { |
|
266 | - $emails->__set( 'headers', $admin_headers ); |
|
265 | + if ( ! empty($admin_headers)) { |
|
266 | + $emails->__set('headers', $admin_headers); |
|
267 | 267 | } |
268 | 268 | |
269 | - $emails->send( $admin_email, $admin_subject, $admin_message, $attachments ); |
|
269 | + $emails->send($admin_email, $admin_subject, $admin_message, $attachments); |
|
270 | 270 | |
271 | 271 | } |
272 | 272 | |
@@ -278,20 +278,20 @@ discard block |
||
278 | 278 | * |
279 | 279 | * @return array |
280 | 280 | */ |
281 | -function give_offline_add_settings( $settings ) { |
|
281 | +function give_offline_add_settings($settings) { |
|
282 | 282 | |
283 | 283 | // Bailout: Do not show offline gateways setting in to metabox if its disabled globally. |
284 | - if ( in_array( 'offline', give_get_option( 'gateways' ) ) ) { |
|
284 | + if (in_array('offline', give_get_option('gateways'))) { |
|
285 | 285 | return $settings; |
286 | 286 | } |
287 | 287 | |
288 | 288 | //Vars |
289 | 289 | $prefix = '_give_'; |
290 | 290 | |
291 | - $is_gateway_active = give_is_gateway_active( 'offline' ); |
|
291 | + $is_gateway_active = give_is_gateway_active('offline'); |
|
292 | 292 | |
293 | 293 | //this gateway isn't active |
294 | - if ( ! $is_gateway_active ) { |
|
294 | + if ( ! $is_gateway_active) { |
|
295 | 295 | //return settings and bounce |
296 | 296 | return $settings; |
297 | 297 | } |
@@ -300,34 +300,34 @@ discard block |
||
300 | 300 | $check_settings = array( |
301 | 301 | |
302 | 302 | array( |
303 | - 'name' => __( 'Offline Donations', 'give' ), |
|
304 | - 'desc' => __( 'Do you want to customize the donation instructions for this form?', 'give' ), |
|
305 | - 'id' => $prefix . 'customize_offline_donations', |
|
303 | + 'name' => __('Offline Donations', 'give'), |
|
304 | + 'desc' => __('Do you want to customize the donation instructions for this form?', 'give'), |
|
305 | + 'id' => $prefix.'customize_offline_donations', |
|
306 | 306 | 'type' => 'radio_inline', |
307 | 307 | 'default' => 'global', |
308 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
309 | - 'global' => __( 'Global Option', 'give' ), |
|
310 | - 'enabled' => __( 'Customize', 'give' ), |
|
311 | - 'disabled' => __( 'Disable', 'give' ), |
|
308 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
309 | + 'global' => __('Global Option', 'give'), |
|
310 | + 'enabled' => __('Customize', 'give'), |
|
311 | + 'disabled' => __('Disable', 'give'), |
|
312 | 312 | ) |
313 | 313 | ), |
314 | 314 | ), |
315 | 315 | array( |
316 | - 'name' => __( 'Billing Fields', 'give' ), |
|
317 | - 'desc' => __( 'This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give' ), |
|
318 | - 'id' => $prefix . 'offline_donation_enable_billing_fields_single', |
|
316 | + 'name' => __('Billing Fields', 'give'), |
|
317 | + 'desc' => __('This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give'), |
|
318 | + 'id' => $prefix.'offline_donation_enable_billing_fields_single', |
|
319 | 319 | 'row_classes' => 'give-subfield', |
320 | 320 | 'type' => 'radio_inline', |
321 | 321 | 'default' => 'disabled', |
322 | 322 | 'options' => array( |
323 | - 'enabled' => __( 'Enabled', 'give' ), |
|
324 | - 'disabled' => __( 'Disabled', 'give' ), |
|
323 | + 'enabled' => __('Enabled', 'give'), |
|
324 | + 'disabled' => __('Disabled', 'give'), |
|
325 | 325 | ), |
326 | 326 | ), |
327 | 327 | array( |
328 | - 'id' => $prefix . 'offline_checkout_notes', |
|
329 | - 'name' => __( 'Donation Instructions', 'give' ), |
|
330 | - 'desc' => __( 'Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
328 | + 'id' => $prefix.'offline_checkout_notes', |
|
329 | + 'name' => __('Donation Instructions', 'give'), |
|
330 | + 'desc' => __('Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
331 | 331 | 'default' => give_get_default_offline_donation_content(), |
332 | 332 | 'type' => 'wysiwyg', |
333 | 333 | 'row_classes' => 'give-subfield', |
@@ -336,17 +336,17 @@ discard block |
||
336 | 336 | ) |
337 | 337 | ), |
338 | 338 | array( |
339 | - 'id' => $prefix . 'offline_donation_subject', |
|
340 | - 'name' => __( 'Email Subject', 'give' ), |
|
341 | - 'desc' => __( 'Enter the subject line for the donation receipt email.', 'give' ), |
|
342 | - 'default' => __( '{form_title} - Offline Donation Instructions', 'give' ), |
|
339 | + 'id' => $prefix.'offline_donation_subject', |
|
340 | + 'name' => __('Email Subject', 'give'), |
|
341 | + 'desc' => __('Enter the subject line for the donation receipt email.', 'give'), |
|
342 | + 'default' => __('{form_title} - Offline Donation Instructions', 'give'), |
|
343 | 343 | 'row_classes' => 'give-subfield', |
344 | 344 | 'type' => 'text' |
345 | 345 | ), |
346 | 346 | array( |
347 | - 'id' => $prefix . 'offline_donation_email', |
|
348 | - 'name' => __( 'Email Instructions', 'give' ), |
|
349 | - 'desc' => __( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ) . ' ' . __( 'Available template tags:', 'give' ) . give_get_emails_tags_list(), |
|
347 | + 'id' => $prefix.'offline_donation_email', |
|
348 | + 'name' => __('Email Instructions', 'give'), |
|
349 | + 'desc' => __('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give').' '.__('Available template tags:', 'give').give_get_emails_tags_list(), |
|
350 | 350 | 'default' => give_get_default_offline_donation_email_content(), |
351 | 351 | 'type' => 'wysiwyg', |
352 | 352 | 'row_classes' => 'give-subfield', |
@@ -358,14 +358,14 @@ discard block |
||
358 | 358 | 'name' => 'offline_docs', |
359 | 359 | 'type' => 'docs_link', |
360 | 360 | 'url' => 'http://docs.givewp.com/settings-gateway-offline-donations', |
361 | - 'title' => __( 'Offline Donations', 'give' ), |
|
361 | + 'title' => __('Offline Donations', 'give'), |
|
362 | 362 | ), |
363 | 363 | ); |
364 | 364 | |
365 | - return array_merge( $settings, $check_settings ); |
|
365 | + return array_merge($settings, $check_settings); |
|
366 | 366 | } |
367 | 367 | |
368 | -add_filter( 'give_forms_offline_donations_metabox_fields', 'give_offline_add_settings' ); |
|
368 | +add_filter('give_forms_offline_donations_metabox_fields', 'give_offline_add_settings'); |
|
369 | 369 | |
370 | 370 | |
371 | 371 | /** |
@@ -377,32 +377,32 @@ discard block |
||
377 | 377 | */ |
378 | 378 | function give_get_default_offline_donation_content() { |
379 | 379 | |
380 | - $sitename = get_bloginfo( 'sitename' ); |
|
380 | + $sitename = get_bloginfo('sitename'); |
|
381 | 381 | |
382 | - $default_text = '<p>' . __( 'In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>'; |
|
382 | + $default_text = '<p>'.__('In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>'; |
|
383 | 383 | $default_text .= '<ol>'; |
384 | 384 | $default_text .= '<li>'; |
385 | 385 | $default_text .= sprintf( |
386 | 386 | /* translators: %s: site name */ |
387 | - __( 'Make a check payable to "%s"', 'give' ), |
|
387 | + __('Make a check payable to "%s"', 'give'), |
|
388 | 388 | $sitename |
389 | 389 | ); |
390 | 390 | $default_text .= '</li>'; |
391 | 391 | $default_text .= '<li>'; |
392 | 392 | $default_text .= sprintf( |
393 | 393 | /* translators: %s: site name */ |
394 | - __( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
394 | + __('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
395 | 395 | $sitename |
396 | 396 | ); |
397 | 397 | $default_text .= '</li>'; |
398 | - $default_text .= '<li>' . __( 'Please mail your check to:', 'give' ) . '</li>'; |
|
398 | + $default_text .= '<li>'.__('Please mail your check to:', 'give').'</li>'; |
|
399 | 399 | $default_text .= '</ol>'; |
400 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
400 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
401 | 401 | $default_text .= ' <em>123 G Street </em><br>'; |
402 | 402 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
403 | - $default_text .= '<p>' . __( 'All contributions will be gratefully acknowledged and are tax deductible.', 'give' ) . '</p>'; |
|
403 | + $default_text .= '<p>'.__('All contributions will be gratefully acknowledged and are tax deductible.', 'give').'</p>'; |
|
404 | 404 | |
405 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
405 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
406 | 406 | |
407 | 407 | } |
408 | 408 | |
@@ -415,34 +415,34 @@ discard block |
||
415 | 415 | */ |
416 | 416 | function give_get_default_offline_donation_email_content() { |
417 | 417 | |
418 | - $sitename = get_bloginfo( 'sitename' ); |
|
419 | - $default_text = '<p>' . __( 'Dear {name},', 'give' ) . '</p>'; |
|
420 | - $default_text .= '<p>' . __( 'Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give' ) . '</p>'; |
|
418 | + $sitename = get_bloginfo('sitename'); |
|
419 | + $default_text = '<p>'.__('Dear {name},', 'give').'</p>'; |
|
420 | + $default_text .= '<p>'.__('Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give').'</p>'; |
|
421 | 421 | $default_text .= '<ol>'; |
422 | 422 | $default_text .= '<li>'; |
423 | 423 | $default_text .= sprintf( |
424 | 424 | /* translators: %s: site name */ |
425 | - __( 'Make a check payable to "%s"', 'give' ), |
|
425 | + __('Make a check payable to "%s"', 'give'), |
|
426 | 426 | $sitename |
427 | 427 | ); |
428 | 428 | $default_text .= '</li>'; |
429 | 429 | $default_text .= '<li>'; |
430 | 430 | $default_text .= sprintf( |
431 | 431 | /* translators: %s: site name */ |
432 | - __( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
432 | + __('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
433 | 433 | $sitename |
434 | 434 | ); |
435 | 435 | $default_text .= '</li>'; |
436 | - $default_text .= '<li>' . __( 'Please mail your check to:', 'give' ) . '</li>'; |
|
436 | + $default_text .= '<li>'.__('Please mail your check to:', 'give').'</li>'; |
|
437 | 437 | $default_text .= '</ol>'; |
438 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
438 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
439 | 439 | $default_text .= ' <em>123 G Street </em><br>'; |
440 | 440 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
441 | - $default_text .= '<p>' . __( 'Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give' ) . '</p>'; |
|
442 | - $default_text .= '<p>' . __( 'Sincerely,', 'give' ) . '</p>'; |
|
443 | - $default_text .= '<p>' . $sitename . '</p>'; |
|
441 | + $default_text .= '<p>'.__('Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give').'</p>'; |
|
442 | + $default_text .= '<p>'.__('Sincerely,', 'give').'</p>'; |
|
443 | + $default_text .= '<p>'.$sitename.'</p>'; |
|
444 | 444 | |
445 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
445 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
446 | 446 | |
447 | 447 | } |
448 | 448 | |
@@ -456,17 +456,17 @@ discard block |
||
456 | 456 | * |
457 | 457 | * @return string |
458 | 458 | */ |
459 | -function give_offline_donation_receipt_status_notice( $notice, $id ) { |
|
460 | - $payment = new Give_Payment( $id ); |
|
459 | +function give_offline_donation_receipt_status_notice($notice, $id) { |
|
460 | + $payment = new Give_Payment($id); |
|
461 | 461 | |
462 | - if ( 'offline' !== $payment->gateway || $payment->is_completed() ) { |
|
462 | + if ('offline' !== $payment->gateway || $payment->is_completed()) { |
|
463 | 463 | return $notice; |
464 | 464 | } |
465 | 465 | |
466 | - return give_output_error( __( 'Payment Pending: Please follow the instructions below to complete your donation.', 'give' ), false, 'warning' ); |
|
466 | + return give_output_error(__('Payment Pending: Please follow the instructions below to complete your donation.', 'give'), false, 'warning'); |
|
467 | 467 | } |
468 | 468 | |
469 | -add_filter( 'give_receipt_status_notice', 'give_offline_donation_receipt_status_notice', 10, 2 ); |
|
469 | +add_filter('give_receipt_status_notice', 'give_offline_donation_receipt_status_notice', 10, 2); |
|
470 | 470 | |
471 | 471 | /** |
472 | 472 | * Add offline payment instruction on payment receipt. |
@@ -477,26 +477,26 @@ discard block |
||
477 | 477 | * |
478 | 478 | * @return mixed |
479 | 479 | */ |
480 | -function give_offline_payment_receipt_after( $payment ) { |
|
480 | +function give_offline_payment_receipt_after($payment) { |
|
481 | 481 | // Get payment object. |
482 | - $payment = new Give_Payment( $payment->ID ); |
|
482 | + $payment = new Give_Payment($payment->ID); |
|
483 | 483 | |
484 | 484 | // Bailout. |
485 | - if ( 'offline' !== $payment->gateway ) { |
|
485 | + if ('offline' !== $payment->gateway) { |
|
486 | 486 | return false; |
487 | 487 | } |
488 | 488 | |
489 | 489 | ?> |
490 | 490 | <tr> |
491 | - <td scope="row"><strong><?php esc_html_e( 'Offline Payment Instruction:', 'give' ); ?></strong></td> |
|
491 | + <td scope="row"><strong><?php esc_html_e('Offline Payment Instruction:', 'give'); ?></strong></td> |
|
492 | 492 | <td> |
493 | - <?php echo give_get_offline_payment_instruction( $payment->form_id, true ); ?> |
|
493 | + <?php echo give_get_offline_payment_instruction($payment->form_id, true); ?> |
|
494 | 494 | </td> |
495 | 495 | </tr> |
496 | 496 | <?php |
497 | 497 | } |
498 | 498 | |
499 | -add_filter( 'give_payment_receipt_after', 'give_offline_payment_receipt_after' ); |
|
499 | +add_filter('give_payment_receipt_after', 'give_offline_payment_receipt_after'); |
|
500 | 500 | |
501 | 501 | /** |
502 | 502 | * Get offline payment instructions. |
@@ -508,27 +508,27 @@ discard block |
||
508 | 508 | * |
509 | 509 | * @return string |
510 | 510 | */ |
511 | -function give_get_offline_payment_instruction( $form_id, $wpautop = false ) { |
|
511 | +function give_get_offline_payment_instruction($form_id, $wpautop = false) { |
|
512 | 512 | // Bailout. |
513 | - if ( ! $form_id ) { |
|
513 | + if ( ! $form_id) { |
|
514 | 514 | return ''; |
515 | 515 | } |
516 | 516 | |
517 | - $post_offline_customization_option = get_post_meta( $form_id, '_give_customize_offline_donations', true ); |
|
518 | - $post_offline_instructions = get_post_meta( $form_id, '_give_offline_checkout_notes', true ); |
|
519 | - $global_offline_instruction = give_get_option( 'global_offline_donation_content' ); |
|
517 | + $post_offline_customization_option = get_post_meta($form_id, '_give_customize_offline_donations', true); |
|
518 | + $post_offline_instructions = get_post_meta($form_id, '_give_offline_checkout_notes', true); |
|
519 | + $global_offline_instruction = give_get_option('global_offline_donation_content'); |
|
520 | 520 | $offline_instructions = $global_offline_instruction; |
521 | 521 | |
522 | - if ( give_is_setting_enabled( $post_offline_customization_option ) ) { |
|
522 | + if (give_is_setting_enabled($post_offline_customization_option)) { |
|
523 | 523 | $offline_instructions = $post_offline_instructions; |
524 | 524 | } |
525 | 525 | |
526 | - $settings_url = admin_url( 'post.php?post=' . $form_id . '&action=edit&message=1' ); |
|
526 | + $settings_url = admin_url('post.php?post='.$form_id.'&action=edit&message=1'); |
|
527 | 527 | |
528 | 528 | /* translators: %s: form settings url */ |
529 | - $offline_instructions = ! empty( $offline_instructions ) ? $offline_instructions : sprintf( __( 'Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give' ), $settings_url ); |
|
529 | + $offline_instructions = ! empty($offline_instructions) ? $offline_instructions : sprintf(__('Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give'), $settings_url); |
|
530 | 530 | |
531 | - return ( $wpautop ? wpautop( $offline_instructions ) : $offline_instructions ); |
|
531 | + return ($wpautop ? wpautop($offline_instructions) : $offline_instructions); |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | |
@@ -542,24 +542,24 @@ discard block |
||
542 | 542 | * |
543 | 543 | * @return array |
544 | 544 | */ |
545 | -function give_filter_offline_gateway( $gateway_list, $form_id ) { |
|
545 | +function give_filter_offline_gateway($gateway_list, $form_id) { |
|
546 | 546 | if ( |
547 | 547 | // Show offline payment gateway if enable for new donation form. |
548 | - ( false === strpos( $_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms' ) ) |
|
548 | + (false === strpos($_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms')) |
|
549 | 549 | && $form_id |
550 | - && ! give_is_setting_enabled( get_post_meta( $form_id, '_give_customize_offline_donations', true ), array( |
|
550 | + && ! give_is_setting_enabled(get_post_meta($form_id, '_give_customize_offline_donations', true), array( |
|
551 | 551 | 'enabled', |
552 | 552 | 'global', |
553 | - ) ) |
|
553 | + )) |
|
554 | 554 | ) { |
555 | - unset( $gateway_list['offline'] ); |
|
555 | + unset($gateway_list['offline']); |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | // Output. |
559 | 559 | return $gateway_list; |
560 | 560 | } |
561 | 561 | |
562 | -add_filter( 'give_enabled_payment_gateways', 'give_filter_offline_gateway', 10, 2 ); |
|
562 | +add_filter('give_enabled_payment_gateways', 'give_filter_offline_gateway', 10, 2); |
|
563 | 563 | |
564 | 564 | /** |
565 | 565 | * Set default gateway to global default payment gateway |
@@ -573,10 +573,10 @@ discard block |
||
573 | 573 | * |
574 | 574 | * @return void |
575 | 575 | */ |
576 | -function _give_customize_offline_donations_on_save_callback( $meta_key, $meta_value, $postid ) { |
|
577 | - if ( ! give_is_setting_enabled( $meta_value ) && ( 'offline' === get_post_meta( $postid, '_give_default_gateway', true ) ) ) { |
|
578 | - update_post_meta( $postid, '_give_default_gateway', 'global' ); |
|
576 | +function _give_customize_offline_donations_on_save_callback($meta_key, $meta_value, $postid) { |
|
577 | + if ( ! give_is_setting_enabled($meta_value) && ('offline' === get_post_meta($postid, '_give_default_gateway', true))) { |
|
578 | + update_post_meta($postid, '_give_default_gateway', 'global'); |
|
579 | 579 | } |
580 | 580 | } |
581 | 581 | |
582 | -add_filter( 'give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3 ); |
|
582 | +add_filter('give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3); |
@@ -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,38 +26,38 @@ discard block |
||
26 | 26 | function give_donation_history() { |
27 | 27 | |
28 | 28 | // If payment_key query arg exists, return receipt instead of donation history. |
29 | - if ( isset( $_GET['payment_key'] ) ) { |
|
29 | + if (isset($_GET['payment_key'])) { |
|
30 | 30 | ob_start(); |
31 | - echo give_receipt_shortcode( array() ); |
|
32 | - echo '<a href="' . esc_url( give_get_history_page_uri() ) . '">« ' . esc_html__( 'Return to All Donations', 'give' ) . '</a>'; |
|
31 | + echo give_receipt_shortcode(array()); |
|
32 | + echo '<a href="'.esc_url(give_get_history_page_uri()).'">« '.esc_html__('Return to All Donations', 'give').'</a>'; |
|
33 | 33 | |
34 | 34 | return ob_get_clean(); |
35 | 35 | } |
36 | 36 | |
37 | - $email_access = give_get_option( 'email_access' ); |
|
37 | + $email_access = give_get_option('email_access'); |
|
38 | 38 | |
39 | 39 | //Is user logged in? Does a session exist? Does an email-access token exist? |
40 | - if ( is_user_logged_in() || Give()->session->get_session_expiration() !== false || ( $email_access == 'on' && Give()->email_access->token_exists ) ) { |
|
40 | + if (is_user_logged_in() || Give()->session->get_session_expiration() !== false || ($email_access == 'on' && Give()->email_access->token_exists)) { |
|
41 | 41 | ob_start(); |
42 | - give_get_template_part( 'history', 'donations' ); |
|
42 | + give_get_template_part('history', 'donations'); |
|
43 | 43 | |
44 | 44 | return ob_get_clean(); |
45 | 45 | } //Is Email-based access enabled? |
46 | - elseif ( give_is_setting_enabled( $email_access ) ) { |
|
46 | + elseif (give_is_setting_enabled($email_access)) { |
|
47 | 47 | |
48 | 48 | ob_start(); |
49 | - give_get_template_part( 'email', 'login-form' ); |
|
49 | + give_get_template_part('email', 'login-form'); |
|
50 | 50 | |
51 | 51 | return ob_get_clean(); |
52 | 52 | } else { |
53 | - $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' ); |
|
54 | - echo apply_filters( 'give_donation_history_nonuser_message', give_output_error( $message, false ), $message ); |
|
55 | - echo do_shortcode( '[give_login]' ); |
|
53 | + $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'); |
|
54 | + echo apply_filters('give_donation_history_nonuser_message', give_output_error($message, false), $message); |
|
55 | + echo do_shortcode('[give_login]'); |
|
56 | 56 | |
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
60 | -add_shortcode( 'donation_history', 'give_donation_history' ); |
|
60 | +add_shortcode('donation_history', 'give_donation_history'); |
|
61 | 61 | |
62 | 62 | /** |
63 | 63 | * Donation Form Shortcode |
@@ -70,29 +70,29 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @return string |
72 | 72 | */ |
73 | -function give_form_shortcode( $atts ) { |
|
74 | - $atts = shortcode_atts( array( |
|
73 | +function give_form_shortcode($atts) { |
|
74 | + $atts = shortcode_atts(array( |
|
75 | 75 | 'id' => '', |
76 | 76 | 'show_title' => true, |
77 | 77 | 'show_goal' => true, |
78 | 78 | 'show_content' => '', |
79 | 79 | 'float_labels' => '', |
80 | 80 | 'display_style' => '', |
81 | - ), $atts, 'give_form' ); |
|
81 | + ), $atts, 'give_form'); |
|
82 | 82 | |
83 | 83 | // Convert string to bool. |
84 | - $atts['show_title'] = filter_var( $atts['show_title'], FILTER_VALIDATE_BOOLEAN ); |
|
85 | - $atts['show_goal'] = filter_var( $atts['show_goal'], FILTER_VALIDATE_BOOLEAN ); |
|
84 | + $atts['show_title'] = filter_var($atts['show_title'], FILTER_VALIDATE_BOOLEAN); |
|
85 | + $atts['show_goal'] = filter_var($atts['show_goal'], FILTER_VALIDATE_BOOLEAN); |
|
86 | 86 | |
87 | 87 | //get the Give Form |
88 | 88 | ob_start(); |
89 | - give_get_donation_form( $atts ); |
|
89 | + give_get_donation_form($atts); |
|
90 | 90 | $final_output = ob_get_clean(); |
91 | 91 | |
92 | - return apply_filters( 'give_donate_form', $final_output, $atts ); |
|
92 | + return apply_filters('give_donate_form', $final_output, $atts); |
|
93 | 93 | } |
94 | 94 | |
95 | -add_shortcode( 'give_form', 'give_form_shortcode' ); |
|
95 | +add_shortcode('give_form', 'give_form_shortcode'); |
|
96 | 96 | |
97 | 97 | /** |
98 | 98 | * Donation Form Goal Shortcode. |
@@ -105,37 +105,37 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return string |
107 | 107 | */ |
108 | -function give_goal_shortcode( $atts ) { |
|
109 | - $atts = shortcode_atts( array( |
|
108 | +function give_goal_shortcode($atts) { |
|
109 | + $atts = shortcode_atts(array( |
|
110 | 110 | 'id' => '', |
111 | 111 | 'show_text' => true, |
112 | 112 | 'show_bar' => true, |
113 | - ), $atts, 'give_goal' ); |
|
113 | + ), $atts, 'give_goal'); |
|
114 | 114 | |
115 | 115 | |
116 | 116 | //get the Give Form. |
117 | 117 | ob_start(); |
118 | 118 | |
119 | 119 | //Sanity check 1: ensure there is an ID Provided. |
120 | - if ( empty( $atts['id'] ) ) { |
|
121 | - give_output_error( esc_html__( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true ); |
|
120 | + if (empty($atts['id'])) { |
|
121 | + give_output_error(esc_html__('The shortcode is missing Donation Form ID attribute.', 'give'), true); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | //Sanity check 2: Check the form even has Goals enabled. |
125 | - if ( ! give_is_setting_enabled( get_post_meta( $atts['id'], '_give_goal_option', true ) ) ) { |
|
125 | + if ( ! give_is_setting_enabled(get_post_meta($atts['id'], '_give_goal_option', true))) { |
|
126 | 126 | |
127 | - give_output_error( esc_html__( 'The form does not have Goals enabled.', 'give' ), true ); |
|
127 | + give_output_error(esc_html__('The form does not have Goals enabled.', 'give'), true); |
|
128 | 128 | } else { |
129 | 129 | //Passed all sanity checks: output Goal. |
130 | - give_show_goal_progress( $atts['id'], $atts ); |
|
130 | + give_show_goal_progress($atts['id'], $atts); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | $final_output = ob_get_clean(); |
134 | 134 | |
135 | - return apply_filters( 'give_goal_shortcode_output', $final_output, $atts ); |
|
135 | + return apply_filters('give_goal_shortcode_output', $final_output, $atts); |
|
136 | 136 | } |
137 | 137 | |
138 | -add_shortcode( 'give_goal', 'give_goal_shortcode' ); |
|
138 | +add_shortcode('give_goal', 'give_goal_shortcode'); |
|
139 | 139 | |
140 | 140 | |
141 | 141 | /** |
@@ -152,22 +152,22 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return string |
154 | 154 | */ |
155 | -function give_login_form_shortcode( $atts ) { |
|
156 | - $atts = shortcode_atts( array( |
|
155 | +function give_login_form_shortcode($atts) { |
|
156 | + $atts = shortcode_atts(array( |
|
157 | 157 | // Add backward compatibility for redirect attribute. |
158 | 158 | 'redirect' => '', |
159 | 159 | |
160 | 160 | 'login-redirect' => '', |
161 | 161 | 'logout-redirect' => '', |
162 | - ), $atts, 'give_login' ); |
|
162 | + ), $atts, 'give_login'); |
|
163 | 163 | |
164 | 164 | // 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. |
165 | - $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect'] ) ? $atts['redirect'] : '' ); |
|
165 | + $atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : ''); |
|
166 | 166 | |
167 | - return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] ); |
|
167 | + return give_login_form($atts['login-redirect'], $atts['logout-redirect']); |
|
168 | 168 | } |
169 | 169 | |
170 | -add_shortcode( 'give_login', 'give_login_form_shortcode' ); |
|
170 | +add_shortcode('give_login', 'give_login_form_shortcode'); |
|
171 | 171 | |
172 | 172 | /** |
173 | 173 | * Register Shortcode. |
@@ -182,15 +182,15 @@ discard block |
||
182 | 182 | * |
183 | 183 | * @return string |
184 | 184 | */ |
185 | -function give_register_form_shortcode( $atts ) { |
|
186 | - $atts = shortcode_atts( array( |
|
185 | +function give_register_form_shortcode($atts) { |
|
186 | + $atts = shortcode_atts(array( |
|
187 | 187 | 'redirect' => '', |
188 | - ), $atts, 'give_register' ); |
|
188 | + ), $atts, 'give_register'); |
|
189 | 189 | |
190 | - return give_register_form( $atts['redirect'] ); |
|
190 | + return give_register_form($atts['redirect']); |
|
191 | 191 | } |
192 | 192 | |
193 | -add_shortcode( 'give_register', 'give_register_form_shortcode' ); |
|
193 | +add_shortcode('give_register', 'give_register_form_shortcode'); |
|
194 | 194 | |
195 | 195 | /** |
196 | 196 | * Receipt Shortcode. |
@@ -203,12 +203,12 @@ discard block |
||
203 | 203 | * |
204 | 204 | * @return string |
205 | 205 | */ |
206 | -function give_receipt_shortcode( $atts ) { |
|
206 | +function give_receipt_shortcode($atts) { |
|
207 | 207 | |
208 | 208 | global $give_receipt_args, $payment; |
209 | 209 | |
210 | - $give_receipt_args = shortcode_atts( array( |
|
211 | - 'error' => esc_html__( 'You are missing the payment key to view this donation receipt.', 'give' ), |
|
210 | + $give_receipt_args = shortcode_atts(array( |
|
211 | + 'error' => esc_html__('You are missing the payment key to view this donation receipt.', 'give'), |
|
212 | 212 | 'price' => true, |
213 | 213 | 'donor' => true, |
214 | 214 | 'date' => true, |
@@ -217,50 +217,50 @@ discard block |
||
217 | 217 | 'payment_id' => true, |
218 | 218 | 'payment_status' => false, |
219 | 219 | 'status_notice' => true, |
220 | - ), $atts, 'give_receipt' ); |
|
220 | + ), $atts, 'give_receipt'); |
|
221 | 221 | |
222 | 222 | //set $session var |
223 | 223 | $session = give_get_purchase_session(); |
224 | 224 | |
225 | 225 | //set payment key var |
226 | - if ( isset( $_GET['payment_key'] ) ) { |
|
227 | - $payment_key = urldecode( $_GET['payment_key'] ); |
|
228 | - } elseif ( $session ) { |
|
226 | + if (isset($_GET['payment_key'])) { |
|
227 | + $payment_key = urldecode($_GET['payment_key']); |
|
228 | + } elseif ($session) { |
|
229 | 229 | $payment_key = $session['purchase_key']; |
230 | - } elseif ( $give_receipt_args['payment_key'] ) { |
|
230 | + } elseif ($give_receipt_args['payment_key']) { |
|
231 | 231 | $payment_key = $give_receipt_args['payment_key']; |
232 | 232 | } |
233 | 233 | |
234 | - $email_access = give_get_option( 'email_access' ); |
|
234 | + $email_access = give_get_option('email_access'); |
|
235 | 235 | |
236 | 236 | // No payment_key found & Email Access is Turned on: |
237 | - if ( ! isset( $payment_key ) && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) { |
|
237 | + if ( ! isset($payment_key) && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) { |
|
238 | 238 | |
239 | 239 | ob_start(); |
240 | 240 | |
241 | - give_get_template_part( 'email-login-form' ); |
|
241 | + give_get_template_part('email-login-form'); |
|
242 | 242 | |
243 | 243 | return ob_get_clean(); |
244 | 244 | |
245 | - } elseif ( ! isset( $payment_key ) ) { |
|
245 | + } elseif ( ! isset($payment_key)) { |
|
246 | 246 | |
247 | - return give_output_error( $give_receipt_args['error'], false, 'error' ); |
|
247 | + return give_output_error($give_receipt_args['error'], false, 'error'); |
|
248 | 248 | |
249 | 249 | } |
250 | 250 | |
251 | - $payment_id = give_get_purchase_id_by_key( $payment_key ); |
|
252 | - $user_can_view = give_can_view_receipt( $payment_key ); |
|
251 | + $payment_id = give_get_purchase_id_by_key($payment_key); |
|
252 | + $user_can_view = give_can_view_receipt($payment_key); |
|
253 | 253 | |
254 | 254 | // Key was provided, but user is logged out. Offer them the ability to login and view the receipt. |
255 | - if ( ! $user_can_view && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) { |
|
255 | + if ( ! $user_can_view && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) { |
|
256 | 256 | |
257 | 257 | ob_start(); |
258 | 258 | |
259 | - give_get_template_part( 'email-login-form' ); |
|
259 | + give_get_template_part('email-login-form'); |
|
260 | 260 | |
261 | 261 | return ob_get_clean(); |
262 | 262 | |
263 | - } elseif ( ! $user_can_view ) { |
|
263 | + } elseif ( ! $user_can_view) { |
|
264 | 264 | |
265 | 265 | global $give_login_redirect; |
266 | 266 | |
@@ -268,9 +268,9 @@ discard block |
||
268 | 268 | |
269 | 269 | ob_start(); |
270 | 270 | |
271 | - give_output_error( apply_filters( 'give_must_be_logged_in_error_message', esc_html__( 'You must be logged in to view this donation receipt.', 'give' ) ) ); |
|
271 | + give_output_error(apply_filters('give_must_be_logged_in_error_message', esc_html__('You must be logged in to view this donation receipt.', 'give'))); |
|
272 | 272 | |
273 | - give_get_template_part( 'shortcode', 'login' ); |
|
273 | + give_get_template_part('shortcode', 'login'); |
|
274 | 274 | |
275 | 275 | $login_form = ob_get_clean(); |
276 | 276 | |
@@ -285,20 +285,20 @@ discard block |
||
285 | 285 | * or if user is logged in and the user can view sensitive shop data. |
286 | 286 | * |
287 | 287 | */ |
288 | - if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) { |
|
289 | - return give_output_error( $give_receipt_args['error'], false, 'error' ); |
|
288 | + if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) { |
|
289 | + return give_output_error($give_receipt_args['error'], false, 'error'); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | ob_start(); |
293 | 293 | |
294 | - give_get_template_part( 'shortcode', 'receipt' ); |
|
294 | + give_get_template_part('shortcode', 'receipt'); |
|
295 | 295 | |
296 | 296 | $display = ob_get_clean(); |
297 | 297 | |
298 | 298 | return $display; |
299 | 299 | } |
300 | 300 | |
301 | -add_shortcode( 'give_receipt', 'give_receipt_shortcode' ); |
|
301 | +add_shortcode('give_receipt', 'give_receipt_shortcode'); |
|
302 | 302 | |
303 | 303 | /** |
304 | 304 | * Profile Editor Shortcode. |
@@ -317,18 +317,18 @@ discard block |
||
317 | 317 | * |
318 | 318 | * @return string Output generated from the profile editor |
319 | 319 | */ |
320 | -function give_profile_editor_shortcode( $atts ) { |
|
320 | +function give_profile_editor_shortcode($atts) { |
|
321 | 321 | |
322 | 322 | ob_start(); |
323 | 323 | |
324 | - give_get_template_part( 'shortcode', 'profile-editor' ); |
|
324 | + give_get_template_part('shortcode', 'profile-editor'); |
|
325 | 325 | |
326 | 326 | $display = ob_get_clean(); |
327 | 327 | |
328 | 328 | return $display; |
329 | 329 | } |
330 | 330 | |
331 | -add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' ); |
|
331 | +add_shortcode('give_profile_editor', 'give_profile_editor_shortcode'); |
|
332 | 332 | |
333 | 333 | /** |
334 | 334 | * Process Profile Updater Form. |
@@ -341,30 +341,30 @@ discard block |
||
341 | 341 | * |
342 | 342 | * @return bool |
343 | 343 | */ |
344 | -function give_process_profile_editor_updates( $data ) { |
|
344 | +function give_process_profile_editor_updates($data) { |
|
345 | 345 | // Profile field change request |
346 | - if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) { |
|
346 | + if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) { |
|
347 | 347 | return false; |
348 | 348 | } |
349 | 349 | |
350 | 350 | // Nonce security |
351 | - if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) { |
|
351 | + if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) { |
|
352 | 352 | return false; |
353 | 353 | } |
354 | 354 | |
355 | 355 | $user_id = get_current_user_id(); |
356 | - $old_user_data = get_userdata( $user_id ); |
|
357 | - |
|
358 | - $display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name; |
|
359 | - $first_name = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name; |
|
360 | - $last_name = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name; |
|
361 | - $email = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email; |
|
362 | - $line1 = ( isset( $data['give_address_line1'] ) ? sanitize_text_field( $data['give_address_line1'] ) : '' ); |
|
363 | - $line2 = ( isset( $data['give_address_line2'] ) ? sanitize_text_field( $data['give_address_line2'] ) : '' ); |
|
364 | - $city = ( isset( $data['give_address_city'] ) ? sanitize_text_field( $data['give_address_city'] ) : '' ); |
|
365 | - $state = ( isset( $data['give_address_state'] ) ? sanitize_text_field( $data['give_address_state'] ) : '' ); |
|
366 | - $zip = ( isset( $data['give_address_zip'] ) ? sanitize_text_field( $data['give_address_zip'] ) : '' ); |
|
367 | - $country = ( isset( $data['give_address_country'] ) ? sanitize_text_field( $data['give_address_country'] ) : '' ); |
|
356 | + $old_user_data = get_userdata($user_id); |
|
357 | + |
|
358 | + $display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name; |
|
359 | + $first_name = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name; |
|
360 | + $last_name = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name; |
|
361 | + $email = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email; |
|
362 | + $line1 = (isset($data['give_address_line1']) ? sanitize_text_field($data['give_address_line1']) : ''); |
|
363 | + $line2 = (isset($data['give_address_line2']) ? sanitize_text_field($data['give_address_line2']) : ''); |
|
364 | + $city = (isset($data['give_address_city']) ? sanitize_text_field($data['give_address_city']) : ''); |
|
365 | + $state = (isset($data['give_address_state']) ? sanitize_text_field($data['give_address_state']) : ''); |
|
366 | + $zip = (isset($data['give_address_zip']) ? sanitize_text_field($data['give_address_zip']) : ''); |
|
367 | + $country = (isset($data['give_address_country']) ? sanitize_text_field($data['give_address_country']) : ''); |
|
368 | 368 | |
369 | 369 | $userdata = array( |
370 | 370 | 'ID' => $user_id, |
@@ -392,46 +392,46 @@ discard block |
||
392 | 392 | * @param int $user_id The ID of the user. |
393 | 393 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
394 | 394 | */ |
395 | - do_action( 'give_pre_update_user_profile', $user_id, $userdata ); |
|
395 | + do_action('give_pre_update_user_profile', $user_id, $userdata); |
|
396 | 396 | |
397 | 397 | // New password |
398 | - if ( ! empty( $data['give_new_user_pass1'] ) ) { |
|
399 | - if ( $data['give_new_user_pass1'] !== $data['give_new_user_pass2'] ) { |
|
400 | - give_set_error( 'password_mismatch', esc_html__( 'The passwords you entered do not match. Please try again.', 'give' ) ); |
|
398 | + if ( ! empty($data['give_new_user_pass1'])) { |
|
399 | + if ($data['give_new_user_pass1'] !== $data['give_new_user_pass2']) { |
|
400 | + give_set_error('password_mismatch', esc_html__('The passwords you entered do not match. Please try again.', 'give')); |
|
401 | 401 | } else { |
402 | 402 | $userdata['user_pass'] = $data['give_new_user_pass1']; |
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
406 | - if ( empty( $email ) ) { |
|
406 | + if (empty($email)) { |
|
407 | 407 | // Make sure email should not be empty. |
408 | - give_set_error( 'email_empty', esc_html__( 'The email you entered is empty.', 'give' ) ); |
|
408 | + give_set_error('email_empty', esc_html__('The email you entered is empty.', 'give')); |
|
409 | 409 | |
410 | - } else if ( ! is_email( $email ) ) { |
|
410 | + } else if ( ! is_email($email)) { |
|
411 | 411 | // Make sure email should be valid. |
412 | - give_set_error( 'email_not_valid', esc_html__( 'The email you entered is not valid. Please use another', 'give' ) ); |
|
412 | + give_set_error('email_not_valid', esc_html__('The email you entered is not valid. Please use another', 'give')); |
|
413 | 413 | |
414 | - } else if ( $email != $old_user_data->user_email ) { |
|
414 | + } else if ($email != $old_user_data->user_email) { |
|
415 | 415 | // Make sure the new email doesn't belong to another user |
416 | - if ( email_exists( $email ) ) { |
|
417 | - give_set_error( 'email_exists', esc_html__( 'The email you entered belongs to another user. Please use another.', 'give' ) ); |
|
416 | + if (email_exists($email)) { |
|
417 | + give_set_error('email_exists', esc_html__('The email you entered belongs to another user. Please use another.', 'give')); |
|
418 | 418 | } |
419 | 419 | } |
420 | 420 | |
421 | 421 | // Check for errors |
422 | 422 | $errors = give_get_errors(); |
423 | 423 | |
424 | - if ( $errors ) { |
|
424 | + if ($errors) { |
|
425 | 425 | // Send back to the profile editor if there are errors |
426 | - wp_redirect( $data['give_redirect'] ); |
|
426 | + wp_redirect($data['give_redirect']); |
|
427 | 427 | give_die(); |
428 | 428 | } |
429 | 429 | |
430 | 430 | // Update the user |
431 | - $meta = update_user_meta( $user_id, '_give_user_address', $address ); |
|
432 | - $updated = wp_update_user( $userdata ); |
|
431 | + $meta = update_user_meta($user_id, '_give_user_address', $address); |
|
432 | + $updated = wp_update_user($userdata); |
|
433 | 433 | |
434 | - if ( $updated ) { |
|
434 | + if ($updated) { |
|
435 | 435 | |
436 | 436 | /** |
437 | 437 | * Fires after updating user profile. |
@@ -441,12 +441,12 @@ discard block |
||
441 | 441 | * @param int $user_id The ID of the user. |
442 | 442 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
443 | 443 | */ |
444 | - do_action( 'give_user_profile_updated', $user_id, $userdata ); |
|
445 | - wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) ); |
|
444 | + do_action('give_user_profile_updated', $user_id, $userdata); |
|
445 | + wp_redirect(add_query_arg('updated', 'true', $data['give_redirect'])); |
|
446 | 446 | give_die(); |
447 | 447 | } |
448 | 448 | |
449 | 449 | return false; |
450 | 450 | } |
451 | 451 | |
452 | -add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' ); |
|
452 | +add_action('give_edit_user_profile', 'give_process_profile_editor_updates'); |
@@ -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 | |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | */ |
88 | 88 | public function __construct() { |
89 | 89 | |
90 | - if ( 'none' === $this->get_template() ) { |
|
90 | + if ('none' === $this->get_template()) { |
|
91 | 91 | $this->html = false; |
92 | 92 | } |
93 | 93 | |
94 | - add_action( 'give_email_send_before', array( $this, 'send_before' ) ); |
|
95 | - add_action( 'give_email_send_after', array( $this, 'send_after' ) ); |
|
94 | + add_action('give_email_send_before', array($this, 'send_before')); |
|
95 | + add_action('give_email_send_after', array($this, 'send_after')); |
|
96 | 96 | |
97 | 97 | } |
98 | 98 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @param $key |
105 | 105 | * @param $value |
106 | 106 | */ |
107 | - public function __set( $key, $value ) { |
|
107 | + public function __set($key, $value) { |
|
108 | 108 | $this->$key = $value; |
109 | 109 | } |
110 | 110 | |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | * @since 1.0 |
115 | 115 | */ |
116 | 116 | public function get_from_name() { |
117 | - if ( ! $this->from_name ) { |
|
118 | - $this->from_name = give_get_option( 'from_name', get_bloginfo( 'name' ) ); |
|
117 | + if ( ! $this->from_name) { |
|
118 | + $this->from_name = give_get_option('from_name', get_bloginfo('name')); |
|
119 | 119 | } |
120 | 120 | |
121 | - return apply_filters( 'give_email_from_name', wp_specialchars_decode( $this->from_name ), $this ); |
|
121 | + return apply_filters('give_email_from_name', wp_specialchars_decode($this->from_name), $this); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -127,11 +127,11 @@ discard block |
||
127 | 127 | * @since 1.0 |
128 | 128 | */ |
129 | 129 | public function get_from_address() { |
130 | - if ( ! $this->from_address ) { |
|
131 | - $this->from_address = give_get_option( 'from_email', get_option( 'admin_email' ) ); |
|
130 | + if ( ! $this->from_address) { |
|
131 | + $this->from_address = give_get_option('from_email', get_option('admin_email')); |
|
132 | 132 | } |
133 | 133 | |
134 | - return apply_filters( 'give_email_from_address', $this->from_address, $this ); |
|
134 | + return apply_filters('give_email_from_address', $this->from_address, $this); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -140,13 +140,13 @@ discard block |
||
140 | 140 | * @since 1.0 |
141 | 141 | */ |
142 | 142 | public function get_content_type() { |
143 | - if ( ! $this->content_type && $this->html ) { |
|
144 | - $this->content_type = apply_filters( 'give_email_default_content_type', 'text/html', $this ); |
|
145 | - } else if ( ! $this->html ) { |
|
143 | + if ( ! $this->content_type && $this->html) { |
|
144 | + $this->content_type = apply_filters('give_email_default_content_type', 'text/html', $this); |
|
145 | + } else if ( ! $this->html) { |
|
146 | 146 | $this->content_type = 'text/plain'; |
147 | 147 | } |
148 | 148 | |
149 | - return apply_filters( 'give_email_content_type', $this->content_type, $this ); |
|
149 | + return apply_filters('give_email_content_type', $this->content_type, $this); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -155,13 +155,13 @@ discard block |
||
155 | 155 | * @since 1.0 |
156 | 156 | */ |
157 | 157 | public function get_headers() { |
158 | - if ( ! $this->headers ) { |
|
158 | + if ( ! $this->headers) { |
|
159 | 159 | $this->headers = "From: {$this->get_from_name()} <{$this->get_from_address()}>\r\n"; |
160 | 160 | $this->headers .= "Reply-To: {$this->get_from_address()}\r\n"; |
161 | 161 | $this->headers .= "Content-Type: {$this->get_content_type()}; charset=utf-8\r\n"; |
162 | 162 | } |
163 | 163 | |
164 | - return apply_filters( 'give_email_headers', $this->headers, $this ); |
|
164 | + return apply_filters('give_email_headers', $this->headers, $this); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function get_templates() { |
173 | 173 | $templates = array( |
174 | - 'default' => esc_html__( 'Default Template', 'give' ), |
|
175 | - 'none' => esc_html__( 'No template, plain text only', 'give' ) |
|
174 | + 'default' => esc_html__('Default Template', 'give'), |
|
175 | + 'none' => esc_html__('No template, plain text only', 'give') |
|
176 | 176 | ); |
177 | 177 | |
178 | - return apply_filters( 'give_email_templates', $templates ); |
|
178 | + return apply_filters('give_email_templates', $templates); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -184,11 +184,11 @@ discard block |
||
184 | 184 | * @since 1.0 |
185 | 185 | */ |
186 | 186 | public function get_template() { |
187 | - if ( ! $this->template ) { |
|
188 | - $this->template = give_get_option( 'email_template', 'default' ); |
|
187 | + if ( ! $this->template) { |
|
188 | + $this->template = give_get_option('email_template', 'default'); |
|
189 | 189 | } |
190 | 190 | |
191 | - return apply_filters( 'give_email_template', $this->template ); |
|
191 | + return apply_filters('give_email_template', $this->template); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * @since 1.0 |
198 | 198 | */ |
199 | 199 | public function get_heading() { |
200 | - return apply_filters( 'give_email_heading', $this->heading ); |
|
200 | + return apply_filters('give_email_heading', $this->heading); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @return mixed |
209 | 209 | */ |
210 | - public function parse_tags( $content ) { |
|
210 | + public function parse_tags($content) { |
|
211 | 211 | return $content; |
212 | 212 | } |
213 | 213 | |
@@ -220,19 +220,19 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @return string |
222 | 222 | */ |
223 | - public function build_email( $message ) { |
|
223 | + public function build_email($message) { |
|
224 | 224 | |
225 | - if ( false === $this->html ) { |
|
226 | - return apply_filters( 'give_email_message', wp_strip_all_tags( $message ), $this ); |
|
225 | + if (false === $this->html) { |
|
226 | + return apply_filters('give_email_message', wp_strip_all_tags($message), $this); |
|
227 | 227 | } |
228 | 228 | |
229 | - $message = $this->text_to_html( $message ); |
|
229 | + $message = $this->text_to_html($message); |
|
230 | 230 | |
231 | 231 | $template = $this->get_template(); |
232 | 232 | |
233 | 233 | ob_start(); |
234 | 234 | |
235 | - give_get_template_part( 'emails/header', $template, true ); |
|
235 | + give_get_template_part('emails/header', $template, true); |
|
236 | 236 | |
237 | 237 | /** |
238 | 238 | * Fires in the email head. |
@@ -241,17 +241,17 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @param Give_Emails $this The email object. |
243 | 243 | */ |
244 | - do_action( 'give_email_header', $this ); |
|
244 | + do_action('give_email_header', $this); |
|
245 | 245 | |
246 | - if ( has_action( 'give_email_template_' . $template ) ) { |
|
246 | + if (has_action('give_email_template_'.$template)) { |
|
247 | 247 | /** |
248 | 248 | * Fires in a specific email template. |
249 | 249 | * |
250 | 250 | * @since 1.0 |
251 | 251 | */ |
252 | - do_action( "give_email_template_{$template}" ); |
|
252 | + do_action("give_email_template_{$template}"); |
|
253 | 253 | } else { |
254 | - give_get_template_part( 'emails/body', $template, true ); |
|
254 | + give_get_template_part('emails/body', $template, true); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @param Give_Emails $this The email object. |
263 | 263 | */ |
264 | - do_action( 'give_email_body', $this ); |
|
264 | + do_action('give_email_body', $this); |
|
265 | 265 | |
266 | - give_get_template_part( 'emails/footer', $template, true ); |
|
266 | + give_get_template_part('emails/footer', $template, true); |
|
267 | 267 | |
268 | 268 | /** |
269 | 269 | * Fires in the email footer. |
@@ -272,12 +272,12 @@ discard block |
||
272 | 272 | * |
273 | 273 | * @param Give_Emails $this The email object. |
274 | 274 | */ |
275 | - do_action( 'give_email_footer', $this ); |
|
275 | + do_action('give_email_footer', $this); |
|
276 | 276 | |
277 | 277 | $body = ob_get_clean(); |
278 | - $message = str_replace( '{email}', $message, $body ); |
|
278 | + $message = str_replace('{email}', $message, $body); |
|
279 | 279 | |
280 | - return apply_filters( 'give_email_message', $message, $this ); |
|
280 | + return apply_filters('give_email_message', $message, $this); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | /** |
@@ -290,10 +290,10 @@ discard block |
||
290 | 290 | * |
291 | 291 | * @return bool |
292 | 292 | */ |
293 | - public function send( $to, $subject, $message, $attachments = '' ) { |
|
293 | + public function send($to, $subject, $message, $attachments = '') { |
|
294 | 294 | |
295 | - if ( ! did_action( 'init' ) && ! did_action( 'admin_init' ) ) { |
|
296 | - _doing_it_wrong( __FUNCTION__, esc_html__( 'You cannot send email with Give_Emails until init/admin_init has been reached.', 'give' ), null ); |
|
295 | + if ( ! did_action('init') && ! did_action('admin_init')) { |
|
296 | + _doing_it_wrong(__FUNCTION__, esc_html__('You cannot send email with Give_Emails until init/admin_init has been reached.', 'give'), null); |
|
297 | 297 | |
298 | 298 | return false; |
299 | 299 | } |
@@ -305,16 +305,16 @@ discard block |
||
305 | 305 | * |
306 | 306 | * @param Give_Emails $this The email object. |
307 | 307 | */ |
308 | - do_action( 'give_email_send_before', $this ); |
|
308 | + do_action('give_email_send_before', $this); |
|
309 | 309 | |
310 | - $subject = $this->parse_tags( $subject ); |
|
311 | - $message = $this->parse_tags( $message ); |
|
310 | + $subject = $this->parse_tags($subject); |
|
311 | + $message = $this->parse_tags($message); |
|
312 | 312 | |
313 | - $message = $this->build_email( $message ); |
|
313 | + $message = $this->build_email($message); |
|
314 | 314 | |
315 | - $attachments = apply_filters( 'give_email_attachments', $attachments, $this ); |
|
315 | + $attachments = apply_filters('give_email_attachments', $attachments, $this); |
|
316 | 316 | |
317 | - $sent = wp_mail( $to, $subject, $message, $this->get_headers(), $attachments ); |
|
317 | + $sent = wp_mail($to, $subject, $message, $this->get_headers(), $attachments); |
|
318 | 318 | |
319 | 319 | /** |
320 | 320 | * Fires after sending an email. |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | * |
324 | 324 | * @param Give_Emails $this The email object. |
325 | 325 | */ |
326 | - do_action( 'give_email_send_after', $this ); |
|
326 | + do_action('give_email_send_after', $this); |
|
327 | 327 | |
328 | 328 | return $sent; |
329 | 329 | |
@@ -335,9 +335,9 @@ discard block |
||
335 | 335 | * @since 1.0 |
336 | 336 | */ |
337 | 337 | public function send_before() { |
338 | - add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); |
|
339 | - add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); |
|
340 | - add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); |
|
338 | + add_filter('wp_mail_from', array($this, 'get_from_address')); |
|
339 | + add_filter('wp_mail_from_name', array($this, 'get_from_name')); |
|
340 | + add_filter('wp_mail_content_type', array($this, 'get_content_type')); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
@@ -346,9 +346,9 @@ discard block |
||
346 | 346 | * @since 1.0 |
347 | 347 | */ |
348 | 348 | public function send_after() { |
349 | - remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); |
|
350 | - remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); |
|
351 | - remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); |
|
349 | + remove_filter('wp_mail_from', array($this, 'get_from_address')); |
|
350 | + remove_filter('wp_mail_from_name', array($this, 'get_from_name')); |
|
351 | + remove_filter('wp_mail_content_type', array($this, 'get_content_type')); |
|
352 | 352 | |
353 | 353 | // Reset heading to an empty string |
354 | 354 | $this->heading = ''; |
@@ -359,10 +359,10 @@ discard block |
||
359 | 359 | * |
360 | 360 | * @since 1.0 |
361 | 361 | */ |
362 | - public function text_to_html( $message ) { |
|
362 | + public function text_to_html($message) { |
|
363 | 363 | |
364 | - if ( 'text/html' == $this->content_type || true === $this->html ) { |
|
365 | - $message = wpautop( $message ); |
|
364 | + if ('text/html' == $this->content_type || true === $this->html) { |
|
365 | + $message = wpautop($message); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | return $message; |
@@ -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,7 +30,7 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @since 1.0 |
32 | 32 | */ |
33 | - do_action( 'give_pre_process_donation' ); |
|
33 | + do_action('give_pre_process_donation'); |
|
34 | 34 | |
35 | 35 | // Validate the form $_POST data |
36 | 36 | $valid_data = give_purchase_form_validate_fields(); |
@@ -45,26 +45,26 @@ discard block |
||
45 | 45 | * @param bool|array $valid_data Validate fields. |
46 | 46 | * @param array $_POST Array of variables passed via the HTTP POST. |
47 | 47 | */ |
48 | - do_action( 'give_checkout_error_checks', $valid_data, $_POST ); |
|
48 | + do_action('give_checkout_error_checks', $valid_data, $_POST); |
|
49 | 49 | |
50 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
50 | + $is_ajax = isset($_POST['give_ajax']); |
|
51 | 51 | |
52 | 52 | // Process the login form |
53 | - if ( isset( $_POST['give_login_submit'] ) ) { |
|
53 | + if (isset($_POST['give_login_submit'])) { |
|
54 | 54 | give_process_form_login(); |
55 | 55 | } |
56 | 56 | |
57 | 57 | // Validate the user |
58 | - $user = give_get_purchase_form_user( $valid_data ); |
|
58 | + $user = give_get_purchase_form_user($valid_data); |
|
59 | 59 | |
60 | - if ( false === $valid_data || give_get_errors() || ! $user ) { |
|
61 | - if ( $is_ajax ) { |
|
60 | + if (false === $valid_data || give_get_errors() || ! $user) { |
|
61 | + if ($is_ajax) { |
|
62 | 62 | /** |
63 | 63 | * Fires when AJAX sends back errors from the donation form. |
64 | 64 | * |
65 | 65 | * @since 1.0 |
66 | 66 | */ |
67 | - do_action( 'give_ajax_donation_errors' ); |
|
67 | + do_action('give_ajax_donation_errors'); |
|
68 | 68 | give_die(); |
69 | 69 | } else { |
70 | 70 | return false; |
@@ -72,17 +72,17 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | // If AJAX send back success to proceed with form submission |
75 | - if ( $is_ajax ) { |
|
75 | + if ($is_ajax) { |
|
76 | 76 | echo 'success'; |
77 | 77 | give_die(); |
78 | 78 | } |
79 | 79 | |
80 | 80 | // After AJAX: Setup session if not using php_sessions |
81 | - if ( ! Give()->session->use_php_sessions() ) { |
|
81 | + if ( ! Give()->session->use_php_sessions()) { |
|
82 | 82 | // Double-check that set_cookie is publicly accessible; |
83 | 83 | // we're using a slightly modified class-wp-sessions.php |
84 | - $session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' ); |
|
85 | - if ( $session_reflection->isPublic() ) { |
|
84 | + $session_reflection = new ReflectionMethod('WP_Session', 'set_cookie'); |
|
85 | + if ($session_reflection->isPublic()) { |
|
86 | 86 | // Manually set the cookie. |
87 | 87 | Give()->session->init()->set_cookie(); |
88 | 88 | } |
@@ -97,18 +97,18 @@ discard block |
||
97 | 97 | 'address' => $user['address'], |
98 | 98 | ); |
99 | 99 | |
100 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
100 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
101 | 101 | |
102 | - $price = isset( $_POST['give-amount'] ) ? (float) apply_filters( 'give_donation_total', give_sanitize_amount( give_format_amount( $_POST['give-amount'] ) ) ) : '0.00'; |
|
103 | - $purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); |
|
102 | + $price = isset($_POST['give-amount']) ? (float) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00'; |
|
103 | + $purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); |
|
104 | 104 | |
105 | 105 | // Setup donation information |
106 | 106 | $purchase_data = array( |
107 | 107 | 'price' => $price, |
108 | 108 | 'purchase_key' => $purchase_key, |
109 | 109 | 'user_email' => $user['user_email'], |
110 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
111 | - 'user_info' => stripslashes_deep( $user_info ), |
|
110 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
111 | + 'user_info' => stripslashes_deep($user_info), |
|
112 | 112 | 'post_data' => $_POST, |
113 | 113 | 'gateway' => $valid_data['gateway'], |
114 | 114 | 'card_info' => $valid_data['cc_info'], |
@@ -128,10 +128,10 @@ discard block |
||
128 | 128 | * @param array $user_info Array containing basic user information. |
129 | 129 | * @param bool|array $valid_data Validate fields. |
130 | 130 | */ |
131 | - do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data ); |
|
131 | + do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data); |
|
132 | 132 | |
133 | 133 | // Sanity check for price |
134 | - if ( ! $purchase_data['price'] ) { |
|
134 | + if ( ! $purchase_data['price']) { |
|
135 | 135 | // Revert to manual |
136 | 136 | $purchase_data['gateway'] = 'manual'; |
137 | 137 | $_POST['give-gateway'] = 'manual'; |
@@ -142,27 +142,27 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @since 1.7 |
144 | 144 | */ |
145 | - $purchase_data = apply_filters( 'give_donation_data_before_gateway', $purchase_data, $valid_data ); |
|
145 | + $purchase_data = apply_filters('give_donation_data_before_gateway', $purchase_data, $valid_data); |
|
146 | 146 | |
147 | 147 | // Setup the data we're storing in the donation session |
148 | 148 | $session_data = $purchase_data; |
149 | 149 | |
150 | 150 | // Make sure credit card numbers are never stored in sessions |
151 | - unset( $session_data['card_info']['card_number'] ); |
|
152 | - unset( $session_data['post_data']['card_number'] ); |
|
151 | + unset($session_data['card_info']['card_number']); |
|
152 | + unset($session_data['post_data']['card_number']); |
|
153 | 153 | |
154 | 154 | // Used for showing data to non logged-in users after donation, and for other plugins needing donation data. |
155 | - give_set_purchase_session( $session_data ); |
|
155 | + give_set_purchase_session($session_data); |
|
156 | 156 | |
157 | 157 | // Send info to the gateway for payment processing |
158 | - give_send_to_gateway( $purchase_data['gateway'], $purchase_data ); |
|
158 | + give_send_to_gateway($purchase_data['gateway'], $purchase_data); |
|
159 | 159 | give_die(); |
160 | 160 | |
161 | 161 | } |
162 | 162 | |
163 | -add_action( 'give_purchase', 'give_process_donation_form' ); |
|
164 | -add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' ); |
|
165 | -add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' ); |
|
163 | +add_action('give_purchase', 'give_process_donation_form'); |
|
164 | +add_action('wp_ajax_give_process_donation', 'give_process_donation_form'); |
|
165 | +add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form'); |
|
166 | 166 | |
167 | 167 | |
168 | 168 | /** |
@@ -175,26 +175,26 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return void |
177 | 177 | */ |
178 | -function give_checkout_check_existing_email( $valid_data, $post ) { |
|
178 | +function give_checkout_check_existing_email($valid_data, $post) { |
|
179 | 179 | |
180 | 180 | // Verify that the email address belongs to this customer. |
181 | - if ( is_user_logged_in() ) { |
|
181 | + if (is_user_logged_in()) { |
|
182 | 182 | |
183 | 183 | $email = $valid_data['logged_in_user']['user_email']; |
184 | - $customer = new Give_Customer( get_current_user_id(), true ); |
|
184 | + $customer = new Give_Customer(get_current_user_id(), true); |
|
185 | 185 | |
186 | 186 | // If this email address is not registered with this customer, see if it belongs to any other customer |
187 | - if ( $email !== $customer->email && ( is_array( $customer->emails ) && ! in_array( $email, $customer->emails ) ) ) { |
|
188 | - $found_customer = new Give_Customer( $email ); |
|
187 | + if ($email !== $customer->email && (is_array($customer->emails) && ! in_array($email, $customer->emails))) { |
|
188 | + $found_customer = new Give_Customer($email); |
|
189 | 189 | |
190 | - if ( $found_customer->id > 0 ) { |
|
191 | - give_set_error( 'give-customer-email-exists', sprintf( esc_html__( 'The email address %s is already in use.', 'give' ), $email ) ); |
|
190 | + if ($found_customer->id > 0) { |
|
191 | + give_set_error('give-customer-email-exists', sprintf(esc_html__('The email address %s is already in use.', 'give'), $email)); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
197 | -add_action( 'give_checkout_error_checks', 'give_checkout_check_existing_email', 10, 2 ); |
|
197 | +add_action('give_checkout_error_checks', 'give_checkout_check_existing_email', 10, 2); |
|
198 | 198 | |
199 | 199 | /** |
200 | 200 | * Process the checkout login form |
@@ -205,37 +205,37 @@ discard block |
||
205 | 205 | */ |
206 | 206 | function give_process_form_login() { |
207 | 207 | |
208 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
208 | + $is_ajax = isset($_POST['give_ajax']); |
|
209 | 209 | |
210 | 210 | $user_data = give_purchase_form_validate_user_login(); |
211 | 211 | |
212 | - if ( give_get_errors() || $user_data['user_id'] < 1 ) { |
|
213 | - if ( $is_ajax ) { |
|
212 | + if (give_get_errors() || $user_data['user_id'] < 1) { |
|
213 | + if ($is_ajax) { |
|
214 | 214 | /** |
215 | 215 | * Fires when AJAX sends back errors from the donation form. |
216 | 216 | * |
217 | 217 | * @since 1.0 |
218 | 218 | */ |
219 | - do_action( 'give_ajax_donation_errors' ); |
|
219 | + do_action('give_ajax_donation_errors'); |
|
220 | 220 | give_die(); |
221 | 221 | } else { |
222 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
222 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
223 | 223 | exit; |
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
227 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] ); |
|
227 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']); |
|
228 | 228 | |
229 | - if ( $is_ajax ) { |
|
229 | + if ($is_ajax) { |
|
230 | 230 | echo 'success'; |
231 | 231 | give_die(); |
232 | 232 | } else { |
233 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
233 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | |
237 | -add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' ); |
|
238 | -add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' ); |
|
237 | +add_action('wp_ajax_give_process_donation_login', 'give_process_form_login'); |
|
238 | +add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login'); |
|
239 | 239 | |
240 | 240 | /** |
241 | 241 | * Donation Form Validate Fields |
@@ -247,44 +247,44 @@ discard block |
||
247 | 247 | function give_purchase_form_validate_fields() { |
248 | 248 | |
249 | 249 | // Check if there is $_POST |
250 | - if ( empty( $_POST ) ) { |
|
250 | + if (empty($_POST)) { |
|
251 | 251 | return false; |
252 | 252 | } |
253 | 253 | |
254 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
254 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
255 | 255 | |
256 | 256 | // Start an array to collect valid data |
257 | 257 | $valid_data = array( |
258 | 258 | 'gateway' => give_purchase_form_validate_gateway(), // Gateway fallback (amount is validated here) |
259 | - 'need_new_user' => false, // New user flag |
|
260 | - 'need_user_login' => false, // Login user flag |
|
261 | - 'logged_user_data' => array(), // Logged user collected data |
|
262 | - 'new_user_data' => array(), // New user collected data |
|
263 | - 'login_user_data' => array(), // Login user collected data |
|
264 | - 'guest_user_data' => array(), // Guest user collected data |
|
265 | - 'cc_info' => give_purchase_form_validate_cc(),// Credit card info |
|
259 | + 'need_new_user' => false, // New user flag |
|
260 | + 'need_user_login' => false, // Login user flag |
|
261 | + 'logged_user_data' => array(), // Logged user collected data |
|
262 | + 'new_user_data' => array(), // New user collected data |
|
263 | + 'login_user_data' => array(), // Login user collected data |
|
264 | + 'guest_user_data' => array(), // Guest user collected data |
|
265 | + 'cc_info' => give_purchase_form_validate_cc(), // Credit card info |
|
266 | 266 | ); |
267 | 267 | |
268 | 268 | // Validate Honeypot First |
269 | - if ( ! empty( $_POST['give-honeypot'] ) ) { |
|
270 | - give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) ); |
|
269 | + if ( ! empty($_POST['give-honeypot'])) { |
|
270 | + give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give')); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | // Validate agree to terms |
274 | - if ( give_is_terms_enabled( $form_id ) ) { |
|
274 | + if (give_is_terms_enabled($form_id)) { |
|
275 | 275 | give_purchase_form_validate_agree_to_terms(); |
276 | 276 | } |
277 | 277 | |
278 | - if ( is_user_logged_in() ) { |
|
278 | + if (is_user_logged_in()) { |
|
279 | 279 | // Collect logged in user data |
280 | 280 | $valid_data['logged_in_user'] = give_purchase_form_validate_logged_in_user(); |
281 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) { |
|
281 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') { |
|
282 | 282 | // Set new user registration as required |
283 | 283 | $valid_data['need_new_user'] = true; |
284 | 284 | // Validate new user data |
285 | 285 | $valid_data['new_user_data'] = give_purchase_form_validate_new_user(); |
286 | 286 | // Check if login validation is needed |
287 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) { |
|
287 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') { |
|
288 | 288 | // Set user login as required |
289 | 289 | $valid_data['need_user_login'] = true; |
290 | 290 | // Validate users login info |
@@ -309,41 +309,41 @@ discard block |
||
309 | 309 | */ |
310 | 310 | function give_purchase_form_validate_gateway() { |
311 | 311 | |
312 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
313 | - $amount = isset( $_REQUEST['give-amount'] ) ? give_sanitize_amount( $_REQUEST['give-amount'] ) : 0; |
|
314 | - $gateway = give_get_default_gateway( $form_id ); |
|
312 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
313 | + $amount = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0; |
|
314 | + $gateway = give_get_default_gateway($form_id); |
|
315 | 315 | |
316 | 316 | // Check if a gateway value is present |
317 | - if ( ! empty( $_REQUEST['give-gateway'] ) ) { |
|
317 | + if ( ! empty($_REQUEST['give-gateway'])) { |
|
318 | 318 | |
319 | - $gateway = sanitize_text_field( $_REQUEST['give-gateway'] ); |
|
319 | + $gateway = sanitize_text_field($_REQUEST['give-gateway']); |
|
320 | 320 | |
321 | 321 | // Is amount being donated in LIVE mode 0.00? If so, error: |
322 | - if ( $amount == 0 && ! give_is_test_mode() ) { |
|
322 | + if ($amount == 0 && ! give_is_test_mode()) { |
|
323 | 323 | |
324 | - give_set_error( 'invalid_donation_amount', esc_html__( 'Please insert a valid donation amount.', 'give' ) ); |
|
324 | + give_set_error('invalid_donation_amount', esc_html__('Please insert a valid donation amount.', 'give')); |
|
325 | 325 | |
326 | 326 | } //Check for a minimum custom amount |
327 | - elseif ( ! give_verify_minimum_price() ) { |
|
327 | + elseif ( ! give_verify_minimum_price()) { |
|
328 | 328 | // translators: %s: minimum donation amount. |
329 | 329 | give_set_error( |
330 | 330 | 'invalid_donation_minimum', |
331 | 331 | sprintf( |
332 | 332 | /* translators: %s: minimum donation amount */ |
333 | - esc_html__( 'This form has a minimum donation amount of %s.', 'give' ), |
|
334 | - give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ) ) ) |
|
333 | + esc_html__('This form has a minimum donation amount of %s.', 'give'), |
|
334 | + give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id))) |
|
335 | 335 | ) |
336 | 336 | ); |
337 | 337 | |
338 | 338 | } //Is this test mode zero donation? Let it through but set to manual gateway. |
339 | - elseif ( $amount == 0 && give_is_test_mode() ) { |
|
339 | + elseif ($amount == 0 && give_is_test_mode()) { |
|
340 | 340 | |
341 | 341 | $gateway = 'manual'; |
342 | 342 | |
343 | 343 | } //Check if this gateway is active. |
344 | - elseif ( ! give_is_gateway_active( $gateway ) ) { |
|
344 | + elseif ( ! give_is_gateway_active($gateway)) { |
|
345 | 345 | |
346 | - give_set_error( 'invalid_gateway', esc_html__( 'The selected payment gateway is not enabled.', 'give' ) ); |
|
346 | + give_set_error('invalid_gateway', esc_html__('The selected payment gateway is not enabled.', 'give')); |
|
347 | 347 | |
348 | 348 | } |
349 | 349 | } |
@@ -361,23 +361,23 @@ discard block |
||
361 | 361 | */ |
362 | 362 | function give_verify_minimum_price() { |
363 | 363 | |
364 | - $amount = give_sanitize_amount( $_REQUEST['give-amount'] ); |
|
365 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
366 | - $price_id = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : 0; |
|
367 | - $variable_prices = give_has_variable_prices( $form_id ); |
|
364 | + $amount = give_sanitize_amount($_REQUEST['give-amount']); |
|
365 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
366 | + $price_id = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : 0; |
|
367 | + $variable_prices = give_has_variable_prices($form_id); |
|
368 | 368 | |
369 | - if ( $variable_prices && ! empty( $price_id ) ) { |
|
369 | + if ($variable_prices && ! empty($price_id)) { |
|
370 | 370 | |
371 | - $price_level_amount = give_get_price_option_amount( $form_id, $price_id ); |
|
371 | + $price_level_amount = give_get_price_option_amount($form_id, $price_id); |
|
372 | 372 | |
373 | - if ( $price_level_amount == $amount ) { |
|
373 | + if ($price_level_amount == $amount) { |
|
374 | 374 | return true; |
375 | 375 | } |
376 | 376 | } |
377 | 377 | |
378 | - $minimum = give_get_form_minimum_price( $form_id ); |
|
378 | + $minimum = give_get_form_minimum_price($form_id); |
|
379 | 379 | |
380 | - if ( $minimum > $amount ) { |
|
380 | + if ($minimum > $amount) { |
|
381 | 381 | return false; |
382 | 382 | } |
383 | 383 | |
@@ -393,9 +393,9 @@ discard block |
||
393 | 393 | */ |
394 | 394 | function give_purchase_form_validate_agree_to_terms() { |
395 | 395 | // Validate agree to terms. |
396 | - if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) { |
|
396 | + if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) { |
|
397 | 397 | // User did not agree. |
398 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', esc_html__( 'You must agree to the terms and conditions.', 'give' ) ) ); |
|
398 | + give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', esc_html__('You must agree to the terms and conditions.', 'give'))); |
|
399 | 399 | } |
400 | 400 | } |
401 | 401 | |
@@ -409,43 +409,43 @@ discard block |
||
409 | 409 | * |
410 | 410 | * @return array |
411 | 411 | */ |
412 | -function give_get_required_fields( $form_id ) { |
|
412 | +function give_get_required_fields($form_id) { |
|
413 | 413 | |
414 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
414 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
415 | 415 | |
416 | 416 | $required_fields = array( |
417 | 417 | 'give_email' => array( |
418 | 418 | 'error_id' => 'invalid_email', |
419 | - 'error_message' => esc_html__( 'Please enter a valid email address.', 'give' ), |
|
419 | + 'error_message' => esc_html__('Please enter a valid email address.', 'give'), |
|
420 | 420 | ), |
421 | 421 | 'give_first' => array( |
422 | 422 | 'error_id' => 'invalid_first_name', |
423 | - 'error_message' => esc_html__( 'Please enter your first name.', 'give' ), |
|
423 | + 'error_message' => esc_html__('Please enter your first name.', 'give'), |
|
424 | 424 | ), |
425 | 425 | ); |
426 | 426 | |
427 | - $require_address = give_require_billing_address( $payment_mode ); |
|
427 | + $require_address = give_require_billing_address($payment_mode); |
|
428 | 428 | |
429 | - if ( $require_address ) { |
|
430 | - $required_fields['card_address'] = array( |
|
429 | + if ($require_address) { |
|
430 | + $required_fields['card_address'] = array( |
|
431 | 431 | 'error_id' => 'invalid_card_address', |
432 | - 'error_message' => esc_html__( 'Please enter your primary billing address.', 'give' ), |
|
432 | + 'error_message' => esc_html__('Please enter your primary billing address.', 'give'), |
|
433 | 433 | ); |
434 | - $required_fields['card_zip'] = array( |
|
434 | + $required_fields['card_zip'] = array( |
|
435 | 435 | 'error_id' => 'invalid_zip_code', |
436 | - 'error_message' => esc_html__( 'Please enter your zip / postal code.', 'give' ), |
|
436 | + 'error_message' => esc_html__('Please enter your zip / postal code.', 'give'), |
|
437 | 437 | ); |
438 | - $required_fields['card_city'] = array( |
|
438 | + $required_fields['card_city'] = array( |
|
439 | 439 | 'error_id' => 'invalid_city', |
440 | - 'error_message' => esc_html__( 'Please enter your billing city.', 'give' ), |
|
440 | + 'error_message' => esc_html__('Please enter your billing city.', 'give'), |
|
441 | 441 | ); |
442 | 442 | $required_fields['billing_country'] = array( |
443 | 443 | 'error_id' => 'invalid_country', |
444 | - 'error_message' => esc_html__( 'Please select your billing country.', 'give' ), |
|
444 | + 'error_message' => esc_html__('Please select your billing country.', 'give'), |
|
445 | 445 | ); |
446 | - $required_fields['card_state'] = array( |
|
446 | + $required_fields['card_state'] = array( |
|
447 | 447 | 'error_id' => 'invalid_state', |
448 | - 'error_message' => esc_html__( 'Please enter billing state / province.', 'give' ), |
|
448 | + 'error_message' => esc_html__('Please enter billing state / province.', 'give'), |
|
449 | 449 | ); |
450 | 450 | } |
451 | 451 | |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | * |
455 | 455 | * @since 1.7 |
456 | 456 | */ |
457 | - $required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id ); |
|
457 | + $required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id); |
|
458 | 458 | |
459 | 459 | return $required_fields; |
460 | 460 | |
@@ -469,16 +469,16 @@ discard block |
||
469 | 469 | * |
470 | 470 | * @return mixed|void |
471 | 471 | */ |
472 | -function give_require_billing_address( $payment_mode ) { |
|
472 | +function give_require_billing_address($payment_mode) { |
|
473 | 473 | |
474 | 474 | $return = false; |
475 | 475 | |
476 | - if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { |
|
476 | + if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { |
|
477 | 477 | $return = true; |
478 | 478 | } |
479 | 479 | |
480 | 480 | // Let payment gateways and other extensions determine if address fields should be required. |
481 | - return apply_filters( 'give_require_billing_address', $return ); |
|
481 | + return apply_filters('give_require_billing_address', $return); |
|
482 | 482 | |
483 | 483 | } |
484 | 484 | |
@@ -492,42 +492,42 @@ discard block |
||
492 | 492 | function give_purchase_form_validate_logged_in_user() { |
493 | 493 | global $user_ID; |
494 | 494 | |
495 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
495 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
496 | 496 | |
497 | 497 | // Start empty array to collect valid user data. |
498 | 498 | $valid_user_data = array( |
499 | 499 | // Assume there will be errors. |
500 | - 'user_id' => - 1, |
|
500 | + 'user_id' => -1, |
|
501 | 501 | ); |
502 | 502 | |
503 | 503 | // Verify there is a user_ID. |
504 | - if ( $user_ID > 0 ) { |
|
504 | + if ($user_ID > 0) { |
|
505 | 505 | // Get the logged in user data. |
506 | - $user_data = get_userdata( $user_ID ); |
|
506 | + $user_data = get_userdata($user_ID); |
|
507 | 507 | |
508 | 508 | // Loop through required fields and show error messages. |
509 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
510 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
511 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
509 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
510 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
511 | + give_set_error($value['error_id'], $value['error_message']); |
|
512 | 512 | } |
513 | 513 | } |
514 | 514 | |
515 | 515 | // Verify data. |
516 | - if ( $user_data ) { |
|
516 | + if ($user_data) { |
|
517 | 517 | // Collected logged in user data. |
518 | 518 | $valid_user_data = array( |
519 | 519 | 'user_id' => $user_ID, |
520 | - 'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email, |
|
521 | - 'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name, |
|
522 | - 'user_last' => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name, |
|
520 | + 'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email, |
|
521 | + 'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name, |
|
522 | + 'user_last' => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name, |
|
523 | 523 | ); |
524 | 524 | |
525 | - if ( ! is_email( $valid_user_data['user_email'] ) ) { |
|
526 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
525 | + if ( ! is_email($valid_user_data['user_email'])) { |
|
526 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
527 | 527 | } |
528 | 528 | } else { |
529 | 529 | // Set invalid user error. |
530 | - give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) ); |
|
530 | + give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give')); |
|
531 | 531 | } |
532 | 532 | } |
533 | 533 | |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | // Default user data. |
547 | 547 | $default_user_data = array( |
548 | 548 | 'give-form-id' => '', |
549 | - 'user_id' => - 1, // Assume there will be errors. |
|
549 | + 'user_id' => -1, // Assume there will be errors. |
|
550 | 550 | 'user_first' => '', |
551 | 551 | 'user_last' => '', |
552 | 552 | 'give_user_login' => false, |
@@ -556,14 +556,14 @@ discard block |
||
556 | 556 | ); |
557 | 557 | |
558 | 558 | // Get user data. |
559 | - $user_data = wp_parse_args( array_map( 'trim', give_clean( $_POST ) ), $default_user_data ); |
|
559 | + $user_data = wp_parse_args(array_map('trim', give_clean($_POST)), $default_user_data); |
|
560 | 560 | $registering_new_user = false; |
561 | - $form_id = absint( $user_data['give-form-id'] ); |
|
561 | + $form_id = absint($user_data['give-form-id']); |
|
562 | 562 | |
563 | 563 | // Start an empty array to collect valid user data. |
564 | 564 | $valid_user_data = array( |
565 | 565 | // Assume there will be errors. |
566 | - 'user_id' => - 1, |
|
566 | + 'user_id' => -1, |
|
567 | 567 | |
568 | 568 | // Get first name. |
569 | 569 | 'user_first' => $user_data['give_first'], |
@@ -573,25 +573,25 @@ discard block |
||
573 | 573 | ); |
574 | 574 | |
575 | 575 | // Loop through required fields and show error messages. |
576 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
577 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
578 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
576 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
577 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
578 | + give_set_error($value['error_id'], $value['error_message']); |
|
579 | 579 | } |
580 | 580 | } |
581 | 581 | |
582 | 582 | // Check if we have an username to register. |
583 | - if( give_validate_username( $user_data['give_user_login'] ) ) { |
|
583 | + if (give_validate_username($user_data['give_user_login'])) { |
|
584 | 584 | $registering_new_user = true; |
585 | 585 | $valid_user_data['user_login'] = $user_data['give_user_login']; |
586 | 586 | } |
587 | 587 | |
588 | 588 | // Check if we have an email to verify. |
589 | - if( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) { |
|
589 | + if (give_validate_user_email($user_data['give_email'], $registering_new_user)) { |
|
590 | 590 | $valid_user_data['user_email'] = $user_data['give_email']; |
591 | 591 | } |
592 | 592 | |
593 | 593 | // Check password. |
594 | - if( give_validate_user_password( $user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)){ |
|
594 | + if (give_validate_user_password($user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)) { |
|
595 | 595 | // All is good to go. |
596 | 596 | $valid_user_data['user_pass'] = $user_data['give_user_pass']; |
597 | 597 | } |
@@ -611,36 +611,36 @@ discard block |
||
611 | 611 | // Start an array to collect valid user data. |
612 | 612 | $valid_user_data = array( |
613 | 613 | // Assume there will be errors |
614 | - 'user_id' => - 1, |
|
614 | + 'user_id' => -1, |
|
615 | 615 | ); |
616 | 616 | |
617 | 617 | // Username. |
618 | - if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) { |
|
619 | - give_set_error( 'must_log_in', esc_html__( 'You must register or login to complete your donation.', 'give' ) ); |
|
618 | + if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') { |
|
619 | + give_set_error('must_log_in', esc_html__('You must register or login to complete your donation.', 'give')); |
|
620 | 620 | |
621 | 621 | return $valid_user_data; |
622 | 622 | } |
623 | 623 | |
624 | 624 | // Get the user by login. |
625 | - $user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) ); |
|
625 | + $user_data = get_user_by('login', strip_tags($_POST['give_user_login'])); |
|
626 | 626 | |
627 | 627 | // Check if user exists. |
628 | - if ( $user_data ) { |
|
628 | + if ($user_data) { |
|
629 | 629 | // Get password. |
630 | - $user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false; |
|
630 | + $user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false; |
|
631 | 631 | |
632 | 632 | // Check user_pass. |
633 | - if ( $user_pass ) { |
|
633 | + if ($user_pass) { |
|
634 | 634 | // Check if password is valid. |
635 | - if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { |
|
635 | + if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { |
|
636 | 636 | // Incorrect password. |
637 | 637 | give_set_error( |
638 | 638 | 'password_incorrect', |
639 | 639 | sprintf( |
640 | 640 | '%1$s <a href="%2$s">%3$s</a>', |
641 | - esc_html__( 'The password you entered is incorrect.', 'give' ), |
|
642 | - wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ), |
|
643 | - esc_html__( 'Reset Password', 'give' ) |
|
641 | + esc_html__('The password you entered is incorrect.', 'give'), |
|
642 | + wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"), |
|
643 | + esc_html__('Reset Password', 'give') |
|
644 | 644 | ) |
645 | 645 | ); |
646 | 646 | // All is correct. |
@@ -657,11 +657,11 @@ discard block |
||
657 | 657 | } |
658 | 658 | } else { |
659 | 659 | // Empty password. |
660 | - give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) ); |
|
660 | + give_set_error('password_empty', esc_html__('Enter a password.', 'give')); |
|
661 | 661 | } |
662 | 662 | } else { |
663 | 663 | // No username. |
664 | - give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) ); |
|
664 | + give_set_error('username_incorrect', esc_html__('The username you entered does not exist.', 'give')); |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | return $valid_user_data; |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | */ |
677 | 677 | function give_purchase_form_validate_guest_user() { |
678 | 678 | |
679 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
679 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
680 | 680 | |
681 | 681 | // Start an array to collect valid user data. |
682 | 682 | $valid_user_data = array( |
@@ -685,38 +685,38 @@ discard block |
||
685 | 685 | ); |
686 | 686 | |
687 | 687 | // Show error message if user must be logged in. |
688 | - if ( give_logged_in_only( $form_id ) ) { |
|
689 | - give_set_error( 'logged_in_only', esc_html__( 'You must be logged in to donate.', 'give' ) ); |
|
688 | + if (give_logged_in_only($form_id)) { |
|
689 | + give_set_error('logged_in_only', esc_html__('You must be logged in to donate.', 'give')); |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | // Get the guest email. |
693 | - $guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
693 | + $guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
694 | 694 | |
695 | 695 | // Check email. |
696 | - if ( $guest_email && strlen( $guest_email ) > 0 ) { |
|
696 | + if ($guest_email && strlen($guest_email) > 0) { |
|
697 | 697 | // Validate email. |
698 | - if ( ! is_email( $guest_email ) ) { |
|
698 | + if ( ! is_email($guest_email)) { |
|
699 | 699 | // Invalid email. |
700 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
700 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
701 | 701 | } else { |
702 | 702 | // All is good to go. |
703 | 703 | $valid_user_data['user_email'] = $guest_email; |
704 | 704 | |
705 | 705 | // Get user_id from donor if exist. |
706 | - $donor = new Give_Customer( $guest_email ); |
|
707 | - if ( $donor->id && $donor->user_id ) { |
|
706 | + $donor = new Give_Customer($guest_email); |
|
707 | + if ($donor->id && $donor->user_id) { |
|
708 | 708 | $valid_user_data['user_id'] = $donor->user_id; |
709 | 709 | } |
710 | 710 | } |
711 | 711 | } else { |
712 | 712 | // No email. |
713 | - give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) ); |
|
713 | + give_set_error('email_empty', esc_html__('Enter an email.', 'give')); |
|
714 | 714 | } |
715 | 715 | |
716 | 716 | // Loop through required fields and show error messages. |
717 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
718 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
719 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
717 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
718 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
719 | + give_set_error($value['error_id'], $value['error_message']); |
|
720 | 720 | } |
721 | 721 | } |
722 | 722 | |
@@ -732,36 +732,36 @@ discard block |
||
732 | 732 | * @since 1.0 |
733 | 733 | * @return integer |
734 | 734 | */ |
735 | -function give_register_and_login_new_user( $user_data = array() ) { |
|
735 | +function give_register_and_login_new_user($user_data = array()) { |
|
736 | 736 | // Verify the array. |
737 | - if ( empty( $user_data ) ) { |
|
738 | - return - 1; |
|
737 | + if (empty($user_data)) { |
|
738 | + return -1; |
|
739 | 739 | } |
740 | 740 | |
741 | - if ( give_get_errors() ) { |
|
742 | - return - 1; |
|
741 | + if (give_get_errors()) { |
|
742 | + return -1; |
|
743 | 743 | } |
744 | 744 | |
745 | - $user_args = apply_filters( 'give_insert_user_args', array( |
|
746 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '', |
|
747 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '', |
|
748 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '', |
|
749 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '', |
|
750 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '', |
|
751 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
752 | - 'role' => get_option( 'default_role' ), |
|
753 | - ), $user_data ); |
|
745 | + $user_args = apply_filters('give_insert_user_args', array( |
|
746 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', |
|
747 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', |
|
748 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', |
|
749 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', |
|
750 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', |
|
751 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
752 | + 'role' => get_option('default_role'), |
|
753 | + ), $user_data); |
|
754 | 754 | |
755 | 755 | // Insert new user. |
756 | - $user_id = wp_insert_user( $user_args ); |
|
756 | + $user_id = wp_insert_user($user_args); |
|
757 | 757 | |
758 | 758 | // Validate inserted user. |
759 | - if ( is_wp_error( $user_id ) ) { |
|
760 | - return - 1; |
|
759 | + if (is_wp_error($user_id)) { |
|
760 | + return -1; |
|
761 | 761 | } |
762 | 762 | |
763 | 763 | // Allow themes and plugins to filter the user data. |
764 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args ); |
|
764 | + $user_data = apply_filters('give_insert_user_data', $user_data, $user_args); |
|
765 | 765 | |
766 | 766 | /** |
767 | 767 | * Fires after inserting user. |
@@ -771,10 +771,10 @@ discard block |
||
771 | 771 | * @param int $user_id User id. |
772 | 772 | * @param array $user_data Array containing user data. |
773 | 773 | */ |
774 | - do_action( 'give_insert_user', $user_id, $user_data ); |
|
774 | + do_action('give_insert_user', $user_id, $user_data); |
|
775 | 775 | |
776 | 776 | // Login new user. |
777 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] ); |
|
777 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']); |
|
778 | 778 | |
779 | 779 | // Return user id. |
780 | 780 | return $user_id; |
@@ -789,27 +789,27 @@ discard block |
||
789 | 789 | * @since 1.0 |
790 | 790 | * @return array |
791 | 791 | */ |
792 | -function give_get_purchase_form_user( $valid_data = array() ) { |
|
792 | +function give_get_purchase_form_user($valid_data = array()) { |
|
793 | 793 | |
794 | 794 | // Initialize user. |
795 | 795 | $user = false; |
796 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
796 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
797 | 797 | |
798 | - if ( $is_ajax ) { |
|
798 | + if ($is_ajax) { |
|
799 | 799 | // Do not create or login the user during the ajax submission (check for errors only). |
800 | 800 | return true; |
801 | - } elseif ( is_user_logged_in() ) { |
|
801 | + } elseif (is_user_logged_in()) { |
|
802 | 802 | // Set the valid user as the logged in collected data. |
803 | 803 | $user = $valid_data['logged_in_user']; |
804 | - } elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) { |
|
804 | + } elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) { |
|
805 | 805 | // New user registration. |
806 | - if ( $valid_data['need_new_user'] === true ) { |
|
806 | + if ($valid_data['need_new_user'] === true) { |
|
807 | 807 | // Set user. |
808 | 808 | $user = $valid_data['new_user_data']; |
809 | 809 | // Register and login new user. |
810 | - $user['user_id'] = give_register_and_login_new_user( $user ); |
|
810 | + $user['user_id'] = give_register_and_login_new_user($user); |
|
811 | 811 | // User login |
812 | - } elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) { |
|
812 | + } elseif ($valid_data['need_user_login'] === true && ! $is_ajax) { |
|
813 | 813 | |
814 | 814 | /* |
815 | 815 | * The login form is now processed in the give_process_purchase_login() function. |
@@ -822,48 +822,48 @@ discard block |
||
822 | 822 | // Set user. |
823 | 823 | $user = $valid_data['login_user_data']; |
824 | 824 | // Login user. |
825 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] ); |
|
825 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); |
|
826 | 826 | } |
827 | 827 | } |
828 | 828 | |
829 | 829 | // Check guest checkout. |
830 | - if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) { |
|
830 | + if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) { |
|
831 | 831 | // Set user |
832 | 832 | $user = $valid_data['guest_user_data']; |
833 | 833 | } |
834 | 834 | |
835 | 835 | // Verify we have an user. |
836 | - if ( false === $user || empty( $user ) ) { |
|
836 | + if (false === $user || empty($user)) { |
|
837 | 837 | // Return false. |
838 | 838 | return false; |
839 | 839 | } |
840 | 840 | |
841 | 841 | // Get user first name. |
842 | - if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { |
|
843 | - $user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : ''; |
|
842 | + if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { |
|
843 | + $user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : ''; |
|
844 | 844 | } |
845 | 845 | |
846 | 846 | // Get user last name. |
847 | - if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { |
|
848 | - $user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : ''; |
|
847 | + if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { |
|
848 | + $user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : ''; |
|
849 | 849 | } |
850 | 850 | |
851 | 851 | // Get the user's billing address details. |
852 | 852 | $user['address'] = array(); |
853 | - $user['address']['line1'] = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false; |
|
854 | - $user['address']['line2'] = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false; |
|
855 | - $user['address']['city'] = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false; |
|
856 | - $user['address']['state'] = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false; |
|
857 | - $user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false; |
|
858 | - $user['address']['zip'] = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false; |
|
859 | - |
|
860 | - if ( empty( $user['address']['country'] ) ) { |
|
853 | + $user['address']['line1'] = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false; |
|
854 | + $user['address']['line2'] = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false; |
|
855 | + $user['address']['city'] = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false; |
|
856 | + $user['address']['state'] = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false; |
|
857 | + $user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false; |
|
858 | + $user['address']['zip'] = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false; |
|
859 | + |
|
860 | + if (empty($user['address']['country'])) { |
|
861 | 861 | $user['address'] = false; |
862 | 862 | } // Country will always be set if address fields are present. |
863 | 863 | |
864 | - if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) { |
|
864 | + if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) { |
|
865 | 865 | // Store the address in the user's meta so the donation form can be pre-populated with it on return purchases. |
866 | - update_user_meta( $user['user_id'], '_give_user_address', $user['address'] ); |
|
866 | + update_user_meta($user['user_id'], '_give_user_address', $user['address']); |
|
867 | 867 | } |
868 | 868 | |
869 | 869 | // Return valid user. |
@@ -882,16 +882,16 @@ discard block |
||
882 | 882 | $card_data = give_get_purchase_cc_info(); |
883 | 883 | |
884 | 884 | // Validate the card zip. |
885 | - if ( ! empty( $card_data['card_zip'] ) ) { |
|
886 | - if ( ! give_purchase_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { |
|
887 | - give_set_error( 'invalid_cc_zip', esc_html__( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) ); |
|
885 | + if ( ! empty($card_data['card_zip'])) { |
|
886 | + if ( ! give_purchase_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { |
|
887 | + give_set_error('invalid_cc_zip', esc_html__('The zip / postal code you entered for your billing address is invalid.', 'give')); |
|
888 | 888 | } |
889 | 889 | } |
890 | 890 | |
891 | 891 | // Ensure no spaces. |
892 | - if ( ! empty( $card_data['card_number'] ) ) { |
|
893 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs |
|
894 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces |
|
892 | + if ( ! empty($card_data['card_number'])) { |
|
893 | + $card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs |
|
894 | + $card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces |
|
895 | 895 | } |
896 | 896 | |
897 | 897 | // This should validate card numbers at some point too. |
@@ -907,17 +907,17 @@ discard block |
||
907 | 907 | */ |
908 | 908 | function give_get_purchase_cc_info() { |
909 | 909 | $cc_info = array(); |
910 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
911 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
912 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
913 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
914 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
915 | - $cc_info['card_address'] = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : ''; |
|
916 | - $cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : ''; |
|
917 | - $cc_info['card_city'] = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : ''; |
|
918 | - $cc_info['card_state'] = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : ''; |
|
919 | - $cc_info['card_country'] = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : ''; |
|
920 | - $cc_info['card_zip'] = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : ''; |
|
910 | + $cc_info['card_name'] = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : ''; |
|
911 | + $cc_info['card_number'] = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : ''; |
|
912 | + $cc_info['card_cvc'] = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : ''; |
|
913 | + $cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : ''; |
|
914 | + $cc_info['card_exp_year'] = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : ''; |
|
915 | + $cc_info['card_address'] = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : ''; |
|
916 | + $cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : ''; |
|
917 | + $cc_info['card_city'] = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : ''; |
|
918 | + $cc_info['card_state'] = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : ''; |
|
919 | + $cc_info['card_country'] = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : ''; |
|
920 | + $cc_info['card_zip'] = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : ''; |
|
921 | 921 | |
922 | 922 | // Return cc info |
923 | 923 | return $cc_info; |
@@ -933,14 +933,14 @@ discard block |
||
933 | 933 | * |
934 | 934 | * @return bool|mixed|void |
935 | 935 | */ |
936 | -function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
936 | +function give_purchase_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
937 | 937 | $ret = false; |
938 | 938 | |
939 | - if ( empty( $zip ) || empty( $country_code ) ) { |
|
939 | + if (empty($zip) || empty($country_code)) { |
|
940 | 940 | return $ret; |
941 | 941 | } |
942 | 942 | |
943 | - $country_code = strtoupper( $country_code ); |
|
943 | + $country_code = strtoupper($country_code); |
|
944 | 944 | |
945 | 945 | $zip_regex = array( |
946 | 946 | 'AD' => 'AD\d{3}', |
@@ -1100,11 +1100,11 @@ discard block |
||
1100 | 1100 | 'ZM' => '\d{5}', |
1101 | 1101 | ); |
1102 | 1102 | |
1103 | - if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) { |
|
1103 | + if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) { |
|
1104 | 1104 | $ret = true; |
1105 | 1105 | } |
1106 | 1106 | |
1107 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code ); |
|
1107 | + return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); |
|
1108 | 1108 | } |
1109 | 1109 | |
1110 | 1110 | |
@@ -1118,36 +1118,36 @@ discard block |
||
1118 | 1118 | * |
1119 | 1119 | * @return bool |
1120 | 1120 | */ |
1121 | -function give_validate_multi_donation_form_level( $valid_data, $data ) { |
|
1121 | +function give_validate_multi_donation_form_level($valid_data, $data) { |
|
1122 | 1122 | /* @var Give_Donate_Form $form */ |
1123 | - $form = new Give_Donate_Form( $data['give-form-id'] ); |
|
1123 | + $form = new Give_Donate_Form($data['give-form-id']); |
|
1124 | 1124 | |
1125 | 1125 | $donation_level_matched = false; |
1126 | 1126 | |
1127 | - if ( $form->is_multi_type_donation_form() ) { |
|
1127 | + if ($form->is_multi_type_donation_form()) { |
|
1128 | 1128 | |
1129 | 1129 | // Bailout. |
1130 | - if ( ! ( $variable_prices = $form->get_prices() ) ) { |
|
1130 | + if ( ! ($variable_prices = $form->get_prices())) { |
|
1131 | 1131 | return false; |
1132 | 1132 | } |
1133 | 1133 | |
1134 | 1134 | // Sanitize donation amount. |
1135 | - $data['give-amount'] = give_sanitize_amount( $data['give-amount'] ); |
|
1135 | + $data['give-amount'] = give_sanitize_amount($data['give-amount']); |
|
1136 | 1136 | |
1137 | 1137 | // Get number of decimals. |
1138 | 1138 | $default_decimals = give_get_price_decimals(); |
1139 | 1139 | |
1140 | - if ( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ) { |
|
1140 | + if ($data['give-amount'] === give_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']), $default_decimals)) { |
|
1141 | 1141 | return true; |
1142 | 1142 | } |
1143 | 1143 | |
1144 | 1144 | // Find correct donation level from all donation levels. |
1145 | - foreach ( $variable_prices as $variable_price ) { |
|
1145 | + foreach ($variable_prices as $variable_price) { |
|
1146 | 1146 | // Sanitize level amount. |
1147 | - $variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals ); |
|
1147 | + $variable_price['_give_amount'] = give_sanitize_amount($variable_price['_give_amount'], $default_decimals); |
|
1148 | 1148 | |
1149 | 1149 | // Set first match donation level ID. |
1150 | - if ( $data['give-amount'] === $variable_price['_give_amount'] ) { |
|
1150 | + if ($data['give-amount'] === $variable_price['_give_amount']) { |
|
1151 | 1151 | $_POST['give-price-id'] = $variable_price['_give_id']['level_id']; |
1152 | 1152 | $donation_level_matched = true; |
1153 | 1153 | break; |
@@ -1158,19 +1158,19 @@ discard block |
||
1158 | 1158 | // If yes then set price id to custom if amount is greater then custom minimum amount (if any). |
1159 | 1159 | if ( |
1160 | 1160 | ! $donation_level_matched |
1161 | - && ( give_is_setting_enabled( get_post_meta( $data['give-form-id'], '_give_custom_amount', true ) ) ) |
|
1161 | + && (give_is_setting_enabled(get_post_meta($data['give-form-id'], '_give_custom_amount', true))) |
|
1162 | 1162 | ) { |
1163 | 1163 | // Sanitize custom minimum amount. |
1164 | - $custom_minimum_amount = give_sanitize_amount( get_post_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals ); |
|
1164 | + $custom_minimum_amount = give_sanitize_amount(get_post_meta($data['give-form-id'], '_give_custom_amount_minimum', true), $default_decimals); |
|
1165 | 1165 | |
1166 | - if ( $data['give-amount'] >= $custom_minimum_amount ) { |
|
1166 | + if ($data['give-amount'] >= $custom_minimum_amount) { |
|
1167 | 1167 | $_POST['give-price-id'] = 'custom'; |
1168 | 1168 | $donation_level_matched = true; |
1169 | 1169 | } |
1170 | 1170 | } |
1171 | 1171 | } |
1172 | 1172 | |
1173 | - return ( $donation_level_matched ? true : false ); |
|
1173 | + return ($donation_level_matched ? true : false); |
|
1174 | 1174 | } |
1175 | 1175 | |
1176 | -add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 ); |
|
1176 | +add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2); |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | */ |
41 | 41 | |
42 | 42 | // Exit if accessed directly. |
43 | -if ( ! defined( 'ABSPATH' ) ) { |
|
43 | +if ( ! defined('ABSPATH')) { |
|
44 | 44 | exit; |
45 | 45 | } |
46 | 46 | |
47 | -if ( ! class_exists( 'Give' ) ) : |
|
47 | +if ( ! class_exists('Give')) : |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * Main Give Class |
@@ -195,11 +195,11 @@ discard block |
||
195 | 195 | * @return Give |
196 | 196 | */ |
197 | 197 | public static function instance() { |
198 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Give ) ) { |
|
198 | + if ( ! isset(self::$instance) && ! (self::$instance instanceof Give)) { |
|
199 | 199 | self::$instance = new Give; |
200 | 200 | self::$instance->setup_constants(); |
201 | 201 | |
202 | - add_action( 'plugins_loaded', array( self::$instance, 'load_textdomain' ) ); |
|
202 | + add_action('plugins_loaded', array(self::$instance, 'load_textdomain')); |
|
203 | 203 | |
204 | 204 | self::$instance->includes(); |
205 | 205 | self::$instance->roles = new Give_Roles(); |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | */ |
233 | 233 | public function __clone() { |
234 | 234 | // Cloning instances of the class is forbidden |
235 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'give' ), '1.0' ); |
|
235 | + _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'give'), '1.0'); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | */ |
246 | 246 | public function __wakeup() { |
247 | 247 | // Unserializing instances of the class is forbidden. |
248 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'give' ), '1.0' ); |
|
248 | + _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'give'), '1.0'); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -259,33 +259,33 @@ discard block |
||
259 | 259 | private function setup_constants() { |
260 | 260 | |
261 | 261 | // Plugin version |
262 | - if ( ! defined( 'GIVE_VERSION' ) ) { |
|
263 | - define( 'GIVE_VERSION', '1.8.2' ); |
|
262 | + if ( ! defined('GIVE_VERSION')) { |
|
263 | + define('GIVE_VERSION', '1.8.2'); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | // Plugin Folder Path |
267 | - if ( ! defined( 'GIVE_PLUGIN_DIR' ) ) { |
|
268 | - define( 'GIVE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
|
267 | + if ( ! defined('GIVE_PLUGIN_DIR')) { |
|
268 | + define('GIVE_PLUGIN_DIR', plugin_dir_path(__FILE__)); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | // Plugin Folder URL |
272 | - if ( ! defined( 'GIVE_PLUGIN_URL' ) ) { |
|
273 | - define( 'GIVE_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
|
272 | + if ( ! defined('GIVE_PLUGIN_URL')) { |
|
273 | + define('GIVE_PLUGIN_URL', plugin_dir_url(__FILE__)); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | // Plugin Basename aka: "give/give.php" |
277 | - if ( ! defined( 'GIVE_PLUGIN_BASENAME' ) ) { |
|
278 | - define( 'GIVE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); |
|
277 | + if ( ! defined('GIVE_PLUGIN_BASENAME')) { |
|
278 | + define('GIVE_PLUGIN_BASENAME', plugin_basename(__FILE__)); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | // Plugin Root File |
282 | - if ( ! defined( 'GIVE_PLUGIN_FILE' ) ) { |
|
283 | - define( 'GIVE_PLUGIN_FILE', __FILE__ ); |
|
282 | + if ( ! defined('GIVE_PLUGIN_FILE')) { |
|
283 | + define('GIVE_PLUGIN_FILE', __FILE__); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | // Make sure CAL_GREGORIAN is defined |
287 | - if ( ! defined( 'CAL_GREGORIAN' ) ) { |
|
288 | - define( 'CAL_GREGORIAN', 1 ); |
|
287 | + if ( ! defined('CAL_GREGORIAN')) { |
|
288 | + define('CAL_GREGORIAN', 1); |
|
289 | 289 | } |
290 | 290 | } |
291 | 291 | |
@@ -300,122 +300,122 @@ discard block |
||
300 | 300 | private function includes() { |
301 | 301 | global $give_options; |
302 | 302 | |
303 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-settings.php'; |
|
304 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-give-settings.php'; |
|
303 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-admin-settings.php'; |
|
304 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-give-settings.php'; |
|
305 | 305 | $give_options = give_get_settings(); |
306 | 306 | |
307 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/give-metabox-functions.php'; |
|
308 | - require_once GIVE_PLUGIN_DIR . 'includes/post-types.php'; |
|
309 | - require_once GIVE_PLUGIN_DIR . 'includes/scripts.php'; |
|
310 | - require_once GIVE_PLUGIN_DIR . 'includes/ajax-functions.php'; |
|
311 | - require_once GIVE_PLUGIN_DIR . 'includes/actions.php'; |
|
312 | - require_once GIVE_PLUGIN_DIR . 'includes/filters.php'; |
|
313 | - require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api.php'; |
|
314 | - |
|
315 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-roles.php'; |
|
316 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-template-loader.php'; |
|
317 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-donate-form.php'; |
|
318 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db.php'; |
|
319 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-customers.php'; |
|
320 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-customer-meta.php'; |
|
321 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-customer.php'; |
|
322 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-stats.php'; |
|
323 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-session.php'; |
|
324 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-html-elements.php'; |
|
325 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-logging.php'; |
|
326 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-license-handler.php'; |
|
327 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cron.php'; |
|
328 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-email-access.php'; |
|
329 | - |
|
330 | - require_once GIVE_PLUGIN_DIR . 'includes/country-functions.php'; |
|
331 | - require_once GIVE_PLUGIN_DIR . 'includes/template-functions.php'; |
|
332 | - require_once GIVE_PLUGIN_DIR . 'includes/misc-functions.php'; |
|
333 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/functions.php'; |
|
334 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/template.php'; |
|
335 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/widget.php'; |
|
336 | - require_once GIVE_PLUGIN_DIR . 'includes/shortcodes.php'; |
|
337 | - require_once GIVE_PLUGIN_DIR . 'includes/formatting.php'; |
|
338 | - require_once GIVE_PLUGIN_DIR . 'includes/price-functions.php'; |
|
339 | - require_once GIVE_PLUGIN_DIR . 'includes/error-tracking.php'; |
|
340 | - require_once GIVE_PLUGIN_DIR . 'includes/process-donation.php'; |
|
341 | - require_once GIVE_PLUGIN_DIR . 'includes/login-register.php'; |
|
342 | - require_once GIVE_PLUGIN_DIR . 'includes/user-functions.php'; |
|
343 | - require_once GIVE_PLUGIN_DIR . 'includes/plugin-compatibility.php'; |
|
344 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-functions.php'; |
|
345 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-actions.php'; |
|
346 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-filters.php'; |
|
347 | - |
|
348 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/functions.php'; |
|
349 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/actions.php'; |
|
350 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payment-stats.php'; |
|
351 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payments-query.php'; |
|
352 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-payment.php'; |
|
353 | - |
|
354 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/functions.php'; |
|
355 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/actions.php'; |
|
356 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/paypal-standard.php'; |
|
357 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/offline-donations.php'; |
|
358 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/manual.php'; |
|
359 | - |
|
360 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-emails.php'; |
|
361 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-email-tags.php'; |
|
362 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/functions.php'; |
|
363 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php'; |
|
364 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php'; |
|
365 | - |
|
366 | - if( defined( 'WP_CLI' ) && WP_CLI ) { |
|
367 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php'; |
|
307 | + require_once GIVE_PLUGIN_DIR.'includes/admin/give-metabox-functions.php'; |
|
308 | + require_once GIVE_PLUGIN_DIR.'includes/post-types.php'; |
|
309 | + require_once GIVE_PLUGIN_DIR.'includes/scripts.php'; |
|
310 | + require_once GIVE_PLUGIN_DIR.'includes/ajax-functions.php'; |
|
311 | + require_once GIVE_PLUGIN_DIR.'includes/actions.php'; |
|
312 | + require_once GIVE_PLUGIN_DIR.'includes/filters.php'; |
|
313 | + require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api.php'; |
|
314 | + |
|
315 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-roles.php'; |
|
316 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-template-loader.php'; |
|
317 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-donate-form.php'; |
|
318 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db.php'; |
|
319 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-customers.php'; |
|
320 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-customer-meta.php'; |
|
321 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-customer.php'; |
|
322 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-stats.php'; |
|
323 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-session.php'; |
|
324 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-html-elements.php'; |
|
325 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-logging.php'; |
|
326 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-license-handler.php'; |
|
327 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cron.php'; |
|
328 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-email-access.php'; |
|
329 | + |
|
330 | + require_once GIVE_PLUGIN_DIR.'includes/country-functions.php'; |
|
331 | + require_once GIVE_PLUGIN_DIR.'includes/template-functions.php'; |
|
332 | + require_once GIVE_PLUGIN_DIR.'includes/misc-functions.php'; |
|
333 | + require_once GIVE_PLUGIN_DIR.'includes/forms/functions.php'; |
|
334 | + require_once GIVE_PLUGIN_DIR.'includes/forms/template.php'; |
|
335 | + require_once GIVE_PLUGIN_DIR.'includes/forms/widget.php'; |
|
336 | + require_once GIVE_PLUGIN_DIR.'includes/shortcodes.php'; |
|
337 | + require_once GIVE_PLUGIN_DIR.'includes/formatting.php'; |
|
338 | + require_once GIVE_PLUGIN_DIR.'includes/price-functions.php'; |
|
339 | + require_once GIVE_PLUGIN_DIR.'includes/error-tracking.php'; |
|
340 | + require_once GIVE_PLUGIN_DIR.'includes/process-donation.php'; |
|
341 | + require_once GIVE_PLUGIN_DIR.'includes/login-register.php'; |
|
342 | + require_once GIVE_PLUGIN_DIR.'includes/user-functions.php'; |
|
343 | + require_once GIVE_PLUGIN_DIR.'includes/plugin-compatibility.php'; |
|
344 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-functions.php'; |
|
345 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-actions.php'; |
|
346 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-filters.php'; |
|
347 | + |
|
348 | + require_once GIVE_PLUGIN_DIR.'includes/payments/functions.php'; |
|
349 | + require_once GIVE_PLUGIN_DIR.'includes/payments/actions.php'; |
|
350 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-payment-stats.php'; |
|
351 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-payments-query.php'; |
|
352 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-give-payment.php'; |
|
353 | + |
|
354 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/functions.php'; |
|
355 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/actions.php'; |
|
356 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/paypal-standard.php'; |
|
357 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/offline-donations.php'; |
|
358 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/manual.php'; |
|
359 | + |
|
360 | + require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-emails.php'; |
|
361 | + require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-email-tags.php'; |
|
362 | + require_once GIVE_PLUGIN_DIR.'includes/emails/functions.php'; |
|
363 | + require_once GIVE_PLUGIN_DIR.'includes/emails/template.php'; |
|
364 | + require_once GIVE_PLUGIN_DIR.'includes/emails/actions.php'; |
|
365 | + |
|
366 | + if (defined('WP_CLI') && WP_CLI) { |
|
367 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cli-commands.php'; |
|
368 | 368 | } |
369 | 369 | |
370 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
371 | - |
|
372 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-footer.php'; |
|
373 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/welcome.php'; |
|
374 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-pages.php'; |
|
375 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-notices.php'; |
|
376 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php'; |
|
377 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-i18n-module.php'; |
|
378 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-actions.php'; |
|
379 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-filters.php'; |
|
380 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/system-info.php'; |
|
381 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/add-ons.php'; |
|
382 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/plugins.php'; |
|
383 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/dashboard-widgets.php'; |
|
384 | - |
|
385 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/actions.php'; |
|
386 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/payments-history.php'; |
|
387 | - |
|
388 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customers.php'; |
|
389 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customer-functions.php'; |
|
390 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customer-actions.php'; |
|
391 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/metabox.php'; |
|
392 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/class-metabox-form-data.php'; |
|
393 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/dashboard-columns.php'; |
|
394 | - |
|
395 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/export-functions.php'; |
|
396 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/reports.php'; |
|
397 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools.php'; |
|
398 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/tools-actions.php'; |
|
399 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/pdf-reports.php'; |
|
400 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-give-graph.php'; |
|
401 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/graphing.php'; |
|
402 | - |
|
403 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/abstract-shortcode-generator.php'; |
|
404 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/class-shortcode-button.php'; |
|
405 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-form.php'; |
|
406 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-goal.php'; |
|
407 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-login.php'; |
|
408 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-register.php'; |
|
409 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-profile-editor.php'; |
|
410 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donation-history.php'; |
|
411 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-receipt.php'; |
|
412 | - |
|
413 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
414 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrades.php'; |
|
370 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
371 | + |
|
372 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-footer.php'; |
|
373 | + require_once GIVE_PLUGIN_DIR.'includes/admin/welcome.php'; |
|
374 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-pages.php'; |
|
375 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-admin-notices.php'; |
|
376 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php'; |
|
377 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-i18n-module.php'; |
|
378 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-actions.php'; |
|
379 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-filters.php'; |
|
380 | + require_once GIVE_PLUGIN_DIR.'includes/admin/system-info.php'; |
|
381 | + require_once GIVE_PLUGIN_DIR.'includes/admin/add-ons.php'; |
|
382 | + require_once GIVE_PLUGIN_DIR.'includes/admin/plugins.php'; |
|
383 | + require_once GIVE_PLUGIN_DIR.'includes/admin/dashboard-widgets.php'; |
|
384 | + |
|
385 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/actions.php'; |
|
386 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/payments-history.php'; |
|
387 | + |
|
388 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customers.php'; |
|
389 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customer-functions.php'; |
|
390 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customer-actions.php'; |
|
391 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/metabox.php'; |
|
392 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/class-metabox-form-data.php'; |
|
393 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/dashboard-columns.php'; |
|
394 | + |
|
395 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/export-functions.php'; |
|
396 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/reports.php'; |
|
397 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/tools.php'; |
|
398 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/tools-actions.php'; |
|
399 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/pdf-reports.php'; |
|
400 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-give-graph.php'; |
|
401 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/graphing.php'; |
|
402 | + |
|
403 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/abstract-shortcode-generator.php'; |
|
404 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/class-shortcode-button.php'; |
|
405 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-form.php'; |
|
406 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-goal.php'; |
|
407 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-login.php'; |
|
408 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-register.php'; |
|
409 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-profile-editor.php'; |
|
410 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-donation-history.php'; |
|
411 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-receipt.php'; |
|
412 | + |
|
413 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
414 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrades.php'; |
|
415 | 415 | |
416 | 416 | } |
417 | 417 | |
418 | - require_once GIVE_PLUGIN_DIR . 'includes/install.php'; |
|
418 | + require_once GIVE_PLUGIN_DIR.'includes/install.php'; |
|
419 | 419 | |
420 | 420 | } |
421 | 421 | |
@@ -429,26 +429,26 @@ discard block |
||
429 | 429 | */ |
430 | 430 | public function load_textdomain() { |
431 | 431 | // Set filter for Give's languages directory |
432 | - $give_lang_dir = dirname( plugin_basename( GIVE_PLUGIN_FILE ) ) . '/languages/'; |
|
433 | - $give_lang_dir = apply_filters( 'give_languages_directory', $give_lang_dir ); |
|
432 | + $give_lang_dir = dirname(plugin_basename(GIVE_PLUGIN_FILE)).'/languages/'; |
|
433 | + $give_lang_dir = apply_filters('give_languages_directory', $give_lang_dir); |
|
434 | 434 | |
435 | 435 | // Traditional WordPress plugin locale filter |
436 | - $locale = apply_filters( 'plugin_locale', get_locale(), 'give' ); |
|
437 | - $mofile = sprintf( '%1$s-%2$s.mo', 'give', $locale ); |
|
436 | + $locale = apply_filters('plugin_locale', get_locale(), 'give'); |
|
437 | + $mofile = sprintf('%1$s-%2$s.mo', 'give', $locale); |
|
438 | 438 | |
439 | 439 | // Setup paths to current locale file |
440 | - $mofile_local = $give_lang_dir . $mofile; |
|
441 | - $mofile_global = WP_LANG_DIR . '/give/' . $mofile; |
|
440 | + $mofile_local = $give_lang_dir.$mofile; |
|
441 | + $mofile_global = WP_LANG_DIR.'/give/'.$mofile; |
|
442 | 442 | |
443 | - if ( file_exists( $mofile_global ) ) { |
|
443 | + if (file_exists($mofile_global)) { |
|
444 | 444 | // Look in global /wp-content/languages/give folder |
445 | - load_textdomain( 'give', $mofile_global ); |
|
446 | - } elseif ( file_exists( $mofile_local ) ) { |
|
445 | + load_textdomain('give', $mofile_global); |
|
446 | + } elseif (file_exists($mofile_local)) { |
|
447 | 447 | // Look in local location from filter `give_languages_directory` |
448 | - load_textdomain( 'give', $mofile_local ); |
|
448 | + load_textdomain('give', $mofile_local); |
|
449 | 449 | } else { |
450 | 450 | // Load the default language files packaged up w/ Give |
451 | - load_plugin_textdomain( 'give', false, $give_lang_dir ); |
|
451 | + load_plugin_textdomain('give', false, $give_lang_dir); |
|
452 | 452 | } |
453 | 453 | } |
454 | 454 |