@@ -358,9 +358,9 @@ |
||
358 | 358 | require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php'; |
359 | 359 | require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php'; |
360 | 360 | |
361 | - if( defined( 'WP_CLI' ) && WP_CLI ) { |
|
362 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php'; |
|
363 | - } |
|
361 | + if( defined( 'WP_CLI' ) && WP_CLI ) { |
|
362 | + require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php'; |
|
363 | + } |
|
364 | 364 | |
365 | 365 | if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
366 | 366 |
@@ -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(); |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @since 1.8.7 |
223 | 223 | */ |
224 | - do_action( 'give_init', self::$instance ); |
|
224 | + do_action('give_init', self::$instance); |
|
225 | 225 | |
226 | 226 | return self::$instance; |
227 | 227 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | */ |
240 | 240 | public function __clone() { |
241 | 241 | // Cloning instances of the class is forbidden |
242 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'give' ), '1.0' ); |
|
242 | + _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'give'), '1.0'); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | */ |
253 | 253 | public function __wakeup() { |
254 | 254 | // Unserializing instances of the class is forbidden. |
255 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'give' ), '1.0' ); |
|
255 | + _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'give'), '1.0'); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -266,33 +266,33 @@ discard block |
||
266 | 266 | private function setup_constants() { |
267 | 267 | |
268 | 268 | // Plugin version |
269 | - if ( ! defined( 'GIVE_VERSION' ) ) { |
|
270 | - define( 'GIVE_VERSION', '1.8.7' ); |
|
269 | + if ( ! defined('GIVE_VERSION')) { |
|
270 | + define('GIVE_VERSION', '1.8.7'); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | // Plugin Folder Path |
274 | - if ( ! defined( 'GIVE_PLUGIN_DIR' ) ) { |
|
275 | - define( 'GIVE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
|
274 | + if ( ! defined('GIVE_PLUGIN_DIR')) { |
|
275 | + define('GIVE_PLUGIN_DIR', plugin_dir_path(__FILE__)); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | // Plugin Folder URL |
279 | - if ( ! defined( 'GIVE_PLUGIN_URL' ) ) { |
|
280 | - define( 'GIVE_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
|
279 | + if ( ! defined('GIVE_PLUGIN_URL')) { |
|
280 | + define('GIVE_PLUGIN_URL', plugin_dir_url(__FILE__)); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | // Plugin Basename aka: "give/give.php" |
284 | - if ( ! defined( 'GIVE_PLUGIN_BASENAME' ) ) { |
|
285 | - define( 'GIVE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); |
|
284 | + if ( ! defined('GIVE_PLUGIN_BASENAME')) { |
|
285 | + define('GIVE_PLUGIN_BASENAME', plugin_basename(__FILE__)); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | // Plugin Root File |
289 | - if ( ! defined( 'GIVE_PLUGIN_FILE' ) ) { |
|
290 | - define( 'GIVE_PLUGIN_FILE', __FILE__ ); |
|
289 | + if ( ! defined('GIVE_PLUGIN_FILE')) { |
|
290 | + define('GIVE_PLUGIN_FILE', __FILE__); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | // Make sure CAL_GREGORIAN is defined |
294 | - if ( ! defined( 'CAL_GREGORIAN' ) ) { |
|
295 | - define( 'CAL_GREGORIAN', 1 ); |
|
294 | + if ( ! defined('CAL_GREGORIAN')) { |
|
295 | + define('CAL_GREGORIAN', 1); |
|
296 | 296 | } |
297 | 297 | } |
298 | 298 | |
@@ -307,123 +307,123 @@ discard block |
||
307 | 307 | private function includes() { |
308 | 308 | global $give_options; |
309 | 309 | |
310 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-settings.php'; |
|
311 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-give-settings.php'; |
|
310 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-admin-settings.php'; |
|
311 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-give-settings.php'; |
|
312 | 312 | $give_options = give_get_settings(); |
313 | 313 | |
314 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/give-metabox-functions.php'; |
|
315 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cache.php'; |
|
316 | - require_once GIVE_PLUGIN_DIR . 'includes/post-types.php'; |
|
317 | - require_once GIVE_PLUGIN_DIR . 'includes/scripts.php'; |
|
318 | - require_once GIVE_PLUGIN_DIR . 'includes/ajax-functions.php'; |
|
319 | - require_once GIVE_PLUGIN_DIR . 'includes/actions.php'; |
|
320 | - require_once GIVE_PLUGIN_DIR . 'includes/filters.php'; |
|
321 | - require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api.php'; |
|
322 | - |
|
323 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-roles.php'; |
|
324 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-template-loader.php'; |
|
325 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-donate-form.php'; |
|
326 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db.php'; |
|
327 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-customers.php'; |
|
328 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-customer-meta.php'; |
|
329 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-customer.php'; |
|
330 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-stats.php'; |
|
331 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-session.php'; |
|
332 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-html-elements.php'; |
|
333 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-logging.php'; |
|
334 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-license-handler.php'; |
|
335 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cron.php'; |
|
336 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-email-access.php'; |
|
337 | - |
|
338 | - require_once GIVE_PLUGIN_DIR . 'includes/country-functions.php'; |
|
339 | - require_once GIVE_PLUGIN_DIR . 'includes/template-functions.php'; |
|
340 | - require_once GIVE_PLUGIN_DIR . 'includes/misc-functions.php'; |
|
341 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/functions.php'; |
|
342 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/template.php'; |
|
343 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/widget.php'; |
|
344 | - require_once GIVE_PLUGIN_DIR . 'includes/shortcodes.php'; |
|
345 | - require_once GIVE_PLUGIN_DIR . 'includes/formatting.php'; |
|
346 | - require_once GIVE_PLUGIN_DIR . 'includes/price-functions.php'; |
|
347 | - require_once GIVE_PLUGIN_DIR . 'includes/error-tracking.php'; |
|
348 | - require_once GIVE_PLUGIN_DIR . 'includes/process-donation.php'; |
|
349 | - require_once GIVE_PLUGIN_DIR . 'includes/login-register.php'; |
|
350 | - require_once GIVE_PLUGIN_DIR . 'includes/user-functions.php'; |
|
351 | - require_once GIVE_PLUGIN_DIR . 'includes/plugin-compatibility.php'; |
|
352 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-functions.php'; |
|
353 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-actions.php'; |
|
354 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-filters.php'; |
|
355 | - |
|
356 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/functions.php'; |
|
357 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/actions.php'; |
|
358 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payment-stats.php'; |
|
359 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payments-query.php'; |
|
360 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-payment.php'; |
|
361 | - |
|
362 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/functions.php'; |
|
363 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/actions.php'; |
|
364 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/paypal-standard.php'; |
|
365 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/offline-donations.php'; |
|
366 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/manual.php'; |
|
367 | - |
|
368 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-emails.php'; |
|
369 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-email-tags.php'; |
|
370 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/functions.php'; |
|
371 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php'; |
|
372 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php'; |
|
373 | - |
|
374 | - if( defined( 'WP_CLI' ) && WP_CLI ) { |
|
375 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php'; |
|
314 | + require_once GIVE_PLUGIN_DIR.'includes/admin/give-metabox-functions.php'; |
|
315 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cache.php'; |
|
316 | + require_once GIVE_PLUGIN_DIR.'includes/post-types.php'; |
|
317 | + require_once GIVE_PLUGIN_DIR.'includes/scripts.php'; |
|
318 | + require_once GIVE_PLUGIN_DIR.'includes/ajax-functions.php'; |
|
319 | + require_once GIVE_PLUGIN_DIR.'includes/actions.php'; |
|
320 | + require_once GIVE_PLUGIN_DIR.'includes/filters.php'; |
|
321 | + require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api.php'; |
|
322 | + |
|
323 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-roles.php'; |
|
324 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-template-loader.php'; |
|
325 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-donate-form.php'; |
|
326 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db.php'; |
|
327 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-customers.php'; |
|
328 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-customer-meta.php'; |
|
329 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-customer.php'; |
|
330 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-stats.php'; |
|
331 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-session.php'; |
|
332 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-html-elements.php'; |
|
333 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-logging.php'; |
|
334 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-license-handler.php'; |
|
335 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cron.php'; |
|
336 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-email-access.php'; |
|
337 | + |
|
338 | + require_once GIVE_PLUGIN_DIR.'includes/country-functions.php'; |
|
339 | + require_once GIVE_PLUGIN_DIR.'includes/template-functions.php'; |
|
340 | + require_once GIVE_PLUGIN_DIR.'includes/misc-functions.php'; |
|
341 | + require_once GIVE_PLUGIN_DIR.'includes/forms/functions.php'; |
|
342 | + require_once GIVE_PLUGIN_DIR.'includes/forms/template.php'; |
|
343 | + require_once GIVE_PLUGIN_DIR.'includes/forms/widget.php'; |
|
344 | + require_once GIVE_PLUGIN_DIR.'includes/shortcodes.php'; |
|
345 | + require_once GIVE_PLUGIN_DIR.'includes/formatting.php'; |
|
346 | + require_once GIVE_PLUGIN_DIR.'includes/price-functions.php'; |
|
347 | + require_once GIVE_PLUGIN_DIR.'includes/error-tracking.php'; |
|
348 | + require_once GIVE_PLUGIN_DIR.'includes/process-donation.php'; |
|
349 | + require_once GIVE_PLUGIN_DIR.'includes/login-register.php'; |
|
350 | + require_once GIVE_PLUGIN_DIR.'includes/user-functions.php'; |
|
351 | + require_once GIVE_PLUGIN_DIR.'includes/plugin-compatibility.php'; |
|
352 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-functions.php'; |
|
353 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-actions.php'; |
|
354 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-filters.php'; |
|
355 | + |
|
356 | + require_once GIVE_PLUGIN_DIR.'includes/payments/functions.php'; |
|
357 | + require_once GIVE_PLUGIN_DIR.'includes/payments/actions.php'; |
|
358 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-payment-stats.php'; |
|
359 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-payments-query.php'; |
|
360 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-give-payment.php'; |
|
361 | + |
|
362 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/functions.php'; |
|
363 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/actions.php'; |
|
364 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/paypal-standard.php'; |
|
365 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/offline-donations.php'; |
|
366 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/manual.php'; |
|
367 | + |
|
368 | + require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-emails.php'; |
|
369 | + require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-email-tags.php'; |
|
370 | + require_once GIVE_PLUGIN_DIR.'includes/emails/functions.php'; |
|
371 | + require_once GIVE_PLUGIN_DIR.'includes/emails/template.php'; |
|
372 | + require_once GIVE_PLUGIN_DIR.'includes/emails/actions.php'; |
|
373 | + |
|
374 | + if (defined('WP_CLI') && WP_CLI) { |
|
375 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cli-commands.php'; |
|
376 | 376 | } |
377 | 377 | |
378 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
379 | - |
|
380 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-footer.php'; |
|
381 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/welcome.php'; |
|
382 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-pages.php'; |
|
383 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-notices.php'; |
|
384 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php'; |
|
385 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-i18n-module.php'; |
|
386 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-actions.php'; |
|
387 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-filters.php'; |
|
388 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/system-info.php'; |
|
389 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/add-ons.php'; |
|
390 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/plugins.php'; |
|
391 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/dashboard-widgets.php'; |
|
392 | - |
|
393 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/actions.php'; |
|
394 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/payments-history.php'; |
|
395 | - |
|
396 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customers.php'; |
|
397 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customer-functions.php'; |
|
398 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customer-actions.php'; |
|
399 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/metabox.php'; |
|
400 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/class-metabox-form-data.php'; |
|
401 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/dashboard-columns.php'; |
|
402 | - |
|
403 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/export-functions.php'; |
|
404 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/reports.php'; |
|
405 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools.php'; |
|
406 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/tools-actions.php'; |
|
407 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/pdf-reports.php'; |
|
408 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-give-graph.php'; |
|
409 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/graphing.php'; |
|
410 | - |
|
411 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/abstract-shortcode-generator.php'; |
|
412 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/class-shortcode-button.php'; |
|
413 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-form.php'; |
|
414 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-goal.php'; |
|
415 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-login.php'; |
|
416 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-register.php'; |
|
417 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-profile-editor.php'; |
|
418 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donation-history.php'; |
|
419 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-receipt.php'; |
|
420 | - |
|
421 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
422 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrades.php'; |
|
378 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
379 | + |
|
380 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-footer.php'; |
|
381 | + require_once GIVE_PLUGIN_DIR.'includes/admin/welcome.php'; |
|
382 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-pages.php'; |
|
383 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-admin-notices.php'; |
|
384 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php'; |
|
385 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-i18n-module.php'; |
|
386 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-actions.php'; |
|
387 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-filters.php'; |
|
388 | + require_once GIVE_PLUGIN_DIR.'includes/admin/system-info.php'; |
|
389 | + require_once GIVE_PLUGIN_DIR.'includes/admin/add-ons.php'; |
|
390 | + require_once GIVE_PLUGIN_DIR.'includes/admin/plugins.php'; |
|
391 | + require_once GIVE_PLUGIN_DIR.'includes/admin/dashboard-widgets.php'; |
|
392 | + |
|
393 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/actions.php'; |
|
394 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/payments-history.php'; |
|
395 | + |
|
396 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customers.php'; |
|
397 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customer-functions.php'; |
|
398 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customer-actions.php'; |
|
399 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/metabox.php'; |
|
400 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/class-metabox-form-data.php'; |
|
401 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/dashboard-columns.php'; |
|
402 | + |
|
403 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/export-functions.php'; |
|
404 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/reports.php'; |
|
405 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/tools.php'; |
|
406 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/tools-actions.php'; |
|
407 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/pdf-reports.php'; |
|
408 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-give-graph.php'; |
|
409 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/graphing.php'; |
|
410 | + |
|
411 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/abstract-shortcode-generator.php'; |
|
412 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/class-shortcode-button.php'; |
|
413 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-form.php'; |
|
414 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-goal.php'; |
|
415 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-login.php'; |
|
416 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-register.php'; |
|
417 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-profile-editor.php'; |
|
418 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-donation-history.php'; |
|
419 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-receipt.php'; |
|
420 | + |
|
421 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
422 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrades.php'; |
|
423 | 423 | |
424 | 424 | } |
425 | 425 | |
426 | - require_once GIVE_PLUGIN_DIR . 'includes/install.php'; |
|
426 | + require_once GIVE_PLUGIN_DIR.'includes/install.php'; |
|
427 | 427 | |
428 | 428 | } |
429 | 429 | |
@@ -437,26 +437,26 @@ discard block |
||
437 | 437 | */ |
438 | 438 | public function load_textdomain() { |
439 | 439 | // Set filter for Give's languages directory |
440 | - $give_lang_dir = dirname( plugin_basename( GIVE_PLUGIN_FILE ) ) . '/languages/'; |
|
441 | - $give_lang_dir = apply_filters( 'give_languages_directory', $give_lang_dir ); |
|
440 | + $give_lang_dir = dirname(plugin_basename(GIVE_PLUGIN_FILE)).'/languages/'; |
|
441 | + $give_lang_dir = apply_filters('give_languages_directory', $give_lang_dir); |
|
442 | 442 | |
443 | 443 | // Traditional WordPress plugin locale filter |
444 | - $locale = apply_filters( 'plugin_locale', get_locale(), 'give' ); |
|
445 | - $mofile = sprintf( '%1$s-%2$s.mo', 'give', $locale ); |
|
444 | + $locale = apply_filters('plugin_locale', get_locale(), 'give'); |
|
445 | + $mofile = sprintf('%1$s-%2$s.mo', 'give', $locale); |
|
446 | 446 | |
447 | 447 | // Setup paths to current locale file |
448 | - $mofile_local = $give_lang_dir . $mofile; |
|
449 | - $mofile_global = WP_LANG_DIR . '/give/' . $mofile; |
|
448 | + $mofile_local = $give_lang_dir.$mofile; |
|
449 | + $mofile_global = WP_LANG_DIR.'/give/'.$mofile; |
|
450 | 450 | |
451 | - if ( file_exists( $mofile_global ) ) { |
|
451 | + if (file_exists($mofile_global)) { |
|
452 | 452 | // Look in global /wp-content/languages/give folder |
453 | - load_textdomain( 'give', $mofile_global ); |
|
454 | - } elseif ( file_exists( $mofile_local ) ) { |
|
453 | + load_textdomain('give', $mofile_global); |
|
454 | + } elseif (file_exists($mofile_local)) { |
|
455 | 455 | // Look in local location from filter `give_languages_directory` |
456 | - load_textdomain( 'give', $mofile_local ); |
|
456 | + load_textdomain('give', $mofile_local); |
|
457 | 457 | } else { |
458 | 458 | // Load the default language files packaged up w/ Give |
459 | - load_plugin_textdomain( 'give', false, $give_lang_dir ); |
|
459 | + load_plugin_textdomain('give', false, $give_lang_dir); |
|
460 | 460 | } |
461 | 461 | } |
462 | 462 |
@@ -45,22 +45,22 @@ discard block |
||
45 | 45 | * @param string $default_path Default path. Default is empty. |
46 | 46 | */ |
47 | 47 | function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
48 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
49 | - extract( $args ); |
|
50 | - } |
|
48 | + if ( ! empty( $args ) && is_array( $args ) ) { |
|
49 | + extract( $args ); |
|
50 | + } |
|
51 | 51 | |
52 | - $template_names = array( $template_name . '.php' ); |
|
52 | + $template_names = array( $template_name . '.php' ); |
|
53 | 53 | |
54 | - $located = give_locate_template( $template_names, $template_path, $default_path ); |
|
54 | + $located = give_locate_template( $template_names, $template_path, $default_path ); |
|
55 | 55 | |
56 | - if ( ! file_exists( $located ) ) { |
|
56 | + if ( ! file_exists( $located ) ) { |
|
57 | 57 | /* translators: %s: the template */ |
58 | - give_output_error( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true ); |
|
59 | - return; |
|
60 | - } |
|
58 | + give_output_error( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true ); |
|
59 | + return; |
|
60 | + } |
|
61 | 61 | |
62 | - // Allow 3rd party plugin filter template file from their plugin. |
|
63 | - $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
62 | + // Allow 3rd party plugin filter template file from their plugin. |
|
63 | + $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Fires in give template, before the file is included. |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * @param string $located Template file filter by 3rd party plugin. |
75 | 75 | * @param array $args Passed arguments. |
76 | 76 | */ |
77 | - do_action( 'give_before_template_part', $template_name, $template_path, $located, $args ); |
|
77 | + do_action( 'give_before_template_part', $template_name, $template_path, $located, $args ); |
|
78 | 78 | |
79 | - include( $located ); |
|
79 | + include( $located ); |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Fires in give template, after the file is included. |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param string $located Template file filter by 3rd party plugin. |
91 | 91 | * @param array $args Passed arguments. |
92 | 92 | */ |
93 | - do_action( 'give_after_template_part', $template_name, $template_path, $located, $args ); |
|
93 | + do_action( 'give_after_template_part', $template_name, $template_path, $located, $args ); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -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 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @return string |
22 | 22 | */ |
23 | 23 | function give_get_templates_dir() { |
24 | - return GIVE_PLUGIN_DIR . 'templates'; |
|
24 | + return GIVE_PLUGIN_DIR.'templates'; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @return string |
32 | 32 | */ |
33 | 33 | function give_get_templates_url() { |
34 | - return GIVE_PLUGIN_URL . 'templates'; |
|
34 | + return GIVE_PLUGIN_URL.'templates'; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -44,23 +44,23 @@ discard block |
||
44 | 44 | * @param string $template_path Template file path. Default is empty. |
45 | 45 | * @param string $default_path Default path. Default is empty. |
46 | 46 | */ |
47 | -function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
48 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
49 | - extract( $args ); |
|
47 | +function give_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
48 | + if ( ! empty($args) && is_array($args)) { |
|
49 | + extract($args); |
|
50 | 50 | } |
51 | 51 | |
52 | - $template_names = array( $template_name . '.php' ); |
|
52 | + $template_names = array($template_name.'.php'); |
|
53 | 53 | |
54 | - $located = give_locate_template( $template_names, $template_path, $default_path ); |
|
54 | + $located = give_locate_template($template_names, $template_path, $default_path); |
|
55 | 55 | |
56 | - if ( ! file_exists( $located ) ) { |
|
56 | + if ( ! file_exists($located)) { |
|
57 | 57 | /* translators: %s: the template */ |
58 | - give_output_error( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true ); |
|
58 | + give_output_error(sprintf(__('The %s template was not found.', 'give'), $located), true); |
|
59 | 59 | return; |
60 | 60 | } |
61 | 61 | |
62 | 62 | // Allow 3rd party plugin filter template file from their plugin. |
63 | - $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
63 | + $located = apply_filters('give_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Fires in give template, before the file is included. |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * @param string $located Template file filter by 3rd party plugin. |
75 | 75 | * @param array $args Passed arguments. |
76 | 76 | */ |
77 | - do_action( 'give_before_template_part', $template_name, $template_path, $located, $args ); |
|
77 | + do_action('give_before_template_part', $template_name, $template_path, $located, $args); |
|
78 | 78 | |
79 | - include( $located ); |
|
79 | + include($located); |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Fires in give template, after the file is included. |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param string $located Template file filter by 3rd party plugin. |
91 | 91 | * @param array $args Passed arguments. |
92 | 92 | */ |
93 | - do_action( 'give_after_template_part', $template_name, $template_path, $located, $args ); |
|
93 | + do_action('give_after_template_part', $template_name, $template_path, $located, $args); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @return string |
108 | 108 | */ |
109 | -function give_get_template_part( $slug, $name = null, $load = true ) { |
|
109 | +function give_get_template_part($slug, $name = null, $load = true) { |
|
110 | 110 | |
111 | 111 | /** |
112 | 112 | * Fires in give template part, before the template part is retrieved. |
@@ -118,20 +118,20 @@ discard block |
||
118 | 118 | * @param string $slug Template part file slug {slug}.php. |
119 | 119 | * @param string $name Template part file name {slug}-{name}.php. |
120 | 120 | */ |
121 | - do_action( "get_template_part_{$slug}", $slug, $name ); |
|
121 | + do_action("get_template_part_{$slug}", $slug, $name); |
|
122 | 122 | |
123 | 123 | // Setup possible parts |
124 | 124 | $templates = array(); |
125 | - if ( isset( $name ) ) { |
|
126 | - $templates[] = $slug . '-' . $name . '.php'; |
|
125 | + if (isset($name)) { |
|
126 | + $templates[] = $slug.'-'.$name.'.php'; |
|
127 | 127 | } |
128 | - $templates[] = $slug . '.php'; |
|
128 | + $templates[] = $slug.'.php'; |
|
129 | 129 | |
130 | 130 | // Allow template parts to be filtered |
131 | - $templates = apply_filters( 'give_get_template_part', $templates, $slug, $name ); |
|
131 | + $templates = apply_filters('give_get_template_part', $templates, $slug, $name); |
|
132 | 132 | |
133 | 133 | // Return the part that is found |
134 | - return give_locate_template( $templates, $load, false ); |
|
134 | + return give_locate_template($templates, $load, false); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -152,37 +152,37 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return string The template filename if one is located. |
154 | 154 | */ |
155 | -function give_locate_template( $template_names, $load = false, $require_once = true ) { |
|
155 | +function give_locate_template($template_names, $load = false, $require_once = true) { |
|
156 | 156 | // No file found yet |
157 | 157 | $located = false; |
158 | 158 | |
159 | 159 | // Try to find a template file |
160 | - foreach ( (array) $template_names as $template_name ) { |
|
160 | + foreach ((array) $template_names as $template_name) { |
|
161 | 161 | |
162 | 162 | // Continue if template is empty |
163 | - if ( empty( $template_name ) ) { |
|
163 | + if (empty($template_name)) { |
|
164 | 164 | continue; |
165 | 165 | } |
166 | 166 | |
167 | 167 | // Trim off any slashes from the template name |
168 | - $template_name = ltrim( $template_name, '/' ); |
|
168 | + $template_name = ltrim($template_name, '/'); |
|
169 | 169 | |
170 | 170 | // try locating this template file by looping through the template paths |
171 | - foreach ( give_get_theme_template_paths() as $template_path ) { |
|
171 | + foreach (give_get_theme_template_paths() as $template_path) { |
|
172 | 172 | |
173 | - if ( file_exists( $template_path . $template_name ) ) { |
|
174 | - $located = $template_path . $template_name; |
|
173 | + if (file_exists($template_path.$template_name)) { |
|
174 | + $located = $template_path.$template_name; |
|
175 | 175 | break; |
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
179 | - if ( $located ) { |
|
179 | + if ($located) { |
|
180 | 180 | break; |
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | - if ( ( true == $load ) && ! empty( $located ) ) { |
|
185 | - load_template( $located, $require_once ); |
|
184 | + if ((true == $load) && ! empty($located)) { |
|
185 | + load_template($located, $require_once); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | return $located; |
@@ -199,17 +199,17 @@ discard block |
||
199 | 199 | $template_dir = give_get_theme_template_dir_name(); |
200 | 200 | |
201 | 201 | $file_paths = array( |
202 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
203 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
202 | + 1 => trailingslashit(get_stylesheet_directory()).$template_dir, |
|
203 | + 10 => trailingslashit(get_template_directory()).$template_dir, |
|
204 | 204 | 100 => give_get_templates_dir() |
205 | 205 | ); |
206 | 206 | |
207 | - $file_paths = apply_filters( 'give_template_paths', $file_paths ); |
|
207 | + $file_paths = apply_filters('give_template_paths', $file_paths); |
|
208 | 208 | |
209 | 209 | // sort the file paths based on priority |
210 | - ksort( $file_paths, SORT_NUMERIC ); |
|
210 | + ksort($file_paths, SORT_NUMERIC); |
|
211 | 211 | |
212 | - return array_map( 'trailingslashit', $file_paths ); |
|
212 | + return array_map('trailingslashit', $file_paths); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * @return string |
222 | 222 | */ |
223 | 223 | function give_get_theme_template_dir_name() { |
224 | - return trailingslashit( apply_filters( 'give_templates_dir', 'give' ) ); |
|
224 | + return trailingslashit(apply_filters('give_templates_dir', 'give')); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -231,10 +231,10 @@ discard block |
||
231 | 231 | * @return void |
232 | 232 | */ |
233 | 233 | function give_version_in_header() { |
234 | - echo '<meta name="generator" content="Give v' . GIVE_VERSION . '" />' . "\n"; |
|
234 | + echo '<meta name="generator" content="Give v'.GIVE_VERSION.'" />'."\n"; |
|
235 | 235 | } |
236 | 236 | |
237 | -add_action( 'wp_head', 'give_version_in_header' ); |
|
237 | +add_action('wp_head', 'give_version_in_header'); |
|
238 | 238 | |
239 | 239 | /** |
240 | 240 | * Determines if we're currently on the Donations History page. |
@@ -244,9 +244,9 @@ discard block |
||
244 | 244 | */ |
245 | 245 | function give_is_donation_history_page() { |
246 | 246 | |
247 | - $ret = is_page( give_get_option( 'history_page' ) ); |
|
247 | + $ret = is_page(give_get_option('history_page')); |
|
248 | 248 | |
249 | - return apply_filters( 'give_is_donation_history_page', $ret ); |
|
249 | + return apply_filters('give_is_donation_history_page', $ret); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -258,25 +258,25 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @return array Modified array of classes |
260 | 260 | */ |
261 | -function give_add_body_classes( $class ) { |
|
261 | +function give_add_body_classes($class) { |
|
262 | 262 | $classes = (array) $class; |
263 | 263 | |
264 | - if ( give_is_success_page() ) { |
|
264 | + if (give_is_success_page()) { |
|
265 | 265 | $classes[] = 'give-success'; |
266 | 266 | $classes[] = 'give-page'; |
267 | 267 | } |
268 | 268 | |
269 | - if ( give_is_failed_transaction_page() ) { |
|
269 | + if (give_is_failed_transaction_page()) { |
|
270 | 270 | $classes[] = 'give-failed-transaction'; |
271 | 271 | $classes[] = 'give-page'; |
272 | 272 | } |
273 | 273 | |
274 | - if ( give_is_donation_history_page() ) { |
|
274 | + if (give_is_donation_history_page()) { |
|
275 | 275 | $classes[] = 'give-donation-history'; |
276 | 276 | $classes[] = 'give-page'; |
277 | 277 | } |
278 | 278 | |
279 | - if ( give_is_test_mode() ) { |
|
279 | + if (give_is_test_mode()) { |
|
280 | 280 | $classes[] = 'give-test-mode'; |
281 | 281 | $classes[] = 'give-page'; |
282 | 282 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | //Theme-specific Classes used to prevent conflicts via CSS |
285 | 285 | $current_theme = wp_get_theme(); |
286 | 286 | |
287 | - switch ( $current_theme->template ) { |
|
287 | + switch ($current_theme->template) { |
|
288 | 288 | |
289 | 289 | case 'Divi': |
290 | 290 | $classes[] = 'give-divi'; |
@@ -298,10 +298,10 @@ discard block |
||
298 | 298 | |
299 | 299 | } |
300 | 300 | |
301 | - return array_unique( $classes ); |
|
301 | + return array_unique($classes); |
|
302 | 302 | } |
303 | 303 | |
304 | -add_filter( 'body_class', 'give_add_body_classes' ); |
|
304 | +add_filter('body_class', 'give_add_body_classes'); |
|
305 | 305 | |
306 | 306 | |
307 | 307 | /** |
@@ -317,22 +317,22 @@ discard block |
||
317 | 317 | * |
318 | 318 | * @return array |
319 | 319 | */ |
320 | -function give_add_post_class( $classes, $class = '', $post_id = '' ) { |
|
321 | - if ( ! $post_id || 'give_forms' !== get_post_type( $post_id ) ) { |
|
320 | +function give_add_post_class($classes, $class = '', $post_id = '') { |
|
321 | + if ( ! $post_id || 'give_forms' !== get_post_type($post_id)) { |
|
322 | 322 | return $classes; |
323 | 323 | } |
324 | 324 | |
325 | 325 | //@TODO: Add classes for custom taxonomy and form configurations (multi vs single donations, etc). |
326 | 326 | |
327 | - if ( false !== ( $key = array_search( 'hentry', $classes ) ) ) { |
|
328 | - unset( $classes[ $key ] ); |
|
327 | + if (false !== ($key = array_search('hentry', $classes))) { |
|
328 | + unset($classes[$key]); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | return $classes; |
332 | 332 | } |
333 | 333 | |
334 | 334 | |
335 | -add_filter( 'post_class', 'give_add_post_class', 20, 3 ); |
|
335 | +add_filter('post_class', 'give_add_post_class', 20, 3); |
|
336 | 336 | |
337 | 337 | /** |
338 | 338 | * Get the placeholder image URL for forms etc |
@@ -342,84 +342,84 @@ discard block |
||
342 | 342 | */ |
343 | 343 | function give_get_placeholder_img_src() { |
344 | 344 | |
345 | - $placeholder_url = '//placehold.it/600x600&text=' . urlencode( esc_attr__( 'Give Placeholder Image', 'give' ) ); |
|
345 | + $placeholder_url = '//placehold.it/600x600&text='.urlencode(esc_attr__('Give Placeholder Image', 'give')); |
|
346 | 346 | |
347 | - return apply_filters( 'give_placeholder_img_src', $placeholder_url ); |
|
347 | + return apply_filters('give_placeholder_img_src', $placeholder_url); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | |
351 | 351 | /** |
352 | 352 | * Global |
353 | 353 | */ |
354 | -if ( ! function_exists( 'give_output_content_wrapper' ) ) { |
|
354 | +if ( ! function_exists('give_output_content_wrapper')) { |
|
355 | 355 | |
356 | 356 | /** |
357 | 357 | * Output the start of the page wrapper. |
358 | 358 | */ |
359 | 359 | function give_output_content_wrapper() { |
360 | - give_get_template_part( 'global/wrapper-start' ); |
|
360 | + give_get_template_part('global/wrapper-start'); |
|
361 | 361 | } |
362 | 362 | } |
363 | -if ( ! function_exists( 'give_output_content_wrapper_end' ) ) { |
|
363 | +if ( ! function_exists('give_output_content_wrapper_end')) { |
|
364 | 364 | |
365 | 365 | /** |
366 | 366 | * Output the end of the page wrapper. |
367 | 367 | */ |
368 | 368 | function give_output_content_wrapper_end() { |
369 | - give_get_template_part( 'global/wrapper-end' ); |
|
369 | + give_get_template_part('global/wrapper-end'); |
|
370 | 370 | } |
371 | 371 | } |
372 | 372 | |
373 | 373 | /** |
374 | 374 | * Single Give Form |
375 | 375 | */ |
376 | -if ( ! function_exists( 'give_left_sidebar_pre_wrap' ) ) { |
|
376 | +if ( ! function_exists('give_left_sidebar_pre_wrap')) { |
|
377 | 377 | function give_left_sidebar_pre_wrap() { |
378 | - echo apply_filters( 'give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">' ); |
|
378 | + echo apply_filters('give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">'); |
|
379 | 379 | } |
380 | 380 | } |
381 | 381 | |
382 | -if ( ! function_exists( 'give_left_sidebar_post_wrap' ) ) { |
|
382 | +if ( ! function_exists('give_left_sidebar_post_wrap')) { |
|
383 | 383 | function give_left_sidebar_post_wrap() { |
384 | - echo apply_filters( 'give_left_sidebar_post_wrap', '</div>' ); |
|
384 | + echo apply_filters('give_left_sidebar_post_wrap', '</div>'); |
|
385 | 385 | } |
386 | 386 | } |
387 | 387 | |
388 | -if ( ! function_exists( 'give_get_forms_sidebar' ) ) { |
|
388 | +if ( ! function_exists('give_get_forms_sidebar')) { |
|
389 | 389 | function give_get_forms_sidebar() { |
390 | - give_get_template_part( 'single-give-form/sidebar' ); |
|
390 | + give_get_template_part('single-give-form/sidebar'); |
|
391 | 391 | } |
392 | 392 | } |
393 | 393 | |
394 | -if ( ! function_exists( 'give_show_form_images' ) ) { |
|
394 | +if ( ! function_exists('give_show_form_images')) { |
|
395 | 395 | |
396 | 396 | /** |
397 | 397 | * Output the donation form featured image. |
398 | 398 | */ |
399 | 399 | function give_show_form_images() { |
400 | - if ( give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) { |
|
401 | - give_get_template_part( 'single-give-form/featured-image' ); |
|
400 | + if (give_is_setting_enabled(give_get_option('form_featured_img'))) { |
|
401 | + give_get_template_part('single-give-form/featured-image'); |
|
402 | 402 | } |
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
406 | -if ( ! function_exists( 'give_template_single_title' ) ) { |
|
406 | +if ( ! function_exists('give_template_single_title')) { |
|
407 | 407 | |
408 | 408 | /** |
409 | 409 | * Output the form title. |
410 | 410 | */ |
411 | 411 | function give_template_single_title() { |
412 | - give_get_template_part( 'single-give-form/title' ); |
|
412 | + give_get_template_part('single-give-form/title'); |
|
413 | 413 | } |
414 | 414 | } |
415 | 415 | |
416 | -if ( ! function_exists( 'give_show_avatars' ) ) { |
|
416 | +if ( ! function_exists('give_show_avatars')) { |
|
417 | 417 | |
418 | 418 | /** |
419 | 419 | * Output the product title. |
420 | 420 | */ |
421 | 421 | function give_show_avatars() { |
422 | - echo do_shortcode( '[give_donors_gravatars]' ); |
|
422 | + echo do_shortcode('[give_donors_gravatars]'); |
|
423 | 423 | } |
424 | 424 | } |
425 | 425 | |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | * Conditional Functions |
428 | 428 | */ |
429 | 429 | |
430 | -if ( ! function_exists( 'is_give_form' ) ) { |
|
430 | +if ( ! function_exists('is_give_form')) { |
|
431 | 431 | |
432 | 432 | /** |
433 | 433 | * is_give_form |
@@ -439,11 +439,11 @@ discard block |
||
439 | 439 | * @return bool |
440 | 440 | */ |
441 | 441 | function is_give_form() { |
442 | - return is_singular( array( 'give_form' ) ); |
|
442 | + return is_singular(array('give_form')); |
|
443 | 443 | } |
444 | 444 | } |
445 | 445 | |
446 | -if ( ! function_exists( 'is_give_category' ) ) { |
|
446 | +if ( ! function_exists('is_give_category')) { |
|
447 | 447 | |
448 | 448 | /** |
449 | 449 | * is_give_category |
@@ -458,12 +458,12 @@ discard block |
||
458 | 458 | * |
459 | 459 | * @return bool |
460 | 460 | */ |
461 | - function is_give_category( $term = '' ) { |
|
462 | - return is_tax( 'give_forms_category', $term ); |
|
461 | + function is_give_category($term = '') { |
|
462 | + return is_tax('give_forms_category', $term); |
|
463 | 463 | } |
464 | 464 | } |
465 | 465 | |
466 | -if ( ! function_exists( 'is_give_tag' ) ) { |
|
466 | +if ( ! function_exists('is_give_tag')) { |
|
467 | 467 | |
468 | 468 | /** |
469 | 469 | * is_give_tag |
@@ -478,12 +478,12 @@ discard block |
||
478 | 478 | * |
479 | 479 | * @return bool |
480 | 480 | */ |
481 | - function is_give_tag( $term = '' ) { |
|
482 | - return is_tax( 'give_forms_tag', $term ); |
|
481 | + function is_give_tag($term = '') { |
|
482 | + return is_tax('give_forms_tag', $term); |
|
483 | 483 | } |
484 | 484 | } |
485 | 485 | |
486 | -if ( ! function_exists( 'is_give_taxonomy' ) ) { |
|
486 | +if ( ! function_exists('is_give_taxonomy')) { |
|
487 | 487 | |
488 | 488 | /** |
489 | 489 | * is_give_taxonomy |
@@ -495,6 +495,6 @@ discard block |
||
495 | 495 | * @return bool |
496 | 496 | */ |
497 | 497 | function is_give_taxonomy() { |
498 | - return is_tax( get_object_taxonomies( 'give_form' ) ); |
|
498 | + return is_tax(get_object_taxonomies('give_form')); |
|
499 | 499 | } |
500 | 500 | } |
@@ -689,7 +689,7 @@ |
||
689 | 689 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
690 | 690 | esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) ) |
691 | 691 | ); |
692 | - }else{ |
|
692 | + } else{ |
|
693 | 693 | $messages[$subscription['id']] = sprintf( |
694 | 694 | __( 'You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ), |
695 | 695 | human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ), |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * @access private |
220 | 220 | * @since 1.0 |
221 | 221 | * |
222 | - * @return bool |
|
222 | + * @return false|null |
|
223 | 223 | */ |
224 | 224 | public function auto_updater() { |
225 | 225 | |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | * @access public |
476 | 476 | * @since 1.7 |
477 | 477 | * |
478 | - * @return bool|void |
|
478 | + * @return false|null |
|
479 | 479 | */ |
480 | 480 | public function weekly_license_check() { |
481 | 481 | |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | * @access public |
528 | 528 | * @since 1.7 |
529 | 529 | * |
530 | - * @return bool|void |
|
530 | + * @return false|null |
|
531 | 531 | */ |
532 | 532 | public function weekly_subscription_check() { |
533 | 533 | |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | * @access private |
608 | 608 | * @since 1.7 |
609 | 609 | * |
610 | - * @return bool|void |
|
610 | + * @return false|null |
|
611 | 611 | */ |
612 | 612 | private function __single_subscription_check() { |
613 | 613 | // Do not fire if license key is not set. |
@@ -802,7 +802,7 @@ discard block |
||
802 | 802 | * @access private |
803 | 803 | * @since 1.7 |
804 | 804 | * |
805 | - * @return void|bool |
|
805 | + * @return false|null |
|
806 | 806 | */ |
807 | 807 | private function __remove_license_key_from_subscriptions(){ |
808 | 808 | $subscriptions = get_option( 'give_subscriptions', array() ); |
@@ -694,7 +694,7 @@ |
||
694 | 694 | if( |
695 | 695 | empty( $this->license ) |
696 | 696 | && ! $this->__is_notice_dismissed( 'general' ) |
697 | - && empty( $showed_invalid_message ) |
|
697 | + && empty( $showed_invalid_message ) |
|
698 | 698 | ) { |
699 | 699 | $messages['general'] = sprintf( |
700 | 700 | __( 'You have invalid or expired license keys for Give Addon. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ), |
@@ -10,11 +10,11 @@ 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 | -if ( ! class_exists( 'Give_License' ) ) : |
|
17 | +if ( ! class_exists('Give_License')) : |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Give_License Class |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @var string |
105 | 105 | */ |
106 | - private $api_url = 'https://givewp.com/edd-sl-api/'; |
|
106 | + private $api_url = 'https://givewp.com/edd-sl-api/'; |
|
107 | 107 | |
108 | 108 | /** |
109 | 109 | * Account URL |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @var null|string |
115 | 115 | */ |
116 | - private $account_url = 'https://givewp.com/my-account/'; |
|
116 | + private $account_url = 'https://givewp.com/my-account/'; |
|
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Ccheckout URL |
@@ -142,19 +142,19 @@ discard block |
||
142 | 142 | * @param string $_checkout_url |
143 | 143 | * @param string $_account_url |
144 | 144 | */ |
145 | - public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null ) { |
|
145 | + public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null) { |
|
146 | 146 | $give_options = give_get_settings(); |
147 | 147 | |
148 | 148 | $this->file = $_file; |
149 | 149 | $this->item_name = $_item_name; |
150 | - $this->item_shortname = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) ); |
|
150 | + $this->item_shortname = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name))); |
|
151 | 151 | $this->version = $_version; |
152 | - $this->license = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : ''; |
|
153 | - $this->license_data = get_option( $this->item_shortname . '_license_active' ); |
|
152 | + $this->license = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : ''; |
|
153 | + $this->license_data = get_option($this->item_shortname.'_license_active'); |
|
154 | 154 | $this->author = $_author; |
155 | - $this->api_url = is_null( $_api_url ) ? $this->api_url : $_api_url; |
|
156 | - $this->checkout_url = is_null( $_checkout_url ) ? $this->checkout_url : $_checkout_url; |
|
157 | - $this->account_url = is_null( $_account_url ) ? $this->account_url : $_account_url; |
|
155 | + $this->api_url = is_null($_api_url) ? $this->api_url : $_api_url; |
|
156 | + $this->checkout_url = is_null($_checkout_url) ? $this->checkout_url : $_checkout_url; |
|
157 | + $this->account_url = is_null($_account_url) ? $this->account_url : $_account_url; |
|
158 | 158 | |
159 | 159 | // Setup hooks |
160 | 160 | $this->includes(); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @return void |
174 | 174 | */ |
175 | 175 | private function includes() { |
176 | - if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
176 | + if ( ! class_exists('EDD_SL_Plugin_Updater')) { |
|
177 | 177 | require_once 'admin/EDD_SL_Plugin_Updater.php'; |
178 | 178 | } |
179 | 179 | } |
@@ -191,26 +191,26 @@ discard block |
||
191 | 191 | private function hooks() { |
192 | 192 | |
193 | 193 | // Register settings |
194 | - add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 ); |
|
194 | + add_filter('give_settings_licenses', array($this, 'settings'), 1); |
|
195 | 195 | |
196 | 196 | // Activate license key on settings save |
197 | - add_action( 'admin_init', array( $this, 'activate_license' ) ); |
|
197 | + add_action('admin_init', array($this, 'activate_license')); |
|
198 | 198 | |
199 | 199 | // Deactivate license key |
200 | - add_action( 'admin_init', array( $this, 'deactivate_license' ) ); |
|
200 | + add_action('admin_init', array($this, 'deactivate_license')); |
|
201 | 201 | |
202 | 202 | // Updater |
203 | - add_action( 'admin_init', array( $this, 'auto_updater' ), 0 ); |
|
203 | + add_action('admin_init', array($this, 'auto_updater'), 0); |
|
204 | 204 | |
205 | - add_action( 'admin_notices', array( $this, 'notices' ) ); |
|
205 | + add_action('admin_notices', array($this, 'notices')); |
|
206 | 206 | |
207 | 207 | // Check license weekly. |
208 | - add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_license_check' ) ); |
|
209 | - add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_license_check' ) ); |
|
208 | + add_action('give_weekly_scheduled_events', array($this, 'weekly_license_check')); |
|
209 | + add_action('give_validate_license_when_site_migrated', array($this, 'weekly_license_check')); |
|
210 | 210 | |
211 | 211 | // Check subscription weekly. |
212 | - add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_subscription_check' ) ); |
|
213 | - add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_subscription_check' ) ); |
|
212 | + add_action('give_weekly_scheduled_events', array($this, 'weekly_subscription_check')); |
|
213 | + add_action('give_validate_license_when_site_migrated', array($this, 'weekly_subscription_check')); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | /** |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public function auto_updater() { |
225 | 225 | |
226 | - if ( ! $this->is_valid_license() ) { |
|
226 | + if ( ! $this->is_valid_license()) { |
|
227 | 227 | return false; |
228 | 228 | } |
229 | 229 | |
@@ -252,16 +252,16 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @return array License settings. |
254 | 254 | */ |
255 | - public function settings( $settings ) { |
|
255 | + public function settings($settings) { |
|
256 | 256 | |
257 | 257 | $give_license_settings = array( |
258 | 258 | array( |
259 | 259 | 'name' => $this->item_name, |
260 | - 'id' => $this->item_shortname . '_license_key', |
|
260 | + 'id' => $this->item_shortname.'_license_key', |
|
261 | 261 | 'desc' => '', |
262 | 262 | 'type' => 'license_key', |
263 | 263 | 'options' => array( |
264 | - 'license' => get_option( $this->item_shortname . '_license_active' ), |
|
264 | + 'license' => get_option($this->item_shortname.'_license_active'), |
|
265 | 265 | 'shortname' => $this->item_shortname, |
266 | 266 | 'item_name' => $this->item_name, |
267 | 267 | 'api_url' => $this->api_url, |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | ) |
273 | 273 | ); |
274 | 274 | |
275 | - return array_merge( $settings, $give_license_settings ); |
|
275 | + return array_merge($settings, $give_license_settings); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -287,18 +287,18 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @return array License settings content. |
289 | 289 | */ |
290 | - public function license_settings_content( $settings ) { |
|
290 | + public function license_settings_content($settings) { |
|
291 | 291 | |
292 | 292 | $give_license_settings = array( |
293 | 293 | array( |
294 | - 'name' => esc_html__( 'Add-on Licenses', 'give' ), |
|
294 | + 'name' => esc_html__('Add-on Licenses', 'give'), |
|
295 | 295 | 'desc' => '<hr>', |
296 | 296 | 'type' => 'give_title', |
297 | 297 | 'id' => 'give_title' |
298 | 298 | ), |
299 | 299 | ); |
300 | 300 | |
301 | - return array_merge( $settings, $give_license_settings ); |
|
301 | + return array_merge($settings, $give_license_settings); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
@@ -313,37 +313,37 @@ discard block |
||
313 | 313 | */ |
314 | 314 | public function activate_license() { |
315 | 315 | // Bailout: Check if license key set of not. |
316 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
316 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
317 | 317 | return; |
318 | 318 | } |
319 | 319 | |
320 | 320 | // Security check. |
321 | - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { |
|
321 | + if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) { |
|
322 | 322 | |
323 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
323 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
324 | 324 | |
325 | 325 | } |
326 | 326 | |
327 | 327 | // Check if user have correct permissions. |
328 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
328 | + if ( ! current_user_can('manage_give_settings')) { |
|
329 | 329 | return; |
330 | 330 | } |
331 | 331 | |
332 | 332 | // Allow third party addon developers to handle license activation. |
333 | - if( $this->__is_third_party_addon() ){ |
|
334 | - do_action( 'give_activate_license', $this ); |
|
333 | + if ($this->__is_third_party_addon()) { |
|
334 | + do_action('give_activate_license', $this); |
|
335 | 335 | return; |
336 | 336 | } |
337 | 337 | |
338 | 338 | // Delete previous license setting if a empty license key submitted. |
339 | - if ( empty( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
340 | - delete_option( $this->item_shortname . '_license_active' ); |
|
339 | + if (empty($_POST[$this->item_shortname.'_license_key'])) { |
|
340 | + delete_option($this->item_shortname.'_license_active'); |
|
341 | 341 | return; |
342 | 342 | } |
343 | 343 | |
344 | 344 | // Do not simultaneously activate any addon if user want to deactivate any addon. |
345 | - foreach ( $_POST as $key => $value ) { |
|
346 | - if ( false !== strpos( $key, 'license_key_deactivate' ) ) { |
|
345 | + foreach ($_POST as $key => $value) { |
|
346 | + if (false !== strpos($key, 'license_key_deactivate')) { |
|
347 | 347 | // Don't activate a key when deactivating a different key |
348 | 348 | return; |
349 | 349 | } |
@@ -351,15 +351,15 @@ discard block |
||
351 | 351 | |
352 | 352 | |
353 | 353 | // Check if plugin previously installed. |
354 | - if ( $this->is_valid_license() ) { |
|
354 | + if ($this->is_valid_license()) { |
|
355 | 355 | return; |
356 | 356 | } |
357 | 357 | |
358 | 358 | // Get license key. |
359 | - $license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] ); |
|
359 | + $license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']); |
|
360 | 360 | |
361 | 361 | // Bailout. |
362 | - if( empty( $license ) ) { |
|
362 | + if (empty($license)) { |
|
363 | 363 | return; |
364 | 364 | } |
365 | 365 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | $api_params = array( |
371 | 371 | 'edd_action' => 'activate_license', //never change from "edd_" to "give_"! |
372 | 372 | 'license' => $license, |
373 | - 'item_name' => urlencode( $this->item_name ), |
|
373 | + 'item_name' => urlencode($this->item_name), |
|
374 | 374 | 'url' => home_url() |
375 | 375 | ); |
376 | 376 | |
@@ -385,16 +385,16 @@ discard block |
||
385 | 385 | ); |
386 | 386 | |
387 | 387 | // Make sure there are no errors |
388 | - if ( is_wp_error( $response ) ) { |
|
388 | + if (is_wp_error($response)) { |
|
389 | 389 | return; |
390 | 390 | } |
391 | 391 | |
392 | 392 | // Tell WordPress to look for updates |
393 | - set_site_transient( 'update_plugins', null ); |
|
393 | + set_site_transient('update_plugins', null); |
|
394 | 394 | |
395 | 395 | // Decode license data |
396 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
397 | - update_option( $this->item_shortname . '_license_active', $license_data ); |
|
396 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
397 | + update_option($this->item_shortname.'_license_active', $license_data); |
|
398 | 398 | |
399 | 399 | // Check subscription for license key and store this to db (if any). |
400 | 400 | $this->__single_subscription_check(); |
@@ -412,34 +412,34 @@ discard block |
||
412 | 412 | */ |
413 | 413 | public function deactivate_license() { |
414 | 414 | |
415 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
415 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
416 | 416 | return; |
417 | 417 | } |
418 | 418 | |
419 | - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { |
|
419 | + if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) { |
|
420 | 420 | |
421 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
421 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
422 | 422 | |
423 | 423 | } |
424 | 424 | |
425 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
425 | + if ( ! current_user_can('manage_give_settings')) { |
|
426 | 426 | return; |
427 | 427 | } |
428 | 428 | |
429 | 429 | // Allow third party addon developers to handle license deactivation. |
430 | - if( $this->__is_third_party_addon() ){ |
|
431 | - do_action( 'give_deactivate_license', $this ); |
|
430 | + if ($this->__is_third_party_addon()) { |
|
431 | + do_action('give_deactivate_license', $this); |
|
432 | 432 | return; |
433 | 433 | } |
434 | 434 | |
435 | 435 | // Run on deactivate button press |
436 | - if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) { |
|
436 | + if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) { |
|
437 | 437 | |
438 | 438 | // Data to send to the API |
439 | 439 | $api_params = array( |
440 | 440 | 'edd_action' => 'deactivate_license', //never change from "edd_" to "give_"! |
441 | 441 | 'license' => $this->license, |
442 | - 'item_name' => urlencode( $this->item_name ), |
|
442 | + 'item_name' => urlencode($this->item_name), |
|
443 | 443 | 'url' => home_url() |
444 | 444 | ); |
445 | 445 | |
@@ -454,15 +454,15 @@ discard block |
||
454 | 454 | ); |
455 | 455 | |
456 | 456 | // Make sure there are no errors |
457 | - if ( is_wp_error( $response ) ) { |
|
457 | + if (is_wp_error($response)) { |
|
458 | 458 | return; |
459 | 459 | } |
460 | 460 | |
461 | 461 | // Decode the license data |
462 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
462 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
463 | 463 | |
464 | 464 | // Remove license data. |
465 | - delete_option( $this->item_shortname . '_license_active' ); |
|
465 | + delete_option($this->item_shortname.'_license_active'); |
|
466 | 466 | |
467 | 467 | // Remove license key from subscriptions if exist. |
468 | 468 | $this->__remove_license_key_from_subscriptions(); |
@@ -479,18 +479,18 @@ discard block |
||
479 | 479 | */ |
480 | 480 | public function weekly_license_check() { |
481 | 481 | |
482 | - if( ! empty( $_POST['give_settings'] ) ) { |
|
482 | + if ( ! empty($_POST['give_settings'])) { |
|
483 | 483 | // Don't fire when saving settings |
484 | 484 | return false; |
485 | 485 | } |
486 | 486 | |
487 | - if( empty( $this->license ) ) { |
|
487 | + if (empty($this->license)) { |
|
488 | 488 | return false; |
489 | 489 | } |
490 | 490 | |
491 | 491 | // Allow third party addon developers to handle their license check. |
492 | - if( $this->__is_third_party_addon() ){ |
|
493 | - do_action( 'give_weekly_license_check', $this ); |
|
492 | + if ($this->__is_third_party_addon()) { |
|
493 | + do_action('give_weekly_license_check', $this); |
|
494 | 494 | return false; |
495 | 495 | } |
496 | 496 | |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | $api_params = array( |
499 | 499 | 'edd_action'=> 'check_license', |
500 | 500 | 'license' => $this->license, |
501 | - 'item_name' => urlencode( $this->item_name ), |
|
501 | + 'item_name' => urlencode($this->item_name), |
|
502 | 502 | 'url' => home_url() |
503 | 503 | ); |
504 | 504 | |
@@ -513,12 +513,12 @@ discard block |
||
513 | 513 | ); |
514 | 514 | |
515 | 515 | // Make sure the response came back okay. |
516 | - if ( is_wp_error( $response ) ) { |
|
516 | + if (is_wp_error($response)) { |
|
517 | 517 | return false; |
518 | 518 | } |
519 | 519 | |
520 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
521 | - update_option( $this->item_shortname . '_license_active', $license_data ); |
|
520 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
521 | + update_option($this->item_shortname.'_license_active', $license_data); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | /** |
@@ -531,24 +531,24 @@ discard block |
||
531 | 531 | */ |
532 | 532 | public function weekly_subscription_check() { |
533 | 533 | |
534 | - if( ! empty( $_POST['give_settings'] ) ) { |
|
534 | + if ( ! empty($_POST['give_settings'])) { |
|
535 | 535 | // Don't fire when saving settings |
536 | 536 | return false; |
537 | 537 | } |
538 | 538 | |
539 | 539 | // Remove old subscription data. |
540 | - if( absint( get_option( '_give_subscriptions_edit_last', true ) ) < current_time( 'timestamp' , 1 ) ){ |
|
541 | - delete_option( 'give_subscriptions' ); |
|
542 | - update_option( '_give_subscriptions_edit_last', strtotime( '+ 1 day', current_time( 'timestamp' , 1 ) ) ); |
|
540 | + if (absint(get_option('_give_subscriptions_edit_last', true)) < current_time('timestamp', 1)) { |
|
541 | + delete_option('give_subscriptions'); |
|
542 | + update_option('_give_subscriptions_edit_last', strtotime('+ 1 day', current_time('timestamp', 1))); |
|
543 | 543 | } |
544 | 544 | |
545 | - if( empty( $this->license ) ) { |
|
545 | + if (empty($this->license)) { |
|
546 | 546 | return false; |
547 | 547 | } |
548 | 548 | |
549 | 549 | // Allow third party addon developers to handle there subscription check. |
550 | - if( $this->__is_third_party_addon() ){ |
|
551 | - do_action( 'give_weekly_subscription_check', $this ); |
|
550 | + if ($this->__is_third_party_addon()) { |
|
551 | + do_action('give_weekly_subscription_check', $this); |
|
552 | 552 | return false; |
553 | 553 | } |
554 | 554 | |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | // This is custom feature to check subscriptions. |
563 | 563 | 'edd_action'=> 'check_subscription', |
564 | 564 | 'license' => $this->license, |
565 | - 'item_name' => urlencode( $this->item_name ), |
|
565 | + 'item_name' => urlencode($this->item_name), |
|
566 | 566 | 'url' => home_url() |
567 | 567 | ); |
568 | 568 | |
@@ -577,27 +577,27 @@ discard block |
||
577 | 577 | ); |
578 | 578 | |
579 | 579 | // Make sure the response came back okay. |
580 | - if ( is_wp_error( $response ) ) { |
|
580 | + if (is_wp_error($response)) { |
|
581 | 581 | return false; |
582 | 582 | } |
583 | 583 | |
584 | - $subscription_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
584 | + $subscription_data = json_decode(wp_remote_retrieve_body($response), true); |
|
585 | 585 | |
586 | - if( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) { |
|
587 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
586 | + if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) { |
|
587 | + $subscriptions = get_option('give_subscriptions', array()); |
|
588 | 588 | |
589 | 589 | // Update subscription data only if subscription does not exist already. |
590 | - if( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) { |
|
591 | - $subscriptions[ $subscription_data['id'] ] = $subscription_data; |
|
592 | - $subscriptions[ $subscription_data['id'] ]['licenses'] = array(); |
|
590 | + if ( ! array_key_exists($subscription_data['id'], $subscriptions)) { |
|
591 | + $subscriptions[$subscription_data['id']] = $subscription_data; |
|
592 | + $subscriptions[$subscription_data['id']]['licenses'] = array(); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | // Store licenses for subscription. |
596 | - if( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) { |
|
597 | - $subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license; |
|
596 | + if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) { |
|
597 | + $subscriptions[$subscription_data['id']]['licenses'][] = $this->license; |
|
598 | 598 | } |
599 | 599 | |
600 | - update_option( 'give_subscriptions', $subscriptions ); |
|
600 | + update_option('give_subscriptions', $subscriptions); |
|
601 | 601 | } |
602 | 602 | } |
603 | 603 | |
@@ -611,11 +611,11 @@ discard block |
||
611 | 611 | */ |
612 | 612 | private function __single_subscription_check() { |
613 | 613 | // Do not fire if license key is not set. |
614 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
614 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
615 | 615 | return false; |
616 | 616 | } |
617 | 617 | |
618 | - if( empty( $this->license ) ) { |
|
618 | + if (empty($this->license)) { |
|
619 | 619 | return false; |
620 | 620 | } |
621 | 621 | |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | // This is custom feature to check subscriptions. |
627 | 627 | 'edd_action'=> 'check_subscription', |
628 | 628 | 'license' => $this->license, |
629 | - 'item_name' => urlencode( $this->item_name ), |
|
629 | + 'item_name' => urlencode($this->item_name), |
|
630 | 630 | 'url' => home_url() |
631 | 631 | ); |
632 | 632 | |
@@ -641,27 +641,27 @@ discard block |
||
641 | 641 | ); |
642 | 642 | |
643 | 643 | // Make sure the response came back okay. |
644 | - if ( is_wp_error( $response ) ) { |
|
644 | + if (is_wp_error($response)) { |
|
645 | 645 | return false; |
646 | 646 | } |
647 | 647 | |
648 | - $subscription_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
648 | + $subscription_data = json_decode(wp_remote_retrieve_body($response), true); |
|
649 | 649 | |
650 | - if( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) { |
|
651 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
650 | + if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) { |
|
651 | + $subscriptions = get_option('give_subscriptions', array()); |
|
652 | 652 | |
653 | 653 | // Update subscription data only if subscription does not exist already. |
654 | - if( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) { |
|
655 | - $subscriptions[ $subscription_data['id'] ] = $subscription_data; |
|
656 | - $subscriptions[ $subscription_data['id'] ]['licenses'] = array(); |
|
654 | + if ( ! array_key_exists($subscription_data['id'], $subscriptions)) { |
|
655 | + $subscriptions[$subscription_data['id']] = $subscription_data; |
|
656 | + $subscriptions[$subscription_data['id']]['licenses'] = array(); |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | // Store licenses for subscription. |
660 | - if( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) { |
|
661 | - $subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license; |
|
660 | + if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) { |
|
661 | + $subscriptions[$subscription_data['id']]['licenses'][] = $this->license; |
|
662 | 662 | } |
663 | 663 | |
664 | - update_option( 'give_subscriptions', $subscriptions ); |
|
664 | + update_option('give_subscriptions', $subscriptions); |
|
665 | 665 | } |
666 | 666 | } |
667 | 667 | |
@@ -674,12 +674,12 @@ discard block |
||
674 | 674 | * @return void |
675 | 675 | */ |
676 | 676 | public function notices() { |
677 | - if( ! current_user_can( 'manage_give_settings' ) ) { |
|
677 | + if ( ! current_user_can('manage_give_settings')) { |
|
678 | 678 | return; |
679 | 679 | } |
680 | 680 | |
681 | 681 | // Do not show licenses notices on license tab. |
682 | - if( 'licenses' === give_get_current_setting_tab() ) { |
|
682 | + if ('licenses' === give_get_current_setting_tab()) { |
|
683 | 683 | return; |
684 | 684 | } |
685 | 685 | |
@@ -688,93 +688,93 @@ discard block |
||
688 | 688 | static $addon_license_key_in_subscriptions; |
689 | 689 | |
690 | 690 | // Set default value. |
691 | - $addon_license_key_in_subscriptions = ! empty( $addon_license_key_in_subscriptions ) ? $addon_license_key_in_subscriptions : array(); |
|
691 | + $addon_license_key_in_subscriptions = ! empty($addon_license_key_in_subscriptions) ? $addon_license_key_in_subscriptions : array(); |
|
692 | 692 | $messages = array(); |
693 | 693 | |
694 | - if( |
|
695 | - empty( $this->license ) |
|
696 | - && ! $this->__is_notice_dismissed( 'general' ) |
|
697 | - && empty( $showed_invalid_message ) |
|
694 | + if ( |
|
695 | + empty($this->license) |
|
696 | + && ! $this->__is_notice_dismissed('general') |
|
697 | + && empty($showed_invalid_message) |
|
698 | 698 | ) { |
699 | 699 | $messages['general'] = sprintf( |
700 | - __( 'You have invalid or expired license keys for Give Addon. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ), |
|
701 | - admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) |
|
700 | + __('You have invalid or expired license keys for Give Addon. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'), |
|
701 | + admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses') |
|
702 | 702 | ); |
703 | 703 | $showed_invalid_message = true; |
704 | 704 | |
705 | 705 | } |
706 | 706 | |
707 | 707 | // Get subscriptions. |
708 | - $subscriptions = get_option( 'give_subscriptions' ); |
|
708 | + $subscriptions = get_option('give_subscriptions'); |
|
709 | 709 | |
710 | 710 | // Show subscription messages. |
711 | - if( ! empty( $subscriptions ) && ! $showed_subscriptions_message ) { |
|
711 | + if ( ! empty($subscriptions) && ! $showed_subscriptions_message) { |
|
712 | 712 | |
713 | - foreach ( $subscriptions as $subscription ) { |
|
713 | + foreach ($subscriptions as $subscription) { |
|
714 | 714 | // Subscription expires timestamp. |
715 | - $subscription_expires = strtotime( $subscription['expires'] ); |
|
715 | + $subscription_expires = strtotime($subscription['expires']); |
|
716 | 716 | |
717 | 717 | // Start showing subscriptions message before one week of renewal date. |
718 | - if( strtotime( '- 7 days', $subscription_expires ) > current_time( 'timestamp', 1 ) ) { |
|
718 | + if (strtotime('- 7 days', $subscription_expires) > current_time('timestamp', 1)) { |
|
719 | 719 | continue; |
720 | 720 | } |
721 | 721 | |
722 | 722 | // Check if subscription message already exist in messages. |
723 | - if( array_key_exists( $subscription['id'], $messages ) ) { |
|
723 | + if (array_key_exists($subscription['id'], $messages)) { |
|
724 | 724 | continue; |
725 | 725 | } |
726 | 726 | |
727 | - if( ( ! $this->__is_notice_dismissed( $subscription['id'] ) && 'active' !== $subscription['status'] ) ) { |
|
727 | + if (( ! $this->__is_notice_dismissed($subscription['id']) && 'active' !== $subscription['status'])) { |
|
728 | 728 | |
729 | - if( strtotime( $subscription['expires'] ) < current_time( 'timestamp', 1 ) ) {// Check if license already expired. |
|
729 | + if (strtotime($subscription['expires']) < current_time('timestamp', 1)) {// Check if license already expired. |
|
730 | 730 | $messages[$subscription['id']] = sprintf( |
731 | - __( 'You Give addon license expired for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ), |
|
732 | - urldecode( $subscription['invoice_url'] ), |
|
731 | + __('You Give addon license expired for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give'), |
|
732 | + urldecode($subscription['invoice_url']), |
|
733 | 733 | $subscription['payment_id'], |
734 | 734 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
735 | - esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) ) |
|
735 | + esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'])) |
|
736 | 736 | ); |
737 | - }else{ |
|
737 | + } else { |
|
738 | 738 | $messages[$subscription['id']] = sprintf( |
739 | - __( 'You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ), |
|
740 | - human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ), |
|
741 | - urldecode( $subscription['invoice_url'] ), |
|
739 | + __('You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give'), |
|
740 | + human_time_diff(current_time('timestamp', 1), strtotime($subscription['expires'])), |
|
741 | + urldecode($subscription['invoice_url']), |
|
742 | 742 | $subscription['payment_id'], |
743 | 743 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
744 | - esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) ) |
|
744 | + esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'])) |
|
745 | 745 | ); |
746 | 746 | } |
747 | 747 | } |
748 | 748 | |
749 | 749 | // Stop validation for these license keys. |
750 | - $addon_license_key_in_subscriptions = array_merge( $addon_license_key_in_subscriptions, $subscription['licenses'] ); |
|
750 | + $addon_license_key_in_subscriptions = array_merge($addon_license_key_in_subscriptions, $subscription['licenses']); |
|
751 | 751 | } |
752 | 752 | $showed_subscriptions_message = true; |
753 | 753 | } |
754 | 754 | |
755 | 755 | // Show non subscription addon messages. |
756 | - if( |
|
757 | - ! in_array( $this->license, $addon_license_key_in_subscriptions ) |
|
758 | - && ! $this->__is_notice_dismissed( 'general' ) |
|
756 | + if ( |
|
757 | + ! in_array($this->license, $addon_license_key_in_subscriptions) |
|
758 | + && ! $this->__is_notice_dismissed('general') |
|
759 | 759 | && ! $this->is_valid_license() |
760 | - && empty( $showed_invalid_message ) |
|
760 | + && empty($showed_invalid_message) |
|
761 | 761 | ) { |
762 | 762 | |
763 | 763 | $messages['general'] = sprintf( |
764 | - __( 'You have invalid or expired license keys for Give Addon. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ), |
|
765 | - admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) |
|
764 | + __('You have invalid or expired license keys for Give Addon. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'), |
|
765 | + admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses') |
|
766 | 766 | ); |
767 | 767 | $showed_invalid_message = true; |
768 | 768 | |
769 | 769 | } |
770 | 770 | |
771 | 771 | // Print messages. |
772 | - if( ! empty( $messages ) ) { |
|
773 | - foreach( $messages as $notice_id => $message ) { |
|
772 | + if ( ! empty($messages)) { |
|
773 | + foreach ($messages as $notice_id => $message) { |
|
774 | 774 | |
775 | 775 | echo sprintf( |
776 | 776 | '<div class="notice notice-error is-dismissible give-license-notice" data-dismiss-notice-shortly="%1$s"><p>%2$s</p></div>', |
777 | - esc_url( add_query_arg( '_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'] ) ), |
|
777 | + esc_url(add_query_arg('_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'])), |
|
778 | 778 | $message |
779 | 779 | ); |
780 | 780 | } |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | * @return bool |
791 | 791 | */ |
792 | 792 | public function is_valid_license() { |
793 | - if( apply_filters( 'give_is_valid_license' , ( is_object( $this->license_data ) && ! empty( $this->license_data ) && property_exists( $this->license_data, 'license' )&& 'valid' === $this->license_data->license ) ) ) { |
|
793 | + if (apply_filters('give_is_valid_license', (is_object($this->license_data) && ! empty($this->license_data) && property_exists($this->license_data, 'license') && 'valid' === $this->license_data->license))) { |
|
794 | 794 | return true; |
795 | 795 | } |
796 | 796 | |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | * @return bool |
807 | 807 | */ |
808 | 808 | private function __is_third_party_addon() { |
809 | - return ( false === strpos( $this->api_url, 'givewp.com/' ) ); |
|
809 | + return (false === strpos($this->api_url, 'givewp.com/')); |
|
810 | 810 | } |
811 | 811 | |
812 | 812 | /** |
@@ -820,26 +820,26 @@ discard block |
||
820 | 820 | * |
821 | 821 | * @return void|bool |
822 | 822 | */ |
823 | - private function __remove_license_key_from_subscriptions(){ |
|
824 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
823 | + private function __remove_license_key_from_subscriptions() { |
|
824 | + $subscriptions = get_option('give_subscriptions', array()); |
|
825 | 825 | |
826 | 826 | // Bailout. |
827 | - if( empty( $this->license ) ) { |
|
827 | + if (empty($this->license)) { |
|
828 | 828 | return false; |
829 | 829 | } |
830 | 830 | |
831 | - if( ! empty( $subscriptions ) ) { |
|
832 | - foreach ( $subscriptions as $subscription_id => $subscription ) { |
|
833 | - $license_index = array_search( $this->license, $subscription['licenses'] ); |
|
834 | - if( false !== $license_index ) { |
|
831 | + if ( ! empty($subscriptions)) { |
|
832 | + foreach ($subscriptions as $subscription_id => $subscription) { |
|
833 | + $license_index = array_search($this->license, $subscription['licenses']); |
|
834 | + if (false !== $license_index) { |
|
835 | 835 | // Remove license key. |
836 | - unset( $subscriptions[ $subscription_id ]['licenses'][$license_index] ); |
|
836 | + unset($subscriptions[$subscription_id]['licenses'][$license_index]); |
|
837 | 837 | |
838 | 838 | // Rearrange license keys. |
839 | - $subscriptions[ $subscription_id ]['licenses'] = array_values( $subscriptions[ $subscription_id ]['licenses'] ); |
|
839 | + $subscriptions[$subscription_id]['licenses'] = array_values($subscriptions[$subscription_id]['licenses']); |
|
840 | 840 | |
841 | 841 | // Update subscription information. |
842 | - update_option( 'give_subscriptions', $subscriptions ); |
|
842 | + update_option('give_subscriptions', $subscriptions); |
|
843 | 843 | break; |
844 | 844 | } |
845 | 845 | } |
@@ -854,7 +854,7 @@ discard block |
||
854 | 854 | * |
855 | 855 | * @return void |
856 | 856 | */ |
857 | - private function __remove_license_notices_show_blocker(){ |
|
857 | + private function __remove_license_notices_show_blocker() { |
|
858 | 858 | global $wpdb; |
859 | 859 | |
860 | 860 | // Delete permanent notice blocker. |
@@ -892,21 +892,21 @@ discard block |
||
892 | 892 | * |
893 | 893 | * @return bool |
894 | 894 | */ |
895 | - private function __is_notice_dismissed( $notice_id ){ |
|
895 | + private function __is_notice_dismissed($notice_id) { |
|
896 | 896 | $current_user = wp_get_current_user(); |
897 | 897 | $is_notice_dismissed = false; |
898 | 898 | |
899 | 899 | // Ge is notice dismissed permanently. |
900 | - $already_dismiss_notices = ( $already_dismiss_notices = get_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', true ) ) |
|
900 | + $already_dismiss_notices = ($already_dismiss_notices = get_user_meta($current_user->ID, '_give_hide_license_notices_permanently', true)) |
|
901 | 901 | ? $already_dismiss_notices |
902 | 902 | : array(); |
903 | 903 | |
904 | 904 | |
905 | - if( |
|
906 | - in_array( $notice_id, $already_dismiss_notices ) |
|
907 | - || Give_Cache::get( "_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}", true ) |
|
905 | + if ( |
|
906 | + in_array($notice_id, $already_dismiss_notices) |
|
907 | + || Give_Cache::get("_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}", true) |
|
908 | 908 | ) { |
909 | - $is_notice_dismissed = true; |
|
909 | + $is_notice_dismissed = true; |
|
910 | 910 | } |
911 | 911 | |
912 | 912 | return $is_notice_dismissed; |
@@ -890,7 +890,7 @@ discard block |
||
890 | 890 | * @access public |
891 | 891 | * |
892 | 892 | * @param string $meta_key Metadata name. Default is empty. |
893 | - * @param mixed $meta_value Metadata value. |
|
893 | + * @param string $meta_value Metadata value. |
|
894 | 894 | * @param bool $unique Optional. Whether the same key should not be added. Default is false. |
895 | 895 | * |
896 | 896 | * @return bool False for failure. True for success. |
@@ -922,7 +922,7 @@ discard block |
||
922 | 922 | * @access public |
923 | 923 | * |
924 | 924 | * @param string $meta_key Metadata name. Default is empty. |
925 | - * @param mixed $meta_value Optional. Metadata value. Default is empty. |
|
925 | + * @param string $meta_value Optional. Metadata value. Default is empty. |
|
926 | 926 | * |
927 | 927 | * @return bool False for failure. True for success. |
928 | 928 | */ |
@@ -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 | |
@@ -144,29 +144,29 @@ discard block |
||
144 | 144 | * @param bool $_id_or_email |
145 | 145 | * @param bool $by_user_id |
146 | 146 | */ |
147 | - public function __construct( $_id_or_email = false, $by_user_id = false ) { |
|
147 | + public function __construct($_id_or_email = false, $by_user_id = false) { |
|
148 | 148 | |
149 | 149 | $this->db = new Give_DB_Customers; |
150 | 150 | |
151 | - if ( false === $_id_or_email || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) ) { |
|
151 | + if (false === $_id_or_email || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email))) { |
|
152 | 152 | return false; |
153 | 153 | } |
154 | 154 | |
155 | - $by_user_id = is_bool( $by_user_id ) ? $by_user_id : false; |
|
155 | + $by_user_id = is_bool($by_user_id) ? $by_user_id : false; |
|
156 | 156 | |
157 | - if ( is_numeric( $_id_or_email ) ) { |
|
157 | + if (is_numeric($_id_or_email)) { |
|
158 | 158 | $field = $by_user_id ? 'user_id' : 'id'; |
159 | 159 | } else { |
160 | 160 | $field = 'email'; |
161 | 161 | } |
162 | 162 | |
163 | - $customer = $this->db->get_customer_by( $field, $_id_or_email ); |
|
163 | + $customer = $this->db->get_customer_by($field, $_id_or_email); |
|
164 | 164 | |
165 | - if ( empty( $customer ) || ! is_object( $customer ) ) { |
|
165 | + if (empty($customer) || ! is_object($customer)) { |
|
166 | 166 | return false; |
167 | 167 | } |
168 | 168 | |
169 | - $this->setup_customer( $customer ); |
|
169 | + $this->setup_customer($customer); |
|
170 | 170 | |
171 | 171 | } |
172 | 172 | |
@@ -182,15 +182,15 @@ discard block |
||
182 | 182 | * |
183 | 183 | * @return bool If the setup was successful or not. |
184 | 184 | */ |
185 | - private function setup_customer( $customer ) { |
|
185 | + private function setup_customer($customer) { |
|
186 | 186 | |
187 | - if ( ! is_object( $customer ) ) { |
|
187 | + if ( ! is_object($customer)) { |
|
188 | 188 | return false; |
189 | 189 | } |
190 | 190 | |
191 | - foreach ( $customer as $key => $value ) { |
|
191 | + foreach ($customer as $key => $value) { |
|
192 | 192 | |
193 | - switch ( $key ) { |
|
193 | + switch ($key) { |
|
194 | 194 | |
195 | 195 | case 'notes': |
196 | 196 | $this->$key = $this->get_notes(); |
@@ -204,11 +204,11 @@ discard block |
||
204 | 204 | } |
205 | 205 | |
206 | 206 | // Get donor's all email including primary email. |
207 | - $this->emails = (array) $this->get_meta( 'additional_email', false ); |
|
208 | - $this->emails = array( 'primary' => $this->email ) + $this->emails; |
|
207 | + $this->emails = (array) $this->get_meta('additional_email', false); |
|
208 | + $this->emails = array('primary' => $this->email) + $this->emails; |
|
209 | 209 | |
210 | 210 | // Customer ID and email are the only things that are necessary, make sure they exist. |
211 | - if ( ! empty( $this->id ) && ! empty( $this->email ) ) { |
|
211 | + if ( ! empty($this->id) && ! empty($this->email)) { |
|
212 | 212 | return true; |
213 | 213 | } |
214 | 214 | |
@@ -222,16 +222,16 @@ discard block |
||
222 | 222 | * @since 1.0 |
223 | 223 | * @access public |
224 | 224 | */ |
225 | - public function __get( $key ) { |
|
225 | + public function __get($key) { |
|
226 | 226 | |
227 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
227 | + if (method_exists($this, 'get_'.$key)) { |
|
228 | 228 | |
229 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
229 | + return call_user_func(array($this, 'get_'.$key)); |
|
230 | 230 | |
231 | 231 | } else { |
232 | 232 | |
233 | 233 | /* translators: %s: property key */ |
234 | - return new WP_Error( 'give-customer-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); |
|
234 | + return new WP_Error('give-customer-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key)); |
|
235 | 235 | |
236 | 236 | } |
237 | 237 | |
@@ -247,9 +247,9 @@ discard block |
||
247 | 247 | * |
248 | 248 | * @return bool|int False if not a valid creation, customer ID if user is found or valid creation. |
249 | 249 | */ |
250 | - public function create( $data = array() ) { |
|
250 | + public function create($data = array()) { |
|
251 | 251 | |
252 | - if ( $this->id != 0 || empty( $data ) ) { |
|
252 | + if ($this->id != 0 || empty($data)) { |
|
253 | 253 | return false; |
254 | 254 | } |
255 | 255 | |
@@ -257,15 +257,15 @@ discard block |
||
257 | 257 | 'payment_ids' => '', |
258 | 258 | ); |
259 | 259 | |
260 | - $args = wp_parse_args( $data, $defaults ); |
|
261 | - $args = $this->sanitize_columns( $args ); |
|
260 | + $args = wp_parse_args($data, $defaults); |
|
261 | + $args = $this->sanitize_columns($args); |
|
262 | 262 | |
263 | - if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) { |
|
263 | + if (empty($args['email']) || ! is_email($args['email'])) { |
|
264 | 264 | return false; |
265 | 265 | } |
266 | 266 | |
267 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
268 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
267 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
268 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
@@ -275,18 +275,18 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @param array $args Customer attributes. |
277 | 277 | */ |
278 | - do_action( 'give_customer_pre_create', $args ); |
|
278 | + do_action('give_customer_pre_create', $args); |
|
279 | 279 | |
280 | 280 | $created = false; |
281 | 281 | |
282 | 282 | // The DB class 'add' implies an update if the customer being asked to be created already exists |
283 | - if ( $this->db->add( $data ) ) { |
|
283 | + if ($this->db->add($data)) { |
|
284 | 284 | |
285 | 285 | // We've successfully added/updated the customer, reset the class vars with the new data |
286 | - $customer = $this->db->get_customer_by( 'email', $args['email'] ); |
|
286 | + $customer = $this->db->get_customer_by('email', $args['email']); |
|
287 | 287 | |
288 | 288 | // Setup the customer data with the values from DB |
289 | - $this->setup_customer( $customer ); |
|
289 | + $this->setup_customer($customer); |
|
290 | 290 | |
291 | 291 | $created = $this->id; |
292 | 292 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * customer ID if user is found or valid creation. |
301 | 301 | * @param array $args Customer attributes. |
302 | 302 | */ |
303 | - do_action( 'give_customer_post_create', $created, $args ); |
|
303 | + do_action('give_customer_post_create', $created, $args); |
|
304 | 304 | |
305 | 305 | return $created; |
306 | 306 | |
@@ -316,13 +316,13 @@ discard block |
||
316 | 316 | * |
317 | 317 | * @return bool If the update was successful or not. |
318 | 318 | */ |
319 | - public function update( $data = array() ) { |
|
319 | + public function update($data = array()) { |
|
320 | 320 | |
321 | - if ( empty( $data ) ) { |
|
321 | + if (empty($data)) { |
|
322 | 322 | return false; |
323 | 323 | } |
324 | 324 | |
325 | - $data = $this->sanitize_columns( $data ); |
|
325 | + $data = $this->sanitize_columns($data); |
|
326 | 326 | |
327 | 327 | /** |
328 | 328 | * Fires before updating customers. |
@@ -332,14 +332,14 @@ discard block |
||
332 | 332 | * @param int $customer_id Customer id. |
333 | 333 | * @param array $data Customer attributes. |
334 | 334 | */ |
335 | - do_action( 'give_customer_pre_update', $this->id, $data ); |
|
335 | + do_action('give_customer_pre_update', $this->id, $data); |
|
336 | 336 | |
337 | 337 | $updated = false; |
338 | 338 | |
339 | - if ( $this->db->update( $this->id, $data ) ) { |
|
339 | + if ($this->db->update($this->id, $data)) { |
|
340 | 340 | |
341 | - $customer = $this->db->get_customer_by( 'id', $this->id ); |
|
342 | - $this->setup_customer( $customer ); |
|
341 | + $customer = $this->db->get_customer_by('id', $this->id); |
|
342 | + $this->setup_customer($customer); |
|
343 | 343 | |
344 | 344 | $updated = true; |
345 | 345 | } |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | * @param int $customer_id Customer id. |
354 | 354 | * @param array $data Customer attributes. |
355 | 355 | */ |
356 | - do_action( 'give_customer_post_update', $updated, $this->id, $data ); |
|
356 | + do_action('give_customer_post_update', $updated, $this->id, $data); |
|
357 | 357 | |
358 | 358 | return $updated; |
359 | 359 | } |
@@ -371,27 +371,27 @@ discard block |
||
371 | 371 | * |
372 | 372 | * @return bool If the attachment was successfuly. |
373 | 373 | */ |
374 | - public function attach_payment( $payment_id = 0, $update_stats = true ) { |
|
374 | + public function attach_payment($payment_id = 0, $update_stats = true) { |
|
375 | 375 | |
376 | - if ( empty( $payment_id ) ) { |
|
376 | + if (empty($payment_id)) { |
|
377 | 377 | return false; |
378 | 378 | } |
379 | 379 | |
380 | - if ( empty( $this->payment_ids ) ) { |
|
380 | + if (empty($this->payment_ids)) { |
|
381 | 381 | |
382 | 382 | $new_payment_ids = $payment_id; |
383 | 383 | |
384 | 384 | } else { |
385 | 385 | |
386 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
386 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
387 | 387 | |
388 | - if ( in_array( $payment_id, $payment_ids ) ) { |
|
388 | + if (in_array($payment_id, $payment_ids)) { |
|
389 | 389 | $update_stats = false; |
390 | 390 | } |
391 | 391 | |
392 | 392 | $payment_ids[] = $payment_id; |
393 | 393 | |
394 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
394 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
395 | 395 | |
396 | 396 | } |
397 | 397 | |
@@ -403,20 +403,20 @@ discard block |
||
403 | 403 | * @param int $payment_id Payment id. |
404 | 404 | * @param int $customer_id Customer id. |
405 | 405 | */ |
406 | - do_action( 'give_customer_pre_attach_payment', $payment_id, $this->id ); |
|
406 | + do_action('give_customer_pre_attach_payment', $payment_id, $this->id); |
|
407 | 407 | |
408 | - $payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
408 | + $payment_added = $this->update(array('payment_ids' => $new_payment_ids)); |
|
409 | 409 | |
410 | - if ( $payment_added ) { |
|
410 | + if ($payment_added) { |
|
411 | 411 | |
412 | 412 | $this->payment_ids = $new_payment_ids; |
413 | 413 | |
414 | 414 | // We added this payment successfully, increment the stats |
415 | - if ( $update_stats ) { |
|
416 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
415 | + if ($update_stats) { |
|
416 | + $payment_amount = give_get_payment_amount($payment_id); |
|
417 | 417 | |
418 | - if ( ! empty( $payment_amount ) ) { |
|
419 | - $this->increase_value( $payment_amount ); |
|
418 | + if ( ! empty($payment_amount)) { |
|
419 | + $this->increase_value($payment_amount); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | $this->increase_purchase_count(); |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | * @param int $payment_id Payment id. |
433 | 433 | * @param int $customer_id Customer id. |
434 | 434 | */ |
435 | - do_action( 'give_customer_post_attach_payment', $payment_added, $payment_id, $this->id ); |
|
435 | + do_action('give_customer_post_attach_payment', $payment_added, $payment_id, $this->id); |
|
436 | 436 | |
437 | 437 | return $payment_added; |
438 | 438 | } |
@@ -450,33 +450,33 @@ discard block |
||
450 | 450 | * |
451 | 451 | * @return boolean If the removal was successful. |
452 | 452 | */ |
453 | - public function remove_payment( $payment_id = 0, $update_stats = true ) { |
|
453 | + public function remove_payment($payment_id = 0, $update_stats = true) { |
|
454 | 454 | |
455 | - if ( empty( $payment_id ) ) { |
|
455 | + if (empty($payment_id)) { |
|
456 | 456 | return false; |
457 | 457 | } |
458 | 458 | |
459 | - $payment = new Give_Payment( $payment_id ); |
|
459 | + $payment = new Give_Payment($payment_id); |
|
460 | 460 | |
461 | - if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) { |
|
461 | + if ('publish' !== $payment->status && 'revoked' !== $payment->status) { |
|
462 | 462 | $update_stats = false; |
463 | 463 | } |
464 | 464 | |
465 | 465 | $new_payment_ids = ''; |
466 | 466 | |
467 | - if ( ! empty( $this->payment_ids ) ) { |
|
467 | + if ( ! empty($this->payment_ids)) { |
|
468 | 468 | |
469 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
469 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
470 | 470 | |
471 | - $pos = array_search( $payment_id, $payment_ids ); |
|
472 | - if ( false === $pos ) { |
|
471 | + $pos = array_search($payment_id, $payment_ids); |
|
472 | + if (false === $pos) { |
|
473 | 473 | return false; |
474 | 474 | } |
475 | 475 | |
476 | - unset( $payment_ids[ $pos ] ); |
|
477 | - $payment_ids = array_filter( $payment_ids ); |
|
476 | + unset($payment_ids[$pos]); |
|
477 | + $payment_ids = array_filter($payment_ids); |
|
478 | 478 | |
479 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
479 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
480 | 480 | |
481 | 481 | } |
482 | 482 | |
@@ -488,20 +488,20 @@ discard block |
||
488 | 488 | * @param int $payment_id Payment id. |
489 | 489 | * @param int $customer_id Customer id. |
490 | 490 | */ |
491 | - do_action( 'give_customer_pre_remove_payment', $payment_id, $this->id ); |
|
491 | + do_action('give_customer_pre_remove_payment', $payment_id, $this->id); |
|
492 | 492 | |
493 | - $payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
493 | + $payment_removed = $this->update(array('payment_ids' => $new_payment_ids)); |
|
494 | 494 | |
495 | - if ( $payment_removed ) { |
|
495 | + if ($payment_removed) { |
|
496 | 496 | |
497 | 497 | $this->payment_ids = $new_payment_ids; |
498 | 498 | |
499 | - if ( $update_stats ) { |
|
499 | + if ($update_stats) { |
|
500 | 500 | // We removed this payment successfully, decrement the stats |
501 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
501 | + $payment_amount = give_get_payment_amount($payment_id); |
|
502 | 502 | |
503 | - if ( ! empty( $payment_amount ) ) { |
|
504 | - $this->decrease_value( $payment_amount ); |
|
503 | + if ( ! empty($payment_amount)) { |
|
504 | + $this->decrease_value($payment_amount); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | $this->decrease_purchase_count(); |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | * @param int $payment_id Payment id. |
518 | 518 | * @param int $customer_id Customer id. |
519 | 519 | */ |
520 | - do_action( 'give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id ); |
|
520 | + do_action('give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id); |
|
521 | 521 | |
522 | 522 | return $payment_removed; |
523 | 523 | |
@@ -533,10 +533,10 @@ discard block |
||
533 | 533 | * |
534 | 534 | * @return int The donation count. |
535 | 535 | */ |
536 | - public function increase_purchase_count( $count = 1 ) { |
|
536 | + public function increase_purchase_count($count = 1) { |
|
537 | 537 | |
538 | 538 | // Make sure it's numeric and not negative. |
539 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
539 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
540 | 540 | return false; |
541 | 541 | } |
542 | 542 | |
@@ -550,9 +550,9 @@ discard block |
||
550 | 550 | * @param int $count The number to increase by. |
551 | 551 | * @param int $customer_id Customer id. |
552 | 552 | */ |
553 | - do_action( 'give_customer_pre_increase_purchase_count', $count, $this->id ); |
|
553 | + do_action('give_customer_pre_increase_purchase_count', $count, $this->id); |
|
554 | 554 | |
555 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
555 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
556 | 556 | $this->purchase_count = $new_total; |
557 | 557 | } |
558 | 558 | |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | * @param int $count The number increased by. |
566 | 566 | * @param int $customer_id Customer id. |
567 | 567 | */ |
568 | - do_action( 'give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id ); |
|
568 | + do_action('give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id); |
|
569 | 569 | |
570 | 570 | return $this->purchase_count; |
571 | 571 | } |
@@ -580,16 +580,16 @@ discard block |
||
580 | 580 | * |
581 | 581 | * @return mixed If successful, the new count, otherwise false. |
582 | 582 | */ |
583 | - public function decrease_purchase_count( $count = 1 ) { |
|
583 | + public function decrease_purchase_count($count = 1) { |
|
584 | 584 | |
585 | 585 | // Make sure it's numeric and not negative |
586 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
586 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
587 | 587 | return false; |
588 | 588 | } |
589 | 589 | |
590 | 590 | $new_total = (int) $this->purchase_count - (int) $count; |
591 | 591 | |
592 | - if ( $new_total < 0 ) { |
|
592 | + if ($new_total < 0) { |
|
593 | 593 | $new_total = 0; |
594 | 594 | } |
595 | 595 | |
@@ -601,9 +601,9 @@ discard block |
||
601 | 601 | * @param int $count The number to decrease by. |
602 | 602 | * @param int $customer_id Customer id. |
603 | 603 | */ |
604 | - do_action( 'give_customer_pre_decrease_purchase_count', $count, $this->id ); |
|
604 | + do_action('give_customer_pre_decrease_purchase_count', $count, $this->id); |
|
605 | 605 | |
606 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
606 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
607 | 607 | $this->purchase_count = $new_total; |
608 | 608 | } |
609 | 609 | |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | * @param int $count The number decreased by. |
617 | 617 | * @param int $customer_id Customer id. |
618 | 618 | */ |
619 | - do_action( 'give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id ); |
|
619 | + do_action('give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id); |
|
620 | 620 | |
621 | 621 | return $this->purchase_count; |
622 | 622 | } |
@@ -631,9 +631,9 @@ discard block |
||
631 | 631 | * |
632 | 632 | * @return mixed If successful, the new value, otherwise false. |
633 | 633 | */ |
634 | - public function increase_value( $value = 0.00 ) { |
|
634 | + public function increase_value($value = 0.00) { |
|
635 | 635 | |
636 | - $new_value = floatval( $this->purchase_value ) + $value; |
|
636 | + $new_value = floatval($this->purchase_value) + $value; |
|
637 | 637 | |
638 | 638 | /** |
639 | 639 | * Fires before increasing customer lifetime value. |
@@ -643,9 +643,9 @@ discard block |
||
643 | 643 | * @param float $value The value to increase by. |
644 | 644 | * @param int $customer_id Customer id. |
645 | 645 | */ |
646 | - do_action( 'give_customer_pre_increase_value', $value, $this->id ); |
|
646 | + do_action('give_customer_pre_increase_value', $value, $this->id); |
|
647 | 647 | |
648 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
648 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
649 | 649 | $this->purchase_value = $new_value; |
650 | 650 | } |
651 | 651 | |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | * @param float $value The value increased by. |
659 | 659 | * @param int $customer_id Customer id. |
660 | 660 | */ |
661 | - do_action( 'give_customer_post_increase_value', $this->purchase_value, $value, $this->id ); |
|
661 | + do_action('give_customer_post_increase_value', $this->purchase_value, $value, $this->id); |
|
662 | 662 | |
663 | 663 | return $this->purchase_value; |
664 | 664 | } |
@@ -673,11 +673,11 @@ discard block |
||
673 | 673 | * |
674 | 674 | * @return mixed If successful, the new value, otherwise false. |
675 | 675 | */ |
676 | - public function decrease_value( $value = 0.00 ) { |
|
676 | + public function decrease_value($value = 0.00) { |
|
677 | 677 | |
678 | - $new_value = floatval( $this->purchase_value ) - $value; |
|
678 | + $new_value = floatval($this->purchase_value) - $value; |
|
679 | 679 | |
680 | - if ( $new_value < 0 ) { |
|
680 | + if ($new_value < 0) { |
|
681 | 681 | $new_value = 0.00; |
682 | 682 | } |
683 | 683 | |
@@ -689,9 +689,9 @@ discard block |
||
689 | 689 | * @param float $value The value to decrease by. |
690 | 690 | * @param int $customer_id Customer id. |
691 | 691 | */ |
692 | - do_action( 'give_customer_pre_decrease_value', $value, $this->id ); |
|
692 | + do_action('give_customer_pre_decrease_value', $value, $this->id); |
|
693 | 693 | |
694 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
694 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
695 | 695 | $this->purchase_value = $new_value; |
696 | 696 | } |
697 | 697 | |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | * @param float $value The value decreased by. |
705 | 705 | * @param int $customer_id Customer id. |
706 | 706 | */ |
707 | - do_action( 'give_customer_post_decrease_value', $this->purchase_value, $value, $this->id ); |
|
707 | + do_action('give_customer_post_decrease_value', $this->purchase_value, $value, $this->id); |
|
708 | 708 | |
709 | 709 | return $this->purchase_value; |
710 | 710 | } |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | * |
724 | 724 | * @return mixed If successful, the new donation stat value, otherwise false. |
725 | 725 | */ |
726 | - public function update_donation_value( $curr_amount, $new_amount ) { |
|
726 | + public function update_donation_value($curr_amount, $new_amount) { |
|
727 | 727 | /** |
728 | 728 | * Payment total difference value can be: |
729 | 729 | * zero (in case amount not change) |
@@ -733,12 +733,12 @@ discard block |
||
733 | 733 | $payment_total_diff = $new_amount - $curr_amount; |
734 | 734 | |
735 | 735 | // We do not need to update donation stat if donation did not change. |
736 | - if ( ! $payment_total_diff ) { |
|
736 | + if ( ! $payment_total_diff) { |
|
737 | 737 | return false; |
738 | 738 | } |
739 | 739 | |
740 | - if ( $payment_total_diff > 0 ) { |
|
741 | - $this->increase_value( $payment_total_diff ); |
|
740 | + if ($payment_total_diff > 0) { |
|
741 | + $this->increase_value($payment_total_diff); |
|
742 | 742 | } else { |
743 | 743 | // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
744 | 744 | $this->decrease_value( -$payment_total_diff ); |
@@ -758,15 +758,15 @@ discard block |
||
758 | 758 | * |
759 | 759 | * @return array The notes requested. |
760 | 760 | */ |
761 | - public function get_notes( $length = 20, $paged = 1 ) { |
|
761 | + public function get_notes($length = 20, $paged = 1) { |
|
762 | 762 | |
763 | - $length = is_numeric( $length ) ? $length : 20; |
|
764 | - $offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0; |
|
763 | + $length = is_numeric($length) ? $length : 20; |
|
764 | + $offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0; |
|
765 | 765 | |
766 | 766 | $all_notes = $this->get_raw_notes(); |
767 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
767 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
768 | 768 | |
769 | - $desired_notes = array_slice( $notes_array, $offset, $length ); |
|
769 | + $desired_notes = array_slice($notes_array, $offset, $length); |
|
770 | 770 | |
771 | 771 | return $desired_notes; |
772 | 772 | |
@@ -783,9 +783,9 @@ discard block |
||
783 | 783 | public function get_notes_count() { |
784 | 784 | |
785 | 785 | $all_notes = $this->get_raw_notes(); |
786 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
786 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
787 | 787 | |
788 | - return count( $notes_array ); |
|
788 | + return count($notes_array); |
|
789 | 789 | |
790 | 790 | } |
791 | 791 | |
@@ -799,22 +799,22 @@ discard block |
||
799 | 799 | * |
800 | 800 | * @return string|boolean The new note if added successfully, false otherwise. |
801 | 801 | */ |
802 | - public function add_note( $note = '' ) { |
|
802 | + public function add_note($note = '') { |
|
803 | 803 | |
804 | - $note = trim( $note ); |
|
805 | - if ( empty( $note ) ) { |
|
804 | + $note = trim($note); |
|
805 | + if (empty($note)) { |
|
806 | 806 | return false; |
807 | 807 | } |
808 | 808 | |
809 | 809 | $notes = $this->get_raw_notes(); |
810 | 810 | |
811 | - if ( empty( $notes ) ) { |
|
811 | + if (empty($notes)) { |
|
812 | 812 | $notes = ''; |
813 | 813 | } |
814 | 814 | |
815 | - $note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note; |
|
816 | - $new_note = apply_filters( 'give_customer_add_note_string', $note_string ); |
|
817 | - $notes .= "\n\n" . $new_note; |
|
815 | + $note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note; |
|
816 | + $new_note = apply_filters('give_customer_add_note_string', $note_string); |
|
817 | + $notes .= "\n\n".$new_note; |
|
818 | 818 | |
819 | 819 | /** |
820 | 820 | * Fires before customer note added. |
@@ -824,11 +824,11 @@ discard block |
||
824 | 824 | * @param string $new_note New note to add. |
825 | 825 | * @param int $customer_id Customer id. |
826 | 826 | */ |
827 | - do_action( 'give_customer_pre_add_note', $new_note, $this->id ); |
|
827 | + do_action('give_customer_pre_add_note', $new_note, $this->id); |
|
828 | 828 | |
829 | - $updated = $this->update( array( 'notes' => $notes ) ); |
|
829 | + $updated = $this->update(array('notes' => $notes)); |
|
830 | 830 | |
831 | - if ( $updated ) { |
|
831 | + if ($updated) { |
|
832 | 832 | $this->notes = $this->get_notes(); |
833 | 833 | } |
834 | 834 | |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | * @param string $new_note New note added. |
842 | 842 | * @param int $customer_id Customer id. |
843 | 843 | */ |
844 | - do_action( 'give_customer_post_add_note', $this->notes, $new_note, $this->id ); |
|
844 | + do_action('give_customer_post_add_note', $this->notes, $new_note, $this->id); |
|
845 | 845 | |
846 | 846 | // Return the formatted note, so we can test, as well as update any displays |
847 | 847 | return $new_note; |
@@ -858,7 +858,7 @@ discard block |
||
858 | 858 | */ |
859 | 859 | private function get_raw_notes() { |
860 | 860 | |
861 | - $all_notes = $this->db->get_column( 'notes', $this->id ); |
|
861 | + $all_notes = $this->db->get_column('notes', $this->id); |
|
862 | 862 | |
863 | 863 | return $all_notes; |
864 | 864 | |
@@ -875,8 +875,8 @@ discard block |
||
875 | 875 | * |
876 | 876 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true. |
877 | 877 | */ |
878 | - public function get_meta( $meta_key = '', $single = true ) { |
|
879 | - return Give()->customer_meta->get_meta( $this->id, $meta_key, $single ); |
|
878 | + public function get_meta($meta_key = '', $single = true) { |
|
879 | + return Give()->customer_meta->get_meta($this->id, $meta_key, $single); |
|
880 | 880 | } |
881 | 881 | |
882 | 882 | /** |
@@ -891,8 +891,8 @@ discard block |
||
891 | 891 | * |
892 | 892 | * @return bool False for failure. True for success. |
893 | 893 | */ |
894 | - public function add_meta( $meta_key = '', $meta_value, $unique = false ) { |
|
895 | - return Give()->customer_meta->add_meta( $this->id, $meta_key, $meta_value, $unique ); |
|
894 | + public function add_meta($meta_key = '', $meta_value, $unique = false) { |
|
895 | + return Give()->customer_meta->add_meta($this->id, $meta_key, $meta_value, $unique); |
|
896 | 896 | } |
897 | 897 | |
898 | 898 | /** |
@@ -907,8 +907,8 @@ discard block |
||
907 | 907 | * |
908 | 908 | * @return bool False on failure, true if success. |
909 | 909 | */ |
910 | - public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) { |
|
911 | - return Give()->customer_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value ); |
|
910 | + public function update_meta($meta_key = '', $meta_value, $prev_value = '') { |
|
911 | + return Give()->customer_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value); |
|
912 | 912 | } |
913 | 913 | |
914 | 914 | /** |
@@ -922,8 +922,8 @@ discard block |
||
922 | 922 | * |
923 | 923 | * @return bool False for failure. True for success. |
924 | 924 | */ |
925 | - public function delete_meta( $meta_key = '', $meta_value = '' ) { |
|
926 | - return Give()->customer_meta->delete_meta( $this->id, $meta_key, $meta_value ); |
|
925 | + public function delete_meta($meta_key = '', $meta_value = '') { |
|
926 | + return Give()->customer_meta->delete_meta($this->id, $meta_key, $meta_value); |
|
927 | 927 | } |
928 | 928 | |
929 | 929 | /** |
@@ -936,51 +936,51 @@ discard block |
||
936 | 936 | * |
937 | 937 | * @return array The sanitized data, based off column defaults. |
938 | 938 | */ |
939 | - private function sanitize_columns( $data ) { |
|
939 | + private function sanitize_columns($data) { |
|
940 | 940 | |
941 | 941 | $columns = $this->db->get_columns(); |
942 | 942 | $default_values = $this->db->get_column_defaults(); |
943 | 943 | |
944 | - foreach ( $columns as $key => $type ) { |
|
944 | + foreach ($columns as $key => $type) { |
|
945 | 945 | |
946 | 946 | // Only sanitize data that we were provided |
947 | - if ( ! array_key_exists( $key, $data ) ) { |
|
947 | + if ( ! array_key_exists($key, $data)) { |
|
948 | 948 | continue; |
949 | 949 | } |
950 | 950 | |
951 | - switch ( $type ) { |
|
951 | + switch ($type) { |
|
952 | 952 | |
953 | 953 | case '%s': |
954 | - if ( 'email' == $key ) { |
|
955 | - $data[ $key ] = sanitize_email( $data[ $key ] ); |
|
956 | - } elseif ( 'notes' == $key ) { |
|
957 | - $data[ $key ] = strip_tags( $data[ $key ] ); |
|
954 | + if ('email' == $key) { |
|
955 | + $data[$key] = sanitize_email($data[$key]); |
|
956 | + } elseif ('notes' == $key) { |
|
957 | + $data[$key] = strip_tags($data[$key]); |
|
958 | 958 | } else { |
959 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
959 | + $data[$key] = sanitize_text_field($data[$key]); |
|
960 | 960 | } |
961 | 961 | break; |
962 | 962 | |
963 | 963 | case '%d': |
964 | - if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) { |
|
965 | - $data[ $key ] = $default_values[ $key ]; |
|
964 | + if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) { |
|
965 | + $data[$key] = $default_values[$key]; |
|
966 | 966 | } else { |
967 | - $data[ $key ] = absint( $data[ $key ] ); |
|
967 | + $data[$key] = absint($data[$key]); |
|
968 | 968 | } |
969 | 969 | break; |
970 | 970 | |
971 | 971 | case '%f': |
972 | 972 | // Convert what was given to a float |
973 | - $value = floatval( $data[ $key ] ); |
|
973 | + $value = floatval($data[$key]); |
|
974 | 974 | |
975 | - if ( ! is_float( $value ) ) { |
|
976 | - $data[ $key ] = $default_values[ $key ]; |
|
975 | + if ( ! is_float($value)) { |
|
976 | + $data[$key] = $default_values[$key]; |
|
977 | 977 | } else { |
978 | - $data[ $key ] = $value; |
|
978 | + $data[$key] = $value; |
|
979 | 979 | } |
980 | 980 | break; |
981 | 981 | |
982 | 982 | default: |
983 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
983 | + $data[$key] = sanitize_text_field($data[$key]); |
|
984 | 984 | break; |
985 | 985 | |
986 | 986 | } |
@@ -1000,33 +1000,33 @@ discard block |
||
1000 | 1000 | * |
1001 | 1001 | * @return bool If the email was added successfully |
1002 | 1002 | */ |
1003 | - public function add_email( $email = '', $primary = false ) { |
|
1004 | - if ( ! is_email( $email ) ) { |
|
1003 | + public function add_email($email = '', $primary = false) { |
|
1004 | + if ( ! is_email($email)) { |
|
1005 | 1005 | return false; |
1006 | 1006 | } |
1007 | - $existing = new Give_Customer( $email ); |
|
1007 | + $existing = new Give_Customer($email); |
|
1008 | 1008 | |
1009 | - if ( $existing->id > 0 ) { |
|
1009 | + if ($existing->id > 0) { |
|
1010 | 1010 | // Email address already belongs to another customer |
1011 | 1011 | return false; |
1012 | 1012 | } |
1013 | 1013 | |
1014 | - if ( email_exists( $email ) ) { |
|
1015 | - $user = get_user_by( 'email', $email ); |
|
1016 | - if ( $user->ID != $this->user_id ) { |
|
1014 | + if (email_exists($email)) { |
|
1015 | + $user = get_user_by('email', $email); |
|
1016 | + if ($user->ID != $this->user_id) { |
|
1017 | 1017 | return false; |
1018 | 1018 | } |
1019 | 1019 | } |
1020 | 1020 | |
1021 | - do_action( 'give_donor_pre_add_email', $email, $this->id, $this ); |
|
1021 | + do_action('give_donor_pre_add_email', $email, $this->id, $this); |
|
1022 | 1022 | |
1023 | 1023 | // Add is used to ensure duplicate emails are not added |
1024 | - $ret = (bool) $this->add_meta( 'additional_email', $email ); |
|
1024 | + $ret = (bool) $this->add_meta('additional_email', $email); |
|
1025 | 1025 | |
1026 | - do_action( 'give_donor_post_add_email', $email, $this->id, $this ); |
|
1026 | + do_action('give_donor_post_add_email', $email, $this->id, $this); |
|
1027 | 1027 | |
1028 | - if ( $ret && true === $primary ) { |
|
1029 | - $this->set_primary_email( $email ); |
|
1028 | + if ($ret && true === $primary) { |
|
1029 | + $this->set_primary_email($email); |
|
1030 | 1030 | } |
1031 | 1031 | |
1032 | 1032 | return $ret; |
@@ -1042,16 +1042,16 @@ discard block |
||
1042 | 1042 | * |
1043 | 1043 | * @return bool If the email was removed successfully |
1044 | 1044 | */ |
1045 | - public function remove_email( $email = '' ) { |
|
1046 | - if ( ! is_email( $email ) ) { |
|
1045 | + public function remove_email($email = '') { |
|
1046 | + if ( ! is_email($email)) { |
|
1047 | 1047 | return false; |
1048 | 1048 | } |
1049 | 1049 | |
1050 | - do_action( 'give_donor_pre_remove_email', $email, $this->id, $this ); |
|
1050 | + do_action('give_donor_pre_remove_email', $email, $this->id, $this); |
|
1051 | 1051 | |
1052 | - $ret = (bool) $this->delete_meta( 'additional_email', $email ); |
|
1052 | + $ret = (bool) $this->delete_meta('additional_email', $email); |
|
1053 | 1053 | |
1054 | - do_action( 'give_donor_post_remove_email', $email, $this->id, $this ); |
|
1054 | + do_action('give_donor_post_remove_email', $email, $this->id, $this); |
|
1055 | 1055 | |
1056 | 1056 | return $ret; |
1057 | 1057 | } |
@@ -1068,16 +1068,16 @@ discard block |
||
1068 | 1068 | * |
1069 | 1069 | * @return bool If the email was set as primary successfully |
1070 | 1070 | */ |
1071 | - public function set_primary_email( $new_primary_email = '' ) { |
|
1072 | - if ( ! is_email( $new_primary_email ) ) { |
|
1071 | + public function set_primary_email($new_primary_email = '') { |
|
1072 | + if ( ! is_email($new_primary_email)) { |
|
1073 | 1073 | return false; |
1074 | 1074 | } |
1075 | 1075 | |
1076 | - do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this ); |
|
1076 | + do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this); |
|
1077 | 1077 | |
1078 | - $existing = new Give_Customer( $new_primary_email ); |
|
1078 | + $existing = new Give_Customer($new_primary_email); |
|
1079 | 1079 | |
1080 | - if ( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) { |
|
1080 | + if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) { |
|
1081 | 1081 | // This email belongs to another customer |
1082 | 1082 | return false; |
1083 | 1083 | } |
@@ -1085,21 +1085,21 @@ discard block |
||
1085 | 1085 | $old_email = $this->email; |
1086 | 1086 | |
1087 | 1087 | // Update customer record with new email |
1088 | - $update = $this->update( array( 'email' => $new_primary_email ) ); |
|
1088 | + $update = $this->update(array('email' => $new_primary_email)); |
|
1089 | 1089 | |
1090 | 1090 | // Remove new primary from list of additional emails |
1091 | - $remove = $this->remove_email( $new_primary_email ); |
|
1091 | + $remove = $this->remove_email($new_primary_email); |
|
1092 | 1092 | |
1093 | 1093 | // Add old email to additional emails list |
1094 | - $add = $this->add_email( $old_email ); |
|
1094 | + $add = $this->add_email($old_email); |
|
1095 | 1095 | |
1096 | 1096 | $ret = $update && $remove && $add; |
1097 | 1097 | |
1098 | - if ( $ret ) { |
|
1098 | + if ($ret) { |
|
1099 | 1099 | $this->email = $new_primary_email; |
1100 | 1100 | } |
1101 | 1101 | |
1102 | - do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this ); |
|
1102 | + do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this); |
|
1103 | 1103 | |
1104 | 1104 | return $ret; |
1105 | 1105 | } |
@@ -337,7 +337,7 @@ |
||
337 | 337 | * |
338 | 338 | * @since 1.0 |
339 | 339 | * @uses Give()->session->get() |
340 | - * @return mixed array | false |
|
340 | + * @return string array | false |
|
341 | 341 | */ |
342 | 342 | function give_get_purchase_session() { |
343 | 343 | return Give()->session->get( 'give_purchase' ); |
@@ -812,10 +812,10 @@ discard block |
||
812 | 812 | } |
813 | 813 | |
814 | 814 | if ( ! is_int( $params[1] ) |
815 | - && ! is_float( $params[1] ) |
|
816 | - && ! is_string( $params[1] ) |
|
817 | - && $params[1] !== null |
|
818 | - && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) |
|
815 | + && ! is_float( $params[1] ) |
|
816 | + && ! is_string( $params[1] ) |
|
817 | + && $params[1] !== null |
|
818 | + && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) |
|
819 | 819 | ) { |
820 | 820 | trigger_error( esc_html__( 'array_column(): The column key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
821 | 821 | |
@@ -823,10 +823,10 @@ discard block |
||
823 | 823 | } |
824 | 824 | |
825 | 825 | if ( isset( $params[2] ) |
826 | - && ! is_int( $params[2] ) |
|
827 | - && ! is_float( $params[2] ) |
|
828 | - && ! is_string( $params[2] ) |
|
829 | - && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) |
|
826 | + && ! is_int( $params[2] ) |
|
827 | + && ! is_float( $params[2] ) |
|
828 | + && ! is_string( $params[2] ) |
|
829 | + && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) |
|
830 | 830 | ) { |
831 | 831 | trigger_error( esc_html__( 'array_column(): The index key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
832 | 832 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | */ |
24 | 24 | function give_is_test_mode() { |
25 | 25 | |
26 | - $ret = give_is_setting_enabled( give_get_option( 'test_mode' ) ); |
|
26 | + $ret = give_is_setting_enabled(give_get_option('test_mode')); |
|
27 | 27 | |
28 | - return (bool) apply_filters( 'give_is_test_mode', $ret ); |
|
28 | + return (bool) apply_filters('give_is_test_mode', $ret); |
|
29 | 29 | |
30 | 30 | } |
31 | 31 | |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | */ |
38 | 38 | function give_get_currency() { |
39 | 39 | |
40 | - $currency = give_get_option( 'currency', 'USD' ); |
|
40 | + $currency = give_get_option('currency', 'USD'); |
|
41 | 41 | |
42 | - return apply_filters( 'give_currency', $currency ); |
|
42 | + return apply_filters('give_currency', $currency); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -51,9 +51,9 @@ discard block |
||
51 | 51 | */ |
52 | 52 | function give_get_currency_position() { |
53 | 53 | |
54 | - $currency_pos = give_get_option( 'currency_position', 'before' ); |
|
54 | + $currency_pos = give_get_option('currency_position', 'before'); |
|
55 | 55 | |
56 | - return apply_filters( 'give_currency_position', $currency_pos ); |
|
56 | + return apply_filters('give_currency_position', $currency_pos); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | |
@@ -66,39 +66,39 @@ discard block |
||
66 | 66 | |
67 | 67 | function give_get_currencies() { |
68 | 68 | $currencies = array( |
69 | - 'USD' => esc_html__( 'US Dollars ($)', 'give' ), |
|
70 | - 'EUR' => esc_html__( 'Euros (€)', 'give' ), |
|
71 | - 'GBP' => esc_html__( 'Pounds Sterling (£)', 'give' ), |
|
72 | - 'AUD' => esc_html__( 'Australian Dollars ($)', 'give' ), |
|
73 | - 'BRL' => esc_html__( 'Brazilian Real (R$)', 'give' ), |
|
74 | - 'CAD' => esc_html__( 'Canadian Dollars ($)', 'give' ), |
|
75 | - 'CZK' => esc_html__( 'Czech Koruna (Kč)', 'give' ), |
|
76 | - 'DKK' => esc_html__( 'Danish Krone (kr)', 'give' ), |
|
77 | - 'HKD' => esc_html__( 'Hong Kong Dollar ($)', 'give' ), |
|
78 | - 'HUF' => esc_html__( 'Hungarian Forint (Ft)', 'give' ), |
|
79 | - 'ILS' => esc_html__( 'Israeli Shekel (₪)', 'give' ), |
|
80 | - 'JPY' => esc_html__( 'Japanese Yen (¥)', 'give' ), |
|
81 | - 'MYR' => esc_html__( 'Malaysian Ringgits (RM)', 'give' ), |
|
82 | - 'MXN' => esc_html__( 'Mexican Peso ($)', 'give' ), |
|
83 | - 'MAD' => esc_html__( 'Moroccan Dirham (.د.م)', 'give' ), |
|
84 | - 'NZD' => esc_html__( 'New Zealand Dollar ($)', 'give' ), |
|
85 | - 'NOK' => esc_html__( 'Norwegian Krone (Kr.)', 'give' ), |
|
86 | - 'PHP' => esc_html__( 'Philippine Pesos (₱)', 'give' ), |
|
87 | - 'PLN' => esc_html__( 'Polish Zloty (zł)', 'give' ), |
|
88 | - 'SGD' => esc_html__( 'Singapore Dollar ($)', 'give' ), |
|
89 | - 'KRW' => esc_html__( 'South Korean Won (₩)', 'give' ), |
|
90 | - 'ZAR' => esc_html__( 'South African Rand (R)', 'give' ), |
|
91 | - 'SEK' => esc_html__( 'Swedish Krona (kr)', 'give' ), |
|
92 | - 'CHF' => esc_html__( 'Swiss Franc (CHF)', 'give' ), |
|
93 | - 'TWD' => esc_html__( 'Taiwan New Dollars (NT$)', 'give' ), |
|
94 | - 'THB' => esc_html__( 'Thai Baht (฿)', 'give' ), |
|
95 | - 'INR' => esc_html__( 'Indian Rupee (₹)', 'give' ), |
|
96 | - 'TRY' => esc_html__( 'Turkish Lira (₺)', 'give' ), |
|
97 | - 'RIAL' => esc_html__( 'Iranian Rial (﷼)', 'give' ), |
|
98 | - 'RUB' => esc_html__( 'Russian Rubles (руб)', 'give' ) |
|
69 | + 'USD' => esc_html__('US Dollars ($)', 'give'), |
|
70 | + 'EUR' => esc_html__('Euros (€)', 'give'), |
|
71 | + 'GBP' => esc_html__('Pounds Sterling (£)', 'give'), |
|
72 | + 'AUD' => esc_html__('Australian Dollars ($)', 'give'), |
|
73 | + 'BRL' => esc_html__('Brazilian Real (R$)', 'give'), |
|
74 | + 'CAD' => esc_html__('Canadian Dollars ($)', 'give'), |
|
75 | + 'CZK' => esc_html__('Czech Koruna (Kč)', 'give'), |
|
76 | + 'DKK' => esc_html__('Danish Krone (kr)', 'give'), |
|
77 | + 'HKD' => esc_html__('Hong Kong Dollar ($)', 'give'), |
|
78 | + 'HUF' => esc_html__('Hungarian Forint (Ft)', 'give'), |
|
79 | + 'ILS' => esc_html__('Israeli Shekel (₪)', 'give'), |
|
80 | + 'JPY' => esc_html__('Japanese Yen (¥)', 'give'), |
|
81 | + 'MYR' => esc_html__('Malaysian Ringgits (RM)', 'give'), |
|
82 | + 'MXN' => esc_html__('Mexican Peso ($)', 'give'), |
|
83 | + 'MAD' => esc_html__('Moroccan Dirham (.د.م)', 'give'), |
|
84 | + 'NZD' => esc_html__('New Zealand Dollar ($)', 'give'), |
|
85 | + 'NOK' => esc_html__('Norwegian Krone (Kr.)', 'give'), |
|
86 | + 'PHP' => esc_html__('Philippine Pesos (₱)', 'give'), |
|
87 | + 'PLN' => esc_html__('Polish Zloty (zł)', 'give'), |
|
88 | + 'SGD' => esc_html__('Singapore Dollar ($)', 'give'), |
|
89 | + 'KRW' => esc_html__('South Korean Won (₩)', 'give'), |
|
90 | + 'ZAR' => esc_html__('South African Rand (R)', 'give'), |
|
91 | + 'SEK' => esc_html__('Swedish Krona (kr)', 'give'), |
|
92 | + 'CHF' => esc_html__('Swiss Franc (CHF)', 'give'), |
|
93 | + 'TWD' => esc_html__('Taiwan New Dollars (NT$)', 'give'), |
|
94 | + 'THB' => esc_html__('Thai Baht (฿)', 'give'), |
|
95 | + 'INR' => esc_html__('Indian Rupee (₹)', 'give'), |
|
96 | + 'TRY' => esc_html__('Turkish Lira (₺)', 'give'), |
|
97 | + 'RIAL' => esc_html__('Iranian Rial (﷼)', 'give'), |
|
98 | + 'RUB' => esc_html__('Russian Rubles (руб)', 'give') |
|
99 | 99 | ); |
100 | 100 | |
101 | - return apply_filters( 'give_currencies', $currencies ); |
|
101 | + return apply_filters('give_currencies', $currencies); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | |
@@ -114,12 +114,12 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @return string The symbol to use for the currency |
116 | 116 | */ |
117 | -function give_currency_symbol( $currency = '' ) { |
|
117 | +function give_currency_symbol($currency = '') { |
|
118 | 118 | |
119 | - if ( empty( $currency ) ) { |
|
119 | + if (empty($currency)) { |
|
120 | 120 | $currency = give_get_currency(); |
121 | 121 | } |
122 | - switch ( $currency ) : |
|
122 | + switch ($currency) : |
|
123 | 123 | case 'GBP' : |
124 | 124 | $symbol = '£'; |
125 | 125 | break; |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | endswitch; |
199 | 199 | |
200 | 200 | |
201 | - return apply_filters( 'give_currency_symbol', $symbol, $currency ); |
|
201 | + return apply_filters('give_currency_symbol', $symbol, $currency); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | |
@@ -212,21 +212,21 @@ discard block |
||
212 | 212 | |
213 | 213 | global $wp; |
214 | 214 | |
215 | - if ( get_option( 'permalink_structure' ) ) { |
|
216 | - $base = trailingslashit( home_url( $wp->request ) ); |
|
215 | + if (get_option('permalink_structure')) { |
|
216 | + $base = trailingslashit(home_url($wp->request)); |
|
217 | 217 | } else { |
218 | - $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) ); |
|
219 | - $base = remove_query_arg( array( 'post_type', 'name' ), $base ); |
|
218 | + $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request))); |
|
219 | + $base = remove_query_arg(array('post_type', 'name'), $base); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | $scheme = is_ssl() ? 'https' : 'http'; |
223 | - $current_uri = set_url_scheme( $base, $scheme ); |
|
223 | + $current_uri = set_url_scheme($base, $scheme); |
|
224 | 224 | |
225 | - if ( is_front_page() ) { |
|
226 | - $current_uri = home_url( '/' ); |
|
225 | + if (is_front_page()) { |
|
226 | + $current_uri = home_url('/'); |
|
227 | 227 | } |
228 | 228 | |
229 | - return apply_filters( 'give_get_current_page_url', $current_uri ); |
|
229 | + return apply_filters('give_get_current_page_url', $current_uri); |
|
230 | 230 | |
231 | 231 | } |
232 | 232 | |
@@ -248,15 +248,15 @@ discard block |
||
248 | 248 | */ |
249 | 249 | $gateways = give_get_enabled_payment_gateways(); |
250 | 250 | |
251 | - if ( count( $gateways ) == 1 && ! isset( $gateways['paypal'] ) && ! isset( $gateways['manual'] ) ) { |
|
251 | + if (count($gateways) == 1 && ! isset($gateways['paypal']) && ! isset($gateways['manual'])) { |
|
252 | 252 | $ret = true; |
253 | - } else if ( count( $gateways ) == 1 ) { |
|
253 | + } else if (count($gateways) == 1) { |
|
254 | 254 | $ret = false; |
255 | - } else if ( count( $gateways ) == 2 && isset( $gateways['paypal'] ) && isset( $gateways['manual'] ) ) { |
|
255 | + } else if (count($gateways) == 2 && isset($gateways['paypal']) && isset($gateways['manual'])) { |
|
256 | 256 | $ret = false; |
257 | 257 | } |
258 | 258 | |
259 | - return (bool) apply_filters( 'give_verify_credit_cards', $ret ); |
|
259 | + return (bool) apply_filters('give_verify_credit_cards', $ret); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -268,26 +268,26 @@ discard block |
||
268 | 268 | function give_get_timezone_id() { |
269 | 269 | |
270 | 270 | // if site timezone string exists, return it |
271 | - if ( $timezone = get_option( 'timezone_string' ) ) { |
|
271 | + if ($timezone = get_option('timezone_string')) { |
|
272 | 272 | return $timezone; |
273 | 273 | } |
274 | 274 | |
275 | 275 | // get UTC offset, if it isn't set return UTC |
276 | - if ( ! ( $utc_offset = 3600 * get_option( 'gmt_offset', 0 ) ) ) { |
|
276 | + if ( ! ($utc_offset = 3600 * get_option('gmt_offset', 0))) { |
|
277 | 277 | return 'UTC'; |
278 | 278 | } |
279 | 279 | |
280 | 280 | // attempt to guess the timezone string from the UTC offset |
281 | - $timezone = timezone_name_from_abbr( '', $utc_offset ); |
|
281 | + $timezone = timezone_name_from_abbr('', $utc_offset); |
|
282 | 282 | |
283 | 283 | // last try, guess timezone string manually |
284 | - if ( $timezone === false ) { |
|
284 | + if ($timezone === false) { |
|
285 | 285 | |
286 | - $is_dst = date( 'I' ); |
|
286 | + $is_dst = date('I'); |
|
287 | 287 | |
288 | - foreach ( timezone_abbreviations_list() as $abbr ) { |
|
289 | - foreach ( $abbr as $city ) { |
|
290 | - if ( $city['dst'] == $is_dst && $city['offset'] == $utc_offset ) { |
|
288 | + foreach (timezone_abbreviations_list() as $abbr) { |
|
289 | + foreach ($abbr as $city) { |
|
290 | + if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) { |
|
291 | 291 | return $city['timezone_id']; |
292 | 292 | } |
293 | 293 | } |
@@ -311,17 +311,17 @@ discard block |
||
311 | 311 | |
312 | 312 | $ip = '127.0.0.1'; |
313 | 313 | |
314 | - if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
314 | + if ( ! empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
315 | 315 | //check ip from share internet |
316 | 316 | $ip = $_SERVER['HTTP_CLIENT_IP']; |
317 | - } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
317 | + } elseif ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
318 | 318 | //to check ip is pass from proxy |
319 | 319 | $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
320 | - } elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) { |
|
320 | + } elseif ( ! empty($_SERVER['REMOTE_ADDR'])) { |
|
321 | 321 | $ip = $_SERVER['REMOTE_ADDR']; |
322 | 322 | } |
323 | 323 | |
324 | - return apply_filters( 'give_get_ip', $ip ); |
|
324 | + return apply_filters('give_get_ip', $ip); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | |
@@ -336,9 +336,9 @@ discard block |
||
336 | 336 | * |
337 | 337 | * @uses Give()->session->set() |
338 | 338 | */ |
339 | -function give_set_purchase_session( $purchase_data = array() ) { |
|
340 | - Give()->session->set( 'give_purchase', $purchase_data ); |
|
341 | - Give()->session->set( 'give_email', $purchase_data['user_email'] ); |
|
339 | +function give_set_purchase_session($purchase_data = array()) { |
|
340 | + Give()->session->set('give_purchase', $purchase_data); |
|
341 | + Give()->session->set('give_email', $purchase_data['user_email']); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | /** |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | * @return mixed array | false |
353 | 353 | */ |
354 | 354 | function give_get_purchase_session() { |
355 | - return Give()->session->get( 'give_purchase' ); |
|
355 | + return Give()->session->get('give_purchase'); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
@@ -367,14 +367,14 @@ discard block |
||
367 | 367 | * |
368 | 368 | * @return string |
369 | 369 | */ |
370 | -function give_get_purchase_summary( $purchase_data, $email = true ) { |
|
370 | +function give_get_purchase_summary($purchase_data, $email = true) { |
|
371 | 371 | $summary = ''; |
372 | 372 | |
373 | - if ( $email ) { |
|
374 | - $summary .= $purchase_data['user_email'] . ' - '; |
|
373 | + if ($email) { |
|
374 | + $summary .= $purchase_data['user_email'].' - '; |
|
375 | 375 | } |
376 | 376 | |
377 | - $summary .= get_the_title( $purchase_data['post_data']['give-form-id'] ); |
|
377 | + $summary .= get_the_title($purchase_data['post_data']['give-form-id']); |
|
378 | 378 | |
379 | 379 | return $summary; |
380 | 380 | } |
@@ -391,31 +391,31 @@ discard block |
||
391 | 391 | function give_get_host() { |
392 | 392 | $host = false; |
393 | 393 | |
394 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
394 | + if (defined('WPE_APIKEY')) { |
|
395 | 395 | $host = 'WP Engine'; |
396 | - } elseif ( defined( 'PAGELYBIN' ) ) { |
|
396 | + } elseif (defined('PAGELYBIN')) { |
|
397 | 397 | $host = 'Pagely'; |
398 | - } elseif ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
398 | + } elseif (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
399 | 399 | $host = 'ICDSoft'; |
400 | - } elseif ( DB_HOST == 'mysqlv5' ) { |
|
400 | + } elseif (DB_HOST == 'mysqlv5') { |
|
401 | 401 | $host = 'NetworkSolutions'; |
402 | - } elseif ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
402 | + } elseif (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
403 | 403 | $host = 'iPage'; |
404 | - } elseif ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
404 | + } elseif (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
405 | 405 | $host = 'IPower'; |
406 | - } elseif ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
406 | + } elseif (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
407 | 407 | $host = 'MediaTemple Grid'; |
408 | - } elseif ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
408 | + } elseif (strpos(DB_HOST, '.pair.com') !== false) { |
|
409 | 409 | $host = 'pair Networks'; |
410 | - } elseif ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
410 | + } elseif (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
411 | 411 | $host = 'Rackspace Cloud'; |
412 | - } elseif ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
412 | + } elseif (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
413 | 413 | $host = 'SysFix.eu Power Hosting'; |
414 | - } elseif ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
414 | + } elseif (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
415 | 415 | $host = 'Flywheel'; |
416 | 416 | } else { |
417 | 417 | // Adding a general fallback for data gathering |
418 | - $host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME']; |
|
418 | + $host = 'DBH: '.DB_HOST.', SRV: '.$_SERVER['SERVER_NAME']; |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | return $host; |
@@ -431,67 +431,67 @@ discard block |
||
431 | 431 | * |
432 | 432 | * @return bool true if host matches, false if not |
433 | 433 | */ |
434 | -function give_is_host( $host = false ) { |
|
434 | +function give_is_host($host = false) { |
|
435 | 435 | |
436 | 436 | $return = false; |
437 | 437 | |
438 | - if ( $host ) { |
|
439 | - $host = str_replace( ' ', '', strtolower( $host ) ); |
|
438 | + if ($host) { |
|
439 | + $host = str_replace(' ', '', strtolower($host)); |
|
440 | 440 | |
441 | - switch ( $host ) { |
|
441 | + switch ($host) { |
|
442 | 442 | case 'wpengine': |
443 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
443 | + if (defined('WPE_APIKEY')) { |
|
444 | 444 | $return = true; |
445 | 445 | } |
446 | 446 | break; |
447 | 447 | case 'pagely': |
448 | - if ( defined( 'PAGELYBIN' ) ) { |
|
448 | + if (defined('PAGELYBIN')) { |
|
449 | 449 | $return = true; |
450 | 450 | } |
451 | 451 | break; |
452 | 452 | case 'icdsoft': |
453 | - if ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
453 | + if (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
454 | 454 | $return = true; |
455 | 455 | } |
456 | 456 | break; |
457 | 457 | case 'networksolutions': |
458 | - if ( DB_HOST == 'mysqlv5' ) { |
|
458 | + if (DB_HOST == 'mysqlv5') { |
|
459 | 459 | $return = true; |
460 | 460 | } |
461 | 461 | break; |
462 | 462 | case 'ipage': |
463 | - if ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
463 | + if (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
464 | 464 | $return = true; |
465 | 465 | } |
466 | 466 | break; |
467 | 467 | case 'ipower': |
468 | - if ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
468 | + if (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
469 | 469 | $return = true; |
470 | 470 | } |
471 | 471 | break; |
472 | 472 | case 'mediatemplegrid': |
473 | - if ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
473 | + if (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
474 | 474 | $return = true; |
475 | 475 | } |
476 | 476 | break; |
477 | 477 | case 'pairnetworks': |
478 | - if ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
478 | + if (strpos(DB_HOST, '.pair.com') !== false) { |
|
479 | 479 | $return = true; |
480 | 480 | } |
481 | 481 | break; |
482 | 482 | case 'rackspacecloud': |
483 | - if ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
483 | + if (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
484 | 484 | $return = true; |
485 | 485 | } |
486 | 486 | break; |
487 | 487 | case 'sysfix.eu': |
488 | 488 | case 'sysfix.eupowerhosting': |
489 | - if ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
489 | + if (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
490 | 490 | $return = true; |
491 | 491 | } |
492 | 492 | break; |
493 | 493 | case 'flywheel': |
494 | - if ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
494 | + if (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
495 | 495 | $return = true; |
496 | 496 | } |
497 | 497 | break; |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | * @param string $replacement Optional. The function that should have been called. |
525 | 525 | * @param array $backtrace Optional. Contains stack backtrace of deprecated function. |
526 | 526 | */ |
527 | -function _give_deprecated_function( $function, $version, $replacement = null, $backtrace = null ) { |
|
527 | +function _give_deprecated_function($function, $version, $replacement = null, $backtrace = null) { |
|
528 | 528 | |
529 | 529 | /** |
530 | 530 | * Fires while give deprecated function call occurs. |
@@ -537,19 +537,19 @@ discard block |
||
537 | 537 | * @param string $replacement Optional. The function that should have been called. |
538 | 538 | * @param string $version The plugin version that deprecated the function. |
539 | 539 | */ |
540 | - do_action( 'give_deprecated_function_run', $function, $replacement, $version ); |
|
540 | + do_action('give_deprecated_function_run', $function, $replacement, $version); |
|
541 | 541 | |
542 | - $show_errors = current_user_can( 'manage_options' ); |
|
542 | + $show_errors = current_user_can('manage_options'); |
|
543 | 543 | |
544 | 544 | // Allow plugin to filter the output error trigger |
545 | - if ( WP_DEBUG && apply_filters( 'give_deprecated_function_trigger_error', $show_errors ) ) { |
|
546 | - if ( ! is_null( $replacement ) ) { |
|
547 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give' ), $function, $version, $replacement ) ); |
|
548 | - trigger_error( print_r( $backtrace, 1 ) ); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
545 | + if (WP_DEBUG && apply_filters('give_deprecated_function_trigger_error', $show_errors)) { |
|
546 | + if ( ! is_null($replacement)) { |
|
547 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give'), $function, $version, $replacement)); |
|
548 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
549 | 549 | // Alternatively we could dump this to a file. |
550 | 550 | } else { |
551 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give' ), $function, $version ) ); |
|
552 | - trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
551 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give'), $function, $version)); |
|
552 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
553 | 553 | // Alternatively we could dump this to a file. |
554 | 554 | } |
555 | 555 | } |
@@ -563,8 +563,8 @@ discard block |
||
563 | 563 | * @return string $post_id |
564 | 564 | */ |
565 | 565 | function give_get_admin_post_id() { |
566 | - $post_id = isset( $_GET['post'] ) ? $_GET['post'] : null; |
|
567 | - if ( ! $post_id && isset( $_POST['post_id'] ) ) { |
|
566 | + $post_id = isset($_GET['post']) ? $_GET['post'] : null; |
|
567 | + if ( ! $post_id && isset($_POST['post_id'])) { |
|
568 | 568 | $post_id = $_POST['post_id']; |
569 | 569 | } |
570 | 570 | |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | * @return string Arg separator output |
579 | 579 | */ |
580 | 580 | function give_get_php_arg_separator_output() { |
581 | - return ini_get( 'arg_separator.output' ); |
|
581 | + return ini_get('arg_separator.output'); |
|
582 | 582 | } |
583 | 583 | |
584 | 584 | |
@@ -593,10 +593,10 @@ discard block |
||
593 | 593 | * |
594 | 594 | * @return string Short month name |
595 | 595 | */ |
596 | -function give_month_num_to_name( $n ) { |
|
597 | - $timestamp = mktime( 0, 0, 0, $n, 1, 2005 ); |
|
596 | +function give_month_num_to_name($n) { |
|
597 | + $timestamp = mktime(0, 0, 0, $n, 1, 2005); |
|
598 | 598 | |
599 | - return date_i18n( "M", $timestamp ); |
|
599 | + return date_i18n("M", $timestamp); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | |
@@ -609,10 +609,10 @@ discard block |
||
609 | 609 | * |
610 | 610 | * @return bool Whether or not function is disabled. |
611 | 611 | */ |
612 | -function give_is_func_disabled( $function ) { |
|
613 | - $disabled = explode( ',', ini_get( 'disable_functions' ) ); |
|
612 | +function give_is_func_disabled($function) { |
|
613 | + $disabled = explode(',', ini_get('disable_functions')); |
|
614 | 614 | |
615 | - return in_array( $function, $disabled ); |
|
615 | + return in_array($function, $disabled); |
|
616 | 616 | } |
617 | 617 | |
618 | 618 | |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | */ |
624 | 624 | function give_get_newsletter() { ?> |
625 | 625 | |
626 | - <p class="newsletter-intro"><?php esc_html_e( 'Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give' ); ?></p> |
|
626 | + <p class="newsletter-intro"><?php esc_html_e('Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give'); ?></p> |
|
627 | 627 | |
628 | 628 | <div class="give-newsletter-form-wrap"> |
629 | 629 | |
@@ -631,33 +631,33 @@ discard block |
||
631 | 631 | method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" |
632 | 632 | target="_blank" novalidate> |
633 | 633 | <div class="give-newsletter-confirmation"> |
634 | - <p><?php esc_html_e( 'Thanks for Subscribing!', 'give' ); ?> :)</p> |
|
634 | + <p><?php esc_html_e('Thanks for Subscribing!', 'give'); ?> :)</p> |
|
635 | 635 | </div> |
636 | 636 | |
637 | 637 | <table class="form-table give-newsletter-form"> |
638 | 638 | <tr valign="middle"> |
639 | 639 | <td> |
640 | 640 | <label for="mce-EMAIL" |
641 | - class="screen-reader-text"><?php esc_html_e( 'Email Address (required)', 'give' ); ?></label> |
|
641 | + class="screen-reader-text"><?php esc_html_e('Email Address (required)', 'give'); ?></label> |
|
642 | 642 | <input type="email" name="EMAIL" id="mce-EMAIL" |
643 | - placeholder="<?php esc_attr_e( 'Email Address (required)', 'give' ); ?>" |
|
643 | + placeholder="<?php esc_attr_e('Email Address (required)', 'give'); ?>" |
|
644 | 644 | class="required email" value=""> |
645 | 645 | </td> |
646 | 646 | <td> |
647 | 647 | <label for="mce-FNAME" |
648 | - class="screen-reader-text"><?php esc_html_e( 'First Name', 'give' ); ?></label> |
|
648 | + class="screen-reader-text"><?php esc_html_e('First Name', 'give'); ?></label> |
|
649 | 649 | <input type="text" name="FNAME" id="mce-FNAME" |
650 | - placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>" class="" value=""> |
|
650 | + placeholder="<?php esc_attr_e('First Name', 'give'); ?>" class="" value=""> |
|
651 | 651 | </td> |
652 | 652 | <td> |
653 | 653 | <label for="mce-LNAME" |
654 | - class="screen-reader-text"><?php esc_html_e( 'Last Name', 'give' ); ?></label> |
|
654 | + class="screen-reader-text"><?php esc_html_e('Last Name', 'give'); ?></label> |
|
655 | 655 | <input type="text" name="LNAME" id="mce-LNAME" |
656 | - placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>" class="" value=""> |
|
656 | + placeholder="<?php esc_attr_e('Last Name', 'give'); ?>" class="" value=""> |
|
657 | 657 | </td> |
658 | 658 | <td> |
659 | 659 | <input type="submit" name="subscribe" id="mc-embedded-subscribe" class="button" |
660 | - value="<?php esc_attr_e( 'Subscribe', 'give' ); ?>"> |
|
660 | + value="<?php esc_attr_e('Subscribe', 'give'); ?>"> |
|
661 | 661 | </td> |
662 | 662 | </tr> |
663 | 663 | </table> |
@@ -720,7 +720,7 @@ discard block |
||
720 | 720 | <a href="https://twitter.com/givewp" class="twitter-follow-button" data-show-count="false"><?php |
721 | 721 | printf( |
722 | 722 | /* translators: %s: Give twitter user @givewp */ |
723 | - esc_html_e( 'Follow %s', 'give' ), |
|
723 | + esc_html_e('Follow %s', 'give'), |
|
724 | 724 | '@givewp' |
725 | 725 | ); |
726 | 726 | ?></a> |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | * |
750 | 750 | * @return string |
751 | 751 | */ |
752 | -function give_svg_icons( $icon ) { |
|
752 | +function give_svg_icons($icon) { |
|
753 | 753 | |
754 | 754 | // Store your SVGs in an associative array |
755 | 755 | $svgs = array( |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | ); |
762 | 762 | |
763 | 763 | // Return the chosen icon's SVG string |
764 | - return $svgs[ $icon ]; |
|
764 | + return $svgs[$icon]; |
|
765 | 765 | } |
766 | 766 | |
767 | 767 | /** |
@@ -773,15 +773,15 @@ discard block |
||
773 | 773 | * |
774 | 774 | * @return mixed |
775 | 775 | */ |
776 | -function modify_nav_menu_meta_box_object( $post_type ) { |
|
777 | - if ( isset( $post_type->name ) && $post_type->name == 'give_forms' ) { |
|
778 | - $post_type->labels->name = esc_html__( 'Donation Forms', 'give' ); |
|
776 | +function modify_nav_menu_meta_box_object($post_type) { |
|
777 | + if (isset($post_type->name) && $post_type->name == 'give_forms') { |
|
778 | + $post_type->labels->name = esc_html__('Donation Forms', 'give'); |
|
779 | 779 | } |
780 | 780 | |
781 | 781 | return $post_type; |
782 | 782 | } |
783 | 783 | |
784 | -add_filter( 'nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object' ); |
|
784 | +add_filter('nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object'); |
|
785 | 785 | |
786 | 786 | |
787 | 787 | /** |
@@ -795,7 +795,7 @@ discard block |
||
795 | 795 | * @license https://opensource.org/licenses/MIT MIT |
796 | 796 | */ |
797 | 797 | |
798 | -if ( ! function_exists( 'array_column' ) ) { |
|
798 | +if ( ! function_exists('array_column')) { |
|
799 | 799 | /** |
800 | 800 | * Returns the values from a single column of the input array, identified by |
801 | 801 | * the $columnKey. |
@@ -814,53 +814,53 @@ discard block |
||
814 | 814 | * |
815 | 815 | * @return array |
816 | 816 | */ |
817 | - function array_column( $input = null, $columnKey = null, $indexKey = null ) { |
|
817 | + function array_column($input = null, $columnKey = null, $indexKey = null) { |
|
818 | 818 | // Using func_get_args() in order to check for proper number of |
819 | 819 | // parameters and trigger errors exactly as the built-in array_column() |
820 | 820 | // does in PHP 5.5. |
821 | 821 | $argc = func_num_args(); |
822 | 822 | $params = func_get_args(); |
823 | 823 | |
824 | - if ( $argc < 2 ) { |
|
825 | - trigger_error( sprintf( esc_html__( 'array_column() expects at least 2 parameters, %s given.', 'give' ), $argc ), E_USER_WARNING ); |
|
824 | + if ($argc < 2) { |
|
825 | + trigger_error(sprintf(esc_html__('array_column() expects at least 2 parameters, %s given.', 'give'), $argc), E_USER_WARNING); |
|
826 | 826 | |
827 | 827 | return null; |
828 | 828 | } |
829 | 829 | |
830 | - if ( ! is_array( $params[0] ) ) { |
|
831 | - trigger_error( sprintf( esc_html__( 'array_column() expects parameter 1 to be array, %s given.', 'give' ), gettype( $params[0] ) ), E_USER_WARNING ); |
|
830 | + if ( ! is_array($params[0])) { |
|
831 | + trigger_error(sprintf(esc_html__('array_column() expects parameter 1 to be array, %s given.', 'give'), gettype($params[0])), E_USER_WARNING); |
|
832 | 832 | |
833 | 833 | return null; |
834 | 834 | } |
835 | 835 | |
836 | - if ( ! is_int( $params[1] ) |
|
837 | - && ! is_float( $params[1] ) |
|
838 | - && ! is_string( $params[1] ) |
|
836 | + if ( ! is_int($params[1]) |
|
837 | + && ! is_float($params[1]) |
|
838 | + && ! is_string($params[1]) |
|
839 | 839 | && $params[1] !== null |
840 | - && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) |
|
840 | + && ! (is_object($params[1]) && method_exists($params[1], '__toString')) |
|
841 | 841 | ) { |
842 | - trigger_error( esc_html__( 'array_column(): The column key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
|
842 | + trigger_error(esc_html__('array_column(): The column key should be either a string or an integer.', 'give'), E_USER_WARNING); |
|
843 | 843 | |
844 | 844 | return false; |
845 | 845 | } |
846 | 846 | |
847 | - if ( isset( $params[2] ) |
|
848 | - && ! is_int( $params[2] ) |
|
849 | - && ! is_float( $params[2] ) |
|
850 | - && ! is_string( $params[2] ) |
|
851 | - && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) |
|
847 | + if (isset($params[2]) |
|
848 | + && ! is_int($params[2]) |
|
849 | + && ! is_float($params[2]) |
|
850 | + && ! is_string($params[2]) |
|
851 | + && ! (is_object($params[2]) && method_exists($params[2], '__toString')) |
|
852 | 852 | ) { |
853 | - trigger_error( esc_html__( 'array_column(): The index key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
|
853 | + trigger_error(esc_html__('array_column(): The index key should be either a string or an integer.', 'give'), E_USER_WARNING); |
|
854 | 854 | |
855 | 855 | return false; |
856 | 856 | } |
857 | 857 | |
858 | 858 | $paramsInput = $params[0]; |
859 | - $paramsColumnKey = ( $params[1] !== null ) ? (string) $params[1] : null; |
|
859 | + $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null; |
|
860 | 860 | |
861 | 861 | $paramsIndexKey = null; |
862 | - if ( isset( $params[2] ) ) { |
|
863 | - if ( is_float( $params[2] ) || is_int( $params[2] ) ) { |
|
862 | + if (isset($params[2])) { |
|
863 | + if (is_float($params[2]) || is_int($params[2])) { |
|
864 | 864 | $paramsIndexKey = (int) $params[2]; |
865 | 865 | } else { |
866 | 866 | $paramsIndexKey = (string) $params[2]; |
@@ -869,26 +869,26 @@ discard block |
||
869 | 869 | |
870 | 870 | $resultArray = array(); |
871 | 871 | |
872 | - foreach ( $paramsInput as $row ) { |
|
872 | + foreach ($paramsInput as $row) { |
|
873 | 873 | $key = $value = null; |
874 | 874 | $keySet = $valueSet = false; |
875 | 875 | |
876 | - if ( $paramsIndexKey !== null && array_key_exists( $paramsIndexKey, $row ) ) { |
|
876 | + if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { |
|
877 | 877 | $keySet = true; |
878 | - $key = (string) $row[ $paramsIndexKey ]; |
|
878 | + $key = (string) $row[$paramsIndexKey]; |
|
879 | 879 | } |
880 | 880 | |
881 | - if ( $paramsColumnKey === null ) { |
|
881 | + if ($paramsColumnKey === null) { |
|
882 | 882 | $valueSet = true; |
883 | 883 | $value = $row; |
884 | - } elseif ( is_array( $row ) && array_key_exists( $paramsColumnKey, $row ) ) { |
|
884 | + } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) { |
|
885 | 885 | $valueSet = true; |
886 | - $value = $row[ $paramsColumnKey ]; |
|
886 | + $value = $row[$paramsColumnKey]; |
|
887 | 887 | } |
888 | 888 | |
889 | - if ( $valueSet ) { |
|
890 | - if ( $keySet ) { |
|
891 | - $resultArray[ $key ] = $value; |
|
889 | + if ($valueSet) { |
|
890 | + if ($keySet) { |
|
891 | + $resultArray[$key] = $value; |
|
892 | 892 | } else { |
893 | 893 | $resultArray[] = $value; |
894 | 894 | } |
@@ -910,40 +910,40 @@ discard block |
||
910 | 910 | * |
911 | 911 | * @return bool Whether the receipt is visible or not. |
912 | 912 | */ |
913 | -function give_can_view_receipt( $payment_key = '' ) { |
|
913 | +function give_can_view_receipt($payment_key = '') { |
|
914 | 914 | |
915 | 915 | $return = false; |
916 | 916 | |
917 | - if ( empty( $payment_key ) ) { |
|
917 | + if (empty($payment_key)) { |
|
918 | 918 | return $return; |
919 | 919 | } |
920 | 920 | |
921 | 921 | global $give_receipt_args; |
922 | 922 | |
923 | - $give_receipt_args['id'] = give_get_purchase_id_by_key( $payment_key ); |
|
923 | + $give_receipt_args['id'] = give_get_purchase_id_by_key($payment_key); |
|
924 | 924 | |
925 | - $user_id = (int) give_get_payment_user_id( $give_receipt_args['id'] ); |
|
925 | + $user_id = (int) give_get_payment_user_id($give_receipt_args['id']); |
|
926 | 926 | |
927 | - $payment_meta = give_get_payment_meta( $give_receipt_args['id'] ); |
|
927 | + $payment_meta = give_get_payment_meta($give_receipt_args['id']); |
|
928 | 928 | |
929 | - if ( is_user_logged_in() ) { |
|
930 | - if ( $user_id === (int) get_current_user_id() ) { |
|
929 | + if (is_user_logged_in()) { |
|
930 | + if ($user_id === (int) get_current_user_id()) { |
|
931 | 931 | $return = true; |
932 | - } elseif ( wp_get_current_user()->user_email === give_get_payment_user_email( $give_receipt_args['id'] ) ) { |
|
932 | + } elseif (wp_get_current_user()->user_email === give_get_payment_user_email($give_receipt_args['id'])) { |
|
933 | 933 | $return = true; |
934 | - } elseif ( current_user_can( 'view_give_sensitive_data' ) ) { |
|
934 | + } elseif (current_user_can('view_give_sensitive_data')) { |
|
935 | 935 | $return = true; |
936 | 936 | } |
937 | 937 | } |
938 | 938 | |
939 | 939 | $session = give_get_purchase_session(); |
940 | - if ( ! empty( $session ) && ! is_user_logged_in() ) { |
|
941 | - if ( $session['purchase_key'] === $payment_meta['key'] ) { |
|
940 | + if ( ! empty($session) && ! is_user_logged_in()) { |
|
941 | + if ($session['purchase_key'] === $payment_meta['key']) { |
|
942 | 942 | $return = true; |
943 | 943 | } |
944 | 944 | } |
945 | 945 | |
946 | - return (bool) apply_filters( 'give_can_view_receipt', $return, $payment_key ); |
|
946 | + return (bool) apply_filters('give_can_view_receipt', $return, $payment_key); |
|
947 | 947 | |
948 | 948 | } |
949 | 949 | |
@@ -952,7 +952,7 @@ discard block |
||
952 | 952 | * |
953 | 953 | * Fallback in case the calendar extension is not loaded in PHP; Only supports Gregorian calendar |
954 | 954 | */ |
955 | -if ( ! function_exists( 'cal_days_in_month' ) ) { |
|
955 | +if ( ! function_exists('cal_days_in_month')) { |
|
956 | 956 | /** |
957 | 957 | * cal_days_in_month |
958 | 958 | * |
@@ -962,8 +962,8 @@ discard block |
||
962 | 962 | * |
963 | 963 | * @return bool|string |
964 | 964 | */ |
965 | - function cal_days_in_month( $calendar, $month, $year ) { |
|
966 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
965 | + function cal_days_in_month($calendar, $month, $year) { |
|
966 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
967 | 967 | } |
968 | 968 | } |
969 | 969 | |
@@ -982,42 +982,42 @@ discard block |
||
982 | 982 | */ |
983 | 983 | function give_get_plugins() { |
984 | 984 | $plugins = get_plugins(); |
985 | - $active_plugin_paths = (array) get_option( 'active_plugins', array() ); |
|
985 | + $active_plugin_paths = (array) get_option('active_plugins', array()); |
|
986 | 986 | |
987 | - if ( is_multisite() ) { |
|
988 | - $network_activated_plugin_paths = array_keys( get_site_option( 'active_sitewide_plugins', array() ) ); |
|
989 | - $active_plugin_paths = array_merge( $active_plugin_paths, $network_activated_plugin_paths ); |
|
987 | + if (is_multisite()) { |
|
988 | + $network_activated_plugin_paths = array_keys(get_site_option('active_sitewide_plugins', array())); |
|
989 | + $active_plugin_paths = array_merge($active_plugin_paths, $network_activated_plugin_paths); |
|
990 | 990 | } |
991 | 991 | |
992 | - foreach ( $plugins as $plugin_path => $plugin_data ) { |
|
992 | + foreach ($plugins as $plugin_path => $plugin_data) { |
|
993 | 993 | // Is plugin active? |
994 | - if ( in_array( $plugin_path, $active_plugin_paths ) ) { |
|
995 | - $plugins[ $plugin_path ]['Status'] = 'active'; |
|
994 | + if (in_array($plugin_path, $active_plugin_paths)) { |
|
995 | + $plugins[$plugin_path]['Status'] = 'active'; |
|
996 | 996 | } else { |
997 | - $plugins[ $plugin_path ]['Status'] = 'inactive'; |
|
997 | + $plugins[$plugin_path]['Status'] = 'inactive'; |
|
998 | 998 | } |
999 | 999 | |
1000 | - $dirname = strtolower( dirname( $plugin_path ) ); |
|
1000 | + $dirname = strtolower(dirname($plugin_path)); |
|
1001 | 1001 | |
1002 | 1002 | // Is plugin a Give add-on by WordImpress? |
1003 | - if ( strstr( $dirname, 'give-' ) && strstr( $plugin_data['AuthorURI'], 'wordimpress.com' ) ) { |
|
1003 | + if (strstr($dirname, 'give-') && strstr($plugin_data['AuthorURI'], 'wordimpress.com')) { |
|
1004 | 1004 | // Plugin is a Give-addon. |
1005 | - $plugins[ $plugin_path ]['Type'] = 'add-on'; |
|
1005 | + $plugins[$plugin_path]['Type'] = 'add-on'; |
|
1006 | 1006 | |
1007 | 1007 | // Get license info from database. |
1008 | - $plugin_name = str_replace( 'Give - ', '', $plugin_data['Name'] ); |
|
1009 | - $db_option = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $plugin_name ) ) ) . '_license_active'; |
|
1010 | - $license_active = get_option( $db_option ); |
|
1008 | + $plugin_name = str_replace('Give - ', '', $plugin_data['Name']); |
|
1009 | + $db_option = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($plugin_name))).'_license_active'; |
|
1010 | + $license_active = get_option($db_option); |
|
1011 | 1011 | |
1012 | 1012 | // Does a valid license exist? |
1013 | - if ( ! empty( $license_active ) && 'valid' === $license_active->license ) { |
|
1014 | - $plugins[ $plugin_path ]['License'] = true; |
|
1013 | + if ( ! empty($license_active) && 'valid' === $license_active->license) { |
|
1014 | + $plugins[$plugin_path]['License'] = true; |
|
1015 | 1015 | } else { |
1016 | - $plugins[ $plugin_path ]['License'] = false; |
|
1016 | + $plugins[$plugin_path]['License'] = false; |
|
1017 | 1017 | } |
1018 | 1018 | } else { |
1019 | 1019 | // Plugin is not a Give add-on. |
1020 | - $plugins[ $plugin_path ]['Type'] = 'other'; |
|
1020 | + $plugins[$plugin_path]['Type'] = 'other'; |
|
1021 | 1021 | } |
1022 | 1022 | } |
1023 | 1023 | |
@@ -1034,16 +1034,16 @@ discard block |
||
1034 | 1034 | * |
1035 | 1035 | * @return bool |
1036 | 1036 | */ |
1037 | -function give_is_terms_enabled( $form_id ) { |
|
1038 | - $form_option = get_post_meta( $form_id, '_give_terms_option', true ); |
|
1037 | +function give_is_terms_enabled($form_id) { |
|
1038 | + $form_option = get_post_meta($form_id, '_give_terms_option', true); |
|
1039 | 1039 | |
1040 | 1040 | if ( |
1041 | - give_is_setting_enabled( $form_option, 'global' ) |
|
1042 | - && give_is_setting_enabled( give_get_option( 'terms' ) ) |
|
1041 | + give_is_setting_enabled($form_option, 'global') |
|
1042 | + && give_is_setting_enabled(give_get_option('terms')) |
|
1043 | 1043 | ) { |
1044 | 1044 | return true; |
1045 | 1045 | |
1046 | - } elseif ( give_is_setting_enabled( $form_option ) ) { |
|
1046 | + } elseif (give_is_setting_enabled($form_option)) { |
|
1047 | 1047 | return true; |
1048 | 1048 | |
1049 | 1049 | } else { |
@@ -1066,9 +1066,9 @@ discard block |
||
1066 | 1066 | * |
1067 | 1067 | * @return WP_Error|bool |
1068 | 1068 | */ |
1069 | -function give_delete_donation_stats( $date_range = '', $args = array() ) { |
|
1069 | +function give_delete_donation_stats($date_range = '', $args = array()) { |
|
1070 | 1070 | // Delete all cache. |
1071 | - $status = Give_Cache::delete( Give_Cache::get_options_like( 'give_stats' ) ); |
|
1071 | + $status = Give_Cache::delete(Give_Cache::get_options_like('give_stats')); |
|
1072 | 1072 | |
1073 | 1073 | /** |
1074 | 1074 | * Fire the action when donation stats delete. |
@@ -1078,7 +1078,7 @@ discard block |
||
1078 | 1078 | * @param string|array $date_range |
1079 | 1079 | * @param array $args |
1080 | 1080 | */ |
1081 | - do_action( 'give_delete_donation_stats', $status, $date_range, $args ); |
|
1081 | + do_action('give_delete_donation_stats', $status, $date_range, $args); |
|
1082 | 1082 | |
1083 | 1083 | return $status; |
1084 | 1084 | } |
1085 | 1085 | \ No newline at end of file |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | * |
327 | 327 | * @since 1.0 |
328 | 328 | * |
329 | - * @param int|bool $form_id Form ID (default: false). |
|
329 | + * @param boolean $form_id Form ID (default: false). |
|
330 | 330 | * @param int $payment_id Payment ID. |
331 | 331 | * |
332 | 332 | * @return void |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | * @param int $year Year number. Default is null. |
645 | 645 | * @param int $hour Hour number. Default is null. |
646 | 646 | * |
647 | - * @return int $earnings Earnings |
|
647 | + * @return double $earnings Earnings |
|
648 | 648 | */ |
649 | 649 | function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
650 | 650 | |
@@ -959,7 +959,7 @@ discard block |
||
959 | 959 | * |
960 | 960 | * @param int $payment_id Payment ID. |
961 | 961 | * |
962 | - * @return int $form_id Form ID. |
|
962 | + * @return string $form_id Form ID. |
|
963 | 963 | */ |
964 | 964 | function give_get_payment_form_id( $payment_id ) { |
965 | 965 | $payment = new Give_Payment( $payment_id ); |
@@ -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 | |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return array $payments Payments retrieved from the database |
45 | 45 | */ |
46 | -function give_get_payments( $args = array() ) { |
|
46 | +function give_get_payments($args = array()) { |
|
47 | 47 | |
48 | 48 | // Fallback to post objects to ensure backwards compatibility. |
49 | - if ( ! isset( $args['output'] ) ) { |
|
49 | + if ( ! isset($args['output'])) { |
|
50 | 50 | $args['output'] = 'posts'; |
51 | 51 | } |
52 | 52 | |
53 | - $args = apply_filters( 'give_get_payments_args', $args ); |
|
54 | - $payments = new Give_Payments_Query( $args ); |
|
53 | + $args = apply_filters('give_get_payments_args', $args); |
|
54 | + $payments = new Give_Payments_Query($args); |
|
55 | 55 | |
56 | 56 | return $payments->get_payments(); |
57 | 57 | } |
@@ -66,48 +66,48 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return mixed |
68 | 68 | */ |
69 | -function give_get_payment_by( $field = '', $value = '' ) { |
|
69 | +function give_get_payment_by($field = '', $value = '') { |
|
70 | 70 | |
71 | - if ( empty( $field ) || empty( $value ) ) { |
|
71 | + if (empty($field) || empty($value)) { |
|
72 | 72 | return false; |
73 | 73 | } |
74 | 74 | |
75 | - switch ( strtolower( $field ) ) { |
|
75 | + switch (strtolower($field)) { |
|
76 | 76 | |
77 | 77 | case 'id': |
78 | - $payment = new Give_Payment( $value ); |
|
78 | + $payment = new Give_Payment($value); |
|
79 | 79 | $id = $payment->ID; |
80 | 80 | |
81 | - if ( empty( $id ) ) { |
|
81 | + if (empty($id)) { |
|
82 | 82 | return false; |
83 | 83 | } |
84 | 84 | |
85 | 85 | break; |
86 | 86 | |
87 | 87 | case 'key': |
88 | - $payment = give_get_payments( array( |
|
88 | + $payment = give_get_payments(array( |
|
89 | 89 | 'meta_key' => '_give_payment_purchase_key', |
90 | 90 | 'meta_value' => $value, |
91 | 91 | 'posts_per_page' => 1, |
92 | 92 | 'fields' => 'ids', |
93 | - ) ); |
|
93 | + )); |
|
94 | 94 | |
95 | - if ( $payment ) { |
|
96 | - $payment = new Give_Payment( $payment[0] ); |
|
95 | + if ($payment) { |
|
96 | + $payment = new Give_Payment($payment[0]); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | break; |
100 | 100 | |
101 | 101 | case 'payment_number': |
102 | - $payment = give_get_payments( array( |
|
102 | + $payment = give_get_payments(array( |
|
103 | 103 | 'meta_key' => '_give_payment_number', |
104 | 104 | 'meta_value' => $value, |
105 | 105 | 'posts_per_page' => 1, |
106 | 106 | 'fields' => 'ids', |
107 | - ) ); |
|
107 | + )); |
|
108 | 108 | |
109 | - if ( $payment ) { |
|
110 | - $payment = new Give_Payment( $payment[0] ); |
|
109 | + if ($payment) { |
|
110 | + $payment = new Give_Payment($payment[0]); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | break; |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | return false; |
117 | 117 | } |
118 | 118 | |
119 | - if ( $payment ) { |
|
119 | + if ($payment) { |
|
120 | 120 | return $payment; |
121 | 121 | } |
122 | 122 | |
@@ -132,23 +132,23 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @return int|bool Payment ID if payment is inserted, false otherwise. |
134 | 134 | */ |
135 | -function give_insert_payment( $payment_data = array() ) { |
|
135 | +function give_insert_payment($payment_data = array()) { |
|
136 | 136 | |
137 | - if ( empty( $payment_data ) ) { |
|
137 | + if (empty($payment_data)) { |
|
138 | 138 | return false; |
139 | 139 | } |
140 | 140 | |
141 | 141 | $payment = new Give_Payment(); |
142 | - $gateway = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : ''; |
|
143 | - $gateway = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway; |
|
144 | - $form_id = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0; |
|
145 | - $price_id = give_get_payment_meta_price_id( $payment_data ); |
|
146 | - $form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id ); |
|
142 | + $gateway = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : ''; |
|
143 | + $gateway = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway; |
|
144 | + $form_id = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0; |
|
145 | + $price_id = give_get_payment_meta_price_id($payment_data); |
|
146 | + $form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id); |
|
147 | 147 | |
148 | 148 | // Set properties. |
149 | 149 | $payment->total = $payment_data['price']; |
150 | - $payment->status = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending'; |
|
151 | - $payment->currency = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency(); |
|
150 | + $payment->status = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending'; |
|
151 | + $payment->currency = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency(); |
|
152 | 152 | $payment->user_info = $payment_data['user_info']; |
153 | 153 | $payment->gateway = $gateway; |
154 | 154 | $payment->form_title = $form_title; |
@@ -162,31 +162,31 @@ discard block |
||
162 | 162 | $payment->ip = give_get_ip(); |
163 | 163 | $payment->key = $payment_data['purchase_key']; |
164 | 164 | $payment->mode = give_is_test_mode() ? 'test' : 'live'; |
165 | - $payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : ''; |
|
165 | + $payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : ''; |
|
166 | 166 | |
167 | 167 | // Add the donation. |
168 | 168 | $args = array( |
169 | 169 | 'price' => $payment->total, |
170 | 170 | 'price_id' => $payment->price_id, |
171 | - 'fees' => isset( $payment_data['fees'] ) ? $payment_data['fees'] : array(), |
|
171 | + 'fees' => isset($payment_data['fees']) ? $payment_data['fees'] : array(), |
|
172 | 172 | ); |
173 | 173 | |
174 | - $payment->add_donation( $payment->form_id, $args ); |
|
174 | + $payment->add_donation($payment->form_id, $args); |
|
175 | 175 | |
176 | 176 | // Set date if present. |
177 | - if ( isset( $payment_data['post_date'] ) ) { |
|
177 | + if (isset($payment_data['post_date'])) { |
|
178 | 178 | $payment->date = $payment_data['post_date']; |
179 | 179 | } |
180 | 180 | |
181 | 181 | // Handle sequential payments. |
182 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
182 | + if (give_get_option('enable_sequential')) { |
|
183 | 183 | $number = give_get_next_payment_number(); |
184 | - $payment->number = give_format_payment_number( $number ); |
|
185 | - update_option( 'give_last_payment_number', $number ); |
|
184 | + $payment->number = give_format_payment_number($number); |
|
185 | + update_option('give_last_payment_number', $number); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | // Clear the user's donation cache. |
189 | - delete_transient( 'give_user_' . $payment_data['user_info']['id'] . '_purchases' ); |
|
189 | + delete_transient('give_user_'.$payment_data['user_info']['id'].'_purchases'); |
|
190 | 190 | |
191 | 191 | // Save payment. |
192 | 192 | $payment->save(); |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | * @param int $payment_id The payment ID. |
200 | 200 | * @param array $payment_data Arguments passed. |
201 | 201 | */ |
202 | - do_action( 'give_insert_payment', $payment->ID, $payment_data ); |
|
202 | + do_action('give_insert_payment', $payment->ID, $payment_data); |
|
203 | 203 | |
204 | 204 | // Return payment ID upon success. |
205 | - if ( ! empty( $payment->ID ) ) { |
|
205 | + if ( ! empty($payment->ID)) { |
|
206 | 206 | return $payment->ID; |
207 | 207 | } |
208 | 208 | |
@@ -218,10 +218,10 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @return bool|int |
220 | 220 | */ |
221 | -function give_create_payment( $payment_data ) { |
|
221 | +function give_create_payment($payment_data) { |
|
222 | 222 | |
223 | - $form_id = intval( $payment_data['post_data']['give-form-id'] ); |
|
224 | - $price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : ''; |
|
223 | + $form_id = intval($payment_data['post_data']['give-form-id']); |
|
224 | + $price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : ''; |
|
225 | 225 | |
226 | 226 | // Collect payment data. |
227 | 227 | $insert_payment_data = array( |
@@ -245,10 +245,10 @@ discard block |
||
245 | 245 | * |
246 | 246 | * @param array $insert_payment_data |
247 | 247 | */ |
248 | - $insert_payment_data = apply_filters( 'give_create_payment', $insert_payment_data ); |
|
248 | + $insert_payment_data = apply_filters('give_create_payment', $insert_payment_data); |
|
249 | 249 | |
250 | 250 | // Record the pending payment. |
251 | - return give_insert_payment( $insert_payment_data ); |
|
251 | + return give_insert_payment($insert_payment_data); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @return bool |
263 | 263 | */ |
264 | -function give_update_payment_status( $payment_id, $new_status = 'publish' ) { |
|
264 | +function give_update_payment_status($payment_id, $new_status = 'publish') { |
|
265 | 265 | |
266 | - $payment = new Give_Payment( $payment_id ); |
|
266 | + $payment = new Give_Payment($payment_id); |
|
267 | 267 | $payment->status = $new_status; |
268 | 268 | $updated = $payment->save(); |
269 | 269 | |
@@ -282,38 +282,38 @@ discard block |
||
282 | 282 | * |
283 | 283 | * @return void |
284 | 284 | */ |
285 | -function give_delete_purchase( $payment_id = 0, $update_customer = true ) { |
|
285 | +function give_delete_purchase($payment_id = 0, $update_customer = true) { |
|
286 | 286 | global $give_logs; |
287 | 287 | |
288 | - $payment = new Give_Payment( $payment_id ); |
|
289 | - $amount = give_get_payment_amount( $payment_id ); |
|
288 | + $payment = new Give_Payment($payment_id); |
|
289 | + $amount = give_get_payment_amount($payment_id); |
|
290 | 290 | $status = $payment->post_status; |
291 | - $customer_id = give_get_payment_customer_id( $payment_id ); |
|
292 | - $customer = new Give_Customer( $customer_id ); |
|
291 | + $customer_id = give_get_payment_customer_id($payment_id); |
|
292 | + $customer = new Give_Customer($customer_id); |
|
293 | 293 | |
294 | 294 | // Only undo donations that aren't these statuses. |
295 | - $dont_undo_statuses = apply_filters( 'give_undo_purchase_statuses', array( |
|
295 | + $dont_undo_statuses = apply_filters('give_undo_purchase_statuses', array( |
|
296 | 296 | 'pending', |
297 | 297 | 'cancelled', |
298 | - ) ); |
|
298 | + )); |
|
299 | 299 | |
300 | - if ( ! in_array( $status, $dont_undo_statuses ) ) { |
|
301 | - give_undo_purchase( false, $payment_id ); |
|
300 | + if ( ! in_array($status, $dont_undo_statuses)) { |
|
301 | + give_undo_purchase(false, $payment_id); |
|
302 | 302 | } |
303 | 303 | |
304 | - if ( $status == 'publish' ) { |
|
304 | + if ($status == 'publish') { |
|
305 | 305 | |
306 | 306 | // Only decrease earnings if they haven't already been decreased (or were never increased for this payment). |
307 | - give_decrease_total_earnings( $amount ); |
|
307 | + give_decrease_total_earnings($amount); |
|
308 | 308 | |
309 | 309 | // @todo: Refresh only range related stat cache |
310 | 310 | give_delete_donation_stats(); |
311 | 311 | |
312 | - if ( $customer->id && $update_customer ) { |
|
312 | + if ($customer->id && $update_customer) { |
|
313 | 313 | |
314 | 314 | // Decrement the stats for the donor. |
315 | 315 | $customer->decrease_purchase_count(); |
316 | - $customer->decrease_value( $amount ); |
|
316 | + $customer->decrease_value($amount); |
|
317 | 317 | |
318 | 318 | } |
319 | 319 | } |
@@ -325,17 +325,17 @@ discard block |
||
325 | 325 | * |
326 | 326 | * @param int $payment_id Payment ID. |
327 | 327 | */ |
328 | - do_action( 'give_payment_delete', $payment_id ); |
|
328 | + do_action('give_payment_delete', $payment_id); |
|
329 | 329 | |
330 | - if ( $customer->id && $update_customer ) { |
|
330 | + if ($customer->id && $update_customer) { |
|
331 | 331 | |
332 | 332 | // Remove the payment ID from the donor. |
333 | - $customer->remove_payment( $payment_id ); |
|
333 | + $customer->remove_payment($payment_id); |
|
334 | 334 | |
335 | 335 | } |
336 | 336 | |
337 | 337 | // Remove the payment. |
338 | - wp_delete_post( $payment_id, true ); |
|
338 | + wp_delete_post($payment_id, true); |
|
339 | 339 | |
340 | 340 | // Remove related sale log entries. |
341 | 341 | $give_logs->delete_logs( |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * |
357 | 357 | * @param int $payment_id Payment ID. |
358 | 358 | */ |
359 | - do_action( 'give_payment_deleted', $payment_id ); |
|
359 | + do_action('give_payment_deleted', $payment_id); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | /** |
@@ -372,25 +372,25 @@ discard block |
||
372 | 372 | * |
373 | 373 | * @return void |
374 | 374 | */ |
375 | -function give_undo_purchase( $form_id = false, $payment_id ) { |
|
375 | +function give_undo_purchase($form_id = false, $payment_id) { |
|
376 | 376 | |
377 | - if ( ! empty( $form_id ) ) { |
|
377 | + if ( ! empty($form_id)) { |
|
378 | 378 | $form_id = false; |
379 | - _give_deprected_argument( 'form_id', 'give_undo_purchase', '1.5' ); |
|
379 | + _give_deprected_argument('form_id', 'give_undo_purchase', '1.5'); |
|
380 | 380 | } |
381 | 381 | |
382 | - $payment = new Give_Payment( $payment_id ); |
|
382 | + $payment = new Give_Payment($payment_id); |
|
383 | 383 | |
384 | - $maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id ); |
|
385 | - if ( true === $maybe_decrease_earnings ) { |
|
384 | + $maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id); |
|
385 | + if (true === $maybe_decrease_earnings) { |
|
386 | 386 | // Decrease earnings. |
387 | - give_decrease_earnings( $payment->form_id, $payment->total ); |
|
387 | + give_decrease_earnings($payment->form_id, $payment->total); |
|
388 | 388 | } |
389 | 389 | |
390 | - $maybe_decrease_sales = apply_filters( 'give_decrease_sales_on_undo', true, $payment, $payment->form_id ); |
|
391 | - if ( true === $maybe_decrease_sales ) { |
|
390 | + $maybe_decrease_sales = apply_filters('give_decrease_sales_on_undo', true, $payment, $payment->form_id); |
|
391 | + if (true === $maybe_decrease_sales) { |
|
392 | 392 | // Decrease donation count. |
393 | - give_decrease_purchase_count( $payment->form_id ); |
|
393 | + give_decrease_purchase_count($payment->form_id); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | } |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | * |
408 | 408 | * @return object $stats Contains the number of payments per payment status. |
409 | 409 | */ |
410 | -function give_count_payments( $args = array() ) { |
|
410 | +function give_count_payments($args = array()) { |
|
411 | 411 | |
412 | 412 | global $wpdb; |
413 | 413 | |
@@ -419,18 +419,18 @@ discard block |
||
419 | 419 | 'form_id' => null, |
420 | 420 | ); |
421 | 421 | |
422 | - $args = wp_parse_args( $args, $defaults ); |
|
422 | + $args = wp_parse_args($args, $defaults); |
|
423 | 423 | |
424 | 424 | $select = 'SELECT p.post_status,count( * ) AS num_posts'; |
425 | 425 | $join = ''; |
426 | 426 | $where = "WHERE p.post_type = 'give_payment'"; |
427 | 427 | |
428 | 428 | // Count payments for a specific user. |
429 | - if ( ! empty( $args['user'] ) ) { |
|
429 | + if ( ! empty($args['user'])) { |
|
430 | 430 | |
431 | - if ( is_email( $args['user'] ) ) { |
|
431 | + if (is_email($args['user'])) { |
|
432 | 432 | $field = 'email'; |
433 | - } elseif ( is_numeric( $args['user'] ) ) { |
|
433 | + } elseif (is_numeric($args['user'])) { |
|
434 | 434 | $field = 'id'; |
435 | 435 | } else { |
436 | 436 | $field = ''; |
@@ -438,105 +438,105 @@ discard block |
||
438 | 438 | |
439 | 439 | $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
440 | 440 | |
441 | - if ( ! empty( $field ) ) { |
|
441 | + if ( ! empty($field)) { |
|
442 | 442 | $where .= " |
443 | 443 | AND m.meta_key = '_give_payment_user_{$field}' |
444 | 444 | AND m.meta_value = '{$args['user']}'"; |
445 | 445 | } |
446 | 446 | |
447 | 447 | // Count payments for a search. |
448 | - } elseif ( ! empty( $args['s'] ) ) { |
|
448 | + } elseif ( ! empty($args['s'])) { |
|
449 | 449 | |
450 | - if ( is_email( $args['s'] ) || strlen( $args['s'] ) == 32 ) { |
|
450 | + if (is_email($args['s']) || strlen($args['s']) == 32) { |
|
451 | 451 | |
452 | - if ( is_email( $args['s'] ) ) { |
|
452 | + if (is_email($args['s'])) { |
|
453 | 453 | $field = '_give_payment_user_email'; |
454 | 454 | } else { |
455 | 455 | $field = '_give_payment_purchase_key'; |
456 | 456 | } |
457 | 457 | |
458 | - $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
459 | - $where .= $wpdb->prepare( ' |
|
458 | + $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
459 | + $where .= $wpdb->prepare(' |
|
460 | 460 | AND m.meta_key = %s |
461 | 461 | AND m.meta_value = %s', |
462 | 462 | $field, |
463 | 463 | $args['s'] |
464 | 464 | ); |
465 | 465 | |
466 | - } elseif ( '#' == substr( $args['s'], 0, 1 ) ) { |
|
466 | + } elseif ('#' == substr($args['s'], 0, 1)) { |
|
467 | 467 | |
468 | - $search = str_replace( '#:', '', $args['s'] ); |
|
469 | - $search = str_replace( '#', '', $search ); |
|
468 | + $search = str_replace('#:', '', $args['s']); |
|
469 | + $search = str_replace('#', '', $search); |
|
470 | 470 | |
471 | 471 | $select = 'SELECT p2.post_status,count( * ) AS num_posts '; |
472 | 472 | $join = "LEFT JOIN $wpdb->postmeta m ON m.meta_key = '_give_log_payment_id' AND m.post_id = p.ID "; |
473 | 473 | $join .= "INNER JOIN $wpdb->posts p2 ON m.meta_value = p2.ID "; |
474 | 474 | $where = "WHERE p.post_type = 'give_log' "; |
475 | - $where .= $wpdb->prepare( 'AND p.post_parent = %d} ', $search ); |
|
475 | + $where .= $wpdb->prepare('AND p.post_parent = %d} ', $search); |
|
476 | 476 | |
477 | - } elseif ( is_numeric( $args['s'] ) ) { |
|
477 | + } elseif (is_numeric($args['s'])) { |
|
478 | 478 | |
479 | - $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
480 | - $where .= $wpdb->prepare( " |
|
479 | + $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
480 | + $where .= $wpdb->prepare(" |
|
481 | 481 | AND m.meta_key = '_give_payment_user_id' |
482 | 482 | AND m.meta_value = %d", |
483 | 483 | $args['s'] |
484 | 484 | ); |
485 | 485 | |
486 | 486 | } else { |
487 | - $search = $wpdb->esc_like( $args['s'] ); |
|
488 | - $search = '%' . $search . '%'; |
|
487 | + $search = $wpdb->esc_like($args['s']); |
|
488 | + $search = '%'.$search.'%'; |
|
489 | 489 | |
490 | - $where .= $wpdb->prepare( 'AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search ); |
|
490 | + $where .= $wpdb->prepare('AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search); |
|
491 | 491 | } |
492 | 492 | } |
493 | 493 | |
494 | - if ( ! empty( $args['form_id'] ) && is_numeric( $args['form_id'] ) ) { |
|
494 | + if ( ! empty($args['form_id']) && is_numeric($args['form_id'])) { |
|
495 | 495 | |
496 | - $where .= $wpdb->prepare( ' AND p.post_parent = %d', $args['form_id'] ); |
|
496 | + $where .= $wpdb->prepare(' AND p.post_parent = %d', $args['form_id']); |
|
497 | 497 | |
498 | 498 | } |
499 | 499 | // Limit payments count by date. |
500 | - if ( ! empty( $args['start-date'] ) && false !== strpos( $args['start-date'], '/' ) ) { |
|
500 | + if ( ! empty($args['start-date']) && false !== strpos($args['start-date'], '/')) { |
|
501 | 501 | |
502 | - $date_parts = explode( '/', $args['start-date'] ); |
|
503 | - $month = ! empty( $date_parts[0] ) && is_numeric( $date_parts[0] ) ? $date_parts[0] : 0; |
|
504 | - $day = ! empty( $date_parts[1] ) && is_numeric( $date_parts[1] ) ? $date_parts[1] : 0; |
|
505 | - $year = ! empty( $date_parts[2] ) && is_numeric( $date_parts[2] ) ? $date_parts[2] : 0; |
|
502 | + $date_parts = explode('/', $args['start-date']); |
|
503 | + $month = ! empty($date_parts[0]) && is_numeric($date_parts[0]) ? $date_parts[0] : 0; |
|
504 | + $day = ! empty($date_parts[1]) && is_numeric($date_parts[1]) ? $date_parts[1] : 0; |
|
505 | + $year = ! empty($date_parts[2]) && is_numeric($date_parts[2]) ? $date_parts[2] : 0; |
|
506 | 506 | |
507 | - $is_date = checkdate( $month, $day, $year ); |
|
508 | - if ( false !== $is_date ) { |
|
507 | + $is_date = checkdate($month, $day, $year); |
|
508 | + if (false !== $is_date) { |
|
509 | 509 | |
510 | - $date = new DateTime( $args['start-date'] ); |
|
511 | - $where .= $wpdb->prepare( " AND p.post_date >= '%s'", $date->format( 'Y-m-d' ) ); |
|
510 | + $date = new DateTime($args['start-date']); |
|
511 | + $where .= $wpdb->prepare(" AND p.post_date >= '%s'", $date->format('Y-m-d')); |
|
512 | 512 | |
513 | 513 | } |
514 | 514 | |
515 | 515 | // Fixes an issue with the payments list table counts when no end date is specified (partiy with stats class). |
516 | - if ( empty( $args['end-date'] ) ) { |
|
516 | + if (empty($args['end-date'])) { |
|
517 | 517 | $args['end-date'] = $args['start-date']; |
518 | 518 | } |
519 | 519 | } |
520 | 520 | |
521 | - if ( ! empty( $args['end-date'] ) && false !== strpos( $args['end-date'], '/' ) ) { |
|
521 | + if ( ! empty($args['end-date']) && false !== strpos($args['end-date'], '/')) { |
|
522 | 522 | |
523 | - $date_parts = explode( '/', $args['end-date'] ); |
|
523 | + $date_parts = explode('/', $args['end-date']); |
|
524 | 524 | |
525 | - $month = ! empty( $date_parts[0] ) ? $date_parts[0] : 0; |
|
526 | - $day = ! empty( $date_parts[1] ) ? $date_parts[1] : 0; |
|
527 | - $year = ! empty( $date_parts[2] ) ? $date_parts[2] : 0; |
|
525 | + $month = ! empty($date_parts[0]) ? $date_parts[0] : 0; |
|
526 | + $day = ! empty($date_parts[1]) ? $date_parts[1] : 0; |
|
527 | + $year = ! empty($date_parts[2]) ? $date_parts[2] : 0; |
|
528 | 528 | |
529 | - $is_date = checkdate( $month, $day, $year ); |
|
530 | - if ( false !== $is_date ) { |
|
529 | + $is_date = checkdate($month, $day, $year); |
|
530 | + if (false !== $is_date) { |
|
531 | 531 | |
532 | - $date = new DateTime( $args['end-date'] ); |
|
533 | - $where .= $wpdb->prepare( " AND p.post_date <= '%s'", $date->format( 'Y-m-d' ) ); |
|
532 | + $date = new DateTime($args['end-date']); |
|
533 | + $where .= $wpdb->prepare(" AND p.post_date <= '%s'", $date->format('Y-m-d')); |
|
534 | 534 | |
535 | 535 | } |
536 | 536 | } |
537 | 537 | |
538 | - $where = apply_filters( 'give_count_payments_where', $where ); |
|
539 | - $join = apply_filters( 'give_count_payments_join', $join ); |
|
538 | + $where = apply_filters('give_count_payments_where', $where); |
|
539 | + $join = apply_filters('give_count_payments_join', $join); |
|
540 | 540 | |
541 | 541 | $query = "$select |
542 | 542 | FROM $wpdb->posts p |
@@ -545,36 +545,36 @@ discard block |
||
545 | 545 | GROUP BY p.post_status |
546 | 546 | "; |
547 | 547 | |
548 | - $cache_key = md5( $query ); |
|
548 | + $cache_key = md5($query); |
|
549 | 549 | |
550 | - $count = wp_cache_get( $cache_key, 'counts' ); |
|
551 | - if ( false !== $count ) { |
|
550 | + $count = wp_cache_get($cache_key, 'counts'); |
|
551 | + if (false !== $count) { |
|
552 | 552 | return $count; |
553 | 553 | } |
554 | 554 | |
555 | - $count = $wpdb->get_results( $query, ARRAY_A ); |
|
555 | + $count = $wpdb->get_results($query, ARRAY_A); |
|
556 | 556 | |
557 | 557 | $stats = array(); |
558 | 558 | $statuses = get_post_stati(); |
559 | - if ( isset( $statuses['private'] ) && empty( $args['s'] ) ) { |
|
560 | - unset( $statuses['private'] ); |
|
559 | + if (isset($statuses['private']) && empty($args['s'])) { |
|
560 | + unset($statuses['private']); |
|
561 | 561 | } |
562 | 562 | |
563 | - foreach ( $statuses as $state ) { |
|
564 | - $stats[ $state ] = 0; |
|
563 | + foreach ($statuses as $state) { |
|
564 | + $stats[$state] = 0; |
|
565 | 565 | } |
566 | 566 | |
567 | - foreach ( (array) $count as $row ) { |
|
567 | + foreach ((array) $count as $row) { |
|
568 | 568 | |
569 | - if ( 'private' == $row['post_status'] && empty( $args['s'] ) ) { |
|
569 | + if ('private' == $row['post_status'] && empty($args['s'])) { |
|
570 | 570 | continue; |
571 | 571 | } |
572 | 572 | |
573 | - $stats[ $row['post_status'] ] = $row['num_posts']; |
|
573 | + $stats[$row['post_status']] = $row['num_posts']; |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | $stats = (object) $stats; |
577 | - wp_cache_set( $cache_key, $stats, 'counts' ); |
|
577 | + wp_cache_set($cache_key, $stats, 'counts'); |
|
578 | 578 | |
579 | 579 | return $stats; |
580 | 580 | } |
@@ -589,11 +589,11 @@ discard block |
||
589 | 589 | * |
590 | 590 | * @return bool $exists True if payment exists, false otherwise. |
591 | 591 | */ |
592 | -function give_check_for_existing_payment( $payment_id ) { |
|
592 | +function give_check_for_existing_payment($payment_id) { |
|
593 | 593 | $exists = false; |
594 | - $payment = new Give_Payment( $payment_id ); |
|
594 | + $payment = new Give_Payment($payment_id); |
|
595 | 595 | |
596 | - if ( $payment_id === $payment->ID && 'publish' === $payment->status ) { |
|
596 | + if ($payment_id === $payment->ID && 'publish' === $payment->status) { |
|
597 | 597 | $exists = true; |
598 | 598 | } |
599 | 599 | |
@@ -611,31 +611,31 @@ discard block |
||
611 | 611 | * |
612 | 612 | * @return bool|mixed True if payment status exists, false otherwise. |
613 | 613 | */ |
614 | -function give_get_payment_status( $payment, $return_label = false ) { |
|
614 | +function give_get_payment_status($payment, $return_label = false) { |
|
615 | 615 | |
616 | - if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) { |
|
616 | + if ( ! is_object($payment) || ! isset($payment->post_status)) { |
|
617 | 617 | return false; |
618 | 618 | } |
619 | 619 | |
620 | 620 | $statuses = give_get_payment_statuses(); |
621 | 621 | |
622 | - if ( ! is_array( $statuses ) || empty( $statuses ) ) { |
|
622 | + if ( ! is_array($statuses) || empty($statuses)) { |
|
623 | 623 | return false; |
624 | 624 | } |
625 | 625 | |
626 | 626 | // Get payment object if no already given. |
627 | - $payment = $payment instanceof Give_Payment ? $payment : new Give_Payment( $payment->ID ); |
|
627 | + $payment = $payment instanceof Give_Payment ? $payment : new Give_Payment($payment->ID); |
|
628 | 628 | |
629 | - if ( array_key_exists( $payment->status, $statuses ) ) { |
|
630 | - if ( true === $return_label ) { |
|
629 | + if (array_key_exists($payment->status, $statuses)) { |
|
630 | + if (true === $return_label) { |
|
631 | 631 | // Return translated status label. |
632 | - return $statuses[ $payment->status ]; |
|
632 | + return $statuses[$payment->status]; |
|
633 | 633 | } else { |
634 | 634 | // Account that our 'publish' status is labeled 'Complete' |
635 | 635 | $post_status = 'publish' == $payment->status ? 'Complete' : $payment->post_status; |
636 | 636 | |
637 | 637 | // Make sure we're matching cases, since they matter |
638 | - return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) ); |
|
638 | + return array_search(strtolower($post_status), array_map('strtolower', $statuses)); |
|
639 | 639 | } |
640 | 640 | } |
641 | 641 | |
@@ -651,17 +651,17 @@ discard block |
||
651 | 651 | */ |
652 | 652 | function give_get_payment_statuses() { |
653 | 653 | $payment_statuses = array( |
654 | - 'pending' => __( 'Pending', 'give' ), |
|
655 | - 'publish' => __( 'Complete', 'give' ), |
|
656 | - 'refunded' => __( 'Refunded', 'give' ), |
|
657 | - 'failed' => __( 'Failed', 'give' ), |
|
658 | - 'cancelled' => __( 'Cancelled', 'give' ), |
|
659 | - 'abandoned' => __( 'Abandoned', 'give' ), |
|
660 | - 'preapproval' => __( 'Pre-Approved', 'give' ), |
|
661 | - 'revoked' => __( 'Revoked', 'give' ), |
|
654 | + 'pending' => __('Pending', 'give'), |
|
655 | + 'publish' => __('Complete', 'give'), |
|
656 | + 'refunded' => __('Refunded', 'give'), |
|
657 | + 'failed' => __('Failed', 'give'), |
|
658 | + 'cancelled' => __('Cancelled', 'give'), |
|
659 | + 'abandoned' => __('Abandoned', 'give'), |
|
660 | + 'preapproval' => __('Pre-Approved', 'give'), |
|
661 | + 'revoked' => __('Revoked', 'give'), |
|
662 | 662 | ); |
663 | 663 | |
664 | - return apply_filters( 'give_payment_statuses', $payment_statuses ); |
|
664 | + return apply_filters('give_payment_statuses', $payment_statuses); |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | /** |
@@ -674,10 +674,10 @@ discard block |
||
674 | 674 | * @return array $payment_status All the available payment statuses. |
675 | 675 | */ |
676 | 676 | function give_get_payment_status_keys() { |
677 | - $statuses = array_keys( give_get_payment_statuses() ); |
|
678 | - asort( $statuses ); |
|
677 | + $statuses = array_keys(give_get_payment_statuses()); |
|
678 | + asort($statuses); |
|
679 | 679 | |
680 | - return array_values( $statuses ); |
|
680 | + return array_values($statuses); |
|
681 | 681 | } |
682 | 682 | |
683 | 683 | /** |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | * |
693 | 693 | * @return int $earnings Earnings |
694 | 694 | */ |
695 | -function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
|
695 | +function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) { |
|
696 | 696 | |
697 | 697 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead. |
698 | 698 | global $wpdb; |
@@ -702,41 +702,41 @@ discard block |
||
702 | 702 | 'nopaging' => true, |
703 | 703 | 'year' => $year, |
704 | 704 | 'monthnum' => $month_num, |
705 | - 'post_status' => array( 'publish' ), |
|
705 | + 'post_status' => array('publish'), |
|
706 | 706 | 'fields' => 'ids', |
707 | 707 | 'update_post_term_cache' => false, |
708 | 708 | ); |
709 | - if ( ! empty( $day ) ) { |
|
709 | + if ( ! empty($day)) { |
|
710 | 710 | $args['day'] = $day; |
711 | 711 | } |
712 | 712 | |
713 | - if ( ! empty( $hour ) ) { |
|
713 | + if ( ! empty($hour)) { |
|
714 | 714 | $args['hour'] = $hour; |
715 | 715 | } |
716 | 716 | |
717 | - $args = apply_filters( 'give_get_earnings_by_date_args', $args ); |
|
718 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
717 | + $args = apply_filters('give_get_earnings_by_date_args', $args); |
|
718 | + $key = Give_Cache::get_key('give_stats', $args); |
|
719 | 719 | |
720 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
720 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
721 | 721 | $earnings = false; |
722 | 722 | } else { |
723 | - $earnings = Give_Cache::get( $key ); |
|
723 | + $earnings = Give_Cache::get($key); |
|
724 | 724 | } |
725 | 725 | |
726 | - if ( false === $earnings ) { |
|
727 | - $sales = get_posts( $args ); |
|
726 | + if (false === $earnings) { |
|
727 | + $sales = get_posts($args); |
|
728 | 728 | $earnings = 0; |
729 | - if ( $sales ) { |
|
730 | - $sales = implode( ',', $sales ); |
|
729 | + if ($sales) { |
|
730 | + $sales = implode(',', $sales); |
|
731 | 731 | |
732 | - $earnings = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})" ); |
|
732 | + $earnings = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})"); |
|
733 | 733 | |
734 | 734 | } |
735 | 735 | // Cache the results for one hour. |
736 | - Give_Cache::set( $key, $earnings, HOUR_IN_SECONDS ); |
|
736 | + Give_Cache::set($key, $earnings, HOUR_IN_SECONDS); |
|
737 | 737 | } |
738 | 738 | |
739 | - return round( $earnings, 2 ); |
|
739 | + return round($earnings, 2); |
|
740 | 740 | } |
741 | 741 | |
742 | 742 | /** |
@@ -751,7 +751,7 @@ discard block |
||
751 | 751 | * |
752 | 752 | * @return int $count Sales |
753 | 753 | */ |
754 | -function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) { |
|
754 | +function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) { |
|
755 | 755 | |
756 | 756 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead. |
757 | 757 | $args = array( |
@@ -759,14 +759,14 @@ discard block |
||
759 | 759 | 'nopaging' => true, |
760 | 760 | 'year' => $year, |
761 | 761 | 'fields' => 'ids', |
762 | - 'post_status' => array( 'publish' ), |
|
762 | + 'post_status' => array('publish'), |
|
763 | 763 | 'update_post_meta_cache' => false, |
764 | 764 | 'update_post_term_cache' => false, |
765 | 765 | ); |
766 | 766 | |
767 | - $show_free = apply_filters( 'give_sales_by_date_show_free', true, $args ); |
|
767 | + $show_free = apply_filters('give_sales_by_date_show_free', true, $args); |
|
768 | 768 | |
769 | - if ( false === $show_free ) { |
|
769 | + if (false === $show_free) { |
|
770 | 770 | $args['meta_query'] = array( |
771 | 771 | array( |
772 | 772 | 'key' => '_give_payment_total', |
@@ -777,33 +777,33 @@ discard block |
||
777 | 777 | ); |
778 | 778 | } |
779 | 779 | |
780 | - if ( ! empty( $month_num ) ) { |
|
780 | + if ( ! empty($month_num)) { |
|
781 | 781 | $args['monthnum'] = $month_num; |
782 | 782 | } |
783 | 783 | |
784 | - if ( ! empty( $day ) ) { |
|
784 | + if ( ! empty($day)) { |
|
785 | 785 | $args['day'] = $day; |
786 | 786 | } |
787 | 787 | |
788 | - if ( ! empty( $hour ) ) { |
|
788 | + if ( ! empty($hour)) { |
|
789 | 789 | $args['hour'] = $hour; |
790 | 790 | } |
791 | 791 | |
792 | - $args = apply_filters( 'give_get_sales_by_date_args', $args ); |
|
792 | + $args = apply_filters('give_get_sales_by_date_args', $args); |
|
793 | 793 | |
794 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
794 | + $key = Give_Cache::get_key('give_stats', $args); |
|
795 | 795 | |
796 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
796 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
797 | 797 | $count = false; |
798 | 798 | } else { |
799 | - $count = Give_Cache::get( $key ); |
|
799 | + $count = Give_Cache::get($key); |
|
800 | 800 | } |
801 | 801 | |
802 | - if ( false === $count ) { |
|
803 | - $sales = new WP_Query( $args ); |
|
802 | + if (false === $count) { |
|
803 | + $sales = new WP_Query($args); |
|
804 | 804 | $count = (int) $sales->post_count; |
805 | 805 | // Cache the results for one hour. |
806 | - Give_Cache::set( $key, $count, HOUR_IN_SECONDS ); |
|
806 | + Give_Cache::set($key, $count, HOUR_IN_SECONDS); |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | return $count; |
@@ -818,19 +818,19 @@ discard block |
||
818 | 818 | * |
819 | 819 | * @return bool $ret True if complete, false otherwise. |
820 | 820 | */ |
821 | -function give_is_payment_complete( $payment_id ) { |
|
822 | - $payment = new Give_Payment( $payment_id ); |
|
821 | +function give_is_payment_complete($payment_id) { |
|
822 | + $payment = new Give_Payment($payment_id); |
|
823 | 823 | |
824 | 824 | $ret = false; |
825 | 825 | |
826 | - if ( $payment->ID > 0 ) { |
|
826 | + if ($payment->ID > 0) { |
|
827 | 827 | |
828 | - if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) { |
|
828 | + if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) { |
|
829 | 829 | $ret = true; |
830 | 830 | } |
831 | 831 | } |
832 | 832 | |
833 | - return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status ); |
|
833 | + return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status); |
|
834 | 834 | } |
835 | 835 | |
836 | 836 | /** |
@@ -856,49 +856,49 @@ discard block |
||
856 | 856 | * |
857 | 857 | * @return float $total Total earnings. |
858 | 858 | */ |
859 | -function give_get_total_earnings( $recalculate = false ) { |
|
859 | +function give_get_total_earnings($recalculate = false) { |
|
860 | 860 | |
861 | - $total = get_option( 'give_earnings_total', 0 ); |
|
861 | + $total = get_option('give_earnings_total', 0); |
|
862 | 862 | |
863 | 863 | // Calculate total earnings. |
864 | - if ( ! $total || $recalculate ) { |
|
864 | + if ( ! $total || $recalculate) { |
|
865 | 865 | global $wpdb; |
866 | 866 | |
867 | 867 | $total = (float) 0; |
868 | 868 | |
869 | - $args = apply_filters( 'give_get_total_earnings_args', array( |
|
869 | + $args = apply_filters('give_get_total_earnings_args', array( |
|
870 | 870 | 'offset' => 0, |
871 | - 'number' => - 1, |
|
872 | - 'status' => array( 'publish' ), |
|
871 | + 'number' => -1, |
|
872 | + 'status' => array('publish'), |
|
873 | 873 | 'fields' => 'ids', |
874 | - ) ); |
|
874 | + )); |
|
875 | 875 | |
876 | - $payments = give_get_payments( $args ); |
|
877 | - if ( $payments ) { |
|
876 | + $payments = give_get_payments($args); |
|
877 | + if ($payments) { |
|
878 | 878 | |
879 | 879 | /** |
880 | 880 | * If performing a donation, we need to skip the very last payment in the database, |
881 | 881 | * since it calls give_increase_total_earnings() on completion, |
882 | 882 | * which results in duplicated earnings for the very first donation. |
883 | 883 | */ |
884 | - if ( did_action( 'give_update_payment_status' ) ) { |
|
885 | - array_pop( $payments ); |
|
884 | + if (did_action('give_update_payment_status')) { |
|
885 | + array_pop($payments); |
|
886 | 886 | } |
887 | 887 | |
888 | - if ( ! empty( $payments ) ) { |
|
889 | - $payments = implode( ',', $payments ); |
|
890 | - $total += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})" ); |
|
888 | + if ( ! empty($payments)) { |
|
889 | + $payments = implode(',', $payments); |
|
890 | + $total += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})"); |
|
891 | 891 | } |
892 | 892 | } |
893 | 893 | |
894 | - update_option( 'give_earnings_total', $total, 'no' ); |
|
894 | + update_option('give_earnings_total', $total, 'no'); |
|
895 | 895 | } |
896 | 896 | |
897 | - if ( $total < 0 ) { |
|
897 | + if ($total < 0) { |
|
898 | 898 | $total = 0; // Don't ever show negative earnings. |
899 | 899 | } |
900 | 900 | |
901 | - return apply_filters( 'give_total_earnings', round( $total, give_currency_decimal_filter() ) ); |
|
901 | + return apply_filters('give_total_earnings', round($total, give_currency_decimal_filter())); |
|
902 | 902 | } |
903 | 903 | |
904 | 904 | /** |
@@ -911,10 +911,10 @@ discard block |
||
911 | 911 | * |
912 | 912 | * @return float $total Total earnings. |
913 | 913 | */ |
914 | -function give_increase_total_earnings( $amount = 0 ) { |
|
914 | +function give_increase_total_earnings($amount = 0) { |
|
915 | 915 | $total = give_get_total_earnings(); |
916 | 916 | $total += $amount; |
917 | - update_option( 'give_earnings_total', $total ); |
|
917 | + update_option('give_earnings_total', $total); |
|
918 | 918 | |
919 | 919 | return $total; |
920 | 920 | } |
@@ -928,13 +928,13 @@ discard block |
||
928 | 928 | * |
929 | 929 | * @return float $total Total earnings. |
930 | 930 | */ |
931 | -function give_decrease_total_earnings( $amount = 0 ) { |
|
931 | +function give_decrease_total_earnings($amount = 0) { |
|
932 | 932 | $total = give_get_total_earnings(); |
933 | 933 | $total -= $amount; |
934 | - if ( $total < 0 ) { |
|
934 | + if ($total < 0) { |
|
935 | 935 | $total = 0; |
936 | 936 | } |
937 | - update_option( 'give_earnings_total', $total ); |
|
937 | + update_option('give_earnings_total', $total); |
|
938 | 938 | |
939 | 939 | return $total; |
940 | 940 | } |
@@ -950,10 +950,10 @@ discard block |
||
950 | 950 | * |
951 | 951 | * @return mixed $meta Payment Meta. |
952 | 952 | */ |
953 | -function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) { |
|
954 | - $payment = new Give_Payment( $payment_id ); |
|
953 | +function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) { |
|
954 | + $payment = new Give_Payment($payment_id); |
|
955 | 955 | |
956 | - return $payment->get_meta( $meta_key, $single ); |
|
956 | + return $payment->get_meta($meta_key, $single); |
|
957 | 957 | } |
958 | 958 | |
959 | 959 | /** |
@@ -966,10 +966,10 @@ discard block |
||
966 | 966 | * |
967 | 967 | * @return mixed Meta ID if successful, false if unsuccessful. |
968 | 968 | */ |
969 | -function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
970 | - $payment = new Give_Payment( $payment_id ); |
|
969 | +function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') { |
|
970 | + $payment = new Give_Payment($payment_id); |
|
971 | 971 | |
972 | - return $payment->update_meta( $meta_key, $meta_value, $prev_value ); |
|
972 | + return $payment->update_meta($meta_key, $meta_value, $prev_value); |
|
973 | 973 | } |
974 | 974 | |
975 | 975 | /** |
@@ -981,8 +981,8 @@ discard block |
||
981 | 981 | * |
982 | 982 | * @return string $user_info User Info Meta Values. |
983 | 983 | */ |
984 | -function give_get_payment_meta_user_info( $payment_id ) { |
|
985 | - $payment = new Give_Payment( $payment_id ); |
|
984 | +function give_get_payment_meta_user_info($payment_id) { |
|
985 | + $payment = new Give_Payment($payment_id); |
|
986 | 986 | |
987 | 987 | return $payment->user_info; |
988 | 988 | } |
@@ -998,8 +998,8 @@ discard block |
||
998 | 998 | * |
999 | 999 | * @return int $form_id Form ID. |
1000 | 1000 | */ |
1001 | -function give_get_payment_form_id( $payment_id ) { |
|
1002 | - $payment = new Give_Payment( $payment_id ); |
|
1001 | +function give_get_payment_form_id($payment_id) { |
|
1002 | + $payment = new Give_Payment($payment_id); |
|
1003 | 1003 | |
1004 | 1004 | return $payment->form_id; |
1005 | 1005 | } |
@@ -1013,8 +1013,8 @@ discard block |
||
1013 | 1013 | * |
1014 | 1014 | * @return string $email User email. |
1015 | 1015 | */ |
1016 | -function give_get_payment_user_email( $payment_id ) { |
|
1017 | - $payment = new Give_Payment( $payment_id ); |
|
1016 | +function give_get_payment_user_email($payment_id) { |
|
1017 | + $payment = new Give_Payment($payment_id); |
|
1018 | 1018 | |
1019 | 1019 | return $payment->email; |
1020 | 1020 | } |
@@ -1028,11 +1028,11 @@ discard block |
||
1028 | 1028 | * |
1029 | 1029 | * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true) |
1030 | 1030 | */ |
1031 | -function give_is_guest_payment( $payment_id ) { |
|
1032 | - $payment_user_id = give_get_payment_user_id( $payment_id ); |
|
1033 | - $is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true; |
|
1031 | +function give_is_guest_payment($payment_id) { |
|
1032 | + $payment_user_id = give_get_payment_user_id($payment_id); |
|
1033 | + $is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true; |
|
1034 | 1034 | |
1035 | - return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id ); |
|
1035 | + return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id); |
|
1036 | 1036 | } |
1037 | 1037 | |
1038 | 1038 | /** |
@@ -1044,8 +1044,8 @@ discard block |
||
1044 | 1044 | * |
1045 | 1045 | * @return int $user_id User ID. |
1046 | 1046 | */ |
1047 | -function give_get_payment_user_id( $payment_id ) { |
|
1048 | - $payment = new Give_Payment( $payment_id ); |
|
1047 | +function give_get_payment_user_id($payment_id) { |
|
1048 | + $payment = new Give_Payment($payment_id); |
|
1049 | 1049 | |
1050 | 1050 | return $payment->user_id; |
1051 | 1051 | } |
@@ -1059,8 +1059,8 @@ discard block |
||
1059 | 1059 | * |
1060 | 1060 | * @return int $customer_id Customer ID. |
1061 | 1061 | */ |
1062 | -function give_get_payment_customer_id( $payment_id ) { |
|
1063 | - $payment = new Give_Payment( $payment_id ); |
|
1062 | +function give_get_payment_customer_id($payment_id) { |
|
1063 | + $payment = new Give_Payment($payment_id); |
|
1064 | 1064 | |
1065 | 1065 | return $payment->customer_id; |
1066 | 1066 | } |
@@ -1074,8 +1074,8 @@ discard block |
||
1074 | 1074 | * |
1075 | 1075 | * @return string $ip User IP. |
1076 | 1076 | */ |
1077 | -function give_get_payment_user_ip( $payment_id ) { |
|
1078 | - $payment = new Give_Payment( $payment_id ); |
|
1077 | +function give_get_payment_user_ip($payment_id) { |
|
1078 | + $payment = new Give_Payment($payment_id); |
|
1079 | 1079 | |
1080 | 1080 | return $payment->ip; |
1081 | 1081 | } |
@@ -1089,8 +1089,8 @@ discard block |
||
1089 | 1089 | * |
1090 | 1090 | * @return string $date The date the payment was completed. |
1091 | 1091 | */ |
1092 | -function give_get_payment_completed_date( $payment_id = 0 ) { |
|
1093 | - $payment = new Give_Payment( $payment_id ); |
|
1092 | +function give_get_payment_completed_date($payment_id = 0) { |
|
1093 | + $payment = new Give_Payment($payment_id); |
|
1094 | 1094 | |
1095 | 1095 | return $payment->completed_date; |
1096 | 1096 | } |
@@ -1104,8 +1104,8 @@ discard block |
||
1104 | 1104 | * |
1105 | 1105 | * @return string $gateway Gateway. |
1106 | 1106 | */ |
1107 | -function give_get_payment_gateway( $payment_id ) { |
|
1108 | - $payment = new Give_Payment( $payment_id ); |
|
1107 | +function give_get_payment_gateway($payment_id) { |
|
1108 | + $payment = new Give_Payment($payment_id); |
|
1109 | 1109 | |
1110 | 1110 | return $payment->gateway; |
1111 | 1111 | } |
@@ -1119,8 +1119,8 @@ discard block |
||
1119 | 1119 | * |
1120 | 1120 | * @return string $currency The currency code. |
1121 | 1121 | */ |
1122 | -function give_get_payment_currency_code( $payment_id = 0 ) { |
|
1123 | - $payment = new Give_Payment( $payment_id ); |
|
1122 | +function give_get_payment_currency_code($payment_id = 0) { |
|
1123 | + $payment = new Give_Payment($payment_id); |
|
1124 | 1124 | |
1125 | 1125 | return $payment->currency; |
1126 | 1126 | } |
@@ -1134,10 +1134,10 @@ discard block |
||
1134 | 1134 | * |
1135 | 1135 | * @return string $currency The currency name. |
1136 | 1136 | */ |
1137 | -function give_get_payment_currency( $payment_id = 0 ) { |
|
1138 | - $currency = give_get_payment_currency_code( $payment_id ); |
|
1137 | +function give_get_payment_currency($payment_id = 0) { |
|
1138 | + $currency = give_get_payment_currency_code($payment_id); |
|
1139 | 1139 | |
1140 | - return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id ); |
|
1140 | + return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id); |
|
1141 | 1141 | } |
1142 | 1142 | |
1143 | 1143 | /** |
@@ -1149,8 +1149,8 @@ discard block |
||
1149 | 1149 | * |
1150 | 1150 | * @return string $key Donation key. |
1151 | 1151 | */ |
1152 | -function give_get_payment_key( $payment_id = 0 ) { |
|
1153 | - $payment = new Give_Payment( $payment_id ); |
|
1152 | +function give_get_payment_key($payment_id = 0) { |
|
1153 | + $payment = new Give_Payment($payment_id); |
|
1154 | 1154 | |
1155 | 1155 | return $payment->key; |
1156 | 1156 | } |
@@ -1166,8 +1166,8 @@ discard block |
||
1166 | 1166 | * |
1167 | 1167 | * @return string $number Payment order number. |
1168 | 1168 | */ |
1169 | -function give_get_payment_number( $payment_id = 0 ) { |
|
1170 | - $payment = new Give_Payment( $payment_id ); |
|
1169 | +function give_get_payment_number($payment_id = 0) { |
|
1170 | + $payment = new Give_Payment($payment_id); |
|
1171 | 1171 | |
1172 | 1172 | return $payment->number; |
1173 | 1173 | } |
@@ -1181,23 +1181,23 @@ discard block |
||
1181 | 1181 | * |
1182 | 1182 | * @return string The formatted payment number. |
1183 | 1183 | */ |
1184 | -function give_format_payment_number( $number ) { |
|
1184 | +function give_format_payment_number($number) { |
|
1185 | 1185 | |
1186 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
1186 | + if ( ! give_get_option('enable_sequential')) { |
|
1187 | 1187 | return $number; |
1188 | 1188 | } |
1189 | 1189 | |
1190 | - if ( ! is_numeric( $number ) ) { |
|
1190 | + if ( ! is_numeric($number)) { |
|
1191 | 1191 | return $number; |
1192 | 1192 | } |
1193 | 1193 | |
1194 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
1195 | - $number = absint( $number ); |
|
1196 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
1194 | + $prefix = give_get_option('sequential_prefix'); |
|
1195 | + $number = absint($number); |
|
1196 | + $postfix = give_get_option('sequential_postfix'); |
|
1197 | 1197 | |
1198 | - $formatted_number = $prefix . $number . $postfix; |
|
1198 | + $formatted_number = $prefix.$number.$postfix; |
|
1199 | 1199 | |
1200 | - return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix ); |
|
1200 | + return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix); |
|
1201 | 1201 | } |
1202 | 1202 | |
1203 | 1203 | /** |
@@ -1210,17 +1210,17 @@ discard block |
||
1210 | 1210 | */ |
1211 | 1211 | function give_get_next_payment_number() { |
1212 | 1212 | |
1213 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
1213 | + if ( ! give_get_option('enable_sequential')) { |
|
1214 | 1214 | return false; |
1215 | 1215 | } |
1216 | 1216 | |
1217 | - $number = get_option( 'give_last_payment_number' ); |
|
1218 | - $start = give_get_option( 'sequential_start', 1 ); |
|
1217 | + $number = get_option('give_last_payment_number'); |
|
1218 | + $start = give_get_option('sequential_start', 1); |
|
1219 | 1219 | $increment_number = true; |
1220 | 1220 | |
1221 | - if ( false !== $number ) { |
|
1221 | + if (false !== $number) { |
|
1222 | 1222 | |
1223 | - if ( empty( $number ) ) { |
|
1223 | + if (empty($number)) { |
|
1224 | 1224 | |
1225 | 1225 | $number = $start; |
1226 | 1226 | $increment_number = false; |
@@ -1229,24 +1229,24 @@ discard block |
||
1229 | 1229 | } else { |
1230 | 1230 | |
1231 | 1231 | // This case handles the first addition of the new option, as well as if it get's deleted for any reason. |
1232 | - $payments = new Give_Payments_Query( array( |
|
1232 | + $payments = new Give_Payments_Query(array( |
|
1233 | 1233 | 'number' => 1, |
1234 | 1234 | 'order' => 'DESC', |
1235 | 1235 | 'orderby' => 'ID', |
1236 | 1236 | 'output' => 'posts', |
1237 | 1237 | 'fields' => 'ids', |
1238 | - ) ); |
|
1238 | + )); |
|
1239 | 1239 | $last_payment = $payments->get_payments(); |
1240 | 1240 | |
1241 | - if ( ! empty( $last_payment ) ) { |
|
1241 | + if ( ! empty($last_payment)) { |
|
1242 | 1242 | |
1243 | - $number = give_get_payment_number( $last_payment[0] ); |
|
1243 | + $number = give_get_payment_number($last_payment[0]); |
|
1244 | 1244 | |
1245 | 1245 | } |
1246 | 1246 | |
1247 | - if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) { |
|
1247 | + if ( ! empty($number) && $number !== (int) $last_payment[0]) { |
|
1248 | 1248 | |
1249 | - $number = give_remove_payment_prefix_postfix( $number ); |
|
1249 | + $number = give_remove_payment_prefix_postfix($number); |
|
1250 | 1250 | |
1251 | 1251 | } else { |
1252 | 1252 | |
@@ -1255,13 +1255,13 @@ discard block |
||
1255 | 1255 | } |
1256 | 1256 | } |
1257 | 1257 | |
1258 | - $increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number ); |
|
1258 | + $increment_number = apply_filters('give_increment_payment_number', $increment_number, $number); |
|
1259 | 1259 | |
1260 | - if ( $increment_number ) { |
|
1261 | - $number ++; |
|
1260 | + if ($increment_number) { |
|
1261 | + $number++; |
|
1262 | 1262 | } |
1263 | 1263 | |
1264 | - return apply_filters( 'give_get_next_payment_number', $number ); |
|
1264 | + return apply_filters('give_get_next_payment_number', $number); |
|
1265 | 1265 | } |
1266 | 1266 | |
1267 | 1267 | /** |
@@ -1273,25 +1273,25 @@ discard block |
||
1273 | 1273 | * |
1274 | 1274 | * @return string The new Payment number without prefix and postfix. |
1275 | 1275 | */ |
1276 | -function give_remove_payment_prefix_postfix( $number ) { |
|
1276 | +function give_remove_payment_prefix_postfix($number) { |
|
1277 | 1277 | |
1278 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
1279 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
1278 | + $prefix = give_get_option('sequential_prefix'); |
|
1279 | + $postfix = give_get_option('sequential_postfix'); |
|
1280 | 1280 | |
1281 | 1281 | // Remove prefix. |
1282 | - $number = preg_replace( '/' . $prefix . '/', '', $number, 1 ); |
|
1282 | + $number = preg_replace('/'.$prefix.'/', '', $number, 1); |
|
1283 | 1283 | |
1284 | 1284 | // Remove the postfix. |
1285 | - $length = strlen( $number ); |
|
1286 | - $postfix_pos = strrpos( $number, $postfix ); |
|
1287 | - if ( false !== $postfix_pos ) { |
|
1288 | - $number = substr_replace( $number, '', $postfix_pos, $length ); |
|
1285 | + $length = strlen($number); |
|
1286 | + $postfix_pos = strrpos($number, $postfix); |
|
1287 | + if (false !== $postfix_pos) { |
|
1288 | + $number = substr_replace($number, '', $postfix_pos, $length); |
|
1289 | 1289 | } |
1290 | 1290 | |
1291 | 1291 | // Ensure it's a whole number. |
1292 | - $number = intval( $number ); |
|
1292 | + $number = intval($number); |
|
1293 | 1293 | |
1294 | - return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix ); |
|
1294 | + return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix); |
|
1295 | 1295 | |
1296 | 1296 | } |
1297 | 1297 | |
@@ -1308,10 +1308,10 @@ discard block |
||
1308 | 1308 | * |
1309 | 1309 | * @return string $amount Fully formatted payment amount. |
1310 | 1310 | */ |
1311 | -function give_payment_amount( $payment_id = 0 ) { |
|
1312 | - $amount = give_get_payment_amount( $payment_id ); |
|
1311 | +function give_payment_amount($payment_id = 0) { |
|
1312 | + $amount = give_get_payment_amount($payment_id); |
|
1313 | 1313 | |
1314 | - return give_currency_filter( give_format_amount( $amount ), give_get_payment_currency_code( $payment_id ) ); |
|
1314 | + return give_currency_filter(give_format_amount($amount), give_get_payment_currency_code($payment_id)); |
|
1315 | 1315 | } |
1316 | 1316 | |
1317 | 1317 | /** |
@@ -1324,11 +1324,11 @@ discard block |
||
1324 | 1324 | * |
1325 | 1325 | * @return mixed|void |
1326 | 1326 | */ |
1327 | -function give_get_payment_amount( $payment_id ) { |
|
1327 | +function give_get_payment_amount($payment_id) { |
|
1328 | 1328 | |
1329 | - $payment = new Give_Payment( $payment_id ); |
|
1329 | + $payment = new Give_Payment($payment_id); |
|
1330 | 1330 | |
1331 | - return apply_filters( 'give_payment_amount', floatval( $payment->total ), $payment_id ); |
|
1331 | + return apply_filters('give_payment_amount', floatval($payment->total), $payment_id); |
|
1332 | 1332 | } |
1333 | 1333 | |
1334 | 1334 | /** |
@@ -1345,10 +1345,10 @@ discard block |
||
1345 | 1345 | * |
1346 | 1346 | * @return array Fully formatted payment subtotal. |
1347 | 1347 | */ |
1348 | -function give_payment_subtotal( $payment_id = 0 ) { |
|
1349 | - $subtotal = give_get_payment_subtotal( $payment_id ); |
|
1348 | +function give_payment_subtotal($payment_id = 0) { |
|
1349 | + $subtotal = give_get_payment_subtotal($payment_id); |
|
1350 | 1350 | |
1351 | - return give_currency_filter( give_format_amount( $subtotal ), give_get_payment_currency_code( $payment_id ) ); |
|
1351 | + return give_currency_filter(give_format_amount($subtotal), give_get_payment_currency_code($payment_id)); |
|
1352 | 1352 | } |
1353 | 1353 | |
1354 | 1354 | /** |
@@ -1362,8 +1362,8 @@ discard block |
||
1362 | 1362 | * |
1363 | 1363 | * @return float $subtotal Subtotal for payment (non formatted). |
1364 | 1364 | */ |
1365 | -function give_get_payment_subtotal( $payment_id = 0 ) { |
|
1366 | - $payment = new G_Payment( $payment_id ); |
|
1365 | +function give_get_payment_subtotal($payment_id = 0) { |
|
1366 | + $payment = new G_Payment($payment_id); |
|
1367 | 1367 | |
1368 | 1368 | return $payment->subtotal; |
1369 | 1369 | } |
@@ -1378,10 +1378,10 @@ discard block |
||
1378 | 1378 | * |
1379 | 1379 | * @return mixed array if payment fees found, false otherwise. |
1380 | 1380 | */ |
1381 | -function give_get_payment_fees( $payment_id = 0, $type = 'all' ) { |
|
1382 | - $payment = new Give_Payment( $payment_id ); |
|
1381 | +function give_get_payment_fees($payment_id = 0, $type = 'all') { |
|
1382 | + $payment = new Give_Payment($payment_id); |
|
1383 | 1383 | |
1384 | - return $payment->get_fees( $type ); |
|
1384 | + return $payment->get_fees($type); |
|
1385 | 1385 | } |
1386 | 1386 | |
1387 | 1387 | /** |
@@ -1393,8 +1393,8 @@ discard block |
||
1393 | 1393 | * |
1394 | 1394 | * @return string The donation ID. |
1395 | 1395 | */ |
1396 | -function give_get_payment_transaction_id( $payment_id = 0 ) { |
|
1397 | - $payment = new Give_Payment( $payment_id ); |
|
1396 | +function give_get_payment_transaction_id($payment_id = 0) { |
|
1397 | + $payment = new Give_Payment($payment_id); |
|
1398 | 1398 | |
1399 | 1399 | return $payment->transaction_id; |
1400 | 1400 | } |
@@ -1409,15 +1409,15 @@ discard block |
||
1409 | 1409 | * |
1410 | 1410 | * @return bool|mixed |
1411 | 1411 | */ |
1412 | -function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) { |
|
1412 | +function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') { |
|
1413 | 1413 | |
1414 | - if ( empty( $payment_id ) || empty( $transaction_id ) ) { |
|
1414 | + if (empty($payment_id) || empty($transaction_id)) { |
|
1415 | 1415 | return false; |
1416 | 1416 | } |
1417 | 1417 | |
1418 | - $transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
1418 | + $transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id); |
|
1419 | 1419 | |
1420 | - return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id ); |
|
1420 | + return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id); |
|
1421 | 1421 | } |
1422 | 1422 | |
1423 | 1423 | /** |
@@ -1430,12 +1430,12 @@ discard block |
||
1430 | 1430 | * |
1431 | 1431 | * @return int $purchase Donation ID. |
1432 | 1432 | */ |
1433 | -function give_get_purchase_id_by_key( $key ) { |
|
1433 | +function give_get_purchase_id_by_key($key) { |
|
1434 | 1434 | global $wpdb; |
1435 | 1435 | |
1436 | - $purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
1436 | + $purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key)); |
|
1437 | 1437 | |
1438 | - if ( $purchase != null ) { |
|
1438 | + if ($purchase != null) { |
|
1439 | 1439 | return $purchase; |
1440 | 1440 | } |
1441 | 1441 | |
@@ -1453,12 +1453,12 @@ discard block |
||
1453 | 1453 | * |
1454 | 1454 | * @return int $purchase Donation ID. |
1455 | 1455 | */ |
1456 | -function give_get_purchase_id_by_transaction_id( $key ) { |
|
1456 | +function give_get_purchase_id_by_transaction_id($key) { |
|
1457 | 1457 | global $wpdb; |
1458 | 1458 | |
1459 | - $purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) ); |
|
1459 | + $purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key)); |
|
1460 | 1460 | |
1461 | - if ( $purchase != null ) { |
|
1461 | + if ($purchase != null) { |
|
1462 | 1462 | return $purchase; |
1463 | 1463 | } |
1464 | 1464 | |
@@ -1475,19 +1475,19 @@ discard block |
||
1475 | 1475 | * |
1476 | 1476 | * @return array $notes Donation Notes |
1477 | 1477 | */ |
1478 | -function give_get_payment_notes( $payment_id = 0, $search = '' ) { |
|
1478 | +function give_get_payment_notes($payment_id = 0, $search = '') { |
|
1479 | 1479 | |
1480 | - if ( empty( $payment_id ) && empty( $search ) ) { |
|
1480 | + if (empty($payment_id) && empty($search)) { |
|
1481 | 1481 | return false; |
1482 | 1482 | } |
1483 | 1483 | |
1484 | - remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1485 | - remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 ); |
|
1484 | + remove_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1485 | + remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10); |
|
1486 | 1486 | |
1487 | - $notes = get_comments( array( 'post_id' => $payment_id, 'order' => 'ASC', 'search' => $search ) ); |
|
1487 | + $notes = get_comments(array('post_id' => $payment_id, 'order' => 'ASC', 'search' => $search)); |
|
1488 | 1488 | |
1489 | - add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1490 | - add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
1489 | + add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1490 | + add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
1491 | 1491 | |
1492 | 1492 | return $notes; |
1493 | 1493 | } |
@@ -1503,8 +1503,8 @@ discard block |
||
1503 | 1503 | * |
1504 | 1504 | * @return int The new note ID |
1505 | 1505 | */ |
1506 | -function give_insert_payment_note( $payment_id = 0, $note = '' ) { |
|
1507 | - if ( empty( $payment_id ) ) { |
|
1506 | +function give_insert_payment_note($payment_id = 0, $note = '') { |
|
1507 | + if (empty($payment_id)) { |
|
1508 | 1508 | return false; |
1509 | 1509 | } |
1510 | 1510 | |
@@ -1516,14 +1516,14 @@ discard block |
||
1516 | 1516 | * @param int $payment_id Payment ID. |
1517 | 1517 | * @param string $note The note. |
1518 | 1518 | */ |
1519 | - do_action( 'give_pre_insert_payment_note', $payment_id, $note ); |
|
1519 | + do_action('give_pre_insert_payment_note', $payment_id, $note); |
|
1520 | 1520 | |
1521 | - $note_id = wp_insert_comment( wp_filter_comment( array( |
|
1521 | + $note_id = wp_insert_comment(wp_filter_comment(array( |
|
1522 | 1522 | 'comment_post_ID' => $payment_id, |
1523 | 1523 | 'comment_content' => $note, |
1524 | 1524 | 'user_id' => is_admin() ? get_current_user_id() : 0, |
1525 | - 'comment_date' => current_time( 'mysql' ), |
|
1526 | - 'comment_date_gmt' => current_time( 'mysql', 1 ), |
|
1525 | + 'comment_date' => current_time('mysql'), |
|
1526 | + 'comment_date_gmt' => current_time('mysql', 1), |
|
1527 | 1527 | 'comment_approved' => 1, |
1528 | 1528 | 'comment_parent' => 0, |
1529 | 1529 | 'comment_author' => '', |
@@ -1532,7 +1532,7 @@ discard block |
||
1532 | 1532 | 'comment_author_email' => '', |
1533 | 1533 | 'comment_type' => 'give_payment_note', |
1534 | 1534 | |
1535 | - ) ) ); |
|
1535 | + ))); |
|
1536 | 1536 | |
1537 | 1537 | /** |
1538 | 1538 | * Fires after payment note inserted. |
@@ -1543,7 +1543,7 @@ discard block |
||
1543 | 1543 | * @param int $payment_id Payment ID. |
1544 | 1544 | * @param string $note The note. |
1545 | 1545 | */ |
1546 | - do_action( 'give_insert_payment_note', $note_id, $payment_id, $note ); |
|
1546 | + do_action('give_insert_payment_note', $note_id, $payment_id, $note); |
|
1547 | 1547 | |
1548 | 1548 | return $note_id; |
1549 | 1549 | } |
@@ -1558,8 +1558,8 @@ discard block |
||
1558 | 1558 | * |
1559 | 1559 | * @return bool True on success, false otherwise. |
1560 | 1560 | */ |
1561 | -function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) { |
|
1562 | - if ( empty( $comment_id ) ) { |
|
1561 | +function give_delete_payment_note($comment_id = 0, $payment_id = 0) { |
|
1562 | + if (empty($comment_id)) { |
|
1563 | 1563 | return false; |
1564 | 1564 | } |
1565 | 1565 | |
@@ -1571,9 +1571,9 @@ discard block |
||
1571 | 1571 | * @param int $comment_id Note ID. |
1572 | 1572 | * @param int $payment_id Payment ID. |
1573 | 1573 | */ |
1574 | - do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id ); |
|
1574 | + do_action('give_pre_delete_payment_note', $comment_id, $payment_id); |
|
1575 | 1575 | |
1576 | - $ret = wp_delete_comment( $comment_id, true ); |
|
1576 | + $ret = wp_delete_comment($comment_id, true); |
|
1577 | 1577 | |
1578 | 1578 | /** |
1579 | 1579 | * Fires after donation note deleted. |
@@ -1583,7 +1583,7 @@ discard block |
||
1583 | 1583 | * @param int $comment_id Note ID. |
1584 | 1584 | * @param int $payment_id Payment ID. |
1585 | 1585 | */ |
1586 | - do_action( 'give_post_delete_payment_note', $comment_id, $payment_id ); |
|
1586 | + do_action('give_post_delete_payment_note', $comment_id, $payment_id); |
|
1587 | 1587 | |
1588 | 1588 | return $ret; |
1589 | 1589 | } |
@@ -1598,34 +1598,34 @@ discard block |
||
1598 | 1598 | * |
1599 | 1599 | * @return string |
1600 | 1600 | */ |
1601 | -function give_get_payment_note_html( $note, $payment_id = 0 ) { |
|
1601 | +function give_get_payment_note_html($note, $payment_id = 0) { |
|
1602 | 1602 | |
1603 | - if ( is_numeric( $note ) ) { |
|
1604 | - $note = get_comment( $note ); |
|
1603 | + if (is_numeric($note)) { |
|
1604 | + $note = get_comment($note); |
|
1605 | 1605 | } |
1606 | 1606 | |
1607 | - if ( ! empty( $note->user_id ) ) { |
|
1608 | - $user = get_userdata( $note->user_id ); |
|
1607 | + if ( ! empty($note->user_id)) { |
|
1608 | + $user = get_userdata($note->user_id); |
|
1609 | 1609 | $user = $user->display_name; |
1610 | 1610 | } else { |
1611 | - $user = esc_html__( 'System', 'give' ); |
|
1611 | + $user = esc_html__('System', 'give'); |
|
1612 | 1612 | } |
1613 | 1613 | |
1614 | - $date_format = give_date_format() . ', ' . get_option( 'time_format' ); |
|
1614 | + $date_format = give_date_format().', '.get_option('time_format'); |
|
1615 | 1615 | |
1616 | - $delete_note_url = wp_nonce_url( add_query_arg( array( |
|
1616 | + $delete_note_url = wp_nonce_url(add_query_arg(array( |
|
1617 | 1617 | 'give-action' => 'delete_payment_note', |
1618 | 1618 | 'note_id' => $note->comment_ID, |
1619 | 1619 | 'payment_id' => $payment_id, |
1620 | - ) ), |
|
1621 | - 'give_delete_payment_note_' . $note->comment_ID |
|
1620 | + )), |
|
1621 | + 'give_delete_payment_note_'.$note->comment_ID |
|
1622 | 1622 | ); |
1623 | 1623 | |
1624 | - $note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">'; |
|
1624 | + $note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">'; |
|
1625 | 1625 | $note_html .= '<p>'; |
1626 | - $note_html .= '<strong>' . $user . '</strong> – <span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>'; |
|
1626 | + $note_html .= '<strong>'.$user.'</strong> – <span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>'; |
|
1627 | 1627 | $note_html .= $note->comment_content; |
1628 | - $note_html .= ' – <a href="' . esc_url( $delete_note_url ) . '" class="give-delete-payment-note" data-note-id="' . absint( $note->comment_ID ) . '" data-payment-id="' . absint( $payment_id ) . '" aria-label="' . esc_attr__( 'Delete this donation note.', 'give' ) . '">' . esc_html__( 'Delete', 'give' ) . '</a>'; |
|
1628 | + $note_html .= ' – <a href="'.esc_url($delete_note_url).'" class="give-delete-payment-note" data-note-id="'.absint($note->comment_ID).'" data-payment-id="'.absint($payment_id).'" aria-label="'.esc_attr__('Delete this donation note.', 'give').'">'.esc_html__('Delete', 'give').'</a>'; |
|
1629 | 1629 | $note_html .= '</p>'; |
1630 | 1630 | $note_html .= '</div>'; |
1631 | 1631 | |
@@ -1643,18 +1643,18 @@ discard block |
||
1643 | 1643 | * |
1644 | 1644 | * @return void |
1645 | 1645 | */ |
1646 | -function give_hide_payment_notes( $query ) { |
|
1647 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) { |
|
1648 | - $types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array(); |
|
1649 | - if ( ! is_array( $types ) ) { |
|
1650 | - $types = array( $types ); |
|
1646 | +function give_hide_payment_notes($query) { |
|
1647 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) { |
|
1648 | + $types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array(); |
|
1649 | + if ( ! is_array($types)) { |
|
1650 | + $types = array($types); |
|
1651 | 1651 | } |
1652 | 1652 | $types[] = 'give_payment_note'; |
1653 | 1653 | $query->query_vars['type__not_in'] = $types; |
1654 | 1654 | } |
1655 | 1655 | } |
1656 | 1656 | |
1657 | -add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1657 | +add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1658 | 1658 | |
1659 | 1659 | /** |
1660 | 1660 | * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets |
@@ -1666,15 +1666,15 @@ discard block |
||
1666 | 1666 | * |
1667 | 1667 | * @return array $clauses Updated comment clauses. |
1668 | 1668 | */ |
1669 | -function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) { |
|
1670 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) { |
|
1669 | +function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) { |
|
1670 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) { |
|
1671 | 1671 | $clauses['where'] .= ' AND comment_type != "give_payment_note"'; |
1672 | 1672 | } |
1673 | 1673 | |
1674 | 1674 | return $clauses; |
1675 | 1675 | } |
1676 | 1676 | |
1677 | -add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
1677 | +add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
1678 | 1678 | |
1679 | 1679 | |
1680 | 1680 | /** |
@@ -1687,15 +1687,15 @@ discard block |
||
1687 | 1687 | * |
1688 | 1688 | * @return string $where |
1689 | 1689 | */ |
1690 | -function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) { |
|
1690 | +function give_hide_payment_notes_from_feeds($where, $wp_comment_query) { |
|
1691 | 1691 | global $wpdb; |
1692 | 1692 | |
1693 | - $where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' ); |
|
1693 | + $where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note'); |
|
1694 | 1694 | |
1695 | 1695 | return $where; |
1696 | 1696 | } |
1697 | 1697 | |
1698 | -add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 ); |
|
1698 | +add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2); |
|
1699 | 1699 | |
1700 | 1700 | |
1701 | 1701 | /** |
@@ -1709,32 +1709,32 @@ discard block |
||
1709 | 1709 | * |
1710 | 1710 | * @return array Array of comment counts. |
1711 | 1711 | */ |
1712 | -function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) { |
|
1712 | +function give_remove_payment_notes_in_comment_counts($stats, $post_id) { |
|
1713 | 1713 | global $wpdb, $pagenow; |
1714 | 1714 | |
1715 | - if ( 'index.php' != $pagenow ) { |
|
1715 | + if ('index.php' != $pagenow) { |
|
1716 | 1716 | return $stats; |
1717 | 1717 | } |
1718 | 1718 | |
1719 | 1719 | $post_id = (int) $post_id; |
1720 | 1720 | |
1721 | - if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) { |
|
1721 | + if (apply_filters('give_count_payment_notes_in_comments', false)) { |
|
1722 | 1722 | return $stats; |
1723 | 1723 | } |
1724 | 1724 | |
1725 | - $stats = wp_cache_get( "comments-{$post_id}", 'counts' ); |
|
1725 | + $stats = wp_cache_get("comments-{$post_id}", 'counts'); |
|
1726 | 1726 | |
1727 | - if ( false !== $stats ) { |
|
1727 | + if (false !== $stats) { |
|
1728 | 1728 | return $stats; |
1729 | 1729 | } |
1730 | 1730 | |
1731 | 1731 | $where = 'WHERE comment_type != "give_payment_note"'; |
1732 | 1732 | |
1733 | - if ( $post_id > 0 ) { |
|
1734 | - $where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id ); |
|
1733 | + if ($post_id > 0) { |
|
1734 | + $where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id); |
|
1735 | 1735 | } |
1736 | 1736 | |
1737 | - $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
|
1737 | + $count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A); |
|
1738 | 1738 | |
1739 | 1739 | $total = 0; |
1740 | 1740 | $approved = array( |
@@ -1744,30 +1744,30 @@ discard block |
||
1744 | 1744 | 'trash' => 'trash', |
1745 | 1745 | 'post-trashed' => 'post-trashed', |
1746 | 1746 | ); |
1747 | - foreach ( (array) $count as $row ) { |
|
1747 | + foreach ((array) $count as $row) { |
|
1748 | 1748 | // Don't count post-trashed toward totals. |
1749 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) { |
|
1749 | + if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) { |
|
1750 | 1750 | $total += $row['num_comments']; |
1751 | 1751 | } |
1752 | - if ( isset( $approved[ $row['comment_approved'] ] ) ) { |
|
1753 | - $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments']; |
|
1752 | + if (isset($approved[$row['comment_approved']])) { |
|
1753 | + $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
1754 | 1754 | } |
1755 | 1755 | } |
1756 | 1756 | |
1757 | 1757 | $stats['total_comments'] = $total; |
1758 | - foreach ( $approved as $key ) { |
|
1759 | - if ( empty( $stats[ $key ] ) ) { |
|
1760 | - $stats[ $key ] = 0; |
|
1758 | + foreach ($approved as $key) { |
|
1759 | + if (empty($stats[$key])) { |
|
1760 | + $stats[$key] = 0; |
|
1761 | 1761 | } |
1762 | 1762 | } |
1763 | 1763 | |
1764 | 1764 | $stats = (object) $stats; |
1765 | - wp_cache_set( "comments-{$post_id}", $stats, 'counts' ); |
|
1765 | + wp_cache_set("comments-{$post_id}", $stats, 'counts'); |
|
1766 | 1766 | |
1767 | 1767 | return $stats; |
1768 | 1768 | } |
1769 | 1769 | |
1770 | -add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 ); |
|
1770 | +add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2); |
|
1771 | 1771 | |
1772 | 1772 | |
1773 | 1773 | /** |
@@ -1780,9 +1780,9 @@ discard block |
||
1780 | 1780 | * |
1781 | 1781 | * @return string $where Modified where clause. |
1782 | 1782 | */ |
1783 | -function give_filter_where_older_than_week( $where = '' ) { |
|
1783 | +function give_filter_where_older_than_week($where = '') { |
|
1784 | 1784 | // Payments older than one week. |
1785 | - $start = date( 'Y-m-d', strtotime( '-7 days' ) ); |
|
1785 | + $start = date('Y-m-d', strtotime('-7 days')); |
|
1786 | 1786 | $where .= " AND post_date <= '{$start}'"; |
1787 | 1787 | |
1788 | 1788 | return $where; |
@@ -1802,38 +1802,38 @@ discard block |
||
1802 | 1802 | * |
1803 | 1803 | * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title. |
1804 | 1804 | */ |
1805 | -function give_get_payment_form_title( $payment_meta, $only_level = false, $separator = '' ) { |
|
1805 | +function give_get_payment_form_title($payment_meta, $only_level = false, $separator = '') { |
|
1806 | 1806 | |
1807 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0; |
|
1808 | - $price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null; |
|
1809 | - $form_title = isset( $payment_meta['form_title'] ) ? $payment_meta['form_title'] : ''; |
|
1807 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0; |
|
1808 | + $price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null; |
|
1809 | + $form_title = isset($payment_meta['form_title']) ? $payment_meta['form_title'] : ''; |
|
1810 | 1810 | |
1811 | - if ( $only_level == true ) { |
|
1811 | + if ($only_level == true) { |
|
1812 | 1812 | $form_title = ''; |
1813 | 1813 | } |
1814 | 1814 | |
1815 | 1815 | //If multi-level, append to the form title. |
1816 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1816 | + if (give_has_variable_prices($form_id)) { |
|
1817 | 1817 | |
1818 | 1818 | //Only add separator if there is a form title. |
1819 | - if ( ! empty( $form_title ) ) { |
|
1820 | - $form_title .= ' ' . $separator . ' '; |
|
1819 | + if ( ! empty($form_title)) { |
|
1820 | + $form_title .= ' '.$separator.' '; |
|
1821 | 1821 | } |
1822 | 1822 | |
1823 | 1823 | $form_title .= '<span class="donation-level-text-wrap">'; |
1824 | 1824 | |
1825 | - if ( $price_id == 'custom' ) { |
|
1826 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
1827 | - $form_title .= ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' ); |
|
1825 | + if ($price_id == 'custom') { |
|
1826 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
1827 | + $form_title .= ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give'); |
|
1828 | 1828 | } else { |
1829 | - $form_title .= give_get_price_option_name( $form_id, $price_id ); |
|
1829 | + $form_title .= give_get_price_option_name($form_id, $price_id); |
|
1830 | 1830 | } |
1831 | 1831 | |
1832 | 1832 | $form_title .= '</span>'; |
1833 | 1833 | |
1834 | 1834 | } |
1835 | 1835 | |
1836 | - return apply_filters( 'give_get_payment_form_title', $form_title, $payment_meta ); |
|
1836 | + return apply_filters('give_get_payment_form_title', $form_title, $payment_meta); |
|
1837 | 1837 | |
1838 | 1838 | } |
1839 | 1839 | |
@@ -1847,20 +1847,20 @@ discard block |
||
1847 | 1847 | * |
1848 | 1848 | * @return string $price_id |
1849 | 1849 | */ |
1850 | -function give_get_price_id( $form_id, $price ) { |
|
1850 | +function give_get_price_id($form_id, $price) { |
|
1851 | 1851 | |
1852 | 1852 | $price_id = 0; |
1853 | 1853 | |
1854 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1854 | + if (give_has_variable_prices($form_id)) { |
|
1855 | 1855 | |
1856 | - $levels = maybe_unserialize( get_post_meta( $form_id, '_give_donation_levels', true ) ); |
|
1856 | + $levels = maybe_unserialize(get_post_meta($form_id, '_give_donation_levels', true)); |
|
1857 | 1857 | |
1858 | - foreach ( $levels as $level ) { |
|
1858 | + foreach ($levels as $level) { |
|
1859 | 1859 | |
1860 | - $level_amount = (float) give_sanitize_amount( $level['_give_amount'] ); |
|
1860 | + $level_amount = (float) give_sanitize_amount($level['_give_amount']); |
|
1861 | 1861 | |
1862 | 1862 | // Check that this indeed the recurring price. |
1863 | - if ( $level_amount == $price ) { |
|
1863 | + if ($level_amount == $price) { |
|
1864 | 1864 | |
1865 | 1865 | $price_id = $level['_give_id']['level_id']; |
1866 | 1866 | |
@@ -1885,10 +1885,10 @@ discard block |
||
1885 | 1885 | * |
1886 | 1886 | * @return string|void |
1887 | 1887 | */ |
1888 | -function give_get_form_dropdown( $args = array(), $echo = false ) { |
|
1889 | - $form_dropdown_html = Give()->html->forms_dropdown( $args ); |
|
1888 | +function give_get_form_dropdown($args = array(), $echo = false) { |
|
1889 | + $form_dropdown_html = Give()->html->forms_dropdown($args); |
|
1890 | 1890 | |
1891 | - if ( ! $echo ) { |
|
1891 | + if ( ! $echo) { |
|
1892 | 1892 | return $form_dropdown_html; |
1893 | 1893 | } |
1894 | 1894 | |
@@ -1905,17 +1905,17 @@ discard block |
||
1905 | 1905 | * |
1906 | 1906 | * @return string|bool |
1907 | 1907 | */ |
1908 | -function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) { |
|
1908 | +function give_get_form_variable_price_dropdown($args = array(), $echo = false) { |
|
1909 | 1909 | |
1910 | 1910 | // Check for give form id. |
1911 | - if ( empty( $args['id'] ) ) { |
|
1911 | + if (empty($args['id'])) { |
|
1912 | 1912 | return false; |
1913 | 1913 | } |
1914 | 1914 | |
1915 | - $form = new Give_Donate_Form( $args['id'] ); |
|
1915 | + $form = new Give_Donate_Form($args['id']); |
|
1916 | 1916 | |
1917 | 1917 | // Check if form has variable prices or not. |
1918 | - if ( ! $form->ID || ! $form->has_variable_prices() ) { |
|
1918 | + if ( ! $form->ID || ! $form->has_variable_prices()) { |
|
1919 | 1919 | return false; |
1920 | 1920 | } |
1921 | 1921 | |
@@ -1923,22 +1923,22 @@ discard block |
||
1923 | 1923 | $variable_price_options = array(); |
1924 | 1924 | |
1925 | 1925 | // Check if multi donation form support custom donation or not. |
1926 | - if ( $form->is_custom_price_mode() ) { |
|
1927 | - $variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' ); |
|
1926 | + if ($form->is_custom_price_mode()) { |
|
1927 | + $variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give'); |
|
1928 | 1928 | } |
1929 | 1929 | |
1930 | 1930 | // Get variable price and ID from variable price array. |
1931 | - foreach ( $variable_prices as $variable_price ) { |
|
1932 | - $variable_price_options[ $variable_price['_give_id']['level_id'] ] = ! empty( $variable_price['_give_text'] ) ? $variable_price['_give_text'] : give_currency_filter( give_format_amount( $variable_price['_give_amount'] ) ); |
|
1931 | + foreach ($variable_prices as $variable_price) { |
|
1932 | + $variable_price_options[$variable_price['_give_id']['level_id']] = ! empty($variable_price['_give_text']) ? $variable_price['_give_text'] : give_currency_filter(give_format_amount($variable_price['_give_amount'])); |
|
1933 | 1933 | } |
1934 | 1934 | |
1935 | 1935 | // Update options. |
1936 | - $args = array_merge( $args, array( 'options' => $variable_price_options ) ); |
|
1936 | + $args = array_merge($args, array('options' => $variable_price_options)); |
|
1937 | 1937 | |
1938 | 1938 | // Generate select html. |
1939 | - $form_dropdown_html = Give()->html->select( $args ); |
|
1939 | + $form_dropdown_html = Give()->html->select($args); |
|
1940 | 1940 | |
1941 | - if ( ! $echo ) { |
|
1941 | + if ( ! $echo) { |
|
1942 | 1942 | return $form_dropdown_html; |
1943 | 1943 | } |
1944 | 1944 | |
@@ -1957,14 +1957,14 @@ discard block |
||
1957 | 1957 | * |
1958 | 1958 | * @return string |
1959 | 1959 | */ |
1960 | -function give_get_payment_meta_price_id( $payment_meta ) { |
|
1960 | +function give_get_payment_meta_price_id($payment_meta) { |
|
1961 | 1961 | |
1962 | - if(isset($payment_meta['give_price_id'])) { |
|
1963 | - $price_id = $payment_meta['give_price_id']; |
|
1964 | - } elseif(isset($payment_meta['price_id'])) { |
|
1965 | - $price_id = $payment_meta['price_id']; |
|
1962 | + if (isset($payment_meta['give_price_id'])) { |
|
1963 | + $price_id = $payment_meta['give_price_id']; |
|
1964 | + } elseif (isset($payment_meta['price_id'])) { |
|
1965 | + $price_id = $payment_meta['price_id']; |
|
1966 | 1966 | } else { |
1967 | - $price_id = give_get_price_id( $payment_meta['give_form_id'], $payment_meta['price'] ); |
|
1967 | + $price_id = give_get_price_id($payment_meta['give_form_id'], $payment_meta['price']); |
|
1968 | 1968 | } |
1969 | 1969 | |
1970 | 1970 | return apply_filters('give_get_payment_meta_price_id', $price_id); |
@@ -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 | |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | * @return void |
22 | 22 | */ |
23 | 23 | function give_register_dashboard_widgets() { |
24 | - if ( current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) { |
|
25 | - wp_add_dashboard_widget( 'give_dashboard_sales', esc_html__( 'Give: Donation Statistics', 'give' ), 'give_dashboard_sales_widget' ); |
|
24 | + if (current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) { |
|
25 | + wp_add_dashboard_widget('give_dashboard_sales', esc_html__('Give: Donation Statistics', 'give'), 'give_dashboard_sales_widget'); |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | -add_action( 'wp_dashboard_setup', 'give_register_dashboard_widgets', 10 ); |
|
29 | +add_action('wp_dashboard_setup', 'give_register_dashboard_widgets', 10); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Sales Summary Dashboard Widget |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | function give_dashboard_sales_widget() { |
40 | 40 | |
41 | - if ( ! current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) { |
|
41 | + if ( ! current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) { |
|
42 | 42 | return; |
43 | 43 | } |
44 | 44 | $stats = new Give_Payment_Stats; ?> |
@@ -46,27 +46,27 @@ discard block |
||
46 | 46 | <div class="give-dashboard-widget"> |
47 | 47 | |
48 | 48 | <div class="give-dashboard-today give-clearfix"> |
49 | - <h3 class="give-dashboard-date-today"><?php echo date( _x( 'F j, Y', 'dashboard widget', 'give' ) ); ?></h3> |
|
49 | + <h3 class="give-dashboard-date-today"><?php echo date(_x('F j, Y', 'dashboard widget', 'give')); ?></h3> |
|
50 | 50 | |
51 | 51 | <p class="give-dashboard-happy-day"><?php |
52 | 52 | printf( |
53 | 53 | /* translators: %s: day of the week */ |
54 | - esc_html__( 'Happy %s!', 'give' ), |
|
55 | - date( 'l', current_time( 'timestamp' ) ) |
|
54 | + esc_html__('Happy %s!', 'give'), |
|
55 | + date('l', current_time('timestamp')) |
|
56 | 56 | ); |
57 | 57 | ?></p> |
58 | 58 | |
59 | 59 | <p class="give-dashboard-today-earnings"><?php |
60 | - $earnings_today = $stats->get_earnings( 0, 'today', false ); |
|
61 | - echo give_currency_filter( give_format_amount( $earnings_today ) ); |
|
60 | + $earnings_today = $stats->get_earnings(0, 'today', false); |
|
61 | + echo give_currency_filter(give_format_amount($earnings_today)); |
|
62 | 62 | ?></p> |
63 | 63 | |
64 | 64 | <p class="give-orders-today"><?php |
65 | - $donations_today = $stats->get_sales( 0, 'today', false ); |
|
65 | + $donations_today = $stats->get_sales(0, 'today', false); |
|
66 | 66 | printf( |
67 | 67 | /* translators: %s: daily donation count */ |
68 | - esc_html__( '%s donations today', 'give' ), |
|
69 | - give_format_amount( $donations_today, false ) |
|
68 | + esc_html__('%s donations today', 'give'), |
|
69 | + give_format_amount($donations_today, false) |
|
70 | 70 | ); |
71 | 71 | ?></p> |
72 | 72 | |
@@ -76,34 +76,34 @@ discard block |
||
76 | 76 | <table class="give-table-stats"> |
77 | 77 | <thead style="display: none;"> |
78 | 78 | <tr> |
79 | - <th><?php esc_html_e( 'This Week', 'give' ); ?></th> |
|
80 | - <th><?php esc_html_e( 'This Month', 'give' ); ?></th> |
|
81 | - <th><?php esc_html_e( 'Past 30 Days', 'give' ); ?></th> |
|
79 | + <th><?php esc_html_e('This Week', 'give'); ?></th> |
|
80 | + <th><?php esc_html_e('This Month', 'give'); ?></th> |
|
81 | + <th><?php esc_html_e('Past 30 Days', 'give'); ?></th> |
|
82 | 82 | </tr> |
83 | 83 | </thead> |
84 | 84 | <tbody> |
85 | 85 | <tr id="give-table-stats-tr-1"> |
86 | 86 | <td> |
87 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_week' ) ) ); ?></p> |
|
87 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_week'))); ?></p> |
|
88 | 88 | |
89 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'This Week', 'give' ); ?></p> |
|
89 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('This Week', 'give'); ?></p> |
|
90 | 90 | </td> |
91 | 91 | <td> |
92 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_month' ) ) ); ?></p> |
|
92 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_month'))); ?></p> |
|
93 | 93 | |
94 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'This Month', 'give' ); ?></p> |
|
94 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('This Month', 'give'); ?></p> |
|
95 | 95 | </td> |
96 | 96 | </tr> |
97 | 97 | <tr id="give-table-stats-tr-2"> |
98 | 98 | <td> |
99 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'last_month' ) ) ) ?></p> |
|
99 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'last_month'))) ?></p> |
|
100 | 100 | |
101 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'Last Month', 'give' ); ?></p> |
|
101 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('Last Month', 'give'); ?></p> |
|
102 | 102 | </td> |
103 | 103 | <td> |
104 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_year', false ) ) ) ?></p> |
|
104 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_year', false))) ?></p> |
|
105 | 105 | |
106 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'This Year', 'give' ); ?></p> |
|
106 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('This Year', 'give'); ?></p> |
|
107 | 107 | </td> |
108 | 108 | </tr> |
109 | 109 | </tbody> |
@@ -123,23 +123,23 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @return array |
125 | 125 | */ |
126 | -function give_dashboard_at_a_glance_widget( $items ) { |
|
127 | - $num_posts = wp_count_posts( 'give_forms' ); |
|
126 | +function give_dashboard_at_a_glance_widget($items) { |
|
127 | + $num_posts = wp_count_posts('give_forms'); |
|
128 | 128 | |
129 | - if ( $num_posts && $num_posts->publish ) { |
|
129 | + if ($num_posts && $num_posts->publish) { |
|
130 | 130 | |
131 | 131 | $text = sprintf( |
132 | 132 | /* translators: %s: number of posts published */ |
133 | - _n( '%s Give Form', '%s Give Forms', $num_posts->publish, 'give' ), |
|
133 | + _n('%s Give Form', '%s Give Forms', $num_posts->publish, 'give'), |
|
134 | 134 | $num_posts->publish |
135 | 135 | ); |
136 | 136 | |
137 | - $text = sprintf( $text, number_format_i18n( $num_posts->publish ) ); |
|
137 | + $text = sprintf($text, number_format_i18n($num_posts->publish)); |
|
138 | 138 | |
139 | - if ( current_user_can( 'edit_give_forms', get_current_user_id() ) ) { |
|
139 | + if (current_user_can('edit_give_forms', get_current_user_id())) { |
|
140 | 140 | $text = sprintf( |
141 | 141 | '<a class="give-forms-count" href="%1$s">%2$s</a>', |
142 | - admin_url( 'edit.php?post_type=give_forms' ), |
|
142 | + admin_url('edit.php?post_type=give_forms'), |
|
143 | 143 | $text |
144 | 144 | ); |
145 | 145 | } else { |
@@ -155,4 +155,4 @@ discard block |
||
155 | 155 | return $items; |
156 | 156 | } |
157 | 157 | |
158 | -add_filter( 'dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1 ); |
|
158 | +add_filter('dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | */ |
25 | 25 | function give_customers_page() { |
26 | 26 | $default_views = give_customer_views(); |
27 | - $requested_view = isset( $_GET['view'] ) ? sanitize_text_field( $_GET['view'] ) : 'customers'; |
|
28 | - if ( array_key_exists( $requested_view, $default_views ) && function_exists( $default_views[ $requested_view ] ) ) { |
|
29 | - give_render_customer_view( $requested_view, $default_views ); |
|
27 | + $requested_view = isset($_GET['view']) ? sanitize_text_field($_GET['view']) : 'customers'; |
|
28 | + if (array_key_exists($requested_view, $default_views) && function_exists($default_views[$requested_view])) { |
|
29 | + give_render_customer_view($requested_view, $default_views); |
|
30 | 30 | } else { |
31 | 31 | give_customers_list(); |
32 | 32 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | $views = array(); |
44 | 44 | |
45 | - return apply_filters( 'give_customer_views', $views ); |
|
45 | + return apply_filters('give_customer_views', $views); |
|
46 | 46 | |
47 | 47 | } |
48 | 48 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | $tabs = array(); |
58 | 58 | |
59 | - return apply_filters( 'give_customer_tabs', $tabs ); |
|
59 | + return apply_filters('give_customer_tabs', $tabs); |
|
60 | 60 | |
61 | 61 | } |
62 | 62 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @return void |
68 | 68 | */ |
69 | 69 | function give_customers_list() { |
70 | - include( dirname( __FILE__ ) . '/class-customer-table.php' ); |
|
70 | + include(dirname(__FILE__).'/class-customer-table.php'); |
|
71 | 71 | |
72 | 72 | $customers_table = new Give_Customer_Reports_Table(); |
73 | 73 | $customers_table->prepare_items(); |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @since 1.0 |
82 | 82 | */ |
83 | - do_action( 'give_donors_table_top' ); |
|
83 | + do_action('give_donors_table_top'); |
|
84 | 84 | ?> |
85 | - <form id="give-donors-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); ?>"> |
|
85 | + <form id="give-donors-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors'); ?>"> |
|
86 | 86 | <?php |
87 | - $customers_table->search_box( esc_html__( 'Search Donors', 'give' ), 'give-donors' ); |
|
87 | + $customers_table->search_box(esc_html__('Search Donors', 'give'), 'give-donors'); |
|
88 | 88 | $customers_table->display(); |
89 | 89 | ?> |
90 | 90 | <input type="hidden" name="post_type" value="give_forms" /> |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @since 1.0 |
99 | 99 | */ |
100 | - do_action( 'give_donors_table_bottom' ); |
|
100 | + do_action('give_donors_table_bottom'); |
|
101 | 101 | ?> |
102 | 102 | </div> |
103 | 103 | <?php |
@@ -113,27 +113,27 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return void |
115 | 115 | */ |
116 | -function give_render_customer_view( $view, $callbacks ) { |
|
116 | +function give_render_customer_view($view, $callbacks) { |
|
117 | 117 | |
118 | 118 | $render = true; |
119 | 119 | |
120 | - $customer_view_role = apply_filters( 'give_view_customers_role', 'view_give_reports' ); |
|
120 | + $customer_view_role = apply_filters('give_view_customers_role', 'view_give_reports'); |
|
121 | 121 | |
122 | - if ( ! current_user_can( $customer_view_role ) ) { |
|
123 | - give_set_error( 'give-no-access', esc_html__( 'You are not permitted to view this data.', 'give' ) ); |
|
122 | + if ( ! current_user_can($customer_view_role)) { |
|
123 | + give_set_error('give-no-access', esc_html__('You are not permitted to view this data.', 'give')); |
|
124 | 124 | $render = false; |
125 | 125 | } |
126 | 126 | |
127 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
128 | - give_set_error( 'give-invalid_customer', esc_html__( 'Invalid Donor ID.', 'give' ) ); |
|
127 | + if ( ! isset($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
128 | + give_set_error('give-invalid_customer', esc_html__('Invalid Donor ID.', 'give')); |
|
129 | 129 | $render = false; |
130 | 130 | } |
131 | 131 | |
132 | 132 | $customer_id = (int) $_GET['id']; |
133 | - $customer = new Give_Customer( $customer_id ); |
|
133 | + $customer = new Give_Customer($customer_id); |
|
134 | 134 | |
135 | - if ( empty( $customer->id ) ) { |
|
136 | - give_set_error( 'give-invalid_customer', esc_html__( 'Invalid Donor ID.', 'give' ) ); |
|
135 | + if (empty($customer->id)) { |
|
136 | + give_set_error('give-invalid_customer', esc_html__('Invalid Donor ID.', 'give')); |
|
137 | 137 | $render = false; |
138 | 138 | } |
139 | 139 | |
@@ -142,34 +142,34 @@ discard block |
||
142 | 142 | |
143 | 143 | <div class='wrap'> |
144 | 144 | |
145 | - <?php if ( give_get_errors() ) : ?> |
|
145 | + <?php if (give_get_errors()) : ?> |
|
146 | 146 | <div class="error settings-error"> |
147 | - <?php give_print_errors( 0 ); ?> |
|
147 | + <?php give_print_errors(0); ?> |
|
148 | 148 | </div> |
149 | 149 | <?php endif; ?> |
150 | 150 | |
151 | - <h1 class="screen-reader-text"><?php esc_html_e( 'Donor', 'give' ); ?></h1> |
|
151 | + <h1 class="screen-reader-text"><?php esc_html_e('Donor', 'give'); ?></h1> |
|
152 | 152 | |
153 | - <?php if ( $customer && $render ) : ?> |
|
153 | + <?php if ($customer && $render) : ?> |
|
154 | 154 | |
155 | 155 | <h2 class="nav-tab-wrapper"> |
156 | 156 | <?php |
157 | - foreach ( $customer_tabs as $key => $tab ) : |
|
157 | + foreach ($customer_tabs as $key => $tab) : |
|
158 | 158 | $active = $key === $view ? true : false; |
159 | 159 | $class = $active ? 'nav-tab nav-tab-active' : 'nav-tab'; |
160 | 160 | printf( |
161 | 161 | '<a href="%1$s" class="%2$s"><span class="dashicons %3$s"></span>%4$s</a>'."\n", |
162 | - esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=' . $key . '&id=' . $customer->id ) ), |
|
163 | - esc_attr( $class ), |
|
164 | - sanitize_html_class( $tab['dashicon'] ), |
|
165 | - esc_html( $tab['title'] ) |
|
162 | + esc_url(admin_url('edit.php?post_type=give_forms&page=give-donors&view='.$key.'&id='.$customer->id)), |
|
163 | + esc_attr($class), |
|
164 | + sanitize_html_class($tab['dashicon']), |
|
165 | + esc_html($tab['title']) |
|
166 | 166 | ); |
167 | 167 | endforeach; |
168 | 168 | ?> |
169 | 169 | </h2> |
170 | 170 | |
171 | 171 | <div id="give-customer-card-wrapper"> |
172 | - <?php $callbacks[ $view ]( $customer ) ?> |
|
172 | + <?php $callbacks[$view]($customer) ?> |
|
173 | 173 | </div> |
174 | 174 | |
175 | 175 | <?php endif; ?> |
@@ -189,9 +189,9 @@ discard block |
||
189 | 189 | * |
190 | 190 | * @return void |
191 | 191 | */ |
192 | -function give_customers_view( $customer ) { |
|
192 | +function give_customers_view($customer) { |
|
193 | 193 | |
194 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
194 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
195 | 195 | |
196 | 196 | /** |
197 | 197 | * Fires in donor profile screen, above the donor card. |
@@ -200,32 +200,32 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @param object $customer The customer object being displayed. |
202 | 202 | */ |
203 | - do_action( 'give_donor_card_top', $customer ); |
|
203 | + do_action('give_donor_card_top', $customer); |
|
204 | 204 | ?> |
205 | 205 | |
206 | 206 | <div id="donor-summary" class="info-wrapper customer-section postbox"> |
207 | 207 | |
208 | - <form id="edit-customer-info" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ); ?>"> |
|
208 | + <form id="edit-customer-info" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id); ?>"> |
|
209 | 209 | |
210 | 210 | <div class="customer-info"> |
211 | 211 | |
212 | 212 | <div class="donor-bio-header clearfix"> |
213 | 213 | |
214 | 214 | <div class="avatar-wrap left" id="customer-avatar"> |
215 | - <?php echo get_avatar( $customer->email ); ?> |
|
215 | + <?php echo get_avatar($customer->email); ?> |
|
216 | 216 | </div> |
217 | 217 | |
218 | 218 | <div id="customer-name-wrap" class="left"> |
219 | 219 | <span class="customer-id">#<?php echo $customer->id; ?></span> |
220 | - <span class="customer-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr( $customer->name ); ?>" placeholder="<?php esc_attr_e( 'Donor Name', 'give' ); ?>" /></span> |
|
220 | + <span class="customer-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr($customer->name); ?>" placeholder="<?php esc_attr_e('Donor Name', 'give'); ?>" /></span> |
|
221 | 221 | <span class="customer-name info-item editable"><span data-key="name"><?php echo $customer->name; ?></span></span> |
222 | 222 | </div> |
223 | 223 | <p class="customer-since info-item"> |
224 | - <?php esc_html_e( 'Donor since', 'give' ); ?> |
|
225 | - <?php echo date_i18n( give_date_format(), strtotime( $customer->date_created ) ) ?> |
|
224 | + <?php esc_html_e('Donor since', 'give'); ?> |
|
225 | + <?php echo date_i18n(give_date_format(), strtotime($customer->date_created)) ?> |
|
226 | 226 | </p> |
227 | - <?php if ( current_user_can( $customer_edit_role ) ): ?> |
|
228 | - <a href="#" id="edit-customer" class="button info-item editable customer-edit-link"><?php esc_html_e( 'Edit Donor', 'give' ); ?></a> |
|
227 | + <?php if (current_user_can($customer_edit_role)): ?> |
|
228 | + <a href="#" id="edit-customer" class="button info-item editable customer-edit-link"><?php esc_html_e('Edit Donor', 'give'); ?></a> |
|
229 | 229 | <?php endif; ?> |
230 | 230 | </div> |
231 | 231 | <!-- /donor-bio-header --> |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | <table class="widefat"> |
236 | 236 | <tbody> |
237 | 237 | <tr class="alternate"> |
238 | - <th scope="col"><label for="tablecell"><?php esc_html_e( 'User ID:', 'give' ); ?></label></th> |
|
238 | + <th scope="col"><label for="tablecell"><?php esc_html_e('User ID:', 'give'); ?></label></th> |
|
239 | 239 | <td class="row-title"> |
240 | 240 | <span class="customer-user-id info-item edit-item"> |
241 | 241 | <?php |
@@ -251,38 +251,38 @@ discard block |
||
251 | 251 | 'data' => $data_atts, |
252 | 252 | ); |
253 | 253 | |
254 | - if ( ! empty( $user_id ) ) { |
|
255 | - $userdata = get_userdata( $user_id ); |
|
254 | + if ( ! empty($user_id)) { |
|
255 | + $userdata = get_userdata($user_id); |
|
256 | 256 | $user_args['value'] = $userdata->user_login; |
257 | 257 | } |
258 | 258 | |
259 | - echo Give()->html->ajax_user_search( $user_args ); |
|
259 | + echo Give()->html->ajax_user_search($user_args); |
|
260 | 260 | ?> |
261 | 261 | <input type="hidden" name="customerinfo[user_id]" data-key="user_id" value="<?php echo $customer->user_id; ?>" /> |
262 | 262 | </span> |
263 | 263 | |
264 | 264 | <span class="customer-user-id info-item editable"> |
265 | - <?php if ( intval( $customer->user_id ) > 0 ) { ?> |
|
265 | + <?php if (intval($customer->user_id) > 0) { ?> |
|
266 | 266 | <span data-key="user_id"><?php echo $customer->user_id; ?></span> |
267 | 267 | <?php } else { ?> |
268 | - <span data-key="user_id"><?php esc_html_e( 'None', 'give' ); ?></span> |
|
268 | + <span data-key="user_id"><?php esc_html_e('None', 'give'); ?></span> |
|
269 | 269 | <?php } ?> |
270 | - <?php if ( current_user_can( $customer_edit_role ) && intval( $customer->user_id ) > 0 ) { ?> |
|
271 | - <span class="disconnect-user"> - <a id="disconnect-customer" href="#disconnect" aria-label="<?php esc_attr_e( 'Disconnects the current user ID from this customer record.', 'give' ); ?>"><?php esc_html_e( 'Disconnect User', 'give' ); ?></a></span> |
|
270 | + <?php if (current_user_can($customer_edit_role) && intval($customer->user_id) > 0) { ?> |
|
271 | + <span class="disconnect-user"> - <a id="disconnect-customer" href="#disconnect" aria-label="<?php esc_attr_e('Disconnects the current user ID from this customer record.', 'give'); ?>"><?php esc_html_e('Disconnect User', 'give'); ?></a></span> |
|
272 | 272 | <?php } ?> |
273 | 273 | </span> |
274 | 274 | </td> |
275 | 275 | </tr> |
276 | - <?php if ( isset( $customer->user_id ) && $customer->user_id > 0 ) : ?> |
|
276 | + <?php if (isset($customer->user_id) && $customer->user_id > 0) : ?> |
|
277 | 277 | |
278 | 278 | <tr> |
279 | - <th scope="col"><?php esc_html_e( 'Address:', 'give' ); ?></th> |
|
279 | + <th scope="col"><?php esc_html_e('Address:', 'give'); ?></th> |
|
280 | 280 | <td class="row-title"> |
281 | 281 | |
282 | 282 | <div class="customer-address-wrapper"> |
283 | 283 | |
284 | 284 | <?php |
285 | - $address = get_user_meta( $customer->user_id, '_give_user_address', true ); |
|
285 | + $address = get_user_meta($customer->user_id, '_give_user_address', true); |
|
286 | 286 | $defaults = array( |
287 | 287 | 'line1' => '', |
288 | 288 | 'line2' => '', |
@@ -292,10 +292,10 @@ discard block |
||
292 | 292 | 'zip' => '' |
293 | 293 | ); |
294 | 294 | |
295 | - $address = wp_parse_args( $address, $defaults ); |
|
295 | + $address = wp_parse_args($address, $defaults); |
|
296 | 296 | ?> |
297 | 297 | |
298 | - <?php if ( ! empty( $address ) ) { ?> |
|
298 | + <?php if ( ! empty($address)) { ?> |
|
299 | 299 | <span class="customer-address info-item editable"> |
300 | 300 | <span class="info-item" data-key="line1"><?php echo $address['line1']; ?></span> |
301 | 301 | <span class="info-item" data-key="line2"><?php echo $address['line2']; ?></span> |
@@ -306,43 +306,43 @@ discard block |
||
306 | 306 | </span> |
307 | 307 | <?php } ?> |
308 | 308 | <span class="customer-address info-item edit-item"> |
309 | - <input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php esc_attr_e( 'Address 1', 'give' ); ?>" value="<?php echo $address['line1']; ?>" /> |
|
310 | - <input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php esc_attr_e( 'Address 2', 'give' ); ?>" value="<?php echo $address['line2']; ?>" /> |
|
311 | - <input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php esc_attr_e( 'City', 'give' ); ?>" value="<?php echo $address['city']; ?>" /> |
|
309 | + <input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php esc_attr_e('Address 1', 'give'); ?>" value="<?php echo $address['line1']; ?>" /> |
|
310 | + <input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php esc_attr_e('Address 2', 'give'); ?>" value="<?php echo $address['line2']; ?>" /> |
|
311 | + <input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php esc_attr_e('City', 'give'); ?>" value="<?php echo $address['city']; ?>" /> |
|
312 | 312 | <select data-key="country" name="customerinfo[country]" id="billing_country" class="billing_country give-select edit-item"> |
313 | 313 | <?php |
314 | 314 | |
315 | 315 | $selected_country = $address['country']; |
316 | 316 | |
317 | 317 | $countries = give_get_country_list(); |
318 | - foreach ( $countries as $country_code => $country ) { |
|
319 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
318 | + foreach ($countries as $country_code => $country) { |
|
319 | + echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>'; |
|
320 | 320 | } |
321 | 321 | ?> |
322 | 322 | </select> |
323 | 323 | <?php |
324 | 324 | $selected_state = give_get_state(); |
325 | - $states = give_get_states( $selected_country ); |
|
325 | + $states = give_get_states($selected_country); |
|
326 | 326 | |
327 | - $selected_state = isset( $address['state'] ) ? $address['state'] : $selected_state; |
|
327 | + $selected_state = isset($address['state']) ? $address['state'] : $selected_state; |
|
328 | 328 | |
329 | - if ( ! empty( $states ) ) { |
|
329 | + if ( ! empty($states)) { |
|
330 | 330 | ?> |
331 | 331 | <select data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-select info-item"> |
332 | 332 | <?php |
333 | - foreach ( $states as $state_code => $state ) { |
|
334 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
333 | + foreach ($states as $state_code => $state) { |
|
334 | + echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>'; |
|
335 | 335 | } |
336 | 336 | ?> |
337 | 337 | </select> |
338 | 338 | <?php |
339 | 339 | } else { |
340 | 340 | ?> |
341 | - <input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php esc_attr_e( 'State / Province', 'give' ); ?>" /> |
|
341 | + <input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php esc_attr_e('State / Province', 'give'); ?>" /> |
|
342 | 342 | <?php |
343 | 343 | } |
344 | 344 | ?> |
345 | - <input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php esc_attr_e( 'Zip / Postal Code', 'give' ); ?>" value="<?php echo $address['zip']; ?>" /> |
|
345 | + <input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php esc_attr_e('Zip / Postal Code', 'give'); ?>" value="<?php echo $address['zip']; ?>" /> |
|
346 | 346 | </span> |
347 | 347 | |
348 | 348 | </div> |
@@ -358,10 +358,10 @@ discard block |
||
358 | 358 | |
359 | 359 | <span id="customer-edit-actions" class="edit-item"> |
360 | 360 | <input type="hidden" data-key="id" name="customerinfo[id]" value="<?php echo $customer->id; ?>" /> |
361 | - <?php wp_nonce_field( 'edit-customer', '_wpnonce', false, true ); ?> |
|
361 | + <?php wp_nonce_field('edit-customer', '_wpnonce', false, true); ?> |
|
362 | 362 | <input type="hidden" name="give_action" value="edit-customer" /> |
363 | - <input type="submit" id="give-edit-customer-save" class="button-secondary" value="<?php esc_attr_e( 'Update Donor', 'give' ); ?>" /> |
|
364 | - <a id="give-edit-customer-cancel" href="" class="delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a> |
|
363 | + <input type="submit" id="give-edit-customer-save" class="button-secondary" value="<?php esc_attr_e('Update Donor', 'give'); ?>" /> |
|
364 | + <a id="give-edit-customer-cancel" href="" class="delete"><?php esc_html_e('Cancel', 'give'); ?></a> |
|
365 | 365 | </span> |
366 | 366 | |
367 | 367 | </form> |
@@ -376,24 +376,24 @@ discard block |
||
376 | 376 | * |
377 | 377 | * @param object $customer The customer object being displayed. |
378 | 378 | */ |
379 | - do_action( 'give_donor_before_stats', $customer ); |
|
379 | + do_action('give_donor_before_stats', $customer); |
|
380 | 380 | ?> |
381 | 381 | |
382 | 382 | <div id="customer-stats-wrapper" class="customer-section postbox clear"> |
383 | 383 | <ul> |
384 | 384 | <li> |
385 | - <a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $customer->email ) ); ?>"> |
|
385 | + <a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.urlencode($customer->email)); ?>"> |
|
386 | 386 | <span class="dashicons dashicons-heart"></span> |
387 | 387 | <?php |
388 | 388 | //Completed Donations |
389 | - $completed_donations_text = sprintf( _n( '%d Completed Donation', '%d Completed Donations', $customer->purchase_count, 'give' ), $customer->purchase_count ); |
|
390 | - echo apply_filters( 'give_donor_completed_donations', $completed_donations_text, $customer ); |
|
389 | + $completed_donations_text = sprintf(_n('%d Completed Donation', '%d Completed Donations', $customer->purchase_count, 'give'), $customer->purchase_count); |
|
390 | + echo apply_filters('give_donor_completed_donations', $completed_donations_text, $customer); |
|
391 | 391 | ?> |
392 | 392 | </a> |
393 | 393 | </li> |
394 | 394 | <li> |
395 | 395 | <span class="dashicons dashicons-chart-area"></span> |
396 | - <?php echo give_currency_filter( give_format_amount( $customer->purchase_value ) ); ?> <?php esc_html_e( 'Lifetime Donations', 'give' ); ?> |
|
396 | + <?php echo give_currency_filter(give_format_amount($customer->purchase_value)); ?> <?php esc_html_e('Lifetime Donations', 'give'); ?> |
|
397 | 397 | </li> |
398 | 398 | <?php |
399 | 399 | /** |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | * |
406 | 406 | * @param object $customer The customer object being displayed. |
407 | 407 | */ |
408 | - do_action( 'give_donor_stats_list', $customer ); |
|
408 | + do_action('give_donor_stats_list', $customer); |
|
409 | 409 | ?> |
410 | 410 | </ul> |
411 | 411 | </div> |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * |
419 | 419 | * @param object $customer The customer object being displayed. |
420 | 420 | */ |
421 | - do_action( 'give_donor_before_tables_wrapper', $customer ); |
|
421 | + do_action('give_donor_before_tables_wrapper', $customer); |
|
422 | 422 | ?> |
423 | 423 | |
424 | 424 | <div id="customer-tables-wrapper" class="customer-section"> |
@@ -431,40 +431,40 @@ discard block |
||
431 | 431 | * |
432 | 432 | * @param object $customer The customer object being displayed. |
433 | 433 | */ |
434 | - do_action( 'give_donor_before_tables', $customer ); |
|
434 | + do_action('give_donor_before_tables', $customer); |
|
435 | 435 | ?> |
436 | 436 | |
437 | - <h3><?php _e( 'Donor Emails', 'give' ); ?></h3> |
|
437 | + <h3><?php _e('Donor Emails', 'give'); ?></h3> |
|
438 | 438 | |
439 | 439 | <table class="wp-list-table widefat striped emails"> |
440 | 440 | <thead> |
441 | 441 | <tr> |
442 | - <th><?php _e( 'Email', 'give' ); ?></th> |
|
443 | - <th><?php _e( 'Actions', 'give' ); ?></th> |
|
442 | + <th><?php _e('Email', 'give'); ?></th> |
|
443 | + <th><?php _e('Actions', 'give'); ?></th> |
|
444 | 444 | </tr> |
445 | 445 | </thead> |
446 | 446 | |
447 | 447 | <tbody> |
448 | - <?php if ( ! empty( $customer->emails ) ) { ?> |
|
448 | + <?php if ( ! empty($customer->emails)) { ?> |
|
449 | 449 | |
450 | - <?php foreach ( $customer->emails as $key => $email ) : ?> |
|
450 | + <?php foreach ($customer->emails as $key => $email) : ?> |
|
451 | 451 | <tr data-key="<?php echo $key; ?>"> |
452 | 452 | <td> |
453 | 453 | <?php echo $email; ?> |
454 | - <?php if ( 'primary' === $key ) : ?> |
|
454 | + <?php if ('primary' === $key) : ?> |
|
455 | 455 | <span class="dashicons dashicons-star-filled primary-email-icon"></span> |
456 | 456 | <?php endif; ?> |
457 | 457 | </td> |
458 | 458 | <td> |
459 | - <?php if ( 'primary' !== $key ) : ?> |
|
459 | + <?php if ('primary' !== $key) : ?> |
|
460 | 460 | <?php |
461 | - $base_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ); |
|
462 | - $promote_url = wp_nonce_url( add_query_arg( array( 'email' => rawurlencode( $email ), 'give_action' => 'set_donor_primary_email'), $base_url ), 'give-set-donor-primary-email' ); |
|
463 | - $remove_url = wp_nonce_url( add_query_arg( array( 'email' => rawurlencode( $email ), 'give_action' => 'remove_donor_email' ), $base_url ), 'give-remove-donor-email' ); |
|
461 | + $base_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id); |
|
462 | + $promote_url = wp_nonce_url(add_query_arg(array('email' => rawurlencode($email), 'give_action' => 'set_donor_primary_email'), $base_url), 'give-set-donor-primary-email'); |
|
463 | + $remove_url = wp_nonce_url(add_query_arg(array('email' => rawurlencode($email), 'give_action' => 'remove_donor_email'), $base_url), 'give-remove-donor-email'); |
|
464 | 464 | ?> |
465 | - <a href="<?php echo $promote_url; ?>"><?php _e( 'Make Primary', 'give' ); ?></a> |
|
465 | + <a href="<?php echo $promote_url; ?>"><?php _e('Make Primary', 'give'); ?></a> |
|
466 | 466 | | |
467 | - <a href="<?php echo $remove_url; ?>" class="delete"><?php _e( 'Remove', 'give' ); ?></a> |
|
467 | + <a href="<?php echo $remove_url; ?>" class="delete"><?php _e('Remove', 'give'); ?></a> |
|
468 | 468 | <?php endif; ?> |
469 | 469 | </td> |
470 | 470 | </tr> |
@@ -474,56 +474,56 @@ discard block |
||
474 | 474 | <td colspan="2" class="add-customer-email-td"> |
475 | 475 | <div class="add-customer-email-wrapper"> |
476 | 476 | <input type="hidden" name="customer-id" value="<?php echo $customer->id; ?>" /> |
477 | - <?php wp_nonce_field( 'give_add_donor_email', 'add_email_nonce', false, true ); ?> |
|
478 | - <input type="email" name="additional-email" value="" placeholder="<?php _e( 'Email Address', 'give' ); ?>" /> |
|
479 | - <input type="checkbox" name="make-additional-primary" value="1" id="make-additional-primary" /> <label for="make-additional-primary"><?php _e( 'Make Primary', 'give' ); ?></label> |
|
480 | - <button class="button-secondary give-add-customer-email" id="add-customer-email"><?php _e( 'Add Email', 'give' ); ?></button> |
|
477 | + <?php wp_nonce_field('give_add_donor_email', 'add_email_nonce', false, true); ?> |
|
478 | + <input type="email" name="additional-email" value="" placeholder="<?php _e('Email Address', 'give'); ?>" /> |
|
479 | + <input type="checkbox" name="make-additional-primary" value="1" id="make-additional-primary" /> <label for="make-additional-primary"><?php _e('Make Primary', 'give'); ?></label> |
|
480 | + <button class="button-secondary give-add-customer-email" id="add-customer-email"><?php _e('Add Email', 'give'); ?></button> |
|
481 | 481 | <span class="spinner"></span> |
482 | 482 | </div> |
483 | 483 | <div class="notice-wrap"></div> |
484 | 484 | </td> |
485 | 485 | </tr> |
486 | 486 | <?php } else { ?> |
487 | - <tr><td colspan="2"><?php _e( 'No Emails Found', 'easy-digital-downloads' ); ?></td></tr> |
|
487 | + <tr><td colspan="2"><?php _e('No Emails Found', 'easy-digital-downloads'); ?></td></tr> |
|
488 | 488 | <?php } ?> |
489 | 489 | </tbody> |
490 | 490 | </table> |
491 | 491 | |
492 | - <h3><?php esc_html_e( 'Recent Donations', 'give' ); ?></h3> |
|
492 | + <h3><?php esc_html_e('Recent Donations', 'give'); ?></h3> |
|
493 | 493 | <?php |
494 | - $payment_ids = explode( ',', $customer->payment_ids ); |
|
495 | - $payments = give_get_payments( array( 'post__in' => $payment_ids ) ); |
|
496 | - $payments = array_slice( $payments, 0, 10 ); |
|
494 | + $payment_ids = explode(',', $customer->payment_ids); |
|
495 | + $payments = give_get_payments(array('post__in' => $payment_ids)); |
|
496 | + $payments = array_slice($payments, 0, 10); |
|
497 | 497 | ?> |
498 | 498 | <table class="wp-list-table widefat striped payments"> |
499 | 499 | <thead> |
500 | 500 | <tr> |
501 | - <th scope="col"><?php esc_html_e( 'ID', 'give' ); ?></th> |
|
502 | - <th scope="col"><?php esc_html_e( 'Amount', 'give' ); ?></th> |
|
503 | - <th scope="col"><?php esc_html_e( 'Date', 'give' ); ?></th> |
|
504 | - <th scope="col"><?php esc_html_e( 'Status', 'give' ); ?></th> |
|
505 | - <th scope="col"><?php esc_html_e( 'Actions', 'give' ); ?></th> |
|
501 | + <th scope="col"><?php esc_html_e('ID', 'give'); ?></th> |
|
502 | + <th scope="col"><?php esc_html_e('Amount', 'give'); ?></th> |
|
503 | + <th scope="col"><?php esc_html_e('Date', 'give'); ?></th> |
|
504 | + <th scope="col"><?php esc_html_e('Status', 'give'); ?></th> |
|
505 | + <th scope="col"><?php esc_html_e('Actions', 'give'); ?></th> |
|
506 | 506 | </tr> |
507 | 507 | </thead> |
508 | 508 | <tbody> |
509 | - <?php if ( ! empty( $payments ) ) { ?> |
|
510 | - <?php foreach ( $payments as $payment ) : ?> |
|
509 | + <?php if ( ! empty($payments)) { ?> |
|
510 | + <?php foreach ($payments as $payment) : ?> |
|
511 | 511 | <tr> |
512 | 512 | <td><?php echo $payment->ID; ?></td> |
513 | - <td><?php echo give_payment_amount( $payment->ID ); ?></td> |
|
514 | - <td><?php echo date_i18n( give_date_format(), strtotime( $payment->post_date ) ); ?></td> |
|
515 | - <td><?php echo give_get_payment_status( $payment, true ); ?></td> |
|
513 | + <td><?php echo give_payment_amount($payment->ID); ?></td> |
|
514 | + <td><?php echo date_i18n(give_date_format(), strtotime($payment->post_date)); ?></td> |
|
515 | + <td><?php echo give_get_payment_status($payment, true); ?></td> |
|
516 | 516 | <td> |
517 | 517 | <?php |
518 | 518 | printf( |
519 | 519 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
520 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment->ID ), |
|
520 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$payment->ID), |
|
521 | 521 | sprintf( |
522 | 522 | /* translators: %s: Donation ID */ |
523 | - esc_attr__( 'View Donation %s.', 'give' ), |
|
523 | + esc_attr__('View Donation %s.', 'give'), |
|
524 | 524 | $payment->ID |
525 | 525 | ), |
526 | - esc_html__( 'View Donation', 'give' ) |
|
526 | + esc_html__('View Donation', 'give') |
|
527 | 527 | ); |
528 | 528 | ?> |
529 | 529 | |
@@ -538,46 +538,46 @@ discard block |
||
538 | 538 | * @param object $customer The customer object being displayed. |
539 | 539 | * @param object $payment The payment object being displayed. |
540 | 540 | */ |
541 | - do_action( 'give_donor_recent_purchases_actions', $customer, $payment ); |
|
541 | + do_action('give_donor_recent_purchases_actions', $customer, $payment); |
|
542 | 542 | ?> |
543 | 543 | </td> |
544 | 544 | </tr> |
545 | 545 | <?php endforeach; ?> |
546 | 546 | <?php } else { ?> |
547 | 547 | <tr> |
548 | - <td colspan="5"><?php esc_html_e( 'No donations found.', 'give' ); ?></td> |
|
548 | + <td colspan="5"><?php esc_html_e('No donations found.', 'give'); ?></td> |
|
549 | 549 | </tr> |
550 | 550 | <?php } ?> |
551 | 551 | </tbody> |
552 | 552 | </table> |
553 | 553 | |
554 | - <h3><?php esc_html_e( 'Completed Forms', 'give' ); ?></h3> |
|
554 | + <h3><?php esc_html_e('Completed Forms', 'give'); ?></h3> |
|
555 | 555 | <?php |
556 | - $donations = give_get_users_completed_donations( $customer->email ); |
|
556 | + $donations = give_get_users_completed_donations($customer->email); |
|
557 | 557 | ?> |
558 | 558 | <table class="wp-list-table widefat striped donations"> |
559 | 559 | <thead> |
560 | 560 | <tr> |
561 | - <th scope="col"><?php esc_html_e( 'Form', 'give' ); ?></th> |
|
562 | - <th scope="col" width="120px"><?php esc_html_e( 'Actions', 'give' ); ?></th> |
|
561 | + <th scope="col"><?php esc_html_e('Form', 'give'); ?></th> |
|
562 | + <th scope="col" width="120px"><?php esc_html_e('Actions', 'give'); ?></th> |
|
563 | 563 | </tr> |
564 | 564 | </thead> |
565 | 565 | <tbody> |
566 | - <?php if ( ! empty( $donations ) ) { ?> |
|
567 | - <?php foreach ( $donations as $donation ) : ?> |
|
566 | + <?php if ( ! empty($donations)) { ?> |
|
567 | + <?php foreach ($donations as $donation) : ?> |
|
568 | 568 | <tr> |
569 | 569 | <td><?php echo $donation->post_title; ?></td> |
570 | 570 | <td> |
571 | 571 | <?php |
572 | 572 | printf( |
573 | 573 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
574 | - esc_url( admin_url( 'post.php?action=edit&post=' . $donation->ID ) ), |
|
574 | + esc_url(admin_url('post.php?action=edit&post='.$donation->ID)), |
|
575 | 575 | sprintf( |
576 | 576 | /* translators: %s: form name */ |
577 | - esc_attr__( 'View Form %s.', 'give' ), |
|
577 | + esc_attr__('View Form %s.', 'give'), |
|
578 | 578 | $donation->post_title |
579 | 579 | ), |
580 | - esc_html__( 'View Form', 'give' ) |
|
580 | + esc_html__('View Form', 'give') |
|
581 | 581 | ); |
582 | 582 | ?> |
583 | 583 | </td> |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | <?php endforeach; ?> |
586 | 586 | <?php } else { ?> |
587 | 587 | <tr> |
588 | - <td colspan="2"><?php esc_html_e( 'No completed donations found.', 'give' ); ?></td> |
|
588 | + <td colspan="2"><?php esc_html_e('No completed donations found.', 'give'); ?></td> |
|
589 | 589 | </tr> |
590 | 590 | <?php } ?> |
591 | 591 | </tbody> |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | * |
600 | 600 | * @param object $customer The customer object being displayed. |
601 | 601 | */ |
602 | - do_action( 'give_donor_after_tables', $customer ); |
|
602 | + do_action('give_donor_after_tables', $customer); |
|
603 | 603 | ?> |
604 | 604 | |
605 | 605 | </div> |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | * |
613 | 613 | * @param object $customer The customer object being displayed. |
614 | 614 | */ |
615 | - do_action( 'give_donor_card_bottom', $customer ); |
|
615 | + do_action('give_donor_card_bottom', $customer); |
|
616 | 616 | |
617 | 617 | } |
618 | 618 | |
@@ -625,30 +625,30 @@ discard block |
||
625 | 625 | * |
626 | 626 | * @return void |
627 | 627 | */ |
628 | -function give_customer_notes_view( $customer ) { |
|
628 | +function give_customer_notes_view($customer) { |
|
629 | 629 | |
630 | - $paged = isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) ? $_GET['paged'] : 1; |
|
631 | - $paged = absint( $paged ); |
|
630 | + $paged = isset($_GET['paged']) && is_numeric($_GET['paged']) ? $_GET['paged'] : 1; |
|
631 | + $paged = absint($paged); |
|
632 | 632 | $note_count = $customer->get_notes_count(); |
633 | - $per_page = apply_filters( 'give_customer_notes_per_page', 20 ); |
|
634 | - $total_pages = ceil( $note_count / $per_page ); |
|
635 | - $customer_notes = $customer->get_notes( $per_page, $paged ); |
|
633 | + $per_page = apply_filters('give_customer_notes_per_page', 20); |
|
634 | + $total_pages = ceil($note_count / $per_page); |
|
635 | + $customer_notes = $customer->get_notes($per_page, $paged); |
|
636 | 636 | ?> |
637 | 637 | |
638 | 638 | <div id="customer-notes-wrapper"> |
639 | 639 | <div class="customer-notes-header"> |
640 | - <?php echo get_avatar( $customer->email, 30 ); ?> <span><?php echo $customer->name; ?></span> |
|
640 | + <?php echo get_avatar($customer->email, 30); ?> <span><?php echo $customer->name; ?></span> |
|
641 | 641 | </div> |
642 | - <h3><?php esc_html_e( 'Notes', 'give' ); ?></h3> |
|
642 | + <h3><?php esc_html_e('Notes', 'give'); ?></h3> |
|
643 | 643 | |
644 | - <?php if ( 1 == $paged ) : ?> |
|
644 | + <?php if (1 == $paged) : ?> |
|
645 | 645 | <div style="display: block; margin-bottom: 55px;"> |
646 | - <form id="give-add-customer-note" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $customer->id ); ?>"> |
|
646 | + <form id="give-add-customer-note" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$customer->id); ?>"> |
|
647 | 647 | <textarea id="customer-note" name="customer_note" class="customer-note-input" rows="10"></textarea> |
648 | 648 | <br /> |
649 | 649 | <input type="hidden" id="customer-id" name="customer_id" value="<?php echo $customer->id; ?>" /> |
650 | 650 | <input type="hidden" name="give_action" value="add-customer-note" /> |
651 | - <?php wp_nonce_field( 'add-customer-note', 'add_customer_note_nonce', true, true ); ?> |
|
651 | + <?php wp_nonce_field('add-customer-note', 'add_customer_note_nonce', true, true); ?> |
|
652 | 652 | <input id="add-customer-note" class="right button-primary" type="submit" value="Add Note" /> |
653 | 653 | </form> |
654 | 654 | </div> |
@@ -663,26 +663,26 @@ discard block |
||
663 | 663 | 'show_all' => true |
664 | 664 | ); |
665 | 665 | |
666 | - echo paginate_links( $pagination_args ); |
|
666 | + echo paginate_links($pagination_args); |
|
667 | 667 | ?> |
668 | 668 | |
669 | 669 | <div id="give-customer-notes" class="postbox"> |
670 | - <?php if ( count( $customer_notes ) > 0 ) { ?> |
|
671 | - <?php foreach ( $customer_notes as $key => $note ) : ?> |
|
670 | + <?php if (count($customer_notes) > 0) { ?> |
|
671 | + <?php foreach ($customer_notes as $key => $note) : ?> |
|
672 | 672 | <div class="customer-note-wrapper dashboard-comment-wrap comment-item"> |
673 | 673 | <span class="note-content-wrap"> |
674 | - <?php echo stripslashes( $note ); ?> |
|
674 | + <?php echo stripslashes($note); ?> |
|
675 | 675 | </span> |
676 | 676 | </div> |
677 | 677 | <?php endforeach; ?> |
678 | 678 | <?php } else { ?> |
679 | 679 | <div class="give-no-customer-notes"> |
680 | - <?php esc_html_e( 'No donor notes found.', 'give' ); ?> |
|
680 | + <?php esc_html_e('No donor notes found.', 'give'); ?> |
|
681 | 681 | </div> |
682 | 682 | <?php } ?> |
683 | 683 | </div> |
684 | 684 | |
685 | - <?php echo paginate_links( $pagination_args ); ?> |
|
685 | + <?php echo paginate_links($pagination_args); ?> |
|
686 | 686 | |
687 | 687 | </div> |
688 | 688 | |
@@ -698,9 +698,9 @@ discard block |
||
698 | 698 | * |
699 | 699 | * @return void |
700 | 700 | */ |
701 | -function give_customers_delete_view( $customer ) { |
|
701 | +function give_customers_delete_view($customer) { |
|
702 | 702 | |
703 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
703 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
704 | 704 | |
705 | 705 | /** |
706 | 706 | * Fires in donor delete screen, above the content. |
@@ -709,15 +709,15 @@ discard block |
||
709 | 709 | * |
710 | 710 | * @param object $customer The customer object being displayed. |
711 | 711 | */ |
712 | - do_action( 'give_customer_delete_top', $customer ); |
|
712 | + do_action('give_customer_delete_top', $customer); |
|
713 | 713 | ?> |
714 | 714 | |
715 | 715 | <div class="info-wrapper customer-section"> |
716 | 716 | |
717 | - <form id="delete-customer" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $customer->id ); ?>"> |
|
717 | + <form id="delete-customer" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$customer->id); ?>"> |
|
718 | 718 | |
719 | 719 | <div class="customer-notes-header"> |
720 | - <?php echo get_avatar( $customer->email, 30 ); ?> <span><?php echo $customer->name; ?></span> |
|
720 | + <?php echo get_avatar($customer->email, 30); ?> <span><?php echo $customer->name; ?></span> |
|
721 | 721 | </div> |
722 | 722 | |
723 | 723 | |
@@ -725,16 +725,16 @@ discard block |
||
725 | 725 | |
726 | 726 | <span class="delete-customer-options"> |
727 | 727 | <p> |
728 | - <?php echo Give()->html->checkbox( array( 'name' => 'give-customer-delete-confirm' ) ); ?> |
|
729 | - <label for="give-customer-delete-confirm"><?php esc_html_e( 'Are you sure you want to delete this donor?', 'give' ); ?></label> |
|
728 | + <?php echo Give()->html->checkbox(array('name' => 'give-customer-delete-confirm')); ?> |
|
729 | + <label for="give-customer-delete-confirm"><?php esc_html_e('Are you sure you want to delete this donor?', 'give'); ?></label> |
|
730 | 730 | </p> |
731 | 731 | |
732 | 732 | <p> |
733 | - <?php echo Give()->html->checkbox( array( |
|
733 | + <?php echo Give()->html->checkbox(array( |
|
734 | 734 | 'name' => 'give-customer-delete-records', |
735 | - 'options' => array( 'disabled' => true ) |
|
736 | - ) ); ?> |
|
737 | - <label for="give-customer-delete-records"><?php esc_html_e( 'Delete all associated donations and records?', 'give' ); ?></label> |
|
735 | + 'options' => array('disabled' => true) |
|
736 | + )); ?> |
|
737 | + <label for="give-customer-delete-records"><?php esc_html_e('Delete all associated donations and records?', 'give'); ?></label> |
|
738 | 738 | </p> |
739 | 739 | |
740 | 740 | <?php |
@@ -747,16 +747,16 @@ discard block |
||
747 | 747 | * |
748 | 748 | * @param object $customer The customer object being displayed. |
749 | 749 | */ |
750 | - do_action( 'give_customer_delete_inputs', $customer ); |
|
750 | + do_action('give_customer_delete_inputs', $customer); |
|
751 | 751 | ?> |
752 | 752 | </span> |
753 | 753 | |
754 | 754 | <span id="customer-edit-actions"> |
755 | 755 | <input type="hidden" name="customer_id" value="<?php echo $customer->id; ?>" /> |
756 | - <?php wp_nonce_field( 'delete-customer', '_wpnonce', false, true ); ?> |
|
756 | + <?php wp_nonce_field('delete-customer', '_wpnonce', false, true); ?> |
|
757 | 757 | <input type="hidden" name="give_action" value="delete-customer" /> |
758 | - <input type="submit" disabled="disabled" id="give-delete-customer" class="button-primary" value="<?php esc_attr_e( 'Delete Donor', 'give' ); ?>" /> |
|
759 | - <a id="give-delete-customer-cancel" href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ); ?>" class="delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a> |
|
758 | + <input type="submit" disabled="disabled" id="give-delete-customer" class="button-primary" value="<?php esc_attr_e('Delete Donor', 'give'); ?>" /> |
|
759 | + <a id="give-delete-customer-cancel" href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id); ?>" class="delete"><?php esc_html_e('Cancel', 'give'); ?></a> |
|
760 | 760 | </span> |
761 | 761 | |
762 | 762 | </div> |
@@ -772,5 +772,5 @@ discard block |
||
772 | 772 | * |
773 | 773 | * @param object $customer The customer object being displayed. |
774 | 774 | */ |
775 | - do_action( 'give_customer_delete_bottom', $customer ); |
|
775 | + do_action('give_customer_delete_bottom', $customer); |
|
776 | 776 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -25,52 +25,52 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @return void |
27 | 27 | */ |
28 | -function give_update_payment_details( $data ) { |
|
28 | +function give_update_payment_details($data) { |
|
29 | 29 | |
30 | - if ( ! current_user_can( 'edit_give_payments', $data['give_payment_id'] ) ) { |
|
31 | - wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
30 | + if ( ! current_user_can('edit_give_payments', $data['give_payment_id'])) { |
|
31 | + wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
32 | 32 | } |
33 | 33 | |
34 | - check_admin_referer( 'give_update_payment_details_nonce' ); |
|
34 | + check_admin_referer('give_update_payment_details_nonce'); |
|
35 | 35 | |
36 | 36 | // Retrieve the payment ID. |
37 | - $payment_id = absint( $data['give_payment_id'] ); |
|
37 | + $payment_id = absint($data['give_payment_id']); |
|
38 | 38 | |
39 | 39 | /* @var Give_Payment $payment */ |
40 | - $payment = new Give_Payment( $payment_id ); |
|
40 | + $payment = new Give_Payment($payment_id); |
|
41 | 41 | |
42 | 42 | // Retrieve existing payment meta. |
43 | 43 | $meta = $payment->get_meta(); |
44 | 44 | $user_info = $payment->user_info; |
45 | 45 | |
46 | 46 | $status = $data['give-payment-status']; |
47 | - $date = sanitize_text_field( $data['give-payment-date'] ); |
|
48 | - $hour = sanitize_text_field( $data['give-payment-time-hour'] ); |
|
47 | + $date = sanitize_text_field($data['give-payment-date']); |
|
48 | + $hour = sanitize_text_field($data['give-payment-time-hour']); |
|
49 | 49 | |
50 | 50 | // Restrict to our high and low. |
51 | - if ( $hour > 23 ) { |
|
51 | + if ($hour > 23) { |
|
52 | 52 | $hour = 23; |
53 | - } elseif ( $hour < 0 ) { |
|
53 | + } elseif ($hour < 0) { |
|
54 | 54 | $hour = 00; |
55 | 55 | } |
56 | 56 | |
57 | - $minute = sanitize_text_field( $data['give-payment-time-min'] ); |
|
57 | + $minute = sanitize_text_field($data['give-payment-time-min']); |
|
58 | 58 | |
59 | 59 | // Restrict to our high and low. |
60 | - if ( $minute > 59 ) { |
|
60 | + if ($minute > 59) { |
|
61 | 61 | $minute = 59; |
62 | - } elseif ( $minute < 0 ) { |
|
62 | + } elseif ($minute < 0) { |
|
63 | 63 | $minute = 00; |
64 | 64 | } |
65 | 65 | |
66 | - $address = array_map( 'trim', $data['give-payment-address'][0] ); |
|
66 | + $address = array_map('trim', $data['give-payment-address'][0]); |
|
67 | 67 | |
68 | - $curr_total = give_sanitize_amount( $payment->total ); |
|
69 | - $new_total = give_sanitize_amount( $data['give-payment-total'] ); |
|
70 | - $date = date( 'Y-m-d', strtotime( $date ) ) . ' ' . $hour . ':' . $minute . ':00'; |
|
68 | + $curr_total = give_sanitize_amount($payment->total); |
|
69 | + $new_total = give_sanitize_amount($data['give-payment-total']); |
|
70 | + $date = date('Y-m-d', strtotime($date)).' '.$hour.':'.$minute.':00'; |
|
71 | 71 | |
72 | - $curr_customer_id = sanitize_text_field( $data['give-current-customer'] ); |
|
73 | - $new_customer_id = sanitize_text_field( $data['customer-id'] ); |
|
72 | + $curr_customer_id = sanitize_text_field($data['give-current-customer']); |
|
73 | + $new_customer_id = sanitize_text_field($data['customer-id']); |
|
74 | 74 | |
75 | 75 | /** |
76 | 76 | * Fires before updating edited donation. |
@@ -79,98 +79,98 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @param int $payment_id The ID of the payment. |
81 | 81 | */ |
82 | - do_action( 'give_update_edited_purchase', $payment_id ); |
|
82 | + do_action('give_update_edited_purchase', $payment_id); |
|
83 | 83 | |
84 | 84 | $payment->date = $date; |
85 | 85 | $updated = $payment->save(); |
86 | 86 | |
87 | - if ( 0 === $updated ) { |
|
88 | - wp_die( esc_html__( 'Error Updating Donation.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
87 | + if (0 === $updated) { |
|
88 | + wp_die(esc_html__('Error Updating Donation.', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | $customer_changed = false; |
92 | 92 | |
93 | - if ( isset( $data['give-new-customer'] ) && $data['give-new-customer'] == '1' ) { |
|
93 | + if (isset($data['give-new-customer']) && $data['give-new-customer'] == '1') { |
|
94 | 94 | |
95 | - $email = isset( $data['give-new-customer-email'] ) ? sanitize_text_field( $data['give-new-customer-email'] ) : ''; |
|
96 | - $names = isset( $data['give-new-customer-name'] ) ? sanitize_text_field( $data['give-new-customer-name'] ) : ''; |
|
95 | + $email = isset($data['give-new-customer-email']) ? sanitize_text_field($data['give-new-customer-email']) : ''; |
|
96 | + $names = isset($data['give-new-customer-name']) ? sanitize_text_field($data['give-new-customer-name']) : ''; |
|
97 | 97 | |
98 | - if ( empty( $email ) || empty( $names ) ) { |
|
99 | - wp_die( esc_html__( 'New Customers require a name and email address.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
98 | + if (empty($email) || empty($names)) { |
|
99 | + wp_die(esc_html__('New Customers require a name and email address.', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
100 | 100 | } |
101 | 101 | |
102 | - $customer = new Give_Customer( $email ); |
|
103 | - if ( empty( $customer->id ) ) { |
|
104 | - $customer_data = array( 'name' => $names, 'email' => $email ); |
|
105 | - $user_id = email_exists( $email ); |
|
106 | - if ( false !== $user_id ) { |
|
102 | + $customer = new Give_Customer($email); |
|
103 | + if (empty($customer->id)) { |
|
104 | + $customer_data = array('name' => $names, 'email' => $email); |
|
105 | + $user_id = email_exists($email); |
|
106 | + if (false !== $user_id) { |
|
107 | 107 | $customer_data['user_id'] = $user_id; |
108 | 108 | } |
109 | 109 | |
110 | - if ( ! $customer->create( $customer_data ) ) { |
|
110 | + if ( ! $customer->create($customer_data)) { |
|
111 | 111 | // Failed to crete the new donor, assume the previous donor. |
112 | 112 | $customer_changed = false; |
113 | - $customer = new Give_Customer( $curr_customer_id ); |
|
114 | - give_set_error( 'give-payment-new-customer-fail', esc_html__( 'Error creating new donor.', 'give' ) ); |
|
113 | + $customer = new Give_Customer($curr_customer_id); |
|
114 | + give_set_error('give-payment-new-customer-fail', esc_html__('Error creating new donor.', 'give')); |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | 118 | $new_customer_id = $customer->id; |
119 | 119 | |
120 | - $previous_customer = new Give_Customer( $curr_customer_id ); |
|
120 | + $previous_customer = new Give_Customer($curr_customer_id); |
|
121 | 121 | |
122 | 122 | $customer_changed = true; |
123 | 123 | |
124 | - } elseif ( $curr_customer_id !== $new_customer_id ) { |
|
124 | + } elseif ($curr_customer_id !== $new_customer_id) { |
|
125 | 125 | |
126 | - $customer = new Give_Customer( $new_customer_id ); |
|
126 | + $customer = new Give_Customer($new_customer_id); |
|
127 | 127 | $email = $customer->email; |
128 | 128 | $names = $customer->name; |
129 | 129 | |
130 | - $previous_customer = new Give_Customer( $curr_customer_id ); |
|
130 | + $previous_customer = new Give_Customer($curr_customer_id); |
|
131 | 131 | |
132 | 132 | $customer_changed = true; |
133 | 133 | |
134 | 134 | } else { |
135 | 135 | |
136 | - $customer = new Give_Customer( $curr_customer_id ); |
|
136 | + $customer = new Give_Customer($curr_customer_id); |
|
137 | 137 | $email = $customer->email; |
138 | 138 | $names = $customer->name; |
139 | 139 | |
140 | 140 | } |
141 | 141 | |
142 | 142 | // Setup first and last name from input values. |
143 | - $names = explode( ' ', $names ); |
|
144 | - $first_name = ! empty( $names[0] ) ? $names[0] : ''; |
|
143 | + $names = explode(' ', $names); |
|
144 | + $first_name = ! empty($names[0]) ? $names[0] : ''; |
|
145 | 145 | $last_name = ''; |
146 | - if ( ! empty( $names[1] ) ) { |
|
147 | - unset( $names[0] ); |
|
148 | - $last_name = implode( ' ', $names ); |
|
146 | + if ( ! empty($names[1])) { |
|
147 | + unset($names[0]); |
|
148 | + $last_name = implode(' ', $names); |
|
149 | 149 | } |
150 | 150 | |
151 | - if ( $customer_changed ) { |
|
151 | + if ($customer_changed) { |
|
152 | 152 | |
153 | 153 | // Remove the stats and payment from the previous customer and attach it to the new customer. |
154 | - $previous_customer->remove_payment( $payment_id, false ); |
|
155 | - $customer->attach_payment( $payment_id, false ); |
|
154 | + $previous_customer->remove_payment($payment_id, false); |
|
155 | + $customer->attach_payment($payment_id, false); |
|
156 | 156 | |
157 | - if ( 'publish' == $status ) { |
|
157 | + if ('publish' == $status) { |
|
158 | 158 | |
159 | 159 | // Reduce previous user donation count and amount. |
160 | 160 | $previous_customer->decrease_purchase_count(); |
161 | - $previous_customer->decrease_value( $curr_total ); |
|
161 | + $previous_customer->decrease_value($curr_total); |
|
162 | 162 | |
163 | 163 | // If donation was completed adjust stats of new customers. |
164 | 164 | $customer->increase_purchase_count(); |
165 | - $customer->increase_value( $new_total ); |
|
165 | + $customer->increase_value($new_total); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | $payment->customer_id = $customer->id; |
169 | 169 | } else { |
170 | 170 | |
171 | - if ( 'publish' === $status ) { |
|
171 | + if ('publish' === $status) { |
|
172 | 172 | // Update user donation stat. |
173 | - $customer->update_donation_value( $curr_total, $new_total ); |
|
173 | + $customer->update_donation_value($curr_total, $new_total); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
@@ -183,10 +183,10 @@ discard block |
||
183 | 183 | $payment->total = $new_total; |
184 | 184 | |
185 | 185 | // Check for payment notes. |
186 | - if ( ! empty( $data['give-payment-note'] ) ) { |
|
186 | + if ( ! empty($data['give-payment-note'])) { |
|
187 | 187 | |
188 | - $note = wp_kses( $data['give-payment-note'], array() ); |
|
189 | - give_insert_payment_note( $payment_id, $note ); |
|
188 | + $note = wp_kses($data['give-payment-note'], array()); |
|
189 | + give_insert_payment_note($payment_id, $note); |
|
190 | 190 | |
191 | 191 | } |
192 | 192 | |
@@ -194,17 +194,17 @@ discard block |
||
194 | 194 | $payment->status = $status; |
195 | 195 | |
196 | 196 | // Adjust total store earnings if the payment total has been changed. |
197 | - if ( $new_total !== $curr_total && 'publish' == $status ) { |
|
197 | + if ($new_total !== $curr_total && 'publish' == $status) { |
|
198 | 198 | |
199 | - if ( $new_total > $curr_total ) { |
|
199 | + if ($new_total > $curr_total) { |
|
200 | 200 | // Increase if our new total is higher. |
201 | 201 | $difference = $new_total - $curr_total; |
202 | - give_increase_total_earnings( $difference ); |
|
202 | + give_increase_total_earnings($difference); |
|
203 | 203 | |
204 | - } elseif ( $curr_total > $new_total ) { |
|
204 | + } elseif ($curr_total > $new_total) { |
|
205 | 205 | // Decrease if our new total is lower. |
206 | 206 | $difference = $curr_total - $new_total; |
207 | - give_decrease_total_earnings( $difference ); |
|
207 | + give_decrease_total_earnings($difference); |
|
208 | 208 | |
209 | 209 | } |
210 | 210 | } |
@@ -212,16 +212,16 @@ discard block |
||
212 | 212 | $payment->save(); |
213 | 213 | |
214 | 214 | // Get new give form ID. |
215 | - $new_form_id = absint( $data['forms'] ); |
|
216 | - $current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) ); |
|
215 | + $new_form_id = absint($data['forms']); |
|
216 | + $current_form_id = absint($payment->get_meta('_give_payment_form_id')); |
|
217 | 217 | |
218 | 218 | // We are adding payment transfer code in last to remove any conflict with above functionality. |
219 | 219 | // For example: above code will automatically handle form stat (increase/decrease) when payment status changes. |
220 | 220 | // Check if user want to transfer current payment to new give form id. |
221 | - if ( $new_form_id != $current_form_id ) { |
|
221 | + if ($new_form_id != $current_form_id) { |
|
222 | 222 | |
223 | 223 | // Get new give form title. |
224 | - $new_form_title = get_the_title( $new_form_id ); |
|
224 | + $new_form_title = get_the_title($new_form_id); |
|
225 | 225 | |
226 | 226 | // Update new give form data in payment data. |
227 | 227 | $payment_meta = $payment->get_meta(); |
@@ -229,56 +229,56 @@ discard block |
||
229 | 229 | $payment_meta['form_id'] = $new_form_id; |
230 | 230 | |
231 | 231 | // Update price id post meta data for set donation form. |
232 | - if ( ! give_has_variable_prices( $new_form_id ) ) { |
|
232 | + if ( ! give_has_variable_prices($new_form_id)) { |
|
233 | 233 | $payment_meta['price_id'] = ''; |
234 | 234 | } |
235 | 235 | |
236 | 236 | // Update payment give form meta data. |
237 | - $payment->update_meta( '_give_payment_form_id', $new_form_id ); |
|
238 | - $payment->update_meta( '_give_payment_form_title', $new_form_title ); |
|
239 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
237 | + $payment->update_meta('_give_payment_form_id', $new_form_id); |
|
238 | + $payment->update_meta('_give_payment_form_title', $new_form_title); |
|
239 | + $payment->update_meta('_give_payment_meta', $payment_meta); |
|
240 | 240 | |
241 | 241 | // Update price id payment metadata. |
242 | - if ( ! give_has_variable_prices( $new_form_id ) ) { |
|
243 | - $payment->update_meta( '_give_payment_price_id', '' ); |
|
242 | + if ( ! give_has_variable_prices($new_form_id)) { |
|
243 | + $payment->update_meta('_give_payment_price_id', ''); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | // If donation was completed, adjust stats of forms. |
247 | - if ( 'publish' == $status ) { |
|
247 | + if ('publish' == $status) { |
|
248 | 248 | |
249 | 249 | // Decrease sale of old give form. For other payment status. |
250 | - $current_form = new Give_Donate_Form( $current_form_id ); |
|
250 | + $current_form = new Give_Donate_Form($current_form_id); |
|
251 | 251 | $current_form->decrease_sales(); |
252 | - $current_form->decrease_earnings( $curr_total ); |
|
252 | + $current_form->decrease_earnings($curr_total); |
|
253 | 253 | |
254 | 254 | // Increase sale of new give form. |
255 | - $new_form = new Give_Donate_Form( $new_form_id ); |
|
255 | + $new_form = new Give_Donate_Form($new_form_id); |
|
256 | 256 | $new_form->increase_sales(); |
257 | - $new_form->increase_earnings( $new_total ); |
|
257 | + $new_form->increase_earnings($new_total); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | // Re setup payment to update new meta value in object. |
261 | - $payment->update_payment_setup( $payment->ID ); |
|
261 | + $payment->update_payment_setup($payment->ID); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | // Update price id if current form is variable form. |
265 | - if ( ! empty( $data['give-variable-price'] ) && give_has_variable_prices( $payment->form_id ) ) { |
|
265 | + if ( ! empty($data['give-variable-price']) && give_has_variable_prices($payment->form_id)) { |
|
266 | 266 | |
267 | 267 | // Get payment meta data. |
268 | 268 | $payment_meta = $payment->get_meta(); |
269 | 269 | |
270 | 270 | // Set payment id to empty string if variable price id is negative ( i.e. custom amount feature enabled ). |
271 | - $data['give-variable-price'] = ( 'custom' === $data['give-variable-price'] ) ? 'custom' : ( 0 < $data['give-variable-price'] ) ? $data['give-variable-price'] : ''; |
|
271 | + $data['give-variable-price'] = ('custom' === $data['give-variable-price']) ? 'custom' : (0 < $data['give-variable-price']) ? $data['give-variable-price'] : ''; |
|
272 | 272 | |
273 | 273 | // Update payment meta data. |
274 | 274 | $payment_meta['price_id'] = $data['give-variable-price']; |
275 | 275 | |
276 | 276 | // Update payment give form meta data. |
277 | - $payment->update_meta( '_give_payment_price_id', $data['give-variable-price'] ); |
|
278 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
277 | + $payment->update_meta('_give_payment_price_id', $data['give-variable-price']); |
|
278 | + $payment->update_meta('_give_payment_meta', $payment_meta); |
|
279 | 279 | |
280 | 280 | // Re setup payment to update new meta value in object. |
281 | - $payment->update_payment_setup( $payment->ID ); |
|
281 | + $payment->update_payment_setup($payment->ID); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
@@ -288,13 +288,13 @@ discard block |
||
288 | 288 | * |
289 | 289 | * @param int $payment_id The ID of the payment. |
290 | 290 | */ |
291 | - do_action( 'give_updated_edited_purchase', $payment_id ); |
|
291 | + do_action('give_updated_edited_purchase', $payment_id); |
|
292 | 292 | |
293 | - wp_safe_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-updated&id=' . $payment_id ) ); |
|
293 | + wp_safe_redirect(admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-updated&id='.$payment_id)); |
|
294 | 294 | exit; |
295 | 295 | } |
296 | 296 | |
297 | -add_action( 'give_update_payment_details', 'give_update_payment_details' ); |
|
297 | +add_action('give_update_payment_details', 'give_update_payment_details'); |
|
298 | 298 | |
299 | 299 | /** |
300 | 300 | * Trigger a Donation Deletion |
@@ -305,48 +305,48 @@ discard block |
||
305 | 305 | * |
306 | 306 | * @return void |
307 | 307 | */ |
308 | -function give_trigger_purchase_delete( $data ) { |
|
309 | - if ( wp_verify_nonce( $data['_wpnonce'], 'give_donation_nonce' ) ) { |
|
308 | +function give_trigger_purchase_delete($data) { |
|
309 | + if (wp_verify_nonce($data['_wpnonce'], 'give_donation_nonce')) { |
|
310 | 310 | |
311 | - $payment_id = absint( $data['purchase_id'] ); |
|
311 | + $payment_id = absint($data['purchase_id']); |
|
312 | 312 | |
313 | - if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) { |
|
314 | - wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
313 | + if ( ! current_user_can('edit_give_payments', $payment_id)) { |
|
314 | + wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
315 | 315 | } |
316 | 316 | |
317 | - give_delete_purchase( $payment_id ); |
|
318 | - wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&give-message=donation_deleted' ) ); |
|
317 | + give_delete_purchase($payment_id); |
|
318 | + wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-payment-history&give-message=donation_deleted')); |
|
319 | 319 | give_die(); |
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
323 | -add_action( 'give_delete_payment', 'give_trigger_purchase_delete' ); |
|
323 | +add_action('give_delete_payment', 'give_trigger_purchase_delete'); |
|
324 | 324 | |
325 | 325 | /** |
326 | 326 | * AJAX Store Donation Note |
327 | 327 | */ |
328 | 328 | function give_ajax_store_payment_note() { |
329 | 329 | |
330 | - $payment_id = absint( $_POST['payment_id'] ); |
|
331 | - $note = wp_kses( $_POST['note'], array() ); |
|
330 | + $payment_id = absint($_POST['payment_id']); |
|
331 | + $note = wp_kses($_POST['note'], array()); |
|
332 | 332 | |
333 | - if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) { |
|
334 | - wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
333 | + if ( ! current_user_can('edit_give_payments', $payment_id)) { |
|
334 | + wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
335 | 335 | } |
336 | 336 | |
337 | - if ( empty( $payment_id ) ) { |
|
338 | - die( '-1' ); |
|
337 | + if (empty($payment_id)) { |
|
338 | + die('-1'); |
|
339 | 339 | } |
340 | 340 | |
341 | - if ( empty( $note ) ) { |
|
342 | - die( '-1' ); |
|
341 | + if (empty($note)) { |
|
342 | + die('-1'); |
|
343 | 343 | } |
344 | 344 | |
345 | - $note_id = give_insert_payment_note( $payment_id, $note ); |
|
346 | - die( give_get_payment_note_html( $note_id ) ); |
|
345 | + $note_id = give_insert_payment_note($payment_id, $note); |
|
346 | + die(give_get_payment_note_html($note_id)); |
|
347 | 347 | } |
348 | 348 | |
349 | -add_action( 'wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note' ); |
|
349 | +add_action('wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note'); |
|
350 | 350 | |
351 | 351 | /** |
352 | 352 | * Triggers a donation note deletion without ajax |
@@ -357,24 +357,24 @@ discard block |
||
357 | 357 | * |
358 | 358 | * @return void |
359 | 359 | */ |
360 | -function give_trigger_payment_note_deletion( $data ) { |
|
360 | +function give_trigger_payment_note_deletion($data) { |
|
361 | 361 | |
362 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_delete_payment_note_' . $data['note_id'] ) ) { |
|
362 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give_delete_payment_note_'.$data['note_id'])) { |
|
363 | 363 | return; |
364 | 364 | } |
365 | 365 | |
366 | - if ( ! current_user_can( 'edit_give_payments', $data['payment_id'] ) ) { |
|
367 | - wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
366 | + if ( ! current_user_can('edit_give_payments', $data['payment_id'])) { |
|
367 | + wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
368 | 368 | } |
369 | 369 | |
370 | - $edit_order_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=donation-note-deleted&id=' . absint( $data['payment_id'] ) ); |
|
370 | + $edit_order_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=donation-note-deleted&id='.absint($data['payment_id'])); |
|
371 | 371 | |
372 | - give_delete_payment_note( $data['note_id'], $data['payment_id'] ); |
|
372 | + give_delete_payment_note($data['note_id'], $data['payment_id']); |
|
373 | 373 | |
374 | - wp_redirect( $edit_order_url ); |
|
374 | + wp_redirect($edit_order_url); |
|
375 | 375 | } |
376 | 376 | |
377 | -add_action( 'give_delete_payment_note', 'give_trigger_payment_note_deletion' ); |
|
377 | +add_action('give_delete_payment_note', 'give_trigger_payment_note_deletion'); |
|
378 | 378 | |
379 | 379 | /** |
380 | 380 | * Delete a payment note deletion with ajax |
@@ -385,16 +385,16 @@ discard block |
||
385 | 385 | */ |
386 | 386 | function give_ajax_delete_payment_note() { |
387 | 387 | |
388 | - if ( ! current_user_can( 'edit_give_payments', $_POST['payment_id'] ) ) { |
|
389 | - wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
388 | + if ( ! current_user_can('edit_give_payments', $_POST['payment_id'])) { |
|
389 | + wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
390 | 390 | } |
391 | 391 | |
392 | - if ( give_delete_payment_note( $_POST['note_id'], $_POST['payment_id'] ) ) { |
|
393 | - die( '1' ); |
|
392 | + if (give_delete_payment_note($_POST['note_id'], $_POST['payment_id'])) { |
|
393 | + die('1'); |
|
394 | 394 | } else { |
395 | - die( '-1' ); |
|
395 | + die('-1'); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | } |
399 | 399 | |
400 | -add_action( 'wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note' ); |
|
400 | +add_action('wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note'); |