@@ -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 | |
@@ -55,26 +55,26 @@ discard block |
||
| 55 | 55 | public function get_data() { |
| 56 | 56 | global $give_logs, $wpdb; |
| 57 | 57 | |
| 58 | - $totals = $this->get_stored_data( 'give_temp_recount_all_stats' ); |
|
| 59 | - $payment_items = $this->get_stored_data( 'give_temp_payment_items' ); |
|
| 60 | - $processed_payments = $this->get_stored_data( 'give_temp_processed_payments' ); |
|
| 61 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish', 'revoked' ) ); |
|
| 58 | + $totals = $this->get_stored_data('give_temp_recount_all_stats'); |
|
| 59 | + $payment_items = $this->get_stored_data('give_temp_payment_items'); |
|
| 60 | + $processed_payments = $this->get_stored_data('give_temp_processed_payments'); |
|
| 61 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish', 'revoked')); |
|
| 62 | 62 | |
| 63 | - if ( false === $totals ) { |
|
| 63 | + if (false === $totals) { |
|
| 64 | 64 | $totals = array(); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - if ( false === $payment_items ) { |
|
| 67 | + if (false === $payment_items) { |
|
| 68 | 68 | $payment_items = array(); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - if ( false === $processed_payments ) { |
|
| 71 | + if (false === $processed_payments) { |
|
| 72 | 72 | $processed_payments = array(); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - $all_forms = $this->get_stored_data( 'give_temp_form_ids' ); |
|
| 75 | + $all_forms = $this->get_stored_data('give_temp_form_ids'); |
|
| 76 | 76 | |
| 77 | - $args = apply_filters( 'give_recount_form_stats_args', array( |
|
| 77 | + $args = apply_filters('give_recount_form_stats_args', array( |
|
| 78 | 78 | 'post_parent__in' => $all_forms, |
| 79 | 79 | 'post_type' => 'give_log', |
| 80 | 80 | 'posts_per_page' => $this->per_step, |
@@ -82,73 +82,73 @@ discard block |
||
| 82 | 82 | 'paged' => $this->step, |
| 83 | 83 | 'log_type' => 'sale', |
| 84 | 84 | 'fields' => 'ids', |
| 85 | - ) ); |
|
| 85 | + )); |
|
| 86 | 86 | |
| 87 | - $log_ids = $give_logs->get_connected_logs( $args, 'sale' ); |
|
| 87 | + $log_ids = $give_logs->get_connected_logs($args, 'sale'); |
|
| 88 | 88 | |
| 89 | - if ( $log_ids ) { |
|
| 90 | - $log_ids = implode( ',', $log_ids ); |
|
| 89 | + if ($log_ids) { |
|
| 90 | + $log_ids = implode(',', $log_ids); |
|
| 91 | 91 | |
| 92 | - $payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)" ); |
|
| 93 | - unset( $log_ids ); |
|
| 92 | + $payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)"); |
|
| 93 | + unset($log_ids); |
|
| 94 | 94 | |
| 95 | - $payment_ids = implode( ',', $payment_ids ); |
|
| 96 | - $payments = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (" . $payment_ids . ")" ); |
|
| 97 | - unset( $payment_ids ); |
|
| 95 | + $payment_ids = implode(',', $payment_ids); |
|
| 96 | + $payments = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (".$payment_ids.")"); |
|
| 97 | + unset($payment_ids); |
|
| 98 | 98 | |
| 99 | 99 | //Loop through payments |
| 100 | - foreach ( $payments as $payment ) { |
|
| 100 | + foreach ($payments as $payment) { |
|
| 101 | 101 | |
| 102 | 102 | // Prevent payments that have all ready been retrieved from a previous sales log from counting again. |
| 103 | - if ( in_array( $payment->ID, $processed_payments ) ) { |
|
| 103 | + if (in_array($payment->ID, $processed_payments)) { |
|
| 104 | 104 | continue; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | //Verify accepted status' |
| 108 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
| 108 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
| 109 | 109 | $processed_payments[] = $payment->ID; |
| 110 | 110 | continue; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - $payment_item = $payment_items[ $payment->ID ]; |
|
| 113 | + $payment_item = $payment_items[$payment->ID]; |
|
| 114 | 114 | |
| 115 | 115 | |
| 116 | - $form_id = isset( $payment_item['id'] ) ? $payment_item['id'] : ''; |
|
| 116 | + $form_id = isset($payment_item['id']) ? $payment_item['id'] : ''; |
|
| 117 | 117 | |
| 118 | 118 | //Must have a form ID |
| 119 | - if ( empty( $form_id ) ) { |
|
| 119 | + if (empty($form_id)) { |
|
| 120 | 120 | continue; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | //Form ID must be within $all_forms array to be validated |
| 124 | - if ( ! in_array( $form_id, $all_forms ) ) { |
|
| 124 | + if ( ! in_array($form_id, $all_forms)) { |
|
| 125 | 125 | continue; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | //If array key doesn't exist, create it |
| 129 | - if ( ! array_key_exists( $form_id, $totals ) ) { |
|
| 130 | - $totals[ $form_id ] = array( |
|
| 129 | + if ( ! array_key_exists($form_id, $totals)) { |
|
| 130 | + $totals[$form_id] = array( |
|
| 131 | 131 | 'sales' => (int) 0, |
| 132 | 132 | 'earnings' => (float) 0, |
| 133 | 133 | ); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - $totals[ $form_id ]['sales'] ++; |
|
| 137 | - $totals[ $form_id ]['earnings'] += $payment_item['price']; |
|
| 136 | + $totals[$form_id]['sales']++; |
|
| 137 | + $totals[$form_id]['earnings'] += $payment_item['price']; |
|
| 138 | 138 | |
| 139 | 139 | $processed_payments[] = $payment->ID; |
| 140 | 140 | |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - $this->store_data( 'give_temp_processed_payments', $processed_payments ); |
|
| 144 | - $this->store_data( 'give_temp_recount_all_stats', $totals ); |
|
| 143 | + $this->store_data('give_temp_processed_payments', $processed_payments); |
|
| 144 | + $this->store_data('give_temp_recount_all_stats', $totals); |
|
| 145 | 145 | |
| 146 | 146 | return true; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - foreach ( $totals as $key => $stats ) { |
|
| 150 | - update_post_meta( $key, '_give_form_sales', $stats['sales'] ); |
|
| 151 | - update_post_meta( $key, '_give_form_earnings', $stats['earnings'] ); |
|
| 149 | + foreach ($totals as $key => $stats) { |
|
| 150 | + update_post_meta($key, '_give_form_sales', $stats['sales']); |
|
| 151 | + update_post_meta($key, '_give_form_earnings', $stats['earnings']); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | return false; |
@@ -163,20 +163,20 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | public function get_percentage_complete() { |
| 165 | 165 | |
| 166 | - $total = $this->get_stored_data( 'give_recount_all_total', false ); |
|
| 166 | + $total = $this->get_stored_data('give_recount_all_total', false); |
|
| 167 | 167 | |
| 168 | - if ( false === $total ) { |
|
| 168 | + if (false === $total) { |
|
| 169 | 169 | $this->pre_fetch(); |
| 170 | - $total = $this->get_stored_data( 'give_recount_all_total', 0 ); |
|
| 170 | + $total = $this->get_stored_data('give_recount_all_total', 0); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | $percentage = 100; |
| 174 | 174 | |
| 175 | - if ( $total > 0 ) { |
|
| 176 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 175 | + if ($total > 0) { |
|
| 176 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - if ( $percentage > 100 ) { |
|
| 179 | + if ($percentage > 100) { |
|
| 180 | 180 | $percentage = 100; |
| 181 | 181 | } |
| 182 | 182 | |
@@ -190,8 +190,8 @@ discard block |
||
| 190 | 190 | * |
| 191 | 191 | * @param array $request The Form Data passed into the batch processing |
| 192 | 192 | */ |
| 193 | - public function set_properties( $request ) { |
|
| 194 | - $this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false; |
|
| 193 | + public function set_properties($request) { |
|
| 194 | + $this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -202,34 +202,34 @@ discard block |
||
| 202 | 202 | */ |
| 203 | 203 | public function process_step() { |
| 204 | 204 | |
| 205 | - if ( ! $this->can_export() ) { |
|
| 206 | - wp_die( __( 'You do not have permission to recount stats.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 205 | + if ( ! $this->can_export()) { |
|
| 206 | + wp_die(__('You do not have permission to recount stats.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | $had_data = $this->get_data(); |
| 210 | 210 | |
| 211 | - if ( $had_data ) { |
|
| 211 | + if ($had_data) { |
|
| 212 | 212 | $this->done = false; |
| 213 | 213 | |
| 214 | 214 | return true; |
| 215 | 215 | } else { |
| 216 | - $this->delete_data( 'give_recount_all_total' ); |
|
| 217 | - $this->delete_data( 'give_temp_recount_all_stats' ); |
|
| 218 | - $this->delete_data( 'give_temp_payment_items' ); |
|
| 219 | - $this->delete_data( 'give_temp_form_ids' ); |
|
| 220 | - $this->delete_data( 'give_temp_processed_payments' ); |
|
| 216 | + $this->delete_data('give_recount_all_total'); |
|
| 217 | + $this->delete_data('give_temp_recount_all_stats'); |
|
| 218 | + $this->delete_data('give_temp_payment_items'); |
|
| 219 | + $this->delete_data('give_temp_form_ids'); |
|
| 220 | + $this->delete_data('give_temp_processed_payments'); |
|
| 221 | 221 | $this->done = true; |
| 222 | - $this->message = __( 'Donation form income amounts and donation counts stats successfully recounted.', 'give' ); |
|
| 222 | + $this->message = __('Donation form income amounts and donation counts stats successfully recounted.', 'give'); |
|
| 223 | 223 | |
| 224 | 224 | return false; |
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | public function headers() { |
| 229 | - ignore_user_abort( true ); |
|
| 229 | + ignore_user_abort(true); |
|
| 230 | 230 | |
| 231 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 232 | - set_time_limit( 0 ); |
|
| 231 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 232 | + set_time_limit(0); |
|
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | 235 | |
@@ -258,76 +258,76 @@ discard block |
||
| 258 | 258 | |
| 259 | 259 | global $give_logs, $wpdb; |
| 260 | 260 | |
| 261 | - if ( $this->step == 1 ) { |
|
| 262 | - $this->delete_data( 'give_temp_recount_all_total' ); |
|
| 263 | - $this->delete_data( 'give_temp_recount_all_stats' ); |
|
| 264 | - $this->delete_data( 'give_temp_payment_items' ); |
|
| 265 | - $this->delete_data( 'give_temp_processed_payments' ); |
|
| 261 | + if ($this->step == 1) { |
|
| 262 | + $this->delete_data('give_temp_recount_all_total'); |
|
| 263 | + $this->delete_data('give_temp_recount_all_stats'); |
|
| 264 | + $this->delete_data('give_temp_payment_items'); |
|
| 265 | + $this->delete_data('give_temp_processed_payments'); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish', 'revoked' ) ); |
|
| 269 | - $total = $this->get_stored_data( 'give_temp_recount_all_total' ); |
|
| 268 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish', 'revoked')); |
|
| 269 | + $total = $this->get_stored_data('give_temp_recount_all_total'); |
|
| 270 | 270 | |
| 271 | - if ( false === $total ) { |
|
| 271 | + if (false === $total) { |
|
| 272 | 272 | $total = 0; |
| 273 | - $payment_items = $this->get_stored_data( 'give_temp_payment_items' ); |
|
| 273 | + $payment_items = $this->get_stored_data('give_temp_payment_items'); |
|
| 274 | 274 | |
| 275 | - if ( false === $payment_items ) { |
|
| 275 | + if (false === $payment_items) { |
|
| 276 | 276 | $payment_items = array(); |
| 277 | - $this->store_data( 'give_temp_payment_items', $payment_items ); |
|
| 277 | + $this->store_data('give_temp_payment_items', $payment_items); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - $all_forms = $this->get_stored_data( 'give_temp_form_ids' ); |
|
| 280 | + $all_forms = $this->get_stored_data('give_temp_form_ids'); |
|
| 281 | 281 | |
| 282 | - if ( false === $all_forms ) { |
|
| 282 | + if (false === $all_forms) { |
|
| 283 | 283 | $args = array( |
| 284 | 284 | 'post_status' => 'any', |
| 285 | 285 | 'post_type' => 'give_forms', |
| 286 | - 'posts_per_page' => - 1, |
|
| 286 | + 'posts_per_page' => -1, |
|
| 287 | 287 | 'fields' => 'ids', |
| 288 | 288 | ); |
| 289 | 289 | |
| 290 | - $all_forms = get_posts( $args ); |
|
| 291 | - $this->store_data( 'give_temp_form_ids', $all_forms ); |
|
| 290 | + $all_forms = get_posts($args); |
|
| 291 | + $this->store_data('give_temp_form_ids', $all_forms); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - $args = apply_filters( 'give_recount_form_stats_total_args', array( |
|
| 294 | + $args = apply_filters('give_recount_form_stats_total_args', array( |
|
| 295 | 295 | 'post_parent__in' => $all_forms, |
| 296 | 296 | 'post_type' => 'give_log', |
| 297 | 297 | 'post_status' => 'publish', |
| 298 | 298 | 'log_type' => 'sale', |
| 299 | 299 | 'fields' => 'ids', |
| 300 | 300 | 'nopaging' => true, |
| 301 | - ) ); |
|
| 301 | + )); |
|
| 302 | 302 | |
| 303 | - $all_logs = $give_logs->get_connected_logs( $args, 'sale' ); |
|
| 303 | + $all_logs = $give_logs->get_connected_logs($args, 'sale'); |
|
| 304 | 304 | |
| 305 | - if ( $all_logs ) { |
|
| 306 | - $log_ids = implode( ',', $all_logs ); |
|
| 307 | - $payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)" ); |
|
| 308 | - unset( $log_ids ); |
|
| 305 | + if ($all_logs) { |
|
| 306 | + $log_ids = implode(',', $all_logs); |
|
| 307 | + $payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)"); |
|
| 308 | + unset($log_ids); |
|
| 309 | 309 | |
| 310 | - $payment_ids = implode( ',', $payment_ids ); |
|
| 311 | - $payments = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (" . $payment_ids . ")" ); |
|
| 312 | - unset( $payment_ids ); |
|
| 310 | + $payment_ids = implode(',', $payment_ids); |
|
| 311 | + $payments = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (".$payment_ids.")"); |
|
| 312 | + unset($payment_ids); |
|
| 313 | 313 | |
| 314 | - foreach ( $payments as $payment ) { |
|
| 314 | + foreach ($payments as $payment) { |
|
| 315 | 315 | |
| 316 | - $payment = new Give_Payment( $payment->ID ); |
|
| 316 | + $payment = new Give_Payment($payment->ID); |
|
| 317 | 317 | $form_id = $payment->form_id; |
| 318 | 318 | |
| 319 | 319 | //If for some reason somehow the form_ID isn't set check payment meta |
| 320 | - if ( empty( $payment->form_id ) ) { |
|
| 320 | + if (empty($payment->form_id)) { |
|
| 321 | 321 | $payment_meta = $payment->get_meta(); |
| 322 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0; |
|
| 322 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0; |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
| 325 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
| 326 | 326 | continue; |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | - if ( ! array_key_exists( $payment->ID, $payment_items ) ) { |
|
| 330 | - $payment_items[ $payment->ID ] = array( |
|
| 329 | + if ( ! array_key_exists($payment->ID, $payment_items)) { |
|
| 330 | + $payment_items[$payment->ID] = array( |
|
| 331 | 331 | 'id' => $form_id, |
| 332 | 332 | 'payment_id' => $payment->ID, |
| 333 | 333 | 'price' => $payment->total |
@@ -336,11 +336,11 @@ discard block |
||
| 336 | 336 | |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | - $total = count( $all_logs ); |
|
| 339 | + $total = count($all_logs); |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - $this->store_data( 'give_temp_payment_items', $payment_items ); |
|
| 343 | - $this->store_data( 'give_recount_all_total', $total ); |
|
| 342 | + $this->store_data('give_temp_payment_items', $payment_items); |
|
| 343 | + $this->store_data('give_recount_all_total', $total); |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | } |
@@ -354,11 +354,11 @@ discard block |
||
| 354 | 354 | * |
| 355 | 355 | * @return mixed Returns the data from the database |
| 356 | 356 | */ |
| 357 | - private function get_stored_data( $key ) { |
|
| 357 | + private function get_stored_data($key) { |
|
| 358 | 358 | global $wpdb; |
| 359 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 359 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 360 | 360 | |
| 361 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
| 361 | + return empty($value) ? false : maybe_unserialize($value); |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | /** |
@@ -371,10 +371,10 @@ discard block |
||
| 371 | 371 | * |
| 372 | 372 | * @return void |
| 373 | 373 | */ |
| 374 | - private function store_data( $key, $value ) { |
|
| 374 | + private function store_data($key, $value) { |
|
| 375 | 375 | global $wpdb; |
| 376 | 376 | |
| 377 | - $value = maybe_serialize( $value ); |
|
| 377 | + $value = maybe_serialize($value); |
|
| 378 | 378 | |
| 379 | 379 | $data = array( |
| 380 | 380 | 'option_name' => $key, |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | '%s', |
| 389 | 389 | ); |
| 390 | 390 | |
| 391 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 391 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | /** |
@@ -400,9 +400,9 @@ discard block |
||
| 400 | 400 | * |
| 401 | 401 | * @return void |
| 402 | 402 | */ |
| 403 | - private function delete_data( $key ) { |
|
| 403 | + private function delete_data($key) { |
|
| 404 | 404 | global $wpdb; |
| 405 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 405 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | } |
@@ -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', 'revoked' ) ); |
|
| 65 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish', 'revoked')); |
|
| 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', 'revoked' ) ); |
|
| 151 | - $total = $this->get_stored_data( 'give_recount_total_' . $this->form_id ); |
|
| 150 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish', 'revoked')); |
|
| 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( __( 'You do not have permission to recount stats.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 219 | + if ( ! $this->can_export()) { |
|
| 220 | + wp_die(__('You do not have permission to recount stats.', 'give'), __('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( __( 'Donation counts and income amount statistics successfully recounted for "%s".', 'give' ), get_the_title( $this->form_id ) ); |
|
| 233 | + $this->message = sprintf(__('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', 'revoked' ) ); |
|
| 68 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish', 'revoked')); |
|
| 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 ) + absint( $counts->revoked ); |
|
| 121 | - $total = apply_filters( 'give_recount_store_income_total', $total ); |
|
| 119 | + $counts = give_count_payments($args); |
|
| 120 | + $total = absint($counts->publish) + absint($counts->revoked); |
|
| 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( __( 'You do not have permission to recount stats.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 157 | + if ( ! $this->can_export()) { |
|
| 158 | + wp_die(__('You do not have permission to recount stats.', 'give'), __('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 = __( 'Give income successfully recounted.', 'give' ); |
|
| 171 | + $this->message = __('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 | |
@@ -70,36 +70,36 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | $cols = array(); |
| 72 | 72 | |
| 73 | - $columns = isset( $this->data['give_export_option'] ) ? $this->data['give_export_option'] : array(); |
|
| 73 | + $columns = isset($this->data['give_export_option']) ? $this->data['give_export_option'] : array(); |
|
| 74 | 74 | |
| 75 | - if ( empty( $columns ) ) { |
|
| 75 | + if (empty($columns)) { |
|
| 76 | 76 | return false; |
| 77 | 77 | } |
| 78 | - if ( ! empty( $columns['full_name'] ) ) { |
|
| 79 | - $cols['full_name'] = __( 'Full Name', 'give' ); |
|
| 78 | + if ( ! empty($columns['full_name'])) { |
|
| 79 | + $cols['full_name'] = __('Full Name', 'give'); |
|
| 80 | 80 | } |
| 81 | - if ( ! empty( $columns['email'] ) ) { |
|
| 82 | - $cols['email'] = __( 'Email Address', 'give' ); |
|
| 81 | + if ( ! empty($columns['email'])) { |
|
| 82 | + $cols['email'] = __('Email Address', 'give'); |
|
| 83 | 83 | } |
| 84 | - if ( ! empty( $columns['address'] ) ) { |
|
| 85 | - $cols['address_line1'] = __( 'Address', 'give' ); |
|
| 86 | - $cols['address_line2'] = __( 'Address (Line 2)', 'give' ); |
|
| 87 | - $cols['address_city'] = __( 'City', 'give' ); |
|
| 88 | - $cols['address_state'] = __( 'State', 'give' ); |
|
| 89 | - $cols['address_zip'] = __( 'Zip', 'give' ); |
|
| 90 | - $cols['address_country'] = __( 'Country', 'give' ); |
|
| 84 | + if ( ! empty($columns['address'])) { |
|
| 85 | + $cols['address_line1'] = __('Address', 'give'); |
|
| 86 | + $cols['address_line2'] = __('Address (Line 2)', 'give'); |
|
| 87 | + $cols['address_city'] = __('City', 'give'); |
|
| 88 | + $cols['address_state'] = __('State', 'give'); |
|
| 89 | + $cols['address_zip'] = __('Zip', 'give'); |
|
| 90 | + $cols['address_country'] = __('Country', 'give'); |
|
| 91 | 91 | } |
| 92 | - if ( ! empty( $columns['userid'] ) ) { |
|
| 93 | - $cols['userid'] = __( 'User ID', 'give' ); |
|
| 92 | + if ( ! empty($columns['userid'])) { |
|
| 93 | + $cols['userid'] = __('User ID', 'give'); |
|
| 94 | 94 | } |
| 95 | - if ( ! empty( $columns['date_first_donated'] ) ) { |
|
| 96 | - $cols['date_first_donated'] = __( 'First Donation Date', 'give' ); |
|
| 95 | + if ( ! empty($columns['date_first_donated'])) { |
|
| 96 | + $cols['date_first_donated'] = __('First Donation Date', 'give'); |
|
| 97 | 97 | } |
| 98 | - if ( ! empty( $columns['donations'] ) ) { |
|
| 99 | - $cols['donations'] = __( 'Number of Donations', 'give' ); |
|
| 98 | + if ( ! empty($columns['donations'])) { |
|
| 99 | + $cols['donations'] = __('Number of Donations', 'give'); |
|
| 100 | 100 | } |
| 101 | - if ( ! empty( $columns['donation_sum'] ) ) { |
|
| 102 | - $cols['donation_sum'] = __( 'Sum of Donations', 'give' ); |
|
| 101 | + if ( ! empty($columns['donation_sum'])) { |
|
| 102 | + $cols['donation_sum'] = __('Sum of Donations', 'give'); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | return $cols; |
@@ -119,20 +119,20 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | $i = 0; |
| 121 | 121 | |
| 122 | - if ( ! empty( $this->form ) ) { |
|
| 122 | + if ( ! empty($this->form)) { |
|
| 123 | 123 | |
| 124 | 124 | // Export donors of a specific product |
| 125 | 125 | global $give_logs; |
| 126 | 126 | |
| 127 | 127 | $args = array( |
| 128 | - 'post_parent' => absint( $this->form ), |
|
| 128 | + 'post_parent' => absint($this->form), |
|
| 129 | 129 | 'log_type' => 'sale', |
| 130 | 130 | 'posts_per_page' => 30, |
| 131 | 131 | 'paged' => $this->step |
| 132 | 132 | ); |
| 133 | 133 | |
| 134 | 134 | //Check for price option |
| 135 | - if ( null !== $this->price_id ) { |
|
| 135 | + if (null !== $this->price_id) { |
|
| 136 | 136 | $args['meta_query'] = array( |
| 137 | 137 | array( |
| 138 | 138 | 'key' => '_give_log_price_id', |
@@ -141,33 +141,33 @@ discard block |
||
| 141 | 141 | ); |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - $logs = $give_logs->get_connected_logs( $args ); |
|
| 144 | + $logs = $give_logs->get_connected_logs($args); |
|
| 145 | 145 | |
| 146 | - if ( $logs ) { |
|
| 147 | - foreach ( $logs as $log ) { |
|
| 148 | - $payment_id = get_post_meta( $log->ID, '_give_log_payment_id', true ); |
|
| 149 | - $payment = new Give_Payment( $payment_id ); |
|
| 150 | - $donor = Give()->customers->get_customer_by( 'id', $payment->customer_id ); |
|
| 151 | - $data[] = $this->set_donor_data( $i, $data, $donor ); |
|
| 152 | - $i ++; |
|
| 146 | + if ($logs) { |
|
| 147 | + foreach ($logs as $log) { |
|
| 148 | + $payment_id = get_post_meta($log->ID, '_give_log_payment_id', true); |
|
| 149 | + $payment = new Give_Payment($payment_id); |
|
| 150 | + $donor = Give()->customers->get_customer_by('id', $payment->customer_id); |
|
| 151 | + $data[] = $this->set_donor_data($i, $data, $donor); |
|
| 152 | + $i++; |
|
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | } else { |
| 157 | 157 | |
| 158 | 158 | // Export all customers |
| 159 | - $offset = 30 * ( $this->step - 1 ); |
|
| 160 | - $donors = Give()->customers->get_customers( array( 'number' => 30, 'offset' => $offset ) ); |
|
| 159 | + $offset = 30 * ($this->step - 1); |
|
| 160 | + $donors = Give()->customers->get_customers(array('number' => 30, 'offset' => $offset)); |
|
| 161 | 161 | |
| 162 | - foreach ( $donors as $donor ) { |
|
| 162 | + foreach ($donors as $donor) { |
|
| 163 | 163 | |
| 164 | - $data[] = $this->set_donor_data( $i, $data, $donor ); |
|
| 165 | - $i ++; |
|
| 164 | + $data[] = $this->set_donor_data($i, $data, $donor); |
|
| 165 | + $i++; |
|
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
| 170 | - $data = apply_filters( 'give_export_get_data_' . $this->export_type, $data ); |
|
| 169 | + $data = apply_filters('give_export_get_data', $data); |
|
| 170 | + $data = apply_filters('give_export_get_data_'.$this->export_type, $data); |
|
| 171 | 171 | |
| 172 | 172 | return $data; |
| 173 | 173 | } |
@@ -183,19 +183,19 @@ discard block |
||
| 183 | 183 | $percentage = 0; |
| 184 | 184 | |
| 185 | 185 | // We can't count the number when getting them for a specific form |
| 186 | - if ( empty( $this->form ) ) { |
|
| 186 | + if (empty($this->form)) { |
|
| 187 | 187 | |
| 188 | 188 | $total = Give()->customers->count(); |
| 189 | 189 | |
| 190 | - if ( $total > 0 ) { |
|
| 190 | + if ($total > 0) { |
|
| 191 | 191 | |
| 192 | - $percentage = ( ( 30 * $this->step ) / $total ) * 100; |
|
| 192 | + $percentage = ((30 * $this->step) / $total) * 100; |
|
| 193 | 193 | |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - if ( $percentage > 100 ) { |
|
| 198 | + if ($percentage > 100) { |
|
| 199 | 199 | $percentage = 100; |
| 200 | 200 | } |
| 201 | 201 | |
@@ -207,46 +207,46 @@ discard block |
||
| 207 | 207 | * |
| 208 | 208 | * @param $donor |
| 209 | 209 | */ |
| 210 | - private function set_donor_data( $i, $data, $donor ) { |
|
| 210 | + private function set_donor_data($i, $data, $donor) { |
|
| 211 | 211 | |
| 212 | 212 | $columns = $this->csv_cols(); |
| 213 | 213 | |
| 214 | 214 | //Set address variable |
| 215 | 215 | $address = ''; |
| 216 | - if ( isset( $donor->user_id ) && $donor->user_id > 0 ) { |
|
| 217 | - $address = give_get_donor_address( $donor->user_id ); |
|
| 216 | + if (isset($donor->user_id) && $donor->user_id > 0) { |
|
| 217 | + $address = give_get_donor_address($donor->user_id); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | //Set columns |
| 221 | - if ( ! empty( $columns['full_name'] ) ) { |
|
| 222 | - $data[ $i ]['full_name'] = $donor->name; |
|
| 221 | + if ( ! empty($columns['full_name'])) { |
|
| 222 | + $data[$i]['full_name'] = $donor->name; |
|
| 223 | 223 | } |
| 224 | - if ( ! empty( $columns['email'] ) ) { |
|
| 225 | - $data[ $i ]['email'] = $donor->email; |
|
| 224 | + if ( ! empty($columns['email'])) { |
|
| 225 | + $data[$i]['email'] = $donor->email; |
|
| 226 | 226 | } |
| 227 | - if ( ! empty( $columns['address_line1'] ) ) { |
|
| 227 | + if ( ! empty($columns['address_line1'])) { |
|
| 228 | 228 | |
| 229 | - $data[ $i ]['address_line1'] = isset( $address['line1'] ) ? $address['line1'] : ''; |
|
| 230 | - $data[ $i ]['address_line2'] = isset( $address['line2'] ) ? $address['line2'] : ''; |
|
| 231 | - $data[ $i ]['address_city'] = isset( $address['city'] ) ? $address['city'] : ''; |
|
| 232 | - $data[ $i ]['address_state'] = isset( $address['state'] ) ? $address['state'] : ''; |
|
| 233 | - $data[ $i ]['address_zip'] = isset( $address['zip'] ) ? $address['zip'] : ''; |
|
| 234 | - $data[ $i ]['address_country'] = isset( $address['country'] ) ? $address['country'] : ''; |
|
| 229 | + $data[$i]['address_line1'] = isset($address['line1']) ? $address['line1'] : ''; |
|
| 230 | + $data[$i]['address_line2'] = isset($address['line2']) ? $address['line2'] : ''; |
|
| 231 | + $data[$i]['address_city'] = isset($address['city']) ? $address['city'] : ''; |
|
| 232 | + $data[$i]['address_state'] = isset($address['state']) ? $address['state'] : ''; |
|
| 233 | + $data[$i]['address_zip'] = isset($address['zip']) ? $address['zip'] : ''; |
|
| 234 | + $data[$i]['address_country'] = isset($address['country']) ? $address['country'] : ''; |
|
| 235 | 235 | } |
| 236 | - if ( ! empty( $columns['userid'] ) ) { |
|
| 237 | - $data[ $i ]['userid'] = ! empty( $donor->user_id ) ? $donor->user_id : ''; |
|
| 236 | + if ( ! empty($columns['userid'])) { |
|
| 237 | + $data[$i]['userid'] = ! empty($donor->user_id) ? $donor->user_id : ''; |
|
| 238 | 238 | } |
| 239 | - if ( ! empty( $columns['date_first_donated'] ) ) { |
|
| 240 | - $data[ $i ]['date_first_donated'] = date_i18n( get_option( 'date_format' ), strtotime( $donor->date_created ) ); |
|
| 239 | + if ( ! empty($columns['date_first_donated'])) { |
|
| 240 | + $data[$i]['date_first_donated'] = date_i18n(get_option('date_format'), strtotime($donor->date_created)); |
|
| 241 | 241 | } |
| 242 | - if ( ! empty( $columns['donations'] ) ) { |
|
| 243 | - $data[ $i ]['donations'] = $donor->purchase_count; |
|
| 242 | + if ( ! empty($columns['donations'])) { |
|
| 243 | + $data[$i]['donations'] = $donor->purchase_count; |
|
| 244 | 244 | } |
| 245 | - if ( ! empty( $columns['donation_sum'] ) ) { |
|
| 246 | - $data[ $i ]['donation_sum'] = give_format_amount( $donor->purchase_value ); |
|
| 245 | + if ( ! empty($columns['donation_sum'])) { |
|
| 246 | + $data[$i]['donation_sum'] = give_format_amount($donor->purchase_value); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - return $data[ $i ]; |
|
| 249 | + return $data[$i]; |
|
| 250 | 250 | |
| 251 | 251 | } |
| 252 | 252 | |
@@ -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 | |
@@ -25,27 +25,27 @@ discard block |
||
| 25 | 25 | function give_test_ajax_works() { |
| 26 | 26 | |
| 27 | 27 | // Check if the Airplane Mode plugin is installed |
| 28 | - if ( class_exists( 'Airplane_Mode_Core' ) ) { |
|
| 28 | + if (class_exists('Airplane_Mode_Core')) { |
|
| 29 | 29 | |
| 30 | 30 | $airplane = Airplane_Mode_Core::getInstance(); |
| 31 | 31 | |
| 32 | - if ( method_exists( $airplane, 'enabled' ) ) { |
|
| 32 | + if (method_exists($airplane, 'enabled')) { |
|
| 33 | 33 | |
| 34 | - if ( $airplane->enabled() ) { |
|
| 34 | + if ($airplane->enabled()) { |
|
| 35 | 35 | return true; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | } else { |
| 39 | 39 | |
| 40 | - if ( $airplane->check_status() == 'on' ) { |
|
| 40 | + if ($airplane->check_status() == 'on') { |
|
| 41 | 41 | return true; |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - add_filter( 'block_local_requests', '__return_false' ); |
|
| 46 | + add_filter('block_local_requests', '__return_false'); |
|
| 47 | 47 | |
| 48 | - if ( get_transient( '_give_ajax_works' ) ) { |
|
| 48 | + if (get_transient('_give_ajax_works')) { |
|
| 49 | 49 | return true; |
| 50 | 50 | } |
| 51 | 51 | |
@@ -57,35 +57,35 @@ discard block |
||
| 57 | 57 | ) |
| 58 | 58 | ); |
| 59 | 59 | |
| 60 | - $ajax = wp_remote_post( give_get_ajax_url(), $params ); |
|
| 60 | + $ajax = wp_remote_post(give_get_ajax_url(), $params); |
|
| 61 | 61 | $works = true; |
| 62 | 62 | |
| 63 | - if ( is_wp_error( $ajax ) ) { |
|
| 63 | + if (is_wp_error($ajax)) { |
|
| 64 | 64 | |
| 65 | 65 | $works = false; |
| 66 | 66 | |
| 67 | 67 | } else { |
| 68 | 68 | |
| 69 | - if ( empty( $ajax['response'] ) ) { |
|
| 69 | + if (empty($ajax['response'])) { |
|
| 70 | 70 | $works = false; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) { |
|
| 73 | + if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) { |
|
| 74 | 74 | $works = false; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) { |
|
| 77 | + if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) { |
|
| 78 | 78 | $works = false; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) { |
|
| 81 | + if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) { |
|
| 82 | 82 | $works = false; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - if ( $works ) { |
|
| 88 | - set_transient( '_give_ajax_works', '1', DAY_IN_SECONDS ); |
|
| 87 | + if ($works) { |
|
| 88 | + set_transient('_give_ajax_works', '1', DAY_IN_SECONDS); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | return $works; |
@@ -99,16 +99,16 @@ discard block |
||
| 99 | 99 | * @return string |
| 100 | 100 | */ |
| 101 | 101 | function give_get_ajax_url() { |
| 102 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
| 102 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
| 103 | 103 | |
| 104 | 104 | $current_url = give_get_current_page_url(); |
| 105 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
| 105 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
| 106 | 106 | |
| 107 | - if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) { |
|
| 108 | - $ajax_url = preg_replace( '/^http/', 'https', $ajax_url ); |
|
| 107 | + if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) { |
|
| 108 | + $ajax_url = preg_replace('/^http/', 'https', $ajax_url); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - return apply_filters( 'give_ajax_url', $ajax_url ); |
|
| 111 | + return apply_filters('give_ajax_url', $ajax_url); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -118,11 +118,11 @@ discard block |
||
| 118 | 118 | * @return void |
| 119 | 119 | */ |
| 120 | 120 | function give_load_checkout_login_fields() { |
| 121 | - do_action( 'give_purchase_form_login_fields' ); |
|
| 121 | + do_action('give_purchase_form_login_fields'); |
|
| 122 | 122 | give_die(); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | -add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' ); |
|
| 125 | +add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields'); |
|
| 126 | 126 | |
| 127 | 127 | /** |
| 128 | 128 | * Load Checkout Fields |
@@ -131,22 +131,22 @@ discard block |
||
| 131 | 131 | * @return void |
| 132 | 132 | */ |
| 133 | 133 | function give_load_checkout_fields() { |
| 134 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : ''; |
|
| 134 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : ''; |
|
| 135 | 135 | |
| 136 | 136 | ob_start(); |
| 137 | 137 | |
| 138 | - do_action( 'give_purchase_form_register_login_fields', $form_id ); |
|
| 138 | + do_action('give_purchase_form_register_login_fields', $form_id); |
|
| 139 | 139 | |
| 140 | 140 | $fields = ob_get_clean(); |
| 141 | 141 | |
| 142 | - wp_send_json( array( |
|
| 143 | - 'fields' => wp_json_encode( $fields ), |
|
| 144 | - 'submit' => wp_json_encode( give_checkout_button_purchase( $form_id ) ), |
|
| 145 | - ) ); |
|
| 142 | + wp_send_json(array( |
|
| 143 | + 'fields' => wp_json_encode($fields), |
|
| 144 | + 'submit' => wp_json_encode(give_checkout_button_purchase($form_id)), |
|
| 145 | + )); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | -add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' ); |
|
| 149 | -add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' ); |
|
| 148 | +add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields'); |
|
| 149 | +add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields'); |
|
| 150 | 150 | |
| 151 | 151 | /** |
| 152 | 152 | * Get Form Title via AJAX (used only in WordPress Admin) |
@@ -155,9 +155,9 @@ discard block |
||
| 155 | 155 | * @return void |
| 156 | 156 | */ |
| 157 | 157 | function give_ajax_get_form_title() { |
| 158 | - if ( isset( $_POST['form_id'] ) ) { |
|
| 159 | - $title = get_the_title( $_POST['form_id'] ); |
|
| 160 | - if ( $title ) { |
|
| 158 | + if (isset($_POST['form_id'])) { |
|
| 159 | + $title = get_the_title($_POST['form_id']); |
|
| 160 | + if ($title) { |
|
| 161 | 161 | echo $title; |
| 162 | 162 | } else { |
| 163 | 163 | echo 'fail'; |
@@ -166,8 +166,8 @@ discard block |
||
| 166 | 166 | give_die(); |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | -add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' ); |
|
| 170 | -add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' ); |
|
| 169 | +add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title'); |
|
| 170 | +add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title'); |
|
| 171 | 171 | |
| 172 | 172 | /** |
| 173 | 173 | * Retrieve a states drop down |
@@ -177,23 +177,23 @@ discard block |
||
| 177 | 177 | */ |
| 178 | 178 | function give_ajax_get_states_field() { |
| 179 | 179 | |
| 180 | - if ( empty( $_POST['country'] ) ) { |
|
| 180 | + if (empty($_POST['country'])) { |
|
| 181 | 181 | $_POST['country'] = give_get_country(); |
| 182 | 182 | } |
| 183 | - $states = give_get_states( $_POST['country'] ); |
|
| 183 | + $states = give_get_states($_POST['country']); |
|
| 184 | 184 | |
| 185 | - if ( ! empty( $states ) ) { |
|
| 185 | + if ( ! empty($states)) { |
|
| 186 | 186 | |
| 187 | 187 | $args = array( |
| 188 | 188 | 'name' => $_POST['field_name'], |
| 189 | 189 | 'id' => $_POST['field_name'], |
| 190 | - 'class' => $_POST['field_name'] . ' give-select', |
|
| 191 | - 'options' => give_get_states( $_POST['country'] ), |
|
| 190 | + 'class' => $_POST['field_name'].' give-select', |
|
| 191 | + 'options' => give_get_states($_POST['country']), |
|
| 192 | 192 | 'show_option_all' => false, |
| 193 | 193 | 'show_option_none' => false |
| 194 | 194 | ); |
| 195 | 195 | |
| 196 | - $response = Give()->html->select( $args ); |
|
| 196 | + $response = Give()->html->select($args); |
|
| 197 | 197 | |
| 198 | 198 | } else { |
| 199 | 199 | |
@@ -205,8 +205,8 @@ discard block |
||
| 205 | 205 | give_die(); |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | -add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' ); |
|
| 209 | -add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' ); |
|
| 208 | +add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field'); |
|
| 209 | +add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field'); |
|
| 210 | 210 | |
| 211 | 211 | /** |
| 212 | 212 | * Retrieve a states drop down |
@@ -217,17 +217,17 @@ discard block |
||
| 217 | 217 | function give_ajax_form_search() { |
| 218 | 218 | global $wpdb; |
| 219 | 219 | |
| 220 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
| 220 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
| 221 | 221 | $results = array(); |
| 222 | - if ( current_user_can( 'edit_give_forms' ) ) { |
|
| 223 | - $items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50" ); |
|
| 222 | + if (current_user_can('edit_give_forms')) { |
|
| 223 | + $items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50"); |
|
| 224 | 224 | } else { |
| 225 | - $items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50" ); |
|
| 225 | + $items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50"); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - if ( $items ) { |
|
| 228 | + if ($items) { |
|
| 229 | 229 | |
| 230 | - foreach ( $items as $item ) { |
|
| 230 | + foreach ($items as $item) { |
|
| 231 | 231 | |
| 232 | 232 | $results[] = array( |
| 233 | 233 | 'id' => $item->ID, |
@@ -239,18 +239,18 @@ discard block |
||
| 239 | 239 | |
| 240 | 240 | $items[] = array( |
| 241 | 241 | 'id' => 0, |
| 242 | - 'name' => __( 'No results found', 'give' ) |
|
| 242 | + 'name' => __('No results found', 'give') |
|
| 243 | 243 | ); |
| 244 | 244 | |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - echo json_encode( $results ); |
|
| 247 | + echo json_encode($results); |
|
| 248 | 248 | |
| 249 | 249 | give_die(); |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | -add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' ); |
|
| 253 | -add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' ); |
|
| 252 | +add_action('wp_ajax_give_form_search', 'give_ajax_form_search'); |
|
| 253 | +add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search'); |
|
| 254 | 254 | |
| 255 | 255 | /** |
| 256 | 256 | * Search the donors database via Ajax |
@@ -261,21 +261,21 @@ discard block |
||
| 261 | 261 | function give_ajax_donor_search() { |
| 262 | 262 | global $wpdb; |
| 263 | 263 | |
| 264 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
| 264 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
| 265 | 265 | $results = array(); |
| 266 | - if ( ! current_user_can( 'view_give_reports' ) ) { |
|
| 266 | + if ( ! current_user_can('view_give_reports')) { |
|
| 267 | 267 | $donors = array(); |
| 268 | 268 | } else { |
| 269 | - $donors = $wpdb->get_results( "SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" ); |
|
| 269 | + $donors = $wpdb->get_results("SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50"); |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - if ( $donors ) { |
|
| 272 | + if ($donors) { |
|
| 273 | 273 | |
| 274 | - foreach ( $donors as $donor ) { |
|
| 274 | + foreach ($donors as $donor) { |
|
| 275 | 275 | |
| 276 | 276 | $results[] = array( |
| 277 | 277 | 'id' => $donor->id, |
| 278 | - 'name' => $donor->name . '(' . $donor->email . ')' |
|
| 278 | + 'name' => $donor->name.'('.$donor->email.')' |
|
| 279 | 279 | ); |
| 280 | 280 | } |
| 281 | 281 | |
@@ -283,17 +283,17 @@ discard block |
||
| 283 | 283 | |
| 284 | 284 | $donors[] = array( |
| 285 | 285 | 'id' => 0, |
| 286 | - 'name' => __( 'No results found', 'give' ) |
|
| 286 | + 'name' => __('No results found', 'give') |
|
| 287 | 287 | ); |
| 288 | 288 | |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - echo json_encode( $results ); |
|
| 291 | + echo json_encode($results); |
|
| 292 | 292 | |
| 293 | 293 | give_die(); |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | -add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' ); |
|
| 296 | +add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search'); |
|
| 297 | 297 | |
| 298 | 298 | |
| 299 | 299 | /** |
@@ -304,42 +304,42 @@ discard block |
||
| 304 | 304 | */ |
| 305 | 305 | function give_ajax_search_users() { |
| 306 | 306 | |
| 307 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
| 307 | + if (current_user_can('manage_give_settings')) { |
|
| 308 | 308 | |
| 309 | - $search_query = trim( $_POST['user_name'] ); |
|
| 310 | - $exclude = trim( $_POST['exclude'] ); |
|
| 309 | + $search_query = trim($_POST['user_name']); |
|
| 310 | + $exclude = trim($_POST['exclude']); |
|
| 311 | 311 | |
| 312 | 312 | $get_users_args = array( |
| 313 | 313 | 'number' => 9999, |
| 314 | - 'search' => $search_query . '*' |
|
| 314 | + 'search' => $search_query.'*' |
|
| 315 | 315 | ); |
| 316 | 316 | |
| 317 | - if ( ! empty( $exclude ) ) { |
|
| 318 | - $exclude_array = explode( ',', $exclude ); |
|
| 317 | + if ( ! empty($exclude)) { |
|
| 318 | + $exclude_array = explode(',', $exclude); |
|
| 319 | 319 | $get_users_args['exclude'] = $exclude_array; |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | - $get_users_args = apply_filters( 'give_search_users_args', $get_users_args ); |
|
| 322 | + $get_users_args = apply_filters('give_search_users_args', $get_users_args); |
|
| 323 | 323 | |
| 324 | - $found_users = apply_filters( 'give_ajax_found_users', get_users( $get_users_args ), $search_query ); |
|
| 324 | + $found_users = apply_filters('give_ajax_found_users', get_users($get_users_args), $search_query); |
|
| 325 | 325 | |
| 326 | 326 | $user_list = '<ul>'; |
| 327 | - if ( $found_users ) { |
|
| 328 | - foreach ( $found_users as $user ) { |
|
| 329 | - $user_list .= '<li><a href="#" data-userid="' . esc_attr( $user->ID ) . '" data-login="' . esc_attr( $user->user_login ) . '">' . esc_html( $user->user_login ) . '</a></li>'; |
|
| 327 | + if ($found_users) { |
|
| 328 | + foreach ($found_users as $user) { |
|
| 329 | + $user_list .= '<li><a href="#" data-userid="'.esc_attr($user->ID).'" data-login="'.esc_attr($user->user_login).'">'.esc_html($user->user_login).'</a></li>'; |
|
| 330 | 330 | } |
| 331 | 331 | } else { |
| 332 | - $user_list .= '<li>' . __( 'No users found', 'give' ) . '</li>'; |
|
| 332 | + $user_list .= '<li>'.__('No users found', 'give').'</li>'; |
|
| 333 | 333 | } |
| 334 | 334 | $user_list .= '</ul>'; |
| 335 | 335 | |
| 336 | - echo json_encode( array( 'results' => $user_list ) ); |
|
| 336 | + echo json_encode(array('results' => $user_list)); |
|
| 337 | 337 | |
| 338 | 338 | } |
| 339 | 339 | die(); |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | -add_action( 'wp_ajax_give_search_users', 'give_ajax_search_users' ); |
|
| 342 | +add_action('wp_ajax_give_search_users', 'give_ajax_search_users'); |
|
| 343 | 343 | |
| 344 | 344 | |
| 345 | 345 | /** |
@@ -350,32 +350,32 @@ discard block |
||
| 350 | 350 | */ |
| 351 | 351 | function give_check_for_form_price_variations() { |
| 352 | 352 | |
| 353 | - if ( ! current_user_can( 'edit_give_forms', get_current_user_id() ) ) { |
|
| 354 | - die( '-1' ); |
|
| 353 | + if ( ! current_user_can('edit_give_forms', get_current_user_id())) { |
|
| 354 | + die('-1'); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - $form_id = intval( $_POST['form_id'] ); |
|
| 358 | - $form = get_post( $form_id ); |
|
| 357 | + $form_id = intval($_POST['form_id']); |
|
| 358 | + $form = get_post($form_id); |
|
| 359 | 359 | |
| 360 | - if ( 'give_forms' != $form->post_type ) { |
|
| 361 | - die( '-2' ); |
|
| 360 | + if ('give_forms' != $form->post_type) { |
|
| 361 | + die('-2'); |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | - if ( give_has_variable_prices( $form_id ) ) { |
|
| 365 | - $variable_prices = give_get_variable_prices( $form_id ); |
|
| 364 | + if (give_has_variable_prices($form_id)) { |
|
| 365 | + $variable_prices = give_get_variable_prices($form_id); |
|
| 366 | 366 | |
| 367 | - if ( $variable_prices ) { |
|
| 367 | + if ($variable_prices) { |
|
| 368 | 368 | $ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">'; |
| 369 | 369 | |
| 370 | - if ( isset( $_POST['all_prices'] ) ) { |
|
| 371 | - $ajax_response .= '<option value="">' . __( 'All Levels', 'give' ) . '</option>'; |
|
| 370 | + if (isset($_POST['all_prices'])) { |
|
| 371 | + $ajax_response .= '<option value="">'.__('All Levels', 'give').'</option>'; |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - foreach ( $variable_prices as $key => $price ) { |
|
| 374 | + foreach ($variable_prices as $key => $price) { |
|
| 375 | 375 | |
| 376 | - $level_text = ! empty( $price['_give_text'] ) ? esc_html( $price['_give_text'] ) : give_currency_filter( give_format_amount( $price['_give_amount'] ) ); |
|
| 376 | + $level_text = ! empty($price['_give_text']) ? esc_html($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount'])); |
|
| 377 | 377 | |
| 378 | - $ajax_response .= '<option value="' . esc_attr( $price['_give_id']['level_id'] ) . '">' . $level_text . '</option>'; |
|
| 378 | + $ajax_response .= '<option value="'.esc_attr($price['_give_id']['level_id']).'">'.$level_text.'</option>'; |
|
| 379 | 379 | } |
| 380 | 380 | $ajax_response .= '</select>'; |
| 381 | 381 | echo $ajax_response; |
@@ -386,4 +386,4 @@ discard block |
||
| 386 | 386 | give_die(); |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | -add_action( 'wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations' ); |
|
| 389 | +add_action('wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations'); |
|
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -22,20 +22,20 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | function give_process_batch_export_form() { |
| 24 | 24 | |
| 25 | - if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'give-batch-export' ) ) { |
|
| 26 | - wp_die( __( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 25 | + if ( ! wp_verify_nonce($_REQUEST['nonce'], 'give-batch-export')) { |
|
| 26 | + wp_die(__('Nonce verification failed', 'give'), __('Error', 'give'), array('response' => 403)); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export.php'; |
|
| 29 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export.php'; |
|
| 30 | 30 | |
| 31 | - do_action( 'give_batch_export_class_include', $_REQUEST['class'] ); |
|
| 31 | + do_action('give_batch_export_class_include', $_REQUEST['class']); |
|
| 32 | 32 | |
| 33 | 33 | $export = new $_REQUEST['class']; |
| 34 | 34 | $export->export(); |
| 35 | 35 | |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | -add_action( 'give_form_batch_export', 'give_process_batch_export_form' ); |
|
| 38 | +add_action('give_form_batch_export', 'give_process_batch_export_form'); |
|
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * Exports earnings for a specified time period |
@@ -46,14 +46,14 @@ discard block |
||
| 46 | 46 | * @return void |
| 47 | 47 | */ |
| 48 | 48 | function give_export_earnings() { |
| 49 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export-earnings.php'; |
|
| 49 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export-earnings.php'; |
|
| 50 | 50 | |
| 51 | 51 | $earnings_export = new Give_Earnings_Export(); |
| 52 | 52 | |
| 53 | 53 | $earnings_export->export(); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | -add_action( 'give_earnings_export', 'give_export_earnings' ); |
|
| 56 | +add_action('give_earnings_export', 'give_export_earnings'); |
|
| 57 | 57 | |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -66,14 +66,14 @@ discard block |
||
| 66 | 66 | * @return void |
| 67 | 67 | */ |
| 68 | 68 | function give_export_all_customers() { |
| 69 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export-customers.php'; |
|
| 69 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export-customers.php'; |
|
| 70 | 70 | |
| 71 | 71 | $customer_export = new Give_Donors_Export(); |
| 72 | 72 | |
| 73 | 73 | $customer_export->export(); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | -add_action( 'give_email_export', 'give_export_all_customers' ); |
|
| 76 | +add_action('give_email_export', 'give_export_all_customers'); |
|
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * Add a hook allowing extensions to register a hook on the batch export process |
@@ -82,22 +82,22 @@ discard block |
||
| 82 | 82 | * @return void |
| 83 | 83 | */ |
| 84 | 84 | function give_register_batch_exporters() { |
| 85 | - if ( is_admin() ) { |
|
| 86 | - do_action( 'give_register_batch_exporter' ); |
|
| 85 | + if (is_admin()) { |
|
| 86 | + do_action('give_register_batch_exporter'); |
|
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | -add_action( 'plugins_loaded', 'give_register_batch_exporters' ); |
|
| 90 | +add_action('plugins_loaded', 'give_register_batch_exporters'); |
|
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | 93 | * Register the payments batch exporter |
| 94 | 94 | * @since 1.5 |
| 95 | 95 | */ |
| 96 | 96 | function give_register_payments_batch_export() { |
| 97 | - add_action( 'give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1 ); |
|
| 97 | + add_action('give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | -add_action( 'give_register_batch_exporter', 'give_register_payments_batch_export', 10 ); |
|
| 100 | +add_action('give_register_batch_exporter', 'give_register_payments_batch_export', 10); |
|
| 101 | 101 | |
| 102 | 102 | /** |
| 103 | 103 | * Loads the payments batch process if needed |
@@ -108,10 +108,10 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @return void |
| 110 | 110 | */ |
| 111 | -function give_include_payments_batch_processor( $class ) { |
|
| 111 | +function give_include_payments_batch_processor($class) { |
|
| 112 | 112 | |
| 113 | - if ( 'Give_Batch_Payments_Export' === $class ) { |
|
| 114 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-payments.php'; |
|
| 113 | + if ('Give_Batch_Payments_Export' === $class) { |
|
| 114 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-payments.php'; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | } |
@@ -121,10 +121,10 @@ discard block |
||
| 121 | 121 | * @since 1.5.2 |
| 122 | 122 | */ |
| 123 | 123 | function give_register_customers_batch_export() { |
| 124 | - add_action( 'give_batch_export_class_include', 'give_include_customers_batch_processor', 10, 1 ); |
|
| 124 | + add_action('give_batch_export_class_include', 'give_include_customers_batch_processor', 10, 1); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | -add_action( 'give_register_batch_exporter', 'give_register_customers_batch_export', 10 ); |
|
| 127 | +add_action('give_register_batch_exporter', 'give_register_customers_batch_export', 10); |
|
| 128 | 128 | |
| 129 | 129 | /** |
| 130 | 130 | * Loads the customers batch process if needed |
@@ -135,10 +135,10 @@ discard block |
||
| 135 | 135 | * |
| 136 | 136 | * @return void |
| 137 | 137 | */ |
| 138 | -function give_include_customers_batch_processor( $class ) { |
|
| 138 | +function give_include_customers_batch_processor($class) { |
|
| 139 | 139 | |
| 140 | - if ( 'Give_Batch_Customers_Export' === $class ) { |
|
| 141 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-customers.php'; |
|
| 140 | + if ('Give_Batch_Customers_Export' === $class) { |
|
| 141 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-customers.php'; |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | } |
@@ -149,10 +149,10 @@ discard block |
||
| 149 | 149 | * @since 1.5 |
| 150 | 150 | */ |
| 151 | 151 | function give_register_forms_batch_export() { |
| 152 | - add_action( 'give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1 ); |
|
| 152 | + add_action('give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | -add_action( 'give_register_batch_exporter', 'give_register_forms_batch_export', 10 ); |
|
| 155 | +add_action('give_register_batch_exporter', 'give_register_forms_batch_export', 10); |
|
| 156 | 156 | |
| 157 | 157 | /** |
| 158 | 158 | * Loads the file downloads batch process if needed |
@@ -163,10 +163,10 @@ discard block |
||
| 163 | 163 | * |
| 164 | 164 | * @return void |
| 165 | 165 | */ |
| 166 | -function give_include_forms_batch_processor( $class ) { |
|
| 166 | +function give_include_forms_batch_processor($class) { |
|
| 167 | 167 | |
| 168 | - if ( 'Give_Batch_Forms_Export' === $class ) { |
|
| 169 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-forms.php'; |
|
| 168 | + if ('Give_Batch_Forms_Export' === $class) { |
|
| 169 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-forms.php'; |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | } |
| 173 | 173 | \ No newline at end of file |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | // Exit if accessed directly |
| 19 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 19 | +if ( ! defined('ABSPATH')) { |
|
| 20 | 20 | exit; |
| 21 | 21 | } |
| 22 | 22 | |
@@ -29,36 +29,36 @@ discard block |
||
| 29 | 29 | * @return void |
| 30 | 30 | */ |
| 31 | 31 | function give_reports_page() { |
| 32 | - $current_page = admin_url( 'edit.php?post_type=give_forms&page=give-reports' ); |
|
| 33 | - $active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'reports'; |
|
| 32 | + $current_page = admin_url('edit.php?post_type=give_forms&page=give-reports'); |
|
| 33 | + $active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'reports'; |
|
| 34 | 34 | ?> |
| 35 | 35 | <div class="wrap"> |
| 36 | 36 | <h1 class="nav-tab-wrapper"> |
| 37 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
| 37 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
| 38 | 38 | 'tab' => 'reports', |
| 39 | 39 | 'settings-updated' => false |
| 40 | - ), $current_page ) ); ?>" class="nav-tab <?php echo $active_tab == 'reports' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Reports', 'give' ); ?></a> |
|
| 41 | - <?php if ( current_user_can( 'export_give_reports' ) ) { ?> |
|
| 42 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
| 40 | + ), $current_page)); ?>" class="nav-tab <?php echo $active_tab == 'reports' ? 'nav-tab-active' : ''; ?>"><?php _e('Reports', 'give'); ?></a> |
|
| 41 | + <?php if (current_user_can('export_give_reports')) { ?> |
|
| 42 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
| 43 | 43 | 'tab' => 'export', |
| 44 | 44 | 'settings-updated' => false |
| 45 | - ), $current_page ) ); ?>" class="nav-tab <?php echo $active_tab == 'export' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Export', 'give' ); ?></a> |
|
| 45 | + ), $current_page)); ?>" class="nav-tab <?php echo $active_tab == 'export' ? 'nav-tab-active' : ''; ?>"><?php _e('Export', 'give'); ?></a> |
|
| 46 | 46 | <?php } ?> |
| 47 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
| 47 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
| 48 | 48 | 'tab' => 'logs', |
| 49 | 49 | 'settings-updated' => false |
| 50 | - ), $current_page ) ); ?>" class="nav-tab <?php echo $active_tab == 'logs' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Logs', 'give' ); ?></a> |
|
| 51 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
| 50 | + ), $current_page)); ?>" class="nav-tab <?php echo $active_tab == 'logs' ? 'nav-tab-active' : ''; ?>"><?php _e('Logs', 'give'); ?></a> |
|
| 51 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
| 52 | 52 | 'tab' => 'tools', |
| 53 | 53 | 'settings-updated' => false |
| 54 | - ), $current_page ) ); ?>" class="nav-tab <?php echo $active_tab == 'tools' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Tools', 'give' ); ?></a> |
|
| 55 | - <?php do_action( 'give_reports_tabs' ); ?> |
|
| 54 | + ), $current_page)); ?>" class="nav-tab <?php echo $active_tab == 'tools' ? 'nav-tab-active' : ''; ?>"><?php _e('Tools', 'give'); ?></a> |
|
| 55 | + <?php do_action('give_reports_tabs'); ?> |
|
| 56 | 56 | </h1> |
| 57 | 57 | |
| 58 | 58 | <?php |
| 59 | - do_action( 'give_reports_page_top' ); |
|
| 60 | - do_action( 'give_reports_tab_' . $active_tab ); |
|
| 61 | - do_action( 'give_reports_page_bottom' ); |
|
| 59 | + do_action('give_reports_page_top'); |
|
| 60 | + do_action('give_reports_tab_'.$active_tab); |
|
| 61 | + do_action('give_reports_page_bottom'); |
|
| 62 | 62 | ?> |
| 63 | 63 | </div><!-- .wrap --> |
| 64 | 64 | <?php |
@@ -72,13 +72,13 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | function give_reports_default_views() { |
| 74 | 74 | $views = array( |
| 75 | - 'earnings' => __( 'Income', 'give' ), |
|
| 75 | + 'earnings' => __('Income', 'give'), |
|
| 76 | 76 | 'forms' => give_get_forms_label_plural(), |
| 77 | - 'donors' => __( 'Donors', 'give' ), |
|
| 78 | - 'gateways' => __( 'Payment Methods', 'give' ) |
|
| 77 | + 'donors' => __('Donors', 'give'), |
|
| 78 | + 'gateways' => __('Payment Methods', 'give') |
|
| 79 | 79 | ); |
| 80 | 80 | |
| 81 | - $views = apply_filters( 'give_report_views', $views ); |
|
| 81 | + $views = apply_filters('give_report_views', $views); |
|
| 82 | 82 | |
| 83 | 83 | return $views; |
| 84 | 84 | } |
@@ -94,15 +94,15 @@ discard block |
||
| 94 | 94 | * @return string $view Report View |
| 95 | 95 | * |
| 96 | 96 | */ |
| 97 | -function give_get_reporting_view( $default = 'earnings' ) { |
|
| 97 | +function give_get_reporting_view($default = 'earnings') { |
|
| 98 | 98 | |
| 99 | - if ( ! isset( $_GET['view'] ) || ! in_array( $_GET['view'], array_keys( give_reports_default_views() ) ) ) { |
|
| 99 | + if ( ! isset($_GET['view']) || ! in_array($_GET['view'], array_keys(give_reports_default_views()))) { |
|
| 100 | 100 | $view = $default; |
| 101 | 101 | } else { |
| 102 | 102 | $view = $_GET['view']; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - return apply_filters( 'give_get_reporting_view', $view ); |
|
| 105 | + return apply_filters('give_get_reporting_view', $view); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
@@ -115,14 +115,14 @@ discard block |
||
| 115 | 115 | $current_view = 'earnings'; |
| 116 | 116 | $views = give_reports_default_views(); |
| 117 | 117 | |
| 118 | - if ( isset( $_GET['view'] ) && array_key_exists( $_GET['view'], $views ) ) { |
|
| 118 | + if (isset($_GET['view']) && array_key_exists($_GET['view'], $views)) { |
|
| 119 | 119 | $current_view = $_GET['view']; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - do_action( 'give_reports_view_' . $current_view ); |
|
| 122 | + do_action('give_reports_view_'.$current_view); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | -add_action( 'give_reports_tab_reports', 'give_reports_tab_reports' ); |
|
| 125 | +add_action('give_reports_tab_reports', 'give_reports_tab_reports'); |
|
| 126 | 126 | |
| 127 | 127 | /** |
| 128 | 128 | * Renders the Reports Page Views Drop Downs |
@@ -132,25 +132,25 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | function give_report_views() { |
| 134 | 134 | $views = give_reports_default_views(); |
| 135 | - $current_view = isset( $_GET['view'] ) ? $_GET['view'] : 'earnings'; |
|
| 136 | - do_action( 'give_report_view_actions_before' ); |
|
| 135 | + $current_view = isset($_GET['view']) ? $_GET['view'] : 'earnings'; |
|
| 136 | + do_action('give_report_view_actions_before'); |
|
| 137 | 137 | ?> |
| 138 | 138 | <form id="give-reports-filter" method="get"> |
| 139 | 139 | <select id="give-reports-view" name="view"> |
| 140 | - <option value="-1"><?php _e( 'Report Type', 'give' ); ?></option> |
|
| 141 | - <?php foreach ( $views as $view_id => $label ) : ?> |
|
| 142 | - <option value="<?php echo esc_attr( $view_id ); ?>" <?php selected( $view_id, $current_view ); ?>><?php echo $label; ?></option> |
|
| 140 | + <option value="-1"><?php _e('Report Type', 'give'); ?></option> |
|
| 141 | + <?php foreach ($views as $view_id => $label) : ?> |
|
| 142 | + <option value="<?php echo esc_attr($view_id); ?>" <?php selected($view_id, $current_view); ?>><?php echo $label; ?></option> |
|
| 143 | 143 | <?php endforeach; ?> |
| 144 | 144 | </select> |
| 145 | 145 | |
| 146 | - <?php do_action( 'give_report_view_actions' ); ?> |
|
| 146 | + <?php do_action('give_report_view_actions'); ?> |
|
| 147 | 147 | |
| 148 | 148 | <input type="hidden" name="post_type" value="give_forms"/> |
| 149 | 149 | <input type="hidden" name="page" value="give-reports"/> |
| 150 | - <?php submit_button( __( 'Show', 'give' ), 'secondary', 'submit', false ); ?> |
|
| 150 | + <?php submit_button(__('Show', 'give'), 'secondary', 'submit', false); ?> |
|
| 151 | 151 | </form> |
| 152 | 152 | <?php |
| 153 | - do_action( 'give_report_view_actions_after' ); |
|
| 153 | + do_action('give_report_view_actions_after'); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
@@ -163,18 +163,18 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | function give_reports_forms_table() { |
| 165 | 165 | |
| 166 | - if ( isset( $_GET['form-id'] ) ) { |
|
| 166 | + if (isset($_GET['form-id'])) { |
|
| 167 | 167 | return; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - include( dirname( __FILE__ ) . '/class-form-reports-table.php' ); |
|
| 170 | + include(dirname(__FILE__).'/class-form-reports-table.php'); |
|
| 171 | 171 | |
| 172 | 172 | $give_table = new Give_Form_Reports_Table(); |
| 173 | 173 | $give_table->prepare_items(); |
| 174 | 174 | $give_table->display(); |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | -add_action( 'give_reports_view_forms', 'give_reports_forms_table' ); |
|
| 177 | +add_action('give_reports_view_forms', 'give_reports_forms_table'); |
|
| 178 | 178 | |
| 179 | 179 | /** |
| 180 | 180 | * Renders the detailed report for a specific give form |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | * @return void |
| 184 | 184 | */ |
| 185 | 185 | function give_reports_form_details() { |
| 186 | - if ( ! isset( $_GET['form-id'] ) ) { |
|
| 186 | + if ( ! isset($_GET['form-id'])) { |
|
| 187 | 187 | return; |
| 188 | 188 | } |
| 189 | 189 | ?> |
@@ -191,14 +191,14 @@ discard block |
||
| 191 | 191 | <div class="actions bulkactions"> |
| 192 | 192 | <?php give_report_views(); ?> |
| 193 | 193 | |
| 194 | - <button onclick="history.go(-1);" class="button-secondary"><?php _e( 'Go Back', 'give' ); ?></button> |
|
| 194 | + <button onclick="history.go(-1);" class="button-secondary"><?php _e('Go Back', 'give'); ?></button> |
|
| 195 | 195 | </div> |
| 196 | 196 | </div> |
| 197 | 197 | <?php |
| 198 | - give_reports_graph_of_form( absint( $_GET['form-id'] ) ); |
|
| 198 | + give_reports_graph_of_form(absint($_GET['form-id'])); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | -add_action( 'give_reports_view_forms', 'give_reports_form_details' ); |
|
| 201 | +add_action('give_reports_view_forms', 'give_reports_form_details'); |
|
| 202 | 202 | |
| 203 | 203 | /** |
| 204 | 204 | * Renders the Reports Donors Table |
@@ -209,28 +209,28 @@ discard block |
||
| 209 | 209 | * @return void |
| 210 | 210 | */ |
| 211 | 211 | function give_reports_donors_table() { |
| 212 | - include( dirname( __FILE__ ) . '/class-donor-reports-table.php' ); |
|
| 212 | + include(dirname(__FILE__).'/class-donor-reports-table.php'); |
|
| 213 | 213 | |
| 214 | 214 | $give_table = new Give_Donor_Reports_Table(); |
| 215 | 215 | $give_table->prepare_items(); |
| 216 | 216 | ?> |
| 217 | 217 | <div class="wrap give-reports-donors-wrap"> |
| 218 | - <?php do_action( 'give_logs_donors_table_top' ); ?> |
|
| 219 | - <form id="give-donors-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-reports&view=donors' ); ?>"> |
|
| 218 | + <?php do_action('give_logs_donors_table_top'); ?> |
|
| 219 | + <form id="give-donors-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-reports&view=donors'); ?>"> |
|
| 220 | 220 | <?php |
| 221 | - $give_table->search_box( __( 'Search', 'give' ), 'give-donors' ); |
|
| 221 | + $give_table->search_box(__('Search', 'give'), 'give-donors'); |
|
| 222 | 222 | $give_table->display(); |
| 223 | 223 | ?> |
| 224 | 224 | <input type="hidden" name="post_type" value="give_forms"/> |
| 225 | 225 | <input type="hidden" name="page" value="give-reports"/> |
| 226 | 226 | <input type="hidden" name="view" value="donors"/> |
| 227 | 227 | </form> |
| 228 | - <?php do_action( 'give_logs_donors_table_bottom' ); ?> |
|
| 228 | + <?php do_action('give_logs_donors_table_bottom'); ?> |
|
| 229 | 229 | </div> |
| 230 | 230 | <?php |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | -add_action( 'give_reports_view_donors', 'give_reports_donors_table' ); |
|
| 233 | +add_action('give_reports_view_donors', 'give_reports_donors_table'); |
|
| 234 | 234 | |
| 235 | 235 | |
| 236 | 236 | /** |
@@ -242,14 +242,14 @@ discard block |
||
| 242 | 242 | * @return void |
| 243 | 243 | */ |
| 244 | 244 | function give_reports_gateways_table() { |
| 245 | - include( dirname( __FILE__ ) . '/class-gateways-reports-table.php' ); |
|
| 245 | + include(dirname(__FILE__).'/class-gateways-reports-table.php'); |
|
| 246 | 246 | |
| 247 | 247 | $give_table = new Give_Gateawy_Reports_Table(); |
| 248 | 248 | $give_table->prepare_items(); |
| 249 | 249 | $give_table->display(); |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | -add_action( 'give_reports_view_gateways', 'give_reports_gateways_table' ); |
|
| 252 | +add_action('give_reports_view_gateways', 'give_reports_gateways_table'); |
|
| 253 | 253 | |
| 254 | 254 | |
| 255 | 255 | /** |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | function give_reports_earnings() { |
| 262 | 262 | ?> |
| 263 | 263 | <div class="tablenav top reports-table-nav"> |
| 264 | - <h3 class="alignleft reports-earnings-title"><span><?php _e( 'Income Over Time', 'give' ); ?></span></h3> |
|
| 264 | + <h3 class="alignleft reports-earnings-title"><span><?php _e('Income Over Time', 'give'); ?></span></h3> |
|
| 265 | 265 | |
| 266 | 266 | <div class="alignright actions reports-views-wrap"><?php give_report_views(); ?></div> |
| 267 | 267 | </div> |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | give_reports_graph(); |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | -add_action( 'give_reports_view_earnings', 'give_reports_earnings' ); |
|
| 272 | +add_action('give_reports_view_earnings', 'give_reports_earnings'); |
|
| 273 | 273 | |
| 274 | 274 | |
| 275 | 275 | /** |
@@ -284,50 +284,50 @@ discard block |
||
| 284 | 284 | <div id="post-body"> |
| 285 | 285 | <div id="post-body-content"> |
| 286 | 286 | |
| 287 | - <?php do_action( 'give_reports_tab_export_content_top' ); ?> |
|
| 287 | + <?php do_action('give_reports_tab_export_content_top'); ?> |
|
| 288 | 288 | |
| 289 | 289 | <table class="widefat export-options-table give-table"> |
| 290 | 290 | <thead> |
| 291 | 291 | <tr> |
| 292 | - <th class="row-title"><?php _e( 'Export Type', 'give' ); ?></th> |
|
| 293 | - <th><?php _e( 'Export Options', 'give' ); ?></th> |
|
| 292 | + <th class="row-title"><?php _e('Export Type', 'give'); ?></th> |
|
| 293 | + <th><?php _e('Export Options', 'give'); ?></th> |
|
| 294 | 294 | </tr> |
| 295 | 295 | </thead> |
| 296 | 296 | <tbody> |
| 297 | - <?php do_action( 'give_reports_tab_export_table_top' ); ?> |
|
| 297 | + <?php do_action('give_reports_tab_export_table_top'); ?> |
|
| 298 | 298 | <tr class="give-export-pdf-sales-earnings"> |
| 299 | 299 | <td class="row-title"> |
| 300 | - <h3><span><?php _e( 'Export PDF of Donations and Income', 'give' ); ?></span></h3> |
|
| 300 | + <h3><span><?php _e('Export PDF of Donations and Income', 'give'); ?></span></h3> |
|
| 301 | 301 | |
| 302 | - <p><?php _e( 'Download a PDF of Donations and Income reports for all forms for the current year.', 'give' ); ?></p> |
|
| 302 | + <p><?php _e('Download a PDF of Donations and Income reports for all forms for the current year.', 'give'); ?></p> |
|
| 303 | 303 | </td> |
| 304 | 304 | <td> |
| 305 | - <a class="button" href="<?php echo wp_nonce_url( add_query_arg( array( 'give-action' => 'generate_pdf' ) ), 'give_generate_pdf' ); ?>"><?php _e( 'Generate PDF', 'give' ); ?></a> |
|
| 305 | + <a class="button" href="<?php echo wp_nonce_url(add_query_arg(array('give-action' => 'generate_pdf')), 'give_generate_pdf'); ?>"><?php _e('Generate PDF', 'give'); ?></a> |
|
| 306 | 306 | </td> |
| 307 | 307 | </tr> |
| 308 | 308 | <tr class="alternate give-export-sales-earnings"> |
| 309 | 309 | <td class="row-title"> |
| 310 | - <h3><span><?php _e( 'Export Income and Donation Stats', 'give' ); ?></span></h3> |
|
| 310 | + <h3><span><?php _e('Export Income and Donation Stats', 'give'); ?></span></h3> |
|
| 311 | 311 | |
| 312 | - <p><?php _e( 'Download a CSV of income and donations over time.', 'give' ); ?></p> |
|
| 312 | + <p><?php _e('Download a CSV of income and donations over time.', 'give'); ?></p> |
|
| 313 | 313 | </td> |
| 314 | 314 | <td> |
| 315 | 315 | <form method="post"> |
| 316 | - <?php echo Give()->html->year_dropdown( 'start_year' ); ?> |
|
| 317 | - <?php echo Give()->html->month_dropdown( 'start_month' ); ?> |
|
| 318 | - <?php echo _x( 'to', 'Date one to date two', 'give' ); ?> |
|
| 319 | - <?php echo Give()->html->year_dropdown( 'end_year' ); ?> |
|
| 320 | - <?php echo Give()->html->month_dropdown( 'end_month' ); ?> |
|
| 316 | + <?php echo Give()->html->year_dropdown('start_year'); ?> |
|
| 317 | + <?php echo Give()->html->month_dropdown('start_month'); ?> |
|
| 318 | + <?php echo _x('to', 'Date one to date two', 'give'); ?> |
|
| 319 | + <?php echo Give()->html->year_dropdown('end_year'); ?> |
|
| 320 | + <?php echo Give()->html->month_dropdown('end_month'); ?> |
|
| 321 | 321 | <input type="hidden" name="give-action" value="earnings_export"/> |
| 322 | - <input type="submit" value="<?php _e( 'Generate CSV', 'give' ); ?>" class="button-secondary"/> |
|
| 322 | + <input type="submit" value="<?php _e('Generate CSV', 'give'); ?>" class="button-secondary"/> |
|
| 323 | 323 | </form> |
| 324 | 324 | </td> |
| 325 | 325 | </tr> |
| 326 | 326 | <tr class="give-export-payment-history"> |
| 327 | 327 | <td class="row-title"> |
| 328 | - <h3><span><?php _e( 'Export Donation History', 'give' ); ?></span></h3> |
|
| 328 | + <h3><span><?php _e('Export Donation History', 'give'); ?></span></h3> |
|
| 329 | 329 | |
| 330 | - <p><?php _e( 'Download a CSV of all donations recorded.', 'give' ); ?></p> |
|
| 330 | + <p><?php _e('Download a CSV of all donations recorded.', 'give'); ?></p> |
|
| 331 | 331 | </td> |
| 332 | 332 | <td> |
| 333 | 333 | <form id="give-export-payments" class="give-export-form" method="post"> |
@@ -335,29 +335,29 @@ discard block |
||
| 335 | 335 | $args = array( |
| 336 | 336 | 'id' => 'give-payment-export-start', |
| 337 | 337 | 'name' => 'start', |
| 338 | - 'placeholder' => __( 'Start date', 'give' ) |
|
| 338 | + 'placeholder' => __('Start date', 'give') |
|
| 339 | 339 | ); |
| 340 | - echo Give()->html->date_field( $args ); ?> |
|
| 340 | + echo Give()->html->date_field($args); ?> |
|
| 341 | 341 | <?php |
| 342 | 342 | $args = array( |
| 343 | 343 | 'id' => 'give-payment-export-end', |
| 344 | 344 | 'name' => 'end', |
| 345 | - 'placeholder' => __( 'End date', 'give' ) |
|
| 345 | + 'placeholder' => __('End date', 'give') |
|
| 346 | 346 | ); |
| 347 | - echo Give()->html->date_field( $args ); ?> |
|
| 347 | + echo Give()->html->date_field($args); ?> |
|
| 348 | 348 | <select name="status"> |
| 349 | - <option value="any"><?php _e( 'All Statuses', 'give' ); ?></option> |
|
| 349 | + <option value="any"><?php _e('All Statuses', 'give'); ?></option> |
|
| 350 | 350 | <?php |
| 351 | 351 | $statuses = give_get_payment_statuses(); |
| 352 | - foreach ( $statuses as $status => $label ) { |
|
| 353 | - echo '<option value="' . $status . '">' . $label . '</option>'; |
|
| 352 | + foreach ($statuses as $status => $label) { |
|
| 353 | + echo '<option value="'.$status.'">'.$label.'</option>'; |
|
| 354 | 354 | } |
| 355 | 355 | ?> |
| 356 | 356 | </select> |
| 357 | - <?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?> |
|
| 357 | + <?php wp_nonce_field('give_ajax_export', 'give_ajax_export'); ?> |
|
| 358 | 358 | <input type="hidden" name="give-export-class" value="Give_Batch_Payments_Export"/> |
| 359 | 359 | <span> |
| 360 | - <input type="submit" value="<?php _e( 'Generate CSV', 'give' ); ?>" class="button-secondary"/> |
|
| 360 | + <input type="submit" value="<?php _e('Generate CSV', 'give'); ?>" class="button-secondary"/> |
|
| 361 | 361 | <span class="spinner"></span> |
| 362 | 362 | </span> |
| 363 | 363 | </form> |
@@ -366,9 +366,9 @@ discard block |
||
| 366 | 366 | </tr> |
| 367 | 367 | <tr class="alternate give-export-donors"> |
| 368 | 368 | <td class="row-title"> |
| 369 | - <h3><span><?php _e( 'Export Donors in CSV', 'give' ); ?></span></h3> |
|
| 369 | + <h3><span><?php _e('Export Donors in CSV', 'give'); ?></span></h3> |
|
| 370 | 370 | |
| 371 | - <p><?php _e( 'Download an export of donors for all donation forms or only those who have given to a particular form.', 'give' ); ?></p> |
|
| 371 | + <p><?php _e('Download an export of donors for all donation forms or only those who have given to a particular form.', 'give'); ?></p> |
|
| 372 | 372 | </td> |
| 373 | 373 | <td> |
| 374 | 374 | <form method="post" id="give_donor_export" class="give-export-form"> |
@@ -379,54 +379,54 @@ discard block |
||
| 379 | 379 | 'id' => 'give_customer_export_form', |
| 380 | 380 | 'chosen' => true |
| 381 | 381 | ); |
| 382 | - echo Give()->html->forms_dropdown( $args ); ?> |
|
| 382 | + echo Give()->html->forms_dropdown($args); ?> |
|
| 383 | 383 | |
| 384 | - <input type="submit" value="<?php _e( 'Generate CSV', 'give' ); ?>" class="button-secondary"/> |
|
| 384 | + <input type="submit" value="<?php _e('Generate CSV', 'give'); ?>" class="button-secondary"/> |
|
| 385 | 385 | |
| 386 | 386 | <div id="export-donor-options-wrap" class="give-clearfix"> |
| 387 | - <p><?php _e( 'Export Columns', 'give' ); ?>:</p> |
|
| 387 | + <p><?php _e('Export Columns', 'give'); ?>:</p> |
|
| 388 | 388 | <ul id="give-export-option-ul"> |
| 389 | 389 | <li> |
| 390 | - <label for="give-export-fullname"><input type="checkbox" checked name="give_export_option[full_name]" id="give-export-fullname"><?php _e( 'Name', 'give' ); ?> |
|
| 390 | + <label for="give-export-fullname"><input type="checkbox" checked name="give_export_option[full_name]" id="give-export-fullname"><?php _e('Name', 'give'); ?> |
|
| 391 | 391 | </label> |
| 392 | 392 | </li> |
| 393 | 393 | <li> |
| 394 | - <label for="give-export-email"><input type="checkbox" checked name="give_export_option[email]" id="give-export-email"><?php _e( 'Email', 'give' ); ?> |
|
| 394 | + <label for="give-export-email"><input type="checkbox" checked name="give_export_option[email]" id="give-export-email"><?php _e('Email', 'give'); ?> |
|
| 395 | 395 | </label> |
| 396 | 396 | </li> |
| 397 | 397 | <li> |
| 398 | - <label for="give-export-address"><input type="checkbox" checked name="give_export_option[address]" id="give-export-address"><?php _e( 'Address', 'give' ); ?> |
|
| 398 | + <label for="give-export-address"><input type="checkbox" checked name="give_export_option[address]" id="give-export-address"><?php _e('Address', 'give'); ?> |
|
| 399 | 399 | </label> |
| 400 | 400 | </li> |
| 401 | 401 | <li> |
| 402 | - <label for="give-export-userid"><input type="checkbox" checked name="give_export_option[userid]" id="give-export-userid"><?php _e( 'User ID', 'give' ); ?> |
|
| 402 | + <label for="give-export-userid"><input type="checkbox" checked name="give_export_option[userid]" id="give-export-userid"><?php _e('User ID', 'give'); ?> |
|
| 403 | 403 | </label> |
| 404 | 404 | </li> |
| 405 | 405 | <li> |
| 406 | - <label for="give-export-first-donation-date"><input type="checkbox" checked name="give_export_option[date_first_donated]" id="give-export-first-donation-date"><?php _e( 'First Donation Date', 'give' ); ?> |
|
| 406 | + <label for="give-export-first-donation-date"><input type="checkbox" checked name="give_export_option[date_first_donated]" id="give-export-first-donation-date"><?php _e('First Donation Date', 'give'); ?> |
|
| 407 | 407 | </label> |
| 408 | 408 | </li> |
| 409 | 409 | <li> |
| 410 | - <label for="give-export-donation-number"><input type="checkbox" checked name="give_export_option[donations]" id="give-export-donation-number"><?php _e( 'Number of Donations', 'give' ); ?> |
|
| 410 | + <label for="give-export-donation-number"><input type="checkbox" checked name="give_export_option[donations]" id="give-export-donation-number"><?php _e('Number of Donations', 'give'); ?> |
|
| 411 | 411 | </label> |
| 412 | 412 | </li> |
| 413 | 413 | <li> |
| 414 | - <label for="give-export-donation-sum"><input type="checkbox" checked name="give_export_option[donation_sum]" id="give-export-donation-sum"><?php _e( 'Total Donated', 'give' ); ?> |
|
| 414 | + <label for="give-export-donation-sum"><input type="checkbox" checked name="give_export_option[donation_sum]" id="give-export-donation-sum"><?php _e('Total Donated', 'give'); ?> |
|
| 415 | 415 | </label> |
| 416 | 416 | </li> |
| 417 | 417 | </ul> |
| 418 | 418 | </div> |
| 419 | - <?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?> |
|
| 419 | + <?php wp_nonce_field('give_ajax_export', 'give_ajax_export'); ?> |
|
| 420 | 420 | <input type="hidden" name="give-export-class" value="Give_Batch_Customers_Export"/> |
| 421 | 421 | <input type="hidden" name="give-action" value="email_export"/> |
| 422 | 422 | </form> |
| 423 | 423 | </td> |
| 424 | 424 | </tr> |
| 425 | - <?php do_action( 'give_reports_tab_export_table_bottom' ); ?> |
|
| 425 | + <?php do_action('give_reports_tab_export_table_bottom'); ?> |
|
| 426 | 426 | </tbody> |
| 427 | 427 | </table> |
| 428 | 428 | |
| 429 | - <?php do_action( 'give_reports_tab_export_content_bottom' ); ?> |
|
| 429 | + <?php do_action('give_reports_tab_export_content_bottom'); ?> |
|
| 430 | 430 | |
| 431 | 431 | </div> |
| 432 | 432 | <!-- .post-body-content --> |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | <?php |
| 437 | 437 | } |
| 438 | 438 | |
| 439 | -add_action( 'give_reports_tab_export', 'give_reports_tab_export' ); |
|
| 439 | +add_action('give_reports_tab_export', 'give_reports_tab_export'); |
|
| 440 | 440 | |
| 441 | 441 | /** |
| 442 | 442 | * Renders the Reports page |
@@ -446,19 +446,19 @@ discard block |
||
| 446 | 446 | */ |
| 447 | 447 | function give_reports_tab_logs() { |
| 448 | 448 | |
| 449 | - require( GIVE_PLUGIN_DIR . 'includes/admin/reporting/logs.php' ); |
|
| 449 | + require(GIVE_PLUGIN_DIR.'includes/admin/reporting/logs.php'); |
|
| 450 | 450 | |
| 451 | 451 | $current_view = 'sales'; |
| 452 | 452 | $log_views = give_log_default_views(); |
| 453 | 453 | |
| 454 | - if ( isset( $_GET['view'] ) && array_key_exists( $_GET['view'], $log_views ) ) { |
|
| 454 | + if (isset($_GET['view']) && array_key_exists($_GET['view'], $log_views)) { |
|
| 455 | 455 | $current_view = $_GET['view']; |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | - do_action( 'give_logs_view_' . $current_view ); |
|
| 458 | + do_action('give_logs_view_'.$current_view); |
|
| 459 | 459 | } |
| 460 | 460 | |
| 461 | -add_action( 'give_reports_tab_logs', 'give_reports_tab_logs' ); |
|
| 461 | +add_action('give_reports_tab_logs', 'give_reports_tab_logs'); |
|
| 462 | 462 | |
| 463 | 463 | /** |
| 464 | 464 | * Retrieves estimated monthly earnings and sales |
@@ -468,9 +468,9 @@ discard block |
||
| 468 | 468 | */ |
| 469 | 469 | function give_estimated_monthly_stats() { |
| 470 | 470 | |
| 471 | - $estimated = get_transient( 'give_estimated_monthly_stats' ); |
|
| 471 | + $estimated = get_transient('give_estimated_monthly_stats'); |
|
| 472 | 472 | |
| 473 | - if ( false === $estimated ) { |
|
| 473 | + if (false === $estimated) { |
|
| 474 | 474 | |
| 475 | 475 | $estimated = array( |
| 476 | 476 | 'earnings' => 0, |
@@ -479,20 +479,20 @@ discard block |
||
| 479 | 479 | |
| 480 | 480 | $stats = new Give_Payment_Stats; |
| 481 | 481 | |
| 482 | - $to_date_earnings = $stats->get_earnings( 0, 'this_month' ); |
|
| 483 | - $to_date_sales = $stats->get_sales( 0, 'this_month' ); |
|
| 482 | + $to_date_earnings = $stats->get_earnings(0, 'this_month'); |
|
| 483 | + $to_date_sales = $stats->get_sales(0, 'this_month'); |
|
| 484 | 484 | |
| 485 | - $current_day = date( 'd', current_time( 'timestamp' ) ); |
|
| 486 | - $current_month = date( 'n', current_time( 'timestamp' ) ); |
|
| 487 | - $current_year = date( 'Y', current_time( 'timestamp' ) ); |
|
| 488 | - $days_in_month = cal_days_in_month( CAL_GREGORIAN, $current_month, $current_year ); |
|
| 485 | + $current_day = date('d', current_time('timestamp')); |
|
| 486 | + $current_month = date('n', current_time('timestamp')); |
|
| 487 | + $current_year = date('Y', current_time('timestamp')); |
|
| 488 | + $days_in_month = cal_days_in_month(CAL_GREGORIAN, $current_month, $current_year); |
|
| 489 | 489 | |
| 490 | - $estimated['earnings'] = ( $to_date_earnings / $current_day ) * $days_in_month; |
|
| 491 | - $estimated['sales'] = ( $to_date_sales / $current_day ) * $days_in_month; |
|
| 490 | + $estimated['earnings'] = ($to_date_earnings / $current_day) * $days_in_month; |
|
| 491 | + $estimated['sales'] = ($to_date_sales / $current_day) * $days_in_month; |
|
| 492 | 492 | |
| 493 | 493 | // Cache for one day |
| 494 | - set_transient( 'give_estimated_monthly_stats', $estimated, 86400 ); |
|
| 494 | + set_transient('give_estimated_monthly_stats', $estimated, 86400); |
|
| 495 | 495 | } |
| 496 | 496 | |
| 497 | - return maybe_unserialize( $estimated ); |
|
| 497 | + return maybe_unserialize($estimated); |
|
| 498 | 498 | } |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * @since 1.3.0 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -defined( 'ABSPATH' ) or exit; |
|
| 12 | +defined('ABSPATH') or exit; |
|
| 13 | 13 | |
| 14 | 14 | class Give_Shortcode_Donation_Receipt extends Give_Shortcode_Generator { |
| 15 | 15 | |
@@ -18,10 +18,10 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | public function __construct() { |
| 20 | 20 | |
| 21 | - $this->shortcode['title'] = __( 'Donation Receipt', 'give' ); |
|
| 22 | - $this->shortcode['label'] = __( 'Donation Receipt', 'give' ); |
|
| 21 | + $this->shortcode['title'] = __('Donation Receipt', 'give'); |
|
| 22 | + $this->shortcode['label'] = __('Donation Receipt', 'give'); |
|
| 23 | 23 | |
| 24 | - parent::__construct( 'give_receipt' ); |
|
| 24 | + parent::__construct('give_receipt'); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -34,60 +34,60 @@ discard block |
||
| 34 | 34 | return array( |
| 35 | 35 | array( |
| 36 | 36 | 'type' => 'container', |
| 37 | - 'html' => sprintf( '<p class="strong">%s</p>', __( 'Optional settings', 'give' ) ), |
|
| 37 | + 'html' => sprintf('<p class="strong">%s</p>', __('Optional settings', 'give')), |
|
| 38 | 38 | ), |
| 39 | 39 | array( |
| 40 | 40 | 'type' => 'listbox', |
| 41 | 41 | 'name' => 'price', |
| 42 | - 'label' => __( 'Show Donation Amount:', 'give' ), |
|
| 42 | + 'label' => __('Show Donation Amount:', 'give'), |
|
| 43 | 43 | 'options' => array( |
| 44 | - 'true' => __( 'Show', 'give' ), |
|
| 45 | - 'false' => __( 'Hide', 'give' ), |
|
| 44 | + 'true' => __('Show', 'give'), |
|
| 45 | + 'false' => __('Hide', 'give'), |
|
| 46 | 46 | ), |
| 47 | 47 | ), |
| 48 | 48 | array( |
| 49 | 49 | 'type' => 'listbox', |
| 50 | 50 | 'name' => 'donor', |
| 51 | - 'label' => __( 'Show Donor Name:', 'give' ), |
|
| 51 | + 'label' => __('Show Donor Name:', 'give'), |
|
| 52 | 52 | 'options' => array( |
| 53 | - 'true' => __( 'Show', 'give' ), |
|
| 54 | - 'false' => __( 'Hide', 'give' ), |
|
| 53 | + 'true' => __('Show', 'give'), |
|
| 54 | + 'false' => __('Hide', 'give'), |
|
| 55 | 55 | ), |
| 56 | 56 | ), |
| 57 | 57 | array( |
| 58 | 58 | 'type' => 'listbox', |
| 59 | 59 | 'name' => 'date', |
| 60 | - 'label' => __( 'Show Date:', 'give' ), |
|
| 60 | + 'label' => __('Show Date:', 'give'), |
|
| 61 | 61 | 'options' => array( |
| 62 | - 'true' => __( 'Show', 'give' ), |
|
| 63 | - 'false' => __( 'Hide', 'give' ), |
|
| 62 | + 'true' => __('Show', 'give'), |
|
| 63 | + 'false' => __('Hide', 'give'), |
|
| 64 | 64 | ), |
| 65 | 65 | ), |
| 66 | 66 | array( |
| 67 | 67 | 'type' => 'listbox', |
| 68 | 68 | 'name' => 'payment_key', |
| 69 | - 'label' => __( 'Show Payment Key:', 'give' ), |
|
| 69 | + 'label' => __('Show Payment Key:', 'give'), |
|
| 70 | 70 | 'options' => array( |
| 71 | - 'true' => __( 'Show', 'give' ), |
|
| 72 | - 'false' => __( 'Hide', 'give' ), |
|
| 71 | + 'true' => __('Show', 'give'), |
|
| 72 | + 'false' => __('Hide', 'give'), |
|
| 73 | 73 | ), |
| 74 | 74 | ), |
| 75 | 75 | array( |
| 76 | 76 | 'type' => 'listbox', |
| 77 | 77 | 'name' => 'payment_method', |
| 78 | - 'label' => __( 'Show Payment Method:', 'give' ), |
|
| 78 | + 'label' => __('Show Payment Method:', 'give'), |
|
| 79 | 79 | 'options' => array( |
| 80 | - 'true' => __( 'Show', 'give' ), |
|
| 81 | - 'false' => __( 'Hide', 'give' ), |
|
| 80 | + 'true' => __('Show', 'give'), |
|
| 81 | + 'false' => __('Hide', 'give'), |
|
| 82 | 82 | ), |
| 83 | 83 | ), |
| 84 | 84 | array( |
| 85 | 85 | 'type' => 'listbox', |
| 86 | 86 | 'name' => 'payment_id', |
| 87 | - 'label' => __( 'Show Payment ID:', 'give' ), |
|
| 87 | + 'label' => __('Show Payment ID:', 'give'), |
|
| 88 | 88 | 'options' => array( |
| 89 | - 'true' => __( 'Show', 'give' ), |
|
| 90 | - 'false' => __( 'Hide', 'give' ), |
|
| 89 | + 'true' => __('Show', 'give'), |
|
| 90 | + 'false' => __('Hide', 'give'), |
|
| 91 | 91 | ), |
| 92 | 92 | ), |
| 93 | 93 | ); |
@@ -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,15 +23,15 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return array $output Response messages |
| 25 | 25 | */ |
| 26 | -function give_edit_customer( $args ) { |
|
| 26 | +function give_edit_customer($args) { |
|
| 27 | 27 | |
| 28 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
| 28 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
| 29 | 29 | |
| 30 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
| 31 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ) ); |
|
| 30 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
| 31 | + wp_die(__('You do not have permission to edit this donor.', 'give')); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - if ( empty( $args ) ) { |
|
| 34 | + if (empty($args)) { |
|
| 35 | 35 | return; |
| 36 | 36 | } |
| 37 | 37 | |
@@ -39,12 +39,12 @@ discard block |
||
| 39 | 39 | $customer_id = (int) $args['customerinfo']['id']; |
| 40 | 40 | $nonce = $args['_wpnonce']; |
| 41 | 41 | |
| 42 | - if ( ! wp_verify_nonce( $nonce, 'edit-customer' ) ) { |
|
| 43 | - wp_die( __( 'Cheatin\' eh?!', 'give' ) ); |
|
| 42 | + if ( ! wp_verify_nonce($nonce, 'edit-customer')) { |
|
| 43 | + wp_die(__('Cheatin\' eh?!', 'give')); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - $customer = new Give_Customer( $customer_id ); |
|
| 47 | - if ( empty( $customer->id ) ) { |
|
| 46 | + $customer = new Give_Customer($customer_id); |
|
| 47 | + if (empty($customer->id)) { |
|
| 48 | 48 | return false; |
| 49 | 49 | } |
| 50 | 50 | |
@@ -54,23 +54,23 @@ discard block |
||
| 54 | 54 | 'user_id' => 0 |
| 55 | 55 | ); |
| 56 | 56 | |
| 57 | - $customer_info = wp_parse_args( $customer_info, $defaults ); |
|
| 57 | + $customer_info = wp_parse_args($customer_info, $defaults); |
|
| 58 | 58 | |
| 59 | - if ( ! is_email( $customer_info['email'] ) ) { |
|
| 60 | - give_set_error( 'give-invalid-email', __( 'Please enter a valid email address.', 'give' ) ); |
|
| 59 | + if ( ! is_email($customer_info['email'])) { |
|
| 60 | + give_set_error('give-invalid-email', __('Please enter a valid email address.', 'give')); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - if ( (int) $customer_info['user_id'] != (int) $customer->user_id ) { |
|
| 63 | + if ((int) $customer_info['user_id'] != (int) $customer->user_id) { |
|
| 64 | 64 | |
| 65 | 65 | // Make sure we don't already have this user attached to a customer |
| 66 | - if ( ! empty( $customer_info['user_id'] ) && false !== Give()->customers->get_customer_by( 'user_id', $customer_info['user_id'] ) ) { |
|
| 67 | - give_set_error( 'give-invalid-customer-user_id', sprintf( __( 'The User ID %d is already associated with a different donor.', 'give' ), $customer_info['user_id'] ) ); |
|
| 66 | + if ( ! empty($customer_info['user_id']) && false !== Give()->customers->get_customer_by('user_id', $customer_info['user_id'])) { |
|
| 67 | + give_set_error('give-invalid-customer-user_id', sprintf(__('The User ID %d is already associated with a different donor.', 'give'), $customer_info['user_id'])); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | // Make sure it's actually a user |
| 71 | - $user = get_user_by( 'id', $customer_info['user_id'] ); |
|
| 72 | - if ( ! empty( $customer_info['user_id'] ) && false === $user ) { |
|
| 73 | - give_set_error( 'give-invalid-user_id', sprintf( __( 'The User ID %d does not exist. Please assign an existing user.', 'give' ), $customer_info['user_id'] ) ); |
|
| 71 | + $user = get_user_by('id', $customer_info['user_id']); |
|
| 72 | + if ( ! empty($customer_info['user_id']) && false === $user) { |
|
| 73 | + give_set_error('give-invalid-user_id', sprintf(__('The User ID %d does not exist. Please assign an existing user.', 'give'), $customer_info['user_id'])); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | } |
@@ -78,82 +78,82 @@ discard block |
||
| 78 | 78 | // Record this for later |
| 79 | 79 | $previous_user_id = $customer->user_id; |
| 80 | 80 | |
| 81 | - if ( give_get_errors() ) { |
|
| 81 | + if (give_get_errors()) { |
|
| 82 | 82 | return; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | // Setup the customer address, if present |
| 86 | 86 | $address = array(); |
| 87 | - if ( intval( $customer_info['user_id'] ) > 0 ) { |
|
| 87 | + if (intval($customer_info['user_id']) > 0) { |
|
| 88 | 88 | |
| 89 | - $current_address = get_user_meta( $customer_info['user_id'], '_give_user_address', true ); |
|
| 89 | + $current_address = get_user_meta($customer_info['user_id'], '_give_user_address', true); |
|
| 90 | 90 | |
| 91 | - if ( false === $current_address ) { |
|
| 92 | - $address['line1'] = isset( $customer_info['line1'] ) ? $customer_info['line1'] : ''; |
|
| 93 | - $address['line2'] = isset( $customer_info['line2'] ) ? $customer_info['line2'] : ''; |
|
| 94 | - $address['city'] = isset( $customer_info['city'] ) ? $customer_info['city'] : ''; |
|
| 95 | - $address['country'] = isset( $customer_info['country'] ) ? $customer_info['country'] : ''; |
|
| 96 | - $address['zip'] = isset( $customer_info['zip'] ) ? $customer_info['zip'] : ''; |
|
| 97 | - $address['state'] = isset( $customer_info['state'] ) ? $customer_info['state'] : ''; |
|
| 91 | + if (false === $current_address) { |
|
| 92 | + $address['line1'] = isset($customer_info['line1']) ? $customer_info['line1'] : ''; |
|
| 93 | + $address['line2'] = isset($customer_info['line2']) ? $customer_info['line2'] : ''; |
|
| 94 | + $address['city'] = isset($customer_info['city']) ? $customer_info['city'] : ''; |
|
| 95 | + $address['country'] = isset($customer_info['country']) ? $customer_info['country'] : ''; |
|
| 96 | + $address['zip'] = isset($customer_info['zip']) ? $customer_info['zip'] : ''; |
|
| 97 | + $address['state'] = isset($customer_info['state']) ? $customer_info['state'] : ''; |
|
| 98 | 98 | } else { |
| 99 | - $current_address = wp_parse_args( $current_address, array( |
|
| 99 | + $current_address = wp_parse_args($current_address, array( |
|
| 100 | 100 | 'line1', |
| 101 | 101 | 'line2', |
| 102 | 102 | 'city', |
| 103 | 103 | 'zip', |
| 104 | 104 | 'state', |
| 105 | 105 | 'country' |
| 106 | - ) ); |
|
| 107 | - $address['line1'] = isset( $customer_info['line1'] ) ? $customer_info['line1'] : $current_address['line1']; |
|
| 108 | - $address['line2'] = isset( $customer_info['line2'] ) ? $customer_info['line2'] : $current_address['line2']; |
|
| 109 | - $address['city'] = isset( $customer_info['city'] ) ? $customer_info['city'] : $current_address['city']; |
|
| 110 | - $address['country'] = isset( $customer_info['country'] ) ? $customer_info['country'] : $current_address['country']; |
|
| 111 | - $address['zip'] = isset( $customer_info['zip'] ) ? $customer_info['zip'] : $current_address['zip']; |
|
| 112 | - $address['state'] = isset( $customer_info['state'] ) ? $customer_info['state'] : $current_address['state']; |
|
| 106 | + )); |
|
| 107 | + $address['line1'] = isset($customer_info['line1']) ? $customer_info['line1'] : $current_address['line1']; |
|
| 108 | + $address['line2'] = isset($customer_info['line2']) ? $customer_info['line2'] : $current_address['line2']; |
|
| 109 | + $address['city'] = isset($customer_info['city']) ? $customer_info['city'] : $current_address['city']; |
|
| 110 | + $address['country'] = isset($customer_info['country']) ? $customer_info['country'] : $current_address['country']; |
|
| 111 | + $address['zip'] = isset($customer_info['zip']) ? $customer_info['zip'] : $current_address['zip']; |
|
| 112 | + $address['state'] = isset($customer_info['state']) ? $customer_info['state'] : $current_address['state']; |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | // Sanitize the inputs |
| 118 | 118 | $customer_data = array(); |
| 119 | - $customer_data['name'] = strip_tags( stripslashes( $customer_info['name'] ) ); |
|
| 119 | + $customer_data['name'] = strip_tags(stripslashes($customer_info['name'])); |
|
| 120 | 120 | $customer_data['email'] = $customer_info['email']; |
| 121 | 121 | $customer_data['user_id'] = $customer_info['user_id']; |
| 122 | 122 | |
| 123 | - $customer_data = apply_filters( 'give_edit_customer_info', $customer_data, $customer_id ); |
|
| 124 | - $address = apply_filters( 'give_edit_customer_address', $address, $customer_id ); |
|
| 123 | + $customer_data = apply_filters('give_edit_customer_info', $customer_data, $customer_id); |
|
| 124 | + $address = apply_filters('give_edit_customer_address', $address, $customer_id); |
|
| 125 | 125 | |
| 126 | - $customer_data = array_map( 'sanitize_text_field', $customer_data ); |
|
| 127 | - $address = array_map( 'sanitize_text_field', $address ); |
|
| 126 | + $customer_data = array_map('sanitize_text_field', $customer_data); |
|
| 127 | + $address = array_map('sanitize_text_field', $address); |
|
| 128 | 128 | |
| 129 | - do_action( 'give_pre_edit_customer', $customer_id, $customer_data, $address ); |
|
| 129 | + do_action('give_pre_edit_customer', $customer_id, $customer_data, $address); |
|
| 130 | 130 | |
| 131 | 131 | $output = array(); |
| 132 | 132 | $previous_email = $customer->email; |
| 133 | 133 | |
| 134 | - if ( $customer->update( $customer_data ) ) { |
|
| 134 | + if ($customer->update($customer_data)) { |
|
| 135 | 135 | |
| 136 | - if ( ! empty( $customer->user_id ) && $customer->user_id > 0 ) { |
|
| 137 | - update_user_meta( $customer->user_id, '_give_user_address', $address ); |
|
| 136 | + if ( ! empty($customer->user_id) && $customer->user_id > 0) { |
|
| 137 | + update_user_meta($customer->user_id, '_give_user_address', $address); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | // Update some payment meta if we need to |
| 141 | - $payments_array = explode( ',', $customer->payment_ids ); |
|
| 141 | + $payments_array = explode(',', $customer->payment_ids); |
|
| 142 | 142 | |
| 143 | - if ( $customer->email != $previous_email ) { |
|
| 144 | - foreach ( $payments_array as $payment_id ) { |
|
| 145 | - give_update_payment_meta( $payment_id, 'email', $customer->email ); |
|
| 143 | + if ($customer->email != $previous_email) { |
|
| 144 | + foreach ($payments_array as $payment_id) { |
|
| 145 | + give_update_payment_meta($payment_id, 'email', $customer->email); |
|
| 146 | 146 | } |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - if ( $customer->user_id != $previous_user_id ) { |
|
| 150 | - foreach ( $payments_array as $payment_id ) { |
|
| 151 | - give_update_payment_meta( $payment_id, '_give_payment_user_id', $customer->user_id ); |
|
| 149 | + if ($customer->user_id != $previous_user_id) { |
|
| 150 | + foreach ($payments_array as $payment_id) { |
|
| 151 | + give_update_payment_meta($payment_id, '_give_payment_user_id', $customer->user_id); |
|
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | $output['success'] = true; |
| 156 | - $customer_data = array_merge( $customer_data, $address ); |
|
| 156 | + $customer_data = array_merge($customer_data, $address); |
|
| 157 | 157 | $output['customer_info'] = $customer_data; |
| 158 | 158 | |
| 159 | 159 | } else { |
@@ -162,11 +162,11 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - do_action( 'give_post_edit_customer', $customer_id, $customer_data ); |
|
| 165 | + do_action('give_post_edit_customer', $customer_id, $customer_data); |
|
| 166 | 166 | |
| 167 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
| 168 | - header( 'Content-Type: application/json' ); |
|
| 169 | - echo json_encode( $output ); |
|
| 167 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 168 | + header('Content-Type: application/json'); |
|
| 169 | + echo json_encode($output); |
|
| 170 | 170 | wp_die(); |
| 171 | 171 | } |
| 172 | 172 | |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | -add_action( 'give_edit-customer', 'give_edit_customer', 10, 1 ); |
|
| 177 | +add_action('give_edit-customer', 'give_edit_customer', 10, 1); |
|
| 178 | 178 | |
| 179 | 179 | /** |
| 180 | 180 | * Save a customer note being added |
@@ -185,53 +185,53 @@ discard block |
||
| 185 | 185 | * |
| 186 | 186 | * @return int The Note ID that was saved, or 0 if nothing was saved |
| 187 | 187 | */ |
| 188 | -function give_customer_save_note( $args ) { |
|
| 188 | +function give_customer_save_note($args) { |
|
| 189 | 189 | |
| 190 | - $customer_view_role = apply_filters( 'give_view_customers_role', 'view_give_reports' ); |
|
| 190 | + $customer_view_role = apply_filters('give_view_customers_role', 'view_give_reports'); |
|
| 191 | 191 | |
| 192 | - if ( ! is_admin() || ! current_user_can( $customer_view_role ) ) { |
|
| 193 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ) ); |
|
| 192 | + if ( ! is_admin() || ! current_user_can($customer_view_role)) { |
|
| 193 | + wp_die(__('You do not have permission to edit this donor.', 'give')); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - if ( empty( $args ) ) { |
|
| 196 | + if (empty($args)) { |
|
| 197 | 197 | return; |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - $customer_note = trim( sanitize_text_field( $args['customer_note'] ) ); |
|
| 200 | + $customer_note = trim(sanitize_text_field($args['customer_note'])); |
|
| 201 | 201 | $customer_id = (int) $args['customer_id']; |
| 202 | 202 | $nonce = $args['add_customer_note_nonce']; |
| 203 | 203 | |
| 204 | - if ( ! wp_verify_nonce( $nonce, 'add-customer-note' ) ) { |
|
| 205 | - wp_die( __( 'Cheatin\' eh?!', 'give' ) ); |
|
| 204 | + if ( ! wp_verify_nonce($nonce, 'add-customer-note')) { |
|
| 205 | + wp_die(__('Cheatin\' eh?!', 'give')); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - if ( empty( $customer_note ) ) { |
|
| 209 | - give_set_error( 'empty-customer-note', __( 'A note is required', 'give' ) ); |
|
| 208 | + if (empty($customer_note)) { |
|
| 209 | + give_set_error('empty-customer-note', __('A note is required', 'give')); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - if ( give_get_errors() ) { |
|
| 212 | + if (give_get_errors()) { |
|
| 213 | 213 | return; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - $customer = new Give_Customer( $customer_id ); |
|
| 217 | - $new_note = $customer->add_note( $customer_note ); |
|
| 216 | + $customer = new Give_Customer($customer_id); |
|
| 217 | + $new_note = $customer->add_note($customer_note); |
|
| 218 | 218 | |
| 219 | - do_action( 'give_pre_insert_customer_note', $customer_id, $new_note ); |
|
| 219 | + do_action('give_pre_insert_customer_note', $customer_id, $new_note); |
|
| 220 | 220 | |
| 221 | - if ( ! empty( $new_note ) && ! empty( $customer->id ) ) { |
|
| 221 | + if ( ! empty($new_note) && ! empty($customer->id)) { |
|
| 222 | 222 | |
| 223 | 223 | ob_start(); |
| 224 | 224 | ?> |
| 225 | 225 | <div class="customer-note-wrapper dashboard-comment-wrap comment-item"> |
| 226 | 226 | <span class="note-content-wrap"> |
| 227 | - <?php echo stripslashes( $new_note ); ?> |
|
| 227 | + <?php echo stripslashes($new_note); ?> |
|
| 228 | 228 | </span> |
| 229 | 229 | </div> |
| 230 | 230 | <?php |
| 231 | 231 | $output = ob_get_contents(); |
| 232 | 232 | ob_end_clean(); |
| 233 | 233 | |
| 234 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
| 234 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 235 | 235 | echo $output; |
| 236 | 236 | exit; |
| 237 | 237 | } |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | -add_action( 'give_add-customer-note', 'give_customer_save_note', 10, 1 ); |
|
| 247 | +add_action('give_add-customer-note', 'give_customer_save_note', 10, 1); |
|
| 248 | 248 | |
| 249 | 249 | /** |
| 250 | 250 | * Delete a customer |
@@ -255,87 +255,87 @@ discard block |
||
| 255 | 255 | * |
| 256 | 256 | * @return int Whether it was a successful deletion |
| 257 | 257 | */ |
| 258 | -function give_customer_delete( $args ) { |
|
| 258 | +function give_customer_delete($args) { |
|
| 259 | 259 | |
| 260 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
| 260 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
| 261 | 261 | |
| 262 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
| 263 | - wp_die( __( 'You do not have permission to delete this donor.', 'give' ) ); |
|
| 262 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
| 263 | + wp_die(__('You do not have permission to delete this donor.', 'give')); |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - if ( empty( $args ) ) { |
|
| 266 | + if (empty($args)) { |
|
| 267 | 267 | return; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | $customer_id = (int) $args['customer_id']; |
| 271 | - $confirm = ! empty( $args['give-customer-delete-confirm'] ) ? true : false; |
|
| 272 | - $remove_data = ! empty( $args['give-customer-delete-records'] ) ? true : false; |
|
| 271 | + $confirm = ! empty($args['give-customer-delete-confirm']) ? true : false; |
|
| 272 | + $remove_data = ! empty($args['give-customer-delete-records']) ? true : false; |
|
| 273 | 273 | $nonce = $args['_wpnonce']; |
| 274 | 274 | |
| 275 | - if ( ! wp_verify_nonce( $nonce, 'delete-customer' ) ) { |
|
| 276 | - wp_die( __( 'Cheatin\' eh?!', 'give' ) ); |
|
| 275 | + if ( ! wp_verify_nonce($nonce, 'delete-customer')) { |
|
| 276 | + wp_die(__('Cheatin\' eh?!', 'give')); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - if ( ! $confirm ) { |
|
| 280 | - give_set_error( 'customer-delete-no-confirm', __( 'Please confirm you want to delete this donor', 'give' ) ); |
|
| 279 | + if ( ! $confirm) { |
|
| 280 | + give_set_error('customer-delete-no-confirm', __('Please confirm you want to delete this donor', 'give')); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - if ( give_get_errors() ) { |
|
| 284 | - wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer_id ) ); |
|
| 283 | + if (give_get_errors()) { |
|
| 284 | + wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer_id)); |
|
| 285 | 285 | exit; |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - $customer = new Give_Customer( $customer_id ); |
|
| 288 | + $customer = new Give_Customer($customer_id); |
|
| 289 | 289 | |
| 290 | - do_action( 'give_pre_delete_customer', $customer_id, $confirm, $remove_data ); |
|
| 290 | + do_action('give_pre_delete_customer', $customer_id, $confirm, $remove_data); |
|
| 291 | 291 | |
| 292 | 292 | $success = false; |
| 293 | 293 | |
| 294 | - if ( $customer->id > 0 ) { |
|
| 294 | + if ($customer->id > 0) { |
|
| 295 | 295 | |
| 296 | - $payments_array = explode( ',', $customer->payment_ids ); |
|
| 297 | - $success = Give()->customers->delete( $customer->id ); |
|
| 296 | + $payments_array = explode(',', $customer->payment_ids); |
|
| 297 | + $success = Give()->customers->delete($customer->id); |
|
| 298 | 298 | |
| 299 | - if ( $success ) { |
|
| 299 | + if ($success) { |
|
| 300 | 300 | |
| 301 | - if ( $remove_data ) { |
|
| 301 | + if ($remove_data) { |
|
| 302 | 302 | |
| 303 | 303 | // Remove all payments, logs, etc |
| 304 | - foreach ( $payments_array as $payment_id ) { |
|
| 305 | - give_delete_purchase( $payment_id ); |
|
| 304 | + foreach ($payments_array as $payment_id) { |
|
| 305 | + give_delete_purchase($payment_id); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | } else { |
| 309 | 309 | |
| 310 | 310 | // Just set the payments to customer_id of 0 |
| 311 | - foreach ( $payments_array as $payment_id ) { |
|
| 312 | - give_update_payment_meta( $payment_id, '_give_payment_customer_id', 0 ); |
|
| 311 | + foreach ($payments_array as $payment_id) { |
|
| 312 | + give_update_payment_meta($payment_id, '_give_payment_customer_id', 0); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted' ); |
|
| 317 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted'); |
|
| 318 | 318 | |
| 319 | 319 | } else { |
| 320 | 320 | |
| 321 | - give_set_error( 'give-donor-delete-failed', __( 'Error deleting donor', 'give' ) ); |
|
| 322 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $customer_id ); |
|
| 321 | + give_set_error('give-donor-delete-failed', __('Error deleting donor', 'give')); |
|
| 322 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$customer_id); |
|
| 323 | 323 | |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | } else { |
| 327 | 327 | |
| 328 | - give_set_error( 'give-customer-delete-invalid-id', __( 'Invalid Donor ID', 'give' ) ); |
|
| 329 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); |
|
| 328 | + give_set_error('give-customer-delete-invalid-id', __('Invalid Donor ID', 'give')); |
|
| 329 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors'); |
|
| 330 | 330 | |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - wp_redirect( $redirect ); |
|
| 333 | + wp_redirect($redirect); |
|
| 334 | 334 | exit; |
| 335 | 335 | |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | -add_action( 'give_delete-customer', 'give_customer_delete', 10, 1 ); |
|
| 338 | +add_action('give_delete-customer', 'give_customer_delete', 10, 1); |
|
| 339 | 339 | |
| 340 | 340 | /** |
| 341 | 341 | * Disconnect a user ID from a donor |
@@ -346,39 +346,39 @@ discard block |
||
| 346 | 346 | * |
| 347 | 347 | * @return bool If the disconnect was successful |
| 348 | 348 | */ |
| 349 | -function give_disconnect_customer_user_id( $args ) { |
|
| 349 | +function give_disconnect_customer_user_id($args) { |
|
| 350 | 350 | |
| 351 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
| 351 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
| 352 | 352 | |
| 353 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
| 354 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ) ); |
|
| 353 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
| 354 | + wp_die(__('You do not have permission to edit this donor.', 'give')); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - if ( empty( $args ) ) { |
|
| 357 | + if (empty($args)) { |
|
| 358 | 358 | return; |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | $customer_id = (int) $args['customer_id']; |
| 362 | 362 | $nonce = $args['_wpnonce']; |
| 363 | 363 | |
| 364 | - if ( ! wp_verify_nonce( $nonce, 'edit-customer' ) ) { |
|
| 365 | - wp_die( __( 'Cheatin\' eh?!', 'give' ) ); |
|
| 364 | + if ( ! wp_verify_nonce($nonce, 'edit-customer')) { |
|
| 365 | + wp_die(__('Cheatin\' eh?!', 'give')); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - $customer = new Give_Customer( $customer_id ); |
|
| 369 | - if ( empty( $customer->id ) ) { |
|
| 368 | + $customer = new Give_Customer($customer_id); |
|
| 369 | + if (empty($customer->id)) { |
|
| 370 | 370 | return false; |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - do_action( 'give_pre_customer_disconnect_user_id', $customer_id, $customer->user_id ); |
|
| 373 | + do_action('give_pre_customer_disconnect_user_id', $customer_id, $customer->user_id); |
|
| 374 | 374 | |
| 375 | - $customer_args = array( 'user_id' => 0 ); |
|
| 375 | + $customer_args = array('user_id' => 0); |
|
| 376 | 376 | |
| 377 | - if ( $customer->update( $customer_args ) ) { |
|
| 377 | + if ($customer->update($customer_args)) { |
|
| 378 | 378 | global $wpdb; |
| 379 | 379 | |
| 380 | - if ( ! empty( $customer->payment_ids ) ) { |
|
| 381 | - $wpdb->query( "UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $customer->payment_ids )" ); |
|
| 380 | + if ( ! empty($customer->payment_ids)) { |
|
| 381 | + $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $customer->payment_ids )"); |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | $output['success'] = true; |
@@ -386,14 +386,14 @@ discard block |
||
| 386 | 386 | } else { |
| 387 | 387 | |
| 388 | 388 | $output['success'] = false; |
| 389 | - give_set_error( 'give-disconnect-user-fail', __( 'Failed to disconnect user from donor', 'give' ) ); |
|
| 389 | + give_set_error('give-disconnect-user-fail', __('Failed to disconnect user from donor', 'give')); |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - do_action( 'give_post_customer_disconnect_user_id', $customer_id ); |
|
| 392 | + do_action('give_post_customer_disconnect_user_id', $customer_id); |
|
| 393 | 393 | |
| 394 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
| 395 | - header( 'Content-Type: application/json' ); |
|
| 396 | - echo json_encode( $output ); |
|
| 394 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 395 | + header('Content-Type: application/json'); |
|
| 396 | + echo json_encode($output); |
|
| 397 | 397 | wp_die(); |
| 398 | 398 | } |
| 399 | 399 | |
@@ -401,4 +401,4 @@ discard block |
||
| 401 | 401 | |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | -add_action( 'give_disconnect-userid', 'give_disconnect_customer_user_id', 10, 1 ); |
|
| 404 | +add_action('give_disconnect-userid', 'give_disconnect_customer_user_id', 10, 1); |
|