@@ -245,7 +245,7 @@ |
||
| 245 | 245 | |
| 246 | 246 | // Continue if donor already included. |
| 247 | 247 | if ( empty( $payment->customer_id ) || |
| 248 | - in_array( $payment->customer_id, $cached_donor_ids ) |
|
| 248 | + in_array( $payment->customer_id, $cached_donor_ids ) |
|
| 249 | 249 | ) { |
| 250 | 250 | continue; |
| 251 | 251 | } |
@@ -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 | |
@@ -70,12 +70,12 @@ discard block |
||
| 70 | 70 | * |
| 71 | 71 | * @param int $_step |
| 72 | 72 | */ |
| 73 | - public function __construct( $_step = 1 ) { |
|
| 73 | + public function __construct($_step = 1) { |
|
| 74 | 74 | |
| 75 | - parent::__construct( $_step ); |
|
| 75 | + parent::__construct($_step); |
|
| 76 | 76 | |
| 77 | 77 | // Filter to change the filename. |
| 78 | - add_filter( 'give_export_filename', array( $this, 'give_export_filename' ), 10, 2 ); |
|
| 78 | + add_filter('give_export_filename', array($this, 'give_export_filename'), 10, 2); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
@@ -88,19 +88,19 @@ discard block |
||
| 88 | 88 | * |
| 89 | 89 | * @return string $filename file name. |
| 90 | 90 | */ |
| 91 | - public function give_export_filename( $filename, $export_type ) { |
|
| 91 | + public function give_export_filename($filename, $export_type) { |
|
| 92 | 92 | |
| 93 | - if ( $this->export_type !== $export_type ) { |
|
| 93 | + if ($this->export_type !== $export_type) { |
|
| 94 | 94 | return $filename; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - $forms = empty( $_GET['forms'] ) ? 0 : absint( $_GET['forms'] ); |
|
| 97 | + $forms = empty($_GET['forms']) ? 0 : absint($_GET['forms']); |
|
| 98 | 98 | |
| 99 | - if ( $forms ) { |
|
| 100 | - $slug = get_post_field( 'post_name', get_post( $forms ) ); |
|
| 101 | - $filename = 'give-export-donors-' . $slug . '-' . date( 'm-d-Y' ); |
|
| 99 | + if ($forms) { |
|
| 100 | + $slug = get_post_field('post_name', get_post($forms)); |
|
| 101 | + $filename = 'give-export-donors-'.$slug.'-'.date('m-d-Y'); |
|
| 102 | 102 | } else { |
| 103 | - $filename = 'give-export-donors-all-forms-' . date( 'm-d-Y' ); |
|
| 103 | + $filename = 'give-export-donors-all-forms-'.date('m-d-Y'); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | return $filename; |
@@ -113,23 +113,23 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @param array $request The Form Data passed into the batch processing |
| 115 | 115 | */ |
| 116 | - public function set_properties( $request ) { |
|
| 116 | + public function set_properties($request) { |
|
| 117 | 117 | |
| 118 | 118 | // Set data from form submission |
| 119 | - if ( isset( $_POST['form'] ) ) { |
|
| 120 | - parse_str( $_POST['form'], $this->data ); |
|
| 119 | + if (isset($_POST['form'])) { |
|
| 120 | + parse_str($_POST['form'], $this->data); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | $this->form = $this->data['forms']; |
| 124 | 124 | |
| 125 | 125 | // Setup donor ids cache. |
| 126 | - if ( ! empty( $this->form ) ) { |
|
| 126 | + if ( ! empty($this->form)) { |
|
| 127 | 127 | // Cache donor ids to output unique list of donor. |
| 128 | - $this->query_id = give_clean( $_REQUEST['give_export_option']['query_id'] ); |
|
| 128 | + $this->query_id = give_clean($_REQUEST['give_export_option']['query_id']); |
|
| 129 | 129 | $this->cache_donor_ids(); |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - $this->price_id = ! empty( $request['give_price_option'] ) && 'all' !== $request['give_price_option'] ? absint( $request['give_price_option'] ) : null; |
|
| 132 | + $this->price_id = ! empty($request['give_price_option']) && 'all' !== $request['give_price_option'] ? absint($request['give_price_option']) : null; |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
@@ -142,12 +142,12 @@ discard block |
||
| 142 | 142 | // Fetch already cached donor ids. |
| 143 | 143 | $donor_ids = $this->donor_ids; |
| 144 | 144 | |
| 145 | - if ( $cached_donor_ids = Give_Cache::get( $this->query_id, true ) ) { |
|
| 146 | - $donor_ids = array_unique( array_merge( $cached_donor_ids, $this->donor_ids ) ); |
|
| 145 | + if ($cached_donor_ids = Give_Cache::get($this->query_id, true)) { |
|
| 146 | + $donor_ids = array_unique(array_merge($cached_donor_ids, $this->donor_ids)); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - $donor_ids = array_values( $donor_ids ); |
|
| 150 | - Give_Cache::set( $this->query_id, $donor_ids, HOUR_IN_SECONDS, true ); |
|
| 149 | + $donor_ids = array_values($donor_ids); |
|
| 150 | + Give_Cache::set($this->query_id, $donor_ids, HOUR_IN_SECONDS, true); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | /** |
@@ -159,14 +159,14 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | public function csv_cols() { |
| 161 | 161 | |
| 162 | - $columns = isset( $this->data['give_export_option'] ) ? $this->data['give_export_option'] : array(); |
|
| 162 | + $columns = isset($this->data['give_export_option']) ? $this->data['give_export_option'] : array(); |
|
| 163 | 163 | |
| 164 | 164 | // We need columns. |
| 165 | - if ( empty( $columns ) ) { |
|
| 165 | + if (empty($columns)) { |
|
| 166 | 166 | return false; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - $cols = $this->get_cols( $columns ); |
|
| 169 | + $cols = $this->get_cols($columns); |
|
| 170 | 170 | |
| 171 | 171 | return $cols; |
| 172 | 172 | } |
@@ -178,38 +178,38 @@ discard block |
||
| 178 | 178 | * |
| 179 | 179 | * @return array |
| 180 | 180 | */ |
| 181 | - private function get_cols( $columns ) { |
|
| 181 | + private function get_cols($columns) { |
|
| 182 | 182 | |
| 183 | 183 | $cols = array(); |
| 184 | 184 | |
| 185 | - foreach ( $columns as $key => $value ) { |
|
| 185 | + foreach ($columns as $key => $value) { |
|
| 186 | 186 | |
| 187 | - switch ( $key ) { |
|
| 187 | + switch ($key) { |
|
| 188 | 188 | case 'full_name' : |
| 189 | - $cols['full_name'] = esc_html__( 'Full Name', 'give' ); |
|
| 189 | + $cols['full_name'] = esc_html__('Full Name', 'give'); |
|
| 190 | 190 | break; |
| 191 | 191 | case 'email' : |
| 192 | - $cols['email'] = esc_html__( 'Email Address', 'give' ); |
|
| 192 | + $cols['email'] = esc_html__('Email Address', 'give'); |
|
| 193 | 193 | break; |
| 194 | 194 | case 'address' : |
| 195 | - $cols['address_line1'] = esc_html__( 'Address', 'give' ); |
|
| 196 | - $cols['address_line2'] = esc_html__( 'Address 2', 'give' ); |
|
| 197 | - $cols['address_city'] = esc_html__( 'City', 'give' ); |
|
| 198 | - $cols['address_state'] = esc_html__( 'State', 'give' ); |
|
| 199 | - $cols['address_zip'] = esc_html__( 'Zip', 'give' ); |
|
| 200 | - $cols['address_country'] = esc_html__( 'Country', 'give' ); |
|
| 195 | + $cols['address_line1'] = esc_html__('Address', 'give'); |
|
| 196 | + $cols['address_line2'] = esc_html__('Address 2', 'give'); |
|
| 197 | + $cols['address_city'] = esc_html__('City', 'give'); |
|
| 198 | + $cols['address_state'] = esc_html__('State', 'give'); |
|
| 199 | + $cols['address_zip'] = esc_html__('Zip', 'give'); |
|
| 200 | + $cols['address_country'] = esc_html__('Country', 'give'); |
|
| 201 | 201 | break; |
| 202 | 202 | case 'userid' : |
| 203 | - $cols['userid'] = esc_html__( 'User ID', 'give' ); |
|
| 203 | + $cols['userid'] = esc_html__('User ID', 'give'); |
|
| 204 | 204 | break; |
| 205 | 205 | case 'donor_created_date' : |
| 206 | - $cols['donor_created_date'] = esc_html__( 'Donor Created Date', 'give' ); |
|
| 206 | + $cols['donor_created_date'] = esc_html__('Donor Created Date', 'give'); |
|
| 207 | 207 | break; |
| 208 | 208 | case 'donations' : |
| 209 | - $cols['donations'] = esc_html__( 'Number of Donations', 'give' ); |
|
| 209 | + $cols['donations'] = esc_html__('Number of Donations', 'give'); |
|
| 210 | 210 | break; |
| 211 | 211 | case 'donation_sum' : |
| 212 | - $cols['donation_sum'] = esc_html__( 'Sum of Donations', 'give' ); |
|
| 212 | + $cols['donation_sum'] = esc_html__('Sum of Donations', 'give'); |
|
| 213 | 213 | break; |
| 214 | 214 | } |
| 215 | 215 | } |
@@ -230,29 +230,29 @@ discard block |
||
| 230 | 230 | $i = 0; |
| 231 | 231 | |
| 232 | 232 | $data = array(); |
| 233 | - $cached_donor_ids = Give_Cache::get( $this->query_id, true ); |
|
| 233 | + $cached_donor_ids = Give_Cache::get($this->query_id, true); |
|
| 234 | 234 | |
| 235 | - if ( ! empty( $this->form ) ) { |
|
| 235 | + if ( ! empty($this->form)) { |
|
| 236 | 236 | |
| 237 | 237 | // Export donors for a specific donation form and also within specified timeframe |
| 238 | 238 | $args = array( |
| 239 | 239 | 'output' => 'payments', // Use 'posts' to get standard post objects |
| 240 | - 'post_type' => array( 'give_payment' ), |
|
| 240 | + 'post_type' => array('give_payment'), |
|
| 241 | 241 | 'number' => 30, |
| 242 | 242 | 'paged' => $this->step, |
| 243 | 243 | 'status' => 'publish', |
| 244 | 244 | 'meta_key' => '_give_payment_form_id', |
| 245 | - 'meta_value' => absint( $this->form ), |
|
| 245 | + 'meta_value' => absint($this->form), |
|
| 246 | 246 | ); |
| 247 | 247 | |
| 248 | 248 | // Check for date option filter |
| 249 | - if ( ! empty( $this->data['donor_export_start_date'] ) || ! empty( $this->data['donor_export_end_date'] ) ) { |
|
| 250 | - $args['start_date'] = ! empty( $this->data['donor_export_start_date'] ) ? date( 'Y-n-d 00:00:00', strtotime( $this->data['donor_export_start_date'] ) ) : date( 'Y-n-d 23:59:59', '1970-1-01 00:00:00' ); |
|
| 251 | - $args['end_date'] = ! empty( $this->data['donor_export_end_date'] ) ? date( 'Y-n-d 23:59:59', strtotime( $this->data['donor_export_end_date'] ) ) : date( 'Y-n-d 23:59:59', current_time( 'timestamp' ) ); |
|
| 249 | + if ( ! empty($this->data['donor_export_start_date']) || ! empty($this->data['donor_export_end_date'])) { |
|
| 250 | + $args['start_date'] = ! empty($this->data['donor_export_start_date']) ? date('Y-n-d 00:00:00', strtotime($this->data['donor_export_start_date'])) : date('Y-n-d 23:59:59', '1970-1-01 00:00:00'); |
|
| 251 | + $args['end_date'] = ! empty($this->data['donor_export_end_date']) ? date('Y-n-d 23:59:59', strtotime($this->data['donor_export_end_date'])) : date('Y-n-d 23:59:59', current_time('timestamp')); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | // Check for price option. |
| 255 | - if ( null !== $this->price_id ) { |
|
| 255 | + if (null !== $this->price_id) { |
|
| 256 | 256 | $args['meta_query'] = array( |
| 257 | 257 | array( |
| 258 | 258 | 'key' => '_give_payment_price_id', |
@@ -261,44 +261,42 @@ discard block |
||
| 261 | 261 | ); |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - $payments_query = new Give_Payments_Query( $args ); |
|
| 264 | + $payments_query = new Give_Payments_Query($args); |
|
| 265 | 265 | $payments = $payments_query->get_payments(); |
| 266 | 266 | |
| 267 | - if ( $payments ) { |
|
| 267 | + if ($payments) { |
|
| 268 | 268 | /* @var Give_Payment $payment */ |
| 269 | - foreach ( $payments as $payment ) { |
|
| 269 | + foreach ($payments as $payment) { |
|
| 270 | 270 | // Set donation sum. |
| 271 | - $this->payment_stats[ $payment->customer_id ]['donation_sum'] = isset( $this->payment_stats[ $payment->customer_id ]['donation_sum'] ) ? |
|
| 272 | - $this->payment_stats[ $payment->customer_id ]['donation_sum'] : |
|
| 273 | - 0; |
|
| 274 | - $this->payment_stats[ $payment->customer_id ]['donation_sum'] += $payment->total; |
|
| 271 | + $this->payment_stats[$payment->customer_id]['donation_sum'] = isset($this->payment_stats[$payment->customer_id]['donation_sum']) ? |
|
| 272 | + $this->payment_stats[$payment->customer_id]['donation_sum'] : 0; |
|
| 273 | + $this->payment_stats[$payment->customer_id]['donation_sum'] += $payment->total; |
|
| 275 | 274 | |
| 276 | 275 | // Set donation count. |
| 277 | - $this->payment_stats[ $payment->customer_id ]['donations'] = isset( $this->payment_stats[ $payment->customer_id ]['donations'] ) ? |
|
| 278 | - ++ $this->payment_stats[ $payment->customer_id ]['donations'] : |
|
| 279 | - 1; |
|
| 276 | + $this->payment_stats[$payment->customer_id]['donations'] = isset($this->payment_stats[$payment->customer_id]['donations']) ? |
|
| 277 | + ++$this->payment_stats[$payment->customer_id]['donations'] : 1; |
|
| 280 | 278 | |
| 281 | 279 | // Set donation form name. |
| 282 | - $this->payment_stats[ $payment->customer_id ]['form_title'] = $payment->form_title; |
|
| 280 | + $this->payment_stats[$payment->customer_id]['form_title'] = $payment->form_title; |
|
| 283 | 281 | |
| 284 | 282 | // Continue if donor already included. |
| 285 | - if ( empty( $payment->customer_id ) || |
|
| 286 | - in_array( $payment->customer_id, $cached_donor_ids ) |
|
| 283 | + if (empty($payment->customer_id) || |
|
| 284 | + in_array($payment->customer_id, $cached_donor_ids) |
|
| 287 | 285 | ) { |
| 288 | 286 | continue; |
| 289 | 287 | } |
| 290 | 288 | |
| 291 | 289 | $this->donor_ids[] = $cached_donor_ids[] = $payment->customer_id; |
| 292 | 290 | |
| 293 | - $i ++; |
|
| 291 | + $i++; |
|
| 294 | 292 | } |
| 295 | 293 | |
| 296 | - if ( ! empty( $this->donor_ids ) ) { |
|
| 297 | - foreach ( $this->donor_ids as $donor_id ) { |
|
| 298 | - $donor = Give()->donors->get_donor_by( 'id', $donor_id ); |
|
| 299 | - $donor->purchase_count = $this->payment_stats[ $donor_id ]['donations']; |
|
| 300 | - $donor->purchase_value = $this->payment_stats[ $donor_id ]['donation_sum']; |
|
| 301 | - $data[] = $this->set_donor_data( $i, $data, $donor ); |
|
| 294 | + if ( ! empty($this->donor_ids)) { |
|
| 295 | + foreach ($this->donor_ids as $donor_id) { |
|
| 296 | + $donor = Give()->donors->get_donor_by('id', $donor_id); |
|
| 297 | + $donor->purchase_count = $this->payment_stats[$donor_id]['donations']; |
|
| 298 | + $donor->purchase_value = $this->payment_stats[$donor_id]['donation_sum']; |
|
| 299 | + $data[] = $this->set_donor_data($i, $data, $donor); |
|
| 302 | 300 | } |
| 303 | 301 | |
| 304 | 302 | // Cache donor ids only if admin export donor for specific form. |
@@ -308,7 +306,7 @@ discard block |
||
| 308 | 306 | } else { |
| 309 | 307 | |
| 310 | 308 | // Export all donors. |
| 311 | - $offset = 30 * ( $this->step - 1 ); |
|
| 309 | + $offset = 30 * ($this->step - 1); |
|
| 312 | 310 | |
| 313 | 311 | $args = array( |
| 314 | 312 | 'number' => 30, |
@@ -316,29 +314,29 @@ discard block |
||
| 316 | 314 | ); |
| 317 | 315 | |
| 318 | 316 | // Check for date option filter |
| 319 | - if ( ! empty( $this->data['donor_export_start_date'] ) || ! empty( $this->data['donor_export_end_date'] ) ) { |
|
| 317 | + if ( ! empty($this->data['donor_export_start_date']) || ! empty($this->data['donor_export_end_date'])) { |
|
| 320 | 318 | $args['date'] = array( |
| 321 | - 'start' => ! empty( $this->data['donor_export_start_date'] ) ? date( 'Y-n-d 00:00:00', strtotime( $this->data['donor_export_start_date'] ) ) : date( 'Y-n-d 23:59:59', '1970-1-01 00:00:00' ), |
|
| 322 | - 'end' => ! empty( $this->data['donor_export_end_date'] ) ? date( 'Y-n-d 23:59:59', strtotime( $this->data['donor_export_end_date'] ) ) : date( 'Y-n-d 23:59:59', current_time( 'timestamp' ) ), |
|
| 319 | + 'start' => ! empty($this->data['donor_export_start_date']) ? date('Y-n-d 00:00:00', strtotime($this->data['donor_export_start_date'])) : date('Y-n-d 23:59:59', '1970-1-01 00:00:00'), |
|
| 320 | + 'end' => ! empty($this->data['donor_export_end_date']) ? date('Y-n-d 23:59:59', strtotime($this->data['donor_export_end_date'])) : date('Y-n-d 23:59:59', current_time('timestamp')), |
|
| 323 | 321 | ); |
| 324 | 322 | } |
| 325 | 323 | |
| 326 | - $donors = Give()->donors->get_donors( $args ); |
|
| 324 | + $donors = Give()->donors->get_donors($args); |
|
| 327 | 325 | |
| 328 | - foreach ( $donors as $donor ) { |
|
| 326 | + foreach ($donors as $donor) { |
|
| 329 | 327 | |
| 330 | 328 | // Continue if donor already included. |
| 331 | - if ( empty( $donor->id ) || empty( $donor->payment_ids ) ) { |
|
| 329 | + if (empty($donor->id) || empty($donor->payment_ids)) { |
|
| 332 | 330 | continue; |
| 333 | 331 | } |
| 334 | 332 | |
| 335 | - $data[] = $this->set_donor_data( $i, $data, $donor ); |
|
| 336 | - $i ++; |
|
| 333 | + $data[] = $this->set_donor_data($i, $data, $donor); |
|
| 334 | + $i++; |
|
| 337 | 335 | } |
| 338 | 336 | }// End if(). |
| 339 | 337 | |
| 340 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
| 341 | - $data = apply_filters( "give_export_get_data_{$this->export_type}", $data ); |
|
| 338 | + $data = apply_filters('give_export_get_data', $data); |
|
| 339 | + $data = apply_filters("give_export_get_data_{$this->export_type}", $data); |
|
| 342 | 340 | |
| 343 | 341 | return $data; |
| 344 | 342 | } |
@@ -354,18 +352,18 @@ discard block |
||
| 354 | 352 | $percentage = 0; |
| 355 | 353 | |
| 356 | 354 | // We can't count the number when getting them for a specific form. |
| 357 | - if ( empty( $this->form ) ) { |
|
| 355 | + if (empty($this->form)) { |
|
| 358 | 356 | |
| 359 | 357 | $total = Give()->donors->count(); |
| 360 | 358 | |
| 361 | - if ( $total > 0 ) { |
|
| 359 | + if ($total > 0) { |
|
| 362 | 360 | |
| 363 | - $percentage = ( ( 30 * $this->step ) / $total ) * 100; |
|
| 361 | + $percentage = ((30 * $this->step) / $total) * 100; |
|
| 364 | 362 | |
| 365 | 363 | } |
| 366 | 364 | } |
| 367 | 365 | |
| 368 | - if ( $percentage > 100 ) { |
|
| 366 | + if ($percentage > 100) { |
|
| 369 | 367 | $percentage = 100; |
| 370 | 368 | } |
| 371 | 369 | |
@@ -381,49 +379,49 @@ discard block |
||
| 381 | 379 | * |
| 382 | 380 | * @return mixed |
| 383 | 381 | */ |
| 384 | - private function set_donor_data( $i, $data, $donor ) { |
|
| 382 | + private function set_donor_data($i, $data, $donor) { |
|
| 385 | 383 | |
| 386 | 384 | $columns = $this->csv_cols(); |
| 387 | 385 | |
| 388 | 386 | // Set address variable. |
| 389 | 387 | $address = ''; |
| 390 | - if ( isset( $donor->user_id ) && $donor->user_id > 0 ) { |
|
| 391 | - $address = give_get_donor_address( $donor->user_id ); |
|
| 388 | + if (isset($donor->user_id) && $donor->user_id > 0) { |
|
| 389 | + $address = give_get_donor_address($donor->user_id); |
|
| 392 | 390 | } |
| 393 | 391 | |
| 394 | 392 | // Set columns |
| 395 | - if ( ! empty( $columns['full_name'] ) ) { |
|
| 396 | - $donor_name = give_get_donor_name_by( $donor->id, 'donor' ); |
|
| 397 | - $data[ $i ]['full_name'] = $donor_name; |
|
| 393 | + if ( ! empty($columns['full_name'])) { |
|
| 394 | + $donor_name = give_get_donor_name_by($donor->id, 'donor'); |
|
| 395 | + $data[$i]['full_name'] = $donor_name; |
|
| 398 | 396 | } |
| 399 | - if ( ! empty( $columns['email'] ) ) { |
|
| 400 | - $data[ $i ]['email'] = $donor->email; |
|
| 397 | + if ( ! empty($columns['email'])) { |
|
| 398 | + $data[$i]['email'] = $donor->email; |
|
| 401 | 399 | } |
| 402 | - if ( ! empty( $columns['address_line1'] ) ) { |
|
| 403 | - |
|
| 404 | - $data[ $i ]['address_line1'] = isset( $address['line1'] ) ? $address['line1'] : ''; |
|
| 405 | - $data[ $i ]['address_line2'] = isset( $address['line2'] ) ? $address['line2'] : ''; |
|
| 406 | - $data[ $i ]['address_city'] = isset( $address['city'] ) ? $address['city'] : ''; |
|
| 407 | - $data[ $i ]['address_state'] = isset( $address['state'] ) ? $address['state'] : ''; |
|
| 408 | - $data[ $i ]['address_zip'] = isset( $address['zip'] ) ? $address['zip'] : ''; |
|
| 409 | - $data[ $i ]['address_country'] = isset( $address['country'] ) ? $address['country'] : ''; |
|
| 400 | + if ( ! empty($columns['address_line1'])) { |
|
| 401 | + |
|
| 402 | + $data[$i]['address_line1'] = isset($address['line1']) ? $address['line1'] : ''; |
|
| 403 | + $data[$i]['address_line2'] = isset($address['line2']) ? $address['line2'] : ''; |
|
| 404 | + $data[$i]['address_city'] = isset($address['city']) ? $address['city'] : ''; |
|
| 405 | + $data[$i]['address_state'] = isset($address['state']) ? $address['state'] : ''; |
|
| 406 | + $data[$i]['address_zip'] = isset($address['zip']) ? $address['zip'] : ''; |
|
| 407 | + $data[$i]['address_country'] = isset($address['country']) ? $address['country'] : ''; |
|
| 410 | 408 | } |
| 411 | - if ( ! empty( $columns['userid'] ) ) { |
|
| 412 | - $data[ $i ]['userid'] = ! empty( $donor->user_id ) ? $donor->user_id : ''; |
|
| 409 | + if ( ! empty($columns['userid'])) { |
|
| 410 | + $data[$i]['userid'] = ! empty($donor->user_id) ? $donor->user_id : ''; |
|
| 413 | 411 | } |
| 414 | - if ( ! empty( $columns['donor_created_date'] ) ) { |
|
| 415 | - $data[ $i ]['donor_created_date'] = date_i18n( give_date_format(), strtotime( $donor->date_created ) ); |
|
| 412 | + if ( ! empty($columns['donor_created_date'])) { |
|
| 413 | + $data[$i]['donor_created_date'] = date_i18n(give_date_format(), strtotime($donor->date_created)); |
|
| 416 | 414 | } |
| 417 | - if ( ! empty( $columns['donations'] ) ) { |
|
| 418 | - $data[ $i ]['donations'] = $donor->purchase_count; |
|
| 415 | + if ( ! empty($columns['donations'])) { |
|
| 416 | + $data[$i]['donations'] = $donor->purchase_count; |
|
| 419 | 417 | } |
| 420 | - if ( ! empty( $columns['donation_sum'] ) ) { |
|
| 421 | - $data[ $i ]['donation_sum'] = give_format_amount( $donor->purchase_value, array( 'sanitize' => false ) ); |
|
| 418 | + if ( ! empty($columns['donation_sum'])) { |
|
| 419 | + $data[$i]['donation_sum'] = give_format_amount($donor->purchase_value, array('sanitize' => false)); |
|
| 422 | 420 | } |
| 423 | 421 | |
| 424 | - $data[ $i ] = apply_filters( 'give_export_set_donor_data', $data[ $i ], $donor ); |
|
| 422 | + $data[$i] = apply_filters('give_export_set_donor_data', $data[$i], $donor); |
|
| 425 | 423 | |
| 426 | - return $data[ $i ]; |
|
| 424 | + return $data[$i]; |
|
| 427 | 425 | |
| 428 | 426 | } |
| 429 | 427 | |
@@ -433,9 +431,9 @@ discard block |
||
| 433 | 431 | * @param array $request |
| 434 | 432 | * @param Give_Batch_Export $export |
| 435 | 433 | */ |
| 436 | - public function unset_properties( $request, $export ) { |
|
| 437 | - if ( $export->done ) { |
|
| 438 | - Give_Cache::delete( "give_cache_{$this->query_id}" ); |
|
| 434 | + public function unset_properties($request, $export) { |
|
| 435 | + if ($export->done) { |
|
| 436 | + Give_Cache::delete("give_cache_{$this->query_id}"); |
|
| 439 | 437 | } |
| 440 | 438 | } |
| 441 | 439 | } |
| 442 | 440 | \ No newline at end of file |
@@ -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 | |
@@ -118,14 +118,14 @@ discard block |
||
| 118 | 118 | * |
| 119 | 119 | * @param int $_step |
| 120 | 120 | */ |
| 121 | - public function __construct( $_step = 1 ) { |
|
| 121 | + public function __construct($_step = 1) { |
|
| 122 | 122 | |
| 123 | 123 | $upload_dir = wp_upload_dir(); |
| 124 | 124 | $this->filetype = '.csv'; |
| 125 | - $this->filename = 'give-' . $this->export_type . $this->filetype; |
|
| 126 | - $this->file = trailingslashit( $upload_dir['basedir'] ) . $this->filename; |
|
| 125 | + $this->filename = 'give-'.$this->export_type.$this->filetype; |
|
| 126 | + $this->file = trailingslashit($upload_dir['basedir']).$this->filename; |
|
| 127 | 127 | |
| 128 | - if ( ! is_writeable( $upload_dir['basedir'] ) ) { |
|
| 128 | + if ( ! is_writeable($upload_dir['basedir'])) { |
|
| 129 | 129 | $this->is_writable = false; |
| 130 | 130 | } |
| 131 | 131 | |
@@ -141,22 +141,22 @@ discard block |
||
| 141 | 141 | */ |
| 142 | 142 | public function process_step() { |
| 143 | 143 | |
| 144 | - if ( ! $this->can_export() ) { |
|
| 145 | - wp_die( esc_html__( 'You do not have permission to export data.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
| 144 | + if ( ! $this->can_export()) { |
|
| 145 | + wp_die(esc_html__('You do not have permission to export data.', 'give'), esc_html__('Error', 'give'), array( |
|
| 146 | 146 | 'response' => 403, |
| 147 | - ) ); |
|
| 147 | + )); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - if ( $this->step < 2 ) { |
|
| 150 | + if ($this->step < 2) { |
|
| 151 | 151 | |
| 152 | 152 | // Make sure we start with a fresh file on step 1. |
| 153 | - @unlink( $this->file ); |
|
| 153 | + @unlink($this->file); |
|
| 154 | 154 | $this->print_csv_cols(); |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | $rows = $this->print_csv_rows(); |
| 158 | 158 | |
| 159 | - if ( $rows ) { |
|
| 159 | + if ($rows) { |
|
| 160 | 160 | return true; |
| 161 | 161 | } else { |
| 162 | 162 | return false; |
@@ -176,14 +176,14 @@ discard block |
||
| 176 | 176 | $col_data = ''; |
| 177 | 177 | $cols = $this->get_csv_cols(); |
| 178 | 178 | $i = 1; |
| 179 | - foreach ( $cols as $col_id => $column ) { |
|
| 180 | - $col_data .= '"' . addslashes( $column ) . '"'; |
|
| 181 | - $col_data .= $i == count( $cols ) ? '' : ','; |
|
| 182 | - $i ++; |
|
| 179 | + foreach ($cols as $col_id => $column) { |
|
| 180 | + $col_data .= '"'.addslashes($column).'"'; |
|
| 181 | + $col_data .= $i == count($cols) ? '' : ','; |
|
| 182 | + $i++; |
|
| 183 | 183 | } |
| 184 | 184 | $col_data .= "\r\n"; |
| 185 | 185 | |
| 186 | - $this->stash_step_data( $col_data ); |
|
| 186 | + $this->stash_step_data($col_data); |
|
| 187 | 187 | |
| 188 | 188 | return $col_data; |
| 189 | 189 | |
@@ -202,23 +202,23 @@ discard block |
||
| 202 | 202 | $data = $this->get_data(); |
| 203 | 203 | $cols = $this->get_csv_cols(); |
| 204 | 204 | |
| 205 | - if ( $data ) { |
|
| 205 | + if ($data) { |
|
| 206 | 206 | |
| 207 | 207 | // Output each row |
| 208 | - foreach ( $data as $row ) { |
|
| 208 | + foreach ($data as $row) { |
|
| 209 | 209 | $i = 1; |
| 210 | - foreach ( $row as $col_id => $column ) { |
|
| 210 | + foreach ($row as $col_id => $column) { |
|
| 211 | 211 | // Make sure the column is valid |
| 212 | - if ( array_key_exists( $col_id, $cols ) ) { |
|
| 213 | - $row_data .= '"' . addslashes( preg_replace( '/"/', "'", $column ) ) . '"'; |
|
| 214 | - $row_data .= $i == count( $cols ) ? '' : ','; |
|
| 215 | - $i ++; |
|
| 212 | + if (array_key_exists($col_id, $cols)) { |
|
| 213 | + $row_data .= '"'.addslashes(preg_replace('/"/', "'", $column)).'"'; |
|
| 214 | + $row_data .= $i == count($cols) ? '' : ','; |
|
| 215 | + $i++; |
|
| 216 | 216 | } |
| 217 | 217 | } |
| 218 | 218 | $row_data .= "\r\n"; |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - $this->stash_step_data( $row_data ); |
|
| 221 | + $this->stash_step_data($row_data); |
|
| 222 | 222 | |
| 223 | 223 | return $row_data; |
| 224 | 224 | } |
@@ -246,18 +246,18 @@ discard block |
||
| 246 | 246 | |
| 247 | 247 | $file = ''; |
| 248 | 248 | |
| 249 | - if ( @file_exists( $this->file ) ) { |
|
| 249 | + if (@file_exists($this->file)) { |
|
| 250 | 250 | |
| 251 | - if ( ! is_writeable( $this->file ) ) { |
|
| 251 | + if ( ! is_writeable($this->file)) { |
|
| 252 | 252 | $this->is_writable = false; |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | - $file = @file_get_contents( $this->file ); |
|
| 255 | + $file = @file_get_contents($this->file); |
|
| 256 | 256 | |
| 257 | 257 | } else { |
| 258 | 258 | |
| 259 | - @file_put_contents( $this->file, '' ); |
|
| 260 | - @chmod( $this->file, 0664 ); |
|
| 259 | + @file_put_contents($this->file, ''); |
|
| 260 | + @chmod($this->file, 0664); |
|
| 261 | 261 | |
| 262 | 262 | } |
| 263 | 263 | |
@@ -273,18 +273,18 @@ discard block |
||
| 273 | 273 | * |
| 274 | 274 | * @return void |
| 275 | 275 | */ |
| 276 | - protected function stash_step_data( $data = '' ) { |
|
| 276 | + protected function stash_step_data($data = '') { |
|
| 277 | 277 | |
| 278 | 278 | $file = $this->get_file(); |
| 279 | 279 | $file .= $data; |
| 280 | - @file_put_contents( $this->file, $file ); |
|
| 280 | + @file_put_contents($this->file, $file); |
|
| 281 | 281 | |
| 282 | 282 | // If we have no rows after this step, mark it as an empty export. |
| 283 | - $file_rows = file( $this->file, FILE_SKIP_EMPTY_LINES ); |
|
| 283 | + $file_rows = file($this->file, FILE_SKIP_EMPTY_LINES); |
|
| 284 | 284 | $default_cols = $this->get_csv_cols(); |
| 285 | - $default_cols = empty( $default_cols ) ? 0 : 1; |
|
| 285 | + $default_cols = empty($default_cols) ? 0 : 1; |
|
| 286 | 286 | |
| 287 | - $this->is_empty = count( $file_rows ) == $default_cols ? true : false; |
|
| 287 | + $this->is_empty = count($file_rows) == $default_cols ? true : false; |
|
| 288 | 288 | |
| 289 | 289 | } |
| 290 | 290 | |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | |
| 303 | 303 | $file = $this->get_file(); |
| 304 | 304 | |
| 305 | - @unlink( $this->file ); |
|
| 305 | + @unlink($this->file); |
|
| 306 | 306 | |
| 307 | 307 | echo $file; |
| 308 | 308 | |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | * |
| 312 | 312 | * @since 1.8 |
| 313 | 313 | */ |
| 314 | - do_action( 'give_file_export_complete', $_REQUEST ); |
|
| 314 | + do_action('give_file_export_complete', $_REQUEST); |
|
| 315 | 315 | |
| 316 | 316 | give_die(); |
| 317 | 317 | } |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | * |
| 324 | 324 | * @param array $request The Form Data passed into the batch processing. |
| 325 | 325 | */ |
| 326 | - public function set_properties( $request ) { |
|
| 326 | + public function set_properties($request) { |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | /** |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | * @param array $request The Form Data passed into the batch processing. |
| 335 | 335 | * @param Give_Batch_Export $export |
| 336 | 336 | */ |
| 337 | - public function unset_properties( $request, $export ) { |
|
| 337 | + public function unset_properties($request, $export) { |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | /** |
@@ -143,7 +143,7 @@ |
||
| 143 | 143 | * |
| 144 | 144 | * @access public |
| 145 | 145 | * @since 1.0 |
| 146 | - * @return mixed string If search is present, false otherwise |
|
| 146 | + * @return string|false string If search is present, false otherwise |
|
| 147 | 147 | */ |
| 148 | 148 | public function get_search() { |
| 149 | 149 | return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
@@ -10,13 +10,13 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // Load WP_List_Table if not loaded |
| 18 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
| 19 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
| 18 | +if ( ! class_exists('WP_List_Table')) { |
|
| 19 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -62,11 +62,11 @@ discard block |
||
| 62 | 62 | global $status, $page; |
| 63 | 63 | |
| 64 | 64 | // Set parent defaults |
| 65 | - parent::__construct( array( |
|
| 66 | - 'singular' => esc_html__( 'Donor', 'give' ), // Singular name of the listed records |
|
| 67 | - 'plural' => esc_html__( 'Donors', 'give' ), // Plural name of the listed records |
|
| 68 | - 'ajax' => false,// Does this table support ajax? |
|
| 69 | - ) ); |
|
| 65 | + parent::__construct(array( |
|
| 66 | + 'singular' => esc_html__('Donor', 'give'), // Singular name of the listed records |
|
| 67 | + 'plural' => esc_html__('Donors', 'give'), // Plural name of the listed records |
|
| 68 | + 'ajax' => false, // Does this table support ajax? |
|
| 69 | + )); |
|
| 70 | 70 | |
| 71 | 71 | } |
| 72 | 72 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * |
| 84 | 84 | * @return false |
| 85 | 85 | */ |
| 86 | - public function search_box( $text, $input_id ) { |
|
| 86 | + public function search_box($text, $input_id) { |
|
| 87 | 87 | return false; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -98,20 +98,20 @@ discard block |
||
| 98 | 98 | * |
| 99 | 99 | * @return void |
| 100 | 100 | */ |
| 101 | - public function give_search_box( $text, $input_id ) { |
|
| 102 | - $input_id = $input_id . '-search-input'; |
|
| 101 | + public function give_search_box($text, $input_id) { |
|
| 102 | + $input_id = $input_id.'-search-input'; |
|
| 103 | 103 | |
| 104 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
| 105 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
| 104 | + if ( ! empty($_REQUEST['orderby'])) { |
|
| 105 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
| 106 | 106 | } |
| 107 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
| 108 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
| 107 | + if ( ! empty($_REQUEST['order'])) { |
|
| 108 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
| 109 | 109 | } |
| 110 | 110 | ?> |
| 111 | 111 | <p class="search-box donor-search" role="search"> |
| 112 | 112 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
| 113 | 113 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
| 114 | - <?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?> |
|
| 114 | + <?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?> |
|
| 115 | 115 | </p> |
| 116 | 116 | <?php |
| 117 | 117 | } |
@@ -124,33 +124,33 @@ discard block |
||
| 124 | 124 | * |
| 125 | 125 | * @param string $which |
| 126 | 126 | */ |
| 127 | - protected function display_tablenav( $which ) { |
|
| 127 | + protected function display_tablenav($which) { |
|
| 128 | 128 | |
| 129 | - if ( 'top' === $which ) { |
|
| 130 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
| 129 | + if ('top' === $which) { |
|
| 130 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
| 131 | 131 | } |
| 132 | 132 | ?> |
| 133 | - <div class="tablenav give-clearfix <?php echo esc_attr( $which ); ?>"> |
|
| 133 | + <div class="tablenav give-clearfix <?php echo esc_attr($which); ?>"> |
|
| 134 | 134 | |
| 135 | - <?php if ( 'top' === $which ) { ?> |
|
| 135 | + <?php if ('top' === $which) { ?> |
|
| 136 | 136 | <h2 class="alignleft reports-earnings-title"> |
| 137 | - <?php esc_html_e( 'Donors Report', 'give' ); ?> |
|
| 137 | + <?php esc_html_e('Donors Report', 'give'); ?> |
|
| 138 | 138 | </h2> |
| 139 | 139 | <?php } ?> |
| 140 | 140 | |
| 141 | 141 | <div class="alignright tablenav-right"> |
| 142 | 142 | <div class="actions bulkactions"> |
| 143 | 143 | <?php |
| 144 | - if ( 'top' === $which ) { |
|
| 145 | - $this->give_search_box( esc_html__( 'Search Donors', 'give' ), 'give-donors-report-search' ); |
|
| 144 | + if ('top' === $which) { |
|
| 145 | + $this->give_search_box(esc_html__('Search Donors', 'give'), 'give-donors-report-search'); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - $this->bulk_actions( $which ); ?> |
|
| 148 | + $this->bulk_actions($which); ?> |
|
| 149 | 149 | |
| 150 | 150 | </div> |
| 151 | 151 | <?php |
| 152 | - $this->extra_tablenav( $which ); |
|
| 153 | - $this->pagination( $which ); |
|
| 152 | + $this->extra_tablenav($which); |
|
| 153 | + $this->pagination($which); |
|
| 154 | 154 | ?> |
| 155 | 155 | </div> |
| 156 | 156 | |
@@ -172,35 +172,35 @@ discard block |
||
| 172 | 172 | * |
| 173 | 173 | * @return string Column Name |
| 174 | 174 | */ |
| 175 | - public function column_default( $item, $column_name ) { |
|
| 175 | + public function column_default($item, $column_name) { |
|
| 176 | 176 | |
| 177 | - switch ( $column_name ) { |
|
| 177 | + switch ($column_name) { |
|
| 178 | 178 | |
| 179 | 179 | case 'name' : |
| 180 | - $name = '#' . $item['id'] . ' '; |
|
| 181 | - $name .= ! empty( $item['name'] ) ? $item['name'] : '<em>' . esc_html__( 'Unnamed Donor', 'give' ) . '</em>'; |
|
| 182 | - $view_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $item['id'] ); |
|
| 183 | - $value = '<a href="' . esc_url( $view_url ) . '">' . $name . '</a>'; |
|
| 180 | + $name = '#'.$item['id'].' '; |
|
| 181 | + $name .= ! empty($item['name']) ? $item['name'] : '<em>'.esc_html__('Unnamed Donor', 'give').'</em>'; |
|
| 182 | + $view_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$item['id']); |
|
| 183 | + $value = '<a href="'.esc_url($view_url).'">'.$name.'</a>'; |
|
| 184 | 184 | break; |
| 185 | 185 | |
| 186 | 186 | case 'num_donations' : |
| 187 | 187 | $value = sprintf( |
| 188 | 188 | '<a href="%s">%s</a>', |
| 189 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $item['id'] ) ), |
|
| 190 | - esc_html( $item['num_donations'] ) |
|
| 189 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($item['id'])), |
|
| 190 | + esc_html($item['num_donations']) |
|
| 191 | 191 | ); |
| 192 | 192 | break; |
| 193 | 193 | |
| 194 | 194 | case 'amount_spent' : |
| 195 | - $value = give_currency_filter( give_format_amount( $item[ $column_name ], array( 'sanitize' => false ) ) ); |
|
| 195 | + $value = give_currency_filter(give_format_amount($item[$column_name], array('sanitize' => false))); |
|
| 196 | 196 | break; |
| 197 | 197 | |
| 198 | 198 | default: |
| 199 | - $value = isset( $item[ $column_name ] ) ? $item[ $column_name ] : null; |
|
| 199 | + $value = isset($item[$column_name]) ? $item[$column_name] : null; |
|
| 200 | 200 | break; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - return apply_filters( "give_report_column_{$column_name}", $value, $item['id'] ); |
|
| 203 | + return apply_filters("give_report_column_{$column_name}", $value, $item['id']); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -212,13 +212,13 @@ discard block |
||
| 212 | 212 | */ |
| 213 | 213 | public function get_columns() { |
| 214 | 214 | $columns = array( |
| 215 | - 'name' => __( 'Name', 'give' ), |
|
| 216 | - 'email' => __( 'Email', 'give' ), |
|
| 217 | - 'num_donations' => __( 'Donations', 'give' ), |
|
| 218 | - 'amount_spent' => __( 'Total Donated', 'give' ), |
|
| 215 | + 'name' => __('Name', 'give'), |
|
| 216 | + 'email' => __('Email', 'give'), |
|
| 217 | + 'num_donations' => __('Donations', 'give'), |
|
| 218 | + 'amount_spent' => __('Total Donated', 'give'), |
|
| 219 | 219 | ); |
| 220 | 220 | |
| 221 | - return apply_filters( 'give_report_donor_columns', $columns ); |
|
| 221 | + return apply_filters('give_report_donor_columns', $columns); |
|
| 222 | 222 | |
| 223 | 223 | } |
| 224 | 224 | |
@@ -231,10 +231,10 @@ discard block |
||
| 231 | 231 | */ |
| 232 | 232 | public function get_sortable_columns() { |
| 233 | 233 | return array( |
| 234 | - 'id' => array( 'id', true ), |
|
| 235 | - 'name' => array( 'name', true ), |
|
| 236 | - 'num_donations' => array( 'purchase_count', false ), |
|
| 237 | - 'amount_spent' => array( 'purchase_value', false ), |
|
| 234 | + 'id' => array('id', true), |
|
| 235 | + 'name' => array('name', true), |
|
| 236 | + 'num_donations' => array('purchase_count', false), |
|
| 237 | + 'amount_spent' => array('purchase_value', false), |
|
| 238 | 238 | ); |
| 239 | 239 | } |
| 240 | 240 | |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | * @since 1.0 |
| 246 | 246 | * @return void |
| 247 | 247 | */ |
| 248 | - public function bulk_actions( $which = '' ) { |
|
| 248 | + public function bulk_actions($which = '') { |
|
| 249 | 249 | |
| 250 | 250 | } |
| 251 | 251 | |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | * @return int Current page number |
| 258 | 258 | */ |
| 259 | 259 | public function get_paged() { |
| 260 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
| 260 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | * @return mixed string If search is present, false otherwise |
| 269 | 269 | */ |
| 270 | 270 | public function get_search() { |
| 271 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
| 271 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | /** |
@@ -287,15 +287,15 @@ discard block |
||
| 287 | 287 | |
| 288 | 288 | // Get donor query. |
| 289 | 289 | $args = $this->get_donor_query(); |
| 290 | - $donors = Give()->donors->get_donors( $args ); |
|
| 290 | + $donors = Give()->donors->get_donors($args); |
|
| 291 | 291 | |
| 292 | - if ( $donors ) { |
|
| 292 | + if ($donors) { |
|
| 293 | 293 | |
| 294 | - $this->count = count( $donors ); |
|
| 294 | + $this->count = count($donors); |
|
| 295 | 295 | |
| 296 | - foreach ( $donors as $donor ) { |
|
| 296 | + foreach ($donors as $donor) { |
|
| 297 | 297 | |
| 298 | - $user_id = ! empty( $donor->user_id ) ? absint( $donor->user_id ) : 0; |
|
| 298 | + $user_id = ! empty($donor->user_id) ? absint($donor->user_id) : 0; |
|
| 299 | 299 | |
| 300 | 300 | $data[] = array( |
| 301 | 301 | 'id' => $donor->id, |
@@ -323,9 +323,9 @@ discard block |
||
| 323 | 323 | |
| 324 | 324 | $_donor_query['number'] = -1; |
| 325 | 325 | $_donor_query['offset'] = 0; |
| 326 | - $donors = Give()->donors->get_donors( $_donor_query ); |
|
| 326 | + $donors = Give()->donors->get_donors($_donor_query); |
|
| 327 | 327 | |
| 328 | - return count( $donors ); |
|
| 328 | + return count($donors); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | /** |
@@ -337,10 +337,10 @@ discard block |
||
| 337 | 337 | */ |
| 338 | 338 | public function get_donor_query() { |
| 339 | 339 | $paged = $this->get_paged(); |
| 340 | - $offset = $this->per_page * ( $paged - 1 ); |
|
| 340 | + $offset = $this->per_page * ($paged - 1); |
|
| 341 | 341 | $search = $this->get_search(); |
| 342 | - $order = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC'; |
|
| 343 | - $orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id'; |
|
| 342 | + $order = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC'; |
|
| 343 | + $orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id'; |
|
| 344 | 344 | |
| 345 | 345 | $args = array( |
| 346 | 346 | 'number' => $this->per_page, |
@@ -349,10 +349,10 @@ discard block |
||
| 349 | 349 | 'orderby' => $orderby, |
| 350 | 350 | ); |
| 351 | 351 | |
| 352 | - if( $search ) { |
|
| 353 | - if ( is_email( $search ) ) { |
|
| 352 | + if ($search) { |
|
| 353 | + if (is_email($search)) { |
|
| 354 | 354 | $args['email'] = $search; |
| 355 | - } elseif ( is_numeric( $search ) ) { |
|
| 355 | + } elseif (is_numeric($search)) { |
|
| 356 | 356 | $args['id'] = $search; |
| 357 | 357 | } else { |
| 358 | 358 | $args['name'] = $search; |
@@ -379,16 +379,16 @@ discard block |
||
| 379 | 379 | $hidden = array(); // No hidden columns |
| 380 | 380 | $sortable = $this->get_sortable_columns(); |
| 381 | 381 | |
| 382 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
| 382 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
| 383 | 383 | |
| 384 | 384 | $this->items = $this->reports_data(); |
| 385 | 385 | |
| 386 | 386 | $this->total = $this->get_donor_count(); |
| 387 | 387 | |
| 388 | - $this->set_pagination_args( array( |
|
| 388 | + $this->set_pagination_args(array( |
|
| 389 | 389 | 'total_items' => $this->total, |
| 390 | 390 | 'per_page' => $this->per_page, |
| 391 | - 'total_pages' => ceil( $this->total / $this->per_page ), |
|
| 392 | - ) ); |
|
| 391 | + 'total_pages' => ceil($this->total / $this->per_page), |
|
| 392 | + )); |
|
| 393 | 393 | } |
| 394 | 394 | } |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | * Return the calculated completion percentage. |
| 217 | 217 | * |
| 218 | 218 | * @since 1.8.12 |
| 219 | - * @return int |
|
| 219 | + * @return double |
|
| 220 | 220 | */ |
| 221 | 221 | public function get_percentage_complete() { |
| 222 | 222 | return ceil( ( 100 * $this->step_completed ) / $this->total_step ); |
@@ -353,6 +353,9 @@ discard block |
||
| 353 | 353 | return true; |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | + /** |
|
| 357 | + * @param integer $page |
|
| 358 | + */ |
|
| 356 | 359 | public function get_delete_ids( $donation_ids, $page ) { |
| 357 | 360 | $index = $page --; |
| 358 | 361 | $count = count( $donation_ids ); |
@@ -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 | |
@@ -98,8 +98,8 @@ discard block |
||
| 98 | 98 | /** |
| 99 | 99 | * Constructor. |
| 100 | 100 | */ |
| 101 | - public function __construct( $_step = 1 ) { |
|
| 102 | - parent::__construct( $_step ); |
|
| 101 | + public function __construct($_step = 1) { |
|
| 102 | + parent::__construct($_step); |
|
| 103 | 103 | |
| 104 | 104 | $this->is_writable = true; |
| 105 | 105 | } |
@@ -118,32 +118,32 @@ discard block |
||
| 118 | 118 | $donor_ids = array(); |
| 119 | 119 | |
| 120 | 120 | // Check if the ajax request if running for the first time. |
| 121 | - if ( 1 === (int) $this->step ) { |
|
| 121 | + if (1 === (int) $this->step) { |
|
| 122 | 122 | // Delete all the donation ids. |
| 123 | - $this->delete_option( $this->donation_key ); |
|
| 123 | + $this->delete_option($this->donation_key); |
|
| 124 | 124 | // Delete all the donor ids. |
| 125 | - $this->delete_option( $this->donor_key ); |
|
| 125 | + $this->delete_option($this->donor_key); |
|
| 126 | 126 | |
| 127 | 127 | // Delete all the step and set to 'count' which if the first step in the process of deleting the donors. |
| 128 | - $this->update_option( $this->step_key, 'count' ); |
|
| 128 | + $this->update_option($this->step_key, 'count'); |
|
| 129 | 129 | |
| 130 | 130 | // Delete tha page count of the step. |
| 131 | - $this->update_option( $this->step_on_key, '0' ); |
|
| 131 | + $this->update_option($this->step_on_key, '0'); |
|
| 132 | 132 | } else { |
| 133 | 133 | // Get the old donors list. |
| 134 | - $donor_ids = $this->get_option( $this->donor_key ); |
|
| 134 | + $donor_ids = $this->get_option($this->donor_key); |
|
| 135 | 135 | |
| 136 | 136 | // Get the old donation list. |
| 137 | - $donation_ids = $this->get_option( $this->donation_key ); |
|
| 137 | + $donation_ids = $this->get_option($this->donation_key); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | // Get the step and check for it if it's on the first step( 'count' ) or not. |
| 141 | 141 | $step = (int) $this->get_step(); |
| 142 | - if ( 1 === $step ) { |
|
| 142 | + if (1 === $step) { |
|
| 143 | 143 | /** |
| 144 | 144 | * Will add or update the donation and donor data by running wp query. |
| 145 | 145 | */ |
| 146 | - $this->count( $step, $donation_ids, $donor_ids ); |
|
| 146 | + $this->count($step, $donation_ids, $donor_ids); |
|
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | 149 | |
@@ -154,17 +154,17 @@ discard block |
||
| 154 | 154 | * @param array $donation_ids Contain the list of all the donation id's that has being add before this |
| 155 | 155 | * @param array $donor_ids Contain the list of all the donors id's that has being add before this |
| 156 | 156 | */ |
| 157 | - private function count( $step, $donation_ids = array(), $donor_ids = array() ) { |
|
| 157 | + private function count($step, $donation_ids = array(), $donor_ids = array()) { |
|
| 158 | 158 | |
| 159 | 159 | // Get the Page count by default it's zero. |
| 160 | 160 | $paged = (int) $this->get_step_page(); |
| 161 | 161 | // Incresed the page count by one. |
| 162 | - ++ $paged; |
|
| 162 | + ++$paged; |
|
| 163 | 163 | |
| 164 | 164 | /** |
| 165 | 165 | * Filter add to alter the argument before the wp quest run |
| 166 | 166 | */ |
| 167 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
| 167 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
| 168 | 168 | 'post_type' => 'give_payment', |
| 169 | 169 | 'post_status' => 'any', |
| 170 | 170 | 'posts_per_page' => $this->per_step, |
@@ -172,16 +172,16 @@ discard block |
||
| 172 | 172 | // ONLY TEST MODE TRANSACTIONS!!! |
| 173 | 173 | 'meta_key' => '_give_payment_mode', |
| 174 | 174 | 'meta_value' => 'test', |
| 175 | - ) ); |
|
| 175 | + )); |
|
| 176 | 176 | |
| 177 | 177 | // Reset the post data. |
| 178 | 178 | wp_reset_postdata(); |
| 179 | 179 | // Getting the new donation. |
| 180 | - $donation_posts = new WP_Query( $args ); |
|
| 180 | + $donation_posts = new WP_Query($args); |
|
| 181 | 181 | |
| 182 | 182 | // The Loop. |
| 183 | - if ( $donation_posts->have_posts() ) { |
|
| 184 | - while ( $donation_posts->have_posts() ) { |
|
| 183 | + if ($donation_posts->have_posts()) { |
|
| 184 | + while ($donation_posts->have_posts()) { |
|
| 185 | 185 | $donation_posts->the_post(); |
| 186 | 186 | global $post; |
| 187 | 187 | // Add the donation id in side the array. |
@@ -200,23 +200,23 @@ discard block |
||
| 200 | 200 | $max_num_pages = (int) $donation_posts->max_num_pages; |
| 201 | 201 | |
| 202 | 202 | // Check current page is less then max number of page or not |
| 203 | - if ( $paged < $max_num_pages ) { |
|
| 203 | + if ($paged < $max_num_pages) { |
|
| 204 | 204 | // Update the curretn page virable for the next step |
| 205 | - $this->update_option( $this->step_on_key, $paged ); |
|
| 205 | + $this->update_option($this->step_on_key, $paged); |
|
| 206 | 206 | |
| 207 | 207 | // Calculating percentage. |
| 208 | 208 | $page_remain = $max_num_pages - $paged; |
| 209 | - $this->total_step = (int) $max_num_pages + ( $total_donation / $this->per_step ) + ( ( $page_remain * 2 ) * count( $donor_ids ) ); |
|
| 209 | + $this->total_step = (int) $max_num_pages + ($total_donation / $this->per_step) + (($page_remain * 2) * count($donor_ids)); |
|
| 210 | 210 | $this->step_completed = $paged; |
| 211 | 211 | } else { |
| 212 | - $donation_ids_count = count( $donor_ids ); |
|
| 213 | - $this->update_option( $this->step_key, 'donation' ); |
|
| 214 | - $this->update_option( $this->step_on_key, '0' ); |
|
| 212 | + $donation_ids_count = count($donor_ids); |
|
| 213 | + $this->update_option($this->step_key, 'donation'); |
|
| 214 | + $this->update_option($this->step_on_key, '0'); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | - $donor_ids = array_unique( $donor_ids ); |
|
| 218 | - $this->update_option( $this->donor_key, $donor_ids ); |
|
| 219 | - $this->update_option( $this->donation_key, $donation_ids ); |
|
| 217 | + $donor_ids = array_unique($donor_ids); |
|
| 218 | + $this->update_option($this->donor_key, $donor_ids); |
|
| 219 | + $this->update_option($this->donation_key, $donation_ids); |
|
| 220 | 220 | |
| 221 | 221 | wp_reset_postdata(); |
| 222 | 222 | } |
@@ -228,33 +228,33 @@ discard block |
||
| 228 | 228 | * @return int |
| 229 | 229 | */ |
| 230 | 230 | public function get_percentage_complete() { |
| 231 | - return ceil( ( 100 * $this->step_completed ) / $this->total_step ); |
|
| 231 | + return ceil((100 * $this->step_completed) / $this->total_step); |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | public function process_step() { |
| 235 | 235 | |
| 236 | - if ( ! $this->can_export() ) { |
|
| 236 | + if ( ! $this->can_export()) { |
|
| 237 | 237 | wp_die( |
| 238 | - esc_html__( 'You do not have permission to delete test transactions.', 'give' ), |
|
| 239 | - esc_html__( 'Error', 'give' ), |
|
| 240 | - array( 'response' => 403 ) |
|
| 238 | + esc_html__('You do not have permission to delete test transactions.', 'give'), |
|
| 239 | + esc_html__('Error', 'give'), |
|
| 240 | + array('response' => 403) |
|
| 241 | 241 | ); |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | $had_data = $this->get_data(); |
| 245 | 245 | |
| 246 | - if ( $had_data ) { |
|
| 246 | + if ($had_data) { |
|
| 247 | 247 | $this->done = false; |
| 248 | 248 | |
| 249 | 249 | return true; |
| 250 | 250 | } else { |
| 251 | - update_option( 'give_earnings_total', give_get_total_earnings( true ), false ); |
|
| 252 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
| 251 | + update_option('give_earnings_total', give_get_total_earnings(true), false); |
|
| 252 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
| 253 | 253 | |
| 254 | - $this->delete_option( $this->donation_key ); |
|
| 254 | + $this->delete_option($this->donation_key); |
|
| 255 | 255 | |
| 256 | 256 | $this->done = true; |
| 257 | - $this->message = __( 'Test donor and transactions successfully deleted.', 'give' ); |
|
| 257 | + $this->message = __('Test donor and transactions successfully deleted.', 'give'); |
|
| 258 | 258 | |
| 259 | 259 | return false; |
| 260 | 260 | } |
@@ -272,12 +272,12 @@ discard block |
||
| 272 | 272 | public function get_data() { |
| 273 | 273 | |
| 274 | 274 | // Get the donation id's. |
| 275 | - $donation_ids = $this->get_option( $this->donation_key ); |
|
| 275 | + $donation_ids = $this->get_option($this->donation_key); |
|
| 276 | 276 | |
| 277 | 277 | /** |
| 278 | 278 | * Return false id not test donation is found. |
| 279 | 279 | */ |
| 280 | - if ( empty( $donation_ids ) ) { |
|
| 280 | + if (empty($donation_ids)) { |
|
| 281 | 281 | $this->is_empty = true; |
| 282 | 282 | $this->total_step = 1; |
| 283 | 283 | |
@@ -288,68 +288,68 @@ discard block |
||
| 288 | 288 | $step = (int) $this->get_step(); |
| 289 | 289 | |
| 290 | 290 | // get teh donor ids. |
| 291 | - $donor_ids = $this->get_option( $this->donor_key ); |
|
| 291 | + $donor_ids = $this->get_option($this->donor_key); |
|
| 292 | 292 | |
| 293 | 293 | // In step to we delete all the donation in loop. |
| 294 | - if ( 2 === $step ) { |
|
| 294 | + if (2 === $step) { |
|
| 295 | 295 | $pass_to_donor = false; |
| 296 | 296 | $page = (int) $this->get_step_page(); |
| 297 | - $page ++; |
|
| 298 | - $count = count( $donation_ids ); |
|
| 297 | + $page++; |
|
| 298 | + $count = count($donation_ids); |
|
| 299 | 299 | |
| 300 | - $this->total_step = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids ); |
|
| 300 | + $this->total_step = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids); |
|
| 301 | 301 | $this->step_completed = $page; |
| 302 | 302 | |
| 303 | - if ( $count > $this->per_step ) { |
|
| 303 | + if ($count > $this->per_step) { |
|
| 304 | 304 | |
| 305 | - $this->update_option( $this->step_on_key, $page ); |
|
| 306 | - $donation_ids = $this->get_delete_ids( $donation_ids, $page ); |
|
| 307 | - $current_page = (int) ceil( $count / $this->per_step ); |
|
| 305 | + $this->update_option($this->step_on_key, $page); |
|
| 306 | + $donation_ids = $this->get_delete_ids($donation_ids, $page); |
|
| 307 | + $current_page = (int) ceil($count / $this->per_step); |
|
| 308 | 308 | |
| 309 | - if ( $page === $current_page ) { |
|
| 309 | + if ($page === $current_page) { |
|
| 310 | 310 | $pass_to_donor = true; |
| 311 | 311 | } |
| 312 | 312 | } else { |
| 313 | 313 | $pass_to_donor = true; |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - if ( true === $pass_to_donor ) { |
|
| 317 | - $this->update_option( $this->step_key, 'donor' ); |
|
| 318 | - $this->update_option( $this->step_on_key, '0' ); |
|
| 316 | + if (true === $pass_to_donor) { |
|
| 317 | + $this->update_option($this->step_key, 'donor'); |
|
| 318 | + $this->update_option($this->step_on_key, '0'); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - foreach ( $donation_ids as $item ) { |
|
| 321 | + foreach ($donation_ids as $item) { |
|
| 322 | 322 | // Delete the main payment. |
| 323 | - give_delete_donation( absint( $item ) ); |
|
| 323 | + give_delete_donation(absint($item)); |
|
| 324 | 324 | } |
| 325 | - do_action( 'give_delete_log_cache' ); |
|
| 325 | + do_action('give_delete_log_cache'); |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | // Here we delete all the donor |
| 329 | - if ( 3 === $step ) { |
|
| 329 | + if (3 === $step) { |
|
| 330 | 330 | $page = (int) $this->get_step_page(); |
| 331 | - $count = count( $donor_ids ); |
|
| 331 | + $count = count($donor_ids); |
|
| 332 | 332 | |
| 333 | - $this->total_step = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids ); |
|
| 334 | - $this->step_completed = $page + ( count( $donation_ids ) / $this->per_step ); |
|
| 333 | + $this->total_step = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids); |
|
| 334 | + $this->step_completed = $page + (count($donation_ids) / $this->per_step); |
|
| 335 | 335 | |
| 336 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
| 336 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
| 337 | 337 | 'post_type' => 'give_payment', |
| 338 | 338 | 'post_status' => 'any', |
| 339 | 339 | 'posts_per_page' => 1, |
| 340 | 340 | 'meta_key' => '_give_payment_mode', |
| 341 | 341 | 'meta_value' => 'live', |
| 342 | - 'author' => $donor_ids[ $page ], |
|
| 343 | - ) ); |
|
| 342 | + 'author' => $donor_ids[$page], |
|
| 343 | + )); |
|
| 344 | 344 | |
| 345 | - $donation_posts = get_posts( $args ); |
|
| 346 | - if ( empty( $donation_posts ) ) { |
|
| 347 | - Give()->donors->delete_by_user_id( $donor_ids[ $page ] ); |
|
| 345 | + $donation_posts = get_posts($args); |
|
| 346 | + if (empty($donation_posts)) { |
|
| 347 | + Give()->donors->delete_by_user_id($donor_ids[$page]); |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | - $page ++; |
|
| 351 | - $this->update_option( $this->step_on_key, $page ); |
|
| 352 | - if ( $count === $page ) { |
|
| 350 | + $page++; |
|
| 351 | + $this->update_option($this->step_on_key, $page); |
|
| 352 | + if ($count === $page) { |
|
| 353 | 353 | $this->is_empty = false; |
| 354 | 354 | |
| 355 | 355 | return false; |
@@ -361,24 +361,24 @@ discard block |
||
| 361 | 361 | return true; |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | - public function get_delete_ids( $donation_ids, $page ) { |
|
| 365 | - $index = $page --; |
|
| 366 | - $count = count( $donation_ids ); |
|
| 364 | + public function get_delete_ids($donation_ids, $page) { |
|
| 365 | + $index = $page--; |
|
| 366 | + $count = count($donation_ids); |
|
| 367 | 367 | $temp = 0; |
| 368 | 368 | $current_page = 0; |
| 369 | 369 | $post_delete = $this->per_step; |
| 370 | 370 | $page_donation_id = array(); |
| 371 | 371 | |
| 372 | - foreach ( $donation_ids as $item ) { |
|
| 373 | - $temp ++; |
|
| 374 | - $page_donation_id[ $current_page ][] = $item; |
|
| 375 | - if ( $temp === $post_delete ) { |
|
| 376 | - $current_page ++; |
|
| 372 | + foreach ($donation_ids as $item) { |
|
| 373 | + $temp++; |
|
| 374 | + $page_donation_id[$current_page][] = $item; |
|
| 375 | + if ($temp === $post_delete) { |
|
| 376 | + $current_page++; |
|
| 377 | 377 | $temp = 0; |
| 378 | 378 | } |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - return $page_donation_id[ $page ]; |
|
| 381 | + return $page_donation_id[$page]; |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | /** |
@@ -390,8 +390,8 @@ discard block |
||
| 390 | 390 | * |
| 391 | 391 | * @return mixed Returns the data from the database |
| 392 | 392 | */ |
| 393 | - public function get_option( $key, $defalut_value = false ) { |
|
| 394 | - return get_option( $key, $defalut_value ); |
|
| 393 | + public function get_option($key, $defalut_value = false) { |
|
| 394 | + return get_option($key, $defalut_value); |
|
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | /** |
@@ -404,8 +404,8 @@ discard block |
||
| 404 | 404 | * |
| 405 | 405 | * @return void |
| 406 | 406 | */ |
| 407 | - public function update_option( $key, $value ) { |
|
| 408 | - update_option( $key, $value, false ); |
|
| 407 | + public function update_option($key, $value) { |
|
| 408 | + update_option($key, $value, false); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | /** |
@@ -417,8 +417,8 @@ discard block |
||
| 417 | 417 | * |
| 418 | 418 | * @return void |
| 419 | 419 | */ |
| 420 | - public function delete_option( $key ) { |
|
| 421 | - delete_option( $key ); |
|
| 420 | + public function delete_option($key) { |
|
| 421 | + delete_option($key); |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | /** |
@@ -429,12 +429,12 @@ discard block |
||
| 429 | 429 | * @return int|string |
| 430 | 430 | */ |
| 431 | 431 | private function get_step() { |
| 432 | - $step_key = (string) $this->get_option( $this->step_key, false ); |
|
| 433 | - if ( 'count' === $step_key ) { |
|
| 432 | + $step_key = (string) $this->get_option($this->step_key, false); |
|
| 433 | + if ('count' === $step_key) { |
|
| 434 | 434 | return 1; |
| 435 | - } elseif ( 'donation' === $step_key ) { |
|
| 435 | + } elseif ('donation' === $step_key) { |
|
| 436 | 436 | return 2; |
| 437 | - } elseif ( 'donor' === $step_key ) { |
|
| 437 | + } elseif ('donor' === $step_key) { |
|
| 438 | 438 | return 3; |
| 439 | 439 | } else { |
| 440 | 440 | return $step_key; |
@@ -445,6 +445,6 @@ discard block |
||
| 445 | 445 | * Get the current $page value in the ajax. |
| 446 | 446 | */ |
| 447 | 447 | private function get_step_page() { |
| 448 | - return $this->get_option( $this->step_on_key, false ); |
|
| 448 | + return $this->get_option($this->step_on_key, false); |
|
| 449 | 449 | } |
| 450 | 450 | } |
@@ -340,7 +340,7 @@ |
||
| 340 | 340 | * @since 1.0 |
| 341 | 341 | * |
| 342 | 342 | * @param int|float|string $amount Formatted or sanitized price |
| 343 | - * @param int|bool $dp number of decimals |
|
| 343 | + * @param boolean $dp number of decimals |
|
| 344 | 344 | * @param bool $sanitize Whether or not sanitize number |
| 345 | 345 | * |
| 346 | 346 | * @return string $amount Newly formatted amount or Price Not Available |
@@ -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,37 +23,37 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return mixed |
| 25 | 25 | */ |
| 26 | -function give_get_currency_formatting_settings( $id_or_currency_code = null ) { |
|
| 26 | +function give_get_currency_formatting_settings($id_or_currency_code = null) { |
|
| 27 | 27 | $give_options = give_get_settings(); |
| 28 | 28 | $setting = array(); |
| 29 | 29 | |
| 30 | - if ( ! empty( $id_or_currency_code ) ) { |
|
| 31 | - $currencies = give_get_currencies( 'all' ); |
|
| 30 | + if ( ! empty($id_or_currency_code)) { |
|
| 31 | + $currencies = give_get_currencies('all'); |
|
| 32 | 32 | |
| 33 | 33 | // Set default formatting setting only if currency not set as global currency. |
| 34 | 34 | if ( |
| 35 | - is_string( $id_or_currency_code ) && |
|
| 36 | - ! empty( $give_options['currency'] ) && |
|
| 35 | + is_string($id_or_currency_code) && |
|
| 36 | + ! empty($give_options['currency']) && |
|
| 37 | 37 | $id_or_currency_code !== $give_options['currency'] && |
| 38 | - array_key_exists( $id_or_currency_code, $currencies ) |
|
| 38 | + array_key_exists($id_or_currency_code, $currencies) |
|
| 39 | 39 | ) { |
| 40 | - $setting = $currencies[ $id_or_currency_code ]['setting']; |
|
| 41 | - } elseif ( is_numeric( $id_or_currency_code ) && 'give_payment' === get_post_type( $id_or_currency_code ) ) { |
|
| 42 | - $currency = give_get_meta( $id_or_currency_code, '_give_payment_currency', true ); |
|
| 40 | + $setting = $currencies[$id_or_currency_code]['setting']; |
|
| 41 | + } elseif (is_numeric($id_or_currency_code) && 'give_payment' === get_post_type($id_or_currency_code)) { |
|
| 42 | + $currency = give_get_meta($id_or_currency_code, '_give_payment_currency', true); |
|
| 43 | 43 | |
| 44 | 44 | if ( |
| 45 | - ! empty( $currency) && |
|
| 45 | + ! empty($currency) && |
|
| 46 | 46 | $give_options['currency'] !== $currency |
| 47 | 47 | ) { |
| 48 | - $setting = $currencies[ $currency ]['setting']; |
|
| 48 | + $setting = $currencies[$currency]['setting']; |
|
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - if ( empty( $setting ) ) { |
|
| 53 | + if (empty($setting)) { |
|
| 54 | 54 | // Set thousand separator. |
| 55 | - $thousand_separator = isset( $give_options['thousands_separator'] ) ? $give_options['thousands_separator'] : ','; |
|
| 56 | - $thousand_separator = empty( $thousand_separator ) ? ' ' : $thousand_separator; |
|
| 55 | + $thousand_separator = isset($give_options['thousands_separator']) ? $give_options['thousands_separator'] : ','; |
|
| 56 | + $thousand_separator = empty($thousand_separator) ? ' ' : $thousand_separator; |
|
| 57 | 57 | |
| 58 | 58 | // Set decimal separator. |
| 59 | 59 | $default_decimal_separators = array( |
@@ -61,17 +61,16 @@ discard block |
||
| 61 | 61 | ',' => '.', |
| 62 | 62 | ); |
| 63 | 63 | |
| 64 | - $default_decimal_separator = in_array( $thousand_separator, $default_decimal_separators ) ? |
|
| 65 | - $default_decimal_separators[ $thousand_separator ] : |
|
| 66 | - '.'; |
|
| 64 | + $default_decimal_separator = in_array($thousand_separator, $default_decimal_separators) ? |
|
| 65 | + $default_decimal_separators[$thousand_separator] : '.'; |
|
| 67 | 66 | |
| 68 | - $decimal_separator = ! empty( $give_options['decimal_separator'] ) ? $give_options['decimal_separator'] : $default_decimal_separator; |
|
| 67 | + $decimal_separator = ! empty($give_options['decimal_separator']) ? $give_options['decimal_separator'] : $default_decimal_separator; |
|
| 69 | 68 | |
| 70 | 69 | $setting = array( |
| 71 | - 'currency_position' => give_get_option( 'currency_position', 'before' ), |
|
| 70 | + 'currency_position' => give_get_option('currency_position', 'before'), |
|
| 72 | 71 | 'thousands_separator' => $thousand_separator, |
| 73 | 72 | 'decimal_separator' => $decimal_separator, |
| 74 | - 'number_decimals' => give_get_option( 'number_decimals', 0 ), |
|
| 73 | + 'number_decimals' => give_get_option('number_decimals', 0), |
|
| 75 | 74 | ); |
| 76 | 75 | } |
| 77 | 76 | |
@@ -80,7 +79,7 @@ discard block |
||
| 80 | 79 | * |
| 81 | 80 | * @since 1.8.15 |
| 82 | 81 | */ |
| 83 | - return apply_filters( 'give_get_currency_formatting_settings', $setting, $id_or_currency_code ); |
|
| 82 | + return apply_filters('give_get_currency_formatting_settings', $setting, $id_or_currency_code); |
|
| 84 | 83 | } |
| 85 | 84 | |
| 86 | 85 | /** |
@@ -92,16 +91,16 @@ discard block |
||
| 92 | 91 | * |
| 93 | 92 | * @return mixed |
| 94 | 93 | */ |
| 95 | -function give_get_price_decimals( $id_or_currency_code = null ) { |
|
| 94 | +function give_get_price_decimals($id_or_currency_code = null) { |
|
| 96 | 95 | // Set currency on basis of donation id. |
| 97 | - if ( empty( $id_or_currency_code ) ) { |
|
| 96 | + if (empty($id_or_currency_code)) { |
|
| 98 | 97 | $id_or_currency_code = give_get_currency(); |
| 99 | 98 | } |
| 100 | 99 | |
| 101 | 100 | $number_of_decimals = 0; |
| 102 | 101 | |
| 103 | - if ( ! give_is_zero_based_currency( $id_or_currency_code ) ) { |
|
| 104 | - $setting = give_get_currency_formatting_settings( $id_or_currency_code ); |
|
| 102 | + if ( ! give_is_zero_based_currency($id_or_currency_code)) { |
|
| 103 | + $setting = give_get_currency_formatting_settings($id_or_currency_code); |
|
| 105 | 104 | $number_of_decimals = $setting['number_decimals']; |
| 106 | 105 | } |
| 107 | 106 | |
@@ -110,7 +109,7 @@ discard block |
||
| 110 | 109 | * |
| 111 | 110 | * @since 1.6 |
| 112 | 111 | */ |
| 113 | - return apply_filters( 'give_sanitize_amount_decimals', $number_of_decimals, $id_or_currency_code ); |
|
| 112 | + return apply_filters('give_sanitize_amount_decimals', $number_of_decimals, $id_or_currency_code); |
|
| 114 | 113 | } |
| 115 | 114 | |
| 116 | 115 | /** |
@@ -122,15 +121,15 @@ discard block |
||
| 122 | 121 | * |
| 123 | 122 | * @return mixed |
| 124 | 123 | */ |
| 125 | -function give_get_price_thousand_separator( $id_or_currency_code = null ) { |
|
| 126 | - $setting = give_get_currency_formatting_settings( $id_or_currency_code ); |
|
| 124 | +function give_get_price_thousand_separator($id_or_currency_code = null) { |
|
| 125 | + $setting = give_get_currency_formatting_settings($id_or_currency_code); |
|
| 127 | 126 | |
| 128 | 127 | /** |
| 129 | 128 | * Filter the thousand separator |
| 130 | 129 | * |
| 131 | 130 | * @since 1.6 |
| 132 | 131 | */ |
| 133 | - return apply_filters( 'give_get_price_thousand_separator', $setting['thousands_separator'], $id_or_currency_code ); |
|
| 132 | + return apply_filters('give_get_price_thousand_separator', $setting['thousands_separator'], $id_or_currency_code); |
|
| 134 | 133 | } |
| 135 | 134 | |
| 136 | 135 | /** |
@@ -142,15 +141,15 @@ discard block |
||
| 142 | 141 | * |
| 143 | 142 | * @return mixed |
| 144 | 143 | */ |
| 145 | -function give_get_price_decimal_separator( $id_or_currency_code = null ) { |
|
| 146 | - $setting = give_get_currency_formatting_settings( $id_or_currency_code ); |
|
| 144 | +function give_get_price_decimal_separator($id_or_currency_code = null) { |
|
| 145 | + $setting = give_get_currency_formatting_settings($id_or_currency_code); |
|
| 147 | 146 | |
| 148 | 147 | /** |
| 149 | 148 | * Filter the thousand separator |
| 150 | 149 | * |
| 151 | 150 | * @since 1.6 |
| 152 | 151 | */ |
| 153 | - return apply_filters( 'give_get_price_decimal_separator', $setting['decimal_separator'], $id_or_currency_code ); |
|
| 152 | + return apply_filters('give_get_price_decimal_separator', $setting['decimal_separator'], $id_or_currency_code); |
|
| 154 | 153 | } |
| 155 | 154 | |
| 156 | 155 | |
@@ -164,10 +163,10 @@ discard block |
||
| 164 | 163 | * |
| 165 | 164 | * @return string $amount Newly sanitized amount |
| 166 | 165 | */ |
| 167 | -function give_sanitize_amount_for_db( $number, $args = array() ) { |
|
| 166 | +function give_sanitize_amount_for_db($number, $args = array()) { |
|
| 168 | 167 | $args['number_decimals'] = 6; |
| 169 | 168 | |
| 170 | - return give_maybe_sanitize_amount( $number, $args ); |
|
| 169 | + return give_maybe_sanitize_amount($number, $args); |
|
| 171 | 170 | } |
| 172 | 171 | |
| 173 | 172 | /** |
@@ -180,19 +179,19 @@ discard block |
||
| 180 | 179 | * |
| 181 | 180 | * @return string $amount Newly sanitized amount |
| 182 | 181 | */ |
| 183 | -function give_maybe_sanitize_amount( $number, $args = array() ) { |
|
| 182 | +function give_maybe_sanitize_amount($number, $args = array()) { |
|
| 184 | 183 | // Bailout. |
| 185 | - if ( empty( $number ) || ( ! is_numeric( $number ) && ! is_string( $number ) ) ) { |
|
| 184 | + if (empty($number) || ( ! is_numeric($number) && ! is_string($number))) { |
|
| 186 | 185 | return $number; |
| 187 | 186 | } |
| 188 | 187 | |
| 189 | 188 | $func_args = func_get_args(); |
| 190 | 189 | |
| 191 | 190 | // Backward compatibility. |
| 192 | - if ( isset( $func_args[1] ) && ( is_bool( $func_args[1] ) || is_numeric( $func_args[1] ) ) ) { |
|
| 191 | + if (isset($func_args[1]) && (is_bool($func_args[1]) || is_numeric($func_args[1]))) { |
|
| 193 | 192 | $args = array( |
| 194 | 193 | 'number_decimals' => $func_args[1], |
| 195 | - 'trim_zeros' => isset( $func_args[2] ) ? $func_args[2] : false, |
|
| 194 | + 'trim_zeros' => isset($func_args[2]) ? $func_args[2] : false, |
|
| 196 | 195 | ); |
| 197 | 196 | } |
| 198 | 197 | |
@@ -205,24 +204,23 @@ discard block |
||
| 205 | 204 | ) |
| 206 | 205 | ); |
| 207 | 206 | |
| 208 | - $thousand_separator = give_get_price_thousand_separator( $args['currency'] ); |
|
| 209 | - $decimal_separator = give_get_price_decimal_separator( $args['currency'] ); |
|
| 210 | - $number_decimals = is_bool( $args['number_decimals'] ) ? |
|
| 211 | - give_get_price_decimals() : |
|
| 212 | - $args['number_decimals']; |
|
| 207 | + $thousand_separator = give_get_price_thousand_separator($args['currency']); |
|
| 208 | + $decimal_separator = give_get_price_decimal_separator($args['currency']); |
|
| 209 | + $number_decimals = is_bool($args['number_decimals']) ? |
|
| 210 | + give_get_price_decimals() : $args['number_decimals']; |
|
| 213 | 211 | |
| 214 | 212 | // Explode number by . decimal separator. |
| 215 | - $number_parts = explode( '.', $number ); |
|
| 213 | + $number_parts = explode('.', $number); |
|
| 216 | 214 | |
| 217 | 215 | // Remove currency symbols from number if any. |
| 218 | - $number = trim( str_replace( give_currency_symbols( true ), '', $number ) ); |
|
| 216 | + $number = trim(str_replace(give_currency_symbols(true), '', $number)); |
|
| 219 | 217 | |
| 220 | 218 | if ( |
| 221 | 219 | // Non formatted number. |
| 222 | - false === strpos( $number, $thousand_separator ) |
|
| 223 | - && false === strpos( $number, $decimal_separator ) |
|
| 220 | + false === strpos($number, $thousand_separator) |
|
| 221 | + && false === strpos($number, $decimal_separator) |
|
| 224 | 222 | ) { |
| 225 | - return number_format( $number, $number_decimals, '.', '' ); |
|
| 223 | + return number_format($number, $number_decimals, '.', ''); |
|
| 226 | 224 | } elseif ( |
| 227 | 225 | // Decimal formatted number. |
| 228 | 226 | // If number of decimal place set to non zero and |
@@ -230,34 +228,34 @@ discard block |
||
| 230 | 228 | // then number will be consider as decimal formatted which means number is already sanitized. |
| 231 | 229 | $number_decimals |
| 232 | 230 | && '.' === $thousand_separator |
| 233 | - && false !== strpos( $number, $thousand_separator ) |
|
| 234 | - && false === strpos( $number, $decimal_separator ) |
|
| 235 | - && 2 === count( $number_parts ) |
|
| 236 | - && ( $number_decimals >= strlen( $number_parts[1] ) ) |
|
| 237 | - ){ |
|
| 238 | - return number_format( $number, $number_decimals, '.', '' ); |
|
| 231 | + && false !== strpos($number, $thousand_separator) |
|
| 232 | + && false === strpos($number, $decimal_separator) |
|
| 233 | + && 2 === count($number_parts) |
|
| 234 | + && ($number_decimals >= strlen($number_parts[1])) |
|
| 235 | + ) { |
|
| 236 | + return number_format($number, $number_decimals, '.', ''); |
|
| 239 | 237 | } |
| 240 | 238 | |
| 241 | 239 | // Handle thousand separator as '.' |
| 242 | 240 | // Handle sanitize database values. |
| 243 | - $is_db_sanitize_val = ( 2 === count( $number_parts ) && |
|
| 244 | - is_numeric( $number_parts[0] ) && |
|
| 245 | - is_numeric( $number_parts[1] ) && |
|
| 246 | - ( 6 === strlen( $number_parts[1] ) ) ); |
|
| 241 | + $is_db_sanitize_val = (2 === count($number_parts) && |
|
| 242 | + is_numeric($number_parts[0]) && |
|
| 243 | + is_numeric($number_parts[1]) && |
|
| 244 | + (6 === strlen($number_parts[1]))); |
|
| 247 | 245 | |
| 248 | - if ( $is_db_sanitize_val ) { |
|
| 246 | + if ($is_db_sanitize_val) { |
|
| 249 | 247 | // Sanitize database value. |
| 250 | - return number_format( $number, $number_decimals, '.', '' ); |
|
| 248 | + return number_format($number, $number_decimals, '.', ''); |
|
| 251 | 249 | |
| 252 | 250 | } elseif ( |
| 253 | 251 | '.' === $thousand_separator && |
| 254 | - false !== strpos( $number, $thousand_separator ) |
|
| 252 | + false !== strpos($number, $thousand_separator) |
|
| 255 | 253 | ) { |
| 256 | 254 | // Fix point thousand separator value. |
| 257 | - $number = str_replace( '.', '', $number ); |
|
| 255 | + $number = str_replace('.', '', $number); |
|
| 258 | 256 | } |
| 259 | 257 | |
| 260 | - return give_sanitize_amount( $number, $args ); |
|
| 258 | + return give_sanitize_amount($number, $args); |
|
| 261 | 259 | } |
| 262 | 260 | |
| 263 | 261 | /** |
@@ -274,10 +272,10 @@ discard block |
||
| 274 | 272 | * |
| 275 | 273 | * @return string $amount Newly sanitized amount |
| 276 | 274 | */ |
| 277 | -function give_sanitize_amount( $number, $args = array() ) { |
|
| 275 | +function give_sanitize_amount($number, $args = array()) { |
|
| 278 | 276 | |
| 279 | 277 | // Bailout. |
| 280 | - if ( empty( $number ) || ( ! is_numeric( $number ) && ! is_string( $number ) ) ) { |
|
| 278 | + if (empty($number) || ( ! is_numeric($number) && ! is_string($number))) { |
|
| 281 | 279 | return $number; |
| 282 | 280 | } |
| 283 | 281 | |
@@ -285,10 +283,10 @@ discard block |
||
| 285 | 283 | $func_args = func_get_args(); |
| 286 | 284 | |
| 287 | 285 | // Backward compatibility. |
| 288 | - if ( isset( $func_args[1] ) && ( is_bool( $func_args[1] ) || is_numeric( $func_args[1] ) ) ) { |
|
| 286 | + if (isset($func_args[1]) && (is_bool($func_args[1]) || is_numeric($func_args[1]))) { |
|
| 289 | 287 | $args = array( |
| 290 | 288 | 'number_decimals' => $func_args[1], |
| 291 | - 'trim_zeros' => isset( $func_args[2] ) ? $func_args[2] : false, |
|
| 289 | + 'trim_zeros' => isset($func_args[2]) ? $func_args[2] : false, |
|
| 292 | 290 | ); |
| 293 | 291 | } |
| 294 | 292 | |
@@ -304,58 +302,58 @@ discard block |
||
| 304 | 302 | // Remove slash from amount. |
| 305 | 303 | // If thousand or decimal separator is set to ' then in $_POST or $_GET param we will get an escaped number. |
| 306 | 304 | // To prevent notices and warning remove slash from amount/number. |
| 307 | - $number = wp_unslash( $number ); |
|
| 305 | + $number = wp_unslash($number); |
|
| 308 | 306 | |
| 309 | - $thousand_separator = give_get_price_thousand_separator( $args['currency'] ); |
|
| 307 | + $thousand_separator = give_get_price_thousand_separator($args['currency']); |
|
| 310 | 308 | |
| 311 | 309 | $locale = localeconv(); |
| 312 | 310 | $decimals = array( |
| 313 | - give_get_price_decimal_separator( $args['currency'] ), |
|
| 311 | + give_get_price_decimal_separator($args['currency']), |
|
| 314 | 312 | $locale['decimal_point'], |
| 315 | 313 | $locale['mon_decimal_point'], |
| 316 | 314 | ); |
| 317 | 315 | |
| 318 | 316 | // Remove locale from string |
| 319 | - if ( ! is_float( $number ) ) { |
|
| 320 | - $number = str_replace( $decimals, '.', $number ); |
|
| 317 | + if ( ! is_float($number)) { |
|
| 318 | + $number = str_replace($decimals, '.', $number); |
|
| 321 | 319 | } |
| 322 | 320 | |
| 323 | 321 | // Remove thousand amount formatting if amount has. |
| 324 | 322 | // This condition use to add backward compatibility to version before 1.6, because before version 1.6 we were saving formatted amount to db. |
| 325 | 323 | // Do not replace thousand separator from price if it is same as decimal separator, because it will be already replace by above code. |
| 326 | - if ( ! in_array( $thousand_separator, $decimals ) && ( false !== strpos( $number, $thousand_separator ) ) ) { |
|
| 327 | - $number = str_replace( $thousand_separator, '', $number ); |
|
| 328 | - } elseif ( in_array( $thousand_separator, $decimals ) ) { |
|
| 329 | - $number = preg_replace( '/\.(?=.*\.)/', '', $number ); |
|
| 324 | + if ( ! in_array($thousand_separator, $decimals) && (false !== strpos($number, $thousand_separator))) { |
|
| 325 | + $number = str_replace($thousand_separator, '', $number); |
|
| 326 | + } elseif (in_array($thousand_separator, $decimals)) { |
|
| 327 | + $number = preg_replace('/\.(?=.*\.)/', '', $number); |
|
| 330 | 328 | } |
| 331 | 329 | |
| 332 | 330 | // Remove non numeric entity before decimal separator. |
| 333 | - $number = preg_replace( '/[^0-9\.]/', '', $number ); |
|
| 334 | - $default_dp = give_get_price_decimals( $args['currency'] ); |
|
| 331 | + $number = preg_replace('/[^0-9\.]/', '', $number); |
|
| 332 | + $default_dp = give_get_price_decimals($args['currency']); |
|
| 335 | 333 | |
| 336 | 334 | // Reset negative amount to zero. |
| 337 | - if ( 0 > $number ) { |
|
| 338 | - $number = number_format( 0, $default_dp, '.' ); |
|
| 335 | + if (0 > $number) { |
|
| 336 | + $number = number_format(0, $default_dp, '.'); |
|
| 339 | 337 | } |
| 340 | 338 | |
| 341 | 339 | // If number does not have decimal then add number of decimals to it. |
| 342 | 340 | if ( |
| 343 | - false === strpos( $number, '.' ) |
|
| 344 | - || ( $default_dp > strlen( substr( $number, strpos( $number, '.' ) + 1 ) ) ) |
|
| 341 | + false === strpos($number, '.') |
|
| 342 | + || ($default_dp > strlen(substr($number, strpos($number, '.') + 1))) |
|
| 345 | 343 | ) { |
| 346 | - $number = number_format( $number, $default_dp, '.', '' ); |
|
| 344 | + $number = number_format($number, $default_dp, '.', ''); |
|
| 347 | 345 | } |
| 348 | 346 | |
| 349 | 347 | // Format number by custom number of decimals. |
| 350 | - if ( false !== $args['number_decimals'] ) { |
|
| 351 | - $dp = intval( is_bool( $args['number_decimals'] ) ? $default_dp : $args['number_decimals'] ); |
|
| 352 | - $dp = apply_filters( 'give_sanitize_amount_decimals', $dp, $number ); |
|
| 353 | - $number = number_format( floatval( $number ), $dp, '.', '' ); |
|
| 348 | + if (false !== $args['number_decimals']) { |
|
| 349 | + $dp = intval(is_bool($args['number_decimals']) ? $default_dp : $args['number_decimals']); |
|
| 350 | + $dp = apply_filters('give_sanitize_amount_decimals', $dp, $number); |
|
| 351 | + $number = number_format(floatval($number), $dp, '.', ''); |
|
| 354 | 352 | } |
| 355 | 353 | |
| 356 | 354 | // Trim zeros. |
| 357 | - if ( $args['trim_zeros'] && strstr( $number, '.' ) ) { |
|
| 358 | - $number = rtrim( rtrim( $number, '0' ), '.' ); |
|
| 355 | + if ($args['trim_zeros'] && strstr($number, '.')) { |
|
| 356 | + $number = rtrim(rtrim($number, '0'), '.'); |
|
| 359 | 357 | } |
| 360 | 358 | |
| 361 | 359 | /** |
@@ -363,7 +361,7 @@ discard block |
||
| 363 | 361 | * |
| 364 | 362 | * @since 1.0 |
| 365 | 363 | */ |
| 366 | - return apply_filters( 'give_sanitize_amount', $number ); |
|
| 364 | + return apply_filters('give_sanitize_amount', $number); |
|
| 367 | 365 | } |
| 368 | 366 | |
| 369 | 367 | /** |
@@ -376,9 +374,9 @@ discard block |
||
| 376 | 374 | * |
| 377 | 375 | * @return string $amount Newly formatted amount or Price Not Available |
| 378 | 376 | */ |
| 379 | -function give_format_amount( $amount, $args = array() ) { |
|
| 377 | +function give_format_amount($amount, $args = array()) { |
|
| 380 | 378 | // Backward compatibility. |
| 381 | - if ( is_bool( $args ) ) { |
|
| 379 | + if (is_bool($args)) { |
|
| 382 | 380 | $args = array( |
| 383 | 381 | 'decimal' => $args, |
| 384 | 382 | ); |
@@ -391,60 +389,59 @@ discard block |
||
| 391 | 389 | 'currency' => '', |
| 392 | 390 | ); |
| 393 | 391 | |
| 394 | - $args = wp_parse_args( $args, $default_args ); |
|
| 392 | + $args = wp_parse_args($args, $default_args); |
|
| 395 | 393 | |
| 396 | 394 | // Set Currency based on donation id, if required. |
| 397 | - if ( $args['donation_id'] && empty( $args['currency'] ) ) { |
|
| 398 | - $args['currency'] = give_get_meta( $args['donation_id'], '_give_payment_currency', true ); |
|
| 395 | + if ($args['donation_id'] && empty($args['currency'])) { |
|
| 396 | + $args['currency'] = give_get_meta($args['donation_id'], '_give_payment_currency', true); |
|
| 399 | 397 | } |
| 400 | 398 | |
| 401 | 399 | $formatted = 0; |
| 402 | - $currency = ! empty( $args['currency'] ) ? $args['currency'] : give_get_currency( $args['donation_id'] ); |
|
| 403 | - $thousands_sep = give_get_price_thousand_separator( $currency ); |
|
| 404 | - $decimal_sep = give_get_price_decimal_separator( $currency ); |
|
| 405 | - $decimals = ! empty( $args['decimal'] ) ? give_get_price_decimals( $currency ) : 0; |
|
| 400 | + $currency = ! empty($args['currency']) ? $args['currency'] : give_get_currency($args['donation_id']); |
|
| 401 | + $thousands_sep = give_get_price_thousand_separator($currency); |
|
| 402 | + $decimal_sep = give_get_price_decimal_separator($currency); |
|
| 403 | + $decimals = ! empty($args['decimal']) ? give_get_price_decimals($currency) : 0; |
|
| 406 | 404 | |
| 407 | - if ( ! empty( $amount ) ) { |
|
| 405 | + if ( ! empty($amount)) { |
|
| 408 | 406 | // Sanitize amount before formatting. |
| 409 | - $amount = ! empty( $args['sanitize'] ) ? |
|
| 410 | - give_maybe_sanitize_amount( $amount, array( 'number_decimals' => $decimals, 'currency' => $currency ) ) : |
|
| 411 | - number_format( $amount, $decimals, '.', '' ); |
|
| 407 | + $amount = ! empty($args['sanitize']) ? |
|
| 408 | + give_maybe_sanitize_amount($amount, array('number_decimals' => $decimals, 'currency' => $currency)) : number_format($amount, $decimals, '.', ''); |
|
| 412 | 409 | |
| 413 | - switch ( $currency ) { |
|
| 410 | + switch ($currency) { |
|
| 414 | 411 | case 'INR': |
| 415 | 412 | $decimal_amount = ''; |
| 416 | 413 | |
| 417 | 414 | // Extract decimals from amount |
| 418 | - if ( ( $pos = strpos( $amount, '.' ) ) !== false ) { |
|
| 419 | - if ( ! empty( $decimals ) ) { |
|
| 420 | - $decimal_amount = substr( round( substr( $amount, $pos ), $decimals ), 1 ); |
|
| 421 | - $amount = substr( $amount, 0, $pos ); |
|
| 422 | - |
|
| 423 | - if ( ! $decimal_amount ) { |
|
| 424 | - $decimal_amount = substr( "{$decimal_sep}0000000000", 0, ( $decimals + 1 ) ); |
|
| 425 | - } elseif ( ( $decimals + 1 ) > strlen( $decimal_amount ) ) { |
|
| 426 | - $decimal_amount = substr( "{$decimal_amount}000000000", 0, ( $decimals + 1 ) ); |
|
| 415 | + if (($pos = strpos($amount, '.')) !== false) { |
|
| 416 | + if ( ! empty($decimals)) { |
|
| 417 | + $decimal_amount = substr(round(substr($amount, $pos), $decimals), 1); |
|
| 418 | + $amount = substr($amount, 0, $pos); |
|
| 419 | + |
|
| 420 | + if ( ! $decimal_amount) { |
|
| 421 | + $decimal_amount = substr("{$decimal_sep}0000000000", 0, ($decimals + 1)); |
|
| 422 | + } elseif (($decimals + 1) > strlen($decimal_amount)) { |
|
| 423 | + $decimal_amount = substr("{$decimal_amount}000000000", 0, ($decimals + 1)); |
|
| 427 | 424 | } |
| 428 | 425 | } else { |
| 429 | - $amount = number_format( $amount, $decimals, $decimal_sep, '' ); |
|
| 426 | + $amount = number_format($amount, $decimals, $decimal_sep, ''); |
|
| 430 | 427 | } |
| 431 | 428 | } |
| 432 | 429 | |
| 433 | 430 | // Extract last 3 from amount |
| 434 | - $result = substr( $amount, - 3 ); |
|
| 435 | - $amount = substr( $amount, 0, - 3 ); |
|
| 431 | + $result = substr($amount, - 3); |
|
| 432 | + $amount = substr($amount, 0, - 3); |
|
| 436 | 433 | |
| 437 | 434 | // Apply digits 2 by 2 |
| 438 | - while ( strlen( $amount ) > 0 ) { |
|
| 439 | - $result = substr( $amount, - 2 ) . $thousands_sep . $result; |
|
| 440 | - $amount = substr( $amount, 0, - 2 ); |
|
| 435 | + while (strlen($amount) > 0) { |
|
| 436 | + $result = substr($amount, - 2).$thousands_sep.$result; |
|
| 437 | + $amount = substr($amount, 0, - 2); |
|
| 441 | 438 | } |
| 442 | 439 | |
| 443 | - $formatted = $result . $decimal_amount; |
|
| 440 | + $formatted = $result.$decimal_amount; |
|
| 444 | 441 | break; |
| 445 | 442 | |
| 446 | 443 | default: |
| 447 | - $formatted = number_format( $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
| 444 | + $formatted = number_format($amount, $decimals, $decimal_sep, $thousands_sep); |
|
| 448 | 445 | } |
| 449 | 446 | } |
| 450 | 447 | |
@@ -453,7 +450,7 @@ discard block |
||
| 453 | 450 | * |
| 454 | 451 | * @since 1.0 |
| 455 | 452 | */ |
| 456 | - return apply_filters( 'give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $currency, $args ); |
|
| 453 | + return apply_filters('give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $currency, $args); |
|
| 457 | 454 | } |
| 458 | 455 | |
| 459 | 456 | |
@@ -471,17 +468,17 @@ discard block |
||
| 471 | 468 | * |
| 472 | 469 | * @return string formatted amount number with large number names. |
| 473 | 470 | */ |
| 474 | -function give_human_format_large_amount( $amount, $args = array() ) { |
|
| 471 | +function give_human_format_large_amount($amount, $args = array()) { |
|
| 475 | 472 | // Sanitize amount. |
| 476 | - $sanitize_amount = give_maybe_sanitize_amount( $amount ); |
|
| 473 | + $sanitize_amount = give_maybe_sanitize_amount($amount); |
|
| 477 | 474 | |
| 478 | 475 | // Bailout. |
| 479 | - if ( ! floatval( $sanitize_amount ) ) { |
|
| 476 | + if ( ! floatval($sanitize_amount)) { |
|
| 480 | 477 | return '0'; |
| 481 | 478 | }; |
| 482 | 479 | |
| 483 | 480 | // Set default currency; |
| 484 | - if ( empty( $args['currency'] ) ) { |
|
| 481 | + if (empty($args['currency'])) { |
|
| 485 | 482 | $args['currency'] = give_get_currency(); |
| 486 | 483 | } |
| 487 | 484 | |
@@ -489,37 +486,37 @@ discard block |
||
| 489 | 486 | $thousands_sep = give_get_price_thousand_separator(); |
| 490 | 487 | |
| 491 | 488 | // Explode amount to calculate name of large numbers. |
| 492 | - $amount_array = explode( $thousands_sep, $amount ); |
|
| 489 | + $amount_array = explode($thousands_sep, $amount); |
|
| 493 | 490 | |
| 494 | 491 | // Calculate amount parts count. |
| 495 | - $amount_count_parts = count( $amount_array ); |
|
| 492 | + $amount_count_parts = count($amount_array); |
|
| 496 | 493 | |
| 497 | 494 | // Human format amount (default). |
| 498 | 495 | $human_format_amount = $amount; |
| 499 | 496 | |
| 500 | - switch ( $args['currency'] ) { |
|
| 497 | + switch ($args['currency']) { |
|
| 501 | 498 | case 'INR': |
| 502 | 499 | // Calculate large number formatted amount. |
| 503 | - if ( 4 < $amount_count_parts ) { |
|
| 504 | - $human_format_amount = sprintf( esc_html__( '%s arab', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) ); |
|
| 505 | - } elseif ( 3 < $amount_count_parts ) { |
|
| 506 | - $human_format_amount = sprintf( esc_html__( '%s crore', 'give' ), round( ( $sanitize_amount / 10000000 ), 2 ) ); |
|
| 507 | - } elseif ( 2 < $amount_count_parts ) { |
|
| 508 | - $human_format_amount = sprintf( esc_html__( '%s lakh', 'give' ), round( ( $sanitize_amount / 100000 ), 2 ) ); |
|
| 500 | + if (4 < $amount_count_parts) { |
|
| 501 | + $human_format_amount = sprintf(esc_html__('%s arab', 'give'), round(($sanitize_amount / 1000000000), 2)); |
|
| 502 | + } elseif (3 < $amount_count_parts) { |
|
| 503 | + $human_format_amount = sprintf(esc_html__('%s crore', 'give'), round(($sanitize_amount / 10000000), 2)); |
|
| 504 | + } elseif (2 < $amount_count_parts) { |
|
| 505 | + $human_format_amount = sprintf(esc_html__('%s lakh', 'give'), round(($sanitize_amount / 100000), 2)); |
|
| 509 | 506 | } |
| 510 | 507 | break; |
| 511 | 508 | default: |
| 512 | 509 | // Calculate large number formatted amount. |
| 513 | - if ( 4 < $amount_count_parts ) { |
|
| 514 | - $human_format_amount = sprintf( esc_html__( '%s trillion', 'give' ), round( ( $sanitize_amount / 1000000000000 ), 2 ) ); |
|
| 515 | - } elseif ( 3 < $amount_count_parts ) { |
|
| 516 | - $human_format_amount = sprintf( esc_html__( '%s billion', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) ); |
|
| 517 | - } elseif ( 2 < $amount_count_parts ) { |
|
| 518 | - $human_format_amount = sprintf( esc_html__( '%s million', 'give' ), round( ( $sanitize_amount / 1000000 ), 2 ) ); |
|
| 510 | + if (4 < $amount_count_parts) { |
|
| 511 | + $human_format_amount = sprintf(esc_html__('%s trillion', 'give'), round(($sanitize_amount / 1000000000000), 2)); |
|
| 512 | + } elseif (3 < $amount_count_parts) { |
|
| 513 | + $human_format_amount = sprintf(esc_html__('%s billion', 'give'), round(($sanitize_amount / 1000000000), 2)); |
|
| 514 | + } elseif (2 < $amount_count_parts) { |
|
| 515 | + $human_format_amount = sprintf(esc_html__('%s million', 'give'), round(($sanitize_amount / 1000000), 2)); |
|
| 519 | 516 | } |
| 520 | 517 | } |
| 521 | 518 | |
| 522 | - return apply_filters( 'give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount ); |
|
| 519 | + return apply_filters('give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount); |
|
| 523 | 520 | } |
| 524 | 521 | |
| 525 | 522 | /** |
@@ -533,17 +530,16 @@ discard block |
||
| 533 | 530 | * |
| 534 | 531 | * @return string $amount Newly formatted amount or Price Not Available |
| 535 | 532 | */ |
| 536 | -function give_format_decimal( $amount, $dp = false, $sanitize = true ) { |
|
| 533 | +function give_format_decimal($amount, $dp = false, $sanitize = true) { |
|
| 537 | 534 | $decimal_separator = give_get_price_decimal_separator(); |
| 538 | 535 | $formatted_amount = $sanitize ? |
| 539 | - give_maybe_sanitize_amount( $amount, array( 'number_decimals' => $dp ) ) : |
|
| 540 | - number_format( $amount, ( is_bool( $dp ) ? give_get_price_decimals() : $dp ), '.', '' ); |
|
| 536 | + give_maybe_sanitize_amount($amount, array('number_decimals' => $dp)) : number_format($amount, (is_bool($dp) ? give_get_price_decimals() : $dp), '.', ''); |
|
| 541 | 537 | |
| 542 | - if ( false !== strpos( $formatted_amount, '.' ) ) { |
|
| 543 | - $formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount ); |
|
| 538 | + if (false !== strpos($formatted_amount, '.')) { |
|
| 539 | + $formatted_amount = str_replace('.', $decimal_separator, $formatted_amount); |
|
| 544 | 540 | } |
| 545 | 541 | |
| 546 | - return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator ); |
|
| 542 | + return apply_filters('give_format_decimal', $formatted_amount, $amount, $decimal_separator); |
|
| 547 | 543 | } |
| 548 | 544 | |
| 549 | 545 | /** |
@@ -555,7 +551,7 @@ discard block |
||
| 555 | 551 | * |
| 556 | 552 | * @return string Date format string |
| 557 | 553 | */ |
| 558 | -function give_date_format( $date_context = '' ) { |
|
| 554 | +function give_date_format($date_context = '') { |
|
| 559 | 555 | /** |
| 560 | 556 | * Filter the date context |
| 561 | 557 | * |
@@ -576,19 +572,19 @@ discard block |
||
| 576 | 572 | * |
| 577 | 573 | * } |
| 578 | 574 | */ |
| 579 | - $date_format_contexts = apply_filters( 'give_date_format_contexts', array() ); |
|
| 575 | + $date_format_contexts = apply_filters('give_date_format_contexts', array()); |
|
| 580 | 576 | |
| 581 | 577 | // Set date format to default date format. |
| 582 | - $date_format = get_option( 'date_format' ); |
|
| 578 | + $date_format = get_option('date_format'); |
|
| 583 | 579 | |
| 584 | 580 | // Update date format if we have non empty date format context array and non empty date format string for that context. |
| 585 | - if ( $date_context && ! empty( $date_format_contexts ) && array_key_exists( $date_context, $date_format_contexts ) ) { |
|
| 586 | - $date_format = ! empty( $date_format_contexts[ $date_context ] ) |
|
| 587 | - ? $date_format_contexts[ $date_context ] |
|
| 581 | + if ($date_context && ! empty($date_format_contexts) && array_key_exists($date_context, $date_format_contexts)) { |
|
| 582 | + $date_format = ! empty($date_format_contexts[$date_context]) |
|
| 583 | + ? $date_format_contexts[$date_context] |
|
| 588 | 584 | : $date_format; |
| 589 | 585 | } |
| 590 | 586 | |
| 591 | - return apply_filters( 'give_date_format', $date_format ); |
|
| 587 | + return apply_filters('give_date_format', $date_format); |
|
| 592 | 588 | } |
| 593 | 589 | |
| 594 | 590 | /** |
@@ -602,8 +598,8 @@ discard block |
||
| 602 | 598 | * |
| 603 | 599 | * @return string |
| 604 | 600 | */ |
| 605 | -function give_get_cache_key( $action, $query_args ) { |
|
| 606 | - return Give_Cache::get_key( $action, $query_args ); |
|
| 601 | +function give_get_cache_key($action, $query_args) { |
|
| 602 | + return Give_Cache::get_key($action, $query_args); |
|
| 607 | 603 | } |
| 608 | 604 | |
| 609 | 605 | /** |
@@ -616,11 +612,11 @@ discard block |
||
| 616 | 612 | * |
| 617 | 613 | * @return string|array |
| 618 | 614 | */ |
| 619 | -function give_clean( $var ) { |
|
| 620 | - if ( is_array( $var ) ) { |
|
| 621 | - return array_map( 'give_clean', $var ); |
|
| 615 | +function give_clean($var) { |
|
| 616 | + if (is_array($var)) { |
|
| 617 | + return array_map('give_clean', $var); |
|
| 622 | 618 | } else { |
| 623 | - return is_scalar( $var ) ? sanitize_text_field( wp_unslash( $var ) ) : $var; |
|
| 619 | + return is_scalar($var) ? sanitize_text_field(wp_unslash($var)) : $var; |
|
| 624 | 620 | } |
| 625 | 621 | } |
| 626 | 622 | |
@@ -633,10 +629,10 @@ discard block |
||
| 633 | 629 | * |
| 634 | 630 | * @return int |
| 635 | 631 | */ |
| 636 | -function give_let_to_num( $size ) { |
|
| 637 | - $l = substr( $size, - 1 ); |
|
| 638 | - $ret = substr( $size, 0, - 1 ); |
|
| 639 | - switch ( strtoupper( $l ) ) { |
|
| 632 | +function give_let_to_num($size) { |
|
| 633 | + $l = substr($size, - 1); |
|
| 634 | + $ret = substr($size, 0, - 1); |
|
| 635 | + switch (strtoupper($l)) { |
|
| 640 | 636 | case 'P': |
| 641 | 637 | $ret *= 1024; |
| 642 | 638 | case 'T': |
@@ -663,22 +659,22 @@ discard block |
||
| 663 | 659 | * |
| 664 | 660 | * @return bool |
| 665 | 661 | */ |
| 666 | -function give_validate_nonce( $nonce, $action = - 1, $wp_die_args = array() ) { |
|
| 662 | +function give_validate_nonce($nonce, $action = - 1, $wp_die_args = array()) { |
|
| 667 | 663 | |
| 668 | 664 | // Verify nonce. |
| 669 | - $verify_nonce = wp_verify_nonce( $nonce, $action ); |
|
| 665 | + $verify_nonce = wp_verify_nonce($nonce, $action); |
|
| 670 | 666 | |
| 671 | 667 | // On ajax request send nonce verification status. |
| 672 | - if ( wp_doing_ajax() ) { |
|
| 668 | + if (wp_doing_ajax()) { |
|
| 673 | 669 | return $verify_nonce; |
| 674 | 670 | } |
| 675 | 671 | |
| 676 | - if ( ! $verify_nonce ) { |
|
| 672 | + if ( ! $verify_nonce) { |
|
| 677 | 673 | $wp_die_args = wp_parse_args( |
| 678 | 674 | $wp_die_args, |
| 679 | 675 | array( |
| 680 | - 'message' => __( 'Nonce verification has failed.', 'give' ), |
|
| 681 | - 'title' => __( 'Error', 'give' ), |
|
| 676 | + 'message' => __('Nonce verification has failed.', 'give'), |
|
| 677 | + 'title' => __('Error', 'give'), |
|
| 682 | 678 | 'args' => array( |
| 683 | 679 | 'response' => 403, |
| 684 | 680 | ), |
@@ -705,16 +701,16 @@ discard block |
||
| 705 | 701 | * |
| 706 | 702 | * @return bool |
| 707 | 703 | */ |
| 708 | -function give_verify_donation_form_nonce( $nonce = '', $form_id ) { |
|
| 704 | +function give_verify_donation_form_nonce($nonce = '', $form_id) { |
|
| 709 | 705 | |
| 710 | 706 | // Form nonce action. |
| 711 | 707 | $nonce_action = "give_donation_form_nonce_{$form_id}"; |
| 712 | 708 | |
| 713 | 709 | // Nonce validation. |
| 714 | - $verify_nonce = give_validate_nonce( $nonce, $nonce_action ); |
|
| 710 | + $verify_nonce = give_validate_nonce($nonce, $nonce_action); |
|
| 715 | 711 | |
| 716 | - if ( ! $verify_nonce ) { |
|
| 717 | - give_set_error( 'donation_form_nonce', __( 'Nonce verification has failed.', 'give' ) ); |
|
| 712 | + if ( ! $verify_nonce) { |
|
| 713 | + give_set_error('donation_form_nonce', __('Nonce verification has failed.', 'give')); |
|
| 718 | 714 | } |
| 719 | 715 | |
| 720 | 716 | return $verify_nonce; |
@@ -734,43 +730,43 @@ discard block |
||
| 734 | 730 | * |
| 735 | 731 | * @return mixed |
| 736 | 732 | */ |
| 737 | -function give_check_variable( $variable, $conditional = '', $default = false, $array_key_name = '' ) { |
|
| 733 | +function give_check_variable($variable, $conditional = '', $default = false, $array_key_name = '') { |
|
| 738 | 734 | // Get value from array if array key non empty. |
| 739 | - if( empty( $array_key_name ) ) { |
|
| 740 | - switch ( $conditional ) { |
|
| 735 | + if (empty($array_key_name)) { |
|
| 736 | + switch ($conditional) { |
|
| 741 | 737 | case 'isset_empty': |
| 742 | - $variable = ( isset( $variable ) && ! empty( $variable ) ) ? $variable : $default; |
|
| 738 | + $variable = (isset($variable) && ! empty($variable)) ? $variable : $default; |
|
| 743 | 739 | break; |
| 744 | 740 | |
| 745 | 741 | case 'empty': |
| 746 | - $variable = ! empty( $variable ) ? $variable : $default; |
|
| 742 | + $variable = ! empty($variable) ? $variable : $default; |
|
| 747 | 743 | break; |
| 748 | 744 | |
| 749 | 745 | case 'null': |
| 750 | - $variable = ! is_null( $variable ) ? $variable : $default; |
|
| 746 | + $variable = ! is_null($variable) ? $variable : $default; |
|
| 751 | 747 | break; |
| 752 | 748 | |
| 753 | 749 | default: |
| 754 | - $variable = isset( $variable ) ? $variable : $default; |
|
| 750 | + $variable = isset($variable) ? $variable : $default; |
|
| 755 | 751 | } |
| 756 | 752 | } else { |
| 757 | - $isset = array_key_exists( $array_key_name, $variable ); |
|
| 753 | + $isset = array_key_exists($array_key_name, $variable); |
|
| 758 | 754 | |
| 759 | - switch ( $conditional ) { |
|
| 755 | + switch ($conditional) { |
|
| 760 | 756 | case 'isset_empty': |
| 761 | - $variable = ( $isset && ! empty( $variable[ $array_key_name ] ) ) ? $variable[ $array_key_name ] : $default; |
|
| 757 | + $variable = ($isset && ! empty($variable[$array_key_name])) ? $variable[$array_key_name] : $default; |
|
| 762 | 758 | break; |
| 763 | 759 | |
| 764 | 760 | case 'empty': |
| 765 | - $variable = ! empty( $variable[ $array_key_name ] ) ? $variable[ $array_key_name ] : $default; |
|
| 761 | + $variable = ! empty($variable[$array_key_name]) ? $variable[$array_key_name] : $default; |
|
| 766 | 762 | break; |
| 767 | 763 | |
| 768 | 764 | case 'null': |
| 769 | - $variable = $isset && ! is_null( $variable[ $array_key_name ] ) ? $variable[ $array_key_name ] : $default; |
|
| 765 | + $variable = $isset && ! is_null($variable[$array_key_name]) ? $variable[$array_key_name] : $default; |
|
| 770 | 766 | break; |
| 771 | 767 | |
| 772 | 768 | default: |
| 773 | - $variable = $isset && isset( $variable[ $array_key_name ] ) ? $variable[ $array_key_name ] : $default; |
|
| 769 | + $variable = $isset && isset($variable[$array_key_name]) ? $variable[$array_key_name] : $default; |
|
| 774 | 770 | } |
| 775 | 771 | } |
| 776 | 772 | |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | // Exit if accessed directly. |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; |
| 14 | 14 | } |
| 15 | 15 | |
@@ -23,10 +23,10 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | public function __construct() { |
| 25 | 25 | |
| 26 | - $this->shortcode['title'] = esc_html__( 'Donation Form Goal', 'give' ); |
|
| 27 | - $this->shortcode['label'] = esc_html__( 'Donation Form Goal', 'give' ); |
|
| 26 | + $this->shortcode['title'] = esc_html__('Donation Form Goal', 'give'); |
|
| 27 | + $this->shortcode['label'] = esc_html__('Donation Form Goal', 'give'); |
|
| 28 | 28 | |
| 29 | - parent::__construct( 'give_goal' ); |
|
| 29 | + parent::__construct('give_goal'); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | $create_form_link = sprintf( |
| 40 | 40 | /* translators: %s: create new form URL */ |
| 41 | - __( '<a href="%s">Create</a> a new Donation Form.', 'give' ), |
|
| 42 | - admin_url( 'post-new.php?post_type=give_forms' ) |
|
| 41 | + __('<a href="%s">Create</a> a new Donation Form.', 'give'), |
|
| 42 | + admin_url('post-new.php?post_type=give_forms') |
|
| 43 | 43 | ); |
| 44 | 44 | |
| 45 | 45 | return array( |
@@ -51,35 +51,35 @@ discard block |
||
| 51 | 51 | 'meta_value' => 'enabled', |
| 52 | 52 | ), |
| 53 | 53 | 'name' => 'id', |
| 54 | - 'tooltip' => esc_attr__( 'Select a Donation Form', 'give' ), |
|
| 55 | - 'placeholder' => '- ' . esc_attr__( 'Select a Donation Form', 'give' ) . ' -', |
|
| 54 | + 'tooltip' => esc_attr__('Select a Donation Form', 'give'), |
|
| 55 | + 'placeholder' => '- '.esc_attr__('Select a Donation Form', 'give').' -', |
|
| 56 | 56 | 'required' => array( |
| 57 | - 'alert' => esc_html__( 'You must first select a Form!', 'give' ), |
|
| 58 | - 'error' => sprintf( '<p class="strong">%s</p><p class="no-margin">%s</p>', esc_html__( 'No forms found.', 'give' ), $create_form_link ), |
|
| 57 | + 'alert' => esc_html__('You must first select a Form!', 'give'), |
|
| 58 | + 'error' => sprintf('<p class="strong">%s</p><p class="no-margin">%s</p>', esc_html__('No forms found.', 'give'), $create_form_link), |
|
| 59 | 59 | ), |
| 60 | 60 | ), |
| 61 | 61 | array( |
| 62 | 62 | 'type' => 'container', |
| 63 | - 'html' => sprintf( '<p class="strong margin-top">%s</p>', esc_html__( 'Optional settings', 'give' ) ), |
|
| 63 | + 'html' => sprintf('<p class="strong margin-top">%s</p>', esc_html__('Optional settings', 'give')), |
|
| 64 | 64 | ), |
| 65 | 65 | array( |
| 66 | 66 | 'type' => 'listbox', |
| 67 | 67 | 'name' => 'show_text', |
| 68 | - 'label' => esc_attr__( 'Show Text:', 'give' ), |
|
| 69 | - 'tooltip' => esc_attr__( 'This text displays the amount of income raised compared to the goal.', 'give' ), |
|
| 68 | + 'label' => esc_attr__('Show Text:', 'give'), |
|
| 69 | + 'tooltip' => esc_attr__('This text displays the amount of income raised compared to the goal.', 'give'), |
|
| 70 | 70 | 'options' => array( |
| 71 | - 'true' => esc_html__( 'Show', 'give' ), |
|
| 72 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
| 71 | + 'true' => esc_html__('Show', 'give'), |
|
| 72 | + 'false' => esc_html__('Hide', 'give'), |
|
| 73 | 73 | ), |
| 74 | 74 | ), |
| 75 | 75 | array( |
| 76 | 76 | 'type' => 'listbox', |
| 77 | 77 | 'name' => 'show_bar', |
| 78 | - 'label' => esc_attr__( 'Show Progress Bar:', 'give' ), |
|
| 79 | - 'tooltip' => esc_attr__( 'Do you want to display the goal\'s progress bar?', 'give' ), |
|
| 78 | + 'label' => esc_attr__('Show Progress Bar:', 'give'), |
|
| 79 | + 'tooltip' => esc_attr__('Do you want to display the goal\'s progress bar?', 'give'), |
|
| 80 | 80 | 'options' => array( |
| 81 | - 'true' => esc_html__( 'Show', 'give' ), |
|
| 82 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
| 81 | + 'true' => esc_html__('Show', 'give'), |
|
| 82 | + 'false' => esc_html__('Hide', 'give'), |
|
| 83 | 83 | ), |
| 84 | 84 | ), |
| 85 | 85 | ); |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | /** |
| 3 | 3 | * This template is used to display the registration form with [give_register] |
| 4 | 4 | */ |
| 5 | -Give()->notices->render_frontend_notices( 0 ); ?> |
|
| 5 | +Give()->notices->render_frontend_notices(0); ?> |
|
| 6 | 6 | |
| 7 | 7 | <form id="give-register-form" class="give-form" action="" method="post"> |
| 8 | 8 | <?php |
@@ -13,11 +13,11 @@ discard block |
||
| 13 | 13 | * |
| 14 | 14 | * @since 1.0 |
| 15 | 15 | */ |
| 16 | - do_action( 'give_register_form_fields_top' ); |
|
| 16 | + do_action('give_register_form_fields_top'); |
|
| 17 | 17 | ?> |
| 18 | 18 | |
| 19 | 19 | <fieldset> |
| 20 | - <legend><?php esc_html_e( 'Register a New Account', 'give' ); ?></legend> |
|
| 20 | + <legend><?php esc_html_e('Register a New Account', 'give'); ?></legend> |
|
| 21 | 21 | |
| 22 | 22 | <?php |
| 23 | 23 | /** |
@@ -27,26 +27,26 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | * @since 1.0 |
| 29 | 29 | */ |
| 30 | - do_action( 'give_register_form_fields_before' ); |
|
| 30 | + do_action('give_register_form_fields_before'); |
|
| 31 | 31 | ?> |
| 32 | 32 | |
| 33 | 33 | <div class="form-row form-row-first form-row-responsive"> |
| 34 | - <label for="give-user-login"><?php esc_html_e( 'Username', 'give' ); ?></label> |
|
| 34 | + <label for="give-user-login"><?php esc_html_e('Username', 'give'); ?></label> |
|
| 35 | 35 | <input id="give-user-login" class="required give-input" type="text" name="give_user_login" required aria-required="true" /> |
| 36 | 36 | </div> |
| 37 | 37 | |
| 38 | 38 | <div class="form-row form-row-last form-row-responsive"> |
| 39 | - <label for="give-user-email"><?php esc_html_e( 'Email', 'give' ); ?></label> |
|
| 39 | + <label for="give-user-email"><?php esc_html_e('Email', 'give'); ?></label> |
|
| 40 | 40 | <input id="give-user-email" class="required give-input" type="email" name="give_user_email" required aria-required="true" /> |
| 41 | 41 | </div> |
| 42 | 42 | |
| 43 | 43 | <div class="form-row form-row-first form-row-responsive"> |
| 44 | - <label for="give-user-pass"><?php esc_html_e( 'Password', 'give' ); ?></label> |
|
| 44 | + <label for="give-user-pass"><?php esc_html_e('Password', 'give'); ?></label> |
|
| 45 | 45 | <input id="give-user-pass" class="password required give-input" type="password" name="give_user_pass" required aria-required="true" /> |
| 46 | 46 | </div> |
| 47 | 47 | |
| 48 | 48 | <div class="form-row form-row-last form-row-responsive"> |
| 49 | - <label for="give-user-pass2"><?php esc_html_e( 'Confirm PW', 'give' ); ?></label> |
|
| 49 | + <label for="give-user-pass2"><?php esc_html_e('Confirm PW', 'give'); ?></label> |
|
| 50 | 50 | <input id="give-user-pass2" class="password required give-input" type="password" name="give_user_pass2" required aria-required="true" /> |
| 51 | 51 | </div> |
| 52 | 52 | |
@@ -58,17 +58,17 @@ discard block |
||
| 58 | 58 | * |
| 59 | 59 | * @since 1.0 |
| 60 | 60 | */ |
| 61 | - do_action( 'give_register_form_fields_before_submit' ); |
|
| 61 | + do_action('give_register_form_fields_before_submit'); |
|
| 62 | 62 | ?> |
| 63 | 63 | |
| 64 | 64 | <div class="give-hidden"> |
| 65 | 65 | <input type="hidden" name="give_honeypot" value="" /> |
| 66 | 66 | <input type="hidden" name="give_action" value="user_register" /> |
| 67 | - <input type="hidden" name="give_redirect" value="<?php echo esc_url( $give_register_redirect ); ?>" /> |
|
| 67 | + <input type="hidden" name="give_redirect" value="<?php echo esc_url($give_register_redirect); ?>" /> |
|
| 68 | 68 | </div> |
| 69 | 69 | |
| 70 | 70 | <div class="form-row"> |
| 71 | - <input class="button" name="give_register_submit" type="submit" value="<?php esc_attr_e( 'Register', 'give' ); ?>" /> |
|
| 71 | + <input class="button" name="give_register_submit" type="submit" value="<?php esc_attr_e('Register', 'give'); ?>" /> |
|
| 72 | 72 | </div> |
| 73 | 73 | |
| 74 | 74 | <?php |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | * |
| 80 | 80 | * @since 1.0 |
| 81 | 81 | */ |
| 82 | - do_action( 'give_register_form_fields_after' ); |
|
| 82 | + do_action('give_register_form_fields_after'); |
|
| 83 | 83 | ?> |
| 84 | 84 | |
| 85 | 85 | </fieldset> |
@@ -92,6 +92,6 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @since 1.0 |
| 94 | 94 | */ |
| 95 | - do_action( 'give_register_form_fields_bottom' ); |
|
| 95 | + do_action('give_register_form_fields_bottom'); |
|
| 96 | 96 | ?> |
| 97 | 97 | </form> |
@@ -9,13 +9,13 @@ discard block |
||
| 9 | 9 | * @since 1.0 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) {
|
|
| 12 | +if ( ! defined('ABSPATH')) {
|
|
| 13 | 13 | exit; // Exit if accessed directly. |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -$template = strtolower( get_option( 'template' ) ); |
|
| 16 | +$template = strtolower(get_option('template'));
|
|
| 17 | 17 | |
| 18 | -switch ( $template ) {
|
|
| 18 | +switch ($template) {
|
|
| 19 | 19 | case 'twentyeleven' : |
| 20 | 20 | echo '<div id="primary" class="give-wrap"><div id="content" role="main" class="twentyeleven">'; |
| 21 | 21 | break; |
@@ -65,6 +65,6 @@ discard block |
||
| 65 | 65 | echo '<div class="wrapper hentry" style="box-sizing: border-box;">'; |
| 66 | 66 | break; |
| 67 | 67 | default : |
| 68 | - echo apply_filters( 'give_default_wrapper_start', '<div id="container" class="give-wrap container"><div id="content" role="main">' ); |
|
| 68 | + echo apply_filters('give_default_wrapper_start', '<div id="container" class="give-wrap container"><div id="content" role="main">');
|
|
| 69 | 69 | break; |
| 70 | 70 | } |
| 71 | 71 | \ No newline at end of file |
@@ -9,13 +9,13 @@ discard block |
||
| 9 | 9 | * @since 1.0 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) {
|
|
| 12 | +if ( ! defined('ABSPATH')) {
|
|
| 13 | 13 | exit; // Exit if accessed directly. |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -$template = get_option( 'template' ); |
|
| 16 | +$template = get_option('template');
|
|
| 17 | 17 | |
| 18 | -switch ( $template ) {
|
|
| 18 | +switch ($template) {
|
|
| 19 | 19 | case 'twentyeleven' : |
| 20 | 20 | echo '</div></div>'; |
| 21 | 21 | break; |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | break; |
| 28 | 28 | case 'twentyfourteen' : |
| 29 | 29 | echo '</div></div></div>'; |
| 30 | - get_sidebar( 'content' ); |
|
| 30 | + get_sidebar('content');
|
|
| 31 | 31 | break; |
| 32 | 32 | case 'twentyfifteen' : |
| 33 | 33 | echo '</div></div>'; |
@@ -57,6 +57,6 @@ discard block |
||
| 57 | 57 | echo '</div>'; |
| 58 | 58 | break; |
| 59 | 59 | default : |
| 60 | - echo apply_filters( 'give_default_wrapper_end', '</div></div>' ); |
|
| 60 | + echo apply_filters('give_default_wrapper_end', '</div></div>');
|
|
| 61 | 61 | break; |
| 62 | 62 | } |
| 63 | 63 | \ No newline at end of file |