@@ -50,7 +50,7 @@ |
||
| 50 | 50 | * @since 1.5 |
| 51 | 51 | * @global object $wpdb Used to query the database using the WordPress |
| 52 | 52 | * Database API |
| 53 | - * @return array $data The data for the CSV file |
|
| 53 | + * @return boolean $data The data for the CSV file |
|
| 54 | 54 | */ |
| 55 | 55 | public function get_data() { |
| 56 | 56 | global $wpdb; |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -62,23 +62,23 @@ discard block |
||
| 62 | 62 | public function get_data() { |
| 63 | 63 | global $give_logs, $wpdb; |
| 64 | 64 | |
| 65 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
| 65 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
| 66 | 66 | |
| 67 | - if ( $this->step == 1 ) { |
|
| 68 | - $this->delete_data( 'give_temp_recount_form_stats' ); |
|
| 67 | + if ($this->step == 1) { |
|
| 68 | + $this->delete_data('give_temp_recount_form_stats'); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - $totals = $this->get_stored_data( 'give_temp_recount_form_stats' ); |
|
| 71 | + $totals = $this->get_stored_data('give_temp_recount_form_stats'); |
|
| 72 | 72 | |
| 73 | - if ( false === $totals ) { |
|
| 73 | + if (false === $totals) { |
|
| 74 | 74 | $totals = array( |
| 75 | 75 | 'earnings' => (float) 0, |
| 76 | 76 | 'sales' => 0, |
| 77 | 77 | ); |
| 78 | - $this->store_data( 'give_temp_recount_form_stats', $totals ); |
|
| 78 | + $this->store_data('give_temp_recount_form_stats', $totals); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - $args = apply_filters( 'give_recount_form_stats_args', array( |
|
| 81 | + $args = apply_filters('give_recount_form_stats_args', array( |
|
| 82 | 82 | 'post_parent' => $this->form_id, |
| 83 | 83 | 'post_type' => 'give_log', |
| 84 | 84 | 'posts_per_page' => $this->per_step, |
@@ -86,49 +86,49 @@ discard block |
||
| 86 | 86 | 'paged' => $this->step, |
| 87 | 87 | 'log_type' => 'sale', |
| 88 | 88 | 'fields' => 'ids', |
| 89 | - ) ); |
|
| 89 | + )); |
|
| 90 | 90 | |
| 91 | - $log_ids = $give_logs->get_connected_logs( $args, 'sale' ); |
|
| 91 | + $log_ids = $give_logs->get_connected_logs($args, 'sale'); |
|
| 92 | 92 | $this->_log_ids_debug = array(); |
| 93 | 93 | |
| 94 | - if ( $log_ids ) { |
|
| 95 | - $log_ids = implode( ',', $log_ids ); |
|
| 96 | - $payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)" ); |
|
| 97 | - unset( $log_ids ); |
|
| 94 | + if ($log_ids) { |
|
| 95 | + $log_ids = implode(',', $log_ids); |
|
| 96 | + $payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)"); |
|
| 97 | + unset($log_ids); |
|
| 98 | 98 | |
| 99 | - $payment_ids = implode( ',', $payment_ids ); |
|
| 100 | - $payments = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (" . $payment_ids . ")" ); |
|
| 101 | - unset( $payment_ids ); |
|
| 99 | + $payment_ids = implode(',', $payment_ids); |
|
| 100 | + $payments = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (".$payment_ids.")"); |
|
| 101 | + unset($payment_ids); |
|
| 102 | 102 | |
| 103 | - foreach ( $payments as $payment ) { |
|
| 103 | + foreach ($payments as $payment) { |
|
| 104 | 104 | |
| 105 | - $payment = new Give_Payment( $payment->ID ); |
|
| 105 | + $payment = new Give_Payment($payment->ID); |
|
| 106 | 106 | |
| 107 | 107 | //Ensure acceptible status only |
| 108 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
| 108 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
| 109 | 109 | continue; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | //Ensure only payments for this form are counted |
| 113 | - if ( $payment->form_id != $this->form_id ) { |
|
| 113 | + if ($payment->form_id != $this->form_id) { |
|
| 114 | 114 | continue; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | $this->_log_ids_debug[] = $payment->ID; |
| 118 | 118 | |
| 119 | - $totals['sales'] ++; |
|
| 119 | + $totals['sales']++; |
|
| 120 | 120 | $totals['earnings'] += $payment->total; |
| 121 | 121 | |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - $this->store_data( 'give_temp_recount_form_stats', $totals ); |
|
| 124 | + $this->store_data('give_temp_recount_form_stats', $totals); |
|
| 125 | 125 | |
| 126 | 126 | return true; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | |
| 130 | - update_post_meta( $this->form_id, '_give_form_sales', $totals['sales'] ); |
|
| 131 | - update_post_meta( $this->form_id, '_give_form_earnings', $totals['earnings'] ); |
|
| 130 | + update_post_meta($this->form_id, '_give_form_sales', $totals['sales']); |
|
| 131 | + update_post_meta($this->form_id, '_give_form_earnings', $totals['earnings']); |
|
| 132 | 132 | |
| 133 | 133 | return false; |
| 134 | 134 | |
@@ -143,54 +143,54 @@ discard block |
||
| 143 | 143 | public function get_percentage_complete() { |
| 144 | 144 | global $give_logs, $wpdb; |
| 145 | 145 | |
| 146 | - if ( $this->step == 1 ) { |
|
| 147 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
| 146 | + if ($this->step == 1) { |
|
| 147 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
| 151 | - $total = $this->get_stored_data( 'give_recount_total_' . $this->form_id ); |
|
| 150 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
| 151 | + $total = $this->get_stored_data('give_recount_total_'.$this->form_id); |
|
| 152 | 152 | |
| 153 | - if ( false === $total ) { |
|
| 153 | + if (false === $total) { |
|
| 154 | 154 | $total = 0; |
| 155 | - $args = apply_filters( 'give_recount_form_stats_total_args', array( |
|
| 155 | + $args = apply_filters('give_recount_form_stats_total_args', array( |
|
| 156 | 156 | 'post_parent' => $this->form_id, |
| 157 | 157 | 'post_type' => 'give_log', |
| 158 | 158 | 'post_status' => 'publish', |
| 159 | 159 | 'log_type' => 'sale', |
| 160 | 160 | 'fields' => 'ids', |
| 161 | 161 | 'nopaging' => true, |
| 162 | - ) ); |
|
| 162 | + )); |
|
| 163 | 163 | |
| 164 | - $log_ids = $give_logs->get_connected_logs( $args, 'sale' ); |
|
| 164 | + $log_ids = $give_logs->get_connected_logs($args, 'sale'); |
|
| 165 | 165 | |
| 166 | - if ( $log_ids ) { |
|
| 167 | - $log_ids = implode( ',', $log_ids ); |
|
| 168 | - $payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)" ); |
|
| 169 | - unset( $log_ids ); |
|
| 166 | + if ($log_ids) { |
|
| 167 | + $log_ids = implode(',', $log_ids); |
|
| 168 | + $payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)"); |
|
| 169 | + unset($log_ids); |
|
| 170 | 170 | |
| 171 | - $payment_ids = implode( ',', $payment_ids ); |
|
| 172 | - $payments = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (" . $payment_ids . ")" ); |
|
| 173 | - unset( $payment_ids ); |
|
| 171 | + $payment_ids = implode(',', $payment_ids); |
|
| 172 | + $payments = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (".$payment_ids.")"); |
|
| 173 | + unset($payment_ids); |
|
| 174 | 174 | |
| 175 | - foreach ( $payments as $payment ) { |
|
| 176 | - if ( in_array( $payment->post_status, $accepted_statuses ) ) { |
|
| 175 | + foreach ($payments as $payment) { |
|
| 176 | + if (in_array($payment->post_status, $accepted_statuses)) { |
|
| 177 | 177 | continue; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - $total ++; |
|
| 180 | + $total++; |
|
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - $this->store_data( 'give_recount_total_' . $this->form_id, $total ); |
|
| 184 | + $this->store_data('give_recount_total_'.$this->form_id, $total); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | $percentage = 100; |
| 188 | 188 | |
| 189 | - if ( $total > 0 ) { |
|
| 190 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 189 | + if ($total > 0) { |
|
| 190 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - if ( $percentage > 100 ) { |
|
| 193 | + if ($percentage > 100) { |
|
| 194 | 194 | $percentage = 100; |
| 195 | 195 | } |
| 196 | 196 | |
@@ -204,8 +204,8 @@ discard block |
||
| 204 | 204 | * |
| 205 | 205 | * @param array $request The Form Data passed into the batch processing |
| 206 | 206 | */ |
| 207 | - public function set_properties( $request ) { |
|
| 208 | - $this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false; |
|
| 207 | + public function set_properties($request) { |
|
| 208 | + $this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false; |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | /** |
@@ -216,31 +216,31 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | public function process_step() { |
| 218 | 218 | |
| 219 | - if ( ! $this->can_export() ) { |
|
| 220 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 219 | + if ( ! $this->can_export()) { |
|
| 220 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | $had_data = $this->get_data(); |
| 224 | 224 | |
| 225 | - if ( $had_data ) { |
|
| 225 | + if ($had_data) { |
|
| 226 | 226 | $this->done = false; |
| 227 | 227 | |
| 228 | 228 | return true; |
| 229 | 229 | } else { |
| 230 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
| 231 | - $this->delete_data( 'give_temp_recount_form_stats' ); |
|
| 230 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
| 231 | + $this->delete_data('give_temp_recount_form_stats'); |
|
| 232 | 232 | $this->done = true; |
| 233 | - $this->message = sprintf( esc_html__( 'Donation counts and income amount statistics successfully recounted for "%s".', 'give' ), get_the_title( $this->form_id ) ); |
|
| 233 | + $this->message = sprintf(esc_html__('Donation counts and income amount statistics successfully recounted for "%s".', 'give'), get_the_title($this->form_id)); |
|
| 234 | 234 | |
| 235 | 235 | return false; |
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | public function headers() { |
| 240 | - ignore_user_abort( true ); |
|
| 240 | + ignore_user_abort(true); |
|
| 241 | 241 | |
| 242 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 243 | - set_time_limit( 0 ); |
|
| 242 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 243 | + set_time_limit(0); |
|
| 244 | 244 | } |
| 245 | 245 | } |
| 246 | 246 | |
@@ -268,11 +268,11 @@ discard block |
||
| 268 | 268 | * |
| 269 | 269 | * @return mixed Returns the data from the database |
| 270 | 270 | */ |
| 271 | - private function get_stored_data( $key ) { |
|
| 271 | + private function get_stored_data($key) { |
|
| 272 | 272 | global $wpdb; |
| 273 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 273 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 274 | 274 | |
| 275 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
| 275 | + return empty($value) ? false : maybe_unserialize($value); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | /** |
@@ -285,10 +285,10 @@ discard block |
||
| 285 | 285 | * |
| 286 | 286 | * @return void |
| 287 | 287 | */ |
| 288 | - private function store_data( $key, $value ) { |
|
| 288 | + private function store_data($key, $value) { |
|
| 289 | 289 | global $wpdb; |
| 290 | 290 | |
| 291 | - $value = maybe_serialize( $value ); |
|
| 291 | + $value = maybe_serialize($value); |
|
| 292 | 292 | |
| 293 | 293 | $data = array( |
| 294 | 294 | 'option_name' => $key, |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | '%s', |
| 303 | 303 | ); |
| 304 | 304 | |
| 305 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 305 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
@@ -314,9 +314,9 @@ discard block |
||
| 314 | 314 | * |
| 315 | 315 | * @return void |
| 316 | 316 | */ |
| 317 | - private function delete_data( $key ) { |
|
| 317 | + private function delete_data($key) { |
|
| 318 | 318 | global $wpdb; |
| 319 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 319 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | } |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | * @since 1.5 |
| 51 | 51 | * @global object $wpdb Used to query the database using the WordPress |
| 52 | 52 | * Database API |
| 53 | - * @return array $data The data for the CSV file |
|
| 53 | + * @return boolean $data The data for the CSV file |
|
| 54 | 54 | */ |
| 55 | 55 | public function get_data() { |
| 56 | 56 | global $wpdb; |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -54,50 +54,50 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function get_data() { |
| 56 | 56 | |
| 57 | - if ( $this->step == 1 ) { |
|
| 58 | - $this->delete_data( 'give_temp_recount_income' ); |
|
| 57 | + if ($this->step == 1) { |
|
| 58 | + $this->delete_data('give_temp_recount_income'); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - $total = get_option( 'give_temp_recount_income', false ); |
|
| 61 | + $total = get_option('give_temp_recount_income', false); |
|
| 62 | 62 | |
| 63 | - if ( false === $total ) { |
|
| 63 | + if (false === $total) { |
|
| 64 | 64 | $total = (float) 0; |
| 65 | - $this->store_data( 'give_temp_recount_income', $total ); |
|
| 65 | + $this->store_data('give_temp_recount_income', $total); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
| 68 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
| 69 | 69 | |
| 70 | - $args = apply_filters( 'give_recount_income_args', array( |
|
| 70 | + $args = apply_filters('give_recount_income_args', array( |
|
| 71 | 71 | 'number' => $this->per_step, |
| 72 | 72 | 'page' => $this->step, |
| 73 | 73 | 'status' => $accepted_statuses, |
| 74 | 74 | 'fields' => 'ids' |
| 75 | - ) ); |
|
| 75 | + )); |
|
| 76 | 76 | |
| 77 | - $payments = give_get_payments( $args ); |
|
| 77 | + $payments = give_get_payments($args); |
|
| 78 | 78 | |
| 79 | - if ( ! empty( $payments ) ) { |
|
| 79 | + if ( ! empty($payments)) { |
|
| 80 | 80 | |
| 81 | - foreach ( $payments as $payment ) { |
|
| 81 | + foreach ($payments as $payment) { |
|
| 82 | 82 | |
| 83 | - $total += give_get_payment_amount( $payment ); |
|
| 83 | + $total += give_get_payment_amount($payment); |
|
| 84 | 84 | |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - if ( $total < 0 ) { |
|
| 87 | + if ($total < 0) { |
|
| 88 | 88 | $totals = 0; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - $total = round( $total, give_currency_decimal_filter() ); |
|
| 91 | + $total = round($total, give_currency_decimal_filter()); |
|
| 92 | 92 | |
| 93 | - $this->store_data( 'give_temp_recount_income', $total ); |
|
| 93 | + $this->store_data('give_temp_recount_income', $total); |
|
| 94 | 94 | |
| 95 | 95 | return true; |
| 96 | 96 | |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - update_option( 'give_income_total', $total ); |
|
| 100 | - set_transient( 'give_income_total', $total, 86400 ); |
|
| 99 | + update_option('give_income_total', $total); |
|
| 100 | + set_transient('give_income_total', $total, 86400); |
|
| 101 | 101 | |
| 102 | 102 | return false; |
| 103 | 103 | |
@@ -111,25 +111,25 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | public function get_percentage_complete() { |
| 113 | 113 | |
| 114 | - $total = $this->get_stored_data( 'give_recount_income_total' ); |
|
| 114 | + $total = $this->get_stored_data('give_recount_income_total'); |
|
| 115 | 115 | |
| 116 | - if ( false === $total ) { |
|
| 117 | - $args = apply_filters( 'give_recount_income_total_args', array() ); |
|
| 116 | + if (false === $total) { |
|
| 117 | + $args = apply_filters('give_recount_income_total_args', array()); |
|
| 118 | 118 | |
| 119 | - $counts = give_count_payments( $args ); |
|
| 120 | - $total = absint( $counts->publish ); |
|
| 121 | - $total = apply_filters( 'give_recount_store_income_total', $total ); |
|
| 119 | + $counts = give_count_payments($args); |
|
| 120 | + $total = absint($counts->publish); |
|
| 121 | + $total = apply_filters('give_recount_store_income_total', $total); |
|
| 122 | 122 | |
| 123 | - $this->store_data( 'give_recount_income_total', $total ); |
|
| 123 | + $this->store_data('give_recount_income_total', $total); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | $percentage = 100; |
| 127 | 127 | |
| 128 | - if ( $total > 0 ) { |
|
| 129 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 128 | + if ($total > 0) { |
|
| 129 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - if ( $percentage > 100 ) { |
|
| 132 | + if ($percentage > 100) { |
|
| 133 | 133 | $percentage = 100; |
| 134 | 134 | } |
| 135 | 135 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * |
| 144 | 144 | * @param array $request The Form Data passed into the batch processing |
| 145 | 145 | */ |
| 146 | - public function set_properties( $request ) { |
|
| 146 | + public function set_properties($request) { |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /** |
@@ -154,31 +154,31 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | public function process_step() { |
| 156 | 156 | |
| 157 | - if ( ! $this->can_export() ) { |
|
| 158 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 157 | + if ( ! $this->can_export()) { |
|
| 158 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | $had_data = $this->get_data(); |
| 162 | 162 | |
| 163 | - if ( $had_data ) { |
|
| 163 | + if ($had_data) { |
|
| 164 | 164 | $this->done = false; |
| 165 | 165 | |
| 166 | 166 | return true; |
| 167 | 167 | } else { |
| 168 | - $this->delete_data( 'give_recount_income_total' ); |
|
| 169 | - $this->delete_data( 'give_temp_recount_income' ); |
|
| 168 | + $this->delete_data('give_recount_income_total'); |
|
| 169 | + $this->delete_data('give_temp_recount_income'); |
|
| 170 | 170 | $this->done = true; |
| 171 | - $this->message = esc_html__( 'Give income successfully recounted.', 'give' ); |
|
| 171 | + $this->message = esc_html__('Give income successfully recounted.', 'give'); |
|
| 172 | 172 | |
| 173 | 173 | return false; |
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | public function headers() { |
| 178 | - ignore_user_abort( true ); |
|
| 178 | + ignore_user_abort(true); |
|
| 179 | 179 | |
| 180 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 181 | - set_time_limit( 0 ); |
|
| 180 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 181 | + set_time_limit(0); |
|
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | |
@@ -206,11 +206,11 @@ discard block |
||
| 206 | 206 | * |
| 207 | 207 | * @return mixed Returns the data from the database |
| 208 | 208 | */ |
| 209 | - private function get_stored_data( $key ) { |
|
| 209 | + private function get_stored_data($key) { |
|
| 210 | 210 | global $wpdb; |
| 211 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 211 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 212 | 212 | |
| 213 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
| 213 | + return empty($value) ? false : maybe_unserialize($value); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | /** |
@@ -223,10 +223,10 @@ discard block |
||
| 223 | 223 | * |
| 224 | 224 | * @return void |
| 225 | 225 | */ |
| 226 | - private function store_data( $key, $value ) { |
|
| 226 | + private function store_data($key, $value) { |
|
| 227 | 227 | global $wpdb; |
| 228 | 228 | |
| 229 | - $value = maybe_serialize( $value ); |
|
| 229 | + $value = maybe_serialize($value); |
|
| 230 | 230 | |
| 231 | 231 | $data = array( |
| 232 | 232 | 'option_name' => $key, |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | '%s', |
| 241 | 241 | ); |
| 242 | 242 | |
| 243 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 243 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /** |
@@ -252,9 +252,9 @@ discard block |
||
| 252 | 252 | * |
| 253 | 253 | * @return void |
| 254 | 254 | */ |
| 255 | - private function delete_data( $key ) { |
|
| 255 | + private function delete_data($key) { |
|
| 256 | 256 | global $wpdb; |
| 257 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 257 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | } |
@@ -206,6 +206,7 @@ |
||
| 206 | 206 | * Set Donor Data |
| 207 | 207 | * |
| 208 | 208 | * @param $donor |
| 209 | + * @param integer $i |
|
| 209 | 210 | */ |
| 210 | 211 | private function set_donor_data( $i, $data, $donor ) { |
| 211 | 212 | |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -46,16 +46,16 @@ discard block |
||
| 46 | 46 | * |
| 47 | 47 | * @param array $request The Form Data passed into the batch processing |
| 48 | 48 | */ |
| 49 | - public function set_properties( $request ) { |
|
| 49 | + public function set_properties($request) { |
|
| 50 | 50 | |
| 51 | 51 | //Set data from form submission |
| 52 | - if ( isset( $_POST['form'] ) ) { |
|
| 53 | - parse_str( $_POST['form'], $this->data ); |
|
| 52 | + if (isset($_POST['form'])) { |
|
| 53 | + parse_str($_POST['form'], $this->data); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | $this->form = $this->data['forms']; |
| 57 | 57 | |
| 58 | - $this->price_id = ! empty( $request['give_price_option'] ) && 0 !== $request['give_price_option'] ? absint( $request['give_price_option'] ) : null; |
|
| 58 | + $this->price_id = ! empty($request['give_price_option']) && 0 !== $request['give_price_option'] ? absint($request['give_price_option']) : null; |
|
| 59 | 59 | |
| 60 | 60 | } |
| 61 | 61 | |
@@ -69,14 +69,14 @@ discard block |
||
| 69 | 69 | public function csv_cols() { |
| 70 | 70 | |
| 71 | 71 | |
| 72 | - $columns = isset( $this->data['give_export_option'] ) ? $this->data['give_export_option'] : array(); |
|
| 72 | + $columns = isset($this->data['give_export_option']) ? $this->data['give_export_option'] : array(); |
|
| 73 | 73 | |
| 74 | 74 | //We need columns. |
| 75 | - if ( empty( $columns ) ) { |
|
| 75 | + if (empty($columns)) { |
|
| 76 | 76 | return false; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - $cols = $this->get_cols( $columns ); |
|
| 79 | + $cols = $this->get_cols($columns); |
|
| 80 | 80 | |
| 81 | 81 | return $cols; |
| 82 | 82 | } |
@@ -84,38 +84,38 @@ discard block |
||
| 84 | 84 | /** |
| 85 | 85 | * @param $column |
| 86 | 86 | */ |
| 87 | - private function get_cols( $columns ) { |
|
| 87 | + private function get_cols($columns) { |
|
| 88 | 88 | |
| 89 | 89 | $cols = array(); |
| 90 | 90 | |
| 91 | - foreach ( $columns as $key => $value ) { |
|
| 91 | + foreach ($columns as $key => $value) { |
|
| 92 | 92 | |
| 93 | - switch ( $key ) { |
|
| 93 | + switch ($key) { |
|
| 94 | 94 | case 'full_name' : |
| 95 | - $cols['full_name'] = esc_html__( 'Full Name', 'give' ); |
|
| 95 | + $cols['full_name'] = esc_html__('Full Name', 'give'); |
|
| 96 | 96 | break; |
| 97 | 97 | case 'email' : |
| 98 | - $cols['email'] = esc_html__( 'Email Address', 'give' ); |
|
| 98 | + $cols['email'] = esc_html__('Email Address', 'give'); |
|
| 99 | 99 | break; |
| 100 | 100 | case 'address' : |
| 101 | - $cols['address_line1'] = esc_html__( 'Address', 'give' ); |
|
| 102 | - $cols['address_line2'] = esc_html__( 'Address 2', 'give' ); |
|
| 103 | - $cols['address_city'] = esc_html__( 'City', 'give' ); |
|
| 104 | - $cols['address_state'] = esc_html__( 'State', 'give' ); |
|
| 105 | - $cols['address_zip'] = esc_html__( 'Zip', 'give' ); |
|
| 106 | - $cols['address_country'] = esc_html__( 'Country', 'give' ); |
|
| 101 | + $cols['address_line1'] = esc_html__('Address', 'give'); |
|
| 102 | + $cols['address_line2'] = esc_html__('Address 2', 'give'); |
|
| 103 | + $cols['address_city'] = esc_html__('City', 'give'); |
|
| 104 | + $cols['address_state'] = esc_html__('State', 'give'); |
|
| 105 | + $cols['address_zip'] = esc_html__('Zip', 'give'); |
|
| 106 | + $cols['address_country'] = esc_html__('Country', 'give'); |
|
| 107 | 107 | break; |
| 108 | 108 | case 'userid' : |
| 109 | - $cols['userid'] = esc_html__( 'User ID', 'give' ); |
|
| 109 | + $cols['userid'] = esc_html__('User ID', 'give'); |
|
| 110 | 110 | break; |
| 111 | 111 | case 'date_first_donated' : |
| 112 | - $cols['date_first_donated'] = esc_html__( 'First Donation Date', 'give' ); |
|
| 112 | + $cols['date_first_donated'] = esc_html__('First Donation Date', 'give'); |
|
| 113 | 113 | break; |
| 114 | 114 | case 'donations' : |
| 115 | - $cols['donations'] = esc_html__( 'Number of Donations', 'give' ); |
|
| 115 | + $cols['donations'] = esc_html__('Number of Donations', 'give'); |
|
| 116 | 116 | break; |
| 117 | 117 | case 'donation_sum' : |
| 118 | - $cols['donation_sum'] = esc_html__( 'Sum of Donations', 'give' ); |
|
| 118 | + $cols['donation_sum'] = esc_html__('Sum of Donations', 'give'); |
|
| 119 | 119 | break; |
| 120 | 120 | } |
| 121 | 121 | } |
@@ -138,20 +138,20 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | $i = 0; |
| 140 | 140 | |
| 141 | - if ( ! empty( $this->form ) ) { |
|
| 141 | + if ( ! empty($this->form)) { |
|
| 142 | 142 | |
| 143 | 143 | // Export donors of a specific product |
| 144 | 144 | global $give_logs; |
| 145 | 145 | |
| 146 | 146 | $args = array( |
| 147 | - 'post_parent' => absint( $this->form ), |
|
| 147 | + 'post_parent' => absint($this->form), |
|
| 148 | 148 | 'log_type' => 'sale', |
| 149 | 149 | 'posts_per_page' => 30, |
| 150 | 150 | 'paged' => $this->step |
| 151 | 151 | ); |
| 152 | 152 | |
| 153 | 153 | //Check for price option |
| 154 | - if ( null !== $this->price_id ) { |
|
| 154 | + if (null !== $this->price_id) { |
|
| 155 | 155 | $args['meta_query'] = array( |
| 156 | 156 | array( |
| 157 | 157 | 'key' => '_give_log_price_id', |
@@ -160,33 +160,33 @@ discard block |
||
| 160 | 160 | ); |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - $logs = $give_logs->get_connected_logs( $args ); |
|
| 163 | + $logs = $give_logs->get_connected_logs($args); |
|
| 164 | 164 | |
| 165 | - if ( $logs ) { |
|
| 166 | - foreach ( $logs as $log ) { |
|
| 167 | - $payment_id = get_post_meta( $log->ID, '_give_log_payment_id', true ); |
|
| 168 | - $payment = new Give_Payment( $payment_id ); |
|
| 169 | - $donor = Give()->customers->get_customer_by( 'id', $payment->customer_id ); |
|
| 170 | - $data[] = $this->set_donor_data( $i, $data, $donor ); |
|
| 171 | - $i ++; |
|
| 165 | + if ($logs) { |
|
| 166 | + foreach ($logs as $log) { |
|
| 167 | + $payment_id = get_post_meta($log->ID, '_give_log_payment_id', true); |
|
| 168 | + $payment = new Give_Payment($payment_id); |
|
| 169 | + $donor = Give()->customers->get_customer_by('id', $payment->customer_id); |
|
| 170 | + $data[] = $this->set_donor_data($i, $data, $donor); |
|
| 171 | + $i++; |
|
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | } else { |
| 176 | 176 | |
| 177 | 177 | // Export all customers |
| 178 | - $offset = 30 * ( $this->step - 1 ); |
|
| 179 | - $donors = Give()->customers->get_customers( array( 'number' => 30, 'offset' => $offset ) ); |
|
| 178 | + $offset = 30 * ($this->step - 1); |
|
| 179 | + $donors = Give()->customers->get_customers(array('number' => 30, 'offset' => $offset)); |
|
| 180 | 180 | |
| 181 | - foreach ( $donors as $donor ) { |
|
| 181 | + foreach ($donors as $donor) { |
|
| 182 | 182 | |
| 183 | - $data[] = $this->set_donor_data( $i, $data, $donor ); |
|
| 184 | - $i ++; |
|
| 183 | + $data[] = $this->set_donor_data($i, $data, $donor); |
|
| 184 | + $i++; |
|
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
| 189 | - $data = apply_filters( 'give_export_get_data_' . $this->export_type, $data ); |
|
| 188 | + $data = apply_filters('give_export_get_data', $data); |
|
| 189 | + $data = apply_filters('give_export_get_data_'.$this->export_type, $data); |
|
| 190 | 190 | |
| 191 | 191 | return $data; |
| 192 | 192 | } |
@@ -202,19 +202,19 @@ discard block |
||
| 202 | 202 | $percentage = 0; |
| 203 | 203 | |
| 204 | 204 | // We can't count the number when getting them for a specific form |
| 205 | - if ( empty( $this->form ) ) { |
|
| 205 | + if (empty($this->form)) { |
|
| 206 | 206 | |
| 207 | 207 | $total = Give()->customers->count(); |
| 208 | 208 | |
| 209 | - if ( $total > 0 ) { |
|
| 209 | + if ($total > 0) { |
|
| 210 | 210 | |
| 211 | - $percentage = ( ( 30 * $this->step ) / $total ) * 100; |
|
| 211 | + $percentage = ((30 * $this->step) / $total) * 100; |
|
| 212 | 212 | |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | - if ( $percentage > 100 ) { |
|
| 217 | + if ($percentage > 100) { |
|
| 218 | 218 | $percentage = 100; |
| 219 | 219 | } |
| 220 | 220 | |
@@ -226,46 +226,46 @@ discard block |
||
| 226 | 226 | * |
| 227 | 227 | * @param $donor |
| 228 | 228 | */ |
| 229 | - private function set_donor_data( $i, $data, $donor ) { |
|
| 229 | + private function set_donor_data($i, $data, $donor) { |
|
| 230 | 230 | |
| 231 | 231 | $columns = $this->csv_cols(); |
| 232 | 232 | |
| 233 | 233 | //Set address variable |
| 234 | 234 | $address = ''; |
| 235 | - if ( isset( $donor->user_id ) && $donor->user_id > 0 ) { |
|
| 236 | - $address = give_get_donor_address( $donor->user_id ); |
|
| 235 | + if (isset($donor->user_id) && $donor->user_id > 0) { |
|
| 236 | + $address = give_get_donor_address($donor->user_id); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | //Set columns |
| 240 | - if ( ! empty( $columns['full_name'] ) ) { |
|
| 241 | - $data[ $i ]['full_name'] = $donor->name; |
|
| 240 | + if ( ! empty($columns['full_name'])) { |
|
| 241 | + $data[$i]['full_name'] = $donor->name; |
|
| 242 | 242 | } |
| 243 | - if ( ! empty( $columns['email'] ) ) { |
|
| 244 | - $data[ $i ]['email'] = $donor->email; |
|
| 243 | + if ( ! empty($columns['email'])) { |
|
| 244 | + $data[$i]['email'] = $donor->email; |
|
| 245 | 245 | } |
| 246 | - if ( ! empty( $columns['address_line1'] ) ) { |
|
| 247 | - |
|
| 248 | - $data[ $i ]['address_line1'] = isset( $address['line1'] ) ? $address['line1'] : ''; |
|
| 249 | - $data[ $i ]['address_line2'] = isset( $address['line2'] ) ? $address['line2'] : ''; |
|
| 250 | - $data[ $i ]['address_city'] = isset( $address['city'] ) ? $address['city'] : ''; |
|
| 251 | - $data[ $i ]['address_state'] = isset( $address['state'] ) ? $address['state'] : ''; |
|
| 252 | - $data[ $i ]['address_zip'] = isset( $address['zip'] ) ? $address['zip'] : ''; |
|
| 253 | - $data[ $i ]['address_country'] = isset( $address['country'] ) ? $address['country'] : ''; |
|
| 246 | + if ( ! empty($columns['address_line1'])) { |
|
| 247 | + |
|
| 248 | + $data[$i]['address_line1'] = isset($address['line1']) ? $address['line1'] : ''; |
|
| 249 | + $data[$i]['address_line2'] = isset($address['line2']) ? $address['line2'] : ''; |
|
| 250 | + $data[$i]['address_city'] = isset($address['city']) ? $address['city'] : ''; |
|
| 251 | + $data[$i]['address_state'] = isset($address['state']) ? $address['state'] : ''; |
|
| 252 | + $data[$i]['address_zip'] = isset($address['zip']) ? $address['zip'] : ''; |
|
| 253 | + $data[$i]['address_country'] = isset($address['country']) ? $address['country'] : ''; |
|
| 254 | 254 | } |
| 255 | - if ( ! empty( $columns['userid'] ) ) { |
|
| 256 | - $data[ $i ]['userid'] = ! empty( $donor->user_id ) ? $donor->user_id : ''; |
|
| 255 | + if ( ! empty($columns['userid'])) { |
|
| 256 | + $data[$i]['userid'] = ! empty($donor->user_id) ? $donor->user_id : ''; |
|
| 257 | 257 | } |
| 258 | - if ( ! empty( $columns['date_first_donated'] ) ) { |
|
| 259 | - $data[ $i ]['date_first_donated'] = date_i18n( get_option( 'date_format' ), strtotime( $donor->date_created ) ); |
|
| 258 | + if ( ! empty($columns['date_first_donated'])) { |
|
| 259 | + $data[$i]['date_first_donated'] = date_i18n(get_option('date_format'), strtotime($donor->date_created)); |
|
| 260 | 260 | } |
| 261 | - if ( ! empty( $columns['donations'] ) ) { |
|
| 262 | - $data[ $i ]['donations'] = $donor->purchase_count; |
|
| 261 | + if ( ! empty($columns['donations'])) { |
|
| 262 | + $data[$i]['donations'] = $donor->purchase_count; |
|
| 263 | 263 | } |
| 264 | - if ( ! empty( $columns['donation_sum'] ) ) { |
|
| 265 | - $data[ $i ]['donation_sum'] = give_format_amount( $donor->purchase_value ); |
|
| 264 | + if ( ! empty($columns['donation_sum'])) { |
|
| 265 | + $data[$i]['donation_sum'] = give_format_amount($donor->purchase_value); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - return $data[ $i ]; |
|
| 268 | + return $data[$i]; |
|
| 269 | 269 | |
| 270 | 270 | } |
| 271 | 271 | |
@@ -65,7 +65,7 @@ |
||
| 65 | 65 | * |
| 66 | 66 | * @since 1.0 |
| 67 | 67 | * @uses Give_Session::get() |
| 68 | - * @return mixed array if errors are present, false if none found |
|
| 68 | + * @return string array if errors are present, false if none found |
|
| 69 | 69 | */ |
| 70 | 70 | function give_get_errors() { |
| 71 | 71 | return Give()->session->get( 'give_errors' ); |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -29,33 +29,33 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | * @return void |
| 31 | 31 | */ |
| 32 | -function give_print_errors( $form_id ) { |
|
| 32 | +function give_print_errors($form_id) { |
|
| 33 | 33 | |
| 34 | 34 | $errors = give_get_errors(); |
| 35 | 35 | |
| 36 | - $request_form_id = isset( $_REQUEST['form-id'] ) ? intval( $_REQUEST['form-id'] ) : 0; |
|
| 36 | + $request_form_id = isset($_REQUEST['form-id']) ? intval($_REQUEST['form-id']) : 0; |
|
| 37 | 37 | |
| 38 | 38 | //Sanity checks first: Ensure that gateway returned errors display on the appropriate form |
| 39 | - if ( ! isset( $_POST['give_ajax'] ) && $request_form_id !== $form_id ) { |
|
| 39 | + if ( ! isset($_POST['give_ajax']) && $request_form_id !== $form_id) { |
|
| 40 | 40 | return; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - if ( $errors ) { |
|
| 44 | - $classes = apply_filters( 'give_error_class', array( |
|
| 43 | + if ($errors) { |
|
| 44 | + $classes = apply_filters('give_error_class', array( |
|
| 45 | 45 | 'give_errors' |
| 46 | - ) ); |
|
| 47 | - echo '<div class="' . implode( ' ', $classes ) . '">'; |
|
| 46 | + )); |
|
| 47 | + echo '<div class="'.implode(' ', $classes).'">'; |
|
| 48 | 48 | // Loop error codes and display errors |
| 49 | - foreach ( $errors as $error_id => $error ) { |
|
| 50 | - echo '<div class="give_error" id="give_error_' . $error_id . '"><p><strong>' . esc_html__( 'Error', 'give' ) . '</strong>: ' . $error . '</p></div>'; |
|
| 49 | + foreach ($errors as $error_id => $error) { |
|
| 50 | + echo '<div class="give_error" id="give_error_'.$error_id.'"><p><strong>'.esc_html__('Error', 'give').'</strong>: '.$error.'</p></div>'; |
|
| 51 | 51 | } |
| 52 | 52 | echo '</div>'; |
| 53 | 53 | give_clear_errors(); |
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | -add_action( 'give_purchase_form_before_personal_info', 'give_print_errors' ); |
|
| 58 | -add_action( 'give_ajax_checkout_errors', 'give_print_errors' ); |
|
| 57 | +add_action('give_purchase_form_before_personal_info', 'give_print_errors'); |
|
| 58 | +add_action('give_ajax_checkout_errors', 'give_print_errors'); |
|
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * Get Errors |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @return mixed array if errors are present, false if none found |
| 69 | 69 | */ |
| 70 | 70 | function give_get_errors() { |
| 71 | - return Give()->session->get( 'give_errors' ); |
|
| 71 | + return Give()->session->get('give_errors'); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -84,13 +84,13 @@ discard block |
||
| 84 | 84 | * |
| 85 | 85 | * @return void |
| 86 | 86 | */ |
| 87 | -function give_set_error( $error_id, $error_message ) { |
|
| 87 | +function give_set_error($error_id, $error_message) { |
|
| 88 | 88 | $errors = give_get_errors(); |
| 89 | - if ( ! $errors ) { |
|
| 89 | + if ( ! $errors) { |
|
| 90 | 90 | $errors = array(); |
| 91 | 91 | } |
| 92 | - $errors[ $error_id ] = $error_message; |
|
| 93 | - Give()->session->set( 'give_errors', $errors ); |
|
| 92 | + $errors[$error_id] = $error_message; |
|
| 93 | + Give()->session->set('give_errors', $errors); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * @return void |
| 102 | 102 | */ |
| 103 | 103 | function give_clear_errors() { |
| 104 | - Give()->session->set( 'give_errors', null ); |
|
| 104 | + Give()->session->set('give_errors', null); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -114,11 +114,11 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @return string |
| 116 | 116 | */ |
| 117 | -function give_unset_error( $error_id ) { |
|
| 117 | +function give_unset_error($error_id) { |
|
| 118 | 118 | $errors = give_get_errors(); |
| 119 | - if ( $errors ) { |
|
| 120 | - unset( $errors[ $error_id ] ); |
|
| 121 | - Give()->session->set( 'give_errors', $errors ); |
|
| 119 | + if ($errors) { |
|
| 120 | + unset($errors[$error_id]); |
|
| 121 | + Give()->session->set('give_errors', $errors); |
|
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * @return void |
| 130 | 130 | */ |
| 131 | 131 | function _give_die_handler() { |
| 132 | - if ( defined( 'GIVE_UNIT_TESTS' ) ) { |
|
| 132 | + if (defined('GIVE_UNIT_TESTS')) { |
|
| 133 | 133 | return '_give_die_handler'; |
| 134 | 134 | } else { |
| 135 | 135 | die(); |
@@ -144,10 +144,10 @@ discard block |
||
| 144 | 144 | * @since 1.0 |
| 145 | 145 | * @return void |
| 146 | 146 | */ |
| 147 | -function give_die( $message = '', $title = '', $status = 400 ) { |
|
| 148 | - add_filter( 'wp_die_ajax_handler', '_give_die_handler', 10, 3 ); |
|
| 149 | - add_filter( 'wp_die_handler', '_give_die_handler', 10, 3 ); |
|
| 150 | - wp_die( $message, $title, array( 'response' => $status ) ); |
|
| 147 | +function give_die($message = '', $title = '', $status = 400) { |
|
| 148 | + add_filter('wp_die_ajax_handler', '_give_die_handler', 10, 3); |
|
| 149 | + add_filter('wp_die_handler', '_give_die_handler', 10, 3); |
|
| 150 | + wp_die($message, $title, array('response' => $status)); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | /** |
@@ -162,10 +162,10 @@ discard block |
||
| 162 | 162 | * |
| 163 | 163 | * @return string $error |
| 164 | 164 | */ |
| 165 | -function give_output_error( $message, $echo = true, $error_id = 'warning' ) { |
|
| 166 | - $error = '<div class="give_errors" id="give_error_' . $error_id . '"><p class="give_error give_' . $error_id . '">' . $message . '</p></div>'; |
|
| 165 | +function give_output_error($message, $echo = true, $error_id = 'warning') { |
|
| 166 | + $error = '<div class="give_errors" id="give_error_'.$error_id.'"><p class="give_error give_'.$error_id.'">'.$message.'</p></div>'; |
|
| 167 | 167 | |
| 168 | - if ( $echo ) { |
|
| 168 | + if ($echo) { |
|
| 169 | 169 | echo $error; |
| 170 | 170 | } else { |
| 171 | 171 | return $error; |
@@ -33,20 +33,20 @@ discard block |
||
| 33 | 33 | $login_redirect = add_query_arg('give-login-success', 'true', give_get_current_page_url()); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - if ( empty( $logout_redirect ) ) { |
|
| 37 | - $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() ); |
|
| 38 | - } |
|
| 36 | + if ( empty( $logout_redirect ) ) { |
|
| 37 | + $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() ); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | 40 | |
| 41 | - // Add user_logout action to logout url. |
|
| 42 | - $logout_redirect = add_query_arg( |
|
| 43 | - array( |
|
| 44 | - 'give_action' => 'user_logout', |
|
| 45 | - 'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ), |
|
| 46 | - 'give_logout_redirect' => urlencode( $logout_redirect ) |
|
| 47 | - ), |
|
| 48 | - home_url('/') |
|
| 49 | - ); |
|
| 41 | + // Add user_logout action to logout url. |
|
| 42 | + $logout_redirect = add_query_arg( |
|
| 43 | + array( |
|
| 44 | + 'give_action' => 'user_logout', |
|
| 45 | + 'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ), |
|
| 46 | + 'give_logout_redirect' => urlencode( $logout_redirect ) |
|
| 47 | + ), |
|
| 48 | + home_url('/') |
|
| 49 | + ); |
|
| 50 | 50 | |
| 51 | 51 | $give_login_redirect = $login_redirect; |
| 52 | 52 | $give_logout_redirect = $logout_redirect; |
@@ -136,23 +136,23 @@ discard block |
||
| 136 | 136 | * @return void |
| 137 | 137 | */ |
| 138 | 138 | function give_process_user_logout( $data ) { |
| 139 | - if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) { |
|
| 139 | + if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) { |
|
| 140 | 140 | |
| 141 | - // Prevent occurring of any custom action on wp_logout. |
|
| 142 | - remove_all_actions( 'wp_logout' ); |
|
| 141 | + // Prevent occurring of any custom action on wp_logout. |
|
| 142 | + remove_all_actions( 'wp_logout' ); |
|
| 143 | 143 | |
| 144 | - // Before logout give action. |
|
| 145 | - do_action( 'give_before_user_logout' ); |
|
| 144 | + // Before logout give action. |
|
| 145 | + do_action( 'give_before_user_logout' ); |
|
| 146 | 146 | |
| 147 | - // Logout user. |
|
| 148 | - wp_logout(); |
|
| 147 | + // Logout user. |
|
| 148 | + wp_logout(); |
|
| 149 | 149 | |
| 150 | - // After logout give action. |
|
| 151 | - do_action( 'give_after_user_logout' ); |
|
| 150 | + // After logout give action. |
|
| 151 | + do_action( 'give_after_user_logout' ); |
|
| 152 | 152 | |
| 153 | - wp_redirect( $data['give_logout_redirect'] ); |
|
| 154 | - give_die(); |
|
| 155 | - } |
|
| 153 | + wp_redirect( $data['give_logout_redirect'] ); |
|
| 154 | + give_die(); |
|
| 155 | + } |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | add_action( 'give_user_logout', 'give_process_user_logout' ); |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -26,15 +26,15 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @return string Login form |
| 28 | 28 | */ |
| 29 | -function give_login_form( $login_redirect = '', $logout_redirect = '' ) { |
|
| 30 | - global $give_login_redirect, $give_logout_redirect;; |
|
| 29 | +function give_login_form($login_redirect = '', $logout_redirect = '') { |
|
| 30 | + global $give_login_redirect, $give_logout_redirect; ; |
|
| 31 | 31 | |
| 32 | - if ( empty( $login_redirect ) ) { |
|
| 32 | + if (empty($login_redirect)) { |
|
| 33 | 33 | $login_redirect = add_query_arg('give-login-success', 'true', give_get_current_page_url()); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - if ( empty( $logout_redirect ) ) { |
|
| 37 | - $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() ); |
|
| 36 | + if (empty($logout_redirect)) { |
|
| 37 | + $logout_redirect = add_query_arg('give-logout-success', 'true', give_get_current_page_url()); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | $logout_redirect = add_query_arg( |
| 43 | 43 | array( |
| 44 | 44 | 'give_action' => 'user_logout', |
| 45 | - 'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ), |
|
| 46 | - 'give_logout_redirect' => urlencode( $logout_redirect ) |
|
| 45 | + 'give_logout_nonce' => wp_create_nonce('give-logout-nonce'), |
|
| 46 | + 'give_logout_redirect' => urlencode($logout_redirect) |
|
| 47 | 47 | ), |
| 48 | 48 | home_url('/') |
| 49 | 49 | ); |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | ob_start(); |
| 55 | 55 | |
| 56 | - give_get_template_part( 'shortcode', 'login' ); |
|
| 56 | + give_get_template_part('shortcode', 'login'); |
|
| 57 | 57 | |
| 58 | - return apply_filters( 'give_login_form', ob_get_clean() ); |
|
| 58 | + return apply_filters('give_login_form', ob_get_clean()); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -69,10 +69,10 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @return string Register form |
| 71 | 71 | */ |
| 72 | -function give_register_form( $redirect = '' ) { |
|
| 72 | +function give_register_form($redirect = '') { |
|
| 73 | 73 | global $give_options, $give_register_redirect; |
| 74 | 74 | |
| 75 | - if ( empty( $redirect ) ) { |
|
| 75 | + if (empty($redirect)) { |
|
| 76 | 76 | $redirect = give_get_current_page_url(); |
| 77 | 77 | } |
| 78 | 78 | |
@@ -80,11 +80,11 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | ob_start(); |
| 82 | 82 | |
| 83 | - if ( ! is_user_logged_in() ) { |
|
| 84 | - give_get_template_part( 'shortcode', 'register' ); |
|
| 83 | + if ( ! is_user_logged_in()) { |
|
| 84 | + give_get_template_part('shortcode', 'register'); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - return apply_filters( 'give_register_form', ob_get_clean() ); |
|
| 87 | + return apply_filters('give_register_form', ob_get_clean()); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -96,34 +96,34 @@ discard block |
||
| 96 | 96 | * |
| 97 | 97 | * @return void |
| 98 | 98 | */ |
| 99 | -function give_process_login_form( $data ) { |
|
| 100 | - if ( wp_verify_nonce( $data['give_login_nonce'], 'give-login-nonce' ) ) { |
|
| 101 | - $user_data = get_user_by( 'login', $data['give_user_login'] ); |
|
| 102 | - if ( ! $user_data ) { |
|
| 103 | - $user_data = get_user_by( 'email', $data['give_user_login'] ); |
|
| 99 | +function give_process_login_form($data) { |
|
| 100 | + if (wp_verify_nonce($data['give_login_nonce'], 'give-login-nonce')) { |
|
| 101 | + $user_data = get_user_by('login', $data['give_user_login']); |
|
| 102 | + if ( ! $user_data) { |
|
| 103 | + $user_data = get_user_by('email', $data['give_user_login']); |
|
| 104 | 104 | } |
| 105 | - if ( $user_data ) { |
|
| 105 | + if ($user_data) { |
|
| 106 | 106 | $user_ID = $user_data->ID; |
| 107 | 107 | $user_email = $user_data->user_email; |
| 108 | - if ( wp_check_password( $data['give_user_pass'], $user_data->user_pass, $user_data->ID ) ) { |
|
| 109 | - give_log_user_in( $user_data->ID, $data['give_user_login'], $data['give_user_pass'] ); |
|
| 108 | + if (wp_check_password($data['give_user_pass'], $user_data->user_pass, $user_data->ID)) { |
|
| 109 | + give_log_user_in($user_data->ID, $data['give_user_login'], $data['give_user_pass']); |
|
| 110 | 110 | } else { |
| 111 | - give_set_error( 'password_incorrect', esc_html__( 'The password you entered is incorrect.', 'give' ) ); |
|
| 111 | + give_set_error('password_incorrect', esc_html__('The password you entered is incorrect.', 'give')); |
|
| 112 | 112 | } |
| 113 | 113 | } else { |
| 114 | - give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) ); |
|
| 114 | + give_set_error('username_incorrect', esc_html__('The username you entered does not exist.', 'give')); |
|
| 115 | 115 | } |
| 116 | 116 | // Check for errors and redirect if none present |
| 117 | 117 | $errors = give_get_errors(); |
| 118 | - if ( ! $errors ) { |
|
| 119 | - $redirect = apply_filters( 'give_login_redirect', $data['give_login_redirect'], $user_ID ); |
|
| 120 | - wp_redirect( $redirect ); |
|
| 118 | + if ( ! $errors) { |
|
| 119 | + $redirect = apply_filters('give_login_redirect', $data['give_login_redirect'], $user_ID); |
|
| 120 | + wp_redirect($redirect); |
|
| 121 | 121 | give_die(); |
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | -add_action( 'give_user_login', 'give_process_login_form' ); |
|
| 126 | +add_action('give_user_login', 'give_process_login_form'); |
|
| 127 | 127 | |
| 128 | 128 | |
| 129 | 129 | /** |
@@ -135,27 +135,27 @@ discard block |
||
| 135 | 135 | * |
| 136 | 136 | * @return void |
| 137 | 137 | */ |
| 138 | -function give_process_user_logout( $data ) { |
|
| 139 | - if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) { |
|
| 138 | +function give_process_user_logout($data) { |
|
| 139 | + if (wp_verify_nonce($data['give_logout_nonce'], 'give-logout-nonce') && is_user_logged_in()) { |
|
| 140 | 140 | |
| 141 | 141 | // Prevent occurring of any custom action on wp_logout. |
| 142 | - remove_all_actions( 'wp_logout' ); |
|
| 142 | + remove_all_actions('wp_logout'); |
|
| 143 | 143 | |
| 144 | 144 | // Before logout give action. |
| 145 | - do_action( 'give_before_user_logout' ); |
|
| 145 | + do_action('give_before_user_logout'); |
|
| 146 | 146 | |
| 147 | 147 | // Logout user. |
| 148 | 148 | wp_logout(); |
| 149 | 149 | |
| 150 | 150 | // After logout give action. |
| 151 | - do_action( 'give_after_user_logout' ); |
|
| 151 | + do_action('give_after_user_logout'); |
|
| 152 | 152 | |
| 153 | - wp_redirect( $data['give_logout_redirect'] ); |
|
| 153 | + wp_redirect($data['give_logout_redirect']); |
|
| 154 | 154 | give_die(); |
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | -add_action( 'give_user_logout', 'give_process_user_logout' ); |
|
| 158 | +add_action('give_user_logout', 'give_process_user_logout'); |
|
| 159 | 159 | |
| 160 | 160 | /** |
| 161 | 161 | * Log User In |
@@ -168,15 +168,15 @@ discard block |
||
| 168 | 168 | * |
| 169 | 169 | * @return void |
| 170 | 170 | */ |
| 171 | -function give_log_user_in( $user_id, $user_login, $user_pass ) { |
|
| 172 | - if ( $user_id < 1 ) { |
|
| 171 | +function give_log_user_in($user_id, $user_login, $user_pass) { |
|
| 172 | + if ($user_id < 1) { |
|
| 173 | 173 | return; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - wp_set_auth_cookie( $user_id ); |
|
| 177 | - wp_set_current_user( $user_id, $user_login ); |
|
| 178 | - do_action( 'wp_login', $user_login, get_userdata( $user_id ) ); |
|
| 179 | - do_action( 'give_log_user_in', $user_id, $user_login, $user_pass ); |
|
| 176 | + wp_set_auth_cookie($user_id); |
|
| 177 | + wp_set_current_user($user_id, $user_login); |
|
| 178 | + do_action('wp_login', $user_login, get_userdata($user_id)); |
|
| 179 | + do_action('give_log_user_in', $user_id, $user_login, $user_pass); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | |
@@ -189,70 +189,70 @@ discard block |
||
| 189 | 189 | * |
| 190 | 190 | * @return void |
| 191 | 191 | */ |
| 192 | -function give_process_register_form( $data ) { |
|
| 192 | +function give_process_register_form($data) { |
|
| 193 | 193 | |
| 194 | - if ( is_user_logged_in() ) { |
|
| 194 | + if (is_user_logged_in()) { |
|
| 195 | 195 | return; |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - if ( empty( $_POST['give_register_submit'] ) ) { |
|
| 198 | + if (empty($_POST['give_register_submit'])) { |
|
| 199 | 199 | return; |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - do_action( 'give_pre_process_register_form' ); |
|
| 202 | + do_action('give_pre_process_register_form'); |
|
| 203 | 203 | |
| 204 | - if ( empty( $data['give_user_login'] ) ) { |
|
| 205 | - give_set_error( 'empty_username', esc_html__( 'Invalid username.', 'give' ) ); |
|
| 204 | + if (empty($data['give_user_login'])) { |
|
| 205 | + give_set_error('empty_username', esc_html__('Invalid username.', 'give')); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - if ( username_exists( $data['give_user_login'] ) ) { |
|
| 209 | - give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) ); |
|
| 208 | + if (username_exists($data['give_user_login'])) { |
|
| 209 | + give_set_error('username_unavailable', esc_html__('Username already taken.', 'give')); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - if ( ! validate_username( $data['give_user_login'] ) ) { |
|
| 213 | - give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) ); |
|
| 212 | + if ( ! validate_username($data['give_user_login'])) { |
|
| 213 | + give_set_error('username_invalid', esc_html__('Invalid username.', 'give')); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - if ( email_exists( $data['give_user_email'] ) ) { |
|
| 217 | - give_set_error( 'email_unavailable', esc_html__( 'Email address already taken.', 'give' ) ); |
|
| 216 | + if (email_exists($data['give_user_email'])) { |
|
| 217 | + give_set_error('email_unavailable', esc_html__('Email address already taken.', 'give')); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - if ( empty( $data['give_user_email'] ) || ! is_email( $data['give_user_email'] ) ) { |
|
| 221 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
| 220 | + if (empty($data['give_user_email']) || ! is_email($data['give_user_email'])) { |
|
| 221 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - if ( ! empty( $data['give_payment_email'] ) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email( $data['give_payment_email'] ) ) { |
|
| 225 | - give_set_error( 'payment_email_invalid', esc_html__( 'Invalid payment email.', 'give' ) ); |
|
| 224 | + if ( ! empty($data['give_payment_email']) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email($data['give_payment_email'])) { |
|
| 225 | + give_set_error('payment_email_invalid', esc_html__('Invalid payment email.', 'give')); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - if ( empty( $_POST['give_user_pass'] ) ) { |
|
| 229 | - give_set_error( 'empty_password', esc_html__( 'Please enter a password.', 'give' ) ); |
|
| 228 | + if (empty($_POST['give_user_pass'])) { |
|
| 229 | + give_set_error('empty_password', esc_html__('Please enter a password.', 'give')); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | - if ( ( ! empty( $_POST['give_user_pass'] ) && empty( $_POST['give_user_pass2'] ) ) || ( $_POST['give_user_pass'] !== $_POST['give_user_pass2'] ) ) { |
|
| 233 | - give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) ); |
|
| 232 | + if (( ! empty($_POST['give_user_pass']) && empty($_POST['give_user_pass2'])) || ($_POST['give_user_pass'] !== $_POST['give_user_pass2'])) { |
|
| 233 | + give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give')); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - do_action( 'give_process_register_form' ); |
|
| 236 | + do_action('give_process_register_form'); |
|
| 237 | 237 | |
| 238 | 238 | // Check for errors and redirect if none present |
| 239 | 239 | $errors = give_get_errors(); |
| 240 | 240 | |
| 241 | - if ( empty( $errors ) ) { |
|
| 241 | + if (empty($errors)) { |
|
| 242 | 242 | |
| 243 | - $redirect = apply_filters( 'give_register_redirect', $data['give_redirect'] ); |
|
| 243 | + $redirect = apply_filters('give_register_redirect', $data['give_redirect']); |
|
| 244 | 244 | |
| 245 | - give_register_and_login_new_user( array( |
|
| 245 | + give_register_and_login_new_user(array( |
|
| 246 | 246 | 'user_login' => $data['give_user_login'], |
| 247 | 247 | 'user_pass' => $data['give_user_pass'], |
| 248 | 248 | 'user_email' => $data['give_user_email'], |
| 249 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
| 250 | - 'role' => get_option( 'default_role' ) |
|
| 251 | - ) ); |
|
| 249 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
| 250 | + 'role' => get_option('default_role') |
|
| 251 | + )); |
|
| 252 | 252 | |
| 253 | - wp_redirect( $redirect ); |
|
| 253 | + wp_redirect($redirect); |
|
| 254 | 254 | give_die(); |
| 255 | 255 | } |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | -add_action( 'give_user_register', 'give_process_register_form' ); |
|
| 259 | 258 | \ No newline at end of file |
| 259 | +add_action('give_user_register', 'give_process_register_form'); |
|
| 260 | 260 | \ No newline at end of file |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | //validate display_style and float_labels value |
| 93 | 93 | if ( ( $key == 'display_style' && ! in_array( $value, array( 'onpage', 'reveal', 'modal' ) ) ) |
| 94 | - || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) ) |
|
| 94 | + || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) ) |
|
| 95 | 95 | ) { |
| 96 | 96 | |
| 97 | 97 | $atts[ $key ] = ''; |
@@ -169,15 +169,15 @@ discard block |
||
| 169 | 169 | */ |
| 170 | 170 | function give_login_form_shortcode( $atts, $content = null ) { |
| 171 | 171 | $atts = shortcode_atts( array( |
| 172 | - // Add backward compatibility for redirect attribute. |
|
| 173 | - 'redirect' => '', |
|
| 172 | + // Add backward compatibility for redirect attribute. |
|
| 173 | + 'redirect' => '', |
|
| 174 | 174 | |
| 175 | 175 | 'login-redirect' => '', |
| 176 | 176 | 'logout-redirect' => '', |
| 177 | 177 | ), $atts, 'give_login' ); |
| 178 | 178 | |
| 179 | - // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute. |
|
| 180 | - $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect' ] ) ? $atts['redirect'] : '' ); |
|
| 179 | + // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute. |
|
| 180 | + $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect' ] ) ? $atts['redirect'] : '' ); |
|
| 181 | 181 | |
| 182 | 182 | return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] ); |
| 183 | 183 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -25,28 +25,28 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | function give_donation_history() { |
| 27 | 27 | |
| 28 | - $email_access = give_get_option( 'email_access' ); |
|
| 28 | + $email_access = give_get_option('email_access'); |
|
| 29 | 29 | |
| 30 | 30 | //Is user logged in? Does a session exist? Does an email-access token exist? |
| 31 | - if ( is_user_logged_in() || Give()->session->get_session_expiration() !== false || ( $email_access == 'on' && Give()->email_access->token_exists ) ) { |
|
| 31 | + if (is_user_logged_in() || Give()->session->get_session_expiration() !== false || ($email_access == 'on' && Give()->email_access->token_exists)) { |
|
| 32 | 32 | ob_start(); |
| 33 | - give_get_template_part( 'history', 'donations' ); |
|
| 33 | + give_get_template_part('history', 'donations'); |
|
| 34 | 34 | |
| 35 | 35 | return ob_get_clean(); |
| 36 | 36 | } //Is Email-based access enabled? |
| 37 | - elseif ( $email_access == 'on' ) { |
|
| 37 | + elseif ($email_access == 'on') { |
|
| 38 | 38 | |
| 39 | 39 | ob_start(); |
| 40 | - give_get_template_part( 'email', 'login-form' ); |
|
| 40 | + give_get_template_part('email', 'login-form'); |
|
| 41 | 41 | |
| 42 | 42 | return ob_get_clean(); |
| 43 | 43 | } else { |
| 44 | - $message = esc_html__( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' ); |
|
| 45 | - echo apply_filters( 'give_donation_history_nonuser_message', give_output_error( $message, false ), $message ); |
|
| 44 | + $message = esc_html__('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give'); |
|
| 45 | + echo apply_filters('give_donation_history_nonuser_message', give_output_error($message, false), $message); |
|
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | -add_shortcode( 'donation_history', 'give_donation_history' ); |
|
| 49 | +add_shortcode('donation_history', 'give_donation_history'); |
|
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * Donation Form Shortcode |
@@ -60,53 +60,53 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @return string |
| 62 | 62 | */ |
| 63 | -function give_form_shortcode( $atts, $content = null ) { |
|
| 64 | - $atts = shortcode_atts( array( |
|
| 63 | +function give_form_shortcode($atts, $content = null) { |
|
| 64 | + $atts = shortcode_atts(array( |
|
| 65 | 65 | 'id' => '', |
| 66 | 66 | 'show_title' => true, |
| 67 | 67 | 'show_goal' => true, |
| 68 | 68 | 'show_content' => '', |
| 69 | 69 | 'float_labels' => '', |
| 70 | 70 | 'display_style' => '', |
| 71 | - ), $atts, 'give_form' ); |
|
| 71 | + ), $atts, 'give_form'); |
|
| 72 | 72 | |
| 73 | - foreach ( $atts as $key => $value ) { |
|
| 73 | + foreach ($atts as $key => $value) { |
|
| 74 | 74 | //convert shortcode_atts values to booleans |
| 75 | - if ( $key == 'show_title' ) { |
|
| 76 | - $atts[ $key ] = filter_var( $atts[ $key ], FILTER_VALIDATE_BOOLEAN ); |
|
| 77 | - } elseif ( $key == 'show_goal' ) { |
|
| 78 | - $atts[ $key ] = filter_var( $atts[ $key ], FILTER_VALIDATE_BOOLEAN ); |
|
| 75 | + if ($key == 'show_title') { |
|
| 76 | + $atts[$key] = filter_var($atts[$key], FILTER_VALIDATE_BOOLEAN); |
|
| 77 | + } elseif ($key == 'show_goal') { |
|
| 78 | + $atts[$key] = filter_var($atts[$key], FILTER_VALIDATE_BOOLEAN); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | //validate show_content value |
| 82 | - if ( $key == 'show_content' ) { |
|
| 83 | - if ( ! in_array( $value, array( 'none', 'above', 'below' ) ) ) { |
|
| 84 | - $atts[ $key ] = ''; |
|
| 85 | - } else if ( $value == 'above' ) { |
|
| 86 | - $atts[ $key ] = 'give_pre_form'; |
|
| 87 | - } else if ( $value == 'below' ) { |
|
| 88 | - $atts[ $key ] = 'give_post_form'; |
|
| 82 | + if ($key == 'show_content') { |
|
| 83 | + if ( ! in_array($value, array('none', 'above', 'below'))) { |
|
| 84 | + $atts[$key] = ''; |
|
| 85 | + } else if ($value == 'above') { |
|
| 86 | + $atts[$key] = 'give_pre_form'; |
|
| 87 | + } else if ($value == 'below') { |
|
| 88 | + $atts[$key] = 'give_post_form'; |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | //validate display_style and float_labels value |
| 93 | - if ( ( $key == 'display_style' && ! in_array( $value, array( 'onpage', 'reveal', 'modal' ) ) ) |
|
| 94 | - || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) ) |
|
| 93 | + if (($key == 'display_style' && ! in_array($value, array('onpage', 'reveal', 'modal'))) |
|
| 94 | + || ($key == 'float_labels' && ! in_array($value, array('enabled', 'disabled'))) |
|
| 95 | 95 | ) { |
| 96 | 96 | |
| 97 | - $atts[ $key ] = ''; |
|
| 97 | + $atts[$key] = ''; |
|
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | //get the Give Form |
| 102 | 102 | ob_start(); |
| 103 | - give_get_donation_form( $atts ); |
|
| 103 | + give_get_donation_form($atts); |
|
| 104 | 104 | $final_output = ob_get_clean(); |
| 105 | 105 | |
| 106 | - return apply_filters( 'give_donate_form', $final_output, $atts ); |
|
| 106 | + return apply_filters('give_donate_form', $final_output, $atts); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | -add_shortcode( 'give_form', 'give_form_shortcode' ); |
|
| 109 | +add_shortcode('give_form', 'give_form_shortcode'); |
|
| 110 | 110 | |
| 111 | 111 | /** |
| 112 | 112 | * Donation Form Goal Shortcode. |
@@ -120,37 +120,37 @@ discard block |
||
| 120 | 120 | * |
| 121 | 121 | * @return string |
| 122 | 122 | */ |
| 123 | -function give_goal_shortcode( $atts, $content = null ) { |
|
| 124 | - $atts = shortcode_atts( array( |
|
| 123 | +function give_goal_shortcode($atts, $content = null) { |
|
| 124 | + $atts = shortcode_atts(array( |
|
| 125 | 125 | 'id' => '', |
| 126 | 126 | 'show_text' => true, |
| 127 | 127 | 'show_bar' => true, |
| 128 | - ), $atts, 'give_goal' ); |
|
| 128 | + ), $atts, 'give_goal'); |
|
| 129 | 129 | |
| 130 | 130 | |
| 131 | 131 | //get the Give Form. |
| 132 | 132 | ob_start(); |
| 133 | 133 | |
| 134 | 134 | //Sanity check 1: ensure there is an ID Provided. |
| 135 | - if ( empty( $atts['id'] ) ) { |
|
| 136 | - give_output_error( esc_html__( 'Error: No Donation form ID for the shortcode provided.', 'give' ), true ); |
|
| 135 | + if (empty($atts['id'])) { |
|
| 136 | + give_output_error(esc_html__('Error: No Donation form ID for the shortcode provided.', 'give'), true); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | //Sanity check 2: Check that this form even has Goals enabled. |
| 140 | - $goal_option = get_post_meta( $atts['id'], '_give_goal_option', true ); |
|
| 141 | - if ( empty( $goal_option ) || $goal_option !== 'yes' ) { |
|
| 142 | - give_output_error( esc_html__( 'Error: This form does not have Goals enabled.', 'give' ), true ); |
|
| 140 | + $goal_option = get_post_meta($atts['id'], '_give_goal_option', true); |
|
| 141 | + if (empty($goal_option) || $goal_option !== 'yes') { |
|
| 142 | + give_output_error(esc_html__('Error: This form does not have Goals enabled.', 'give'), true); |
|
| 143 | 143 | } else { |
| 144 | 144 | //Passed all sanity checks: output Goal. |
| 145 | - give_show_goal_progress( $atts['id'], $atts ); |
|
| 145 | + give_show_goal_progress($atts['id'], $atts); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | $final_output = ob_get_clean(); |
| 149 | 149 | |
| 150 | - return apply_filters( 'give_goal_shortcode_output', $final_output, $atts ); |
|
| 150 | + return apply_filters('give_goal_shortcode_output', $final_output, $atts); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | -add_shortcode( 'give_goal', 'give_goal_shortcode' ); |
|
| 153 | +add_shortcode('give_goal', 'give_goal_shortcode'); |
|
| 154 | 154 | |
| 155 | 155 | |
| 156 | 156 | /** |
@@ -167,22 +167,22 @@ discard block |
||
| 167 | 167 | * @uses give_login_form() |
| 168 | 168 | * @return string |
| 169 | 169 | */ |
| 170 | -function give_login_form_shortcode( $atts, $content = null ) { |
|
| 171 | - $atts = shortcode_atts( array( |
|
| 170 | +function give_login_form_shortcode($atts, $content = null) { |
|
| 171 | + $atts = shortcode_atts(array( |
|
| 172 | 172 | // Add backward compatibility for redirect attribute. |
| 173 | 173 | 'redirect' => '', |
| 174 | 174 | |
| 175 | 175 | 'login-redirect' => '', |
| 176 | 176 | 'logout-redirect' => '', |
| 177 | - ), $atts, 'give_login' ); |
|
| 177 | + ), $atts, 'give_login'); |
|
| 178 | 178 | |
| 179 | 179 | // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute. |
| 180 | - $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect' ] ) ? $atts['redirect'] : '' ); |
|
| 180 | + $atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : ''); |
|
| 181 | 181 | |
| 182 | - return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] ); |
|
| 182 | + return give_login_form($atts['login-redirect'], $atts['logout-redirect']); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | -add_shortcode( 'give_login', 'give_login_form_shortcode' ); |
|
| 185 | +add_shortcode('give_login', 'give_login_form_shortcode'); |
|
| 186 | 186 | |
| 187 | 187 | /** |
| 188 | 188 | * Register Shortcode. |
@@ -197,15 +197,15 @@ discard block |
||
| 197 | 197 | * @uses give_register_form() |
| 198 | 198 | * @return string |
| 199 | 199 | */ |
| 200 | -function give_register_form_shortcode( $atts, $content = null ) { |
|
| 201 | - $atts = shortcode_atts( array( |
|
| 200 | +function give_register_form_shortcode($atts, $content = null) { |
|
| 201 | + $atts = shortcode_atts(array( |
|
| 202 | 202 | 'redirect' => '', |
| 203 | - ), $atts, 'give_register' ); |
|
| 203 | + ), $atts, 'give_register'); |
|
| 204 | 204 | |
| 205 | - return give_register_form( $atts['redirect'] ); |
|
| 205 | + return give_register_form($atts['redirect']); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | -add_shortcode( 'give_register', 'give_register_form_shortcode' ); |
|
| 208 | +add_shortcode('give_register', 'give_register_form_shortcode'); |
|
| 209 | 209 | |
| 210 | 210 | |
| 211 | 211 | /** |
@@ -220,62 +220,62 @@ discard block |
||
| 220 | 220 | * |
| 221 | 221 | * @return string |
| 222 | 222 | */ |
| 223 | -function give_receipt_shortcode( $atts, $content = null ) { |
|
| 223 | +function give_receipt_shortcode($atts, $content = null) { |
|
| 224 | 224 | |
| 225 | 225 | global $give_receipt_args, $payment; |
| 226 | 226 | |
| 227 | - $give_receipt_args = shortcode_atts( array( |
|
| 228 | - 'error' => esc_html__( 'Sorry, you are missing the payment key to view this donation receipt.', 'give' ), |
|
| 227 | + $give_receipt_args = shortcode_atts(array( |
|
| 228 | + 'error' => esc_html__('Sorry, you are missing the payment key to view this donation receipt.', 'give'), |
|
| 229 | 229 | 'price' => true, |
| 230 | 230 | 'donor' => true, |
| 231 | 231 | 'date' => true, |
| 232 | 232 | 'payment_key' => false, |
| 233 | 233 | 'payment_method' => true, |
| 234 | 234 | 'payment_id' => true |
| 235 | - ), $atts, 'give_receipt' ); |
|
| 235 | + ), $atts, 'give_receipt'); |
|
| 236 | 236 | |
| 237 | 237 | //set $session var |
| 238 | 238 | $session = give_get_purchase_session(); |
| 239 | 239 | |
| 240 | 240 | //set payment key var |
| 241 | - if ( isset( $_GET['payment_key'] ) ) { |
|
| 242 | - $payment_key = urldecode( $_GET['payment_key'] ); |
|
| 243 | - } elseif ( $session ) { |
|
| 241 | + if (isset($_GET['payment_key'])) { |
|
| 242 | + $payment_key = urldecode($_GET['payment_key']); |
|
| 243 | + } elseif ($session) { |
|
| 244 | 244 | $payment_key = $session['purchase_key']; |
| 245 | - } elseif ( $give_receipt_args['payment_key'] ) { |
|
| 245 | + } elseif ($give_receipt_args['payment_key']) { |
|
| 246 | 246 | $payment_key = $give_receipt_args['payment_key']; |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - $email_access = give_get_option( 'email_access' ); |
|
| 249 | + $email_access = give_get_option('email_access'); |
|
| 250 | 250 | |
| 251 | 251 | // No payment_key found & Email Access is Turned on: |
| 252 | - if ( ! isset( $payment_key ) && $email_access == 'on' && ! Give()->email_access->token_exists ) { |
|
| 252 | + if ( ! isset($payment_key) && $email_access == 'on' && ! Give()->email_access->token_exists) { |
|
| 253 | 253 | |
| 254 | 254 | ob_start(); |
| 255 | 255 | |
| 256 | - give_get_template_part( 'email-login-form' ); |
|
| 256 | + give_get_template_part('email-login-form'); |
|
| 257 | 257 | |
| 258 | 258 | return ob_get_clean(); |
| 259 | 259 | |
| 260 | - } elseif ( ! isset( $payment_key ) ) { |
|
| 260 | + } elseif ( ! isset($payment_key)) { |
|
| 261 | 261 | |
| 262 | - return give_output_error( $give_receipt_args['error'], false, 'error' ); |
|
| 262 | + return give_output_error($give_receipt_args['error'], false, 'error'); |
|
| 263 | 263 | |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - $payment_id = give_get_purchase_id_by_key( $payment_key ); |
|
| 267 | - $user_can_view = give_can_view_receipt( $payment_key ); |
|
| 266 | + $payment_id = give_get_purchase_id_by_key($payment_key); |
|
| 267 | + $user_can_view = give_can_view_receipt($payment_key); |
|
| 268 | 268 | |
| 269 | 269 | // Key was provided, but user is logged out. Offer them the ability to login and view the receipt. |
| 270 | - if ( ! $user_can_view && $email_access == 'on' && ! Give()->email_access->token_exists ) { |
|
| 270 | + if ( ! $user_can_view && $email_access == 'on' && ! Give()->email_access->token_exists) { |
|
| 271 | 271 | |
| 272 | 272 | ob_start(); |
| 273 | 273 | |
| 274 | - give_get_template_part( 'email-login-form' ); |
|
| 274 | + give_get_template_part('email-login-form'); |
|
| 275 | 275 | |
| 276 | 276 | return ob_get_clean(); |
| 277 | 277 | |
| 278 | - } elseif ( ! $user_can_view ) { |
|
| 278 | + } elseif ( ! $user_can_view) { |
|
| 279 | 279 | |
| 280 | 280 | global $give_login_redirect; |
| 281 | 281 | |
@@ -283,9 +283,9 @@ discard block |
||
| 283 | 283 | |
| 284 | 284 | ob_start(); |
| 285 | 285 | |
| 286 | - give_output_error( apply_filters( 'give_must_be_logged_in_error_message', esc_html__( 'You must be logged in to view this donation payment receipt.', 'give' ) ) ); |
|
| 286 | + give_output_error(apply_filters('give_must_be_logged_in_error_message', esc_html__('You must be logged in to view this donation payment receipt.', 'give'))); |
|
| 287 | 287 | |
| 288 | - give_get_template_part( 'shortcode', 'login' ); |
|
| 288 | + give_get_template_part('shortcode', 'login'); |
|
| 289 | 289 | |
| 290 | 290 | $login_form = ob_get_clean(); |
| 291 | 291 | |
@@ -300,13 +300,13 @@ discard block |
||
| 300 | 300 | * or if user is logged in and the user can view sensitive shop data. |
| 301 | 301 | * |
| 302 | 302 | */ |
| 303 | - if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) { |
|
| 304 | - return give_output_error( $give_receipt_args['error'], false, 'error' ); |
|
| 303 | + if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) { |
|
| 304 | + return give_output_error($give_receipt_args['error'], false, 'error'); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | ob_start(); |
| 308 | 308 | |
| 309 | - give_get_template_part( 'shortcode', 'receipt' ); |
|
| 309 | + give_get_template_part('shortcode', 'receipt'); |
|
| 310 | 310 | |
| 311 | 311 | $display = ob_get_clean(); |
| 312 | 312 | |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | -add_shortcode( 'give_receipt', 'give_receipt_shortcode' ); |
|
| 318 | +add_shortcode('give_receipt', 'give_receipt_shortcode'); |
|
| 319 | 319 | |
| 320 | 320 | /** |
| 321 | 321 | * Profile Editor Shortcode. |
@@ -335,18 +335,18 @@ discard block |
||
| 335 | 335 | * |
| 336 | 336 | * @return string Output generated from the profile editor |
| 337 | 337 | */ |
| 338 | -function give_profile_editor_shortcode( $atts, $content = null ) { |
|
| 338 | +function give_profile_editor_shortcode($atts, $content = null) { |
|
| 339 | 339 | |
| 340 | 340 | ob_start(); |
| 341 | 341 | |
| 342 | - give_get_template_part( 'shortcode', 'profile-editor' ); |
|
| 342 | + give_get_template_part('shortcode', 'profile-editor'); |
|
| 343 | 343 | |
| 344 | 344 | $display = ob_get_clean(); |
| 345 | 345 | |
| 346 | 346 | return $display; |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | -add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' ); |
|
| 349 | +add_shortcode('give_profile_editor', 'give_profile_editor_shortcode'); |
|
| 350 | 350 | |
| 351 | 351 | /** |
| 352 | 352 | * Process Profile Updater Form. |
@@ -359,30 +359,30 @@ discard block |
||
| 359 | 359 | * |
| 360 | 360 | * @return bool |
| 361 | 361 | */ |
| 362 | -function give_process_profile_editor_updates( $data ) { |
|
| 362 | +function give_process_profile_editor_updates($data) { |
|
| 363 | 363 | // Profile field change request |
| 364 | - if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) { |
|
| 364 | + if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) { |
|
| 365 | 365 | return false; |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | // Nonce security |
| 369 | - if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) { |
|
| 369 | + if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) { |
|
| 370 | 370 | return false; |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | $user_id = get_current_user_id(); |
| 374 | - $old_user_data = get_userdata( $user_id ); |
|
| 375 | - |
|
| 376 | - $display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name; |
|
| 377 | - $first_name = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name; |
|
| 378 | - $last_name = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name; |
|
| 379 | - $email = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email; |
|
| 380 | - $line1 = ( isset( $data['give_address_line1'] ) ? sanitize_text_field( $data['give_address_line1'] ) : '' ); |
|
| 381 | - $line2 = ( isset( $data['give_address_line2'] ) ? sanitize_text_field( $data['give_address_line2'] ) : '' ); |
|
| 382 | - $city = ( isset( $data['give_address_city'] ) ? sanitize_text_field( $data['give_address_city'] ) : '' ); |
|
| 383 | - $state = ( isset( $data['give_address_state'] ) ? sanitize_text_field( $data['give_address_state'] ) : '' ); |
|
| 384 | - $zip = ( isset( $data['give_address_zip'] ) ? sanitize_text_field( $data['give_address_zip'] ) : '' ); |
|
| 385 | - $country = ( isset( $data['give_address_country'] ) ? sanitize_text_field( $data['give_address_country'] ) : '' ); |
|
| 374 | + $old_user_data = get_userdata($user_id); |
|
| 375 | + |
|
| 376 | + $display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name; |
|
| 377 | + $first_name = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name; |
|
| 378 | + $last_name = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name; |
|
| 379 | + $email = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email; |
|
| 380 | + $line1 = (isset($data['give_address_line1']) ? sanitize_text_field($data['give_address_line1']) : ''); |
|
| 381 | + $line2 = (isset($data['give_address_line2']) ? sanitize_text_field($data['give_address_line2']) : ''); |
|
| 382 | + $city = (isset($data['give_address_city']) ? sanitize_text_field($data['give_address_city']) : ''); |
|
| 383 | + $state = (isset($data['give_address_state']) ? sanitize_text_field($data['give_address_state']) : ''); |
|
| 384 | + $zip = (isset($data['give_address_zip']) ? sanitize_text_field($data['give_address_zip']) : ''); |
|
| 385 | + $country = (isset($data['give_address_country']) ? sanitize_text_field($data['give_address_country']) : ''); |
|
| 386 | 386 | |
| 387 | 387 | $userdata = array( |
| 388 | 388 | 'ID' => $user_id, |
@@ -410,46 +410,46 @@ discard block |
||
| 410 | 410 | * @param int $user_id The ID of the user. |
| 411 | 411 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
| 412 | 412 | */ |
| 413 | - do_action( 'give_pre_update_user_profile', $user_id, $userdata ); |
|
| 413 | + do_action('give_pre_update_user_profile', $user_id, $userdata); |
|
| 414 | 414 | |
| 415 | 415 | // New password |
| 416 | - if ( ! empty( $data['give_new_user_pass1'] ) ) { |
|
| 417 | - if ( $data['give_new_user_pass1'] !== $data['give_new_user_pass2'] ) { |
|
| 418 | - give_set_error( 'password_mismatch', esc_html__( 'The passwords you entered do not match. Please try again.', 'give' ) ); |
|
| 416 | + if ( ! empty($data['give_new_user_pass1'])) { |
|
| 417 | + if ($data['give_new_user_pass1'] !== $data['give_new_user_pass2']) { |
|
| 418 | + give_set_error('password_mismatch', esc_html__('The passwords you entered do not match. Please try again.', 'give')); |
|
| 419 | 419 | } else { |
| 420 | 420 | $userdata['user_pass'] = $data['give_new_user_pass1']; |
| 421 | 421 | } |
| 422 | 422 | } |
| 423 | 423 | |
| 424 | - if( empty( $email ) ) { |
|
| 424 | + if (empty($email)) { |
|
| 425 | 425 | // Make sure email should not be empty. |
| 426 | - give_set_error( 'email_empty', esc_html__( 'The email you entered is empty.', 'give' ) ); |
|
| 426 | + give_set_error('email_empty', esc_html__('The email you entered is empty.', 'give')); |
|
| 427 | 427 | |
| 428 | - }else if ( ! is_email( $email ) ){ |
|
| 428 | + } else if ( ! is_email($email)) { |
|
| 429 | 429 | // Make sure email should be valid. |
| 430 | - give_set_error( 'email_not_valid', esc_html__( 'The email you entered is not valid. Please use another', 'give' ) ); |
|
| 430 | + give_set_error('email_not_valid', esc_html__('The email you entered is not valid. Please use another', 'give')); |
|
| 431 | 431 | |
| 432 | - }else if ( $email != $old_user_data->user_email ) { |
|
| 432 | + } else if ($email != $old_user_data->user_email) { |
|
| 433 | 433 | // Make sure the new email doesn't belong to another user |
| 434 | - if ( email_exists( $email ) ) { |
|
| 435 | - give_set_error( 'email_exists', esc_html__( 'The email you entered belongs to another user. Please use another.', 'give' ) ); |
|
| 434 | + if (email_exists($email)) { |
|
| 435 | + give_set_error('email_exists', esc_html__('The email you entered belongs to another user. Please use another.', 'give')); |
|
| 436 | 436 | } |
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | // Check for errors |
| 440 | 440 | $errors = give_get_errors(); |
| 441 | 441 | |
| 442 | - if ( $errors ) { |
|
| 442 | + if ($errors) { |
|
| 443 | 443 | // Send back to the profile editor if there are errors |
| 444 | - wp_redirect( $data['give_redirect'] ); |
|
| 444 | + wp_redirect($data['give_redirect']); |
|
| 445 | 445 | give_die(); |
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | // Update the user |
| 449 | - $meta = update_user_meta( $user_id, '_give_user_address', $address ); |
|
| 450 | - $updated = wp_update_user( $userdata ); |
|
| 449 | + $meta = update_user_meta($user_id, '_give_user_address', $address); |
|
| 450 | + $updated = wp_update_user($userdata); |
|
| 451 | 451 | |
| 452 | - if ( $updated ) { |
|
| 452 | + if ($updated) { |
|
| 453 | 453 | |
| 454 | 454 | /** |
| 455 | 455 | * Fires after updating user profile. |
@@ -459,13 +459,13 @@ discard block |
||
| 459 | 459 | * @param int $user_id The ID of the user. |
| 460 | 460 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
| 461 | 461 | */ |
| 462 | - do_action( 'give_user_profile_updated', $user_id, $userdata ); |
|
| 463 | - wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) ); |
|
| 462 | + do_action('give_user_profile_updated', $user_id, $userdata); |
|
| 463 | + wp_redirect(add_query_arg('updated', 'true', $data['give_redirect'])); |
|
| 464 | 464 | give_die(); |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | return false; |
| 468 | 468 | } |
| 469 | 469 | |
| 470 | -add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' ); |
|
| 470 | +add_action('give_edit_user_profile', 'give_process_profile_editor_updates'); |
|
| 471 | 471 | |
@@ -425,11 +425,11 @@ |
||
| 425 | 425 | // Make sure email should not be empty. |
| 426 | 426 | give_set_error( 'email_empty', esc_html__( 'The email you entered is empty.', 'give' ) ); |
| 427 | 427 | |
| 428 | - }else if ( ! is_email( $email ) ){ |
|
| 428 | + } else if ( ! is_email( $email ) ){ |
|
| 429 | 429 | // Make sure email should be valid. |
| 430 | 430 | give_set_error( 'email_not_valid', esc_html__( 'The email you entered is not valid. Please use another', 'give' ) ); |
| 431 | 431 | |
| 432 | - }else if ( $email != $old_user_data->user_email ) { |
|
| 432 | + } else if ( $email != $old_user_data->user_email ) { |
|
| 433 | 433 | // Make sure the new email doesn't belong to another user |
| 434 | 434 | if ( email_exists( $email ) ) { |
| 435 | 435 | give_set_error( 'email_exists', esc_html__( 'The email you entered belongs to another user. Please use another.', 'give' ) ); |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -23,13 +23,13 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return bool true if has variable prices, false otherwise |
| 25 | 25 | */ |
| 26 | -function give_has_variable_prices( $form_id = 0 ) { |
|
| 26 | +function give_has_variable_prices($form_id = 0) { |
|
| 27 | 27 | |
| 28 | - if ( empty( $form_id ) ) { |
|
| 28 | + if (empty($form_id)) { |
|
| 29 | 29 | return false; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - $form = new Give_Donate_Form( $form_id ); |
|
| 32 | + $form = new Give_Donate_Form($form_id); |
|
| 33 | 33 | |
| 34 | 34 | return $form->has_variable_prices(); |
| 35 | 35 | } |
@@ -44,13 +44,13 @@ discard block |
||
| 44 | 44 | * |
| 45 | 45 | * @return array Variable prices |
| 46 | 46 | */ |
| 47 | -function give_get_variable_prices( $form_id = 0 ) { |
|
| 47 | +function give_get_variable_prices($form_id = 0) { |
|
| 48 | 48 | |
| 49 | - if ( empty( $form_id ) ) { |
|
| 49 | + if (empty($form_id)) { |
|
| 50 | 50 | return false; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - $form = new Give_Donate_Form( $form_id ); |
|
| 53 | + $form = new Give_Donate_Form($form_id); |
|
| 54 | 54 | |
| 55 | 55 | return $form->prices; |
| 56 | 56 | |
@@ -67,13 +67,13 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @return string $default_price |
| 69 | 69 | */ |
| 70 | -function give_get_default_multilevel_amount( $form_id ) { |
|
| 70 | +function give_get_default_multilevel_amount($form_id) { |
|
| 71 | 71 | $default_price = '1.00'; |
| 72 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
| 72 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
| 73 | 73 | |
| 74 | - foreach ( $prices as $price ) { |
|
| 74 | + foreach ($prices as $price) { |
|
| 75 | 75 | |
| 76 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
| 76 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
| 77 | 77 | $default_price = $price['_give_amount']; |
| 78 | 78 | } |
| 79 | 79 | |
@@ -94,15 +94,15 @@ discard block |
||
| 94 | 94 | * @return string $default_price |
| 95 | 95 | * @since 1.0 |
| 96 | 96 | */ |
| 97 | -function give_get_default_form_amount( $form_id ) { |
|
| 97 | +function give_get_default_form_amount($form_id) { |
|
| 98 | 98 | |
| 99 | - if ( give_has_variable_prices( $form_id ) ) { |
|
| 99 | + if (give_has_variable_prices($form_id)) { |
|
| 100 | 100 | |
| 101 | - $default_amount = give_get_default_multilevel_amount( $form_id ); |
|
| 101 | + $default_amount = give_get_default_multilevel_amount($form_id); |
|
| 102 | 102 | |
| 103 | 103 | } else { |
| 104 | 104 | |
| 105 | - $default_amount = get_post_meta( $form_id, '_give_set_price', true ); |
|
| 105 | + $default_amount = get_post_meta($form_id, '_give_set_price', true); |
|
| 106 | 106 | |
| 107 | 107 | } |
| 108 | 108 | |
@@ -123,13 +123,13 @@ discard block |
||
| 123 | 123 | * |
| 124 | 124 | * @return bool |
| 125 | 125 | */ |
| 126 | -function give_is_custom_price_mode( $form_id = 0 ) { |
|
| 126 | +function give_is_custom_price_mode($form_id = 0) { |
|
| 127 | 127 | |
| 128 | - if ( empty( $form_id ) ) { |
|
| 128 | + if (empty($form_id)) { |
|
| 129 | 129 | return false; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - $form = new Give_Donate_Form( $form_id ); |
|
| 132 | + $form = new Give_Donate_Form($form_id); |
|
| 133 | 133 | |
| 134 | 134 | return $form->is_custom_price_mode(); |
| 135 | 135 | } |
| 136 | 136 | \ No newline at end of file |
@@ -544,7 +544,7 @@ |
||
| 544 | 544 | |
| 545 | 545 | if( $payment_total_diff > 0 ) { |
| 546 | 546 | $this->increase_value( $payment_total_diff ); |
| 547 | - }else{ |
|
| 547 | + } else{ |
|
| 548 | 548 | // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
| 549 | 549 | $this->decrease_value( -$payment_total_diff ); |
| 550 | 550 | } |
@@ -565,12 +565,12 @@ discard block |
||
| 565 | 565 | |
| 566 | 566 | /** |
| 567 | 567 | * Decrease/Increase a customer's lifetime value. |
| 568 | - * |
|
| 569 | - * This function will update donation stat on basis of current amount and new amount donation difference. |
|
| 570 | - * Difference value can positive or negative. Negative value will decrease user donation stat while positive value increase donation stat. |
|
| 571 | - * |
|
| 568 | + * |
|
| 569 | + * This function will update donation stat on basis of current amount and new amount donation difference. |
|
| 570 | + * Difference value can positive or negative. Negative value will decrease user donation stat while positive value increase donation stat. |
|
| 571 | + * |
|
| 572 | 572 | * @since 1.0 |
| 573 | - * @access public |
|
| 573 | + * @access public |
|
| 574 | 574 | * |
| 575 | 575 | * @param float $curr_amount Current Donation amount. |
| 576 | 576 | * @param float $new_amount New (changed) Donation amount. |
@@ -578,35 +578,35 @@ discard block |
||
| 578 | 578 | * @return mixed If successful, the new donation stat value, otherwise false. |
| 579 | 579 | */ |
| 580 | 580 | public function update_donation_value( $curr_amount, $new_amount ) { |
| 581 | - /** |
|
| 582 | - * Payment total difference value can be: |
|
| 583 | - * zero (in case amount not change) |
|
| 584 | - * or -ve (in case amount decrease) |
|
| 585 | - * or +ve (in case amount increase) |
|
| 586 | - */ |
|
| 587 | - $payment_total_diff = $new_amount - $curr_amount; |
|
| 588 | - |
|
| 589 | - // We do not need to update donation stat if donation did not change. |
|
| 590 | - if( ! $payment_total_diff ) { |
|
| 591 | - return false; |
|
| 592 | - } |
|
| 593 | - |
|
| 594 | - |
|
| 595 | - if( $payment_total_diff > 0 ) { |
|
| 596 | - $this->increase_value( $payment_total_diff ); |
|
| 597 | - }else{ |
|
| 598 | - // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
|
| 599 | - $this->decrease_value( -$payment_total_diff ); |
|
| 600 | - } |
|
| 601 | - |
|
| 602 | - return $this->purchase_value; |
|
| 581 | + /** |
|
| 582 | + * Payment total difference value can be: |
|
| 583 | + * zero (in case amount not change) |
|
| 584 | + * or -ve (in case amount decrease) |
|
| 585 | + * or +ve (in case amount increase) |
|
| 586 | + */ |
|
| 587 | + $payment_total_diff = $new_amount - $curr_amount; |
|
| 588 | + |
|
| 589 | + // We do not need to update donation stat if donation did not change. |
|
| 590 | + if( ! $payment_total_diff ) { |
|
| 591 | + return false; |
|
| 592 | + } |
|
| 593 | + |
|
| 594 | + |
|
| 595 | + if( $payment_total_diff > 0 ) { |
|
| 596 | + $this->increase_value( $payment_total_diff ); |
|
| 597 | + }else{ |
|
| 598 | + // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
|
| 599 | + $this->decrease_value( -$payment_total_diff ); |
|
| 600 | + } |
|
| 601 | + |
|
| 602 | + return $this->purchase_value; |
|
| 603 | 603 | } |
| 604 | 604 | |
| 605 | 605 | /** |
| 606 | 606 | * Get the parsed notes for a customer as an array. |
| 607 | 607 | * |
| 608 | 608 | * @since 1.0 |
| 609 | - * @access public |
|
| 609 | + * @access public |
|
| 610 | 610 | * |
| 611 | 611 | * @param integer $length The number of notes to get. |
| 612 | 612 | * @param integer $paged What note to start at. |
@@ -631,7 +631,7 @@ discard block |
||
| 631 | 631 | * Get the total number of notes we have after parsing. |
| 632 | 632 | * |
| 633 | 633 | * @since 1.0 |
| 634 | - * @access public |
|
| 634 | + * @access public |
|
| 635 | 635 | * |
| 636 | 636 | * @return int The number of notes for the customer. |
| 637 | 637 | */ |
@@ -648,7 +648,7 @@ discard block |
||
| 648 | 648 | * Add a note for the customer. |
| 649 | 649 | * |
| 650 | 650 | * @since 1.0 |
| 651 | - * @access public |
|
| 651 | + * @access public |
|
| 652 | 652 | * |
| 653 | 653 | * @param string $note The note to add. Default is empty. |
| 654 | 654 | * |
@@ -690,7 +690,7 @@ discard block |
||
| 690 | 690 | * Get the notes column for the customer |
| 691 | 691 | * |
| 692 | 692 | * @since 1.0 |
| 693 | - * @access private |
|
| 693 | + * @access private |
|
| 694 | 694 | * |
| 695 | 695 | * @return string The Notes for the customer, non-parsed. |
| 696 | 696 | */ |
@@ -768,7 +768,7 @@ discard block |
||
| 768 | 768 | * Sanitize the data for update/create |
| 769 | 769 | * |
| 770 | 770 | * @since 1.0 |
| 771 | - * @access private |
|
| 771 | + * @access private |
|
| 772 | 772 | * |
| 773 | 773 | * @param array $data The data to sanitize. |
| 774 | 774 | * |
@@ -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 | |
@@ -134,29 +134,29 @@ discard block |
||
| 134 | 134 | * @param bool $_id_or_email |
| 135 | 135 | * @param bool $by_user_id |
| 136 | 136 | */ |
| 137 | - public function __construct( $_id_or_email = false, $by_user_id = false ) { |
|
| 137 | + public function __construct($_id_or_email = false, $by_user_id = false) { |
|
| 138 | 138 | |
| 139 | 139 | $this->db = new Give_DB_Customers; |
| 140 | 140 | |
| 141 | - if ( false === $_id_or_email || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) ) { |
|
| 141 | + if (false === $_id_or_email || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email))) { |
|
| 142 | 142 | return false; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - $by_user_id = is_bool( $by_user_id ) ? $by_user_id : false; |
|
| 145 | + $by_user_id = is_bool($by_user_id) ? $by_user_id : false; |
|
| 146 | 146 | |
| 147 | - if ( is_numeric( $_id_or_email ) ) { |
|
| 147 | + if (is_numeric($_id_or_email)) { |
|
| 148 | 148 | $field = $by_user_id ? 'user_id' : 'id'; |
| 149 | 149 | } else { |
| 150 | 150 | $field = 'email'; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - $customer = $this->db->get_customer_by( $field, $_id_or_email ); |
|
| 153 | + $customer = $this->db->get_customer_by($field, $_id_or_email); |
|
| 154 | 154 | |
| 155 | - if ( empty( $customer ) || ! is_object( $customer ) ) { |
|
| 155 | + if (empty($customer) || ! is_object($customer)) { |
|
| 156 | 156 | return false; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - $this->setup_customer( $customer ); |
|
| 159 | + $this->setup_customer($customer); |
|
| 160 | 160 | |
| 161 | 161 | } |
| 162 | 162 | |
@@ -172,15 +172,15 @@ discard block |
||
| 172 | 172 | * |
| 173 | 173 | * @return bool If the setup was successful or not. |
| 174 | 174 | */ |
| 175 | - private function setup_customer( $customer ) { |
|
| 175 | + private function setup_customer($customer) { |
|
| 176 | 176 | |
| 177 | - if ( ! is_object( $customer ) ) { |
|
| 177 | + if ( ! is_object($customer)) { |
|
| 178 | 178 | return false; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - foreach ( $customer as $key => $value ) { |
|
| 181 | + foreach ($customer as $key => $value) { |
|
| 182 | 182 | |
| 183 | - switch ( $key ) { |
|
| 183 | + switch ($key) { |
|
| 184 | 184 | |
| 185 | 185 | case 'notes': |
| 186 | 186 | $this->$key = $this->get_notes(); |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | // Customer ID and email are the only things that are necessary, make sure they exist |
| 198 | - if ( ! empty( $this->id ) && ! empty( $this->email ) ) { |
|
| 198 | + if ( ! empty($this->id) && ! empty($this->email)) { |
|
| 199 | 199 | return true; |
| 200 | 200 | } |
| 201 | 201 | |
@@ -209,16 +209,16 @@ discard block |
||
| 209 | 209 | * @since 1.0 |
| 210 | 210 | * @access public |
| 211 | 211 | */ |
| 212 | - public function __get( $key ) { |
|
| 212 | + public function __get($key) { |
|
| 213 | 213 | |
| 214 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
| 214 | + if (method_exists($this, 'get_'.$key)) { |
|
| 215 | 215 | |
| 216 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
| 216 | + return call_user_func(array($this, 'get_'.$key)); |
|
| 217 | 217 | |
| 218 | 218 | } else { |
| 219 | 219 | |
| 220 | 220 | /* translators: %s: property key */ |
| 221 | - return new WP_Error( 'give-customer-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); |
|
| 221 | + return new WP_Error('give-customer-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key)); |
|
| 222 | 222 | |
| 223 | 223 | } |
| 224 | 224 | |
@@ -234,9 +234,9 @@ discard block |
||
| 234 | 234 | * |
| 235 | 235 | * @return mixed False if not a valid creation, Customer ID if user is found or valid creation. |
| 236 | 236 | */ |
| 237 | - public function create( $data = array() ) { |
|
| 237 | + public function create($data = array()) { |
|
| 238 | 238 | |
| 239 | - if ( $this->id != 0 || empty( $data ) ) { |
|
| 239 | + if ($this->id != 0 || empty($data)) { |
|
| 240 | 240 | return false; |
| 241 | 241 | } |
| 242 | 242 | |
@@ -244,34 +244,34 @@ discard block |
||
| 244 | 244 | 'payment_ids' => '' |
| 245 | 245 | ); |
| 246 | 246 | |
| 247 | - $args = wp_parse_args( $data, $defaults ); |
|
| 248 | - $args = $this->sanitize_columns( $args ); |
|
| 247 | + $args = wp_parse_args($data, $defaults); |
|
| 248 | + $args = $this->sanitize_columns($args); |
|
| 249 | 249 | |
| 250 | - if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) { |
|
| 250 | + if (empty($args['email']) || ! is_email($args['email'])) { |
|
| 251 | 251 | return false; |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
| 255 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
| 254 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
| 255 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - do_action( 'give_customer_pre_create', $args ); |
|
| 258 | + do_action('give_customer_pre_create', $args); |
|
| 259 | 259 | |
| 260 | 260 | $created = false; |
| 261 | 261 | |
| 262 | 262 | // The DB class 'add' implies an update if the customer being asked to be created already exists |
| 263 | - if ( $this->db->add( $data ) ) { |
|
| 263 | + if ($this->db->add($data)) { |
|
| 264 | 264 | |
| 265 | 265 | // We've successfully added/updated the customer, reset the class vars with the new data |
| 266 | - $customer = $this->db->get_customer_by( 'email', $args['email'] ); |
|
| 266 | + $customer = $this->db->get_customer_by('email', $args['email']); |
|
| 267 | 267 | |
| 268 | 268 | // Setup the customer data with the values from DB |
| 269 | - $this->setup_customer( $customer ); |
|
| 269 | + $this->setup_customer($customer); |
|
| 270 | 270 | |
| 271 | 271 | $created = $this->id; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - do_action( 'give_customer_post_create', $created, $args ); |
|
| 274 | + do_action('give_customer_post_create', $created, $args); |
|
| 275 | 275 | |
| 276 | 276 | return $created; |
| 277 | 277 | |
@@ -287,27 +287,27 @@ discard block |
||
| 287 | 287 | * |
| 288 | 288 | * @return bool If the update was successful or not. |
| 289 | 289 | */ |
| 290 | - public function update( $data = array() ) { |
|
| 290 | + public function update($data = array()) { |
|
| 291 | 291 | |
| 292 | - if ( empty( $data ) ) { |
|
| 292 | + if (empty($data)) { |
|
| 293 | 293 | return false; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - $data = $this->sanitize_columns( $data ); |
|
| 296 | + $data = $this->sanitize_columns($data); |
|
| 297 | 297 | |
| 298 | - do_action( 'give_customer_pre_update', $this->id, $data ); |
|
| 298 | + do_action('give_customer_pre_update', $this->id, $data); |
|
| 299 | 299 | |
| 300 | 300 | $updated = false; |
| 301 | 301 | |
| 302 | - if ( $this->db->update( $this->id, $data ) ) { |
|
| 302 | + if ($this->db->update($this->id, $data)) { |
|
| 303 | 303 | |
| 304 | - $customer = $this->db->get_customer_by( 'id', $this->id ); |
|
| 305 | - $this->setup_customer( $customer ); |
|
| 304 | + $customer = $this->db->get_customer_by('id', $this->id); |
|
| 305 | + $this->setup_customer($customer); |
|
| 306 | 306 | |
| 307 | 307 | $updated = true; |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - do_action( 'give_customer_post_update', $updated, $this->id, $data ); |
|
| 310 | + do_action('give_customer_post_update', $updated, $this->id, $data); |
|
| 311 | 311 | |
| 312 | 312 | return $updated; |
| 313 | 313 | } |
@@ -325,44 +325,44 @@ discard block |
||
| 325 | 325 | * |
| 326 | 326 | * @return bool If the attachment was successfuly. |
| 327 | 327 | */ |
| 328 | - public function attach_payment( $payment_id = 0, $update_stats = true ) { |
|
| 328 | + public function attach_payment($payment_id = 0, $update_stats = true) { |
|
| 329 | 329 | |
| 330 | - if ( empty( $payment_id ) ) { |
|
| 330 | + if (empty($payment_id)) { |
|
| 331 | 331 | return false; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | - if ( empty( $this->payment_ids ) ) { |
|
| 334 | + if (empty($this->payment_ids)) { |
|
| 335 | 335 | |
| 336 | 336 | $new_payment_ids = $payment_id; |
| 337 | 337 | |
| 338 | 338 | } else { |
| 339 | 339 | |
| 340 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
| 340 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
| 341 | 341 | |
| 342 | - if ( in_array( $payment_id, $payment_ids ) ) { |
|
| 342 | + if (in_array($payment_id, $payment_ids)) { |
|
| 343 | 343 | $update_stats = false; |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | $payment_ids[] = $payment_id; |
| 347 | 347 | |
| 348 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
| 348 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
| 349 | 349 | |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - do_action( 'give_customer_pre_attach_payment', $payment_id, $this->id ); |
|
| 352 | + do_action('give_customer_pre_attach_payment', $payment_id, $this->id); |
|
| 353 | 353 | |
| 354 | - $payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
| 354 | + $payment_added = $this->update(array('payment_ids' => $new_payment_ids)); |
|
| 355 | 355 | |
| 356 | - if ( $payment_added ) { |
|
| 356 | + if ($payment_added) { |
|
| 357 | 357 | |
| 358 | 358 | $this->payment_ids = $new_payment_ids; |
| 359 | 359 | |
| 360 | 360 | // We added this payment successfully, increment the stats |
| 361 | - if ( $update_stats ) { |
|
| 362 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
| 361 | + if ($update_stats) { |
|
| 362 | + $payment_amount = give_get_payment_amount($payment_id); |
|
| 363 | 363 | |
| 364 | - if ( ! empty( $payment_amount ) ) { |
|
| 365 | - $this->increase_value( $payment_amount ); |
|
| 364 | + if ( ! empty($payment_amount)) { |
|
| 365 | + $this->increase_value($payment_amount); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | $this->increase_purchase_count(); |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - do_action( 'give_customer_post_attach_payment', $payment_added, $payment_id, $this->id ); |
|
| 373 | + do_action('give_customer_post_attach_payment', $payment_added, $payment_id, $this->id); |
|
| 374 | 374 | |
| 375 | 375 | return $payment_added; |
| 376 | 376 | } |
@@ -388,50 +388,50 @@ discard block |
||
| 388 | 388 | * |
| 389 | 389 | * @return boolean If the removal was successful. |
| 390 | 390 | */ |
| 391 | - public function remove_payment( $payment_id = 0, $update_stats = true ) { |
|
| 391 | + public function remove_payment($payment_id = 0, $update_stats = true) { |
|
| 392 | 392 | |
| 393 | - if ( empty( $payment_id ) ) { |
|
| 393 | + if (empty($payment_id)) { |
|
| 394 | 394 | return false; |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - $payment = new Give_Payment( $payment_id ); |
|
| 397 | + $payment = new Give_Payment($payment_id); |
|
| 398 | 398 | |
| 399 | - if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) { |
|
| 399 | + if ('publish' !== $payment->status && 'revoked' !== $payment->status) { |
|
| 400 | 400 | $update_stats = false; |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | $new_payment_ids = ''; |
| 404 | 404 | |
| 405 | - if ( ! empty( $this->payment_ids ) ) { |
|
| 405 | + if ( ! empty($this->payment_ids)) { |
|
| 406 | 406 | |
| 407 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
| 407 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
| 408 | 408 | |
| 409 | - $pos = array_search( $payment_id, $payment_ids ); |
|
| 410 | - if ( false === $pos ) { |
|
| 409 | + $pos = array_search($payment_id, $payment_ids); |
|
| 410 | + if (false === $pos) { |
|
| 411 | 411 | return false; |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | - unset( $payment_ids[ $pos ] ); |
|
| 415 | - $payment_ids = array_filter( $payment_ids ); |
|
| 414 | + unset($payment_ids[$pos]); |
|
| 415 | + $payment_ids = array_filter($payment_ids); |
|
| 416 | 416 | |
| 417 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
| 417 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
| 418 | 418 | |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | - do_action( 'give_customer_pre_remove_payment', $payment_id, $this->id ); |
|
| 421 | + do_action('give_customer_pre_remove_payment', $payment_id, $this->id); |
|
| 422 | 422 | |
| 423 | - $payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
| 423 | + $payment_removed = $this->update(array('payment_ids' => $new_payment_ids)); |
|
| 424 | 424 | |
| 425 | - if ( $payment_removed ) { |
|
| 425 | + if ($payment_removed) { |
|
| 426 | 426 | |
| 427 | 427 | $this->payment_ids = $new_payment_ids; |
| 428 | 428 | |
| 429 | - if ( $update_stats ) { |
|
| 429 | + if ($update_stats) { |
|
| 430 | 430 | // We removed this payment successfully, decrement the stats |
| 431 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
| 431 | + $payment_amount = give_get_payment_amount($payment_id); |
|
| 432 | 432 | |
| 433 | - if ( ! empty( $payment_amount ) ) { |
|
| 434 | - $this->decrease_value( $payment_amount ); |
|
| 433 | + if ( ! empty($payment_amount)) { |
|
| 434 | + $this->decrease_value($payment_amount); |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | $this->decrease_purchase_count(); |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | - do_action( 'give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id ); |
|
| 442 | + do_action('give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id); |
|
| 443 | 443 | |
| 444 | 444 | return $payment_removed; |
| 445 | 445 | |
@@ -455,22 +455,22 @@ discard block |
||
| 455 | 455 | * |
| 456 | 456 | * @return int The purchase count. |
| 457 | 457 | */ |
| 458 | - public function increase_purchase_count( $count = 1 ) { |
|
| 458 | + public function increase_purchase_count($count = 1) { |
|
| 459 | 459 | |
| 460 | 460 | // Make sure it's numeric and not negative. |
| 461 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
| 461 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
| 462 | 462 | return false; |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | $new_total = (int) $this->purchase_count + (int) $count; |
| 466 | 466 | |
| 467 | - do_action( 'give_customer_pre_increase_purchase_count', $count, $this->id ); |
|
| 467 | + do_action('give_customer_pre_increase_purchase_count', $count, $this->id); |
|
| 468 | 468 | |
| 469 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
| 469 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
| 470 | 470 | $this->purchase_count = $new_total; |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | - do_action( 'give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id ); |
|
| 473 | + do_action('give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id); |
|
| 474 | 474 | |
| 475 | 475 | return $this->purchase_count; |
| 476 | 476 | } |
@@ -485,26 +485,26 @@ discard block |
||
| 485 | 485 | * |
| 486 | 486 | * @return mixed If successful, the new count, otherwise false. |
| 487 | 487 | */ |
| 488 | - public function decrease_purchase_count( $count = 1 ) { |
|
| 488 | + public function decrease_purchase_count($count = 1) { |
|
| 489 | 489 | |
| 490 | 490 | // Make sure it's numeric and not negative |
| 491 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
| 491 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
| 492 | 492 | return false; |
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | $new_total = (int) $this->purchase_count - (int) $count; |
| 496 | 496 | |
| 497 | - if ( $new_total < 0 ) { |
|
| 497 | + if ($new_total < 0) { |
|
| 498 | 498 | $new_total = 0; |
| 499 | 499 | } |
| 500 | 500 | |
| 501 | - do_action( 'give_customer_pre_decrease_purchase_count', $count, $this->id ); |
|
| 501 | + do_action('give_customer_pre_decrease_purchase_count', $count, $this->id); |
|
| 502 | 502 | |
| 503 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
| 503 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
| 504 | 504 | $this->purchase_count = $new_total; |
| 505 | 505 | } |
| 506 | 506 | |
| 507 | - do_action( 'give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id ); |
|
| 507 | + do_action('give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id); |
|
| 508 | 508 | |
| 509 | 509 | return $this->purchase_count; |
| 510 | 510 | } |
@@ -519,17 +519,17 @@ discard block |
||
| 519 | 519 | * |
| 520 | 520 | * @return mixed If successful, the new value, otherwise false. |
| 521 | 521 | */ |
| 522 | - public function increase_value( $value = 0.00 ) { |
|
| 522 | + public function increase_value($value = 0.00) { |
|
| 523 | 523 | |
| 524 | - $new_value = floatval( $this->purchase_value ) + $value; |
|
| 524 | + $new_value = floatval($this->purchase_value) + $value; |
|
| 525 | 525 | |
| 526 | - do_action( 'give_customer_pre_increase_value', $value, $this->id ); |
|
| 526 | + do_action('give_customer_pre_increase_value', $value, $this->id); |
|
| 527 | 527 | |
| 528 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
| 528 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
| 529 | 529 | $this->purchase_value = $new_value; |
| 530 | 530 | } |
| 531 | 531 | |
| 532 | - do_action( 'give_customer_post_increase_value', $this->purchase_value, $value, $this->id ); |
|
| 532 | + do_action('give_customer_post_increase_value', $this->purchase_value, $value, $this->id); |
|
| 533 | 533 | |
| 534 | 534 | return $this->purchase_value; |
| 535 | 535 | } |
@@ -544,21 +544,21 @@ discard block |
||
| 544 | 544 | * |
| 545 | 545 | * @return mixed If successful, the new value, otherwise false. |
| 546 | 546 | */ |
| 547 | - public function decrease_value( $value = 0.00 ) { |
|
| 547 | + public function decrease_value($value = 0.00) { |
|
| 548 | 548 | |
| 549 | - $new_value = floatval( $this->purchase_value ) - $value; |
|
| 549 | + $new_value = floatval($this->purchase_value) - $value; |
|
| 550 | 550 | |
| 551 | - if ( $new_value < 0 ) { |
|
| 551 | + if ($new_value < 0) { |
|
| 552 | 552 | $new_value = 0.00; |
| 553 | 553 | } |
| 554 | 554 | |
| 555 | - do_action( 'give_customer_pre_decrease_value', $value, $this->id ); |
|
| 555 | + do_action('give_customer_pre_decrease_value', $value, $this->id); |
|
| 556 | 556 | |
| 557 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
| 557 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
| 558 | 558 | $this->purchase_value = $new_value; |
| 559 | 559 | } |
| 560 | 560 | |
| 561 | - do_action( 'give_customer_post_decrease_value', $this->purchase_value, $value, $this->id ); |
|
| 561 | + do_action('give_customer_post_decrease_value', $this->purchase_value, $value, $this->id); |
|
| 562 | 562 | |
| 563 | 563 | return $this->purchase_value; |
| 564 | 564 | } |
@@ -577,7 +577,7 @@ discard block |
||
| 577 | 577 | * |
| 578 | 578 | * @return mixed If successful, the new donation stat value, otherwise false. |
| 579 | 579 | */ |
| 580 | - public function update_donation_value( $curr_amount, $new_amount ) { |
|
| 580 | + public function update_donation_value($curr_amount, $new_amount) { |
|
| 581 | 581 | /** |
| 582 | 582 | * Payment total difference value can be: |
| 583 | 583 | * zero (in case amount not change) |
@@ -587,14 +587,14 @@ discard block |
||
| 587 | 587 | $payment_total_diff = $new_amount - $curr_amount; |
| 588 | 588 | |
| 589 | 589 | // We do not need to update donation stat if donation did not change. |
| 590 | - if( ! $payment_total_diff ) { |
|
| 590 | + if ( ! $payment_total_diff) { |
|
| 591 | 591 | return false; |
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | |
| 595 | - if( $payment_total_diff > 0 ) { |
|
| 596 | - $this->increase_value( $payment_total_diff ); |
|
| 597 | - }else{ |
|
| 595 | + if ($payment_total_diff > 0) { |
|
| 596 | + $this->increase_value($payment_total_diff); |
|
| 597 | + } else { |
|
| 598 | 598 | // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
| 599 | 599 | $this->decrease_value( -$payment_total_diff ); |
| 600 | 600 | } |
@@ -613,15 +613,15 @@ discard block |
||
| 613 | 613 | * |
| 614 | 614 | * @return array The notes requested. |
| 615 | 615 | */ |
| 616 | - public function get_notes( $length = 20, $paged = 1 ) { |
|
| 616 | + public function get_notes($length = 20, $paged = 1) { |
|
| 617 | 617 | |
| 618 | - $length = is_numeric( $length ) ? $length : 20; |
|
| 619 | - $offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0; |
|
| 618 | + $length = is_numeric($length) ? $length : 20; |
|
| 619 | + $offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0; |
|
| 620 | 620 | |
| 621 | 621 | $all_notes = $this->get_raw_notes(); |
| 622 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
| 622 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
| 623 | 623 | |
| 624 | - $desired_notes = array_slice( $notes_array, $offset, $length ); |
|
| 624 | + $desired_notes = array_slice($notes_array, $offset, $length); |
|
| 625 | 625 | |
| 626 | 626 | return $desired_notes; |
| 627 | 627 | |
@@ -638,9 +638,9 @@ discard block |
||
| 638 | 638 | public function get_notes_count() { |
| 639 | 639 | |
| 640 | 640 | $all_notes = $this->get_raw_notes(); |
| 641 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
| 641 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
| 642 | 642 | |
| 643 | - return count( $notes_array ); |
|
| 643 | + return count($notes_array); |
|
| 644 | 644 | |
| 645 | 645 | } |
| 646 | 646 | |
@@ -654,32 +654,32 @@ discard block |
||
| 654 | 654 | * |
| 655 | 655 | * @return string|boolean The new note if added successfully, false otherwise. |
| 656 | 656 | */ |
| 657 | - public function add_note( $note = '' ) { |
|
| 657 | + public function add_note($note = '') { |
|
| 658 | 658 | |
| 659 | - $note = trim( $note ); |
|
| 660 | - if ( empty( $note ) ) { |
|
| 659 | + $note = trim($note); |
|
| 660 | + if (empty($note)) { |
|
| 661 | 661 | return false; |
| 662 | 662 | } |
| 663 | 663 | |
| 664 | 664 | $notes = $this->get_raw_notes(); |
| 665 | 665 | |
| 666 | - if ( empty( $notes ) ) { |
|
| 666 | + if (empty($notes)) { |
|
| 667 | 667 | $notes = ''; |
| 668 | 668 | } |
| 669 | 669 | |
| 670 | - $note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note; |
|
| 671 | - $new_note = apply_filters( 'give_customer_add_note_string', $note_string ); |
|
| 672 | - $notes .= "\n\n" . $new_note; |
|
| 670 | + $note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note; |
|
| 671 | + $new_note = apply_filters('give_customer_add_note_string', $note_string); |
|
| 672 | + $notes .= "\n\n".$new_note; |
|
| 673 | 673 | |
| 674 | - do_action( 'give_customer_pre_add_note', $new_note, $this->id ); |
|
| 674 | + do_action('give_customer_pre_add_note', $new_note, $this->id); |
|
| 675 | 675 | |
| 676 | - $updated = $this->update( array( 'notes' => $notes ) ); |
|
| 676 | + $updated = $this->update(array('notes' => $notes)); |
|
| 677 | 677 | |
| 678 | - if ( $updated ) { |
|
| 678 | + if ($updated) { |
|
| 679 | 679 | $this->notes = $this->get_notes(); |
| 680 | 680 | } |
| 681 | 681 | |
| 682 | - do_action( 'give_customer_post_add_note', $this->notes, $new_note, $this->id ); |
|
| 682 | + do_action('give_customer_post_add_note', $this->notes, $new_note, $this->id); |
|
| 683 | 683 | |
| 684 | 684 | // Return the formatted note, so we can test, as well as update any displays |
| 685 | 685 | return $new_note; |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | */ |
| 697 | 697 | private function get_raw_notes() { |
| 698 | 698 | |
| 699 | - $all_notes = $this->db->get_column( 'notes', $this->id ); |
|
| 699 | + $all_notes = $this->db->get_column('notes', $this->id); |
|
| 700 | 700 | |
| 701 | 701 | return $all_notes; |
| 702 | 702 | |
@@ -713,8 +713,8 @@ discard block |
||
| 713 | 713 | * |
| 714 | 714 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true. |
| 715 | 715 | */ |
| 716 | - public function get_meta( $meta_key = '', $single = true ) { |
|
| 717 | - return Give()->customer_meta->get_meta( $this->id, $meta_key, $single ); |
|
| 716 | + public function get_meta($meta_key = '', $single = true) { |
|
| 717 | + return Give()->customer_meta->get_meta($this->id, $meta_key, $single); |
|
| 718 | 718 | } |
| 719 | 719 | |
| 720 | 720 | /** |
@@ -729,8 +729,8 @@ discard block |
||
| 729 | 729 | * |
| 730 | 730 | * @return bool False for failure. True for success. |
| 731 | 731 | */ |
| 732 | - public function add_meta( $meta_key = '', $meta_value, $unique = false ) { |
|
| 733 | - return Give()->customer_meta->add_meta( $this->id, $meta_key, $meta_value, $unique ); |
|
| 732 | + public function add_meta($meta_key = '', $meta_value, $unique = false) { |
|
| 733 | + return Give()->customer_meta->add_meta($this->id, $meta_key, $meta_value, $unique); |
|
| 734 | 734 | } |
| 735 | 735 | |
| 736 | 736 | /** |
@@ -745,8 +745,8 @@ discard block |
||
| 745 | 745 | * |
| 746 | 746 | * @return bool False on failure, true if success. |
| 747 | 747 | */ |
| 748 | - public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) { |
|
| 749 | - return Give()->customer_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value ); |
|
| 748 | + public function update_meta($meta_key = '', $meta_value, $prev_value = '') { |
|
| 749 | + return Give()->customer_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value); |
|
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | /** |
@@ -760,8 +760,8 @@ discard block |
||
| 760 | 760 | * |
| 761 | 761 | * @return bool False for failure. True for success. |
| 762 | 762 | */ |
| 763 | - public function delete_meta( $meta_key = '', $meta_value = '' ) { |
|
| 764 | - return Give()->customer_meta->delete_meta( $this->id, $meta_key, $meta_value ); |
|
| 763 | + public function delete_meta($meta_key = '', $meta_value = '') { |
|
| 764 | + return Give()->customer_meta->delete_meta($this->id, $meta_key, $meta_value); |
|
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | /** |
@@ -774,51 +774,51 @@ discard block |
||
| 774 | 774 | * |
| 775 | 775 | * @return array The sanitized data, based off column defaults. |
| 776 | 776 | */ |
| 777 | - private function sanitize_columns( $data ) { |
|
| 777 | + private function sanitize_columns($data) { |
|
| 778 | 778 | |
| 779 | 779 | $columns = $this->db->get_columns(); |
| 780 | 780 | $default_values = $this->db->get_column_defaults(); |
| 781 | 781 | |
| 782 | - foreach ( $columns as $key => $type ) { |
|
| 782 | + foreach ($columns as $key => $type) { |
|
| 783 | 783 | |
| 784 | 784 | // Only sanitize data that we were provided |
| 785 | - if ( ! array_key_exists( $key, $data ) ) { |
|
| 785 | + if ( ! array_key_exists($key, $data)) { |
|
| 786 | 786 | continue; |
| 787 | 787 | } |
| 788 | 788 | |
| 789 | - switch ( $type ) { |
|
| 789 | + switch ($type) { |
|
| 790 | 790 | |
| 791 | 791 | case '%s': |
| 792 | - if ( 'email' == $key ) { |
|
| 793 | - $data[ $key ] = sanitize_email( $data[ $key ] ); |
|
| 794 | - } elseif ( 'notes' == $key ) { |
|
| 795 | - $data[ $key ] = strip_tags( $data[ $key ] ); |
|
| 792 | + if ('email' == $key) { |
|
| 793 | + $data[$key] = sanitize_email($data[$key]); |
|
| 794 | + } elseif ('notes' == $key) { |
|
| 795 | + $data[$key] = strip_tags($data[$key]); |
|
| 796 | 796 | } else { |
| 797 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
| 797 | + $data[$key] = sanitize_text_field($data[$key]); |
|
| 798 | 798 | } |
| 799 | 799 | break; |
| 800 | 800 | |
| 801 | 801 | case '%d': |
| 802 | - if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) { |
|
| 803 | - $data[ $key ] = $default_values[ $key ]; |
|
| 802 | + if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) { |
|
| 803 | + $data[$key] = $default_values[$key]; |
|
| 804 | 804 | } else { |
| 805 | - $data[ $key ] = absint( $data[ $key ] ); |
|
| 805 | + $data[$key] = absint($data[$key]); |
|
| 806 | 806 | } |
| 807 | 807 | break; |
| 808 | 808 | |
| 809 | 809 | case '%f': |
| 810 | 810 | // Convert what was given to a float |
| 811 | - $value = floatval( $data[ $key ] ); |
|
| 811 | + $value = floatval($data[$key]); |
|
| 812 | 812 | |
| 813 | - if ( ! is_float( $value ) ) { |
|
| 814 | - $data[ $key ] = $default_values[ $key ]; |
|
| 813 | + if ( ! is_float($value)) { |
|
| 814 | + $data[$key] = $default_values[$key]; |
|
| 815 | 815 | } else { |
| 816 | - $data[ $key ] = $value; |
|
| 816 | + $data[$key] = $value; |
|
| 817 | 817 | } |
| 818 | 818 | break; |
| 819 | 819 | |
| 820 | 820 | default: |
| 821 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
| 821 | + $data[$key] = sanitize_text_field($data[$key]); |
|
| 822 | 822 | break; |
| 823 | 823 | |
| 824 | 824 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | public $error = ''; |
| 24 | 24 | |
| 25 | 25 | private $verify_throttle; |
| 26 | - private $token_expiration; |
|
| 26 | + private $token_expiration; |
|
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * Give_Email_Access constructor. |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | * @return bool |
| 244 | 244 | */ |
| 245 | 245 | function is_valid_verify_key( $token ) { |
| 246 | - /* @var WPDB $wpdb */ |
|
| 246 | + /* @var WPDB $wpdb */ |
|
| 247 | 247 | global $wpdb; |
| 248 | 248 | |
| 249 | 249 | // See if the verify_key exists |
@@ -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,7 +98,7 @@ discard block |
||
| 98 | 98 | public function __construct() { |
| 99 | 99 | |
| 100 | 100 | // get it started |
| 101 | - add_action( 'init', array( $this, 'init' ) ); |
|
| 101 | + add_action('init', array($this, 'init')); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
@@ -113,30 +113,30 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function init() { |
| 115 | 115 | |
| 116 | - $is_enabled = give_get_option( 'email_access' ); |
|
| 116 | + $is_enabled = give_get_option('email_access'); |
|
| 117 | 117 | |
| 118 | 118 | //Non-logged in users only |
| 119 | - if ( is_user_logged_in() || $is_enabled !== 'on' || is_admin() ) { |
|
| 119 | + if (is_user_logged_in() || $is_enabled !== 'on' || is_admin()) { |
|
| 120 | 120 | return; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | //Are db columns setup? |
| 124 | - $is_setup = give_get_option( 'email_access_installed' ); |
|
| 125 | - if ( empty( $is_setup ) ) { |
|
| 124 | + $is_setup = give_get_option('email_access_installed'); |
|
| 125 | + if (empty($is_setup)) { |
|
| 126 | 126 | $this->create_columns(); |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | // Timeouts |
| 130 | - $this->verify_throttle = apply_filters( 'give_nl_verify_throttle', 300 ); |
|
| 131 | - $this->token_expiration = apply_filters( 'give_nl_token_expiration', 7200 ); |
|
| 130 | + $this->verify_throttle = apply_filters('give_nl_verify_throttle', 300); |
|
| 131 | + $this->token_expiration = apply_filters('give_nl_token_expiration', 7200); |
|
| 132 | 132 | |
| 133 | 133 | // Setup login |
| 134 | 134 | $this->check_for_token(); |
| 135 | 135 | |
| 136 | - if ( $this->token_exists ) { |
|
| 137 | - add_filter( 'give_can_view_receipt', '__return_true' ); |
|
| 138 | - add_filter( 'give_user_pending_verification', '__return_false' ); |
|
| 139 | - add_filter( 'give_get_users_purchases_args', array( $this, 'users_purchases_args' ) ); |
|
| 136 | + if ($this->token_exists) { |
|
| 137 | + add_filter('give_can_view_receipt', '__return_true'); |
|
| 138 | + add_filter('give_user_pending_verification', '__return_false'); |
|
| 139 | + add_filter('give_get_users_purchases_args', array($this, 'users_purchases_args')); |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
@@ -150,25 +150,25 @@ discard block |
||
| 150 | 150 | * |
| 151 | 151 | * @return bool |
| 152 | 152 | */ |
| 153 | - public function can_send_email( $customer_id ) { |
|
| 153 | + public function can_send_email($customer_id) { |
|
| 154 | 154 | /* @var WPDB $wpdb */ |
| 155 | 155 | global $wpdb; |
| 156 | 156 | |
| 157 | 157 | // Prevent multiple emails within X minutes |
| 158 | - $throttle = date( 'Y-m-d H:i:s', time() - $this->verify_throttle ); |
|
| 158 | + $throttle = date('Y-m-d H:i:s', time() - $this->verify_throttle); |
|
| 159 | 159 | |
| 160 | 160 | // Does a user row exist? |
| 161 | 161 | $exists = (int) $wpdb->get_var( |
| 162 | - $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id ) |
|
| 162 | + $wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id) |
|
| 163 | 163 | ); |
| 164 | 164 | |
| 165 | - if ( 0 < $exists ) { |
|
| 165 | + if (0 < $exists) { |
|
| 166 | 166 | $row_id = (int) $wpdb->get_var( |
| 167 | - $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle ) |
|
| 167 | + $wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle) |
|
| 168 | 168 | ); |
| 169 | 169 | |
| 170 | - if ( $row_id < 1 ) { |
|
| 171 | - give_set_error( 'give_email_access_attempts_exhausted', esc_html__( 'Please wait a few minutes before requesting a new email access link.', 'give' ) ); |
|
| 170 | + if ($row_id < 1) { |
|
| 171 | + give_set_error('give_email_access_attempts_exhausted', esc_html__('Please wait a few minutes before requesting a new email access link.', 'give')); |
|
| 172 | 172 | |
| 173 | 173 | return false; |
| 174 | 174 | } |
@@ -188,34 +188,34 @@ discard block |
||
| 188 | 188 | * |
| 189 | 189 | * @return void |
| 190 | 190 | */ |
| 191 | - public function send_email( $customer_id, $email ) { |
|
| 191 | + public function send_email($customer_id, $email) { |
|
| 192 | 192 | |
| 193 | - $verify_key = wp_generate_password( 20, false ); |
|
| 193 | + $verify_key = wp_generate_password(20, false); |
|
| 194 | 194 | |
| 195 | 195 | // Generate a new verify key |
| 196 | - $this->set_verify_key( $customer_id, $email, $verify_key ); |
|
| 196 | + $this->set_verify_key($customer_id, $email, $verify_key); |
|
| 197 | 197 | |
| 198 | 198 | // Get the purchase history URL |
| 199 | - $page_id = give_get_option( 'history_page' ); |
|
| 199 | + $page_id = give_get_option('history_page'); |
|
| 200 | 200 | |
| 201 | - $access_url = add_query_arg( array( |
|
| 201 | + $access_url = add_query_arg(array( |
|
| 202 | 202 | 'give_nl' => $verify_key, |
| 203 | - ), get_permalink( $page_id ) ); |
|
| 203 | + ), get_permalink($page_id)); |
|
| 204 | 204 | |
| 205 | 205 | //Nice subject and message |
| 206 | - $subject = apply_filters( 'give_email_access_token_subject', sprintf( esc_html__( 'Your Access Link to %s', 'give' ), get_bloginfo( 'name' ) ) ); |
|
| 206 | + $subject = apply_filters('give_email_access_token_subject', sprintf(esc_html__('Your Access Link to %s', 'give'), get_bloginfo('name'))); |
|
| 207 | 207 | |
| 208 | - $message = esc_html__( 'You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give' ) . "\n\n"; |
|
| 209 | - $message .= '<a href="' . esc_url( $access_url ) . '" target="_blank">' . esc_html__( 'Access My Donation Details »', 'give' ) . '</a>' . "\n\n"; |
|
| 208 | + $message = esc_html__('You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give')."\n\n"; |
|
| 209 | + $message .= '<a href="'.esc_url($access_url).'" target="_blank">'.esc_html__('Access My Donation Details »', 'give').'</a>'."\n\n"; |
|
| 210 | 210 | $message .= "\n\n"; |
| 211 | - $message .= esc_html__( 'Sincerely,', 'give' ) . "\n"; |
|
| 212 | - $message .= get_bloginfo( 'name' ) . "\n"; |
|
| 211 | + $message .= esc_html__('Sincerely,', 'give')."\n"; |
|
| 212 | + $message .= get_bloginfo('name')."\n"; |
|
| 213 | 213 | |
| 214 | - $message = apply_filters( 'give_email_access_token_message', $message ); |
|
| 214 | + $message = apply_filters('give_email_access_token_message', $message); |
|
| 215 | 215 | |
| 216 | 216 | // Send the email |
| 217 | - Give()->emails->__set( 'heading', apply_filters( 'give_email_access_token_heading', esc_html__( 'Your Access Link', 'give' ) ) ); |
|
| 218 | - Give()->emails->send( $email, $subject, $message ); |
|
| 217 | + Give()->emails->__set('heading', apply_filters('give_email_access_token_heading', esc_html__('Your Access Link', 'give'))); |
|
| 218 | + Give()->emails->send($email, $subject, $message); |
|
| 219 | 219 | |
| 220 | 220 | } |
| 221 | 221 | |
@@ -229,24 +229,24 @@ discard block |
||
| 229 | 229 | */ |
| 230 | 230 | public function check_for_token() { |
| 231 | 231 | |
| 232 | - $token = isset( $_GET['give_nl'] ) ? $_GET['give_nl'] : ''; |
|
| 232 | + $token = isset($_GET['give_nl']) ? $_GET['give_nl'] : ''; |
|
| 233 | 233 | |
| 234 | 234 | // Check for cookie |
| 235 | - if ( empty( $token ) ) { |
|
| 236 | - $token = isset( $_COOKIE['give_nl'] ) ? $_COOKIE['give_nl'] : ''; |
|
| 235 | + if (empty($token)) { |
|
| 236 | + $token = isset($_COOKIE['give_nl']) ? $_COOKIE['give_nl'] : ''; |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - if ( ! empty( $token ) ) { |
|
| 240 | - if ( ! $this->is_valid_token( $token ) ) { |
|
| 241 | - if ( ! $this->is_valid_verify_key( $token ) ) { |
|
| 239 | + if ( ! empty($token)) { |
|
| 240 | + if ( ! $this->is_valid_token($token)) { |
|
| 241 | + if ( ! $this->is_valid_verify_key($token)) { |
|
| 242 | 242 | return; |
| 243 | 243 | } |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | $this->token_exists = true; |
| 247 | 247 | // Set cookie |
| 248 | - $lifetime = current_time( 'timestamp' ) + Give()->session->set_expiration_time(); |
|
| 249 | - @setcookie( 'give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
| 248 | + $lifetime = current_time('timestamp') + Give()->session->set_expiration_time(); |
|
| 249 | + @setcookie('give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
| 250 | 250 | } |
| 251 | 251 | } |
| 252 | 252 | |
@@ -260,18 +260,18 @@ discard block |
||
| 260 | 260 | * |
| 261 | 261 | * @return bool |
| 262 | 262 | */ |
| 263 | - public function is_valid_token( $token ) { |
|
| 263 | + public function is_valid_token($token) { |
|
| 264 | 264 | |
| 265 | 265 | global $wpdb; |
| 266 | 266 | |
| 267 | 267 | // Make sure token isn't expired |
| 268 | - $expires = date( 'Y-m-d H:i:s', time() - $this->token_expiration ); |
|
| 268 | + $expires = date('Y-m-d H:i:s', time() - $this->token_expiration); |
|
| 269 | 269 | |
| 270 | 270 | $email = $wpdb->get_var( |
| 271 | - $wpdb->prepare( "SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires ) |
|
| 271 | + $wpdb->prepare("SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires) |
|
| 272 | 272 | ); |
| 273 | 273 | |
| 274 | - if ( ! empty( $email ) ) { |
|
| 274 | + if ( ! empty($email)) { |
|
| 275 | 275 | $this->token_email = $email; |
| 276 | 276 | $this->token = $token; |
| 277 | 277 | |
@@ -279,8 +279,8 @@ discard block |
||
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | //Set error only if email access form isn't being submitted |
| 282 | - if ( ! isset( $_POST['give_email'] ) && ! isset( $_POST['_wpnonce'] ) ) { |
|
| 283 | - give_set_error( 'give_email_token_expired', apply_filters( 'give_email_token_expired_message', 'Sorry, your access token has expired. Please request a new one below:', 'give' ) ); |
|
| 282 | + if ( ! isset($_POST['give_email']) && ! isset($_POST['_wpnonce'])) { |
|
| 283 | + give_set_error('give_email_token_expired', apply_filters('give_email_token_expired_message', 'Sorry, your access token has expired. Please request a new one below:', 'give')); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | |
@@ -300,25 +300,25 @@ discard block |
||
| 300 | 300 | * |
| 301 | 301 | * @return void |
| 302 | 302 | */ |
| 303 | - public function set_verify_key( $customer_id, $email, $verify_key ) { |
|
| 303 | + public function set_verify_key($customer_id, $email, $verify_key) { |
|
| 304 | 304 | global $wpdb; |
| 305 | 305 | |
| 306 | - $now = date( 'Y-m-d H:i:s' ); |
|
| 306 | + $now = date('Y-m-d H:i:s'); |
|
| 307 | 307 | |
| 308 | 308 | // Insert or update? |
| 309 | 309 | $row_id = (int) $wpdb->get_var( |
| 310 | - $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id ) |
|
| 310 | + $wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id) |
|
| 311 | 311 | ); |
| 312 | 312 | |
| 313 | 313 | // Update |
| 314 | - if ( ! empty( $row_id ) ) { |
|
| 314 | + if ( ! empty($row_id)) { |
|
| 315 | 315 | $wpdb->query( |
| 316 | - $wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id ) |
|
| 316 | + $wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id) |
|
| 317 | 317 | ); |
| 318 | 318 | } // Insert |
| 319 | 319 | else { |
| 320 | 320 | $wpdb->query( |
| 321 | - $wpdb->prepare( "INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now ) |
|
| 321 | + $wpdb->prepare("INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now) |
|
| 322 | 322 | ); |
| 323 | 323 | } |
| 324 | 324 | } |
@@ -333,21 +333,21 @@ discard block |
||
| 333 | 333 | * |
| 334 | 334 | * @return bool |
| 335 | 335 | */ |
| 336 | - public function is_valid_verify_key( $token ) { |
|
| 336 | + public function is_valid_verify_key($token) { |
|
| 337 | 337 | /* @var WPDB $wpdb */ |
| 338 | 338 | global $wpdb; |
| 339 | 339 | |
| 340 | 340 | // See if the verify_key exists |
| 341 | 341 | $row = $wpdb->get_row( |
| 342 | - $wpdb->prepare( "SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token ) |
|
| 342 | + $wpdb->prepare("SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token) |
|
| 343 | 343 | ); |
| 344 | 344 | |
| 345 | - $now = date( 'Y-m-d H:i:s' ); |
|
| 345 | + $now = date('Y-m-d H:i:s'); |
|
| 346 | 346 | |
| 347 | 347 | // Set token |
| 348 | - if ( ! empty( $row ) ) { |
|
| 348 | + if ( ! empty($row)) { |
|
| 349 | 349 | $wpdb->query( |
| 350 | - $wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id ) |
|
| 350 | + $wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id) |
|
| 351 | 351 | ); |
| 352 | 352 | |
| 353 | 353 | $this->token_email = $row->email; |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | * |
| 372 | 372 | * @return mixed |
| 373 | 373 | */ |
| 374 | - public function users_purchases_args( $args ) { |
|
| 374 | + public function users_purchases_args($args) { |
|
| 375 | 375 | $args['user'] = $this->token_email; |
| 376 | 376 | |
| 377 | 377 | return $args; |
@@ -392,11 +392,11 @@ discard block |
||
| 392 | 392 | global $wpdb; |
| 393 | 393 | |
| 394 | 394 | //Create columns in customers table |
| 395 | - $query = $wpdb->query( "ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`" ); |
|
| 395 | + $query = $wpdb->query("ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`"); |
|
| 396 | 396 | |
| 397 | 397 | //Columns added properly |
| 398 | - if ( $query ) { |
|
| 399 | - give_update_option( 'email_access_installed', 1 ); |
|
| 398 | + if ($query) { |
|
| 399 | + give_update_option('email_access_installed', 1); |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | } |