@@ -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,7 +23,7 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return array The altered list of views |
| 25 | 25 | */ |
| 26 | -function give_register_default_customer_views( $views ) { |
|
| 26 | +function give_register_default_customer_views($views) { |
|
| 27 | 27 | |
| 28 | 28 | $default_views = array( |
| 29 | 29 | 'overview' => 'give_customers_view', |
@@ -31,11 +31,11 @@ discard block |
||
| 31 | 31 | 'notes' => 'give_customer_notes_view' |
| 32 | 32 | ); |
| 33 | 33 | |
| 34 | - return array_merge( $views, $default_views ); |
|
| 34 | + return array_merge($views, $default_views); |
|
| 35 | 35 | |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | -add_filter( 'give_customer_views', 'give_register_default_customer_views', 1, 1 ); |
|
| 38 | +add_filter('give_customer_views', 'give_register_default_customer_views', 1, 1); |
|
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * Register a tab for the single customer view |
@@ -46,17 +46,17 @@ discard block |
||
| 46 | 46 | * |
| 47 | 47 | * @return array The altered list of tabs |
| 48 | 48 | */ |
| 49 | -function give_register_default_customer_tabs( $tabs ) { |
|
| 49 | +function give_register_default_customer_tabs($tabs) { |
|
| 50 | 50 | |
| 51 | 51 | $default_tabs = array( |
| 52 | - 'overview' => array( 'dashicon' => 'dashicons-admin-users', 'title' => esc_html__( 'Donor Profile', 'give' ) ), |
|
| 53 | - 'notes' => array( 'dashicon' => 'dashicons-admin-comments', 'title' => esc_html__( 'Donor Notes', 'give' ) ) |
|
| 52 | + 'overview' => array('dashicon' => 'dashicons-admin-users', 'title' => esc_html__('Donor Profile', 'give')), |
|
| 53 | + 'notes' => array('dashicon' => 'dashicons-admin-comments', 'title' => esc_html__('Donor Notes', 'give')) |
|
| 54 | 54 | ); |
| 55 | 55 | |
| 56 | - return array_merge( $tabs, $default_tabs ); |
|
| 56 | + return array_merge($tabs, $default_tabs); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | -add_filter( 'give_customer_tabs', 'give_register_default_customer_tabs', 1, 1 ); |
|
| 59 | +add_filter('give_customer_tabs', 'give_register_default_customer_tabs', 1, 1); |
|
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | 62 | * Register the Delete icon as late as possible so it's at the bottom |
@@ -67,11 +67,11 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @return array The altered list of tabs, with 'delete' at the bottom |
| 69 | 69 | */ |
| 70 | -function give_register_delete_customer_tab( $tabs ) { |
|
| 70 | +function give_register_delete_customer_tab($tabs) { |
|
| 71 | 71 | |
| 72 | - $tabs['delete'] = array( 'dashicon' => 'dashicons-trash', 'title' => esc_html__( 'Delete Donor', 'give' ) ); |
|
| 72 | + $tabs['delete'] = array('dashicon' => 'dashicons-trash', 'title' => esc_html__('Delete Donor', 'give')); |
|
| 73 | 73 | |
| 74 | 74 | return $tabs; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | -add_filter( 'give_customer_tabs', 'give_register_delete_customer_tab', PHP_INT_MAX, 1 ); |
|
| 77 | +add_filter('give_customer_tabs', 'give_register_delete_customer_tab', PHP_INT_MAX, 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 | |
@@ -29,8 +29,8 @@ discard block |
||
| 29 | 29 | * @see Give_Cron::weekly_events() |
| 30 | 30 | */ |
| 31 | 31 | public function __construct() { |
| 32 | - add_filter( 'cron_schedules', array( $this, 'add_schedules' ) ); |
|
| 33 | - add_action( 'wp', array( $this, 'schedule_Events' ) ); |
|
| 32 | + add_filter('cron_schedules', array($this, 'add_schedules')); |
|
| 33 | + add_action('wp', array($this, 'schedule_Events')); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -42,11 +42,11 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @return array |
| 44 | 44 | */ |
| 45 | - public function add_schedules( $schedules = array() ) { |
|
| 45 | + public function add_schedules($schedules = array()) { |
|
| 46 | 46 | // Adds once weekly to the existing schedules. |
| 47 | 47 | $schedules['weekly'] = array( |
| 48 | 48 | 'interval' => 604800, |
| 49 | - 'display' => esc_html__( 'Once Weekly', 'give' ) |
|
| 49 | + 'display' => esc_html__('Once Weekly', 'give') |
|
| 50 | 50 | ); |
| 51 | 51 | |
| 52 | 52 | return $schedules; |
@@ -72,8 +72,8 @@ discard block |
||
| 72 | 72 | * @return void |
| 73 | 73 | */ |
| 74 | 74 | private function weekly_events() { |
| 75 | - if ( ! wp_next_scheduled( 'give_weekly_scheduled_events' ) ) { |
|
| 76 | - wp_schedule_event( current_time( 'timestamp' ), 'weekly', 'give_weekly_scheduled_events' ); |
|
| 75 | + if ( ! wp_next_scheduled('give_weekly_scheduled_events')) { |
|
| 76 | + wp_schedule_event(current_time('timestamp'), 'weekly', 'give_weekly_scheduled_events'); |
|
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | * @return void |
| 86 | 86 | */ |
| 87 | 87 | private function daily_events() { |
| 88 | - if ( ! wp_next_scheduled( 'give_daily_scheduled_events' ) ) { |
|
| 89 | - wp_schedule_event( current_time( 'timestamp' ), 'daily', 'give_daily_scheduled_events' ); |
|
| 88 | + if ( ! wp_next_scheduled('give_daily_scheduled_events')) { |
|
| 89 | + wp_schedule_event(current_time('timestamp'), 'daily', 'give_daily_scheduled_events'); |
|
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | |
@@ -408,30 +408,30 @@ |
||
| 408 | 408 | die( '-2' ); |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
| 412 | - esc_html_e( 'n/a', 'give' ); |
|
| 413 | - } else { |
|
| 414 | - // Payment object. |
|
| 415 | - $payment = new Give_Payment( $payment_id ); |
|
| 416 | - |
|
| 417 | - // Payment meta. |
|
| 418 | - $payment_meta = $payment->get_meta(); |
|
| 419 | - |
|
| 420 | - |
|
| 421 | - // Variable price dropdown options. |
|
| 422 | - $variable_price_dropdown_option = array( |
|
| 423 | - 'id' => $form_id, |
|
| 424 | - 'name' => 'give-variable-price', |
|
| 425 | - 'chosen' => true, |
|
| 426 | - 'show_option_all' => '', |
|
| 427 | - 'selected' => $payment_meta['price_id'], |
|
| 428 | - ); |
|
| 429 | - |
|
| 430 | - // Render variable prices select tag html. |
|
| 431 | - give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true ); |
|
| 432 | - } |
|
| 433 | - |
|
| 434 | - give_die(); |
|
| 411 | + if ( ! give_has_variable_prices( $form_id ) ) { |
|
| 412 | + esc_html_e( 'n/a', 'give' ); |
|
| 413 | + } else { |
|
| 414 | + // Payment object. |
|
| 415 | + $payment = new Give_Payment( $payment_id ); |
|
| 416 | + |
|
| 417 | + // Payment meta. |
|
| 418 | + $payment_meta = $payment->get_meta(); |
|
| 419 | + |
|
| 420 | + |
|
| 421 | + // Variable price dropdown options. |
|
| 422 | + $variable_price_dropdown_option = array( |
|
| 423 | + 'id' => $form_id, |
|
| 424 | + 'name' => 'give-variable-price', |
|
| 425 | + 'chosen' => true, |
|
| 426 | + 'show_option_all' => '', |
|
| 427 | + 'selected' => $payment_meta['price_id'], |
|
| 428 | + ); |
|
| 429 | + |
|
| 430 | + // Render variable prices select tag html. |
|
| 431 | + give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true ); |
|
| 432 | + } |
|
| 433 | + |
|
| 434 | + give_die(); |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | add_action( 'wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html' ); |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -26,27 +26,27 @@ discard block |
||
| 26 | 26 | function give_test_ajax_works() { |
| 27 | 27 | |
| 28 | 28 | // Check if the Airplane Mode plugin is installed |
| 29 | - if ( class_exists( 'Airplane_Mode_Core' ) ) { |
|
| 29 | + if (class_exists('Airplane_Mode_Core')) { |
|
| 30 | 30 | |
| 31 | 31 | $airplane = Airplane_Mode_Core::getInstance(); |
| 32 | 32 | |
| 33 | - if ( method_exists( $airplane, 'enabled' ) ) { |
|
| 33 | + if (method_exists($airplane, 'enabled')) { |
|
| 34 | 34 | |
| 35 | - if ( $airplane->enabled() ) { |
|
| 35 | + if ($airplane->enabled()) { |
|
| 36 | 36 | return true; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | } else { |
| 40 | 40 | |
| 41 | - if ( $airplane->check_status() == 'on' ) { |
|
| 41 | + if ($airplane->check_status() == 'on') { |
|
| 42 | 42 | return true; |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - add_filter( 'block_local_requests', '__return_false' ); |
|
| 47 | + add_filter('block_local_requests', '__return_false'); |
|
| 48 | 48 | |
| 49 | - if ( get_transient( '_give_ajax_works' ) ) { |
|
| 49 | + if (get_transient('_give_ajax_works')) { |
|
| 50 | 50 | return true; |
| 51 | 51 | } |
| 52 | 52 | |
@@ -58,35 +58,35 @@ discard block |
||
| 58 | 58 | ) |
| 59 | 59 | ); |
| 60 | 60 | |
| 61 | - $ajax = wp_remote_post( give_get_ajax_url(), $params ); |
|
| 61 | + $ajax = wp_remote_post(give_get_ajax_url(), $params); |
|
| 62 | 62 | $works = true; |
| 63 | 63 | |
| 64 | - if ( is_wp_error( $ajax ) ) { |
|
| 64 | + if (is_wp_error($ajax)) { |
|
| 65 | 65 | |
| 66 | 66 | $works = false; |
| 67 | 67 | |
| 68 | 68 | } else { |
| 69 | 69 | |
| 70 | - if ( empty( $ajax['response'] ) ) { |
|
| 70 | + if (empty($ajax['response'])) { |
|
| 71 | 71 | $works = false; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) { |
|
| 74 | + if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) { |
|
| 75 | 75 | $works = false; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) { |
|
| 78 | + if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) { |
|
| 79 | 79 | $works = false; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) { |
|
| 82 | + if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) { |
|
| 83 | 83 | $works = false; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - if ( $works ) { |
|
| 89 | - set_transient( '_give_ajax_works', '1', DAY_IN_SECONDS ); |
|
| 88 | + if ($works) { |
|
| 89 | + set_transient('_give_ajax_works', '1', DAY_IN_SECONDS); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | return $works; |
@@ -101,16 +101,16 @@ discard block |
||
| 101 | 101 | * @return string |
| 102 | 102 | */ |
| 103 | 103 | function give_get_ajax_url() { |
| 104 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
| 104 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
| 105 | 105 | |
| 106 | 106 | $current_url = give_get_current_page_url(); |
| 107 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
| 107 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
| 108 | 108 | |
| 109 | - if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) { |
|
| 110 | - $ajax_url = preg_replace( '/^http/', 'https', $ajax_url ); |
|
| 109 | + if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) { |
|
| 110 | + $ajax_url = preg_replace('/^http/', 'https', $ajax_url); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - return apply_filters( 'give_ajax_url', $ajax_url ); |
|
| 113 | + return apply_filters('give_ajax_url', $ajax_url); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -126,12 +126,12 @@ discard block |
||
| 126 | 126 | * |
| 127 | 127 | * @since 1.7 |
| 128 | 128 | */ |
| 129 | - do_action( 'give_donation_form_login_fields' ); |
|
| 129 | + do_action('give_donation_form_login_fields'); |
|
| 130 | 130 | |
| 131 | 131 | give_die(); |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | -add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' ); |
|
| 134 | +add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields'); |
|
| 135 | 135 | |
| 136 | 136 | /** |
| 137 | 137 | * Load Checkout Fields |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | * @return void |
| 142 | 142 | */ |
| 143 | 143 | function give_load_checkout_fields() { |
| 144 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : ''; |
|
| 144 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : ''; |
|
| 145 | 145 | |
| 146 | 146 | ob_start(); |
| 147 | 147 | |
@@ -150,18 +150,18 @@ discard block |
||
| 150 | 150 | * |
| 151 | 151 | * @since 1.7 |
| 152 | 152 | */ |
| 153 | - do_action( 'give_donation_form_register_login_fields', $form_id ); |
|
| 153 | + do_action('give_donation_form_register_login_fields', $form_id); |
|
| 154 | 154 | |
| 155 | 155 | $fields = ob_get_clean(); |
| 156 | 156 | |
| 157 | - wp_send_json( array( |
|
| 158 | - 'fields' => wp_json_encode( $fields ), |
|
| 159 | - 'submit' => wp_json_encode( give_checkout_button_purchase( $form_id ) ), |
|
| 160 | - ) ); |
|
| 157 | + wp_send_json(array( |
|
| 158 | + 'fields' => wp_json_encode($fields), |
|
| 159 | + 'submit' => wp_json_encode(give_checkout_button_purchase($form_id)), |
|
| 160 | + )); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | -add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' ); |
|
| 164 | -add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' ); |
|
| 163 | +add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields'); |
|
| 164 | +add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields'); |
|
| 165 | 165 | |
| 166 | 166 | /** |
| 167 | 167 | * Get Form Title via AJAX (used only in WordPress Admin) |
@@ -171,9 +171,9 @@ discard block |
||
| 171 | 171 | * @return void |
| 172 | 172 | */ |
| 173 | 173 | function give_ajax_get_form_title() { |
| 174 | - if ( isset( $_POST['form_id'] ) ) { |
|
| 175 | - $title = get_the_title( $_POST['form_id'] ); |
|
| 176 | - if ( $title ) { |
|
| 174 | + if (isset($_POST['form_id'])) { |
|
| 175 | + $title = get_the_title($_POST['form_id']); |
|
| 176 | + if ($title) { |
|
| 177 | 177 | echo $title; |
| 178 | 178 | } else { |
| 179 | 179 | echo 'fail'; |
@@ -182,8 +182,8 @@ discard block |
||
| 182 | 182 | give_die(); |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | -add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' ); |
|
| 186 | -add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' ); |
|
| 185 | +add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title'); |
|
| 186 | +add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title'); |
|
| 187 | 187 | |
| 188 | 188 | /** |
| 189 | 189 | * Retrieve a states drop down |
@@ -194,23 +194,23 @@ discard block |
||
| 194 | 194 | */ |
| 195 | 195 | function give_ajax_get_states_field() { |
| 196 | 196 | |
| 197 | - if ( empty( $_POST['country'] ) ) { |
|
| 197 | + if (empty($_POST['country'])) { |
|
| 198 | 198 | $_POST['country'] = give_get_country(); |
| 199 | 199 | } |
| 200 | - $states = give_get_states( $_POST['country'] ); |
|
| 200 | + $states = give_get_states($_POST['country']); |
|
| 201 | 201 | |
| 202 | - if ( ! empty( $states ) ) { |
|
| 202 | + if ( ! empty($states)) { |
|
| 203 | 203 | |
| 204 | 204 | $args = array( |
| 205 | 205 | 'name' => $_POST['field_name'], |
| 206 | 206 | 'id' => $_POST['field_name'], |
| 207 | - 'class' => $_POST['field_name'] . ' give-select', |
|
| 208 | - 'options' => give_get_states( $_POST['country'] ), |
|
| 207 | + 'class' => $_POST['field_name'].' give-select', |
|
| 208 | + 'options' => give_get_states($_POST['country']), |
|
| 209 | 209 | 'show_option_all' => false, |
| 210 | 210 | 'show_option_none' => false |
| 211 | 211 | ); |
| 212 | 212 | |
| 213 | - $response = Give()->html->select( $args ); |
|
| 213 | + $response = Give()->html->select($args); |
|
| 214 | 214 | |
| 215 | 215 | } else { |
| 216 | 216 | |
@@ -222,8 +222,8 @@ discard block |
||
| 222 | 222 | give_die(); |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | -add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' ); |
|
| 226 | -add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' ); |
|
| 225 | +add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field'); |
|
| 226 | +add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field'); |
|
| 227 | 227 | |
| 228 | 228 | /** |
| 229 | 229 | * Retrieve a states drop down |
@@ -235,17 +235,17 @@ discard block |
||
| 235 | 235 | function give_ajax_form_search() { |
| 236 | 236 | global $wpdb; |
| 237 | 237 | |
| 238 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
| 238 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
| 239 | 239 | $results = array(); |
| 240 | - if ( current_user_can( 'edit_give_forms' ) ) { |
|
| 241 | - $items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50" ); |
|
| 240 | + if (current_user_can('edit_give_forms')) { |
|
| 241 | + $items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50"); |
|
| 242 | 242 | } else { |
| 243 | - $items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50" ); |
|
| 243 | + $items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50"); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - if ( $items ) { |
|
| 246 | + if ($items) { |
|
| 247 | 247 | |
| 248 | - foreach ( $items as $item ) { |
|
| 248 | + foreach ($items as $item) { |
|
| 249 | 249 | |
| 250 | 250 | $results[] = array( |
| 251 | 251 | 'id' => $item->ID, |
@@ -257,18 +257,18 @@ discard block |
||
| 257 | 257 | |
| 258 | 258 | $items[] = array( |
| 259 | 259 | 'id' => 0, |
| 260 | - 'name' => esc_html__( 'No forms found.', 'give' ) |
|
| 260 | + 'name' => esc_html__('No forms found.', 'give') |
|
| 261 | 261 | ); |
| 262 | 262 | |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - echo json_encode( $results ); |
|
| 265 | + echo json_encode($results); |
|
| 266 | 266 | |
| 267 | 267 | give_die(); |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | -add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' ); |
|
| 271 | -add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' ); |
|
| 270 | +add_action('wp_ajax_give_form_search', 'give_ajax_form_search'); |
|
| 271 | +add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search'); |
|
| 272 | 272 | |
| 273 | 273 | /** |
| 274 | 274 | * Search the donors database via Ajax |
@@ -280,21 +280,21 @@ discard block |
||
| 280 | 280 | function give_ajax_donor_search() { |
| 281 | 281 | global $wpdb; |
| 282 | 282 | |
| 283 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
| 283 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
| 284 | 284 | $results = array(); |
| 285 | - if ( ! current_user_can( 'view_give_reports' ) ) { |
|
| 285 | + if ( ! current_user_can('view_give_reports')) { |
|
| 286 | 286 | $donors = array(); |
| 287 | 287 | } else { |
| 288 | - $donors = $wpdb->get_results( "SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" ); |
|
| 288 | + $donors = $wpdb->get_results("SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50"); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - if ( $donors ) { |
|
| 291 | + if ($donors) { |
|
| 292 | 292 | |
| 293 | - foreach ( $donors as $donor ) { |
|
| 293 | + foreach ($donors as $donor) { |
|
| 294 | 294 | |
| 295 | 295 | $results[] = array( |
| 296 | 296 | 'id' => $donor->id, |
| 297 | - 'name' => $donor->name . '(' . $donor->email . ')' |
|
| 297 | + 'name' => $donor->name.'('.$donor->email.')' |
|
| 298 | 298 | ); |
| 299 | 299 | } |
| 300 | 300 | |
@@ -302,17 +302,17 @@ discard block |
||
| 302 | 302 | |
| 303 | 303 | $donors[] = array( |
| 304 | 304 | 'id' => 0, |
| 305 | - 'name' => esc_html__( 'No donors found.', 'give' ) |
|
| 305 | + 'name' => esc_html__('No donors found.', 'give') |
|
| 306 | 306 | ); |
| 307 | 307 | |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - echo json_encode( $results ); |
|
| 310 | + echo json_encode($results); |
|
| 311 | 311 | |
| 312 | 312 | give_die(); |
| 313 | 313 | } |
| 314 | 314 | |
| 315 | -add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' ); |
|
| 315 | +add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search'); |
|
| 316 | 316 | |
| 317 | 317 | |
| 318 | 318 | /** |
@@ -324,42 +324,42 @@ discard block |
||
| 324 | 324 | */ |
| 325 | 325 | function give_ajax_search_users() { |
| 326 | 326 | |
| 327 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
| 327 | + if (current_user_can('manage_give_settings')) { |
|
| 328 | 328 | |
| 329 | - $search_query = trim( $_POST['user_name'] ); |
|
| 330 | - $exclude = trim( $_POST['exclude'] ); |
|
| 329 | + $search_query = trim($_POST['user_name']); |
|
| 330 | + $exclude = trim($_POST['exclude']); |
|
| 331 | 331 | |
| 332 | 332 | $get_users_args = array( |
| 333 | 333 | 'number' => 9999, |
| 334 | - 'search' => $search_query . '*' |
|
| 334 | + 'search' => $search_query.'*' |
|
| 335 | 335 | ); |
| 336 | 336 | |
| 337 | - if ( ! empty( $exclude ) ) { |
|
| 338 | - $exclude_array = explode( ',', $exclude ); |
|
| 337 | + if ( ! empty($exclude)) { |
|
| 338 | + $exclude_array = explode(',', $exclude); |
|
| 339 | 339 | $get_users_args['exclude'] = $exclude_array; |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - $get_users_args = apply_filters( 'give_search_users_args', $get_users_args ); |
|
| 342 | + $get_users_args = apply_filters('give_search_users_args', $get_users_args); |
|
| 343 | 343 | |
| 344 | - $found_users = apply_filters( 'give_ajax_found_users', get_users( $get_users_args ), $search_query ); |
|
| 344 | + $found_users = apply_filters('give_ajax_found_users', get_users($get_users_args), $search_query); |
|
| 345 | 345 | |
| 346 | 346 | $user_list = '<ul>'; |
| 347 | - if ( $found_users ) { |
|
| 348 | - foreach ( $found_users as $user ) { |
|
| 349 | - $user_list .= '<li><a href="#" data-userid="' . esc_attr( $user->ID ) . '" data-login="' . esc_attr( $user->user_login ) . '">' . esc_html( $user->user_login ) . '</a></li>'; |
|
| 347 | + if ($found_users) { |
|
| 348 | + foreach ($found_users as $user) { |
|
| 349 | + $user_list .= '<li><a href="#" data-userid="'.esc_attr($user->ID).'" data-login="'.esc_attr($user->user_login).'">'.esc_html($user->user_login).'</a></li>'; |
|
| 350 | 350 | } |
| 351 | 351 | } else { |
| 352 | - $user_list .= '<li>' . esc_html__( 'No users found.', 'give' ) . '</li>'; |
|
| 352 | + $user_list .= '<li>'.esc_html__('No users found.', 'give').'</li>'; |
|
| 353 | 353 | } |
| 354 | 354 | $user_list .= '</ul>'; |
| 355 | 355 | |
| 356 | - echo json_encode( array( 'results' => $user_list ) ); |
|
| 356 | + echo json_encode(array('results' => $user_list)); |
|
| 357 | 357 | |
| 358 | 358 | } |
| 359 | 359 | die(); |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | -add_action( 'wp_ajax_give_search_users', 'give_ajax_search_users' ); |
|
| 362 | +add_action('wp_ajax_give_search_users', 'give_ajax_search_users'); |
|
| 363 | 363 | |
| 364 | 364 | |
| 365 | 365 | /** |
@@ -371,32 +371,32 @@ discard block |
||
| 371 | 371 | */ |
| 372 | 372 | function give_check_for_form_price_variations() { |
| 373 | 373 | |
| 374 | - if ( ! current_user_can( 'edit_give_forms', get_current_user_id() ) ) { |
|
| 375 | - die( '-1' ); |
|
| 374 | + if ( ! current_user_can('edit_give_forms', get_current_user_id())) { |
|
| 375 | + die('-1'); |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | - $form_id = intval( $_POST['form_id'] ); |
|
| 379 | - $form = get_post( $form_id ); |
|
| 378 | + $form_id = intval($_POST['form_id']); |
|
| 379 | + $form = get_post($form_id); |
|
| 380 | 380 | |
| 381 | - if ( 'give_forms' != $form->post_type ) { |
|
| 382 | - die( '-2' ); |
|
| 381 | + if ('give_forms' != $form->post_type) { |
|
| 382 | + die('-2'); |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - if ( give_has_variable_prices( $form_id ) ) { |
|
| 386 | - $variable_prices = give_get_variable_prices( $form_id ); |
|
| 385 | + if (give_has_variable_prices($form_id)) { |
|
| 386 | + $variable_prices = give_get_variable_prices($form_id); |
|
| 387 | 387 | |
| 388 | - if ( $variable_prices ) { |
|
| 388 | + if ($variable_prices) { |
|
| 389 | 389 | $ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">'; |
| 390 | 390 | |
| 391 | - if ( isset( $_POST['all_prices'] ) ) { |
|
| 392 | - $ajax_response .= '<option value="">' . esc_html__( 'All Levels', 'give' ) . '</option>'; |
|
| 391 | + if (isset($_POST['all_prices'])) { |
|
| 392 | + $ajax_response .= '<option value="">'.esc_html__('All Levels', 'give').'</option>'; |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | - foreach ( $variable_prices as $key => $price ) { |
|
| 395 | + foreach ($variable_prices as $key => $price) { |
|
| 396 | 396 | |
| 397 | - $level_text = ! empty( $price['_give_text'] ) ? esc_html( $price['_give_text'] ) : give_currency_filter( give_format_amount( $price['_give_amount'] ) ); |
|
| 397 | + $level_text = ! empty($price['_give_text']) ? esc_html($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount'])); |
|
| 398 | 398 | |
| 399 | - $ajax_response .= '<option value="' . esc_attr( $price['_give_id']['level_id'] ) . '">' . $level_text . '</option>'; |
|
| 399 | + $ajax_response .= '<option value="'.esc_attr($price['_give_id']['level_id']).'">'.$level_text.'</option>'; |
|
| 400 | 400 | } |
| 401 | 401 | $ajax_response .= '</select>'; |
| 402 | 402 | echo $ajax_response; |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | give_die(); |
| 408 | 408 | } |
| 409 | 409 | |
| 410 | -add_action( 'wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations' ); |
|
| 410 | +add_action('wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations'); |
|
| 411 | 411 | |
| 412 | 412 | |
| 413 | 413 | /** |
@@ -418,30 +418,30 @@ discard block |
||
| 418 | 418 | * @return void |
| 419 | 419 | */ |
| 420 | 420 | function give_check_for_form_price_variations_html() { |
| 421 | - if ( ! current_user_can( 'edit_give_payments', get_current_user_id() ) ) { |
|
| 421 | + if ( ! current_user_can('edit_give_payments', get_current_user_id())) { |
|
| 422 | 422 | wp_die(); |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | - $form_id = intval( $_POST['form_id'] ); |
|
| 426 | - $payment_id = intval( $_POST['payment_id'] ); |
|
| 427 | - $form = get_post( $form_id ); |
|
| 425 | + $form_id = intval($_POST['form_id']); |
|
| 426 | + $payment_id = intval($_POST['payment_id']); |
|
| 427 | + $form = get_post($form_id); |
|
| 428 | 428 | |
| 429 | - if ( 'give_forms' != $form->post_type ) { |
|
| 429 | + if ('give_forms' != $form->post_type) { |
|
| 430 | 430 | wp_die(); |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
| 434 | - esc_html_e( 'n/a', 'give' ); |
|
| 433 | + if ( ! give_has_variable_prices($form_id)) { |
|
| 434 | + esc_html_e('n/a', 'give'); |
|
| 435 | 435 | } else { |
| 436 | 436 | // Payment object. |
| 437 | - $payment = new Give_Payment( $payment_id ); |
|
| 437 | + $payment = new Give_Payment($payment_id); |
|
| 438 | 438 | |
| 439 | 439 | // Payment meta. |
| 440 | 440 | $payment_meta = $payment->get_meta(); |
| 441 | 441 | |
| 442 | 442 | |
| 443 | 443 | // Variable price dropdown options. |
| 444 | - $variable_price_dropdown_option = array( |
|
| 444 | + $variable_price_dropdown_option = array( |
|
| 445 | 445 | 'id' => $form_id, |
| 446 | 446 | 'name' => 'give-variable-price', |
| 447 | 447 | 'chosen' => true, |
@@ -450,10 +450,10 @@ discard block |
||
| 450 | 450 | ); |
| 451 | 451 | |
| 452 | 452 | // Render variable prices select tag html. |
| 453 | - give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true ); |
|
| 453 | + give_get_form_variable_price_dropdown($variable_price_dropdown_option, true); |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | give_die(); |
| 457 | 457 | } |
| 458 | 458 | |
| 459 | -add_action( 'wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html' ); |
|
| 459 | +add_action('wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html'); |
|
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -31,11 +31,11 @@ discard block |
||
| 31 | 31 | /* @var WPDB $wpdb */ |
| 32 | 32 | global $wpdb; |
| 33 | 33 | |
| 34 | - $this->table_name = $wpdb->prefix . 'give_customermeta'; |
|
| 34 | + $this->table_name = $wpdb->prefix.'give_customermeta'; |
|
| 35 | 35 | $this->primary_key = 'meta_id'; |
| 36 | 36 | $this->version = '1.0'; |
| 37 | 37 | |
| 38 | - add_action( 'plugins_loaded', array( $this, 'register_table' ), 11 ); |
|
| 38 | + add_action('plugins_loaded', array($this, 'register_table'), 11); |
|
| 39 | 39 | |
| 40 | 40 | } |
| 41 | 41 | |
@@ -79,13 +79,13 @@ discard block |
||
| 79 | 79 | * @access private |
| 80 | 80 | * @since 1.6 |
| 81 | 81 | */ |
| 82 | - public function get_meta( $customer_id = 0, $meta_key = '', $single = false ) { |
|
| 83 | - $customer_id = $this->sanitize_customer_id( $customer_id ); |
|
| 84 | - if ( false === $customer_id ) { |
|
| 82 | + public function get_meta($customer_id = 0, $meta_key = '', $single = false) { |
|
| 83 | + $customer_id = $this->sanitize_customer_id($customer_id); |
|
| 84 | + if (false === $customer_id) { |
|
| 85 | 85 | return false; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - return get_metadata( 'customer', $customer_id, $meta_key, $single ); |
|
| 88 | + return get_metadata('customer', $customer_id, $meta_key, $single); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -103,13 +103,13 @@ discard block |
||
| 103 | 103 | * @access private |
| 104 | 104 | * @since 1.6 |
| 105 | 105 | */ |
| 106 | - public function add_meta( $customer_id = 0, $meta_key = '', $meta_value, $unique = false ) { |
|
| 107 | - $customer_id = $this->sanitize_customer_id( $customer_id ); |
|
| 108 | - if ( false === $customer_id ) { |
|
| 106 | + public function add_meta($customer_id = 0, $meta_key = '', $meta_value, $unique = false) { |
|
| 107 | + $customer_id = $this->sanitize_customer_id($customer_id); |
|
| 108 | + if (false === $customer_id) { |
|
| 109 | 109 | return false; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - return add_metadata( 'customer', $customer_id, $meta_key, $meta_value, $unique ); |
|
| 112 | + return add_metadata('customer', $customer_id, $meta_key, $meta_value, $unique); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -132,13 +132,13 @@ discard block |
||
| 132 | 132 | * @access private |
| 133 | 133 | * @since 1.6 |
| 134 | 134 | */ |
| 135 | - public function update_meta( $customer_id = 0, $meta_key = '', $meta_value, $prev_value = '' ) { |
|
| 136 | - $customer_id = $this->sanitize_customer_id( $customer_id ); |
|
| 137 | - if ( false === $customer_id ) { |
|
| 135 | + public function update_meta($customer_id = 0, $meta_key = '', $meta_value, $prev_value = '') { |
|
| 136 | + $customer_id = $this->sanitize_customer_id($customer_id); |
|
| 137 | + if (false === $customer_id) { |
|
| 138 | 138 | return false; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - return update_metadata( 'customer', $customer_id, $meta_key, $meta_value, $prev_value ); |
|
| 141 | + return update_metadata('customer', $customer_id, $meta_key, $meta_value, $prev_value); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
@@ -159,8 +159,8 @@ discard block |
||
| 159 | 159 | * @access private |
| 160 | 160 | * @since 1.6 |
| 161 | 161 | */ |
| 162 | - public function delete_meta( $customer_id = 0, $meta_key = '', $meta_value = '' ) { |
|
| 163 | - return delete_metadata( 'customer', $customer_id, $meta_key, $meta_value ); |
|
| 162 | + public function delete_meta($customer_id = 0, $meta_key = '', $meta_value = '') { |
|
| 163 | + return delete_metadata('customer', $customer_id, $meta_key, $meta_value); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | /** |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | */ |
| 172 | 172 | public function create_table() { |
| 173 | 173 | |
| 174 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 174 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 175 | 175 | |
| 176 | 176 | $sql = "CREATE TABLE {$this->table_name} ( |
| 177 | 177 | meta_id bigint(20) NOT NULL AUTO_INCREMENT, |
@@ -183,9 +183,9 @@ discard block |
||
| 183 | 183 | KEY meta_key (meta_key) |
| 184 | 184 | ) CHARACTER SET utf8 COLLATE utf8_general_ci;"; |
| 185 | 185 | |
| 186 | - dbDelta( $sql ); |
|
| 186 | + dbDelta($sql); |
|
| 187 | 187 | |
| 188 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
| 188 | + update_option($this->table_name.'_db_version', $this->version); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | /** |
@@ -197,23 +197,23 @@ discard block |
||
| 197 | 197 | * |
| 198 | 198 | * @return int|bool The normalized customer ID or false if it's found to not be valid. |
| 199 | 199 | */ |
| 200 | - private function sanitize_customer_id( $customer_id ) { |
|
| 201 | - if ( ! is_numeric( $customer_id ) ) { |
|
| 200 | + private function sanitize_customer_id($customer_id) { |
|
| 201 | + if ( ! is_numeric($customer_id)) { |
|
| 202 | 202 | return false; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | $customer_id = (int) $customer_id; |
| 206 | 206 | |
| 207 | 207 | // We were given a non positive number |
| 208 | - if ( absint( $customer_id ) !== $customer_id ) { |
|
| 208 | + if (absint($customer_id) !== $customer_id) { |
|
| 209 | 209 | return false; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - if ( empty( $customer_id ) ) { |
|
| 212 | + if (empty($customer_id)) { |
|
| 213 | 213 | return false; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - return absint( $customer_id ); |
|
| 216 | + return absint($customer_id); |
|
| 217 | 217 | |
| 218 | 218 | } |
| 219 | 219 | |
@@ -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,14 +24,14 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @return string |
| 26 | 26 | */ |
| 27 | -function give_admin_rate_us( $footer_text ) { |
|
| 27 | +function give_admin_rate_us($footer_text) { |
|
| 28 | 28 | global $typenow; |
| 29 | 29 | |
| 30 | - if ( $typenow == 'give_forms' ) { |
|
| 30 | + if ($typenow == 'give_forms') { |
|
| 31 | 31 | $rate_text = sprintf( |
| 32 | 32 | /* translators: %s: Link to 5 star rating */ |
| 33 | - __( 'If you like <strong>Give</strong> please leave us a %s rating. It takes a minute and helps a lot. Thanks in advance!', 'give' ), |
|
| 34 | - '<a href="https://wordpress.org/support/view/plugin-reviews/give?filter=5#postform" target="_blank" class="give-rating-link" data-rated="' . esc_attr__( 'Thanks :)', 'give' ) . '">★★★★★</a>' |
|
| 33 | + __('If you like <strong>Give</strong> please leave us a %s rating. It takes a minute and helps a lot. Thanks in advance!', 'give'), |
|
| 34 | + '<a href="https://wordpress.org/support/view/plugin-reviews/give?filter=5#postform" target="_blank" class="give-rating-link" data-rated="'.esc_attr__('Thanks :)', 'give').'">★★★★★</a>' |
|
| 35 | 35 | ); |
| 36 | 36 | |
| 37 | 37 | return $rate_text; |
@@ -40,4 +40,4 @@ discard block |
||
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | -add_filter( 'admin_footer_text', 'give_admin_rate_us' ); |
|
| 43 | +add_filter('admin_footer_text', 'give_admin_rate_us'); |
|
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * @since 1.0 |
| 159 | 159 | * @access public |
| 160 | 160 | * |
| 161 | - * @param bool|string|int $_id_or_email |
|
| 161 | + * @param integer $_id_or_email |
|
| 162 | 162 | * |
| 163 | 163 | * @return bool|int |
| 164 | 164 | */ |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | * @param int $user_id User ID. |
| 314 | 314 | * @param WP_User $old_user_data User data. |
| 315 | 315 | * |
| 316 | - * @return bool |
|
| 316 | + * @return false|null |
|
| 317 | 317 | */ |
| 318 | 318 | public function update_customer_email_on_user_update( $user_id = 0, $old_user_data ) { |
| 319 | 319 | |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | * @access public |
| 363 | 363 | * |
| 364 | 364 | * @param string $field ID or email. Default is 'id'. |
| 365 | - * @param mixed $value The Customer ID or email to search. Default is 0. |
|
| 365 | + * @param integer $value The Customer ID or email to search. Default is 0. |
|
| 366 | 366 | * |
| 367 | 367 | * @return mixed Upon success, an object of the customer. Upon failure, NULL |
| 368 | 368 | */ |
@@ -427,13 +427,13 @@ discard block |
||
| 427 | 427 | * |
| 428 | 428 | * @since 1.0 |
| 429 | 429 | * @access public |
| 430 | - * |
|
| 431 | - * @param array $args |
|
| 432 | - * |
|
| 433 | - * @return array|object|null Customers array or object. Null if not found. |
|
| 430 | + * |
|
| 431 | + * @param array $args |
|
| 432 | + * |
|
| 433 | + * @return array|object|null Customers array or object. Null if not found. |
|
| 434 | 434 | */ |
| 435 | 435 | public function get_customers( $args = array() ) { |
| 436 | - /* @var WPDB $wpdb */ |
|
| 436 | + /* @var WPDB $wpdb */ |
|
| 437 | 437 | global $wpdb; |
| 438 | 438 | |
| 439 | 439 | $defaults = array( |
@@ -558,13 +558,13 @@ discard block |
||
| 558 | 558 | * |
| 559 | 559 | * @since 1.0 |
| 560 | 560 | * @access public |
| 561 | - * |
|
| 562 | - * @param array $args |
|
| 563 | - * |
|
| 564 | - * @return int Total number of customers. |
|
| 561 | + * |
|
| 562 | + * @param array $args |
|
| 563 | + * |
|
| 564 | + * @return int Total number of customers. |
|
| 565 | 565 | */ |
| 566 | 566 | public function count( $args = array() ) { |
| 567 | - /* @var WPDB $wpdb */ |
|
| 567 | + /* @var WPDB $wpdb */ |
|
| 568 | 568 | global $wpdb; |
| 569 | 569 | |
| 570 | 570 | $where = ' WHERE 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 | |
@@ -35,11 +35,11 @@ discard block |
||
| 35 | 35 | /* @var WPDB $wpdb */ |
| 36 | 36 | global $wpdb; |
| 37 | 37 | |
| 38 | - $this->table_name = $wpdb->prefix . 'give_customers'; |
|
| 38 | + $this->table_name = $wpdb->prefix.'give_customers'; |
|
| 39 | 39 | $this->primary_key = 'id'; |
| 40 | 40 | $this->version = '1.0'; |
| 41 | 41 | |
| 42 | - add_action( 'profile_update', array( $this, 'update_customer_email_on_user_update' ), 10, 2 ); |
|
| 42 | + add_action('profile_update', array($this, 'update_customer_email_on_user_update'), 10, 2); |
|
| 43 | 43 | |
| 44 | 44 | } |
| 45 | 45 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | 'purchase_value' => 0.00, |
| 83 | 83 | 'purchase_count' => 0, |
| 84 | 84 | 'notes' => '', |
| 85 | - 'date_created' => date( 'Y-m-d H:i:s' ), |
|
| 85 | + 'date_created' => date('Y-m-d H:i:s'), |
|
| 86 | 86 | ); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -96,40 +96,40 @@ discard block |
||
| 96 | 96 | * |
| 97 | 97 | * @return int|bool |
| 98 | 98 | */ |
| 99 | - public function add( $data = array() ) { |
|
| 99 | + public function add($data = array()) { |
|
| 100 | 100 | |
| 101 | 101 | $defaults = array( |
| 102 | 102 | 'payment_ids' => '' |
| 103 | 103 | ); |
| 104 | 104 | |
| 105 | - $args = wp_parse_args( $data, $defaults ); |
|
| 105 | + $args = wp_parse_args($data, $defaults); |
|
| 106 | 106 | |
| 107 | - if ( empty( $args['email'] ) ) { |
|
| 107 | + if (empty($args['email'])) { |
|
| 108 | 108 | return false; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
| 112 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
| 111 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
| 112 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - $customer = $this->get_customer_by( 'email', $args['email'] ); |
|
| 115 | + $customer = $this->get_customer_by('email', $args['email']); |
|
| 116 | 116 | |
| 117 | - if ( $customer ) { |
|
| 117 | + if ($customer) { |
|
| 118 | 118 | // update an existing customer |
| 119 | 119 | |
| 120 | 120 | // Update the payment IDs attached to the customer |
| 121 | - if ( ! empty( $args['payment_ids'] ) ) { |
|
| 121 | + if ( ! empty($args['payment_ids'])) { |
|
| 122 | 122 | |
| 123 | - if ( empty( $customer->payment_ids ) ) { |
|
| 123 | + if (empty($customer->payment_ids)) { |
|
| 124 | 124 | |
| 125 | 125 | $customer->payment_ids = $args['payment_ids']; |
| 126 | 126 | |
| 127 | 127 | } else { |
| 128 | 128 | |
| 129 | - $existing_ids = array_map( 'absint', explode( ',', $customer->payment_ids ) ); |
|
| 130 | - $payment_ids = array_map( 'absint', explode( ',', $args['payment_ids'] ) ); |
|
| 131 | - $payment_ids = array_merge( $payment_ids, $existing_ids ); |
|
| 132 | - $customer->payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
| 129 | + $existing_ids = array_map('absint', explode(',', $customer->payment_ids)); |
|
| 130 | + $payment_ids = array_map('absint', explode(',', $args['payment_ids'])); |
|
| 131 | + $payment_ids = array_merge($payment_ids, $existing_ids); |
|
| 132 | + $customer->payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
| 133 | 133 | |
| 134 | 134 | } |
| 135 | 135 | |
@@ -137,13 +137,13 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - $this->update( $customer->id, $args ); |
|
| 140 | + $this->update($customer->id, $args); |
|
| 141 | 141 | |
| 142 | 142 | return $customer->id; |
| 143 | 143 | |
| 144 | 144 | } else { |
| 145 | 145 | |
| 146 | - return $this->insert( $args, 'customer' ); |
|
| 146 | + return $this->insert($args, 'customer'); |
|
| 147 | 147 | |
| 148 | 148 | } |
| 149 | 149 | |
@@ -162,20 +162,20 @@ discard block |
||
| 162 | 162 | * |
| 163 | 163 | * @return bool|int |
| 164 | 164 | */ |
| 165 | - public function delete( $_id_or_email = false ) { |
|
| 165 | + public function delete($_id_or_email = false) { |
|
| 166 | 166 | |
| 167 | - if ( empty( $_id_or_email ) ) { |
|
| 167 | + if (empty($_id_or_email)) { |
|
| 168 | 168 | return false; |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - $column = is_email( $_id_or_email ) ? 'email' : 'id'; |
|
| 172 | - $customer = $this->get_customer_by( $column, $_id_or_email ); |
|
| 171 | + $column = is_email($_id_or_email) ? 'email' : 'id'; |
|
| 172 | + $customer = $this->get_customer_by($column, $_id_or_email); |
|
| 173 | 173 | |
| 174 | - if ( $customer->id > 0 ) { |
|
| 174 | + if ($customer->id > 0) { |
|
| 175 | 175 | |
| 176 | 176 | global $wpdb; |
| 177 | 177 | |
| 178 | - return $wpdb->delete( $this->table_name, array( 'id' => $customer->id ), array( '%d' ) ); |
|
| 178 | + return $wpdb->delete($this->table_name, array('id' => $customer->id), array('%d')); |
|
| 179 | 179 | |
| 180 | 180 | } else { |
| 181 | 181 | return false; |
@@ -194,14 +194,14 @@ discard block |
||
| 194 | 194 | * |
| 195 | 195 | * @return bool True is exists, false otherwise. |
| 196 | 196 | */ |
| 197 | - public function exists( $value = '', $field = 'email' ) { |
|
| 197 | + public function exists($value = '', $field = 'email') { |
|
| 198 | 198 | |
| 199 | 199 | $columns = $this->get_columns(); |
| 200 | - if ( ! array_key_exists( $field, $columns ) ) { |
|
| 200 | + if ( ! array_key_exists($field, $columns)) { |
|
| 201 | 201 | return false; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - return (bool) $this->get_column_by( 'id', $field, $value ); |
|
| 204 | + return (bool) $this->get_column_by('id', $field, $value); |
|
| 205 | 205 | |
| 206 | 206 | } |
| 207 | 207 | |
@@ -216,16 +216,16 @@ discard block |
||
| 216 | 216 | * |
| 217 | 217 | * @return bool |
| 218 | 218 | */ |
| 219 | - public function attach_payment( $customer_id = 0, $payment_id = 0 ) { |
|
| 219 | + public function attach_payment($customer_id = 0, $payment_id = 0) { |
|
| 220 | 220 | |
| 221 | - $customer = new Give_Customer( $customer_id ); |
|
| 221 | + $customer = new Give_Customer($customer_id); |
|
| 222 | 222 | |
| 223 | - if ( empty( $customer->id ) ) { |
|
| 223 | + if (empty($customer->id)) { |
|
| 224 | 224 | return false; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | // Attach the payment, but don't increment stats, as this function previously did not |
| 228 | - return $customer->attach_payment( $payment_id, false ); |
|
| 228 | + return $customer->attach_payment($payment_id, false); |
|
| 229 | 229 | |
| 230 | 230 | } |
| 231 | 231 | |
@@ -240,16 +240,16 @@ discard block |
||
| 240 | 240 | * |
| 241 | 241 | * @return bool |
| 242 | 242 | */ |
| 243 | - public function remove_payment( $customer_id = 0, $payment_id = 0 ) { |
|
| 243 | + public function remove_payment($customer_id = 0, $payment_id = 0) { |
|
| 244 | 244 | |
| 245 | - $customer = new Give_Customer( $customer_id ); |
|
| 245 | + $customer = new Give_Customer($customer_id); |
|
| 246 | 246 | |
| 247 | - if ( ! $customer ) { |
|
| 247 | + if ( ! $customer) { |
|
| 248 | 248 | return false; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | // Remove the payment, but don't decrease stats, as this function previously did not |
| 252 | - return $customer->remove_payment( $payment_id, false ); |
|
| 252 | + return $customer->remove_payment($payment_id, false); |
|
| 253 | 253 | |
| 254 | 254 | } |
| 255 | 255 | |
@@ -263,18 +263,18 @@ discard block |
||
| 263 | 263 | * |
| 264 | 264 | * @return bool |
| 265 | 265 | */ |
| 266 | - public function increment_stats( $customer_id = 0, $amount = 0.00 ) { |
|
| 266 | + public function increment_stats($customer_id = 0, $amount = 0.00) { |
|
| 267 | 267 | |
| 268 | - $customer = new Give_Customer( $customer_id ); |
|
| 268 | + $customer = new Give_Customer($customer_id); |
|
| 269 | 269 | |
| 270 | - if ( empty( $customer->id ) ) { |
|
| 270 | + if (empty($customer->id)) { |
|
| 271 | 271 | return false; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | $increased_count = $customer->increase_purchase_count(); |
| 275 | - $increased_value = $customer->increase_value( $amount ); |
|
| 275 | + $increased_value = $customer->increase_value($amount); |
|
| 276 | 276 | |
| 277 | - return ( $increased_count && $increased_value ) ? true : false; |
|
| 277 | + return ($increased_count && $increased_value) ? true : false; |
|
| 278 | 278 | |
| 279 | 279 | } |
| 280 | 280 | |
@@ -289,18 +289,18 @@ discard block |
||
| 289 | 289 | * |
| 290 | 290 | * @return bool |
| 291 | 291 | */ |
| 292 | - public function decrement_stats( $customer_id = 0, $amount = 0.00 ) { |
|
| 292 | + public function decrement_stats($customer_id = 0, $amount = 0.00) { |
|
| 293 | 293 | |
| 294 | - $customer = new Give_Customer( $customer_id ); |
|
| 294 | + $customer = new Give_Customer($customer_id); |
|
| 295 | 295 | |
| 296 | - if ( ! $customer ) { |
|
| 296 | + if ( ! $customer) { |
|
| 297 | 297 | return false; |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | $decreased_count = $customer->decrease_purchase_count(); |
| 301 | - $decreased_value = $customer->decrease_value( $amount ); |
|
| 301 | + $decreased_value = $customer->decrease_value($amount); |
|
| 302 | 302 | |
| 303 | - return ( $decreased_count && $decreased_value ) ? true : false; |
|
| 303 | + return ($decreased_count && $decreased_value) ? true : false; |
|
| 304 | 304 | |
| 305 | 305 | } |
| 306 | 306 | |
@@ -315,31 +315,31 @@ discard block |
||
| 315 | 315 | * |
| 316 | 316 | * @return bool |
| 317 | 317 | */ |
| 318 | - public function update_customer_email_on_user_update( $user_id = 0, $old_user_data ) { |
|
| 318 | + public function update_customer_email_on_user_update($user_id = 0, $old_user_data) { |
|
| 319 | 319 | |
| 320 | - $customer = new Give_Customer( $user_id, true ); |
|
| 320 | + $customer = new Give_Customer($user_id, true); |
|
| 321 | 321 | |
| 322 | - if( ! $customer ) { |
|
| 322 | + if ( ! $customer) { |
|
| 323 | 323 | return false; |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - $user = get_userdata( $user_id ); |
|
| 326 | + $user = get_userdata($user_id); |
|
| 327 | 327 | |
| 328 | - if( ! empty( $user ) && $user->user_email !== $customer->email ) { |
|
| 328 | + if ( ! empty($user) && $user->user_email !== $customer->email) { |
|
| 329 | 329 | |
| 330 | - if( ! $this->get_customer_by( 'email', $user->user_email ) ) { |
|
| 330 | + if ( ! $this->get_customer_by('email', $user->user_email)) { |
|
| 331 | 331 | |
| 332 | - $success = $this->update( $customer->id, array( 'email' => $user->user_email ) ); |
|
| 332 | + $success = $this->update($customer->id, array('email' => $user->user_email)); |
|
| 333 | 333 | |
| 334 | - if( $success ) { |
|
| 334 | + if ($success) { |
|
| 335 | 335 | // Update some payment meta if we need to |
| 336 | - $payments_array = explode( ',', $customer->payment_ids ); |
|
| 336 | + $payments_array = explode(',', $customer->payment_ids); |
|
| 337 | 337 | |
| 338 | - if( ! empty( $payments_array ) ) { |
|
| 338 | + if ( ! empty($payments_array)) { |
|
| 339 | 339 | |
| 340 | - foreach ( $payments_array as $payment_id ) { |
|
| 340 | + foreach ($payments_array as $payment_id) { |
|
| 341 | 341 | |
| 342 | - give_update_payment_meta( $payment_id, 'email', $user->user_email ); |
|
| 342 | + give_update_payment_meta($payment_id, 'email', $user->user_email); |
|
| 343 | 343 | |
| 344 | 344 | } |
| 345 | 345 | |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | * @param WP_User $user WordPress User object. |
| 354 | 354 | * @param Give_Customer $customer Give customer object. |
| 355 | 355 | */ |
| 356 | - do_action( 'give_update_customer_email_on_user_update', $user, $customer ); |
|
| 356 | + do_action('give_update_customer_email_on_user_update', $user, $customer); |
|
| 357 | 357 | |
| 358 | 358 | } |
| 359 | 359 | |
@@ -374,46 +374,46 @@ discard block |
||
| 374 | 374 | * |
| 375 | 375 | * @return mixed Upon success, an object of the customer. Upon failure, NULL |
| 376 | 376 | */ |
| 377 | - public function get_customer_by( $field = 'id', $value = 0 ) { |
|
| 377 | + public function get_customer_by($field = 'id', $value = 0) { |
|
| 378 | 378 | /* @var WPDB $wpdb */ |
| 379 | 379 | global $wpdb; |
| 380 | 380 | |
| 381 | - if ( empty( $field ) || empty( $value ) ) { |
|
| 381 | + if (empty($field) || empty($value)) { |
|
| 382 | 382 | return null; |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - if ( 'id' == $field || 'user_id' == $field ) { |
|
| 385 | + if ('id' == $field || 'user_id' == $field) { |
|
| 386 | 386 | // Make sure the value is numeric to avoid casting objects, for example, |
| 387 | 387 | // to int 1. |
| 388 | - if ( ! is_numeric( $value ) ) { |
|
| 388 | + if ( ! is_numeric($value)) { |
|
| 389 | 389 | return false; |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - $value = intval( $value ); |
|
| 392 | + $value = intval($value); |
|
| 393 | 393 | |
| 394 | - if ( $value < 1 ) { |
|
| 394 | + if ($value < 1) { |
|
| 395 | 395 | return false; |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | - } elseif ( 'email' === $field ) { |
|
| 398 | + } elseif ('email' === $field) { |
|
| 399 | 399 | |
| 400 | - if ( ! is_email( $value ) ) { |
|
| 400 | + if ( ! is_email($value)) { |
|
| 401 | 401 | return false; |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | - $value = trim( $value ); |
|
| 404 | + $value = trim($value); |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | - if ( ! $value ) { |
|
| 407 | + if ( ! $value) { |
|
| 408 | 408 | return false; |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - switch ( $field ) { |
|
| 411 | + switch ($field) { |
|
| 412 | 412 | case 'id': |
| 413 | 413 | $db_field = 'id'; |
| 414 | 414 | break; |
| 415 | 415 | case 'email': |
| 416 | - $value = sanitize_text_field( $value ); |
|
| 416 | + $value = sanitize_text_field($value); |
|
| 417 | 417 | $db_field = 'email'; |
| 418 | 418 | break; |
| 419 | 419 | case 'user_id': |
@@ -423,15 +423,15 @@ discard block |
||
| 423 | 423 | return false; |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | - if ( ! $customer = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $db_field = %s LIMIT 1", $value ) ) ) { |
|
| 426 | + if ( ! $customer = $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $db_field = %s LIMIT 1", $value))) { |
|
| 427 | 427 | |
| 428 | 428 | // Look for customer from an additional email |
| 429 | - if( 'email' === $field ) { |
|
| 429 | + if ('email' === $field) { |
|
| 430 | 430 | $meta_table = Give()->customer_meta->table_name; |
| 431 | - $customer_id = $wpdb->get_var( $wpdb->prepare( "SELECT customer_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $value ) ); |
|
| 431 | + $customer_id = $wpdb->get_var($wpdb->prepare("SELECT customer_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $value)); |
|
| 432 | 432 | |
| 433 | - if( ! empty( $customer_id ) ) { |
|
| 434 | - return $this->get( $customer_id ); |
|
| 433 | + if ( ! empty($customer_id)) { |
|
| 434 | + return $this->get($customer_id); |
|
| 435 | 435 | } |
| 436 | 436 | } |
| 437 | 437 | |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | * |
| 452 | 452 | * @return array|object|null Customers array or object. Null if not found. |
| 453 | 453 | */ |
| 454 | - public function get_customers( $args = array() ) { |
|
| 454 | + public function get_customers($args = array()) { |
|
| 455 | 455 | /* @var WPDB $wpdb */ |
| 456 | 456 | global $wpdb; |
| 457 | 457 | |
@@ -463,21 +463,21 @@ discard block |
||
| 463 | 463 | 'order' => 'DESC' |
| 464 | 464 | ); |
| 465 | 465 | |
| 466 | - $args = wp_parse_args( $args, $defaults ); |
|
| 466 | + $args = wp_parse_args($args, $defaults); |
|
| 467 | 467 | |
| 468 | - if ( $args['number'] < 1 ) { |
|
| 468 | + if ($args['number'] < 1) { |
|
| 469 | 469 | $args['number'] = 999999999999; |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | $where = ' WHERE 1=1 '; |
| 473 | 473 | |
| 474 | 474 | // specific customers |
| 475 | - if ( ! empty( $args['id'] ) ) { |
|
| 475 | + if ( ! empty($args['id'])) { |
|
| 476 | 476 | |
| 477 | - if ( is_array( $args['id'] ) ) { |
|
| 478 | - $ids = implode( ',', array_map( 'intval', $args['id'] ) ); |
|
| 477 | + if (is_array($args['id'])) { |
|
| 478 | + $ids = implode(',', array_map('intval', $args['id'])); |
|
| 479 | 479 | } else { |
| 480 | - $ids = intval( $args['id'] ); |
|
| 480 | + $ids = intval($args['id']); |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | $where .= " AND `id` IN( {$ids} ) "; |
@@ -485,12 +485,12 @@ discard block |
||
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | // customers for specific user accounts |
| 488 | - if ( ! empty( $args['user_id'] ) ) { |
|
| 488 | + if ( ! empty($args['user_id'])) { |
|
| 489 | 489 | |
| 490 | - if ( is_array( $args['user_id'] ) ) { |
|
| 491 | - $user_ids = implode( ',', array_map( 'intval', $args['user_id'] ) ); |
|
| 490 | + if (is_array($args['user_id'])) { |
|
| 491 | + $user_ids = implode(',', array_map('intval', $args['user_id'])); |
|
| 492 | 492 | } else { |
| 493 | - $user_ids = intval( $args['user_id'] ); |
|
| 493 | + $user_ids = intval($args['user_id']); |
|
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | $where .= " AND `user_id` IN( {$user_ids} ) "; |
@@ -498,41 +498,41 @@ discard block |
||
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | //specific customers by email |
| 501 | - if( ! empty( $args['email'] ) ) { |
|
| 501 | + if ( ! empty($args['email'])) { |
|
| 502 | 502 | |
| 503 | - if( is_array( $args['email'] ) ) { |
|
| 503 | + if (is_array($args['email'])) { |
|
| 504 | 504 | |
| 505 | - $emails_count = count( $args['email'] ); |
|
| 506 | - $emails_placeholder = array_fill( 0, $emails_count, '%s' ); |
|
| 507 | - $emails = implode( ', ', $emails_placeholder ); |
|
| 505 | + $emails_count = count($args['email']); |
|
| 506 | + $emails_placeholder = array_fill(0, $emails_count, '%s'); |
|
| 507 | + $emails = implode(', ', $emails_placeholder); |
|
| 508 | 508 | |
| 509 | - $where .= $wpdb->prepare( " AND `email` IN( $emails ) ", $args['email'] ); |
|
| 509 | + $where .= $wpdb->prepare(" AND `email` IN( $emails ) ", $args['email']); |
|
| 510 | 510 | } else { |
| 511 | - $where .= $wpdb->prepare( " AND `email` = %s ", $args['email'] ); |
|
| 511 | + $where .= $wpdb->prepare(" AND `email` = %s ", $args['email']); |
|
| 512 | 512 | } |
| 513 | 513 | } |
| 514 | 514 | |
| 515 | 515 | // specific customers by name |
| 516 | - if( ! empty( $args['name'] ) ) { |
|
| 517 | - $where .= $wpdb->prepare( " AND `name` LIKE '%%%%" . '%s' . "%%%%' ", $args['name'] ); |
|
| 516 | + if ( ! empty($args['name'])) { |
|
| 517 | + $where .= $wpdb->prepare(" AND `name` LIKE '%%%%".'%s'."%%%%' ", $args['name']); |
|
| 518 | 518 | } |
| 519 | 519 | |
| 520 | 520 | // Customers created for a specific date or in a date range |
| 521 | - if ( ! empty( $args['date'] ) ) { |
|
| 521 | + if ( ! empty($args['date'])) { |
|
| 522 | 522 | |
| 523 | - if ( is_array( $args['date'] ) ) { |
|
| 523 | + if (is_array($args['date'])) { |
|
| 524 | 524 | |
| 525 | - if ( ! empty( $args['date']['start'] ) ) { |
|
| 525 | + if ( ! empty($args['date']['start'])) { |
|
| 526 | 526 | |
| 527 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) ); |
|
| 527 | + $start = date('Y-m-d H:i:s', strtotime($args['date']['start'])); |
|
| 528 | 528 | |
| 529 | 529 | $where .= " AND `date_created` >= '{$start}'"; |
| 530 | 530 | |
| 531 | 531 | } |
| 532 | 532 | |
| 533 | - if ( ! empty( $args['date']['end'] ) ) { |
|
| 533 | + if ( ! empty($args['date']['end'])) { |
|
| 534 | 534 | |
| 535 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) ); |
|
| 535 | + $end = date('Y-m-d H:i:s', strtotime($args['date']['end'])); |
|
| 536 | 536 | |
| 537 | 537 | $where .= " AND `date_created` <= '{$end}'"; |
| 538 | 538 | |
@@ -540,31 +540,31 @@ discard block |
||
| 540 | 540 | |
| 541 | 541 | } else { |
| 542 | 542 | |
| 543 | - $year = date( 'Y', strtotime( $args['date'] ) ); |
|
| 544 | - $month = date( 'm', strtotime( $args['date'] ) ); |
|
| 545 | - $day = date( 'd', strtotime( $args['date'] ) ); |
|
| 543 | + $year = date('Y', strtotime($args['date'])); |
|
| 544 | + $month = date('m', strtotime($args['date'])); |
|
| 545 | + $day = date('d', strtotime($args['date'])); |
|
| 546 | 546 | |
| 547 | 547 | $where .= " AND $year = YEAR ( date_created ) AND $month = MONTH ( date_created ) AND $day = DAY ( date_created )"; |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | } |
| 551 | 551 | |
| 552 | - $args['orderby'] = ! array_key_exists( $args['orderby'], $this->get_columns() ) ? 'id' : $args['orderby']; |
|
| 552 | + $args['orderby'] = ! array_key_exists($args['orderby'], $this->get_columns()) ? 'id' : $args['orderby']; |
|
| 553 | 553 | |
| 554 | - if ( 'purchase_value' == $args['orderby'] ) { |
|
| 554 | + if ('purchase_value' == $args['orderby']) { |
|
| 555 | 555 | $args['orderby'] = 'purchase_value+0'; |
| 556 | 556 | } |
| 557 | 557 | |
| 558 | - $cache_key = md5( 'give_customers_' . serialize( $args ) ); |
|
| 558 | + $cache_key = md5('give_customers_'.serialize($args)); |
|
| 559 | 559 | |
| 560 | - $customers = wp_cache_get( $cache_key, 'customers' ); |
|
| 560 | + $customers = wp_cache_get($cache_key, 'customers'); |
|
| 561 | 561 | |
| 562 | - $args['orderby'] = esc_sql( $args['orderby'] ); |
|
| 563 | - $args['order'] = esc_sql( $args['order'] ); |
|
| 562 | + $args['orderby'] = esc_sql($args['orderby']); |
|
| 563 | + $args['order'] = esc_sql($args['order']); |
|
| 564 | 564 | |
| 565 | - if ( $customers === false ) { |
|
| 566 | - $customers = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint( $args['offset'] ), absint( $args['number'] ) ) ); |
|
| 567 | - wp_cache_set( $cache_key, $customers, 'customers', 3600 ); |
|
| 565 | + if ($customers === false) { |
|
| 566 | + $customers = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint($args['offset']), absint($args['number']))); |
|
| 567 | + wp_cache_set($cache_key, $customers, 'customers', 3600); |
|
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | return $customers; |
@@ -582,26 +582,26 @@ discard block |
||
| 582 | 582 | * |
| 583 | 583 | * @return int Total number of customers. |
| 584 | 584 | */ |
| 585 | - public function count( $args = array() ) { |
|
| 585 | + public function count($args = array()) { |
|
| 586 | 586 | /* @var WPDB $wpdb */ |
| 587 | 587 | global $wpdb; |
| 588 | 588 | |
| 589 | 589 | $where = ' WHERE 1=1 '; |
| 590 | 590 | |
| 591 | - if ( ! empty( $args['date'] ) ) { |
|
| 591 | + if ( ! empty($args['date'])) { |
|
| 592 | 592 | |
| 593 | - if ( is_array( $args['date'] ) ) { |
|
| 593 | + if (is_array($args['date'])) { |
|
| 594 | 594 | |
| 595 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) ); |
|
| 596 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) ); |
|
| 595 | + $start = date('Y-m-d H:i:s', strtotime($args['date']['start'])); |
|
| 596 | + $end = date('Y-m-d H:i:s', strtotime($args['date']['end'])); |
|
| 597 | 597 | |
| 598 | 598 | $where .= " AND `date_created` >= '{$start}' AND `date_created` <= '{$end}'"; |
| 599 | 599 | |
| 600 | 600 | } else { |
| 601 | 601 | |
| 602 | - $year = date( 'Y', strtotime( $args['date'] ) ); |
|
| 603 | - $month = date( 'm', strtotime( $args['date'] ) ); |
|
| 604 | - $day = date( 'd', strtotime( $args['date'] ) ); |
|
| 602 | + $year = date('Y', strtotime($args['date'])); |
|
| 603 | + $month = date('m', strtotime($args['date'])); |
|
| 604 | + $day = date('d', strtotime($args['date'])); |
|
| 605 | 605 | |
| 606 | 606 | $where .= " AND $year = YEAR ( date_created ) AND $month = MONTH ( date_created ) AND $day = DAY ( date_created )"; |
| 607 | 607 | } |
@@ -609,16 +609,16 @@ discard block |
||
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | |
| 612 | - $cache_key = md5( 'give_customers_count' . serialize( $args ) ); |
|
| 612 | + $cache_key = md5('give_customers_count'.serialize($args)); |
|
| 613 | 613 | |
| 614 | - $count = wp_cache_get( $cache_key, 'customers' ); |
|
| 614 | + $count = wp_cache_get($cache_key, 'customers'); |
|
| 615 | 615 | |
| 616 | - if ( $count === false ) { |
|
| 617 | - $count = $wpdb->get_var( "SELECT COUNT($this->primary_key) FROM " . $this->table_name . "{$where};" ); |
|
| 618 | - wp_cache_set( $cache_key, $count, 'customers', 3600 ); |
|
| 616 | + if ($count === false) { |
|
| 617 | + $count = $wpdb->get_var("SELECT COUNT($this->primary_key) FROM ".$this->table_name."{$where};"); |
|
| 618 | + wp_cache_set($cache_key, $count, 'customers', 3600); |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | - return absint( $count ); |
|
| 621 | + return absint($count); |
|
| 622 | 622 | |
| 623 | 623 | } |
| 624 | 624 | |
@@ -632,9 +632,9 @@ discard block |
||
| 632 | 632 | */ |
| 633 | 633 | public function create_table() { |
| 634 | 634 | |
| 635 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 635 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 636 | 636 | |
| 637 | - $sql = "CREATE TABLE " . $this->table_name . " ( |
|
| 637 | + $sql = "CREATE TABLE ".$this->table_name." ( |
|
| 638 | 638 | id bigint(20) NOT NULL AUTO_INCREMENT, |
| 639 | 639 | user_id bigint(20) NOT NULL, |
| 640 | 640 | email varchar(50) NOT NULL, |
@@ -649,9 +649,9 @@ discard block |
||
| 649 | 649 | KEY user (user_id) |
| 650 | 650 | ) CHARACTER SET utf8 COLLATE utf8_general_ci;"; |
| 651 | 651 | |
| 652 | - dbDelta( $sql ); |
|
| 652 | + dbDelta($sql); |
|
| 653 | 653 | |
| 654 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
| 654 | + update_option($this->table_name.'_db_version', $this->version); |
|
| 655 | 655 | } |
| 656 | 656 | |
| 657 | 657 | /** |
@@ -663,7 +663,7 @@ discard block |
||
| 663 | 663 | * @return bool Returns if the customers table was installed and upgrade routine run. |
| 664 | 664 | */ |
| 665 | 665 | public function installed() { |
| 666 | - return $this->table_exists( $this->table_name ); |
|
| 666 | + return $this->table_exists($this->table_name); |
|
| 667 | 667 | } |
| 668 | 668 | |
| 669 | 669 | } |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * Used to redirect a user back to the purchase |
| 157 | 157 | * page if there are errors present. |
| 158 | 158 | * |
| 159 | - * @param array $args |
|
| 159 | + * @param string $args |
|
| 160 | 160 | * |
| 161 | 161 | * @access public |
| 162 | 162 | * @since 1.0 |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | * |
| 391 | 391 | * @param int $form_id Give Form ID |
| 392 | 392 | * |
| 393 | - * @return int $earnings Earnings for a certain form |
|
| 393 | + * @return double $earnings Earnings for a certain form |
|
| 394 | 394 | */ |
| 395 | 395 | function give_get_form_earnings_stats( $form_id = 0 ) { |
| 396 | 396 | $give_form = new Give_Donate_Form( $form_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 | |
@@ -23,14 +23,14 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | global $typenow; |
| 25 | 25 | |
| 26 | - if ( $typenow != 'give_forms' ) { |
|
| 26 | + if ($typenow != 'give_forms') { |
|
| 27 | 27 | return true; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | return false; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | -add_filter( 'give_shortcode_button_condition', 'give_shortcode_button_condition' ); |
|
| 33 | +add_filter('give_shortcode_button_condition', 'give_shortcode_button_condition'); |
|
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -40,11 +40,11 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @return int|false |
| 42 | 42 | */ |
| 43 | -function get_form_id_from_args( $args ) { |
|
| 43 | +function get_form_id_from_args($args) { |
|
| 44 | 44 | |
| 45 | - if ( isset( $args['form_id'] ) && $args['form_id'] != 0 ) { |
|
| 45 | + if (isset($args['form_id']) && $args['form_id'] != 0) { |
|
| 46 | 46 | |
| 47 | - return intval( $args['form_id'] ); |
|
| 47 | + return intval($args['form_id']); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | return false; |
@@ -59,23 +59,23 @@ discard block |
||
| 59 | 59 | * |
| 60 | 60 | * @return bool |
| 61 | 61 | */ |
| 62 | -function give_is_float_labels_enabled( $args ) { |
|
| 62 | +function give_is_float_labels_enabled($args) { |
|
| 63 | 63 | |
| 64 | 64 | $float_labels = ''; |
| 65 | 65 | |
| 66 | - if ( ! empty( $args['float_labels'] ) ) { |
|
| 66 | + if ( ! empty($args['float_labels'])) { |
|
| 67 | 67 | $float_labels = $args['float_labels']; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - if ( empty( $float_labels ) ) { |
|
| 71 | - $float_labels = get_post_meta( $args['form_id'], '_give_form_floating_labels', true ); |
|
| 70 | + if (empty($float_labels)) { |
|
| 71 | + $float_labels = get_post_meta($args['form_id'], '_give_form_floating_labels', true); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if ( empty( $float_labels ) || ( 'global' === $float_labels ) ) { |
|
| 75 | - $float_labels = give_get_option( 'floatlabels', 'disabled' ); |
|
| 74 | + if (empty($float_labels) || ('global' === $float_labels)) { |
|
| 75 | + $float_labels = give_get_option('floatlabels', 'disabled'); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - return give_is_setting_enabled( $float_labels ); |
|
| 78 | + return give_is_setting_enabled($float_labels); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | $can_checkout = true; |
| 93 | 93 | |
| 94 | - return (bool) apply_filters( 'give_can_checkout', $can_checkout ); |
|
| 94 | + return (bool) apply_filters('give_can_checkout', $can_checkout); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -105,9 +105,9 @@ discard block |
||
| 105 | 105 | function give_get_success_page_uri() { |
| 106 | 106 | $give_options = give_get_settings(); |
| 107 | 107 | |
| 108 | - $success_page = isset( $give_options['success_page'] ) ? get_permalink( absint( $give_options['success_page'] ) ) : get_bloginfo( 'url' ); |
|
| 108 | + $success_page = isset($give_options['success_page']) ? get_permalink(absint($give_options['success_page'])) : get_bloginfo('url'); |
|
| 109 | 109 | |
| 110 | - return apply_filters( 'give_get_success_page_uri', $success_page ); |
|
| 110 | + return apply_filters('give_get_success_page_uri', $success_page); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -119,9 +119,9 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | function give_is_success_page() { |
| 121 | 121 | $give_options = give_get_settings(); |
| 122 | - $is_success_page = isset( $give_options['success_page'] ) ? is_page( $give_options['success_page'] ) : false; |
|
| 122 | + $is_success_page = isset($give_options['success_page']) ? is_page($give_options['success_page']) : false; |
|
| 123 | 123 | |
| 124 | - return apply_filters( 'give_is_success_page', $is_success_page ); |
|
| 124 | + return apply_filters('give_is_success_page', $is_success_page); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -135,17 +135,17 @@ discard block |
||
| 135 | 135 | * @since 1.0 |
| 136 | 136 | * @return void |
| 137 | 137 | */ |
| 138 | -function give_send_to_success_page( $query_string = null ) { |
|
| 138 | +function give_send_to_success_page($query_string = null) { |
|
| 139 | 139 | |
| 140 | 140 | $redirect = give_get_success_page_uri(); |
| 141 | 141 | |
| 142 | - if ( $query_string ) { |
|
| 142 | + if ($query_string) { |
|
| 143 | 143 | $redirect .= $query_string; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - $gateway = isset( $_REQUEST['give-gateway'] ) ? $_REQUEST['give-gateway'] : ''; |
|
| 146 | + $gateway = isset($_REQUEST['give-gateway']) ? $_REQUEST['give-gateway'] : ''; |
|
| 147 | 147 | |
| 148 | - wp_redirect( apply_filters( 'give_success_page_redirect', $redirect, $gateway, $query_string ) ); |
|
| 148 | + wp_redirect(apply_filters('give_success_page_redirect', $redirect, $gateway, $query_string)); |
|
| 149 | 149 | give_die(); |
| 150 | 150 | } |
| 151 | 151 | |
@@ -161,20 +161,20 @@ discard block |
||
| 161 | 161 | * @since 1.0 |
| 162 | 162 | * @return Void |
| 163 | 163 | */ |
| 164 | -function give_send_back_to_checkout( $args = array() ) { |
|
| 164 | +function give_send_back_to_checkout($args = array()) { |
|
| 165 | 165 | |
| 166 | - $url = isset( $_POST['give-current-url'] ) ? sanitize_text_field( $_POST['give-current-url'] ) : ''; |
|
| 166 | + $url = isset($_POST['give-current-url']) ? sanitize_text_field($_POST['give-current-url']) : ''; |
|
| 167 | 167 | |
| 168 | 168 | //Set the form_id. |
| 169 | - if ( isset( $_POST['give-form-id'] ) ) { |
|
| 170 | - $form_id = sanitize_text_field( $_POST['give-form-id'] ); |
|
| 169 | + if (isset($_POST['give-form-id'])) { |
|
| 170 | + $form_id = sanitize_text_field($_POST['give-form-id']); |
|
| 171 | 171 | } else { |
| 172 | 172 | $form_id = 0; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | //Need a URL to continue. If none, redirect back to single form. |
| 176 | - if ( empty( $url ) ) { |
|
| 177 | - wp_safe_redirect( get_permalink( $form_id ) ); |
|
| 176 | + if (empty($url)) { |
|
| 177 | + wp_safe_redirect(get_permalink($form_id)); |
|
| 178 | 178 | give_die(); |
| 179 | 179 | } |
| 180 | 180 | |
@@ -183,36 +183,36 @@ discard block |
||
| 183 | 183 | ); |
| 184 | 184 | |
| 185 | 185 | // Check for backward compatibility. |
| 186 | - if ( is_string( $args ) ) { |
|
| 187 | - $args = str_replace( '?', '', $args ); |
|
| 186 | + if (is_string($args)) { |
|
| 187 | + $args = str_replace('?', '', $args); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - $args = wp_parse_args( $args, $defaults ); |
|
| 190 | + $args = wp_parse_args($args, $defaults); |
|
| 191 | 191 | |
| 192 | 192 | // Merge URL query with $args to maintain third-party URL parameters after redirect. |
| 193 | - $url_data = wp_parse_url( $url ); |
|
| 193 | + $url_data = wp_parse_url($url); |
|
| 194 | 194 | |
| 195 | 195 | //Check if an array to prevent notices before parsing. |
| 196 | - if ( isset( $url_data['query'] ) && ! empty( $url_data['query'] ) ) { |
|
| 197 | - parse_str( $url_data['query'], $query ); |
|
| 196 | + if (isset($url_data['query']) && ! empty($url_data['query'])) { |
|
| 197 | + parse_str($url_data['query'], $query); |
|
| 198 | 198 | |
| 199 | 199 | //Precaution: don't allow any CC info. |
| 200 | - unset( $query['card_number'] ); |
|
| 201 | - unset( $query['card_cvc'] ); |
|
| 200 | + unset($query['card_number']); |
|
| 201 | + unset($query['card_cvc']); |
|
| 202 | 202 | |
| 203 | 203 | } else { |
| 204 | 204 | //No $url_data so pass empty array. |
| 205 | 205 | $query = array(); |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - $new_query = array_merge( $args, $query ); |
|
| 209 | - $new_query_string = http_build_query( $new_query ); |
|
| 208 | + $new_query = array_merge($args, $query); |
|
| 209 | + $new_query_string = http_build_query($new_query); |
|
| 210 | 210 | |
| 211 | 211 | // Assemble URL parts. |
| 212 | - $redirect = home_url( '/' . $url_data['path'] . '?' . $new_query_string . '#give-form-' . $form_id . '-wrap' ); |
|
| 212 | + $redirect = home_url('/'.$url_data['path'].'?'.$new_query_string.'#give-form-'.$form_id.'-wrap'); |
|
| 213 | 213 | |
| 214 | 214 | //Redirect them. |
| 215 | - wp_safe_redirect( apply_filters( 'give_send_back_to_checkout', $redirect, $args ) ); |
|
| 215 | + wp_safe_redirect(apply_filters('give_send_back_to_checkout', $redirect, $args)); |
|
| 216 | 216 | give_die(); |
| 217 | 217 | |
| 218 | 218 | } |
@@ -228,16 +228,16 @@ discard block |
||
| 228 | 228 | * @since 1.0 |
| 229 | 229 | * @return string |
| 230 | 230 | */ |
| 231 | -function give_get_success_page_url( $query_string = null ) { |
|
| 231 | +function give_get_success_page_url($query_string = null) { |
|
| 232 | 232 | |
| 233 | - $success_page = give_get_option( 'success_page', 0 ); |
|
| 234 | - $success_page = get_permalink( $success_page ); |
|
| 233 | + $success_page = give_get_option('success_page', 0); |
|
| 234 | + $success_page = get_permalink($success_page); |
|
| 235 | 235 | |
| 236 | - if ( $query_string ) { |
|
| 236 | + if ($query_string) { |
|
| 237 | 237 | $success_page .= $query_string; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - return apply_filters( 'give_success_page_url', $success_page ); |
|
| 240 | + return apply_filters('give_success_page_url', $success_page); |
|
| 241 | 241 | |
| 242 | 242 | } |
| 243 | 243 | |
@@ -250,15 +250,15 @@ discard block |
||
| 250 | 250 | * |
| 251 | 251 | * @return mixed|void Full URL to the Failed Donation Page, if present, home page if it doesn't exist |
| 252 | 252 | */ |
| 253 | -function give_get_failed_transaction_uri( $extras = false ) { |
|
| 253 | +function give_get_failed_transaction_uri($extras = false) { |
|
| 254 | 254 | $give_options = give_get_settings(); |
| 255 | 255 | |
| 256 | - $uri = ! empty( $give_options['failure_page'] ) ? trailingslashit( get_permalink( $give_options['failure_page'] ) ) : home_url(); |
|
| 257 | - if ( $extras ) { |
|
| 256 | + $uri = ! empty($give_options['failure_page']) ? trailingslashit(get_permalink($give_options['failure_page'])) : home_url(); |
|
| 257 | + if ($extras) { |
|
| 258 | 258 | $uri .= $extras; |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - return apply_filters( 'give_get_failed_transaction_uri', $uri ); |
|
| 261 | + return apply_filters('give_get_failed_transaction_uri', $uri); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | /** |
@@ -269,9 +269,9 @@ discard block |
||
| 269 | 269 | */ |
| 270 | 270 | function give_is_failed_transaction_page() { |
| 271 | 271 | $give_options = give_get_settings(); |
| 272 | - $ret = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false; |
|
| 272 | + $ret = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false; |
|
| 273 | 273 | |
| 274 | - return apply_filters( 'give_is_failure_page', $ret ); |
|
| 274 | + return apply_filters('give_is_failure_page', $ret); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
@@ -283,18 +283,18 @@ discard block |
||
| 283 | 283 | */ |
| 284 | 284 | function give_listen_for_failed_payments() { |
| 285 | 285 | |
| 286 | - $failed_page = give_get_option( 'failure_page', 0 ); |
|
| 286 | + $failed_page = give_get_option('failure_page', 0); |
|
| 287 | 287 | |
| 288 | - if ( ! empty( $failed_page ) && is_page( $failed_page ) && ! empty( $_GET['payment-id'] ) ) { |
|
| 288 | + if ( ! empty($failed_page) && is_page($failed_page) && ! empty($_GET['payment-id'])) { |
|
| 289 | 289 | |
| 290 | - $payment_id = absint( $_GET['payment-id'] ); |
|
| 291 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 290 | + $payment_id = absint($_GET['payment-id']); |
|
| 291 | + give_update_payment_status($payment_id, 'failed'); |
|
| 292 | 292 | |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | -add_action( 'template_redirect', 'give_listen_for_failed_payments' ); |
|
| 297 | +add_action('template_redirect', 'give_listen_for_failed_payments'); |
|
| 298 | 298 | |
| 299 | 299 | /** |
| 300 | 300 | * Retrieve the Donation History page URI |
@@ -307,9 +307,9 @@ discard block |
||
| 307 | 307 | function give_get_history_page_uri() { |
| 308 | 308 | $give_options = give_get_settings(); |
| 309 | 309 | |
| 310 | - $history_page = isset( $give_options['history_page'] ) ? get_permalink( absint( $give_options['history_page'] ) ) : get_bloginfo( 'url' ); |
|
| 310 | + $history_page = isset($give_options['history_page']) ? get_permalink(absint($give_options['history_page'])) : get_bloginfo('url'); |
|
| 311 | 311 | |
| 312 | - return apply_filters( 'give_get_history_page_uri', $history_page ); |
|
| 312 | + return apply_filters('give_get_history_page_uri', $history_page); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | /** |
@@ -322,11 +322,11 @@ discard block |
||
| 322 | 322 | * @since 1.0 |
| 323 | 323 | * @return bool |
| 324 | 324 | */ |
| 325 | -function give_field_is_required( $field = '', $form_id ) { |
|
| 325 | +function give_field_is_required($field = '', $form_id) { |
|
| 326 | 326 | |
| 327 | - $required_fields = give_get_required_fields( $form_id ); |
|
| 327 | + $required_fields = give_get_required_fields($form_id); |
|
| 328 | 328 | |
| 329 | - return array_key_exists( $field, $required_fields ); |
|
| 329 | + return array_key_exists($field, $required_fields); |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | /** |
@@ -344,14 +344,14 @@ discard block |
||
| 344 | 344 | * |
| 345 | 345 | * @return void |
| 346 | 346 | */ |
| 347 | -function give_record_sale_in_log( $give_form_id = 0, $payment_id, $price_id = false, $sale_date = null ) { |
|
| 347 | +function give_record_sale_in_log($give_form_id = 0, $payment_id, $price_id = false, $sale_date = null) { |
|
| 348 | 348 | global $give_logs; |
| 349 | 349 | |
| 350 | 350 | $log_data = array( |
| 351 | 351 | 'post_parent' => $give_form_id, |
| 352 | 352 | 'log_type' => 'sale', |
| 353 | - 'post_date' => isset( $sale_date ) ? $sale_date : null, |
|
| 354 | - 'post_date_gmt' => isset( $sale_date ) ? $sale_date : null |
|
| 353 | + 'post_date' => isset($sale_date) ? $sale_date : null, |
|
| 354 | + 'post_date_gmt' => isset($sale_date) ? $sale_date : null |
|
| 355 | 355 | ); |
| 356 | 356 | |
| 357 | 357 | $log_meta = array( |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | 'price_id' => (int) $price_id |
| 360 | 360 | ); |
| 361 | 361 | |
| 362 | - $give_logs->insert_log( $log_data, $log_meta ); |
|
| 362 | + $give_logs->insert_log($log_data, $log_meta); |
|
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | |
@@ -373,11 +373,11 @@ discard block |
||
| 373 | 373 | * |
| 374 | 374 | * @return bool|int |
| 375 | 375 | */ |
| 376 | -function give_increase_purchase_count( $form_id = 0, $quantity = 1 ) { |
|
| 376 | +function give_increase_purchase_count($form_id = 0, $quantity = 1) { |
|
| 377 | 377 | $quantity = (int) $quantity; |
| 378 | - $form = new Give_Donate_Form( $form_id ); |
|
| 378 | + $form = new Give_Donate_Form($form_id); |
|
| 379 | 379 | |
| 380 | - return $form->increase_sales( $quantity ); |
|
| 380 | + return $form->increase_sales($quantity); |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | /** |
@@ -390,11 +390,11 @@ discard block |
||
| 390 | 390 | * |
| 391 | 391 | * @return bool|int |
| 392 | 392 | */ |
| 393 | -function give_decrease_purchase_count( $form_id = 0, $quantity = 1 ) { |
|
| 393 | +function give_decrease_purchase_count($form_id = 0, $quantity = 1) { |
|
| 394 | 394 | $quantity = (int) $quantity; |
| 395 | - $form = new Give_Donate_Form( $form_id ); |
|
| 395 | + $form = new Give_Donate_Form($form_id); |
|
| 396 | 396 | |
| 397 | - return $form->decrease_sales( $quantity ); |
|
| 397 | + return $form->decrease_sales($quantity); |
|
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | /** |
@@ -407,10 +407,10 @@ discard block |
||
| 407 | 407 | * |
| 408 | 408 | * @return bool|int |
| 409 | 409 | */ |
| 410 | -function give_increase_earnings( $give_form_id = 0, $amount ) { |
|
| 411 | - $form = new Give_Donate_Form( $give_form_id ); |
|
| 410 | +function give_increase_earnings($give_form_id = 0, $amount) { |
|
| 411 | + $form = new Give_Donate_Form($give_form_id); |
|
| 412 | 412 | |
| 413 | - return $form->increase_earnings( $amount ); |
|
| 413 | + return $form->increase_earnings($amount); |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | /** |
@@ -423,10 +423,10 @@ discard block |
||
| 423 | 423 | * |
| 424 | 424 | * @return bool|int |
| 425 | 425 | */ |
| 426 | -function give_decrease_earnings( $form_id = 0, $amount ) { |
|
| 427 | - $form = new Give_Donate_Form( $form_id ); |
|
| 426 | +function give_decrease_earnings($form_id = 0, $amount) { |
|
| 427 | + $form = new Give_Donate_Form($form_id); |
|
| 428 | 428 | |
| 429 | - return $form->decrease_earnings( $amount ); |
|
| 429 | + return $form->decrease_earnings($amount); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | |
@@ -439,8 +439,8 @@ discard block |
||
| 439 | 439 | * |
| 440 | 440 | * @return int $earnings Earnings for a certain form |
| 441 | 441 | */ |
| 442 | -function give_get_form_earnings_stats( $form_id = 0 ) { |
|
| 443 | - $give_form = new Give_Donate_Form( $form_id ); |
|
| 442 | +function give_get_form_earnings_stats($form_id = 0) { |
|
| 443 | + $give_form = new Give_Donate_Form($form_id); |
|
| 444 | 444 | |
| 445 | 445 | return $give_form->earnings; |
| 446 | 446 | } |
@@ -455,8 +455,8 @@ discard block |
||
| 455 | 455 | * |
| 456 | 456 | * @return int $sales Amount of sales for a certain form |
| 457 | 457 | */ |
| 458 | -function give_get_form_sales_stats( $give_form_id = 0 ) { |
|
| 459 | - $give_form = new Give_Donate_Form( $give_form_id ); |
|
| 458 | +function give_get_form_sales_stats($give_form_id = 0) { |
|
| 459 | + $give_form = new Give_Donate_Form($give_form_id); |
|
| 460 | 460 | |
| 461 | 461 | return $give_form->sales; |
| 462 | 462 | } |
@@ -471,16 +471,16 @@ discard block |
||
| 471 | 471 | * |
| 472 | 472 | * @return float $sales Average monthly sales |
| 473 | 473 | */ |
| 474 | -function give_get_average_monthly_form_sales( $form_id = 0 ) { |
|
| 475 | - $sales = give_get_form_sales_stats( $form_id ); |
|
| 476 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
| 474 | +function give_get_average_monthly_form_sales($form_id = 0) { |
|
| 475 | + $sales = give_get_form_sales_stats($form_id); |
|
| 476 | + $release_date = get_post_field('post_date', $form_id); |
|
| 477 | 477 | |
| 478 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
| 478 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
| 479 | 479 | |
| 480 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
| 480 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
| 481 | 481 | |
| 482 | - if ( $months > 0 ) { |
|
| 483 | - $sales = ( $sales / $months ); |
|
| 482 | + if ($months > 0) { |
|
| 483 | + $sales = ($sales / $months); |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | return $sales; |
@@ -496,16 +496,16 @@ discard block |
||
| 496 | 496 | * |
| 497 | 497 | * @return float $earnings Average monthly earnings |
| 498 | 498 | */ |
| 499 | -function give_get_average_monthly_form_earnings( $form_id = 0 ) { |
|
| 500 | - $earnings = give_get_form_earnings_stats( $form_id ); |
|
| 501 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
| 499 | +function give_get_average_monthly_form_earnings($form_id = 0) { |
|
| 500 | + $earnings = give_get_form_earnings_stats($form_id); |
|
| 501 | + $release_date = get_post_field('post_date', $form_id); |
|
| 502 | 502 | |
| 503 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
| 503 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
| 504 | 504 | |
| 505 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
| 505 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
| 506 | 506 | |
| 507 | - if ( $months > 0 ) { |
|
| 508 | - $earnings = ( $earnings / $months ); |
|
| 507 | + if ($months > 0) { |
|
| 508 | + $earnings = ($earnings / $months); |
|
| 509 | 509 | } |
| 510 | 510 | |
| 511 | 511 | return $earnings < 0 ? 0 : $earnings; |
@@ -525,25 +525,25 @@ discard block |
||
| 525 | 525 | * |
| 526 | 526 | * @return string $price_name Name of the price option |
| 527 | 527 | */ |
| 528 | -function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0 ) { |
|
| 528 | +function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0) { |
|
| 529 | 529 | |
| 530 | - $prices = give_get_variable_prices( $form_id ); |
|
| 530 | + $prices = give_get_variable_prices($form_id); |
|
| 531 | 531 | $price_name = ''; |
| 532 | 532 | |
| 533 | - foreach ( $prices as $price ) { |
|
| 533 | + foreach ($prices as $price) { |
|
| 534 | 534 | |
| 535 | - if ( intval( $price['_give_id']['level_id'] ) == intval( $price_id ) ) { |
|
| 535 | + if (intval($price['_give_id']['level_id']) == intval($price_id)) { |
|
| 536 | 536 | |
| 537 | - $price_text = isset( $price['_give_text'] ) ? $price['_give_text'] : ''; |
|
| 538 | - $price_fallback = give_currency_filter( give_format_amount( $price['_give_amount'] ) ); |
|
| 539 | - $price_name = ! empty( $price_text ) ? $price_text : $price_fallback; |
|
| 537 | + $price_text = isset($price['_give_text']) ? $price['_give_text'] : ''; |
|
| 538 | + $price_fallback = give_currency_filter(give_format_amount($price['_give_amount'])); |
|
| 539 | + $price_name = ! empty($price_text) ? $price_text : $price_fallback; |
|
| 540 | 540 | |
| 541 | 541 | } |
| 542 | 542 | |
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | |
| 546 | - return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id ); |
|
| 546 | + return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id); |
|
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | |
@@ -556,14 +556,14 @@ discard block |
||
| 556 | 556 | * |
| 557 | 557 | * @return string $range A fully formatted price range |
| 558 | 558 | */ |
| 559 | -function give_price_range( $form_id = 0 ) { |
|
| 560 | - $low = give_get_lowest_price_option( $form_id ); |
|
| 561 | - $high = give_get_highest_price_option( $form_id ); |
|
| 562 | - $range = '<span class="give_price_range_low">' . give_currency_filter( give_format_amount( $low ) ) . '</span>'; |
|
| 559 | +function give_price_range($form_id = 0) { |
|
| 560 | + $low = give_get_lowest_price_option($form_id); |
|
| 561 | + $high = give_get_highest_price_option($form_id); |
|
| 562 | + $range = '<span class="give_price_range_low">'.give_currency_filter(give_format_amount($low)).'</span>'; |
|
| 563 | 563 | $range .= '<span class="give_price_range_sep"> – </span>'; |
| 564 | - $range .= '<span class="give_price_range_high">' . give_currency_filter( give_format_amount( $high ) ) . '</span>'; |
|
| 564 | + $range .= '<span class="give_price_range_high">'.give_currency_filter(give_format_amount($high)).'</span>'; |
|
| 565 | 565 | |
| 566 | - return apply_filters( 'give_price_range', $range, $form_id, $low, $high ); |
|
| 566 | + return apply_filters('give_price_range', $range, $form_id, $low, $high); |
|
| 567 | 567 | } |
| 568 | 568 | |
| 569 | 569 | |
@@ -578,36 +578,36 @@ discard block |
||
| 578 | 578 | * |
| 579 | 579 | * @return int ID of the lowest price |
| 580 | 580 | */ |
| 581 | -function give_get_lowest_price_id( $form_id = 0 ) { |
|
| 581 | +function give_get_lowest_price_id($form_id = 0) { |
|
| 582 | 582 | |
| 583 | - if ( empty( $form_id ) ) { |
|
| 583 | + if (empty($form_id)) { |
|
| 584 | 584 | $form_id = get_the_ID(); |
| 585 | 585 | } |
| 586 | 586 | |
| 587 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
| 588 | - return give_get_form_price( $form_id ); |
|
| 587 | + if ( ! give_has_variable_prices($form_id)) { |
|
| 588 | + return give_get_form_price($form_id); |
|
| 589 | 589 | } |
| 590 | 590 | |
| 591 | - $prices = give_get_variable_prices( $form_id ); |
|
| 591 | + $prices = give_get_variable_prices($form_id); |
|
| 592 | 592 | |
| 593 | 593 | $low = 0.00; |
| 594 | 594 | $min_id = 1; |
| 595 | 595 | |
| 596 | - if ( ! empty( $prices ) ) { |
|
| 596 | + if ( ! empty($prices)) { |
|
| 597 | 597 | |
| 598 | - foreach ( $prices as $key => $price ) { |
|
| 598 | + foreach ($prices as $key => $price) { |
|
| 599 | 599 | |
| 600 | - if ( empty( $price['_give_amount'] ) ) { |
|
| 600 | + if (empty($price['_give_amount'])) { |
|
| 601 | 601 | continue; |
| 602 | 602 | } |
| 603 | 603 | |
| 604 | - if ( ! isset( $min ) ) { |
|
| 604 | + if ( ! isset($min)) { |
|
| 605 | 605 | $min = $price['_give_amount']; |
| 606 | 606 | } else { |
| 607 | - $min = min( $min, $price['_give_amount'] ); |
|
| 607 | + $min = min($min, $price['_give_amount']); |
|
| 608 | 608 | } |
| 609 | 609 | |
| 610 | - if ( $price['_give_amount'] == $min ) { |
|
| 610 | + if ($price['_give_amount'] == $min) { |
|
| 611 | 611 | $min_id = $price['_give_id']['level_id']; |
| 612 | 612 | } |
| 613 | 613 | } |
@@ -625,43 +625,43 @@ discard block |
||
| 625 | 625 | * |
| 626 | 626 | * @return float Amount of the lowest price |
| 627 | 627 | */ |
| 628 | -function give_get_lowest_price_option( $form_id = 0 ) { |
|
| 629 | - if ( empty( $form_id ) ) { |
|
| 628 | +function give_get_lowest_price_option($form_id = 0) { |
|
| 629 | + if (empty($form_id)) { |
|
| 630 | 630 | $form_id = get_the_ID(); |
| 631 | 631 | } |
| 632 | 632 | |
| 633 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
| 634 | - return give_get_form_price( $form_id ); |
|
| 633 | + if ( ! give_has_variable_prices($form_id)) { |
|
| 634 | + return give_get_form_price($form_id); |
|
| 635 | 635 | } |
| 636 | 636 | |
| 637 | - $prices = give_get_variable_prices( $form_id ); |
|
| 637 | + $prices = give_get_variable_prices($form_id); |
|
| 638 | 638 | |
| 639 | 639 | $low = 0.00; |
| 640 | 640 | |
| 641 | - if ( ! empty( $prices ) ) { |
|
| 641 | + if ( ! empty($prices)) { |
|
| 642 | 642 | |
| 643 | - foreach ( $prices as $key => $price ) { |
|
| 643 | + foreach ($prices as $key => $price) { |
|
| 644 | 644 | |
| 645 | - if ( empty( $price['_give_amount'] ) ) { |
|
| 645 | + if (empty($price['_give_amount'])) { |
|
| 646 | 646 | continue; |
| 647 | 647 | } |
| 648 | 648 | |
| 649 | - if ( ! isset( $min ) ) { |
|
| 649 | + if ( ! isset($min)) { |
|
| 650 | 650 | $min = $price['_give_amount']; |
| 651 | 651 | } else { |
| 652 | - $min = min( $min, give_sanitize_amount( $price['_give_amount'] ) ); |
|
| 652 | + $min = min($min, give_sanitize_amount($price['_give_amount'])); |
|
| 653 | 653 | } |
| 654 | 654 | |
| 655 | - if ( $price['_give_amount'] == $min ) { |
|
| 655 | + if ($price['_give_amount'] == $min) { |
|
| 656 | 656 | $min_id = $key; |
| 657 | 657 | } |
| 658 | 658 | } |
| 659 | 659 | |
| 660 | - $low = $prices[ $min_id ]['_give_amount']; |
|
| 660 | + $low = $prices[$min_id]['_give_amount']; |
|
| 661 | 661 | |
| 662 | 662 | } |
| 663 | 663 | |
| 664 | - return give_sanitize_amount( $low ); |
|
| 664 | + return give_sanitize_amount($low); |
|
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | /** |
@@ -673,41 +673,41 @@ discard block |
||
| 673 | 673 | * |
| 674 | 674 | * @return float Amount of the highest price |
| 675 | 675 | */ |
| 676 | -function give_get_highest_price_option( $form_id = 0 ) { |
|
| 676 | +function give_get_highest_price_option($form_id = 0) { |
|
| 677 | 677 | |
| 678 | - if ( empty( $form_id ) ) { |
|
| 678 | + if (empty($form_id)) { |
|
| 679 | 679 | $form_id = get_the_ID(); |
| 680 | 680 | } |
| 681 | 681 | |
| 682 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
| 683 | - return give_get_form_price( $form_id ); |
|
| 682 | + if ( ! give_has_variable_prices($form_id)) { |
|
| 683 | + return give_get_form_price($form_id); |
|
| 684 | 684 | } |
| 685 | 685 | |
| 686 | - $prices = give_get_variable_prices( $form_id ); |
|
| 686 | + $prices = give_get_variable_prices($form_id); |
|
| 687 | 687 | |
| 688 | 688 | $high = 0.00; |
| 689 | 689 | |
| 690 | - if ( ! empty( $prices ) ) { |
|
| 690 | + if ( ! empty($prices)) { |
|
| 691 | 691 | |
| 692 | 692 | $max = 0; |
| 693 | 693 | |
| 694 | - foreach ( $prices as $key => $price ) { |
|
| 695 | - if ( empty( $price['_give_amount'] ) ) { |
|
| 694 | + foreach ($prices as $key => $price) { |
|
| 695 | + if (empty($price['_give_amount'])) { |
|
| 696 | 696 | continue; |
| 697 | 697 | } |
| 698 | - $give_amount = give_sanitize_amount( $price['_give_amount'] ); |
|
| 698 | + $give_amount = give_sanitize_amount($price['_give_amount']); |
|
| 699 | 699 | |
| 700 | - $max = max( $max, $give_amount ); |
|
| 700 | + $max = max($max, $give_amount); |
|
| 701 | 701 | |
| 702 | - if ( $give_amount == $max ) { |
|
| 702 | + if ($give_amount == $max) { |
|
| 703 | 703 | $max_id = $key; |
| 704 | 704 | } |
| 705 | 705 | } |
| 706 | 706 | |
| 707 | - $high = $prices[ $max_id ]['_give_amount']; |
|
| 707 | + $high = $prices[$max_id]['_give_amount']; |
|
| 708 | 708 | } |
| 709 | 709 | |
| 710 | - return give_sanitize_amount( $high ); |
|
| 710 | + return give_sanitize_amount($high); |
|
| 711 | 711 | } |
| 712 | 712 | |
| 713 | 713 | /** |
@@ -719,15 +719,15 @@ discard block |
||
| 719 | 719 | * |
| 720 | 720 | * @return mixed string|int Price of the form |
| 721 | 721 | */ |
| 722 | -function give_get_form_price( $form_id = 0 ) { |
|
| 722 | +function give_get_form_price($form_id = 0) { |
|
| 723 | 723 | |
| 724 | - if ( empty( $form_id ) ) { |
|
| 724 | + if (empty($form_id)) { |
|
| 725 | 725 | return false; |
| 726 | 726 | } |
| 727 | 727 | |
| 728 | - $form = new Give_Donate_Form( $form_id ); |
|
| 728 | + $form = new Give_Donate_Form($form_id); |
|
| 729 | 729 | |
| 730 | - return $form->__get( 'price' ); |
|
| 730 | + return $form->__get('price'); |
|
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | /** |
@@ -739,15 +739,15 @@ discard block |
||
| 739 | 739 | * |
| 740 | 740 | * @return mixed string|int Minimum price of the form |
| 741 | 741 | */ |
| 742 | -function give_get_form_minimum_price( $form_id = 0 ) { |
|
| 742 | +function give_get_form_minimum_price($form_id = 0) { |
|
| 743 | 743 | |
| 744 | - if ( empty( $form_id ) ) { |
|
| 744 | + if (empty($form_id)) { |
|
| 745 | 745 | return false; |
| 746 | 746 | } |
| 747 | 747 | |
| 748 | - $form = new Give_Donate_Form( $form_id ); |
|
| 748 | + $form = new Give_Donate_Form($form_id); |
|
| 749 | 749 | |
| 750 | - return $form->__get( 'minimum_price' ); |
|
| 750 | + return $form->__get('minimum_price'); |
|
| 751 | 751 | |
| 752 | 752 | } |
| 753 | 753 | |
@@ -762,52 +762,52 @@ discard block |
||
| 762 | 762 | * |
| 763 | 763 | * @return int $formatted_price |
| 764 | 764 | */ |
| 765 | -function give_price( $form_id = 0, $echo = true, $price_id = false ) { |
|
| 765 | +function give_price($form_id = 0, $echo = true, $price_id = false) { |
|
| 766 | 766 | |
| 767 | - if ( empty( $form_id ) ) { |
|
| 767 | + if (empty($form_id)) { |
|
| 768 | 768 | $form_id = get_the_ID(); |
| 769 | 769 | } |
| 770 | 770 | |
| 771 | - if ( give_has_variable_prices( $form_id ) ) { |
|
| 771 | + if (give_has_variable_prices($form_id)) { |
|
| 772 | 772 | |
| 773 | - $prices = give_get_variable_prices( $form_id ); |
|
| 773 | + $prices = give_get_variable_prices($form_id); |
|
| 774 | 774 | |
| 775 | - if ( false !== $price_id ) { |
|
| 775 | + if (false !== $price_id) { |
|
| 776 | 776 | |
| 777 | 777 | //loop through multi-prices to see which is default |
| 778 | - foreach ( $prices as $price ) { |
|
| 778 | + foreach ($prices as $price) { |
|
| 779 | 779 | //this is the default price |
| 780 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
| 780 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
| 781 | 781 | $price = (float) $price['_give_amount']; |
| 782 | 782 | }; |
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | } else { |
| 786 | 786 | |
| 787 | - $price = give_get_lowest_price_option( $form_id ); |
|
| 787 | + $price = give_get_lowest_price_option($form_id); |
|
| 788 | 788 | } |
| 789 | 789 | |
| 790 | - $price = give_sanitize_amount( $price ); |
|
| 790 | + $price = give_sanitize_amount($price); |
|
| 791 | 791 | |
| 792 | 792 | } else { |
| 793 | 793 | |
| 794 | - $price = give_get_form_price( $form_id ); |
|
| 794 | + $price = give_get_form_price($form_id); |
|
| 795 | 795 | |
| 796 | 796 | } |
| 797 | 797 | |
| 798 | - $price = apply_filters( 'give_form_price', give_sanitize_amount( $price ), $form_id ); |
|
| 799 | - $formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>'; |
|
| 800 | - $formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price ); |
|
| 798 | + $price = apply_filters('give_form_price', give_sanitize_amount($price), $form_id); |
|
| 799 | + $formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>'; |
|
| 800 | + $formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price); |
|
| 801 | 801 | |
| 802 | - if ( $echo ) { |
|
| 802 | + if ($echo) { |
|
| 803 | 803 | echo $formatted_price; |
| 804 | 804 | } else { |
| 805 | 805 | return $formatted_price; |
| 806 | 806 | } |
| 807 | 807 | } |
| 808 | 808 | |
| 809 | -add_filter( 'give_form_price', 'give_format_amount', 10 ); |
|
| 810 | -add_filter( 'give_form_price', 'give_currency_filter', 20 ); |
|
| 809 | +add_filter('give_form_price', 'give_format_amount', 10); |
|
| 810 | +add_filter('give_form_price', 'give_currency_filter', 20); |
|
| 811 | 811 | |
| 812 | 812 | |
| 813 | 813 | /** |
@@ -820,19 +820,19 @@ discard block |
||
| 820 | 820 | * |
| 821 | 821 | * @return float $amount Amount of the price option |
| 822 | 822 | */ |
| 823 | -function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) { |
|
| 824 | - $prices = give_get_variable_prices( $form_id ); |
|
| 823 | +function give_get_price_option_amount($form_id = 0, $price_id = 0) { |
|
| 824 | + $prices = give_get_variable_prices($form_id); |
|
| 825 | 825 | |
| 826 | 826 | $amount = 0.00; |
| 827 | 827 | |
| 828 | - foreach ( $prices as $price ) { |
|
| 829 | - if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) { |
|
| 830 | - $amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00; |
|
| 828 | + foreach ($prices as $price) { |
|
| 829 | + if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] == $price_id) { |
|
| 830 | + $amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00; |
|
| 831 | 831 | break; |
| 832 | 832 | }; |
| 833 | 833 | } |
| 834 | 834 | |
| 835 | - return apply_filters( 'give_get_price_option_amount', give_sanitize_amount( $amount ), $form_id, $price_id ); |
|
| 835 | + return apply_filters('give_get_price_option_amount', give_sanitize_amount($amount), $form_id, $price_id); |
|
| 836 | 836 | } |
| 837 | 837 | |
| 838 | 838 | /** |
@@ -844,13 +844,13 @@ discard block |
||
| 844 | 844 | * |
| 845 | 845 | * @return mixed string|int Goal of the form |
| 846 | 846 | */ |
| 847 | -function give_get_form_goal( $form_id = 0 ) { |
|
| 847 | +function give_get_form_goal($form_id = 0) { |
|
| 848 | 848 | |
| 849 | - if ( empty( $form_id ) ) { |
|
| 849 | + if (empty($form_id)) { |
|
| 850 | 850 | return false; |
| 851 | 851 | } |
| 852 | 852 | |
| 853 | - $form = new Give_Donate_Form( $form_id ); |
|
| 853 | + $form = new Give_Donate_Form($form_id); |
|
| 854 | 854 | |
| 855 | 855 | return $form->goal; |
| 856 | 856 | |
@@ -866,27 +866,27 @@ discard block |
||
| 866 | 866 | * |
| 867 | 867 | * @return string $formatted_goal |
| 868 | 868 | */ |
| 869 | -function give_goal( $form_id = 0, $echo = true ) { |
|
| 869 | +function give_goal($form_id = 0, $echo = true) { |
|
| 870 | 870 | |
| 871 | - if ( empty( $form_id ) ) { |
|
| 871 | + if (empty($form_id)) { |
|
| 872 | 872 | $form_id = get_the_ID(); |
| 873 | 873 | } |
| 874 | 874 | |
| 875 | - $goal = give_get_form_goal( $form_id ); |
|
| 875 | + $goal = give_get_form_goal($form_id); |
|
| 876 | 876 | |
| 877 | - $goal = apply_filters( 'give_form_goal', give_sanitize_amount( $goal ), $form_id ); |
|
| 878 | - $formatted_goal = '<span class="give_price" id="give_price_' . $form_id . '">' . $goal . '</span>'; |
|
| 879 | - $formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal ); |
|
| 877 | + $goal = apply_filters('give_form_goal', give_sanitize_amount($goal), $form_id); |
|
| 878 | + $formatted_goal = '<span class="give_price" id="give_price_'.$form_id.'">'.$goal.'</span>'; |
|
| 879 | + $formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal); |
|
| 880 | 880 | |
| 881 | - if ( $echo ) { |
|
| 881 | + if ($echo) { |
|
| 882 | 882 | echo $formatted_goal; |
| 883 | 883 | } else { |
| 884 | 884 | return $formatted_goal; |
| 885 | 885 | } |
| 886 | 886 | } |
| 887 | 887 | |
| 888 | -add_filter( 'give_form_goal', 'give_format_amount', 10 ); |
|
| 889 | -add_filter( 'give_form_goal', 'give_currency_filter', 20 ); |
|
| 888 | +add_filter('give_form_goal', 'give_format_amount', 10); |
|
| 889 | +add_filter('give_form_goal', 'give_currency_filter', 20); |
|
| 890 | 890 | |
| 891 | 891 | |
| 892 | 892 | /** |
@@ -898,10 +898,10 @@ discard block |
||
| 898 | 898 | * |
| 899 | 899 | * @return bool $ret Whether or not the logged_in_only setting is set |
| 900 | 900 | */ |
| 901 | -function give_logged_in_only( $form_id ) { |
|
| 902 | - $ret = give_is_setting_enabled( get_post_meta( $form_id, '_give_logged_in_only', true ) ); |
|
| 901 | +function give_logged_in_only($form_id) { |
|
| 902 | + $ret = give_is_setting_enabled(get_post_meta($form_id, '_give_logged_in_only', true)); |
|
| 903 | 903 | |
| 904 | - return (bool) apply_filters( 'give_logged_in_only', $ret, $form_id ); |
|
| 904 | + return (bool) apply_filters('give_logged_in_only', $ret, $form_id); |
|
| 905 | 905 | |
| 906 | 906 | } |
| 907 | 907 | |
@@ -915,11 +915,11 @@ discard block |
||
| 915 | 915 | * |
| 916 | 916 | * @return string |
| 917 | 917 | */ |
| 918 | -function give_show_login_register_option( $form_id ) { |
|
| 918 | +function give_show_login_register_option($form_id) { |
|
| 919 | 919 | |
| 920 | - $show_register_form = get_post_meta( $form_id, '_give_show_register_form', true ); |
|
| 920 | + $show_register_form = get_post_meta($form_id, '_give_show_register_form', true); |
|
| 921 | 921 | |
| 922 | - return apply_filters( 'give_show_register_form', $show_register_form, $form_id ); |
|
| 922 | + return apply_filters('give_show_register_form', $show_register_form, $form_id); |
|
| 923 | 923 | |
| 924 | 924 | } |
| 925 | 925 | |
@@ -933,12 +933,12 @@ discard block |
||
| 933 | 933 | * @param int $form_id Form ID. |
| 934 | 934 | * @return array |
| 935 | 935 | */ |
| 936 | -function _give_get_prefill_form_field_values( $form_id ) { |
|
| 936 | +function _give_get_prefill_form_field_values($form_id) { |
|
| 937 | 937 | $logged_in_donor_info = array(); |
| 938 | 938 | |
| 939 | - if ( is_user_logged_in() ) : |
|
| 940 | - $donor_data = get_userdata( get_current_user_id() ); |
|
| 941 | - $donor_address = get_user_meta( get_current_user_id(), '_give_user_address', true ); |
|
| 939 | + if (is_user_logged_in()) : |
|
| 940 | + $donor_data = get_userdata(get_current_user_id()); |
|
| 941 | + $donor_address = get_user_meta(get_current_user_id(), '_give_user_address', true); |
|
| 942 | 942 | |
| 943 | 943 | $logged_in_donor_info = array( |
| 944 | 944 | // First name. |
@@ -951,42 +951,42 @@ discard block |
||
| 951 | 951 | 'give_email' => $donor_data->user_email, |
| 952 | 952 | |
| 953 | 953 | // Street address 1. |
| 954 | - 'card_address' => ( ! empty( $donor_address['line1'] ) ? $donor_address['line1'] : '' ), |
|
| 954 | + 'card_address' => ( ! empty($donor_address['line1']) ? $donor_address['line1'] : ''), |
|
| 955 | 955 | |
| 956 | 956 | // Street address 2. |
| 957 | - 'card_address_2' => ( ! empty( $donor_address['line2'] ) ? $donor_address['line2'] : '' ), |
|
| 957 | + 'card_address_2' => ( ! empty($donor_address['line2']) ? $donor_address['line2'] : ''), |
|
| 958 | 958 | |
| 959 | 959 | // Country. |
| 960 | - 'billing_country' => ( ! empty( $donor_address['country'] ) ? $donor_address['country'] : '' ), |
|
| 960 | + 'billing_country' => ( ! empty($donor_address['country']) ? $donor_address['country'] : ''), |
|
| 961 | 961 | |
| 962 | 962 | // State. |
| 963 | - 'card_state' => ( ! empty( $donor_address['state'] ) ? $donor_address['state'] : '' ), |
|
| 963 | + 'card_state' => ( ! empty($donor_address['state']) ? $donor_address['state'] : ''), |
|
| 964 | 964 | |
| 965 | 965 | // City. |
| 966 | - 'card_city' => ( ! empty( $donor_address['city'] ) ? $donor_address['city'] : '' ), |
|
| 966 | + 'card_city' => ( ! empty($donor_address['city']) ? $donor_address['city'] : ''), |
|
| 967 | 967 | |
| 968 | 968 | // Zipcode |
| 969 | - 'card_zip' => ( ! empty( $donor_address['zip'] ) ? $donor_address['zip'] : '' ) |
|
| 969 | + 'card_zip' => ( ! empty($donor_address['zip']) ? $donor_address['zip'] : '') |
|
| 970 | 970 | ); |
| 971 | 971 | endif; |
| 972 | 972 | |
| 973 | 973 | // Bailout: Auto fill form field values only form form which donor is donating. |
| 974 | - if( |
|
| 975 | - empty( $_GET['form-id'] ) |
|
| 974 | + if ( |
|
| 975 | + empty($_GET['form-id']) |
|
| 976 | 976 | || ! $form_id |
| 977 | - || ( $form_id !== absint( $_GET['form-id'] ) ) |
|
| 977 | + || ($form_id !== absint($_GET['form-id'])) |
|
| 978 | 978 | ) { |
| 979 | 979 | return $logged_in_donor_info; |
| 980 | 980 | } |
| 981 | 981 | |
| 982 | 982 | // Get purchase data. |
| 983 | - $give_purchase_data = Give()->session->get( 'give_purchase' ); |
|
| 983 | + $give_purchase_data = Give()->session->get('give_purchase'); |
|
| 984 | 984 | |
| 985 | 985 | // Get donor info from form data. |
| 986 | - $give_donor_info_in_session = empty( $give_purchase_data['post_data'] ) |
|
| 986 | + $give_donor_info_in_session = empty($give_purchase_data['post_data']) |
|
| 987 | 987 | ? array() |
| 988 | 988 | : $give_purchase_data['post_data']; |
| 989 | 989 | |
| 990 | 990 | // Output. |
| 991 | - return wp_parse_args( $give_donor_info_in_session, $logged_in_donor_info ); |
|
| 991 | + return wp_parse_args($give_donor_info_in_session, $logged_in_donor_info); |
|
| 992 | 992 | } |
| 993 | 993 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -85,19 +85,19 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public function get_predefined_dates() { |
| 87 | 87 | $predefined = array( |
| 88 | - 'today' => esc_html__( 'Today', 'give' ), |
|
| 89 | - 'yesterday' => esc_html__( 'Yesterday', 'give' ), |
|
| 90 | - 'this_week' => esc_html__( 'This Week', 'give' ), |
|
| 91 | - 'last_week' => esc_html__( 'Last Week', 'give' ), |
|
| 92 | - 'this_month' => esc_html__( 'This Month', 'give' ), |
|
| 93 | - 'last_month' => esc_html__( 'Last Month', 'give' ), |
|
| 94 | - 'this_quarter' => esc_html__( 'This Quarter', 'give' ), |
|
| 95 | - 'last_quarter' => esc_html__( 'Last Quarter', 'give' ), |
|
| 96 | - 'this_year' => esc_html__( 'This Year', 'give' ), |
|
| 97 | - 'last_year' => esc_html__( 'Last Year', 'give' ) |
|
| 88 | + 'today' => esc_html__('Today', 'give'), |
|
| 89 | + 'yesterday' => esc_html__('Yesterday', 'give'), |
|
| 90 | + 'this_week' => esc_html__('This Week', 'give'), |
|
| 91 | + 'last_week' => esc_html__('Last Week', 'give'), |
|
| 92 | + 'this_month' => esc_html__('This Month', 'give'), |
|
| 93 | + 'last_month' => esc_html__('Last Month', 'give'), |
|
| 94 | + 'this_quarter' => esc_html__('This Quarter', 'give'), |
|
| 95 | + 'last_quarter' => esc_html__('Last Quarter', 'give'), |
|
| 96 | + 'this_year' => esc_html__('This Year', 'give'), |
|
| 97 | + 'last_year' => esc_html__('Last Year', 'give') |
|
| 98 | 98 | ); |
| 99 | 99 | |
| 100 | - return apply_filters( 'give_stats_predefined_dates', $predefined ); |
|
| 100 | + return apply_filters('give_stats_predefined_dates', $predefined); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -113,18 +113,18 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @return void |
| 115 | 115 | */ |
| 116 | - public function setup_dates( $_start_date = 'this_month', $_end_date = false ) { |
|
| 116 | + public function setup_dates($_start_date = 'this_month', $_end_date = false) { |
|
| 117 | 117 | |
| 118 | - if ( empty( $_start_date ) ) { |
|
| 118 | + if (empty($_start_date)) { |
|
| 119 | 119 | $_start_date = 'this_month'; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - if ( empty( $_end_date ) ) { |
|
| 122 | + if (empty($_end_date)) { |
|
| 123 | 123 | $_end_date = $_start_date; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - $this->start_date = $this->convert_date( $_start_date ); |
|
| 127 | - $this->end_date = $this->convert_date( $_end_date, true ); |
|
| 126 | + $this->start_date = $this->convert_date($_start_date); |
|
| 127 | + $this->end_date = $this->convert_date($_end_date, true); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
@@ -140,26 +140,26 @@ discard block |
||
| 140 | 140 | * |
| 141 | 141 | * @return array|WP_Error If the date is invalid, a WP_Error object will be returned. |
| 142 | 142 | */ |
| 143 | - public function convert_date( $date, $end_date = false ) { |
|
| 143 | + public function convert_date($date, $end_date = false) { |
|
| 144 | 144 | |
| 145 | 145 | $this->timestamp = false; |
| 146 | 146 | $second = $end_date ? 59 : 0; |
| 147 | 147 | $minute = $end_date ? 59 : 0; |
| 148 | 148 | $hour = $end_date ? 23 : 0; |
| 149 | 149 | $day = 1; |
| 150 | - $month = date( 'n', current_time( 'timestamp' ) ); |
|
| 151 | - $year = date( 'Y', current_time( 'timestamp' ) ); |
|
| 150 | + $month = date('n', current_time('timestamp')); |
|
| 151 | + $year = date('Y', current_time('timestamp')); |
|
| 152 | 152 | |
| 153 | - if ( array_key_exists( $date, $this->get_predefined_dates() ) ) { |
|
| 153 | + if (array_key_exists($date, $this->get_predefined_dates())) { |
|
| 154 | 154 | |
| 155 | 155 | // This is a predefined date rate, such as last_week |
| 156 | - switch ( $date ) { |
|
| 156 | + switch ($date) { |
|
| 157 | 157 | |
| 158 | 158 | case 'this_month' : |
| 159 | 159 | |
| 160 | - if ( $end_date ) { |
|
| 160 | + if ($end_date) { |
|
| 161 | 161 | |
| 162 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 162 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 163 | 163 | $hour = 23; |
| 164 | 164 | $minute = 59; |
| 165 | 165 | $second = 59; |
@@ -169,28 +169,28 @@ discard block |
||
| 169 | 169 | |
| 170 | 170 | case 'last_month' : |
| 171 | 171 | |
| 172 | - if ( $month == 1 ) { |
|
| 172 | + if ($month == 1) { |
|
| 173 | 173 | |
| 174 | 174 | $month = 12; |
| 175 | - $year --; |
|
| 175 | + $year--; |
|
| 176 | 176 | |
| 177 | 177 | } else { |
| 178 | 178 | |
| 179 | - $month --; |
|
| 179 | + $month--; |
|
| 180 | 180 | |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - if ( $end_date ) { |
|
| 184 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 183 | + if ($end_date) { |
|
| 184 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | break; |
| 188 | 188 | |
| 189 | 189 | case 'today' : |
| 190 | 190 | |
| 191 | - $day = date( 'd', current_time( 'timestamp' ) ); |
|
| 191 | + $day = date('d', current_time('timestamp')); |
|
| 192 | 192 | |
| 193 | - if ( $end_date ) { |
|
| 193 | + if ($end_date) { |
|
| 194 | 194 | $hour = 23; |
| 195 | 195 | $minute = 59; |
| 196 | 196 | $second = 59; |
@@ -200,23 +200,23 @@ discard block |
||
| 200 | 200 | |
| 201 | 201 | case 'yesterday' : |
| 202 | 202 | |
| 203 | - $day = date( 'd', current_time( 'timestamp' ) ) - 1; |
|
| 203 | + $day = date('d', current_time('timestamp')) - 1; |
|
| 204 | 204 | |
| 205 | 205 | // Check if Today is the first day of the month (meaning subtracting one will get us 0) |
| 206 | - if ( $day < 1 ) { |
|
| 206 | + if ($day < 1) { |
|
| 207 | 207 | |
| 208 | 208 | // If current month is 1 |
| 209 | - if ( 1 == $month ) { |
|
| 209 | + if (1 == $month) { |
|
| 210 | 210 | |
| 211 | 211 | $year -= 1; // Today is January 1, so skip back to last day of December |
| 212 | 212 | $month = 12; |
| 213 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 213 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 214 | 214 | |
| 215 | 215 | } else { |
| 216 | 216 | |
| 217 | 217 | // Go back one month and get the last day of the month |
| 218 | 218 | $month -= 1; |
| 219 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 219 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 220 | 220 | |
| 221 | 221 | } |
| 222 | 222 | } |
@@ -225,12 +225,12 @@ discard block |
||
| 225 | 225 | |
| 226 | 226 | case 'this_week' : |
| 227 | 227 | |
| 228 | - $days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24; |
|
| 229 | - $today = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24; |
|
| 228 | + $days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24; |
|
| 229 | + $today = date('d', current_time('timestamp')) * 60 * 60 * 24; |
|
| 230 | 230 | |
| 231 | - if ( $today < $days_to_week_start ) { |
|
| 231 | + if ($today < $days_to_week_start) { |
|
| 232 | 232 | |
| 233 | - if ( $month > 1 ) { |
|
| 233 | + if ($month > 1) { |
|
| 234 | 234 | $month -= 1; |
| 235 | 235 | } else { |
| 236 | 236 | $month = 12; |
@@ -238,19 +238,19 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - if ( ! $end_date ) { |
|
| 241 | + if ( ! $end_date) { |
|
| 242 | 242 | |
| 243 | 243 | // Getting the start day |
| 244 | 244 | |
| 245 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1; |
|
| 246 | - $day += get_option( 'start_of_week' ); |
|
| 245 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 1; |
|
| 246 | + $day += get_option('start_of_week'); |
|
| 247 | 247 | |
| 248 | 248 | } else { |
| 249 | 249 | |
| 250 | 250 | // Getting the end day |
| 251 | 251 | |
| 252 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1; |
|
| 253 | - $day += get_option( 'start_of_week' ) + 6; |
|
| 252 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 1; |
|
| 253 | + $day += get_option('start_of_week') + 6; |
|
| 254 | 254 | |
| 255 | 255 | } |
| 256 | 256 | |
@@ -258,12 +258,12 @@ discard block |
||
| 258 | 258 | |
| 259 | 259 | case 'last_week' : |
| 260 | 260 | |
| 261 | - $days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24; |
|
| 262 | - $today = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24; |
|
| 261 | + $days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24; |
|
| 262 | + $today = date('d', current_time('timestamp')) * 60 * 60 * 24; |
|
| 263 | 263 | |
| 264 | - if ( $today < $days_to_week_start ) { |
|
| 264 | + if ($today < $days_to_week_start) { |
|
| 265 | 265 | |
| 266 | - if ( $month > 1 ) { |
|
| 266 | + if ($month > 1) { |
|
| 267 | 267 | $month -= 1; |
| 268 | 268 | } else { |
| 269 | 269 | $month = 12; |
@@ -271,19 +271,19 @@ discard block |
||
| 271 | 271 | |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - if ( ! $end_date ) { |
|
| 274 | + if ( ! $end_date) { |
|
| 275 | 275 | |
| 276 | 276 | // Getting the start day |
| 277 | 277 | |
| 278 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8; |
|
| 279 | - $day += get_option( 'start_of_week' ); |
|
| 278 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 8; |
|
| 279 | + $day += get_option('start_of_week'); |
|
| 280 | 280 | |
| 281 | 281 | } else { |
| 282 | 282 | |
| 283 | 283 | // Getting the end day |
| 284 | 284 | |
| 285 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8; |
|
| 286 | - $day += get_option( 'start_of_week' ) + 6; |
|
| 285 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 8; |
|
| 286 | + $day += get_option('start_of_week') + 6; |
|
| 287 | 287 | |
| 288 | 288 | } |
| 289 | 289 | |
@@ -291,39 +291,39 @@ discard block |
||
| 291 | 291 | |
| 292 | 292 | case 'this_quarter' : |
| 293 | 293 | |
| 294 | - $month_now = date( 'n', current_time( 'timestamp' ) ); |
|
| 294 | + $month_now = date('n', current_time('timestamp')); |
|
| 295 | 295 | |
| 296 | - if ( $month_now <= 3 ) { |
|
| 296 | + if ($month_now <= 3) { |
|
| 297 | 297 | |
| 298 | - if ( ! $end_date ) { |
|
| 298 | + if ( ! $end_date) { |
|
| 299 | 299 | $month = 1; |
| 300 | 300 | } else { |
| 301 | 301 | $month = 3; |
| 302 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 302 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 303 | 303 | $hour = 23; |
| 304 | 304 | $minute = 59; |
| 305 | 305 | $second = 59; |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - } else if ( $month_now <= 6 ) { |
|
| 308 | + } else if ($month_now <= 6) { |
|
| 309 | 309 | |
| 310 | - if ( ! $end_date ) { |
|
| 310 | + if ( ! $end_date) { |
|
| 311 | 311 | $month = 4; |
| 312 | 312 | } else { |
| 313 | 313 | $month = 6; |
| 314 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 314 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 315 | 315 | $hour = 23; |
| 316 | 316 | $minute = 59; |
| 317 | 317 | $second = 59; |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - } else if ( $month_now <= 9 ) { |
|
| 320 | + } else if ($month_now <= 9) { |
|
| 321 | 321 | |
| 322 | - if ( ! $end_date ) { |
|
| 322 | + if ( ! $end_date) { |
|
| 323 | 323 | $month = 7; |
| 324 | 324 | } else { |
| 325 | 325 | $month = 9; |
| 326 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 326 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 327 | 327 | $hour = 23; |
| 328 | 328 | $minute = 59; |
| 329 | 329 | $second = 59; |
@@ -331,11 +331,11 @@ discard block |
||
| 331 | 331 | |
| 332 | 332 | } else { |
| 333 | 333 | |
| 334 | - if ( ! $end_date ) { |
|
| 334 | + if ( ! $end_date) { |
|
| 335 | 335 | $month = 10; |
| 336 | 336 | } else { |
| 337 | 337 | $month = 12; |
| 338 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 338 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 339 | 339 | $hour = 23; |
| 340 | 340 | $minute = 59; |
| 341 | 341 | $second = 59; |
@@ -347,40 +347,40 @@ discard block |
||
| 347 | 347 | |
| 348 | 348 | case 'last_quarter' : |
| 349 | 349 | |
| 350 | - $month_now = date( 'n', current_time( 'timestamp' ) ); |
|
| 350 | + $month_now = date('n', current_time('timestamp')); |
|
| 351 | 351 | |
| 352 | - if ( $month_now <= 3 ) { |
|
| 352 | + if ($month_now <= 3) { |
|
| 353 | 353 | |
| 354 | - if ( ! $end_date ) { |
|
| 354 | + if ( ! $end_date) { |
|
| 355 | 355 | $month = 10; |
| 356 | 356 | } else { |
| 357 | 357 | $year -= 1; |
| 358 | 358 | $month = 12; |
| 359 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 359 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 360 | 360 | $hour = 23; |
| 361 | 361 | $minute = 59; |
| 362 | 362 | $second = 59; |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | - } else if ( $month_now <= 6 ) { |
|
| 365 | + } else if ($month_now <= 6) { |
|
| 366 | 366 | |
| 367 | - if ( ! $end_date ) { |
|
| 367 | + if ( ! $end_date) { |
|
| 368 | 368 | $month = 1; |
| 369 | 369 | } else { |
| 370 | 370 | $month = 3; |
| 371 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 371 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 372 | 372 | $hour = 23; |
| 373 | 373 | $minute = 59; |
| 374 | 374 | $second = 59; |
| 375 | 375 | } |
| 376 | 376 | |
| 377 | - } else if ( $month_now <= 9 ) { |
|
| 377 | + } else if ($month_now <= 9) { |
|
| 378 | 378 | |
| 379 | - if ( ! $end_date ) { |
|
| 379 | + if ( ! $end_date) { |
|
| 380 | 380 | $month = 4; |
| 381 | 381 | } else { |
| 382 | 382 | $month = 6; |
| 383 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 383 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 384 | 384 | $hour = 23; |
| 385 | 385 | $minute = 59; |
| 386 | 386 | $second = 59; |
@@ -388,11 +388,11 @@ discard block |
||
| 388 | 388 | |
| 389 | 389 | } else { |
| 390 | 390 | |
| 391 | - if ( ! $end_date ) { |
|
| 391 | + if ( ! $end_date) { |
|
| 392 | 392 | $month = 7; |
| 393 | 393 | } else { |
| 394 | 394 | $month = 9; |
| 395 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 395 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 396 | 396 | $hour = 23; |
| 397 | 397 | $minute = 59; |
| 398 | 398 | $second = 59; |
@@ -404,11 +404,11 @@ discard block |
||
| 404 | 404 | |
| 405 | 405 | case 'this_year' : |
| 406 | 406 | |
| 407 | - if ( ! $end_date ) { |
|
| 407 | + if ( ! $end_date) { |
|
| 408 | 408 | $month = 1; |
| 409 | 409 | } else { |
| 410 | 410 | $month = 12; |
| 411 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 411 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 412 | 412 | $hour = 23; |
| 413 | 413 | $minute = 59; |
| 414 | 414 | $second = 59; |
@@ -419,11 +419,11 @@ discard block |
||
| 419 | 419 | case 'last_year' : |
| 420 | 420 | |
| 421 | 421 | $year -= 1; |
| 422 | - if ( ! $end_date ) { |
|
| 422 | + if ( ! $end_date) { |
|
| 423 | 423 | $month = 1; |
| 424 | 424 | } else { |
| 425 | 425 | $month = 12; |
| 426 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 426 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 427 | 427 | $hour = 23; |
| 428 | 428 | $minute = 59; |
| 429 | 429 | $second = 59; |
@@ -434,30 +434,30 @@ discard block |
||
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | |
| 437 | - } else if ( is_numeric( $date ) ) { |
|
| 437 | + } else if (is_numeric($date)) { |
|
| 438 | 438 | |
| 439 | 439 | // return $date unchanged since it is a timestamp |
| 440 | 440 | $this->timestamp = true; |
| 441 | 441 | |
| 442 | - } else if ( false !== strtotime( $date ) ) { |
|
| 442 | + } else if (false !== strtotime($date)) { |
|
| 443 | 443 | |
| 444 | - $date = strtotime( $date, current_time( 'timestamp' ) ); |
|
| 445 | - $year = date( 'Y', $date ); |
|
| 446 | - $month = date( 'm', $date ); |
|
| 447 | - $day = date( 'd', $date ); |
|
| 444 | + $date = strtotime($date, current_time('timestamp')); |
|
| 445 | + $year = date('Y', $date); |
|
| 446 | + $month = date('m', $date); |
|
| 447 | + $day = date('d', $date); |
|
| 448 | 448 | |
| 449 | 449 | } else { |
| 450 | 450 | |
| 451 | - return new WP_Error( 'invalid_date', esc_html__( 'Improper date provided.', 'give' ) ); |
|
| 451 | + return new WP_Error('invalid_date', esc_html__('Improper date provided.', 'give')); |
|
| 452 | 452 | |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | - if ( false === $this->timestamp ) { |
|
| 455 | + if (false === $this->timestamp) { |
|
| 456 | 456 | // Create an exact timestamp |
| 457 | - $date = mktime( $hour, $minute, $second, $month, $day, $year ); |
|
| 457 | + $date = mktime($hour, $minute, $second, $month, $day, $year); |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | - return apply_filters( 'give_stats_date', $date, $end_date, $this ); |
|
| 460 | + return apply_filters('give_stats_date', $date, $end_date, $this); |
|
| 461 | 461 | |
| 462 | 462 | } |
| 463 | 463 | |
@@ -473,33 +473,33 @@ discard block |
||
| 473 | 473 | * |
| 474 | 474 | * @return string |
| 475 | 475 | */ |
| 476 | - public function count_where( $where = '' ) { |
|
| 476 | + public function count_where($where = '') { |
|
| 477 | 477 | // Only get payments in our date range |
| 478 | 478 | |
| 479 | 479 | $start_where = ''; |
| 480 | 480 | $end_where = ''; |
| 481 | 481 | |
| 482 | - if ( $this->start_date ) { |
|
| 482 | + if ($this->start_date) { |
|
| 483 | 483 | |
| 484 | - if ( $this->timestamp ) { |
|
| 484 | + if ($this->timestamp) { |
|
| 485 | 485 | $format = 'Y-m-d H:i:s'; |
| 486 | 486 | } else { |
| 487 | 487 | $format = 'Y-m-d 00:00:00'; |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - $start_date = date( $format, $this->start_date ); |
|
| 490 | + $start_date = date($format, $this->start_date); |
|
| 491 | 491 | $start_where = " AND p.post_date >= '{$start_date}'"; |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | - if ( $this->end_date ) { |
|
| 494 | + if ($this->end_date) { |
|
| 495 | 495 | |
| 496 | - if ( $this->timestamp ) { |
|
| 496 | + if ($this->timestamp) { |
|
| 497 | 497 | $format = 'Y-m-d H:i:s'; |
| 498 | 498 | } else { |
| 499 | 499 | $format = 'Y-m-d 23:59:59'; |
| 500 | 500 | } |
| 501 | 501 | |
| 502 | - $end_date = date( $format, $this->end_date ); |
|
| 502 | + $end_date = date($format, $this->end_date); |
|
| 503 | 503 | |
| 504 | 504 | $end_where = " AND p.post_date <= '{$end_date}'"; |
| 505 | 505 | } |
@@ -521,34 +521,34 @@ discard block |
||
| 521 | 521 | * |
| 522 | 522 | * @return string |
| 523 | 523 | */ |
| 524 | - public function payments_where( $where = '' ) { |
|
| 524 | + public function payments_where($where = '') { |
|
| 525 | 525 | |
| 526 | 526 | global $wpdb; |
| 527 | 527 | |
| 528 | 528 | $start_where = ''; |
| 529 | 529 | $end_where = ''; |
| 530 | 530 | |
| 531 | - if ( ! is_wp_error( $this->start_date ) ) { |
|
| 531 | + if ( ! is_wp_error($this->start_date)) { |
|
| 532 | 532 | |
| 533 | - if ( $this->timestamp ) { |
|
| 533 | + if ($this->timestamp) { |
|
| 534 | 534 | $format = 'Y-m-d H:i:s'; |
| 535 | 535 | } else { |
| 536 | 536 | $format = 'Y-m-d 00:00:00'; |
| 537 | 537 | } |
| 538 | 538 | |
| 539 | - $start_date = date( $format, $this->start_date ); |
|
| 539 | + $start_date = date($format, $this->start_date); |
|
| 540 | 540 | $start_where = " AND $wpdb->posts.post_date >= '{$start_date}'"; |
| 541 | 541 | } |
| 542 | 542 | |
| 543 | - if ( ! is_wp_error( $this->end_date ) ) { |
|
| 543 | + if ( ! is_wp_error($this->end_date)) { |
|
| 544 | 544 | |
| 545 | - if ( $this->timestamp ) { |
|
| 545 | + if ($this->timestamp) { |
|
| 546 | 546 | $format = 'Y-m-d 00:00:00'; |
| 547 | 547 | } else { |
| 548 | 548 | $format = 'Y-m-d 23:59:59'; |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | - $end_date = date( $format, $this->end_date ); |
|
| 551 | + $end_date = date($format, $this->end_date); |
|
| 552 | 552 | |
| 553 | 553 | $end_where = " AND $wpdb->posts.post_date <= '{$end_date}'"; |
| 554 | 554 | } |
@@ -111,14 +111,14 @@ discard block |
||
| 111 | 111 | * @since 1.0 |
| 112 | 112 | * @access public |
| 113 | 113 | * |
| 114 | - * @param int $column Column ID. |
|
| 115 | - * @param int $row_id Row ID. |
|
| 116 | - * |
|
| 117 | - * @return object |
|
| 114 | + * @param int $column Column ID. |
|
| 115 | + * @param int $row_id Row ID. |
|
| 116 | + * |
|
| 117 | + * @return object |
|
| 118 | 118 | */ |
| 119 | 119 | public function get_by( $column, $row_id ) { |
| 120 | - /* @var WPDB $wpdb */ |
|
| 121 | - global $wpdb; |
|
| 120 | + /* @var WPDB $wpdb */ |
|
| 121 | + global $wpdb; |
|
| 122 | 122 | |
| 123 | 123 | $column = esc_sql( $column ); |
| 124 | 124 | return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) ); |
@@ -129,15 +129,15 @@ discard block |
||
| 129 | 129 | * |
| 130 | 130 | * @since 1.0 |
| 131 | 131 | * @access public |
| 132 | - * |
|
| 133 | - * @param int $column Column ID. |
|
| 134 | - * @param int $row_id Row ID. |
|
| 135 | - * |
|
| 132 | + * |
|
| 133 | + * @param int $column Column ID. |
|
| 134 | + * @param int $row_id Row ID. |
|
| 135 | + * |
|
| 136 | 136 | * @return string Column value. |
| 137 | 137 | */ |
| 138 | 138 | public function get_column( $column, $row_id ) { |
| 139 | - /* @var WPDB $wpdb */ |
|
| 140 | - global $wpdb; |
|
| 139 | + /* @var WPDB $wpdb */ |
|
| 140 | + global $wpdb; |
|
| 141 | 141 | |
| 142 | 142 | $column = esc_sql( $column ); |
| 143 | 143 | return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
@@ -148,16 +148,16 @@ discard block |
||
| 148 | 148 | * |
| 149 | 149 | * @since 1.0 |
| 150 | 150 | * @access public |
| 151 | - * |
|
| 152 | - * @param int $column Column ID. |
|
| 153 | - * @param string $column_where Column name. |
|
| 154 | - * @param string $column_value Column value. |
|
| 155 | - * |
|
| 151 | + * |
|
| 152 | + * @param int $column Column ID. |
|
| 153 | + * @param string $column_where Column name. |
|
| 154 | + * @param string $column_value Column value. |
|
| 155 | + * |
|
| 156 | 156 | * @return string |
| 157 | 157 | */ |
| 158 | 158 | public function get_column_by( $column, $column_where, $column_value ) { |
| 159 | - /* @var WPDB $wpdb */ |
|
| 160 | - global $wpdb; |
|
| 159 | + /* @var WPDB $wpdb */ |
|
| 160 | + global $wpdb; |
|
| 161 | 161 | |
| 162 | 162 | $column_where = esc_sql( $column_where ); |
| 163 | 163 | $column = esc_sql( $column ); |
@@ -169,15 +169,15 @@ discard block |
||
| 169 | 169 | * |
| 170 | 170 | * @since 1.0 |
| 171 | 171 | * @access public |
| 172 | - * |
|
| 173 | - * @param array $data |
|
| 174 | - * @param string $type |
|
| 175 | - * |
|
| 172 | + * |
|
| 173 | + * @param array $data |
|
| 174 | + * @param string $type |
|
| 175 | + * |
|
| 176 | 176 | * @return int |
| 177 | 177 | */ |
| 178 | 178 | public function insert( $data, $type = '' ) { |
| 179 | - /* @var WPDB $wpdb */ |
|
| 180 | - global $wpdb; |
|
| 179 | + /* @var WPDB $wpdb */ |
|
| 180 | + global $wpdb; |
|
| 181 | 181 | |
| 182 | 182 | // Set default values |
| 183 | 183 | $data = wp_parse_args( $data, $this->get_column_defaults() ); |
@@ -209,16 +209,16 @@ discard block |
||
| 209 | 209 | * |
| 210 | 210 | * @since 1.0 |
| 211 | 211 | * @access public |
| 212 | - * |
|
| 213 | - * @param int $row_id Column ID |
|
| 214 | - * @param array $data |
|
| 215 | - * @param string $where Column value |
|
| 216 | - * |
|
| 212 | + * |
|
| 213 | + * @param int $row_id Column ID |
|
| 214 | + * @param array $data |
|
| 215 | + * @param string $where Column value |
|
| 216 | + * |
|
| 217 | 217 | * @return bool |
| 218 | 218 | */ |
| 219 | 219 | public function update( $row_id, $data = array(), $where = '' ) { |
| 220 | - /* @var WPDB $wpdb */ |
|
| 221 | - global $wpdb; |
|
| 220 | + /* @var WPDB $wpdb */ |
|
| 221 | + global $wpdb; |
|
| 222 | 222 | |
| 223 | 223 | // Row ID must be positive integer |
| 224 | 224 | $row_id = absint( $row_id ); |
@@ -256,14 +256,14 @@ discard block |
||
| 256 | 256 | * |
| 257 | 257 | * @since 1.0 |
| 258 | 258 | * @access public |
| 259 | - * |
|
| 260 | - * @param int $row_id Column ID. |
|
| 261 | - * |
|
| 259 | + * |
|
| 260 | + * @param int $row_id Column ID. |
|
| 261 | + * |
|
| 262 | 262 | * @return bool |
| 263 | 263 | */ |
| 264 | 264 | public function delete( $row_id = 0 ) { |
| 265 | - /* @var WPDB $wpdb */ |
|
| 266 | - global $wpdb; |
|
| 265 | + /* @var WPDB $wpdb */ |
|
| 266 | + global $wpdb; |
|
| 267 | 267 | |
| 268 | 268 | // Row ID must be positive integer |
| 269 | 269 | $row_id = absint( $row_id ); |
@@ -284,13 +284,13 @@ discard block |
||
| 284 | 284 | * |
| 285 | 285 | * @since 1.3.2 |
| 286 | 286 | * @access public |
| 287 | - * |
|
| 287 | + * |
|
| 288 | 288 | * @param string $table The table name. |
| 289 | - * |
|
| 289 | + * |
|
| 290 | 290 | * @return bool If the table name exists. |
| 291 | 291 | */ |
| 292 | 292 | public function table_exists( $table ) { |
| 293 | - /* @var WPDB $wpdb */ |
|
| 293 | + /* @var WPDB $wpdb */ |
|
| 294 | 294 | global $wpdb; |
| 295 | 295 | |
| 296 | 296 | $table = sanitize_text_field( $table ); |
@@ -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 | |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | * |
| 99 | 99 | * @return object |
| 100 | 100 | */ |
| 101 | - public function get( $row_id ) { |
|
| 101 | + public function get($row_id) { |
|
| 102 | 102 | /* @var WPDB $wpdb */ |
| 103 | 103 | global $wpdb; |
| 104 | 104 | |
| 105 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
| 105 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
@@ -116,12 +116,12 @@ discard block |
||
| 116 | 116 | * |
| 117 | 117 | * @return object |
| 118 | 118 | */ |
| 119 | - public function get_by( $column, $row_id ) { |
|
| 119 | + public function get_by($column, $row_id) { |
|
| 120 | 120 | /* @var WPDB $wpdb */ |
| 121 | 121 | global $wpdb; |
| 122 | 122 | |
| 123 | - $column = esc_sql( $column ); |
|
| 124 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) ); |
|
| 123 | + $column = esc_sql($column); |
|
| 124 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id)); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -135,12 +135,12 @@ discard block |
||
| 135 | 135 | * |
| 136 | 136 | * @return string Column value. |
| 137 | 137 | */ |
| 138 | - public function get_column( $column, $row_id ) { |
|
| 138 | + public function get_column($column, $row_id) { |
|
| 139 | 139 | /* @var WPDB $wpdb */ |
| 140 | 140 | global $wpdb; |
| 141 | 141 | |
| 142 | - $column = esc_sql( $column ); |
|
| 143 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
| 142 | + $column = esc_sql($column); |
|
| 143 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -155,13 +155,13 @@ discard block |
||
| 155 | 155 | * |
| 156 | 156 | * @return string |
| 157 | 157 | */ |
| 158 | - public function get_column_by( $column, $column_where, $column_value ) { |
|
| 158 | + public function get_column_by($column, $column_where, $column_value) { |
|
| 159 | 159 | /* @var WPDB $wpdb */ |
| 160 | 160 | global $wpdb; |
| 161 | 161 | |
| 162 | - $column_where = esc_sql( $column_where ); |
|
| 163 | - $column = esc_sql( $column ); |
|
| 164 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) ); |
|
| 162 | + $column_where = esc_sql($column_where); |
|
| 163 | + $column = esc_sql($column); |
|
| 164 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value)); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -175,12 +175,12 @@ discard block |
||
| 175 | 175 | * |
| 176 | 176 | * @return int |
| 177 | 177 | */ |
| 178 | - public function insert( $data, $type = '' ) { |
|
| 178 | + public function insert($data, $type = '') { |
|
| 179 | 179 | /* @var WPDB $wpdb */ |
| 180 | 180 | global $wpdb; |
| 181 | 181 | |
| 182 | 182 | // Set default values. |
| 183 | - $data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
| 183 | + $data = wp_parse_args($data, $this->get_column_defaults()); |
|
| 184 | 184 | |
| 185 | 185 | /** |
| 186 | 186 | * Fires before inserting data to the database. |
@@ -189,22 +189,22 @@ discard block |
||
| 189 | 189 | * |
| 190 | 190 | * @param array $data |
| 191 | 191 | */ |
| 192 | - do_action( "give_pre_insert_{$type}", $data ); |
|
| 192 | + do_action("give_pre_insert_{$type}", $data); |
|
| 193 | 193 | |
| 194 | 194 | // Initialise column format array |
| 195 | 195 | $column_formats = $this->get_columns(); |
| 196 | 196 | |
| 197 | 197 | // Force fields to lower case |
| 198 | - $data = array_change_key_case( $data ); |
|
| 198 | + $data = array_change_key_case($data); |
|
| 199 | 199 | |
| 200 | 200 | // White list columns |
| 201 | - $data = array_intersect_key( $data, $column_formats ); |
|
| 201 | + $data = array_intersect_key($data, $column_formats); |
|
| 202 | 202 | |
| 203 | 203 | // Reorder $column_formats to match the order of columns given in $data |
| 204 | - $data_keys = array_keys( $data ); |
|
| 205 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
| 204 | + $data_keys = array_keys($data); |
|
| 205 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
| 206 | 206 | |
| 207 | - $wpdb->insert( $this->table_name, $data, $column_formats ); |
|
| 207 | + $wpdb->insert($this->table_name, $data, $column_formats); |
|
| 208 | 208 | |
| 209 | 209 | /** |
| 210 | 210 | * Fires after inserting data to the database. |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | * @param int $insert_id |
| 215 | 215 | * @param array $data |
| 216 | 216 | */ |
| 217 | - do_action( "give_post_insert_{$type}", $wpdb->insert_id, $data ); |
|
| 217 | + do_action("give_post_insert_{$type}", $wpdb->insert_id, $data); |
|
| 218 | 218 | |
| 219 | 219 | return $wpdb->insert_id; |
| 220 | 220 | } |
@@ -231,18 +231,18 @@ discard block |
||
| 231 | 231 | * |
| 232 | 232 | * @return bool |
| 233 | 233 | */ |
| 234 | - public function update( $row_id, $data = array(), $where = '' ) { |
|
| 234 | + public function update($row_id, $data = array(), $where = '') { |
|
| 235 | 235 | /* @var WPDB $wpdb */ |
| 236 | 236 | global $wpdb; |
| 237 | 237 | |
| 238 | 238 | // Row ID must be positive integer |
| 239 | - $row_id = absint( $row_id ); |
|
| 239 | + $row_id = absint($row_id); |
|
| 240 | 240 | |
| 241 | - if ( empty( $row_id ) ) { |
|
| 241 | + if (empty($row_id)) { |
|
| 242 | 242 | return false; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - if ( empty( $where ) ) { |
|
| 245 | + if (empty($where)) { |
|
| 246 | 246 | $where = $this->primary_key; |
| 247 | 247 | } |
| 248 | 248 | |
@@ -250,16 +250,16 @@ discard block |
||
| 250 | 250 | $column_formats = $this->get_columns(); |
| 251 | 251 | |
| 252 | 252 | // Force fields to lower case |
| 253 | - $data = array_change_key_case( $data ); |
|
| 253 | + $data = array_change_key_case($data); |
|
| 254 | 254 | |
| 255 | 255 | // White list columns |
| 256 | - $data = array_intersect_key( $data, $column_formats ); |
|
| 256 | + $data = array_intersect_key($data, $column_formats); |
|
| 257 | 257 | |
| 258 | 258 | // Reorder $column_formats to match the order of columns given in $data |
| 259 | - $data_keys = array_keys( $data ); |
|
| 260 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
| 259 | + $data_keys = array_keys($data); |
|
| 260 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
| 261 | 261 | |
| 262 | - if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) { |
|
| 262 | + if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) { |
|
| 263 | 263 | return false; |
| 264 | 264 | } |
| 265 | 265 | |
@@ -276,18 +276,18 @@ discard block |
||
| 276 | 276 | * |
| 277 | 277 | * @return bool |
| 278 | 278 | */ |
| 279 | - public function delete( $row_id = 0 ) { |
|
| 279 | + public function delete($row_id = 0) { |
|
| 280 | 280 | /* @var WPDB $wpdb */ |
| 281 | 281 | global $wpdb; |
| 282 | 282 | |
| 283 | 283 | // Row ID must be positive integer |
| 284 | - $row_id = absint( $row_id ); |
|
| 284 | + $row_id = absint($row_id); |
|
| 285 | 285 | |
| 286 | - if ( empty( $row_id ) ) { |
|
| 286 | + if (empty($row_id)) { |
|
| 287 | 287 | return false; |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) { |
|
| 290 | + if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) { |
|
| 291 | 291 | return false; |
| 292 | 292 | } |
| 293 | 293 | |
@@ -304,13 +304,13 @@ discard block |
||
| 304 | 304 | * |
| 305 | 305 | * @return bool If the table name exists. |
| 306 | 306 | */ |
| 307 | - public function table_exists( $table ) { |
|
| 307 | + public function table_exists($table) { |
|
| 308 | 308 | /* @var WPDB $wpdb */ |
| 309 | 309 | global $wpdb; |
| 310 | 310 | |
| 311 | - $table = sanitize_text_field( $table ); |
|
| 311 | + $table = sanitize_text_field($table); |
|
| 312 | 312 | |
| 313 | - return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table; |
|
| 313 | + return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table; |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | /** |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | * @return bool Returns if the customers table was installed and upgrade routine run. |
| 323 | 323 | */ |
| 324 | 324 | public function installed() { |
| 325 | - return $this->table_exists( $this->table_name ); |
|
| 325 | + return $this->table_exists($this->table_name); |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | } |