@@ -50,7 +50,7 @@ |
||
| 50 | 50 | * @since 1.5 |
| 51 | 51 | * @global object $wpdb Used to query the database using the WordPress |
| 52 | 52 | * Database API |
| 53 | - * @return array $data The data for the CSV file |
|
| 53 | + * @return boolean $data The data for the CSV file |
|
| 54 | 54 | */ |
| 55 | 55 | public function get_data() { |
| 56 | 56 | global $wpdb; |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -55,16 +55,16 @@ discard block |
||
| 55 | 55 | public function get_data() { |
| 56 | 56 | global $wpdb; |
| 57 | 57 | |
| 58 | - $items = $this->get_stored_data( 'give_temp_reset_ids' ); |
|
| 58 | + $items = $this->get_stored_data('give_temp_reset_ids'); |
|
| 59 | 59 | |
| 60 | - if ( ! is_array( $items ) ) { |
|
| 60 | + if ( ! is_array($items)) { |
|
| 61 | 61 | return false; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
| 65 | - $step_items = array_slice( $items, $offset, $this->per_step ); |
|
| 64 | + $offset = ($this->step - 1) * $this->per_step; |
|
| 65 | + $step_items = array_slice($items, $offset, $this->per_step); |
|
| 66 | 66 | |
| 67 | - if ( $step_items ) { |
|
| 67 | + if ($step_items) { |
|
| 68 | 68 | |
| 69 | 69 | $step_ids = array( |
| 70 | 70 | 'customers' => array(), |
@@ -72,9 +72,9 @@ discard block |
||
| 72 | 72 | 'other' => array(), |
| 73 | 73 | ); |
| 74 | 74 | |
| 75 | - foreach ( $step_items as $item ) { |
|
| 75 | + foreach ($step_items as $item) { |
|
| 76 | 76 | |
| 77 | - switch ( $item['type'] ) { |
|
| 77 | + switch ($item['type']) { |
|
| 78 | 78 | case 'customer': |
| 79 | 79 | $step_ids['customers'][] = $item['id']; |
| 80 | 80 | break; |
@@ -82,8 +82,8 @@ discard block |
||
| 82 | 82 | $step_ids['give_forms'][] = $item['id']; |
| 83 | 83 | break; |
| 84 | 84 | default: |
| 85 | - $item_type = apply_filters( 'give_reset_item_type', 'other', $item ); |
|
| 86 | - $step_ids[ $item_type ][] = $item['id']; |
|
| 85 | + $item_type = apply_filters('give_reset_item_type', 'other', $item); |
|
| 86 | + $step_ids[$item_type][] = $item['id']; |
|
| 87 | 87 | break; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -91,17 +91,17 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | $sql = array(); |
| 93 | 93 | |
| 94 | - foreach ( $step_ids as $type => $ids ) { |
|
| 94 | + foreach ($step_ids as $type => $ids) { |
|
| 95 | 95 | |
| 96 | - if ( empty( $ids ) ) { |
|
| 96 | + if (empty($ids)) { |
|
| 97 | 97 | continue; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - $ids = implode( ',', $ids ); |
|
| 100 | + $ids = implode(',', $ids); |
|
| 101 | 101 | |
| 102 | - switch ( $type ) { |
|
| 102 | + switch ($type) { |
|
| 103 | 103 | case 'customers': |
| 104 | - $table_name = $wpdb->prefix . 'give_customers'; |
|
| 104 | + $table_name = $wpdb->prefix.'give_customers'; |
|
| 105 | 105 | $sql[] = "DELETE FROM $table_name WHERE id IN ($ids)"; |
| 106 | 106 | break; |
| 107 | 107 | case 'forms': |
@@ -116,18 +116,18 @@ discard block |
||
| 116 | 116 | break; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - if ( ! in_array( $type, array( 'customers', 'forms', 'other' ) ) ) { |
|
| 119 | + if ( ! in_array($type, array('customers', 'forms', 'other'))) { |
|
| 120 | 120 | // Allows other types of custom post types to filter on their own post_type |
| 121 | 121 | // and add items to the query list, for the IDs found in their post type. |
| 122 | - $sql = apply_filters( 'give_reset_add_queries_' . $type, $sql, $ids ); |
|
| 122 | + $sql = apply_filters('give_reset_add_queries_'.$type, $sql, $ids); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - if ( ! empty( $sql ) ) { |
|
| 129 | - foreach ( $sql as $query ) { |
|
| 130 | - $wpdb->query( $query ); |
|
| 128 | + if ( ! empty($sql)) { |
|
| 129 | + foreach ($sql as $query) { |
|
| 130 | + $wpdb->query($query); |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
@@ -147,16 +147,16 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | public function get_percentage_complete() { |
| 149 | 149 | |
| 150 | - $items = $this->get_stored_data( 'give_temp_reset_ids', false ); |
|
| 151 | - $total = count( $items ); |
|
| 150 | + $items = $this->get_stored_data('give_temp_reset_ids', false); |
|
| 151 | + $total = count($items); |
|
| 152 | 152 | |
| 153 | 153 | $percentage = 100; |
| 154 | 154 | |
| 155 | - if ( $total > 0 ) { |
|
| 156 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 155 | + if ($total > 0) { |
|
| 156 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - if ( $percentage > 100 ) { |
|
| 159 | + if ($percentage > 100) { |
|
| 160 | 160 | $percentage = 100; |
| 161 | 161 | } |
| 162 | 162 | |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | * |
| 171 | 171 | * @param array $request The Form Data passed into the batch processing |
| 172 | 172 | */ |
| 173 | - public function set_properties( $request ) { |
|
| 173 | + public function set_properties($request) { |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -181,30 +181,30 @@ discard block |
||
| 181 | 181 | */ |
| 182 | 182 | public function process_step() { |
| 183 | 183 | |
| 184 | - if ( ! $this->can_export() ) { |
|
| 185 | - wp_die( esc_html__( 'You do not have permission to export data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 184 | + if ( ! $this->can_export()) { |
|
| 185 | + wp_die(esc_html__('You do not have permission to export data.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | $had_data = $this->get_data(); |
| 189 | 189 | |
| 190 | - if ( $had_data ) { |
|
| 190 | + if ($had_data) { |
|
| 191 | 191 | $this->done = false; |
| 192 | 192 | |
| 193 | 193 | return true; |
| 194 | 194 | } else { |
| 195 | - update_option( 'give_earnings_total', 0 ); |
|
| 196 | - delete_transient( 'give_earnings_total' ); |
|
| 197 | - delete_transient( 'give_estimated_monthly_stats' . true ); |
|
| 198 | - delete_transient( 'give_estimated_monthly_stats' . false ); |
|
| 199 | - $this->delete_data( 'give_temp_reset_ids' ); |
|
| 195 | + update_option('give_earnings_total', 0); |
|
| 196 | + delete_transient('give_earnings_total'); |
|
| 197 | + delete_transient('give_estimated_monthly_stats'.true); |
|
| 198 | + delete_transient('give_estimated_monthly_stats'.false); |
|
| 199 | + $this->delete_data('give_temp_reset_ids'); |
|
| 200 | 200 | |
| 201 | 201 | // Reset the sequential order numbers |
| 202 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
| 203 | - delete_option( 'give_last_payment_number' ); |
|
| 202 | + if (give_get_option('enable_sequential')) { |
|
| 203 | + delete_option('give_last_payment_number'); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | $this->done = true; |
| 207 | - $this->message = esc_html__( 'Donation forms, income, donations counts, and logs successfully reset.', 'give' ); |
|
| 207 | + $this->message = esc_html__('Donation forms, income, donations counts, and logs successfully reset.', 'give'); |
|
| 208 | 208 | |
| 209 | 209 | return false; |
| 210 | 210 | } |
@@ -214,10 +214,10 @@ discard block |
||
| 214 | 214 | * Headers |
| 215 | 215 | */ |
| 216 | 216 | public function headers() { |
| 217 | - ignore_user_abort( true ); |
|
| 217 | + ignore_user_abort(true); |
|
| 218 | 218 | |
| 219 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 220 | - set_time_limit( 0 ); |
|
| 219 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 220 | + set_time_limit(0); |
|
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | 223 | |
@@ -241,35 +241,35 @@ discard block |
||
| 241 | 241 | */ |
| 242 | 242 | public function pre_fetch() { |
| 243 | 243 | |
| 244 | - if ( $this->step == 1 ) { |
|
| 245 | - $this->delete_data( 'give_temp_reset_ids' ); |
|
| 244 | + if ($this->step == 1) { |
|
| 245 | + $this->delete_data('give_temp_reset_ids'); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - $items = get_option( 'give_temp_reset_ids', false ); |
|
| 248 | + $items = get_option('give_temp_reset_ids', false); |
|
| 249 | 249 | |
| 250 | - if ( false === $items ) { |
|
| 250 | + if (false === $items) { |
|
| 251 | 251 | $items = array(); |
| 252 | 252 | |
| 253 | - $give_types_for_reset = array( 'give_forms', 'give_log', 'give_payment' ); |
|
| 254 | - $give_types_for_reset = apply_filters( 'give_reset_store_post_types', $give_types_for_reset ); |
|
| 253 | + $give_types_for_reset = array('give_forms', 'give_log', 'give_payment'); |
|
| 254 | + $give_types_for_reset = apply_filters('give_reset_store_post_types', $give_types_for_reset); |
|
| 255 | 255 | |
| 256 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
| 256 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
| 257 | 257 | 'post_type' => $give_types_for_reset, |
| 258 | 258 | 'post_status' => 'any', |
| 259 | - 'posts_per_page' => - 1, |
|
| 260 | - ) ); |
|
| 259 | + 'posts_per_page' => -1, |
|
| 260 | + )); |
|
| 261 | 261 | |
| 262 | - $posts = get_posts( $args ); |
|
| 263 | - foreach ( $posts as $post ) { |
|
| 262 | + $posts = get_posts($args); |
|
| 263 | + foreach ($posts as $post) { |
|
| 264 | 264 | $items[] = array( |
| 265 | 265 | 'id' => (int) $post->ID, |
| 266 | 266 | 'type' => $post->post_type, |
| 267 | 267 | ); |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - $customer_args = array( 'number' => - 1 ); |
|
| 271 | - $customers = Give()->customers->get_customers( $customer_args ); |
|
| 272 | - foreach ( $customers as $customer ) { |
|
| 270 | + $customer_args = array('number' => -1); |
|
| 271 | + $customers = Give()->customers->get_customers($customer_args); |
|
| 272 | + foreach ($customers as $customer) { |
|
| 273 | 273 | $items[] = array( |
| 274 | 274 | 'id' => (int) $customer->id, |
| 275 | 275 | 'type' => 'customer', |
@@ -278,9 +278,9 @@ discard block |
||
| 278 | 278 | |
| 279 | 279 | // Allow filtering of items to remove with an unassociative array for each item |
| 280 | 280 | // The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method |
| 281 | - $items = apply_filters( 'give_reset_store_items', $items ); |
|
| 281 | + $items = apply_filters('give_reset_store_items', $items); |
|
| 282 | 282 | |
| 283 | - $this->store_data( 'give_temp_reset_ids', $items ); |
|
| 283 | + $this->store_data('give_temp_reset_ids', $items); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | } |
@@ -294,11 +294,11 @@ discard block |
||
| 294 | 294 | * |
| 295 | 295 | * @return mixed Returns the data from the database |
| 296 | 296 | */ |
| 297 | - private function get_stored_data( $key ) { |
|
| 297 | + private function get_stored_data($key) { |
|
| 298 | 298 | global $wpdb; |
| 299 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 299 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 300 | 300 | |
| 301 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
| 301 | + return empty($value) ? false : maybe_unserialize($value); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | /** |
@@ -311,10 +311,10 @@ discard block |
||
| 311 | 311 | * |
| 312 | 312 | * @return void |
| 313 | 313 | */ |
| 314 | - private function store_data( $key, $value ) { |
|
| 314 | + private function store_data($key, $value) { |
|
| 315 | 315 | global $wpdb; |
| 316 | 316 | |
| 317 | - $value = maybe_serialize( $value ); |
|
| 317 | + $value = maybe_serialize($value); |
|
| 318 | 318 | |
| 319 | 319 | $data = array( |
| 320 | 320 | 'option_name' => $key, |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | '%s', |
| 329 | 329 | ); |
| 330 | 330 | |
| 331 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 331 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | /** |
@@ -340,9 +340,9 @@ discard block |
||
| 340 | 340 | * |
| 341 | 341 | * @return void |
| 342 | 342 | */ |
| 343 | - private function delete_data( $key ) { |
|
| 343 | + private function delete_data($key) { |
|
| 344 | 344 | global $wpdb; |
| 345 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 345 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | } |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | * |
| 294 | 294 | * @param int $payment_id A given payment |
| 295 | 295 | * |
| 296 | - * @return mixed void|false |
|
| 296 | + * @return false|null void|false |
|
| 297 | 297 | */ |
| 298 | 298 | public function __construct( $payment_id = false ) { |
| 299 | 299 | |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | * |
| 362 | 362 | * @param string $name The attribute to get |
| 363 | 363 | * |
| 364 | - * @return boolean If the item is set or not |
|
| 364 | + * @return boolean|null If the item is set or not |
|
| 365 | 365 | */ |
| 366 | 366 | public function __isset( $name ) { |
| 367 | 367 | if ( property_exists( $this, $name ) ) { |
@@ -1149,7 +1149,7 @@ discard block |
||
| 1149 | 1149 | * |
| 1150 | 1150 | * @param string $note The note to add |
| 1151 | 1151 | * |
| 1152 | - * @return void |
|
| 1152 | + * @return false|null |
|
| 1153 | 1153 | */ |
| 1154 | 1154 | public function add_note( $note = false ) { |
| 1155 | 1155 | // Bail if no note specified |
@@ -899,7 +899,7 @@ |
||
| 899 | 899 | //Find a match between price_id and level_id |
| 900 | 900 | //First verify array keys exists THEN make the match |
| 901 | 901 | if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) ) |
| 902 | - && $args['price_id'] == $price['_give_id']['level_id'] |
|
| 902 | + && $args['price_id'] == $price['_give_id']['level_id'] |
|
| 903 | 903 | ) { |
| 904 | 904 | $item_price = $price['_give_amount']; |
| 905 | 905 | } |
@@ -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 | |
@@ -353,13 +353,13 @@ discard block |
||
| 353 | 353 | * |
| 354 | 354 | * @return mixed void|false |
| 355 | 355 | */ |
| 356 | - public function __construct( $payment_id = false ) { |
|
| 356 | + public function __construct($payment_id = false) { |
|
| 357 | 357 | |
| 358 | - if ( empty( $payment_id ) ) { |
|
| 358 | + if (empty($payment_id)) { |
|
| 359 | 359 | return false; |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - $this->setup_payment( $payment_id ); |
|
| 362 | + $this->setup_payment($payment_id); |
|
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | /** |
@@ -372,11 +372,11 @@ discard block |
||
| 372 | 372 | * |
| 373 | 373 | * @return mixed The value. |
| 374 | 374 | */ |
| 375 | - public function __get( $key ) { |
|
| 375 | + public function __get($key) { |
|
| 376 | 376 | |
| 377 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
| 377 | + if (method_exists($this, 'get_'.$key)) { |
|
| 378 | 378 | |
| 379 | - $value = call_user_func( array( $this, 'get_' . $key ) ); |
|
| 379 | + $value = call_user_func(array($this, 'get_'.$key)); |
|
| 380 | 380 | |
| 381 | 381 | } else { |
| 382 | 382 | |
@@ -398,18 +398,18 @@ discard block |
||
| 398 | 398 | * @param string $key The property name |
| 399 | 399 | * @param mixed $value The value of the property |
| 400 | 400 | */ |
| 401 | - public function __set( $key, $value ) { |
|
| 402 | - $ignore = array( '_ID' ); |
|
| 401 | + public function __set($key, $value) { |
|
| 402 | + $ignore = array('_ID'); |
|
| 403 | 403 | |
| 404 | - if ( $key === 'status' ) { |
|
| 404 | + if ($key === 'status') { |
|
| 405 | 405 | $this->old_status = $this->status; |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | - if ( ! in_array( $key, $ignore ) ) { |
|
| 409 | - $this->pending[ $key ] = $value; |
|
| 408 | + if ( ! in_array($key, $ignore)) { |
|
| 409 | + $this->pending[$key] = $value; |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - if ( '_ID' !== $key ) { |
|
| 412 | + if ('_ID' !== $key) { |
|
| 413 | 413 | $this->$key = $value; |
| 414 | 414 | } |
| 415 | 415 | } |
@@ -424,9 +424,9 @@ discard block |
||
| 424 | 424 | * |
| 425 | 425 | * @return boolean If the item is set or not |
| 426 | 426 | */ |
| 427 | - public function __isset( $name ) { |
|
| 428 | - if ( property_exists( $this, $name ) ) { |
|
| 429 | - return false === empty( $this->$name ); |
|
| 427 | + public function __isset($name) { |
|
| 428 | + if (property_exists($this, $name)) { |
|
| 429 | + return false === empty($this->$name); |
|
| 430 | 430 | } else { |
| 431 | 431 | return null; |
| 432 | 432 | } |
@@ -442,31 +442,31 @@ discard block |
||
| 442 | 442 | * |
| 443 | 443 | * @return bool If the setup was successful or not |
| 444 | 444 | */ |
| 445 | - private function setup_payment( $payment_id ) { |
|
| 445 | + private function setup_payment($payment_id) { |
|
| 446 | 446 | $this->pending = array(); |
| 447 | 447 | |
| 448 | - if ( empty( $payment_id ) ) { |
|
| 448 | + if (empty($payment_id)) { |
|
| 449 | 449 | return false; |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - $payment = get_post( $payment_id ); |
|
| 452 | + $payment = get_post($payment_id); |
|
| 453 | 453 | |
| 454 | - if ( ! $payment || is_wp_error( $payment ) ) { |
|
| 454 | + if ( ! $payment || is_wp_error($payment)) { |
|
| 455 | 455 | return false; |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | - if ( 'give_payment' !== $payment->post_type ) { |
|
| 458 | + if ('give_payment' !== $payment->post_type) { |
|
| 459 | 459 | return false; |
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | // Allow extensions to perform actions before the payment is loaded |
| 463 | - do_action( 'give_pre_setup_payment', $this, $payment_id ); |
|
| 463 | + do_action('give_pre_setup_payment', $this, $payment_id); |
|
| 464 | 464 | |
| 465 | 465 | // Primary Identifier |
| 466 | - $this->ID = absint( $payment_id ); |
|
| 466 | + $this->ID = absint($payment_id); |
|
| 467 | 467 | |
| 468 | 468 | // Protected ID that can never be changed |
| 469 | - $this->_ID = absint( $payment_id ); |
|
| 469 | + $this->_ID = absint($payment_id); |
|
| 470 | 470 | |
| 471 | 471 | // We have a payment, get the generic payment_meta item to reduce calls to it |
| 472 | 472 | $this->payment_meta = $this->get_meta(); |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | $this->parent_payment = $payment->post_parent; |
| 482 | 482 | |
| 483 | 483 | $all_payment_statuses = give_get_payment_statuses(); |
| 484 | - $this->status_nicename = array_key_exists( $this->status, $all_payment_statuses ) ? $all_payment_statuses[ $this->status ] : ucfirst( $this->status ); |
|
| 484 | + $this->status_nicename = array_key_exists($this->status, $all_payment_statuses) ? $all_payment_statuses[$this->status] : ucfirst($this->status); |
|
| 485 | 485 | |
| 486 | 486 | // Items |
| 487 | 487 | $this->fees = $this->setup_fees(); |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | $this->number = $this->setup_payment_number(); |
| 515 | 515 | |
| 516 | 516 | // Allow extensions to add items to this object via hook |
| 517 | - do_action( 'give_setup_payment', $this, $payment_id ); |
|
| 517 | + do_action('give_setup_payment', $this, $payment_id); |
|
| 518 | 518 | |
| 519 | 519 | return true; |
| 520 | 520 | } |
@@ -532,8 +532,8 @@ discard block |
||
| 532 | 532 | * |
| 533 | 533 | * @return void |
| 534 | 534 | */ |
| 535 | - public function update_payment_setup( $payment_id ) { |
|
| 536 | - $this->setup_payment( $payment_id ); |
|
| 535 | + public function update_payment_setup($payment_id) { |
|
| 536 | + $this->setup_payment($payment_id); |
|
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | /** |
@@ -548,24 +548,24 @@ discard block |
||
| 548 | 548 | |
| 549 | 549 | // Construct the payment title |
| 550 | 550 | $payment_title = ''; |
| 551 | - if ( ! empty( $this->first_name ) && ! empty( $this->last_name ) ) { |
|
| 552 | - $payment_title = $this->first_name . ' ' . $this->last_name; |
|
| 553 | - } else if ( ! empty( $this->first_name ) && empty( $this->last_name ) ) { |
|
| 551 | + if ( ! empty($this->first_name) && ! empty($this->last_name)) { |
|
| 552 | + $payment_title = $this->first_name.' '.$this->last_name; |
|
| 553 | + } else if ( ! empty($this->first_name) && empty($this->last_name)) { |
|
| 554 | 554 | $payment_title = $this->first_name; |
| 555 | - } else if ( ! empty( $this->email ) && is_email( $this->email ) ) { |
|
| 555 | + } else if ( ! empty($this->email) && is_email($this->email)) { |
|
| 556 | 556 | $payment_title = $this->email; |
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | //Set Key |
| 560 | - if ( empty( $this->key ) ) { |
|
| 560 | + if (empty($this->key)) { |
|
| 561 | 561 | |
| 562 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 563 | - $this->key = strtolower( md5( $this->email . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); // Unique key |
|
| 562 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
| 563 | + $this->key = strtolower(md5($this->email.date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); // Unique key |
|
| 564 | 564 | $this->pending['key'] = $this->key; |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | 567 | //Set IP |
| 568 | - if ( empty( $this->ip ) ) { |
|
| 568 | + if (empty($this->ip)) { |
|
| 569 | 569 | |
| 570 | 570 | $this->ip = give_get_ip(); |
| 571 | 571 | $this->pending['ip'] = $this->ip; |
@@ -592,58 +592,58 @@ discard block |
||
| 592 | 592 | 'fees' => $this->fees, |
| 593 | 593 | ); |
| 594 | 594 | |
| 595 | - $args = apply_filters( 'give_insert_payment_args', array( |
|
| 595 | + $args = apply_filters('give_insert_payment_args', array( |
|
| 596 | 596 | 'post_title' => $payment_title, |
| 597 | 597 | 'post_status' => $this->status, |
| 598 | 598 | 'post_type' => 'give_payment', |
| 599 | - 'post_date' => ! empty( $this->date ) ? $this->date : null, |
|
| 600 | - 'post_date_gmt' => ! empty( $this->date ) ? get_gmt_from_date( $this->date ) : null, |
|
| 599 | + 'post_date' => ! empty($this->date) ? $this->date : null, |
|
| 600 | + 'post_date_gmt' => ! empty($this->date) ? get_gmt_from_date($this->date) : null, |
|
| 601 | 601 | 'post_parent' => $this->parent_payment, |
| 602 | - ), $payment_data ); |
|
| 602 | + ), $payment_data); |
|
| 603 | 603 | |
| 604 | 604 | // Create a blank payment |
| 605 | - $payment_id = wp_insert_post( $args ); |
|
| 605 | + $payment_id = wp_insert_post($args); |
|
| 606 | 606 | |
| 607 | - if ( ! empty( $payment_id ) ) { |
|
| 607 | + if ( ! empty($payment_id)) { |
|
| 608 | 608 | |
| 609 | 609 | $this->ID = $payment_id; |
| 610 | 610 | $this->_ID = $payment_id; |
| 611 | 611 | |
| 612 | 612 | $customer = new stdClass; |
| 613 | 613 | |
| 614 | - if ( did_action( 'give_pre_process_purchase' ) && is_user_logged_in() ) { |
|
| 615 | - $customer = new Give_Customer( get_current_user_id(), true ); |
|
| 614 | + if (did_action('give_pre_process_purchase') && is_user_logged_in()) { |
|
| 615 | + $customer = new Give_Customer(get_current_user_id(), true); |
|
| 616 | 616 | } |
| 617 | 617 | |
| 618 | - if ( empty( $customer->id ) ) { |
|
| 619 | - $customer = new Give_Customer( $this->email ); |
|
| 618 | + if (empty($customer->id)) { |
|
| 619 | + $customer = new Give_Customer($this->email); |
|
| 620 | 620 | } |
| 621 | 621 | |
| 622 | - if ( empty( $customer->id ) ) { |
|
| 622 | + if (empty($customer->id)) { |
|
| 623 | 623 | |
| 624 | 624 | $customer_data = array( |
| 625 | - 'name' => ! is_email( $payment_title ) ? $this->first_name . ' ' . $this->last_name : '', |
|
| 625 | + 'name' => ! is_email($payment_title) ? $this->first_name.' '.$this->last_name : '', |
|
| 626 | 626 | 'email' => $this->email, |
| 627 | 627 | 'user_id' => $this->user_id, |
| 628 | 628 | ); |
| 629 | 629 | |
| 630 | - $customer->create( $customer_data ); |
|
| 630 | + $customer->create($customer_data); |
|
| 631 | 631 | |
| 632 | 632 | } |
| 633 | 633 | |
| 634 | 634 | $this->customer_id = $customer->id; |
| 635 | 635 | $this->pending['customer_id'] = $this->customer_id; |
| 636 | - $customer->attach_payment( $this->ID, false ); |
|
| 636 | + $customer->attach_payment($this->ID, false); |
|
| 637 | 637 | |
| 638 | - $this->payment_meta = apply_filters( 'give_payment_meta', $this->payment_meta, $payment_data ); |
|
| 639 | - if ( ! empty( $this->payment_meta['fees'] ) ) { |
|
| 640 | - $this->fees = array_merge( $this->fees, $this->payment_meta['fees'] ); |
|
| 641 | - foreach ( $this->fees as $fee ) { |
|
| 642 | - $this->increase_fees( $fee['amount'] ); |
|
| 638 | + $this->payment_meta = apply_filters('give_payment_meta', $this->payment_meta, $payment_data); |
|
| 639 | + if ( ! empty($this->payment_meta['fees'])) { |
|
| 640 | + $this->fees = array_merge($this->fees, $this->payment_meta['fees']); |
|
| 641 | + foreach ($this->fees as $fee) { |
|
| 642 | + $this->increase_fees($fee['amount']); |
|
| 643 | 643 | } |
| 644 | 644 | } |
| 645 | 645 | |
| 646 | - $this->update_meta( '_give_payment_meta', $this->payment_meta ); |
|
| 646 | + $this->update_meta('_give_payment_meta', $this->payment_meta); |
|
| 647 | 647 | $this->new = true; |
| 648 | 648 | } |
| 649 | 649 | |
@@ -665,11 +665,11 @@ discard block |
||
| 665 | 665 | $saved = false; |
| 666 | 666 | |
| 667 | 667 | //Must have an ID |
| 668 | - if ( empty( $this->ID ) ) { |
|
| 668 | + if (empty($this->ID)) { |
|
| 669 | 669 | |
| 670 | 670 | $payment_id = $this->insert_payment(); |
| 671 | 671 | |
| 672 | - if ( false === $payment_id ) { |
|
| 672 | + if (false === $payment_id) { |
|
| 673 | 673 | $saved = false; |
| 674 | 674 | } else { |
| 675 | 675 | $this->ID = $payment_id; |
@@ -678,48 +678,48 @@ discard block |
||
| 678 | 678 | } |
| 679 | 679 | |
| 680 | 680 | //Set ID if not matching |
| 681 | - if ( $this->ID !== $this->_ID ) { |
|
| 681 | + if ($this->ID !== $this->_ID) { |
|
| 682 | 682 | $this->ID = $this->_ID; |
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | // If we have something pending, let's save it |
| 686 | - if ( ! empty( $this->pending ) ) { |
|
| 686 | + if ( ! empty($this->pending)) { |
|
| 687 | 687 | |
| 688 | 688 | $total_increase = 0; |
| 689 | 689 | $total_decrease = 0; |
| 690 | 690 | |
| 691 | - foreach ( $this->pending as $key => $value ) { |
|
| 691 | + foreach ($this->pending as $key => $value) { |
|
| 692 | 692 | |
| 693 | - switch ( $key ) { |
|
| 693 | + switch ($key) { |
|
| 694 | 694 | |
| 695 | 695 | case 'donations': |
| 696 | 696 | // Update totals for pending donations |
| 697 | - foreach ( $this->pending[ $key ] as $item ) { |
|
| 697 | + foreach ($this->pending[$key] as $item) { |
|
| 698 | 698 | |
| 699 | - $quantity = isset( $item['quantity'] ) ? $item['quantity'] : 1; |
|
| 700 | - $price_id = isset( $item['price_id'] ) ? $item['price_id'] : 0; |
|
| 699 | + $quantity = isset($item['quantity']) ? $item['quantity'] : 1; |
|
| 700 | + $price_id = isset($item['price_id']) ? $item['price_id'] : 0; |
|
| 701 | 701 | |
| 702 | - switch ( $item['action'] ) { |
|
| 702 | + switch ($item['action']) { |
|
| 703 | 703 | |
| 704 | 704 | case 'add': |
| 705 | 705 | |
| 706 | 706 | $price = $item['price']; |
| 707 | 707 | |
| 708 | - if ( 'publish' === $this->status || 'complete' === $this->status ) { |
|
| 708 | + if ('publish' === $this->status || 'complete' === $this->status) { |
|
| 709 | 709 | |
| 710 | 710 | // Add sales logs |
| 711 | - $log_date = date_i18n( 'Y-m-d G:i:s', current_time( 'timestamp' ) ); |
|
| 711 | + $log_date = date_i18n('Y-m-d G:i:s', current_time('timestamp')); |
|
| 712 | 712 | |
| 713 | 713 | $y = 0; |
| 714 | - while ( $y < $quantity ) { |
|
| 714 | + while ($y < $quantity) { |
|
| 715 | 715 | |
| 716 | - give_record_sale_in_log( $item['id'], $this->ID, $price_id, $log_date ); |
|
| 717 | - $y ++; |
|
| 716 | + give_record_sale_in_log($item['id'], $this->ID, $price_id, $log_date); |
|
| 717 | + $y++; |
|
| 718 | 718 | } |
| 719 | 719 | |
| 720 | - $form = new Give_Donate_Form( $item['id'] ); |
|
| 721 | - $form->increase_sales( $quantity ); |
|
| 722 | - $form->increase_earnings( $price ); |
|
| 720 | + $form = new Give_Donate_Form($item['id']); |
|
| 721 | + $form->increase_sales($quantity); |
|
| 722 | + $form->increase_earnings($price); |
|
| 723 | 723 | |
| 724 | 724 | $total_increase += $price; |
| 725 | 725 | } |
@@ -744,15 +744,15 @@ discard block |
||
| 744 | 744 | ) |
| 745 | 745 | ); |
| 746 | 746 | |
| 747 | - $found_logs = get_posts( $log_args ); |
|
| 748 | - foreach ( $found_logs as $log ) { |
|
| 749 | - wp_delete_post( $log->ID, true ); |
|
| 747 | + $found_logs = get_posts($log_args); |
|
| 748 | + foreach ($found_logs as $log) { |
|
| 749 | + wp_delete_post($log->ID, true); |
|
| 750 | 750 | } |
| 751 | 751 | |
| 752 | - if ( 'publish' === $this->status || 'complete' === $this->status ) { |
|
| 753 | - $form = new Give_Donate_Form( $item['id'] ); |
|
| 754 | - $form->decrease_sales( $quantity ); |
|
| 755 | - $form->decrease_earnings( $item['amount'] ); |
|
| 752 | + if ('publish' === $this->status || 'complete' === $this->status) { |
|
| 753 | + $form = new Give_Donate_Form($item['id']); |
|
| 754 | + $form->decrease_sales($quantity); |
|
| 755 | + $form->decrease_earnings($item['amount']); |
|
| 756 | 756 | |
| 757 | 757 | $total_decrease += $item['amount']; |
| 758 | 758 | } |
@@ -765,17 +765,17 @@ discard block |
||
| 765 | 765 | |
| 766 | 766 | case 'fees': |
| 767 | 767 | |
| 768 | - if ( 'publish' !== $this->status && 'complete' !== $this->status ) { |
|
| 768 | + if ('publish' !== $this->status && 'complete' !== $this->status) { |
|
| 769 | 769 | break; |
| 770 | 770 | } |
| 771 | 771 | |
| 772 | - if ( empty( $this->pending[ $key ] ) ) { |
|
| 772 | + if (empty($this->pending[$key])) { |
|
| 773 | 773 | break; |
| 774 | 774 | } |
| 775 | 775 | |
| 776 | - foreach ( $this->pending[ $key ] as $fee ) { |
|
| 776 | + foreach ($this->pending[$key] as $fee) { |
|
| 777 | 777 | |
| 778 | - switch ( $fee['action'] ) { |
|
| 778 | + switch ($fee['action']) { |
|
| 779 | 779 | |
| 780 | 780 | case 'add': |
| 781 | 781 | $total_increase += $fee['amount']; |
@@ -792,43 +792,43 @@ discard block |
||
| 792 | 792 | break; |
| 793 | 793 | |
| 794 | 794 | case 'status': |
| 795 | - $this->update_status( $this->status ); |
|
| 795 | + $this->update_status($this->status); |
|
| 796 | 796 | break; |
| 797 | 797 | |
| 798 | 798 | case 'gateway': |
| 799 | - $this->update_meta( '_give_payment_gateway', $this->gateway ); |
|
| 799 | + $this->update_meta('_give_payment_gateway', $this->gateway); |
|
| 800 | 800 | break; |
| 801 | 801 | |
| 802 | 802 | case 'mode': |
| 803 | - $this->update_meta( '_give_payment_mode', $this->mode ); |
|
| 803 | + $this->update_meta('_give_payment_mode', $this->mode); |
|
| 804 | 804 | break; |
| 805 | 805 | |
| 806 | 806 | case 'transaction_id': |
| 807 | - $this->update_meta( '_give_payment_transaction_id', $this->transaction_id ); |
|
| 807 | + $this->update_meta('_give_payment_transaction_id', $this->transaction_id); |
|
| 808 | 808 | break; |
| 809 | 809 | |
| 810 | 810 | case 'ip': |
| 811 | - $this->update_meta( '_give_payment_user_ip', $this->ip ); |
|
| 811 | + $this->update_meta('_give_payment_user_ip', $this->ip); |
|
| 812 | 812 | break; |
| 813 | 813 | |
| 814 | 814 | case 'customer_id': |
| 815 | - $this->update_meta( '_give_payment_customer_id', $this->customer_id ); |
|
| 815 | + $this->update_meta('_give_payment_customer_id', $this->customer_id); |
|
| 816 | 816 | break; |
| 817 | 817 | |
| 818 | 818 | case 'user_id': |
| 819 | - $this->update_meta( '_give_payment_user_id', $this->user_id ); |
|
| 819 | + $this->update_meta('_give_payment_user_id', $this->user_id); |
|
| 820 | 820 | break; |
| 821 | 821 | |
| 822 | 822 | case 'form_title': |
| 823 | - $this->update_meta( '_give_payment_form_title', $this->form_title ); |
|
| 823 | + $this->update_meta('_give_payment_form_title', $this->form_title); |
|
| 824 | 824 | break; |
| 825 | 825 | |
| 826 | 826 | case 'form_id': |
| 827 | - $this->update_meta( '_give_payment_form_id', $this->form_id ); |
|
| 827 | + $this->update_meta('_give_payment_form_id', $this->form_id); |
|
| 828 | 828 | break; |
| 829 | 829 | |
| 830 | 830 | case 'price_id': |
| 831 | - $this->update_meta( '_give_payment_price_id', $this->price_id ); |
|
| 831 | + $this->update_meta('_give_payment_price_id', $this->price_id); |
|
| 832 | 832 | break; |
| 833 | 833 | |
| 834 | 834 | case 'first_name': |
@@ -844,15 +844,15 @@ discard block |
||
| 844 | 844 | break; |
| 845 | 845 | |
| 846 | 846 | case 'email': |
| 847 | - $this->update_meta( '_give_payment_user_email', $this->email ); |
|
| 847 | + $this->update_meta('_give_payment_user_email', $this->email); |
|
| 848 | 848 | break; |
| 849 | 849 | |
| 850 | 850 | case 'key': |
| 851 | - $this->update_meta( '_give_payment_purchase_key', $this->key ); |
|
| 851 | + $this->update_meta('_give_payment_purchase_key', $this->key); |
|
| 852 | 852 | break; |
| 853 | 853 | |
| 854 | 854 | case 'number': |
| 855 | - $this->update_meta( '_give_payment_number', $this->number ); |
|
| 855 | + $this->update_meta('_give_payment_number', $this->number); |
|
| 856 | 856 | break; |
| 857 | 857 | |
| 858 | 858 | case 'date': |
@@ -862,11 +862,11 @@ discard block |
||
| 862 | 862 | 'edit_date' => true, |
| 863 | 863 | ); |
| 864 | 864 | |
| 865 | - wp_update_post( $args ); |
|
| 865 | + wp_update_post($args); |
|
| 866 | 866 | break; |
| 867 | 867 | |
| 868 | 868 | case 'completed_date': |
| 869 | - $this->update_meta( '_give_completed_date', $this->completed_date ); |
|
| 869 | + $this->update_meta('_give_completed_date', $this->completed_date); |
|
| 870 | 870 | break; |
| 871 | 871 | |
| 872 | 872 | case 'parent_payment': |
@@ -875,38 +875,38 @@ discard block |
||
| 875 | 875 | 'post_parent' => $this->parent_payment, |
| 876 | 876 | ); |
| 877 | 877 | |
| 878 | - wp_update_post( $args ); |
|
| 878 | + wp_update_post($args); |
|
| 879 | 879 | break; |
| 880 | 880 | |
| 881 | 881 | default: |
| 882 | - do_action( 'give_payment_save', $this, $key ); |
|
| 882 | + do_action('give_payment_save', $this, $key); |
|
| 883 | 883 | break; |
| 884 | 884 | } |
| 885 | 885 | } |
| 886 | 886 | |
| 887 | - if ( 'pending' !== $this->status ) { |
|
| 887 | + if ('pending' !== $this->status) { |
|
| 888 | 888 | |
| 889 | - $customer = new Give_Customer( $this->customer_id ); |
|
| 889 | + $customer = new Give_Customer($this->customer_id); |
|
| 890 | 890 | |
| 891 | 891 | $total_change = $total_increase - $total_decrease; |
| 892 | - if ( $total_change < 0 ) { |
|
| 892 | + if ($total_change < 0) { |
|
| 893 | 893 | |
| 894 | - $total_change = - ( $total_change ); |
|
| 894 | + $total_change = - ($total_change); |
|
| 895 | 895 | // Decrease the customer's purchase stats |
| 896 | - $customer->decrease_value( $total_change ); |
|
| 897 | - give_decrease_total_earnings( $total_change ); |
|
| 896 | + $customer->decrease_value($total_change); |
|
| 897 | + give_decrease_total_earnings($total_change); |
|
| 898 | 898 | |
| 899 | - } else if ( $total_change > 0 ) { |
|
| 899 | + } else if ($total_change > 0) { |
|
| 900 | 900 | |
| 901 | 901 | // Increase the customer's purchase stats |
| 902 | - $customer->increase_value( $total_change ); |
|
| 903 | - give_increase_total_earnings( $total_change ); |
|
| 902 | + $customer->increase_value($total_change); |
|
| 903 | + give_increase_total_earnings($total_change); |
|
| 904 | 904 | |
| 905 | 905 | } |
| 906 | 906 | |
| 907 | 907 | } |
| 908 | 908 | |
| 909 | - $this->update_meta( '_give_payment_total', $this->total ); |
|
| 909 | + $this->update_meta('_give_payment_total', $this->total); |
|
| 910 | 910 | |
| 911 | 911 | $new_meta = array( |
| 912 | 912 | 'form_title' => $this->form_title, |
@@ -918,12 +918,12 @@ discard block |
||
| 918 | 918 | ); |
| 919 | 919 | |
| 920 | 920 | $meta = $this->get_meta(); |
| 921 | - $merged_meta = array_merge( $meta, $new_meta ); |
|
| 921 | + $merged_meta = array_merge($meta, $new_meta); |
|
| 922 | 922 | |
| 923 | 923 | // Only save the payment meta if it's changed |
| 924 | - if ( md5( serialize( $meta ) ) !== md5( serialize( $merged_meta ) ) ) { |
|
| 925 | - $updated = $this->update_meta( '_give_payment_meta', $merged_meta ); |
|
| 926 | - if ( false !== $updated ) { |
|
| 924 | + if (md5(serialize($meta)) !== md5(serialize($merged_meta))) { |
|
| 925 | + $updated = $this->update_meta('_give_payment_meta', $merged_meta); |
|
| 926 | + if (false !== $updated) { |
|
| 927 | 927 | $saved = true; |
| 928 | 928 | } |
| 929 | 929 | } |
@@ -932,8 +932,8 @@ discard block |
||
| 932 | 932 | $saved = true; |
| 933 | 933 | } |
| 934 | 934 | |
| 935 | - if ( true === $saved ) { |
|
| 936 | - $this->setup_payment( $this->ID ); |
|
| 935 | + if (true === $saved) { |
|
| 936 | + $this->setup_payment($this->ID); |
|
| 937 | 937 | } |
| 938 | 938 | |
| 939 | 939 | return $saved; |
@@ -951,12 +951,12 @@ discard block |
||
| 951 | 951 | * |
| 952 | 952 | * @return bool True when successful, false otherwise |
| 953 | 953 | */ |
| 954 | - public function add_donation( $form_id = 0, $args = array(), $options = array() ) { |
|
| 954 | + public function add_donation($form_id = 0, $args = array(), $options = array()) { |
|
| 955 | 955 | |
| 956 | - $donation = new Give_Donate_Form( $form_id ); |
|
| 956 | + $donation = new Give_Donate_Form($form_id); |
|
| 957 | 957 | |
| 958 | 958 | // Bail if this post isn't a give donation form |
| 959 | - if ( ! $donation || $donation->post_type !== 'give_forms' ) { |
|
| 959 | + if ( ! $donation || $donation->post_type !== 'give_forms') { |
|
| 960 | 960 | return false; |
| 961 | 961 | } |
| 962 | 962 | |
@@ -967,60 +967,60 @@ discard block |
||
| 967 | 967 | 'fees' => array(), |
| 968 | 968 | ); |
| 969 | 969 | |
| 970 | - $args = wp_parse_args( apply_filters( 'give_payment_add_donation_args', $args, $donation->ID ), $defaults ); |
|
| 970 | + $args = wp_parse_args(apply_filters('give_payment_add_donation_args', $args, $donation->ID), $defaults); |
|
| 971 | 971 | |
| 972 | 972 | // Allow overriding the price |
| 973 | - if ( false !== $args['price'] ) { |
|
| 973 | + if (false !== $args['price']) { |
|
| 974 | 974 | $item_price = $args['price']; |
| 975 | 975 | } else { |
| 976 | 976 | |
| 977 | 977 | // Deal with variable pricing |
| 978 | - if ( give_has_variable_prices( $donation->ID ) ) { |
|
| 979 | - $prices = maybe_unserialize( get_post_meta( $form_id, '_give_donation_levels', true ) ); |
|
| 978 | + if (give_has_variable_prices($donation->ID)) { |
|
| 979 | + $prices = maybe_unserialize(get_post_meta($form_id, '_give_donation_levels', true)); |
|
| 980 | 980 | $item_price = ''; |
| 981 | 981 | //Loop through prices |
| 982 | - foreach ( $prices as $price ) { |
|
| 982 | + foreach ($prices as $price) { |
|
| 983 | 983 | //Find a match between price_id and level_id |
| 984 | 984 | //First verify array keys exists THEN make the match |
| 985 | - if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) ) |
|
| 985 | + if ((isset($args['price_id']) && isset($price['_give_id']['level_id'])) |
|
| 986 | 986 | && $args['price_id'] == $price['_give_id']['level_id'] |
| 987 | 987 | ) { |
| 988 | 988 | $item_price = $price['_give_amount']; |
| 989 | 989 | } |
| 990 | 990 | } |
| 991 | 991 | //Fallback to the lowest price point |
| 992 | - if ( $item_price == '' ) { |
|
| 993 | - $item_price = give_get_lowest_price_option( $donation->ID ); |
|
| 994 | - $args['price_id'] = give_get_lowest_price_id( $donation->ID ); |
|
| 992 | + if ($item_price == '') { |
|
| 993 | + $item_price = give_get_lowest_price_option($donation->ID); |
|
| 994 | + $args['price_id'] = give_get_lowest_price_id($donation->ID); |
|
| 995 | 995 | } |
| 996 | 996 | } else { |
| 997 | 997 | //Simple form price |
| 998 | - $item_price = give_get_form_price( $donation->ID ); |
|
| 998 | + $item_price = give_get_form_price($donation->ID); |
|
| 999 | 999 | } |
| 1000 | 1000 | |
| 1001 | 1001 | } |
| 1002 | 1002 | |
| 1003 | 1003 | // Sanitizing the price here so we don't have a dozen calls later |
| 1004 | - $item_price = give_sanitize_amount( $item_price ); |
|
| 1005 | - $total = round( $item_price, give_currency_decimal_filter() ); |
|
| 1004 | + $item_price = give_sanitize_amount($item_price); |
|
| 1005 | + $total = round($item_price, give_currency_decimal_filter()); |
|
| 1006 | 1006 | |
| 1007 | 1007 | //Add Options |
| 1008 | 1008 | $default_options = array(); |
| 1009 | - if ( false !== $args['price_id'] ) { |
|
| 1009 | + if (false !== $args['price_id']) { |
|
| 1010 | 1010 | $default_options['price_id'] = (int) $args['price_id']; |
| 1011 | 1011 | } |
| 1012 | - $options = wp_parse_args( $options, $default_options ); |
|
| 1012 | + $options = wp_parse_args($options, $default_options); |
|
| 1013 | 1013 | |
| 1014 | 1014 | // Do not allow totals to go negative |
| 1015 | - if ( $total < 0 ) { |
|
| 1015 | + if ($total < 0) { |
|
| 1016 | 1016 | $total = 0; |
| 1017 | 1017 | } |
| 1018 | 1018 | |
| 1019 | 1019 | $donation = array( |
| 1020 | 1020 | 'name' => $donation->post_title, |
| 1021 | 1021 | 'id' => $donation->ID, |
| 1022 | - 'price' => round( $total, give_currency_decimal_filter() ), |
|
| 1023 | - 'subtotal' => round( $total, give_currency_decimal_filter() ), |
|
| 1022 | + 'price' => round($total, give_currency_decimal_filter()), |
|
| 1023 | + 'subtotal' => round($total, give_currency_decimal_filter()), |
|
| 1024 | 1024 | 'fees' => $args['fees'], |
| 1025 | 1025 | 'price_id' => $args['price_id'], |
| 1026 | 1026 | 'action' => 'add', |
@@ -1029,7 +1029,7 @@ discard block |
||
| 1029 | 1029 | |
| 1030 | 1030 | $this->pending['donations'][] = $donation; |
| 1031 | 1031 | |
| 1032 | - $this->increase_subtotal( $total ); |
|
| 1032 | + $this->increase_subtotal($total); |
|
| 1033 | 1033 | |
| 1034 | 1034 | return true; |
| 1035 | 1035 | |
@@ -1046,7 +1046,7 @@ discard block |
||
| 1046 | 1046 | * |
| 1047 | 1047 | * @return bool If the item was removed or not |
| 1048 | 1048 | */ |
| 1049 | - public function remove_donation( $form_id, $args = array() ) { |
|
| 1049 | + public function remove_donation($form_id, $args = array()) { |
|
| 1050 | 1050 | |
| 1051 | 1051 | // Set some defaults |
| 1052 | 1052 | $defaults = array( |
@@ -1054,12 +1054,12 @@ discard block |
||
| 1054 | 1054 | 'price' => false, |
| 1055 | 1055 | 'price_id' => false, |
| 1056 | 1056 | ); |
| 1057 | - $args = wp_parse_args( $args, $defaults ); |
|
| 1057 | + $args = wp_parse_args($args, $defaults); |
|
| 1058 | 1058 | |
| 1059 | - $form = new Give_Donate_Form( $form_id ); |
|
| 1059 | + $form = new Give_Donate_Form($form_id); |
|
| 1060 | 1060 | |
| 1061 | 1061 | // Bail if this post isn't a valid give donation form |
| 1062 | - if ( ! $form || $form->post_type !== 'give_forms' ) { |
|
| 1062 | + if ( ! $form || $form->post_type !== 'give_forms') { |
|
| 1063 | 1063 | return false; |
| 1064 | 1064 | } |
| 1065 | 1065 | |
@@ -1072,7 +1072,7 @@ discard block |
||
| 1072 | 1072 | |
| 1073 | 1073 | $this->pending['donations'][] = $pending_args; |
| 1074 | 1074 | |
| 1075 | - $this->decrease_subtotal( $this->total ); |
|
| 1075 | + $this->decrease_subtotal($this->total); |
|
| 1076 | 1076 | |
| 1077 | 1077 | return true; |
| 1078 | 1078 | } |
@@ -1088,7 +1088,7 @@ discard block |
||
| 1088 | 1088 | * |
| 1089 | 1089 | * @return bool If the fee was added |
| 1090 | 1090 | */ |
| 1091 | - public function add_fee( $args, $global = true ) { |
|
| 1091 | + public function add_fee($args, $global = true) { |
|
| 1092 | 1092 | |
| 1093 | 1093 | $default_args = array( |
| 1094 | 1094 | 'label' => '', |
@@ -1098,16 +1098,16 @@ discard block |
||
| 1098 | 1098 | 'price_id' => 0, |
| 1099 | 1099 | ); |
| 1100 | 1100 | |
| 1101 | - $fee = wp_parse_args( $args, $default_args ); |
|
| 1101 | + $fee = wp_parse_args($args, $default_args); |
|
| 1102 | 1102 | $this->fees[] = $fee; |
| 1103 | 1103 | |
| 1104 | 1104 | |
| 1105 | 1105 | $added_fee = $fee; |
| 1106 | 1106 | $added_fee['action'] = 'add'; |
| 1107 | 1107 | $this->pending['fees'][] = $added_fee; |
| 1108 | - reset( $this->fees ); |
|
| 1108 | + reset($this->fees); |
|
| 1109 | 1109 | |
| 1110 | - $this->increase_fees( $fee['amount'] ); |
|
| 1110 | + $this->increase_fees($fee['amount']); |
|
| 1111 | 1111 | |
| 1112 | 1112 | return true; |
| 1113 | 1113 | } |
@@ -1122,11 +1122,11 @@ discard block |
||
| 1122 | 1122 | * |
| 1123 | 1123 | * @return bool If the fee was removed successfully |
| 1124 | 1124 | */ |
| 1125 | - public function remove_fee( $key ) { |
|
| 1125 | + public function remove_fee($key) { |
|
| 1126 | 1126 | $removed = false; |
| 1127 | 1127 | |
| 1128 | - if ( is_numeric( $key ) ) { |
|
| 1129 | - $removed = $this->remove_fee_by( 'index', $key ); |
|
| 1128 | + if (is_numeric($key)) { |
|
| 1129 | + $removed = $this->remove_fee_by('index', $key); |
|
| 1130 | 1130 | } |
| 1131 | 1131 | |
| 1132 | 1132 | return $removed; |
@@ -1145,47 +1145,47 @@ discard block |
||
| 1145 | 1145 | * |
| 1146 | 1146 | * @return boolean If the item is removed |
| 1147 | 1147 | */ |
| 1148 | - public function remove_fee_by( $key, $value, $global = false ) { |
|
| 1148 | + public function remove_fee_by($key, $value, $global = false) { |
|
| 1149 | 1149 | |
| 1150 | - $allowed_fee_keys = apply_filters( 'give_payment_fee_keys', array( |
|
| 1150 | + $allowed_fee_keys = apply_filters('give_payment_fee_keys', array( |
|
| 1151 | 1151 | 'index', |
| 1152 | 1152 | 'label', |
| 1153 | 1153 | 'amount', |
| 1154 | 1154 | 'type', |
| 1155 | - ) ); |
|
| 1155 | + )); |
|
| 1156 | 1156 | |
| 1157 | - if ( ! in_array( $key, $allowed_fee_keys ) ) { |
|
| 1157 | + if ( ! in_array($key, $allowed_fee_keys)) { |
|
| 1158 | 1158 | return false; |
| 1159 | 1159 | } |
| 1160 | 1160 | |
| 1161 | 1161 | $removed = false; |
| 1162 | - if ( 'index' === $key && array_key_exists( $value, $this->fees ) ) { |
|
| 1162 | + if ('index' === $key && array_key_exists($value, $this->fees)) { |
|
| 1163 | 1163 | |
| 1164 | - $removed_fee = $this->fees[ $value ]; |
|
| 1164 | + $removed_fee = $this->fees[$value]; |
|
| 1165 | 1165 | $removed_fee['action'] = 'remove'; |
| 1166 | 1166 | $this->pending['fees'][] = $removed_fee; |
| 1167 | 1167 | |
| 1168 | - $this->decrease_fees( $removed_fee['amount'] ); |
|
| 1168 | + $this->decrease_fees($removed_fee['amount']); |
|
| 1169 | 1169 | |
| 1170 | - unset( $this->fees[ $value ] ); |
|
| 1170 | + unset($this->fees[$value]); |
|
| 1171 | 1171 | $removed = true; |
| 1172 | 1172 | |
| 1173 | - } else if ( 'index' !== $key ) { |
|
| 1173 | + } else if ('index' !== $key) { |
|
| 1174 | 1174 | |
| 1175 | - foreach ( $this->fees as $index => $fee ) { |
|
| 1175 | + foreach ($this->fees as $index => $fee) { |
|
| 1176 | 1176 | |
| 1177 | - if ( isset( $fee[ $key ] ) && $fee[ $key ] == $value ) { |
|
| 1177 | + if (isset($fee[$key]) && $fee[$key] == $value) { |
|
| 1178 | 1178 | |
| 1179 | 1179 | $removed_fee = $fee; |
| 1180 | 1180 | $removed_fee['action'] = 'remove'; |
| 1181 | 1181 | $this->pending['fees'][] = $removed_fee; |
| 1182 | 1182 | |
| 1183 | - $this->decrease_fees( $removed_fee['amount'] ); |
|
| 1183 | + $this->decrease_fees($removed_fee['amount']); |
|
| 1184 | 1184 | |
| 1185 | - unset( $this->fees[ $index ] ); |
|
| 1185 | + unset($this->fees[$index]); |
|
| 1186 | 1186 | $removed = true; |
| 1187 | 1187 | |
| 1188 | - if ( false === $global ) { |
|
| 1188 | + if (false === $global) { |
|
| 1189 | 1189 | break; |
| 1190 | 1190 | } |
| 1191 | 1191 | |
@@ -1195,8 +1195,8 @@ discard block |
||
| 1195 | 1195 | |
| 1196 | 1196 | } |
| 1197 | 1197 | |
| 1198 | - if ( true === $removed ) { |
|
| 1199 | - $this->fees = array_values( $this->fees ); |
|
| 1198 | + if (true === $removed) { |
|
| 1199 | + $this->fees = array_values($this->fees); |
|
| 1200 | 1200 | } |
| 1201 | 1201 | |
| 1202 | 1202 | return $removed; |
@@ -1212,14 +1212,14 @@ discard block |
||
| 1212 | 1212 | * |
| 1213 | 1213 | * @return array The Fees for the type specified |
| 1214 | 1214 | */ |
| 1215 | - public function get_fees( $type = 'all' ) { |
|
| 1215 | + public function get_fees($type = 'all') { |
|
| 1216 | 1216 | $fees = array(); |
| 1217 | 1217 | |
| 1218 | - if ( ! empty( $this->fees ) && is_array( $this->fees ) ) { |
|
| 1218 | + if ( ! empty($this->fees) && is_array($this->fees)) { |
|
| 1219 | 1219 | |
| 1220 | - foreach ( $this->fees as $fee_id => $fee ) { |
|
| 1220 | + foreach ($this->fees as $fee_id => $fee) { |
|
| 1221 | 1221 | |
| 1222 | - if ( 'all' != $type && ! empty( $fee['type'] ) && $type != $fee['type'] ) { |
|
| 1222 | + if ('all' != $type && ! empty($fee['type']) && $type != $fee['type']) { |
|
| 1223 | 1223 | continue; |
| 1224 | 1224 | } |
| 1225 | 1225 | |
@@ -1229,7 +1229,7 @@ discard block |
||
| 1229 | 1229 | } |
| 1230 | 1230 | } |
| 1231 | 1231 | |
| 1232 | - return apply_filters( 'give_get_payment_fees', $fees, $this->ID, $this ); |
|
| 1232 | + return apply_filters('give_get_payment_fees', $fees, $this->ID, $this); |
|
| 1233 | 1233 | } |
| 1234 | 1234 | |
| 1235 | 1235 | /** |
@@ -1242,13 +1242,13 @@ discard block |
||
| 1242 | 1242 | * |
| 1243 | 1243 | * @return void |
| 1244 | 1244 | */ |
| 1245 | - public function add_note( $note = false ) { |
|
| 1245 | + public function add_note($note = false) { |
|
| 1246 | 1246 | // Bail if no note specified |
| 1247 | - if ( ! $note ) { |
|
| 1247 | + if ( ! $note) { |
|
| 1248 | 1248 | return false; |
| 1249 | 1249 | } |
| 1250 | 1250 | |
| 1251 | - give_insert_payment_note( $this->ID, $note ); |
|
| 1251 | + give_insert_payment_note($this->ID, $note); |
|
| 1252 | 1252 | } |
| 1253 | 1253 | |
| 1254 | 1254 | /** |
@@ -1261,7 +1261,7 @@ discard block |
||
| 1261 | 1261 | * |
| 1262 | 1262 | * @return void |
| 1263 | 1263 | */ |
| 1264 | - private function increase_subtotal( $amount = 0.00 ) { |
|
| 1264 | + private function increase_subtotal($amount = 0.00) { |
|
| 1265 | 1265 | $amount = (float) $amount; |
| 1266 | 1266 | $this->subtotal += $amount; |
| 1267 | 1267 | |
@@ -1278,11 +1278,11 @@ discard block |
||
| 1278 | 1278 | * |
| 1279 | 1279 | * @return void |
| 1280 | 1280 | */ |
| 1281 | - private function decrease_subtotal( $amount = 0.00 ) { |
|
| 1281 | + private function decrease_subtotal($amount = 0.00) { |
|
| 1282 | 1282 | $amount = (float) $amount; |
| 1283 | 1283 | $this->subtotal -= $amount; |
| 1284 | 1284 | |
| 1285 | - if ( $this->subtotal < 0 ) { |
|
| 1285 | + if ($this->subtotal < 0) { |
|
| 1286 | 1286 | $this->subtotal = 0; |
| 1287 | 1287 | } |
| 1288 | 1288 | |
@@ -1299,7 +1299,7 @@ discard block |
||
| 1299 | 1299 | * |
| 1300 | 1300 | * @return void |
| 1301 | 1301 | */ |
| 1302 | - private function increase_fees( $amount = 0.00 ) { |
|
| 1302 | + private function increase_fees($amount = 0.00) { |
|
| 1303 | 1303 | $amount = (float) $amount; |
| 1304 | 1304 | $this->fees_total += $amount; |
| 1305 | 1305 | |
@@ -1316,11 +1316,11 @@ discard block |
||
| 1316 | 1316 | * |
| 1317 | 1317 | * @return void |
| 1318 | 1318 | */ |
| 1319 | - private function decrease_fees( $amount = 0.00 ) { |
|
| 1319 | + private function decrease_fees($amount = 0.00) { |
|
| 1320 | 1320 | $amount = (float) $amount; |
| 1321 | 1321 | $this->fees_total -= $amount; |
| 1322 | 1322 | |
| 1323 | - if ( $this->fees_total < 0 ) { |
|
| 1323 | + if ($this->fees_total < 0) { |
|
| 1324 | 1324 | $this->fees_total = 0; |
| 1325 | 1325 | } |
| 1326 | 1326 | |
@@ -1349,41 +1349,41 @@ discard block |
||
| 1349 | 1349 | * |
| 1350 | 1350 | * @return bool $updated Returns if the status was successfully updated |
| 1351 | 1351 | */ |
| 1352 | - public function update_status( $status = false ) { |
|
| 1352 | + public function update_status($status = false) { |
|
| 1353 | 1353 | |
| 1354 | 1354 | //standardize the 'complete(d)' status |
| 1355 | - if ( $status == 'completed' || $status == 'complete' ) { |
|
| 1355 | + if ($status == 'completed' || $status == 'complete') { |
|
| 1356 | 1356 | $status = 'publish'; |
| 1357 | 1357 | } |
| 1358 | 1358 | |
| 1359 | - $old_status = ! empty( $this->old_status ) ? $this->old_status : false; |
|
| 1359 | + $old_status = ! empty($this->old_status) ? $this->old_status : false; |
|
| 1360 | 1360 | |
| 1361 | - if ( $old_status === $status ) { |
|
| 1361 | + if ($old_status === $status) { |
|
| 1362 | 1362 | return false; // Don't permit status changes that aren't changes |
| 1363 | 1363 | } |
| 1364 | 1364 | |
| 1365 | - $do_change = apply_filters( 'give_should_update_payment_status', true, $this->ID, $status, $old_status ); |
|
| 1365 | + $do_change = apply_filters('give_should_update_payment_status', true, $this->ID, $status, $old_status); |
|
| 1366 | 1366 | |
| 1367 | 1367 | $updated = false; |
| 1368 | 1368 | |
| 1369 | 1369 | |
| 1370 | - if ( $do_change ) { |
|
| 1370 | + if ($do_change) { |
|
| 1371 | 1371 | |
| 1372 | - do_action( 'give_before_payment_status_change', $this->ID, $status, $old_status ); |
|
| 1372 | + do_action('give_before_payment_status_change', $this->ID, $status, $old_status); |
|
| 1373 | 1373 | |
| 1374 | 1374 | $update_fields = array( |
| 1375 | 1375 | 'ID' => $this->ID, |
| 1376 | 1376 | 'post_status' => $status, |
| 1377 | - 'edit_date' => current_time( 'mysql' ) |
|
| 1377 | + 'edit_date' => current_time('mysql') |
|
| 1378 | 1378 | ); |
| 1379 | 1379 | |
| 1380 | - $updated = wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) ); |
|
| 1380 | + $updated = wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields)); |
|
| 1381 | 1381 | |
| 1382 | 1382 | $all_payment_statuses = give_get_payment_statuses(); |
| 1383 | - $this->status_nicename = array_key_exists( $status, $all_payment_statuses ) ? $all_payment_statuses[ $status ] : ucfirst( $status ); |
|
| 1383 | + $this->status_nicename = array_key_exists($status, $all_payment_statuses) ? $all_payment_statuses[$status] : ucfirst($status); |
|
| 1384 | 1384 | |
| 1385 | 1385 | // Process any specific status functions |
| 1386 | - switch ( $status ) { |
|
| 1386 | + switch ($status) { |
|
| 1387 | 1387 | case 'refunded': |
| 1388 | 1388 | $this->process_refund(); |
| 1389 | 1389 | break; |
@@ -1401,7 +1401,7 @@ discard block |
||
| 1401 | 1401 | break; |
| 1402 | 1402 | } |
| 1403 | 1403 | |
| 1404 | - do_action( 'give_update_payment_status', $this->ID, $status, $old_status ); |
|
| 1404 | + do_action('give_update_payment_status', $this->ID, $status, $old_status); |
|
| 1405 | 1405 | |
| 1406 | 1406 | } |
| 1407 | 1407 | |
@@ -1436,32 +1436,32 @@ discard block |
||
| 1436 | 1436 | * |
| 1437 | 1437 | * @return mixed The value from the post meta |
| 1438 | 1438 | */ |
| 1439 | - public function get_meta( $meta_key = '_give_payment_meta', $single = true ) { |
|
| 1439 | + public function get_meta($meta_key = '_give_payment_meta', $single = true) { |
|
| 1440 | 1440 | |
| 1441 | - $meta = get_post_meta( $this->ID, $meta_key, $single ); |
|
| 1441 | + $meta = get_post_meta($this->ID, $meta_key, $single); |
|
| 1442 | 1442 | |
| 1443 | - if ( $meta_key === '_give_payment_meta' ) { |
|
| 1443 | + if ($meta_key === '_give_payment_meta') { |
|
| 1444 | 1444 | |
| 1445 | - if ( empty( $meta['key'] ) ) { |
|
| 1445 | + if (empty($meta['key'])) { |
|
| 1446 | 1446 | $meta['key'] = $this->setup_payment_key(); |
| 1447 | 1447 | } |
| 1448 | 1448 | |
| 1449 | - if ( empty( $meta['form_title'] ) ) { |
|
| 1449 | + if (empty($meta['form_title'])) { |
|
| 1450 | 1450 | $meta['form_title'] = $this->setup_form_title(); |
| 1451 | 1451 | } |
| 1452 | 1452 | |
| 1453 | - if ( empty( $meta['email'] ) ) { |
|
| 1453 | + if (empty($meta['email'])) { |
|
| 1454 | 1454 | $meta['email'] = $this->setup_email(); |
| 1455 | 1455 | } |
| 1456 | 1456 | |
| 1457 | - if ( empty( $meta['date'] ) ) { |
|
| 1458 | - $meta['date'] = get_post_field( 'post_date', $this->ID ); |
|
| 1457 | + if (empty($meta['date'])) { |
|
| 1458 | + $meta['date'] = get_post_field('post_date', $this->ID); |
|
| 1459 | 1459 | } |
| 1460 | 1460 | } |
| 1461 | 1461 | |
| 1462 | - $meta = apply_filters( 'give_get_payment_meta_' . $meta_key, $meta, $this->ID ); |
|
| 1462 | + $meta = apply_filters('give_get_payment_meta_'.$meta_key, $meta, $this->ID); |
|
| 1463 | 1463 | |
| 1464 | - return apply_filters( 'give_get_payment_meta', $meta, $this->ID, $meta_key ); |
|
| 1464 | + return apply_filters('give_get_payment_meta', $meta, $this->ID, $meta_key); |
|
| 1465 | 1465 | } |
| 1466 | 1466 | |
| 1467 | 1467 | /** |
@@ -1476,23 +1476,23 @@ discard block |
||
| 1476 | 1476 | * |
| 1477 | 1477 | * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure |
| 1478 | 1478 | */ |
| 1479 | - public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
| 1480 | - if ( empty( $meta_key ) ) { |
|
| 1479 | + public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') { |
|
| 1480 | + if (empty($meta_key)) { |
|
| 1481 | 1481 | return false; |
| 1482 | 1482 | } |
| 1483 | 1483 | |
| 1484 | - if ( $meta_key == 'key' || $meta_key == 'date' ) { |
|
| 1484 | + if ($meta_key == 'key' || $meta_key == 'date') { |
|
| 1485 | 1485 | |
| 1486 | 1486 | $current_meta = $this->get_meta(); |
| 1487 | - $current_meta[ $meta_key ] = $meta_value; |
|
| 1487 | + $current_meta[$meta_key] = $meta_value; |
|
| 1488 | 1488 | |
| 1489 | 1489 | $meta_key = '_give_payment_meta'; |
| 1490 | 1490 | $meta_value = $current_meta; |
| 1491 | 1491 | |
| 1492 | - } else if ( $meta_key == 'email' || $meta_key == '_give_payment_user_email' ) { |
|
| 1492 | + } else if ($meta_key == 'email' || $meta_key == '_give_payment_user_email') { |
|
| 1493 | 1493 | |
| 1494 | - $meta_value = apply_filters( 'give_give_update_payment_meta_' . $meta_key, $meta_value, $this->ID ); |
|
| 1495 | - update_post_meta( $this->ID, '_give_payment_user_email', $meta_value ); |
|
| 1494 | + $meta_value = apply_filters('give_give_update_payment_meta_'.$meta_key, $meta_value, $this->ID); |
|
| 1495 | + update_post_meta($this->ID, '_give_payment_user_email', $meta_value); |
|
| 1496 | 1496 | |
| 1497 | 1497 | $current_meta = $this->get_meta(); |
| 1498 | 1498 | $current_meta['user_info']['email'] = $meta_value; |
@@ -1502,9 +1502,9 @@ discard block |
||
| 1502 | 1502 | |
| 1503 | 1503 | } |
| 1504 | 1504 | |
| 1505 | - $meta_value = apply_filters( 'give_update_payment_meta_' . $meta_key, $meta_value, $this->ID ); |
|
| 1505 | + $meta_value = apply_filters('give_update_payment_meta_'.$meta_key, $meta_value, $this->ID); |
|
| 1506 | 1506 | |
| 1507 | - return update_post_meta( $this->ID, $meta_key, $meta_value, $prev_value ); |
|
| 1507 | + return update_post_meta($this->ID, $meta_key, $meta_value, $prev_value); |
|
| 1508 | 1508 | } |
| 1509 | 1509 | |
| 1510 | 1510 | /** |
@@ -1519,30 +1519,30 @@ discard block |
||
| 1519 | 1519 | $process_refund = true; |
| 1520 | 1520 | |
| 1521 | 1521 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented |
| 1522 | - if ( 'publish' != $this->old_status || 'refunded' != $this->status ) { |
|
| 1522 | + if ('publish' != $this->old_status || 'refunded' != $this->status) { |
|
| 1523 | 1523 | $process_refund = false; |
| 1524 | 1524 | } |
| 1525 | 1525 | |
| 1526 | 1526 | // Allow extensions to filter for their own payment types, Example: Recurring Payments |
| 1527 | - $process_refund = apply_filters( 'give_should_process_refund', $process_refund, $this ); |
|
| 1527 | + $process_refund = apply_filters('give_should_process_refund', $process_refund, $this); |
|
| 1528 | 1528 | |
| 1529 | - if ( false === $process_refund ) { |
|
| 1529 | + if (false === $process_refund) { |
|
| 1530 | 1530 | return; |
| 1531 | 1531 | } |
| 1532 | 1532 | |
| 1533 | - do_action( 'give_pre_refund_payment', $this ); |
|
| 1533 | + do_action('give_pre_refund_payment', $this); |
|
| 1534 | 1534 | |
| 1535 | - $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_refund', true, $this ); |
|
| 1536 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_refund', true, $this ); |
|
| 1537 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_refund', true, $this ); |
|
| 1535 | + $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_refund', true, $this); |
|
| 1536 | + $decrease_customer_value = apply_filters('give_decrease_customer_value_on_refund', true, $this); |
|
| 1537 | + $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_refund', true, $this); |
|
| 1538 | 1538 | |
| 1539 | - $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
| 1539 | + $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count); |
|
| 1540 | 1540 | $this->delete_sales_logs(); |
| 1541 | 1541 | |
| 1542 | 1542 | // Clear the This Month earnings (this_monththis_month is NOT a typo) |
| 1543 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
| 1543 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
| 1544 | 1544 | |
| 1545 | - do_action( 'give_post_refund_payment', $this ); |
|
| 1545 | + do_action('give_post_refund_payment', $this); |
|
| 1546 | 1546 | } |
| 1547 | 1547 | |
| 1548 | 1548 | /** |
@@ -1569,29 +1569,29 @@ discard block |
||
| 1569 | 1569 | $process_pending = true; |
| 1570 | 1570 | |
| 1571 | 1571 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented |
| 1572 | - if ( 'publish' != $this->old_status || 'pending' != $this->status ) { |
|
| 1572 | + if ('publish' != $this->old_status || 'pending' != $this->status) { |
|
| 1573 | 1573 | $process_pending = false; |
| 1574 | 1574 | } |
| 1575 | 1575 | |
| 1576 | 1576 | // Allow extensions to filter for their own payment types, Example: Recurring Payments |
| 1577 | - $process_pending = apply_filters( 'give_should_process_pending', $process_pending, $this ); |
|
| 1577 | + $process_pending = apply_filters('give_should_process_pending', $process_pending, $this); |
|
| 1578 | 1578 | |
| 1579 | - if ( false === $process_pending ) { |
|
| 1579 | + if (false === $process_pending) { |
|
| 1580 | 1580 | return; |
| 1581 | 1581 | } |
| 1582 | 1582 | |
| 1583 | - $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_pending', true, $this ); |
|
| 1584 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_pending', true, $this ); |
|
| 1585 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_pending', true, $this ); |
|
| 1583 | + $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_pending', true, $this); |
|
| 1584 | + $decrease_customer_value = apply_filters('give_decrease_customer_value_on_pending', true, $this); |
|
| 1585 | + $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_pending', true, $this); |
|
| 1586 | 1586 | |
| 1587 | - $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
| 1587 | + $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count); |
|
| 1588 | 1588 | $this->delete_sales_logs(); |
| 1589 | 1589 | |
| 1590 | 1590 | $this->completed_date = false; |
| 1591 | - $this->update_meta( '_give_completed_date', '' ); |
|
| 1591 | + $this->update_meta('_give_completed_date', ''); |
|
| 1592 | 1592 | |
| 1593 | 1593 | // Clear the This Month earnings (this_monththis_month is NOT a typo) |
| 1594 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
| 1594 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
| 1595 | 1595 | } |
| 1596 | 1596 | |
| 1597 | 1597 | /** |
@@ -1606,29 +1606,29 @@ discard block |
||
| 1606 | 1606 | $process_cancelled = true; |
| 1607 | 1607 | |
| 1608 | 1608 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented |
| 1609 | - if ( 'publish' != $this->old_status || 'cancelled' != $this->status ) { |
|
| 1609 | + if ('publish' != $this->old_status || 'cancelled' != $this->status) { |
|
| 1610 | 1610 | $process_cancelled = false; |
| 1611 | 1611 | } |
| 1612 | 1612 | |
| 1613 | 1613 | // Allow extensions to filter for their own payment types, Example: Recurring Payments |
| 1614 | - $process_cancelled = apply_filters( 'give_should_process_cancelled', $process_cancelled, $this ); |
|
| 1614 | + $process_cancelled = apply_filters('give_should_process_cancelled', $process_cancelled, $this); |
|
| 1615 | 1615 | |
| 1616 | - if ( false === $process_cancelled ) { |
|
| 1616 | + if (false === $process_cancelled) { |
|
| 1617 | 1617 | return; |
| 1618 | 1618 | } |
| 1619 | 1619 | |
| 1620 | - $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_cancelled', true, $this ); |
|
| 1621 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_cancelled', true, $this ); |
|
| 1622 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_cancelled', true, $this ); |
|
| 1620 | + $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_cancelled', true, $this); |
|
| 1621 | + $decrease_customer_value = apply_filters('give_decrease_customer_value_on_cancelled', true, $this); |
|
| 1622 | + $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_cancelled', true, $this); |
|
| 1623 | 1623 | |
| 1624 | - $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
| 1624 | + $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count); |
|
| 1625 | 1625 | $this->delete_sales_logs(); |
| 1626 | 1626 | |
| 1627 | 1627 | $this->completed_date = false; |
| 1628 | - $this->update_meta( '_give_completed_date', '' ); |
|
| 1628 | + $this->update_meta('_give_completed_date', ''); |
|
| 1629 | 1629 | |
| 1630 | 1630 | // Clear the This Month earnings (this_monththis_month is NOT a typo) |
| 1631 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
| 1631 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
| 1632 | 1632 | } |
| 1633 | 1633 | |
| 1634 | 1634 | /** |
@@ -1641,29 +1641,29 @@ discard block |
||
| 1641 | 1641 | $process_revoked = true; |
| 1642 | 1642 | |
| 1643 | 1643 | // If the payment was not in publish, don't decrement stats as they were never incremented |
| 1644 | - if ( 'publish' != $this->old_status || 'revoked' != $this->status ) { |
|
| 1644 | + if ('publish' != $this->old_status || 'revoked' != $this->status) { |
|
| 1645 | 1645 | $process_revoked = false; |
| 1646 | 1646 | } |
| 1647 | 1647 | |
| 1648 | 1648 | // Allow extensions to filter for their own payment types, Example: Recurring Payments |
| 1649 | - $process_revoked = apply_filters( 'give_should_process_revoked', $process_revoked, $this ); |
|
| 1649 | + $process_revoked = apply_filters('give_should_process_revoked', $process_revoked, $this); |
|
| 1650 | 1650 | |
| 1651 | - if ( false === $process_revoked ) { |
|
| 1651 | + if (false === $process_revoked) { |
|
| 1652 | 1652 | return; |
| 1653 | 1653 | } |
| 1654 | 1654 | |
| 1655 | - $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_revoked', true, $this ); |
|
| 1656 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_revoked', true, $this ); |
|
| 1657 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_revoked', true, $this ); |
|
| 1655 | + $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_revoked', true, $this); |
|
| 1656 | + $decrease_customer_value = apply_filters('give_decrease_customer_value_on_revoked', true, $this); |
|
| 1657 | + $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_revoked', true, $this); |
|
| 1658 | 1658 | |
| 1659 | - $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
| 1659 | + $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count); |
|
| 1660 | 1660 | $this->delete_sales_logs(); |
| 1661 | 1661 | |
| 1662 | 1662 | $this->completed_date = false; |
| 1663 | - $this->update_meta( '_give_completed_date', '' ); |
|
| 1663 | + $this->update_meta('_give_completed_date', ''); |
|
| 1664 | 1664 | |
| 1665 | 1665 | // Clear the This Month earnings (this_monththis_month is NOT a typo) |
| 1666 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
| 1666 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
| 1667 | 1667 | } |
| 1668 | 1668 | |
| 1669 | 1669 | /** |
@@ -1678,25 +1678,25 @@ discard block |
||
| 1678 | 1678 | * |
| 1679 | 1679 | * @return void |
| 1680 | 1680 | */ |
| 1681 | - private function maybe_alter_stats( $alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count ) { |
|
| 1681 | + private function maybe_alter_stats($alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count) { |
|
| 1682 | 1682 | |
| 1683 | - give_undo_purchase( false, $this->ID ); |
|
| 1683 | + give_undo_purchase(false, $this->ID); |
|
| 1684 | 1684 | |
| 1685 | 1685 | // Decrease store earnings |
| 1686 | - if ( true === $alter_store_earnings ) { |
|
| 1687 | - give_decrease_total_earnings( $this->total ); |
|
| 1686 | + if (true === $alter_store_earnings) { |
|
| 1687 | + give_decrease_total_earnings($this->total); |
|
| 1688 | 1688 | } |
| 1689 | 1689 | |
| 1690 | 1690 | // Decrement the stats for the customer |
| 1691 | - if ( ! empty( $this->customer_id ) ) { |
|
| 1691 | + if ( ! empty($this->customer_id)) { |
|
| 1692 | 1692 | |
| 1693 | - $customer = new Give_Customer( $this->customer_id ); |
|
| 1693 | + $customer = new Give_Customer($this->customer_id); |
|
| 1694 | 1694 | |
| 1695 | - if ( true === $alter_customer_value ) { |
|
| 1696 | - $customer->decrease_value( $this->total ); |
|
| 1695 | + if (true === $alter_customer_value) { |
|
| 1696 | + $customer->decrease_value($this->total); |
|
| 1697 | 1697 | } |
| 1698 | 1698 | |
| 1699 | - if ( true === $alter_customer_purchase_count ) { |
|
| 1699 | + if (true === $alter_customer_purchase_count) { |
|
| 1700 | 1700 | $customer->decrease_purchase_count(); |
| 1701 | 1701 | } |
| 1702 | 1702 | |
@@ -1746,13 +1746,13 @@ discard block |
||
| 1746 | 1746 | * @return string The date the payment was completed |
| 1747 | 1747 | */ |
| 1748 | 1748 | private function setup_completed_date() { |
| 1749 | - $payment = get_post( $this->ID ); |
|
| 1749 | + $payment = get_post($this->ID); |
|
| 1750 | 1750 | |
| 1751 | - if ( 'pending' == $payment->post_status || 'preapproved' == $payment->post_status ) { |
|
| 1751 | + if ('pending' == $payment->post_status || 'preapproved' == $payment->post_status) { |
|
| 1752 | 1752 | return false; // This payment was never completed |
| 1753 | 1753 | } |
| 1754 | 1754 | |
| 1755 | - $date = ( $date = $this->get_meta( '_give_completed_date', true ) ) ? $date : $payment->modified_date; |
|
| 1755 | + $date = ($date = $this->get_meta('_give_completed_date', true)) ? $date : $payment->modified_date; |
|
| 1756 | 1756 | |
| 1757 | 1757 | return $date; |
| 1758 | 1758 | } |
@@ -1766,7 +1766,7 @@ discard block |
||
| 1766 | 1766 | * @return string The payment mode |
| 1767 | 1767 | */ |
| 1768 | 1768 | private function setup_mode() { |
| 1769 | - return $this->get_meta( '_give_payment_mode' ); |
|
| 1769 | + return $this->get_meta('_give_payment_mode'); |
|
| 1770 | 1770 | } |
| 1771 | 1771 | |
| 1772 | 1772 | /** |
@@ -1778,13 +1778,13 @@ discard block |
||
| 1778 | 1778 | * @return float The payment total |
| 1779 | 1779 | */ |
| 1780 | 1780 | private function setup_total() { |
| 1781 | - $amount = $this->get_meta( '_give_payment_total', true ); |
|
| 1781 | + $amount = $this->get_meta('_give_payment_total', true); |
|
| 1782 | 1782 | |
| 1783 | - if ( empty( $amount ) && '0.00' != $amount ) { |
|
| 1784 | - $meta = $this->get_meta( '_give_payment_meta', true ); |
|
| 1785 | - $meta = maybe_unserialize( $meta ); |
|
| 1783 | + if (empty($amount) && '0.00' != $amount) { |
|
| 1784 | + $meta = $this->get_meta('_give_payment_meta', true); |
|
| 1785 | + $meta = maybe_unserialize($meta); |
|
| 1786 | 1786 | |
| 1787 | - if ( isset( $meta['amount'] ) ) { |
|
| 1787 | + if (isset($meta['amount'])) { |
|
| 1788 | 1788 | $amount = $meta['amount']; |
| 1789 | 1789 | } |
| 1790 | 1790 | } |
@@ -1817,9 +1817,9 @@ discard block |
||
| 1817 | 1817 | private function setup_fees_total() { |
| 1818 | 1818 | $fees_total = (float) 0.00; |
| 1819 | 1819 | |
| 1820 | - $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array(); |
|
| 1821 | - if ( ! empty( $payment_fees ) ) { |
|
| 1822 | - foreach ( $payment_fees as $fee ) { |
|
| 1820 | + $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array(); |
|
| 1821 | + if ( ! empty($payment_fees)) { |
|
| 1822 | + foreach ($payment_fees as $fee) { |
|
| 1823 | 1823 | $fees_total += (float) $fee['amount']; |
| 1824 | 1824 | } |
| 1825 | 1825 | } |
@@ -1837,7 +1837,7 @@ discard block |
||
| 1837 | 1837 | * @return string The currency for the payment |
| 1838 | 1838 | */ |
| 1839 | 1839 | private function setup_currency() { |
| 1840 | - $currency = isset( $this->payment_meta['currency'] ) ? $this->payment_meta['currency'] : apply_filters( 'give_payment_currency_default', give_get_currency(), $this ); |
|
| 1840 | + $currency = isset($this->payment_meta['currency']) ? $this->payment_meta['currency'] : apply_filters('give_payment_currency_default', give_get_currency(), $this); |
|
| 1841 | 1841 | |
| 1842 | 1842 | return $currency; |
| 1843 | 1843 | } |
@@ -1851,7 +1851,7 @@ discard block |
||
| 1851 | 1851 | * @return array The Fees |
| 1852 | 1852 | */ |
| 1853 | 1853 | private function setup_fees() { |
| 1854 | - $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array(); |
|
| 1854 | + $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array(); |
|
| 1855 | 1855 | |
| 1856 | 1856 | return $payment_fees; |
| 1857 | 1857 | } |
@@ -1865,7 +1865,7 @@ discard block |
||
| 1865 | 1865 | * @return string The gateway |
| 1866 | 1866 | */ |
| 1867 | 1867 | private function setup_gateway() { |
| 1868 | - $gateway = $this->get_meta( '_give_payment_gateway', true ); |
|
| 1868 | + $gateway = $this->get_meta('_give_payment_gateway', true); |
|
| 1869 | 1869 | |
| 1870 | 1870 | return $gateway; |
| 1871 | 1871 | } |
@@ -1879,12 +1879,12 @@ discard block |
||
| 1879 | 1879 | * @return string The transaction ID for the payment |
| 1880 | 1880 | */ |
| 1881 | 1881 | private function setup_transaction_id() { |
| 1882 | - $transaction_id = $this->get_meta( '_give_payment_transaction_id', true ); |
|
| 1882 | + $transaction_id = $this->get_meta('_give_payment_transaction_id', true); |
|
| 1883 | 1883 | |
| 1884 | - if ( empty( $transaction_id ) || (int) $transaction_id === (int) $this->ID ) { |
|
| 1884 | + if (empty($transaction_id) || (int) $transaction_id === (int) $this->ID) { |
|
| 1885 | 1885 | |
| 1886 | 1886 | $gateway = $this->gateway; |
| 1887 | - $transaction_id = apply_filters( 'give_get_payment_transaction_id-' . $gateway, $this->ID ); |
|
| 1887 | + $transaction_id = apply_filters('give_get_payment_transaction_id-'.$gateway, $this->ID); |
|
| 1888 | 1888 | |
| 1889 | 1889 | } |
| 1890 | 1890 | |
@@ -1900,7 +1900,7 @@ discard block |
||
| 1900 | 1900 | * @return string The IP address for the payment |
| 1901 | 1901 | */ |
| 1902 | 1902 | private function setup_ip() { |
| 1903 | - $ip = $this->get_meta( '_give_payment_user_ip', true ); |
|
| 1903 | + $ip = $this->get_meta('_give_payment_user_ip', true); |
|
| 1904 | 1904 | |
| 1905 | 1905 | return $ip; |
| 1906 | 1906 | } |
@@ -1914,7 +1914,7 @@ discard block |
||
| 1914 | 1914 | * @return int The Customer ID |
| 1915 | 1915 | */ |
| 1916 | 1916 | private function setup_customer_id() { |
| 1917 | - $customer_id = $this->get_meta( '_give_payment_customer_id', true ); |
|
| 1917 | + $customer_id = $this->get_meta('_give_payment_customer_id', true); |
|
| 1918 | 1918 | |
| 1919 | 1919 | return $customer_id; |
| 1920 | 1920 | } |
@@ -1928,7 +1928,7 @@ discard block |
||
| 1928 | 1928 | * @return int The User ID |
| 1929 | 1929 | */ |
| 1930 | 1930 | private function setup_user_id() { |
| 1931 | - $user_id = $this->get_meta( '_give_payment_user_id', true ); |
|
| 1931 | + $user_id = $this->get_meta('_give_payment_user_id', true); |
|
| 1932 | 1932 | |
| 1933 | 1933 | return $user_id; |
| 1934 | 1934 | } |
@@ -1942,10 +1942,10 @@ discard block |
||
| 1942 | 1942 | * @return string The email address for the payment |
| 1943 | 1943 | */ |
| 1944 | 1944 | private function setup_email() { |
| 1945 | - $email = $this->get_meta( '_give_payment_user_email', true ); |
|
| 1945 | + $email = $this->get_meta('_give_payment_user_email', true); |
|
| 1946 | 1946 | |
| 1947 | - if ( empty( $email ) ) { |
|
| 1948 | - $email = Give()->customers->get_column( 'email', $this->customer_id ); |
|
| 1947 | + if (empty($email)) { |
|
| 1948 | + $email = Give()->customers->get_column('email', $this->customer_id); |
|
| 1949 | 1949 | } |
| 1950 | 1950 | |
| 1951 | 1951 | return $email; |
@@ -1965,15 +1965,15 @@ discard block |
||
| 1965 | 1965 | 'last_name' => $this->last_name, |
| 1966 | 1966 | ); |
| 1967 | 1967 | |
| 1968 | - $user_info = isset( $this->payment_meta['user_info'] ) ? maybe_unserialize( $this->payment_meta['user_info'] ) : array(); |
|
| 1969 | - $user_info = wp_parse_args( $user_info, $defaults ); |
|
| 1968 | + $user_info = isset($this->payment_meta['user_info']) ? maybe_unserialize($this->payment_meta['user_info']) : array(); |
|
| 1969 | + $user_info = wp_parse_args($user_info, $defaults); |
|
| 1970 | 1970 | |
| 1971 | - if ( empty( $user_info ) ) { |
|
| 1971 | + if (empty($user_info)) { |
|
| 1972 | 1972 | // Get the customer, but only if it's been created |
| 1973 | - $customer = new Give_Customer( $this->customer_id ); |
|
| 1973 | + $customer = new Give_Customer($this->customer_id); |
|
| 1974 | 1974 | |
| 1975 | - if ( $customer->id > 0 ) { |
|
| 1976 | - $name = explode( ' ', $customer->name, 2 ); |
|
| 1975 | + if ($customer->id > 0) { |
|
| 1976 | + $name = explode(' ', $customer->name, 2); |
|
| 1977 | 1977 | $user_info = array( |
| 1978 | 1978 | 'first_name' => $name[0], |
| 1979 | 1979 | 'last_name' => $name[1], |
@@ -1983,29 +1983,29 @@ discard block |
||
| 1983 | 1983 | } |
| 1984 | 1984 | } else { |
| 1985 | 1985 | // Get the customer, but only if it's been created |
| 1986 | - $customer = new Give_Customer( $this->customer_id ); |
|
| 1987 | - if ( $customer->id > 0 ) { |
|
| 1988 | - foreach ( $user_info as $key => $value ) { |
|
| 1989 | - if ( ! empty( $value ) ) { |
|
| 1986 | + $customer = new Give_Customer($this->customer_id); |
|
| 1987 | + if ($customer->id > 0) { |
|
| 1988 | + foreach ($user_info as $key => $value) { |
|
| 1989 | + if ( ! empty($value)) { |
|
| 1990 | 1990 | continue; |
| 1991 | 1991 | } |
| 1992 | 1992 | |
| 1993 | - switch ( $key ) { |
|
| 1993 | + switch ($key) { |
|
| 1994 | 1994 | case 'first_name': |
| 1995 | - $name = explode( ' ', $customer->name, 2 ); |
|
| 1995 | + $name = explode(' ', $customer->name, 2); |
|
| 1996 | 1996 | |
| 1997 | - $user_info[ $key ] = $name[0]; |
|
| 1997 | + $user_info[$key] = $name[0]; |
|
| 1998 | 1998 | break; |
| 1999 | 1999 | |
| 2000 | 2000 | case 'last_name': |
| 2001 | - $name = explode( ' ', $customer->name, 2 ); |
|
| 2002 | - $last_name = ! empty( $name[1] ) ? $name[1] : ''; |
|
| 2001 | + $name = explode(' ', $customer->name, 2); |
|
| 2002 | + $last_name = ! empty($name[1]) ? $name[1] : ''; |
|
| 2003 | 2003 | |
| 2004 | - $user_info[ $key ] = $last_name; |
|
| 2004 | + $user_info[$key] = $last_name; |
|
| 2005 | 2005 | break; |
| 2006 | 2006 | |
| 2007 | 2007 | case 'email': |
| 2008 | - $user_info[ $key ] = $customer->email; |
|
| 2008 | + $user_info[$key] = $customer->email; |
|
| 2009 | 2009 | break; |
| 2010 | 2010 | } |
| 2011 | 2011 | } |
@@ -2027,7 +2027,7 @@ discard block |
||
| 2027 | 2027 | */ |
| 2028 | 2028 | private function setup_address() { |
| 2029 | 2029 | |
| 2030 | - $address = ! empty( $this->payment_meta['user_info']['address'] ) ? $this->payment_meta['user_info']['address'] : array( |
|
| 2030 | + $address = ! empty($this->payment_meta['user_info']['address']) ? $this->payment_meta['user_info']['address'] : array( |
|
| 2031 | 2031 | 'line1' => '', |
| 2032 | 2032 | 'line2' => '', |
| 2033 | 2033 | 'city' => '', |
@@ -2049,7 +2049,7 @@ discard block |
||
| 2049 | 2049 | */ |
| 2050 | 2050 | private function setup_form_title() { |
| 2051 | 2051 | |
| 2052 | - $form_id = $this->get_meta( '_give_payment_form_title', true ); |
|
| 2052 | + $form_id = $this->get_meta('_give_payment_form_title', true); |
|
| 2053 | 2053 | |
| 2054 | 2054 | return $form_id; |
| 2055 | 2055 | } |
@@ -2064,7 +2064,7 @@ discard block |
||
| 2064 | 2064 | */ |
| 2065 | 2065 | private function setup_form_id() { |
| 2066 | 2066 | |
| 2067 | - $form_id = $this->get_meta( '_give_payment_form_id', true ); |
|
| 2067 | + $form_id = $this->get_meta('_give_payment_form_id', true); |
|
| 2068 | 2068 | |
| 2069 | 2069 | return $form_id; |
| 2070 | 2070 | } |
@@ -2078,7 +2078,7 @@ discard block |
||
| 2078 | 2078 | * @return int The Form Price ID |
| 2079 | 2079 | */ |
| 2080 | 2080 | private function setup_price_id() { |
| 2081 | - $price_id = $this->get_meta( '_give_payment_price_id', true ); |
|
| 2081 | + $price_id = $this->get_meta('_give_payment_price_id', true); |
|
| 2082 | 2082 | |
| 2083 | 2083 | return $price_id; |
| 2084 | 2084 | } |
@@ -2092,7 +2092,7 @@ discard block |
||
| 2092 | 2092 | * @return string The Payment Key |
| 2093 | 2093 | */ |
| 2094 | 2094 | private function setup_payment_key() { |
| 2095 | - $key = $this->get_meta( '_give_payment_purchase_key', true ); |
|
| 2095 | + $key = $this->get_meta('_give_payment_purchase_key', true); |
|
| 2096 | 2096 | |
| 2097 | 2097 | return $key; |
| 2098 | 2098 | } |
@@ -2108,11 +2108,11 @@ discard block |
||
| 2108 | 2108 | private function setup_payment_number() { |
| 2109 | 2109 | $number = $this->ID; |
| 2110 | 2110 | |
| 2111 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
| 2111 | + if (give_get_option('enable_sequential')) { |
|
| 2112 | 2112 | |
| 2113 | - $number = $this->get_meta( '_give_payment_number', true ); |
|
| 2113 | + $number = $this->get_meta('_give_payment_number', true); |
|
| 2114 | 2114 | |
| 2115 | - if ( ! $number ) { |
|
| 2115 | + if ( ! $number) { |
|
| 2116 | 2116 | |
| 2117 | 2117 | $number = $this->ID; |
| 2118 | 2118 | |
@@ -2131,7 +2131,7 @@ discard block |
||
| 2131 | 2131 | * @return array The payment object as an array |
| 2132 | 2132 | */ |
| 2133 | 2133 | public function array_convert() { |
| 2134 | - return get_object_vars( $this ); |
|
| 2134 | + return get_object_vars($this); |
|
| 2135 | 2135 | } |
| 2136 | 2136 | |
| 2137 | 2137 | /** |
@@ -2143,7 +2143,7 @@ discard block |
||
| 2143 | 2143 | * @return string Date payment was completed |
| 2144 | 2144 | */ |
| 2145 | 2145 | private function get_completed_date() { |
| 2146 | - return apply_filters( 'give_payment_completed_date', $this->completed_date, $this->ID, $this ); |
|
| 2146 | + return apply_filters('give_payment_completed_date', $this->completed_date, $this->ID, $this); |
|
| 2147 | 2147 | } |
| 2148 | 2148 | |
| 2149 | 2149 | /** |
@@ -2155,7 +2155,7 @@ discard block |
||
| 2155 | 2155 | * @return float Payment subtotal |
| 2156 | 2156 | */ |
| 2157 | 2157 | private function get_subtotal() { |
| 2158 | - return apply_filters( 'give_get_payment_subtotal', $this->subtotal, $this->ID, $this ); |
|
| 2158 | + return apply_filters('give_get_payment_subtotal', $this->subtotal, $this->ID, $this); |
|
| 2159 | 2159 | } |
| 2160 | 2160 | |
| 2161 | 2161 | /** |
@@ -2167,7 +2167,7 @@ discard block |
||
| 2167 | 2167 | * @return string Payment currency code |
| 2168 | 2168 | */ |
| 2169 | 2169 | private function get_currency() { |
| 2170 | - return apply_filters( 'give_payment_currency_code', $this->currency, $this->ID, $this ); |
|
| 2170 | + return apply_filters('give_payment_currency_code', $this->currency, $this->ID, $this); |
|
| 2171 | 2171 | } |
| 2172 | 2172 | |
| 2173 | 2173 | /** |
@@ -2179,7 +2179,7 @@ discard block |
||
| 2179 | 2179 | * @return string Gateway used |
| 2180 | 2180 | */ |
| 2181 | 2181 | private function get_gateway() { |
| 2182 | - return apply_filters( 'give_payment_gateway', $this->gateway, $this->ID, $this ); |
|
| 2182 | + return apply_filters('give_payment_gateway', $this->gateway, $this->ID, $this); |
|
| 2183 | 2183 | } |
| 2184 | 2184 | |
| 2185 | 2185 | /** |
@@ -2191,7 +2191,7 @@ discard block |
||
| 2191 | 2191 | * @return string Transaction ID from merchant processor |
| 2192 | 2192 | */ |
| 2193 | 2193 | private function get_transaction_id() { |
| 2194 | - return apply_filters( 'give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this ); |
|
| 2194 | + return apply_filters('give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this); |
|
| 2195 | 2195 | } |
| 2196 | 2196 | |
| 2197 | 2197 | /** |
@@ -2203,7 +2203,7 @@ discard block |
||
| 2203 | 2203 | * @return string Payment IP address |
| 2204 | 2204 | */ |
| 2205 | 2205 | private function get_ip() { |
| 2206 | - return apply_filters( 'give_payment_user_ip', $this->ip, $this->ID, $this ); |
|
| 2206 | + return apply_filters('give_payment_user_ip', $this->ip, $this->ID, $this); |
|
| 2207 | 2207 | } |
| 2208 | 2208 | |
| 2209 | 2209 | /** |
@@ -2215,7 +2215,7 @@ discard block |
||
| 2215 | 2215 | * @return int Payment customer ID |
| 2216 | 2216 | */ |
| 2217 | 2217 | private function get_customer_id() { |
| 2218 | - return apply_filters( 'give_payment_customer_id', $this->customer_id, $this->ID, $this ); |
|
| 2218 | + return apply_filters('give_payment_customer_id', $this->customer_id, $this->ID, $this); |
|
| 2219 | 2219 | } |
| 2220 | 2220 | |
| 2221 | 2221 | /** |
@@ -2227,7 +2227,7 @@ discard block |
||
| 2227 | 2227 | * @return int Payment user ID |
| 2228 | 2228 | */ |
| 2229 | 2229 | private function get_user_id() { |
| 2230 | - return apply_filters( 'give_payment_user_id', $this->user_id, $this->ID, $this ); |
|
| 2230 | + return apply_filters('give_payment_user_id', $this->user_id, $this->ID, $this); |
|
| 2231 | 2231 | } |
| 2232 | 2232 | |
| 2233 | 2233 | /** |
@@ -2239,7 +2239,7 @@ discard block |
||
| 2239 | 2239 | * @return string Payment customer email |
| 2240 | 2240 | */ |
| 2241 | 2241 | private function get_email() { |
| 2242 | - return apply_filters( 'give_payment_user_email', $this->email, $this->ID, $this ); |
|
| 2242 | + return apply_filters('give_payment_user_email', $this->email, $this->ID, $this); |
|
| 2243 | 2243 | } |
| 2244 | 2244 | |
| 2245 | 2245 | /** |
@@ -2251,7 +2251,7 @@ discard block |
||
| 2251 | 2251 | * @return array Payment user info |
| 2252 | 2252 | */ |
| 2253 | 2253 | private function get_user_info() { |
| 2254 | - return apply_filters( 'give_payment_meta_user_info', $this->user_info, $this->ID, $this ); |
|
| 2254 | + return apply_filters('give_payment_meta_user_info', $this->user_info, $this->ID, $this); |
|
| 2255 | 2255 | } |
| 2256 | 2256 | |
| 2257 | 2257 | /** |
@@ -2263,7 +2263,7 @@ discard block |
||
| 2263 | 2263 | * @return array Payment billing address |
| 2264 | 2264 | */ |
| 2265 | 2265 | private function get_address() { |
| 2266 | - return apply_filters( 'give_payment_address', $this->address, $this->ID, $this ); |
|
| 2266 | + return apply_filters('give_payment_address', $this->address, $this->ID, $this); |
|
| 2267 | 2267 | } |
| 2268 | 2268 | |
| 2269 | 2269 | /** |
@@ -2275,7 +2275,7 @@ discard block |
||
| 2275 | 2275 | * @return string Payment key |
| 2276 | 2276 | */ |
| 2277 | 2277 | private function get_key() { |
| 2278 | - return apply_filters( 'give_payment_key', $this->key, $this->ID, $this ); |
|
| 2278 | + return apply_filters('give_payment_key', $this->key, $this->ID, $this); |
|
| 2279 | 2279 | } |
| 2280 | 2280 | |
| 2281 | 2281 | /** |
@@ -2287,7 +2287,7 @@ discard block |
||
| 2287 | 2287 | * @return string Payment form id |
| 2288 | 2288 | */ |
| 2289 | 2289 | private function get_form_id() { |
| 2290 | - return apply_filters( 'give_payment_form_id', $this->form_id, $this->ID, $this ); |
|
| 2290 | + return apply_filters('give_payment_form_id', $this->form_id, $this->ID, $this); |
|
| 2291 | 2291 | } |
| 2292 | 2292 | |
| 2293 | 2293 | /** |
@@ -2299,7 +2299,7 @@ discard block |
||
| 2299 | 2299 | * @return int|string Payment number |
| 2300 | 2300 | */ |
| 2301 | 2301 | private function get_number() { |
| 2302 | - return apply_filters( 'give_payment_number', $this->number, $this->ID, $this ); |
|
| 2302 | + return apply_filters('give_payment_number', $this->number, $this->ID, $this); |
|
| 2303 | 2303 | } |
| 2304 | 2304 | |
| 2305 | 2305 | } |
@@ -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 | |
@@ -54,10 +54,10 @@ discard block |
||
| 54 | 54 | * |
| 55 | 55 | * @param $args array The array of arguments that can be passed in and used for setting up this payment query. |
| 56 | 56 | */ |
| 57 | - public function __construct( $args = array() ) { |
|
| 57 | + public function __construct($args = array()) { |
|
| 58 | 58 | $defaults = array( |
| 59 | 59 | 'output' => 'payments', // Use 'posts' to get standard post objects |
| 60 | - 'post_type' => array( 'give_payment' ), |
|
| 60 | + 'post_type' => array('give_payment'), |
|
| 61 | 61 | 'start_date' => false, |
| 62 | 62 | 'end_date' => false, |
| 63 | 63 | 'number' => 20, |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | 'give_forms' => null |
| 78 | 78 | ); |
| 79 | 79 | |
| 80 | - $this->args = wp_parse_args( $args, $defaults ); |
|
| 80 | + $this->args = wp_parse_args($args, $defaults); |
|
| 81 | 81 | |
| 82 | 82 | $this->init(); |
| 83 | 83 | } |
@@ -88,11 +88,11 @@ discard block |
||
| 88 | 88 | * @access public |
| 89 | 89 | * @since 1.0 |
| 90 | 90 | */ |
| 91 | - public function __set( $query_var, $value ) { |
|
| 92 | - if ( in_array( $query_var, array( 'meta_query', 'tax_query' ) ) ) { |
|
| 93 | - $this->args[ $query_var ][] = $value; |
|
| 91 | + public function __set($query_var, $value) { |
|
| 92 | + if (in_array($query_var, array('meta_query', 'tax_query'))) { |
|
| 93 | + $this->args[$query_var][] = $value; |
|
| 94 | 94 | } else { |
| 95 | - $this->args[ $query_var ] = $value; |
|
| 95 | + $this->args[$query_var] = $value; |
|
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | * @access public |
| 103 | 103 | * @since 1.0 |
| 104 | 104 | */ |
| 105 | - public function __unset( $query_var ) { |
|
| 106 | - unset( $this->args[ $query_var ] ); |
|
| 105 | + public function __unset($query_var) { |
|
| 106 | + unset($this->args[$query_var]); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -115,19 +115,19 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | public function init() { |
| 117 | 117 | |
| 118 | - add_action( 'give_pre_get_payments', array( $this, 'date_filter_pre' ) ); |
|
| 119 | - add_action( 'give_post_get_payments', array( $this, 'date_filter_post' ) ); |
|
| 120 | - |
|
| 121 | - add_action( 'give_pre_get_payments', array( $this, 'orderby' ) ); |
|
| 122 | - add_action( 'give_pre_get_payments', array( $this, 'status' ) ); |
|
| 123 | - add_action( 'give_pre_get_payments', array( $this, 'month' ) ); |
|
| 124 | - add_action( 'give_pre_get_payments', array( $this, 'per_page' ) ); |
|
| 125 | - add_action( 'give_pre_get_payments', array( $this, 'page' ) ); |
|
| 126 | - add_action( 'give_pre_get_payments', array( $this, 'user' ) ); |
|
| 127 | - add_action( 'give_pre_get_payments', array( $this, 'search' ) ); |
|
| 128 | - add_action( 'give_pre_get_payments', array( $this, 'mode' ) ); |
|
| 129 | - add_action( 'give_pre_get_payments', array( $this, 'children' ) ); |
|
| 130 | - add_action( 'give_pre_get_payments', array( $this, 'give_forms' ) ); |
|
| 118 | + add_action('give_pre_get_payments', array($this, 'date_filter_pre')); |
|
| 119 | + add_action('give_post_get_payments', array($this, 'date_filter_post')); |
|
| 120 | + |
|
| 121 | + add_action('give_pre_get_payments', array($this, 'orderby')); |
|
| 122 | + add_action('give_pre_get_payments', array($this, 'status')); |
|
| 123 | + add_action('give_pre_get_payments', array($this, 'month')); |
|
| 124 | + add_action('give_pre_get_payments', array($this, 'per_page')); |
|
| 125 | + add_action('give_pre_get_payments', array($this, 'page')); |
|
| 126 | + add_action('give_pre_get_payments', array($this, 'user')); |
|
| 127 | + add_action('give_pre_get_payments', array($this, 'search')); |
|
| 128 | + add_action('give_pre_get_payments', array($this, 'mode')); |
|
| 129 | + add_action('give_pre_get_payments', array($this, 'children')); |
|
| 130 | + add_action('give_pre_get_payments', array($this, 'give_forms')); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -143,33 +143,33 @@ discard block |
||
| 143 | 143 | */ |
| 144 | 144 | public function get_payments() { |
| 145 | 145 | |
| 146 | - do_action( 'give_pre_get_payments', $this ); |
|
| 146 | + do_action('give_pre_get_payments', $this); |
|
| 147 | 147 | |
| 148 | - $query = new WP_Query( $this->args ); |
|
| 148 | + $query = new WP_Query($this->args); |
|
| 149 | 149 | |
| 150 | 150 | $custom_output = array( |
| 151 | 151 | 'payments', |
| 152 | 152 | 'give_payments', |
| 153 | 153 | ); |
| 154 | 154 | |
| 155 | - if ( ! in_array( $this->args['output'], $custom_output ) ) { |
|
| 155 | + if ( ! in_array($this->args['output'], $custom_output)) { |
|
| 156 | 156 | return $query->posts; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - if ( $query->have_posts() ) { |
|
| 160 | - while ( $query->have_posts() ) { |
|
| 159 | + if ($query->have_posts()) { |
|
| 160 | + while ($query->have_posts()) { |
|
| 161 | 161 | $query->the_post(); |
| 162 | 162 | |
| 163 | 163 | $payment_id = get_post()->ID; |
| 164 | - $payment = new Give_Payment( $payment_id ); |
|
| 164 | + $payment = new Give_Payment($payment_id); |
|
| 165 | 165 | |
| 166 | - $this->payments[] = apply_filters( 'give_payment', $payment, $payment_id, $this ); |
|
| 166 | + $this->payments[] = apply_filters('give_payment', $payment, $payment_id, $this); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | wp_reset_postdata(); |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - do_action( 'give_post_get_payments', $this ); |
|
| 172 | + do_action('give_post_get_payments', $this); |
|
| 173 | 173 | |
| 174 | 174 | return $this->payments; |
| 175 | 175 | } |
@@ -182,13 +182,13 @@ discard block |
||
| 182 | 182 | * @return void |
| 183 | 183 | */ |
| 184 | 184 | public function date_filter_pre() { |
| 185 | - if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) { |
|
| 185 | + if ( ! ($this->args['start_date'] || $this->args['end_date'])) { |
|
| 186 | 186 | return; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - $this->setup_dates( $this->args['start_date'], $this->args['end_date'] ); |
|
| 189 | + $this->setup_dates($this->args['start_date'], $this->args['end_date']); |
|
| 190 | 190 | |
| 191 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
| 191 | + add_filter('posts_where', array($this, 'payments_where')); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | /** |
@@ -200,11 +200,11 @@ discard block |
||
| 200 | 200 | * @return void |
| 201 | 201 | */ |
| 202 | 202 | public function date_filter_post() { |
| 203 | - if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) { |
|
| 203 | + if ( ! ($this->args['start_date'] || $this->args['end_date'])) { |
|
| 204 | 204 | return; |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
| 207 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | /** |
@@ -215,12 +215,12 @@ discard block |
||
| 215 | 215 | * @return void |
| 216 | 216 | */ |
| 217 | 217 | public function status() { |
| 218 | - if ( ! isset ( $this->args['status'] ) ) { |
|
| 218 | + if ( ! isset ($this->args['status'])) { |
|
| 219 | 219 | return; |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - $this->__set( 'post_status', $this->args['status'] ); |
|
| 223 | - $this->__unset( 'status' ); |
|
| 222 | + $this->__set('post_status', $this->args['status']); |
|
| 223 | + $this->__unset('status'); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** |
@@ -231,12 +231,12 @@ discard block |
||
| 231 | 231 | * @return void |
| 232 | 232 | */ |
| 233 | 233 | public function page() { |
| 234 | - if ( ! isset ( $this->args['page'] ) ) { |
|
| 234 | + if ( ! isset ($this->args['page'])) { |
|
| 235 | 235 | return; |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - $this->__set( 'paged', $this->args['page'] ); |
|
| 239 | - $this->__unset( 'page' ); |
|
| 238 | + $this->__set('paged', $this->args['page']); |
|
| 239 | + $this->__unset('page'); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
@@ -248,17 +248,17 @@ discard block |
||
| 248 | 248 | */ |
| 249 | 249 | public function per_page() { |
| 250 | 250 | |
| 251 | - if ( ! isset( $this->args['number'] ) ) { |
|
| 251 | + if ( ! isset($this->args['number'])) { |
|
| 252 | 252 | return; |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | - if ( $this->args['number'] == - 1 ) { |
|
| 256 | - $this->__set( 'nopaging', true ); |
|
| 255 | + if ($this->args['number'] == - 1) { |
|
| 256 | + $this->__set('nopaging', true); |
|
| 257 | 257 | } else { |
| 258 | - $this->__set( 'posts_per_page', $this->args['number'] ); |
|
| 258 | + $this->__set('posts_per_page', $this->args['number']); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - $this->__unset( 'number' ); |
|
| 261 | + $this->__unset('number'); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | /** |
@@ -269,12 +269,12 @@ discard block |
||
| 269 | 269 | * @return void |
| 270 | 270 | */ |
| 271 | 271 | public function month() { |
| 272 | - if ( ! isset ( $this->args['month'] ) ) { |
|
| 272 | + if ( ! isset ($this->args['month'])) { |
|
| 273 | 273 | return; |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - $this->__set( 'monthnum', $this->args['month'] ); |
|
| 277 | - $this->__unset( 'month' ); |
|
| 276 | + $this->__set('monthnum', $this->args['month']); |
|
| 277 | + $this->__unset('month'); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | /** |
@@ -285,13 +285,13 @@ discard block |
||
| 285 | 285 | * @return void |
| 286 | 286 | */ |
| 287 | 287 | public function orderby() { |
| 288 | - switch ( $this->args['orderby'] ) { |
|
| 288 | + switch ($this->args['orderby']) { |
|
| 289 | 289 | case 'amount' : |
| 290 | - $this->__set( 'orderby', 'meta_value_num' ); |
|
| 291 | - $this->__set( 'meta_key', '_give_payment_total' ); |
|
| 290 | + $this->__set('orderby', 'meta_value_num'); |
|
| 291 | + $this->__set('meta_key', '_give_payment_total'); |
|
| 292 | 292 | break; |
| 293 | 293 | default : |
| 294 | - $this->__set( 'orderby', $this->args['orderby'] ); |
|
| 294 | + $this->__set('orderby', $this->args['orderby']); |
|
| 295 | 295 | break; |
| 296 | 296 | } |
| 297 | 297 | } |
@@ -304,20 +304,20 @@ discard block |
||
| 304 | 304 | * @return void |
| 305 | 305 | */ |
| 306 | 306 | public function user() { |
| 307 | - if ( is_null( $this->args['user'] ) ) { |
|
| 307 | + if (is_null($this->args['user'])) { |
|
| 308 | 308 | return; |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | - if ( is_numeric( $this->args['user'] ) ) { |
|
| 311 | + if (is_numeric($this->args['user'])) { |
|
| 312 | 312 | $user_key = '_give_payment_user_id'; |
| 313 | 313 | } else { |
| 314 | 314 | $user_key = '_give_payment_user_email'; |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - $this->__set( 'meta_query', array( |
|
| 317 | + $this->__set('meta_query', array( |
|
| 318 | 318 | 'key' => $user_key, |
| 319 | 319 | 'value' => $this->args['user'] |
| 320 | - ) ); |
|
| 320 | + )); |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | /** |
@@ -329,33 +329,33 @@ discard block |
||
| 329 | 329 | */ |
| 330 | 330 | public function search() { |
| 331 | 331 | |
| 332 | - if ( ! isset( $this->args['s'] ) ) { |
|
| 332 | + if ( ! isset($this->args['s'])) { |
|
| 333 | 333 | return; |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | - $search = trim( $this->args['s'] ); |
|
| 336 | + $search = trim($this->args['s']); |
|
| 337 | 337 | |
| 338 | - if ( empty( $search ) ) { |
|
| 338 | + if (empty($search)) { |
|
| 339 | 339 | return; |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - $is_email = is_email( $search ) || strpos( $search, '@' ) !== false; |
|
| 343 | - $is_user = strpos( $search, strtolower( 'user:' ) ) !== false; |
|
| 342 | + $is_email = is_email($search) || strpos($search, '@') !== false; |
|
| 343 | + $is_user = strpos($search, strtolower('user:')) !== false; |
|
| 344 | 344 | |
| 345 | - if ( ! empty( $this->args['search_in_notes'] ) ) { |
|
| 345 | + if ( ! empty($this->args['search_in_notes'])) { |
|
| 346 | 346 | |
| 347 | - $notes = give_get_payment_notes( 0, $search ); |
|
| 347 | + $notes = give_get_payment_notes(0, $search); |
|
| 348 | 348 | |
| 349 | - if ( ! empty( $notes ) ) { |
|
| 349 | + if ( ! empty($notes)) { |
|
| 350 | 350 | |
| 351 | - $payment_ids = wp_list_pluck( (array) $notes, 'comment_post_ID' ); |
|
| 351 | + $payment_ids = wp_list_pluck((array) $notes, 'comment_post_ID'); |
|
| 352 | 352 | |
| 353 | - $this->__set( 'post__in', $payment_ids ); |
|
| 353 | + $this->__set('post__in', $payment_ids); |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - $this->__unset( 's' ); |
|
| 356 | + $this->__unset('s'); |
|
| 357 | 357 | |
| 358 | - } elseif ( $is_email || strlen( $search ) == 32 ) { |
|
| 358 | + } elseif ($is_email || strlen($search) == 32) { |
|
| 359 | 359 | |
| 360 | 360 | $key = $is_email ? '_give_payment_user_email' : '_give_payment_purchase_key'; |
| 361 | 361 | $search_meta = array( |
@@ -364,19 +364,19 @@ discard block |
||
| 364 | 364 | 'compare' => 'LIKE' |
| 365 | 365 | ); |
| 366 | 366 | |
| 367 | - $this->__set( 'meta_query', $search_meta ); |
|
| 368 | - $this->__unset( 's' ); |
|
| 367 | + $this->__set('meta_query', $search_meta); |
|
| 368 | + $this->__unset('s'); |
|
| 369 | 369 | |
| 370 | - } elseif ( $is_user ) { |
|
| 370 | + } elseif ($is_user) { |
|
| 371 | 371 | |
| 372 | 372 | $search_meta = array( |
| 373 | 373 | 'key' => '_give_payment_user_id', |
| 374 | - 'value' => trim( str_replace( 'user:', '', strtolower( $search ) ) ) |
|
| 374 | + 'value' => trim(str_replace('user:', '', strtolower($search))) |
|
| 375 | 375 | ); |
| 376 | 376 | |
| 377 | - $this->__set( 'meta_query', $search_meta ); |
|
| 377 | + $this->__set('meta_query', $search_meta); |
|
| 378 | 378 | |
| 379 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
| 379 | + if (give_get_option('enable_sequential')) { |
|
| 380 | 380 | |
| 381 | 381 | $search_meta = array( |
| 382 | 382 | 'key' => '_give_payment_number', |
@@ -384,19 +384,19 @@ discard block |
||
| 384 | 384 | 'compare' => 'LIKE' |
| 385 | 385 | ); |
| 386 | 386 | |
| 387 | - $this->__set( 'meta_query', $search_meta ); |
|
| 387 | + $this->__set('meta_query', $search_meta); |
|
| 388 | 388 | |
| 389 | 389 | $this->args['meta_query']['relation'] = 'OR'; |
| 390 | 390 | |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | - $this->__unset( 's' ); |
|
| 393 | + $this->__unset('s'); |
|
| 394 | 394 | |
| 395 | 395 | } elseif ( |
| 396 | - give_get_option( 'enable_sequential' ) && |
|
| 396 | + give_get_option('enable_sequential') && |
|
| 397 | 397 | ( |
| 398 | - false !== strpos( $search, give_get_option( 'sequential_prefix' ) ) || |
|
| 399 | - false !== strpos( $search, give_get_option( 'sequential_postfix' ) ) |
|
| 398 | + false !== strpos($search, give_get_option('sequential_prefix')) || |
|
| 399 | + false !== strpos($search, give_get_option('sequential_postfix')) |
|
| 400 | 400 | ) |
| 401 | 401 | ) { |
| 402 | 402 | |
@@ -406,30 +406,30 @@ discard block |
||
| 406 | 406 | 'compare' => 'LIKE' |
| 407 | 407 | ); |
| 408 | 408 | |
| 409 | - $this->__set( 'meta_query', $search_meta ); |
|
| 410 | - $this->__unset( 's' ); |
|
| 409 | + $this->__set('meta_query', $search_meta); |
|
| 410 | + $this->__unset('s'); |
|
| 411 | 411 | |
| 412 | - } elseif ( is_numeric( $search ) ) { |
|
| 412 | + } elseif (is_numeric($search)) { |
|
| 413 | 413 | |
| 414 | - $post = get_post( $search ); |
|
| 414 | + $post = get_post($search); |
|
| 415 | 415 | |
| 416 | - if ( is_object( $post ) && $post->post_type == 'give_payment' ) { |
|
| 416 | + if (is_object($post) && $post->post_type == 'give_payment') { |
|
| 417 | 417 | |
| 418 | 418 | $arr = array(); |
| 419 | 419 | $arr[] = $search; |
| 420 | - $this->__set( 'post__in', $arr ); |
|
| 421 | - $this->__unset( 's' ); |
|
| 420 | + $this->__set('post__in', $arr); |
|
| 421 | + $this->__unset('s'); |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | - } elseif ( '#' == substr( $search, 0, 1 ) ) { |
|
| 424 | + } elseif ('#' == substr($search, 0, 1)) { |
|
| 425 | 425 | |
| 426 | - $search = str_replace( '#:', '', $search ); |
|
| 427 | - $search = str_replace( '#', '', $search ); |
|
| 428 | - $this->__set( 'give_forms', $search ); |
|
| 429 | - $this->__unset( 's' ); |
|
| 426 | + $search = str_replace('#:', '', $search); |
|
| 427 | + $search = str_replace('#', '', $search); |
|
| 428 | + $this->__set('give_forms', $search); |
|
| 429 | + $this->__unset('s'); |
|
| 430 | 430 | |
| 431 | 431 | } else { |
| 432 | - $this->__set( 's', $search ); |
|
| 432 | + $this->__set('s', $search); |
|
| 433 | 433 | |
| 434 | 434 | } |
| 435 | 435 | |
@@ -443,16 +443,16 @@ discard block |
||
| 443 | 443 | * @return void |
| 444 | 444 | */ |
| 445 | 445 | public function mode() { |
| 446 | - if ( empty( $this->args['mode'] ) || $this->args['mode'] == 'all' ) { |
|
| 447 | - $this->__unset( 'mode' ); |
|
| 446 | + if (empty($this->args['mode']) || $this->args['mode'] == 'all') { |
|
| 447 | + $this->__unset('mode'); |
|
| 448 | 448 | |
| 449 | 449 | return; |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - $this->__set( 'meta_query', array( |
|
| 452 | + $this->__set('meta_query', array( |
|
| 453 | 453 | 'key' => '_give_payment_mode', |
| 454 | 454 | 'value' => $this->args['mode'] |
| 455 | - ) ); |
|
| 455 | + )); |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | /** |
@@ -463,10 +463,10 @@ discard block |
||
| 463 | 463 | * @return void |
| 464 | 464 | */ |
| 465 | 465 | public function children() { |
| 466 | - if ( empty( $this->args['children'] ) ) { |
|
| 467 | - $this->__set( 'post_parent', 0 ); |
|
| 466 | + if (empty($this->args['children'])) { |
|
| 467 | + $this->__set('post_parent', 0); |
|
| 468 | 468 | } |
| 469 | - $this->__unset( 'children' ); |
|
| 469 | + $this->__unset('children'); |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | /** |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | */ |
| 479 | 479 | public function give_forms() { |
| 480 | 480 | |
| 481 | - if ( empty( $this->args['give_forms'] ) ) { |
|
| 481 | + if (empty($this->args['give_forms'])) { |
|
| 482 | 482 | return; |
| 483 | 483 | } |
| 484 | 484 | |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | $args = array( |
| 488 | 488 | 'post_parent' => $this->args['give_forms'], |
| 489 | 489 | 'log_type' => 'sale', |
| 490 | - 'post_status' => array( 'publish' ), |
|
| 490 | + 'post_status' => array('publish'), |
|
| 491 | 491 | 'nopaging' => true, |
| 492 | 492 | 'no_found_rows' => true, |
| 493 | 493 | 'update_post_term_cache' => false, |
@@ -496,31 +496,31 @@ discard block |
||
| 496 | 496 | 'fields' => 'ids' |
| 497 | 497 | ); |
| 498 | 498 | |
| 499 | - if ( is_array( $this->args['give_forms'] ) ) { |
|
| 500 | - unset( $args['post_parent'] ); |
|
| 499 | + if (is_array($this->args['give_forms'])) { |
|
| 500 | + unset($args['post_parent']); |
|
| 501 | 501 | $args['post_parent__in'] = $this->args['give_forms']; |
| 502 | 502 | } |
| 503 | 503 | |
| 504 | - $sales = $give_logs->get_connected_logs( $args ); |
|
| 504 | + $sales = $give_logs->get_connected_logs($args); |
|
| 505 | 505 | |
| 506 | - if ( ! empty( $sales ) ) { |
|
| 506 | + if ( ! empty($sales)) { |
|
| 507 | 507 | |
| 508 | 508 | $payments = array(); |
| 509 | 509 | |
| 510 | - foreach ( $sales as $sale ) { |
|
| 511 | - $payments[] = get_post_meta( $sale, '_give_log_payment_id', true ); |
|
| 510 | + foreach ($sales as $sale) { |
|
| 511 | + $payments[] = get_post_meta($sale, '_give_log_payment_id', true); |
|
| 512 | 512 | } |
| 513 | 513 | |
| 514 | - $this->__set( 'post__in', $payments ); |
|
| 514 | + $this->__set('post__in', $payments); |
|
| 515 | 515 | |
| 516 | 516 | } else { |
| 517 | 517 | |
| 518 | 518 | // Set post_parent to something crazy so it doesn't find anything |
| 519 | - $this->__set( 'post_parent', 999999999999999 ); |
|
| 519 | + $this->__set('post_parent', 999999999999999); |
|
| 520 | 520 | |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | - $this->__unset( 'give_forms' ); |
|
| 523 | + $this->__unset('give_forms'); |
|
| 524 | 524 | |
| 525 | 525 | } |
| 526 | 526 | } |
@@ -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 | |
@@ -39,35 +39,35 @@ discard block |
||
| 39 | 39 | * |
| 40 | 40 | * @return float|int Total amount of donations based on the passed arguments. |
| 41 | 41 | */ |
| 42 | - public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) { |
|
| 42 | + public function get_sales($form_id = 0, $start_date = false, $end_date = false, $status = 'publish') { |
|
| 43 | 43 | |
| 44 | - $this->setup_dates( $start_date, $end_date ); |
|
| 44 | + $this->setup_dates($start_date, $end_date); |
|
| 45 | 45 | |
| 46 | 46 | // Make sure start date is valid |
| 47 | - if ( is_wp_error( $this->start_date ) ) { |
|
| 47 | + if (is_wp_error($this->start_date)) { |
|
| 48 | 48 | return $this->start_date; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | // Make sure end date is valid |
| 52 | - if ( is_wp_error( $this->end_date ) ) { |
|
| 52 | + if (is_wp_error($this->end_date)) { |
|
| 53 | 53 | return $this->end_date; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - if ( empty( $form_id ) ) { |
|
| 56 | + if (empty($form_id)) { |
|
| 57 | 57 | |
| 58 | 58 | // Global sale stats |
| 59 | - add_filter( 'give_count_payments_where', array( $this, 'count_where' ) ); |
|
| 59 | + add_filter('give_count_payments_where', array($this, 'count_where')); |
|
| 60 | 60 | |
| 61 | - if ( is_array( $status ) ) { |
|
| 61 | + if (is_array($status)) { |
|
| 62 | 62 | $count = 0; |
| 63 | - foreach ( $status as $payment_status ) { |
|
| 63 | + foreach ($status as $payment_status) { |
|
| 64 | 64 | $count += give_count_payments()->$payment_status; |
| 65 | 65 | } |
| 66 | 66 | } else { |
| 67 | 67 | $count = give_count_payments()->$status; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - remove_filter( 'give_count_payments_where', array( $this, 'count_where' ) ); |
|
| 70 | + remove_filter('give_count_payments_where', array($this, 'count_where')); |
|
| 71 | 71 | |
| 72 | 72 | } else { |
| 73 | 73 | |
@@ -76,11 +76,11 @@ discard block |
||
| 76 | 76 | // Product specific stats |
| 77 | 77 | global $give_logs; |
| 78 | 78 | |
| 79 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
| 79 | + add_filter('posts_where', array($this, 'payments_where')); |
|
| 80 | 80 | |
| 81 | - $count = $give_logs->get_log_count( $form_id, 'sale' ); |
|
| 81 | + $count = $give_logs->get_log_count($form_id, 'sale'); |
|
| 82 | 82 | |
| 83 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
| 83 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
| 84 | 84 | |
| 85 | 85 | } |
| 86 | 86 | |
@@ -102,31 +102,31 @@ discard block |
||
| 102 | 102 | * |
| 103 | 103 | * @return float|int Total amount of donations based on the passed arguments. |
| 104 | 104 | */ |
| 105 | - public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
|
| 105 | + public function get_earnings($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) { |
|
| 106 | 106 | |
| 107 | 107 | global $wpdb; |
| 108 | 108 | |
| 109 | - $this->setup_dates( $start_date, $end_date ); |
|
| 109 | + $this->setup_dates($start_date, $end_date); |
|
| 110 | 110 | |
| 111 | 111 | // Make sure start date is valid |
| 112 | - if ( is_wp_error( $this->start_date ) ) { |
|
| 112 | + if (is_wp_error($this->start_date)) { |
|
| 113 | 113 | return $this->start_date; |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | // Make sure end date is valid |
| 117 | - if ( is_wp_error( $this->end_date ) ) { |
|
| 117 | + if (is_wp_error($this->end_date)) { |
|
| 118 | 118 | return $this->end_date; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
| 121 | + add_filter('posts_where', array($this, 'payments_where')); |
|
| 122 | 122 | |
| 123 | - if ( empty( $form_id ) ) { |
|
| 123 | + if (empty($form_id)) { |
|
| 124 | 124 | |
| 125 | 125 | // Global earning stats |
| 126 | 126 | $args = array( |
| 127 | 127 | 'post_type' => 'give_payment', |
| 128 | 128 | 'nopaging' => true, |
| 129 | - 'post_status' => array( 'publish' ), |
|
| 129 | + 'post_status' => array('publish'), |
|
| 130 | 130 | 'fields' => 'ids', |
| 131 | 131 | 'update_post_term_cache' => false, |
| 132 | 132 | 'suppress_filters' => false, |
@@ -138,24 +138,24 @@ discard block |
||
| 138 | 138 | ); |
| 139 | 139 | |
| 140 | 140 | //Filter by Gateway ID meta_key |
| 141 | - if ( $gateway_id !== false ) { |
|
| 141 | + if ($gateway_id !== false) { |
|
| 142 | 142 | $args['meta_key'] = '_give_payment_gateway'; |
| 143 | 143 | $args['meta_value'] = $gateway_id; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
| 147 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
| 148 | - $earnings = get_transient( $key ); |
|
| 146 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
| 147 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
| 148 | + $earnings = get_transient($key); |
|
| 149 | 149 | |
| 150 | - if ( false === $earnings ) { |
|
| 151 | - $sales = get_posts( $args ); |
|
| 150 | + if (false === $earnings) { |
|
| 151 | + $sales = get_posts($args); |
|
| 152 | 152 | $earnings = 0; |
| 153 | - if ( $sales ) { |
|
| 154 | - $sales = implode( ',', array_map('intval', $sales ) ); |
|
| 155 | - $earnings += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})" ); |
|
| 153 | + if ($sales) { |
|
| 154 | + $sales = implode(',', array_map('intval', $sales)); |
|
| 155 | + $earnings += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})"); |
|
| 156 | 156 | } |
| 157 | 157 | // Cache the results for one hour |
| 158 | - set_transient( $key, $earnings, HOUR_IN_SECONDS ); |
|
| 158 | + set_transient($key, $earnings, HOUR_IN_SECONDS); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | } else { |
@@ -175,37 +175,37 @@ discard block |
||
| 175 | 175 | 'give_transient_type' => 'give_earnings', |
| 176 | 176 | // This is not a valid query arg, but is used for cache keying |
| 177 | 177 | ); |
| 178 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
| 179 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
| 178 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
| 179 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
| 180 | 180 | //Set transient for faster stats |
| 181 | - $earnings = get_transient( $key ); |
|
| 181 | + $earnings = get_transient($key); |
|
| 182 | 182 | |
| 183 | - if ( false === $earnings ) { |
|
| 183 | + if (false === $earnings) { |
|
| 184 | 184 | |
| 185 | 185 | $this->timestamp = false; |
| 186 | - $log_ids = $give_logs->get_connected_logs( $args, 'sale' ); |
|
| 186 | + $log_ids = $give_logs->get_connected_logs($args, 'sale'); |
|
| 187 | 187 | $earnings = 0; |
| 188 | 188 | |
| 189 | - if ( $log_ids ) { |
|
| 190 | - $log_ids = implode( ',', array_map('intval', $log_ids ) ); |
|
| 191 | - $payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids);" ); |
|
| 189 | + if ($log_ids) { |
|
| 190 | + $log_ids = implode(',', array_map('intval', $log_ids)); |
|
| 191 | + $payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids);"); |
|
| 192 | 192 | |
| 193 | - foreach ( $payment_ids as $payment_id ) { |
|
| 194 | - $earnings += give_get_payment_amount( $payment_id ); |
|
| 193 | + foreach ($payment_ids as $payment_id) { |
|
| 194 | + $earnings += give_get_payment_amount($payment_id); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | // Cache the results for one hour |
| 200 | - set_transient( $key, $earnings, 60 * 60 ); |
|
| 200 | + set_transient($key, $earnings, 60 * 60); |
|
| 201 | 201 | } |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | //remove our filter |
| 205 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
| 205 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
| 206 | 206 | |
| 207 | 207 | //return earnings |
| 208 | - return round( $earnings, give_currency_decimal_filter() ); |
|
| 208 | + return round($earnings, give_currency_decimal_filter()); |
|
| 209 | 209 | |
| 210 | 210 | } |
| 211 | 211 | |
@@ -219,16 +219,16 @@ discard block |
||
| 219 | 219 | * |
| 220 | 220 | * @return array |
| 221 | 221 | */ |
| 222 | - public function get_best_selling( $number = 10 ) { |
|
| 222 | + public function get_best_selling($number = 10) { |
|
| 223 | 223 | |
| 224 | 224 | global $wpdb; |
| 225 | 225 | |
| 226 | - $give_forms = $wpdb->get_results( $wpdb->prepare( |
|
| 226 | + $give_forms = $wpdb->get_results($wpdb->prepare( |
|
| 227 | 227 | "SELECT post_id as form_id, max(meta_value) as sales |
| 228 | 228 | FROM $wpdb->postmeta WHERE meta_key='_give_form_sales' AND meta_value > 0 |
| 229 | 229 | GROUP BY meta_value+0 |
| 230 | 230 | DESC LIMIT %d;", $number |
| 231 | - ) ); |
|
| 231 | + )); |
|
| 232 | 232 | |
| 233 | 233 | return $give_forms; |
| 234 | 234 | } |
@@ -10,7 +10,9 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 13 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | + exit; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | /** |
| 16 | 18 | * Give_API_V1 Class |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly |
| 15 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 15 | +if ( ! defined('ABSPATH')) exit; |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * Give_Batch_Export Class |
@@ -104,14 +104,14 @@ discard block |
||
| 104 | 104 | * @param $_step int The step to process |
| 105 | 105 | * @since 1.5 |
| 106 | 106 | */ |
| 107 | - public function __construct( $_step = 1 ) { |
|
| 107 | + public function __construct($_step = 1) { |
|
| 108 | 108 | |
| 109 | 109 | $upload_dir = wp_upload_dir(); |
| 110 | 110 | $this->filetype = '.csv'; |
| 111 | - $this->filename = 'give-' . $this->export_type . $this->filetype; |
|
| 112 | - $this->file = trailingslashit( $upload_dir['basedir'] ) . $this->filename; |
|
| 111 | + $this->filename = 'give-'.$this->export_type.$this->filetype; |
|
| 112 | + $this->file = trailingslashit($upload_dir['basedir']).$this->filename; |
|
| 113 | 113 | |
| 114 | - if ( ! is_writeable( $upload_dir['basedir'] ) ) { |
|
| 114 | + if ( ! is_writeable($upload_dir['basedir'])) { |
|
| 115 | 115 | $this->is_writable = false; |
| 116 | 116 | } |
| 117 | 117 | |
@@ -127,20 +127,20 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function process_step() { |
| 129 | 129 | |
| 130 | - if ( ! $this->can_export() ) { |
|
| 131 | - wp_die( esc_html__( 'You do not have permission to export data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 130 | + if ( ! $this->can_export()) { |
|
| 131 | + wp_die(esc_html__('You do not have permission to export data.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - if( $this->step < 2 ) { |
|
| 134 | + if ($this->step < 2) { |
|
| 135 | 135 | |
| 136 | 136 | // Make sure we start with a fresh file on step 1 |
| 137 | - @unlink( $this->file ); |
|
| 137 | + @unlink($this->file); |
|
| 138 | 138 | $this->print_csv_cols(); |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | $rows = $this->print_csv_rows(); |
| 142 | 142 | |
| 143 | - if( $rows ) { |
|
| 143 | + if ($rows) { |
|
| 144 | 144 | return true; |
| 145 | 145 | } else { |
| 146 | 146 | return false; |
@@ -160,14 +160,14 @@ discard block |
||
| 160 | 160 | $col_data = ''; |
| 161 | 161 | $cols = $this->get_csv_cols(); |
| 162 | 162 | $i = 1; |
| 163 | - foreach( $cols as $col_id => $column ) { |
|
| 164 | - $col_data .= '"' . addslashes( $column ) . '"'; |
|
| 165 | - $col_data .= $i == count( $cols ) ? '' : ','; |
|
| 163 | + foreach ($cols as $col_id => $column) { |
|
| 164 | + $col_data .= '"'.addslashes($column).'"'; |
|
| 165 | + $col_data .= $i == count($cols) ? '' : ','; |
|
| 166 | 166 | $i++; |
| 167 | 167 | } |
| 168 | 168 | $col_data .= "\r\n"; |
| 169 | 169 | |
| 170 | - $this->stash_step_data( $col_data ); |
|
| 170 | + $this->stash_step_data($col_data); |
|
| 171 | 171 | |
| 172 | 172 | return $col_data; |
| 173 | 173 | |
@@ -186,23 +186,23 @@ discard block |
||
| 186 | 186 | $data = $this->get_data(); |
| 187 | 187 | $cols = $this->get_csv_cols(); |
| 188 | 188 | |
| 189 | - if( $data ) { |
|
| 189 | + if ($data) { |
|
| 190 | 190 | |
| 191 | 191 | // Output each row |
| 192 | - foreach ( $data as $row ) { |
|
| 192 | + foreach ($data as $row) { |
|
| 193 | 193 | $i = 1; |
| 194 | - foreach ( $row as $col_id => $column ) { |
|
| 194 | + foreach ($row as $col_id => $column) { |
|
| 195 | 195 | // Make sure the column is valid |
| 196 | - if ( array_key_exists( $col_id, $cols ) ) { |
|
| 197 | - $row_data .= '"' . addslashes( preg_replace( "/\"/","'", $column ) ) . '"'; |
|
| 198 | - $row_data .= $i == count( $cols ) ? '' : ','; |
|
| 196 | + if (array_key_exists($col_id, $cols)) { |
|
| 197 | + $row_data .= '"'.addslashes(preg_replace("/\"/", "'", $column)).'"'; |
|
| 198 | + $row_data .= $i == count($cols) ? '' : ','; |
|
| 199 | 199 | $i++; |
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | $row_data .= "\r\n"; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - $this->stash_step_data( $row_data ); |
|
| 205 | + $this->stash_step_data($row_data); |
|
| 206 | 206 | |
| 207 | 207 | return $row_data; |
| 208 | 208 | } |
@@ -230,18 +230,18 @@ discard block |
||
| 230 | 230 | |
| 231 | 231 | $file = ''; |
| 232 | 232 | |
| 233 | - if ( @file_exists( $this->file ) ) { |
|
| 233 | + if (@file_exists($this->file)) { |
|
| 234 | 234 | |
| 235 | - if ( ! is_writeable( $this->file ) ) { |
|
| 235 | + if ( ! is_writeable($this->file)) { |
|
| 236 | 236 | $this->is_writable = false; |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - $file = @file_get_contents( $this->file ); |
|
| 239 | + $file = @file_get_contents($this->file); |
|
| 240 | 240 | |
| 241 | 241 | } else { |
| 242 | 242 | |
| 243 | - @file_put_contents( $this->file, '' ); |
|
| 244 | - @chmod( $this->file, 0664 ); |
|
| 243 | + @file_put_contents($this->file, ''); |
|
| 244 | + @chmod($this->file, 0664); |
|
| 245 | 245 | |
| 246 | 246 | } |
| 247 | 247 | |
@@ -255,18 +255,18 @@ discard block |
||
| 255 | 255 | * @param $data string The data to add to the file |
| 256 | 256 | * @return void |
| 257 | 257 | */ |
| 258 | - protected function stash_step_data( $data = '' ) { |
|
| 258 | + protected function stash_step_data($data = '') { |
|
| 259 | 259 | |
| 260 | 260 | $file = $this->get_file(); |
| 261 | 261 | $file .= $data; |
| 262 | - @file_put_contents( $this->file, $file ); |
|
| 262 | + @file_put_contents($this->file, $file); |
|
| 263 | 263 | |
| 264 | 264 | // If we have no rows after this step, mark it as an empty export |
| 265 | - $file_rows = file( $this->file, FILE_SKIP_EMPTY_LINES); |
|
| 265 | + $file_rows = file($this->file, FILE_SKIP_EMPTY_LINES); |
|
| 266 | 266 | $default_cols = $this->get_csv_cols(); |
| 267 | - $default_cols = empty( $default_cols ) ? 0 : 1; |
|
| 267 | + $default_cols = empty($default_cols) ? 0 : 1; |
|
| 268 | 268 | |
| 269 | - $this->is_empty = count( $file_rows ) == $default_cols ? true : false; |
|
| 269 | + $this->is_empty = count($file_rows) == $default_cols ? true : false; |
|
| 270 | 270 | |
| 271 | 271 | } |
| 272 | 272 | |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | |
| 285 | 285 | $file = $this->get_file(); |
| 286 | 286 | |
| 287 | - @unlink( $this->file ); |
|
| 287 | + @unlink($this->file); |
|
| 288 | 288 | |
| 289 | 289 | echo $file; |
| 290 | 290 | |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | * @since 1.5 |
| 298 | 298 | * @param array $request The Form Data passed into the batch processing |
| 299 | 299 | */ |
| 300 | - public function set_properties( $request ) {} |
|
| 300 | + public function set_properties($request) {} |
|
| 301 | 301 | |
| 302 | 302 | /** |
| 303 | 303 | * Allow for prefetching of data for the remainder of the exporter |
@@ -188,8 +188,8 @@ |
||
| 188 | 188 | |
| 189 | 189 | $payment_ids = implode( ',', $payment_ids ); |
| 190 | 190 | $customer->update( array( 'payment_ids' => $payment_ids, |
| 191 | - 'purchase_count' => $purchase_count, |
|
| 192 | - 'purchase_value' => $pending_total |
|
| 191 | + 'purchase_count' => $purchase_count, |
|
| 192 | + 'purchase_value' => $pending_total |
|
| 193 | 193 | ) ); |
| 194 | 194 | |
| 195 | 195 | $this->done = true; |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | * @since 1.5 |
| 51 | 51 | * @global object $wpdb Used to query the database using the WordPress |
| 52 | 52 | * Database API |
| 53 | - * @return array $data The data for the CSV file |
|
| 53 | + * @return boolean $data The data for the CSV file |
|
| 54 | 54 | */ |
| 55 | 55 | public function get_data() { |
| 56 | 56 | global $wpdb; |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -54,39 +54,39 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function get_data() { |
| 56 | 56 | |
| 57 | - $customer = new Give_Customer( $this->customer_id ); |
|
| 58 | - $payments = $this->get_stored_data( 'give_recount_customer_payments_' . $customer->id, array() ); |
|
| 57 | + $customer = new Give_Customer($this->customer_id); |
|
| 58 | + $payments = $this->get_stored_data('give_recount_customer_payments_'.$customer->id, array()); |
|
| 59 | 59 | |
| 60 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
| 61 | - $step_items = array_slice( $payments, $offset, $this->per_step ); |
|
| 60 | + $offset = ($this->step - 1) * $this->per_step; |
|
| 61 | + $step_items = array_slice($payments, $offset, $this->per_step); |
|
| 62 | 62 | |
| 63 | - if ( count( $step_items ) > 0 ) { |
|
| 64 | - $pending_total = (float) $this->get_stored_data( 'give_stats_customer_pending_total' . $customer->id, 0 ); |
|
| 63 | + if (count($step_items) > 0) { |
|
| 64 | + $pending_total = (float) $this->get_stored_data('give_stats_customer_pending_total'.$customer->id, 0); |
|
| 65 | 65 | $step_total = 0; |
| 66 | 66 | |
| 67 | - $found_payment_ids = $this->get_stored_data( 'give_stats_found_payments_' . $customer->id, array() ); |
|
| 67 | + $found_payment_ids = $this->get_stored_data('give_stats_found_payments_'.$customer->id, array()); |
|
| 68 | 68 | |
| 69 | - foreach ( $step_items as $payment ) { |
|
| 70 | - $payment = get_post( $payment->ID ); |
|
| 69 | + foreach ($step_items as $payment) { |
|
| 70 | + $payment = get_post($payment->ID); |
|
| 71 | 71 | |
| 72 | - if ( is_null( $payment ) || is_wp_error( $payment ) || 'give_payment' !== $payment->post_type ) { |
|
| 72 | + if (is_null($payment) || is_wp_error($payment) || 'give_payment' !== $payment->post_type) { |
|
| 73 | 73 | |
| 74 | - $missing_payments = $this->get_stored_data( 'give_stats_missing_payments' . $customer->id, array() ); |
|
| 74 | + $missing_payments = $this->get_stored_data('give_stats_missing_payments'.$customer->id, array()); |
|
| 75 | 75 | $missing_payments[] = $payment->ID; |
| 76 | - $this->store_data( 'give_stats_missing_payments' . $customer->id, $missing_payments ); |
|
| 76 | + $this->store_data('give_stats_missing_payments'.$customer->id, $missing_payments); |
|
| 77 | 77 | |
| 78 | 78 | continue; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | $should_process_payment = 'publish' == $payment->post_status || 'revoked' == $payment->post_status ? true : false; |
| 82 | - $should_process_payment = apply_filters( 'give_customer_recount_should_process_payment', $should_process_payment, $payment ); |
|
| 82 | + $should_process_payment = apply_filters('give_customer_recount_should_process_payment', $should_process_payment, $payment); |
|
| 83 | 83 | |
| 84 | - if ( true === $should_process_payment ) { |
|
| 84 | + if (true === $should_process_payment) { |
|
| 85 | 85 | |
| 86 | 86 | $found_payment_ids[] = $payment->ID; |
| 87 | 87 | |
| 88 | - if ( apply_filters( 'give_customer_recount_sholud_increase_value', true, $payment ) ) { |
|
| 89 | - $payment_amount = give_get_payment_amount( $payment->ID ); |
|
| 88 | + if (apply_filters('give_customer_recount_sholud_increase_value', true, $payment)) { |
|
| 89 | + $payment_amount = give_get_payment_amount($payment->ID); |
|
| 90 | 90 | $step_total += $payment_amount; |
| 91 | 91 | } |
| 92 | 92 | |
@@ -95,8 +95,8 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | $updated_total = $pending_total + $step_total; |
| 98 | - $this->store_data( 'give_stats_customer_pending_total' . $customer->id, $updated_total ); |
|
| 99 | - $this->store_data( 'give_stats_found_payments_' . $customer->id, $found_payment_ids ); |
|
| 98 | + $this->store_data('give_stats_customer_pending_total'.$customer->id, $updated_total); |
|
| 99 | + $this->store_data('give_stats_found_payments_'.$customer->id, $found_payment_ids); |
|
| 100 | 100 | |
| 101 | 101 | return true; |
| 102 | 102 | } |
@@ -113,16 +113,16 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function get_percentage_complete() { |
| 115 | 115 | |
| 116 | - $payments = $this->get_stored_data( 'give_recount_customer_payments_' . $this->customer_id ); |
|
| 117 | - $total = count( $payments ); |
|
| 116 | + $payments = $this->get_stored_data('give_recount_customer_payments_'.$this->customer_id); |
|
| 117 | + $total = count($payments); |
|
| 118 | 118 | |
| 119 | 119 | $percentage = 100; |
| 120 | 120 | |
| 121 | - if ( $total > 0 ) { |
|
| 122 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 121 | + if ($total > 0) { |
|
| 122 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - if ( $percentage > 100 ) { |
|
| 125 | + if ($percentage > 100) { |
|
| 126 | 126 | $percentage = 100; |
| 127 | 127 | } |
| 128 | 128 | |
@@ -136,8 +136,8 @@ discard block |
||
| 136 | 136 | * |
| 137 | 137 | * @param array $request The Form Data passed into the batch processing |
| 138 | 138 | */ |
| 139 | - public function set_properties( $request ) { |
|
| 140 | - $this->customer_id = isset( $request['customer_id'] ) ? sanitize_text_field( $request['customer_id'] ) : false; |
|
| 139 | + public function set_properties($request) { |
|
| 140 | + $this->customer_id = isset($request['customer_id']) ? sanitize_text_field($request['customer_id']) : false; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -148,62 +148,62 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | public function process_step() { |
| 150 | 150 | |
| 151 | - if ( ! $this->can_export() ) { |
|
| 152 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 151 | + if ( ! $this->can_export()) { |
|
| 152 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | $had_data = $this->get_data(); |
| 156 | 156 | |
| 157 | - if ( $had_data ) { |
|
| 157 | + if ($had_data) { |
|
| 158 | 158 | $this->done = false; |
| 159 | 159 | |
| 160 | 160 | return true; |
| 161 | 161 | } else { |
| 162 | - $customer = new Give_Customer( $this->customer_id ); |
|
| 163 | - $payment_ids = get_option( 'give_stats_found_payments_' . $customer->id, array() ); |
|
| 164 | - $this->delete_data( 'give_stats_found_payments_' . $customer->id ); |
|
| 162 | + $customer = new Give_Customer($this->customer_id); |
|
| 163 | + $payment_ids = get_option('give_stats_found_payments_'.$customer->id, array()); |
|
| 164 | + $this->delete_data('give_stats_found_payments_'.$customer->id); |
|
| 165 | 165 | |
| 166 | - $removed_payments = array_unique( get_option( 'give_stats_missing_payments' . $customer->id, array() ) ); |
|
| 166 | + $removed_payments = array_unique(get_option('give_stats_missing_payments'.$customer->id, array())); |
|
| 167 | 167 | |
| 168 | 168 | // Find non-existing payments (deleted) and total up the purchase count |
| 169 | 169 | $purchase_count = 0; |
| 170 | - foreach ( $payment_ids as $key => $payment_id ) { |
|
| 171 | - if ( in_array( $payment_id, $removed_payments ) ) { |
|
| 172 | - unset( $payment_ids[ $key ] ); |
|
| 170 | + foreach ($payment_ids as $key => $payment_id) { |
|
| 171 | + if (in_array($payment_id, $removed_payments)) { |
|
| 172 | + unset($payment_ids[$key]); |
|
| 173 | 173 | continue; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - $payment = get_post( $payment_id ); |
|
| 177 | - if ( apply_filters( 'give_customer_recount_should_increase_count', true, $payment ) ) { |
|
| 178 | - $purchase_count ++; |
|
| 176 | + $payment = get_post($payment_id); |
|
| 177 | + if (apply_filters('give_customer_recount_should_increase_count', true, $payment)) { |
|
| 178 | + $purchase_count++; |
|
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - $this->delete_data( 'give_stats_missing_payments' . $customer->id ); |
|
| 182 | + $this->delete_data('give_stats_missing_payments'.$customer->id); |
|
| 183 | 183 | |
| 184 | - $pending_total = $this->get_stored_data( 'give_stats_customer_pending_total' . $customer->id, 0 ); |
|
| 185 | - $this->delete_data( 'give_stats_customer_pending_total' . $customer->id ); |
|
| 186 | - $this->delete_data( 'give_recount_customer_stats_' . $customer->id ); |
|
| 187 | - $this->delete_data( 'give_recount_customer_payments_' . $this->customer_id ); |
|
| 184 | + $pending_total = $this->get_stored_data('give_stats_customer_pending_total'.$customer->id, 0); |
|
| 185 | + $this->delete_data('give_stats_customer_pending_total'.$customer->id); |
|
| 186 | + $this->delete_data('give_recount_customer_stats_'.$customer->id); |
|
| 187 | + $this->delete_data('give_recount_customer_payments_'.$this->customer_id); |
|
| 188 | 188 | |
| 189 | - $payment_ids = implode( ',', $payment_ids ); |
|
| 190 | - $customer->update( array( 'payment_ids' => $payment_ids, |
|
| 189 | + $payment_ids = implode(',', $payment_ids); |
|
| 190 | + $customer->update(array('payment_ids' => $payment_ids, |
|
| 191 | 191 | 'purchase_count' => $purchase_count, |
| 192 | 192 | 'purchase_value' => $pending_total |
| 193 | - ) ); |
|
| 193 | + )); |
|
| 194 | 194 | |
| 195 | 195 | $this->done = true; |
| 196 | - $this->message = esc_html__( 'Donor stats successfully recounted.', 'give' ); |
|
| 196 | + $this->message = esc_html__('Donor stats successfully recounted.', 'give'); |
|
| 197 | 197 | |
| 198 | 198 | return false; |
| 199 | 199 | } |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | public function headers() { |
| 203 | - ignore_user_abort( true ); |
|
| 203 | + ignore_user_abort(true); |
|
| 204 | 204 | |
| 205 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 206 | - set_time_limit( 0 ); |
|
| 205 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 206 | + set_time_limit(0); |
|
| 207 | 207 | } |
| 208 | 208 | } |
| 209 | 209 | |
@@ -230,26 +230,26 @@ discard block |
||
| 230 | 230 | * @return void |
| 231 | 231 | */ |
| 232 | 232 | public function pre_fetch() { |
| 233 | - if ( $this->step === 1 ) { |
|
| 234 | - $allowed_payment_status = apply_filters( 'give_recount_customer_payment_statuses', give_get_payment_status_keys() ); |
|
| 233 | + if ($this->step === 1) { |
|
| 234 | + $allowed_payment_status = apply_filters('give_recount_customer_payment_statuses', give_get_payment_status_keys()); |
|
| 235 | 235 | |
| 236 | 236 | // Before we start, let's zero out the customer's data |
| 237 | - $customer = new Give_Customer( $this->customer_id ); |
|
| 238 | - $customer->update( array( 'purchase_value' => give_format_amount( 0 ), 'purchase_count' => 0 ) ); |
|
| 237 | + $customer = new Give_Customer($this->customer_id); |
|
| 238 | + $customer->update(array('purchase_value' => give_format_amount(0), 'purchase_count' => 0)); |
|
| 239 | 239 | |
| 240 | - $attached_payment_ids = explode( ',', $customer->payment_ids ); |
|
| 240 | + $attached_payment_ids = explode(',', $customer->payment_ids); |
|
| 241 | 241 | |
| 242 | 242 | $attached_args = array( |
| 243 | 243 | 'post__in' => $attached_payment_ids, |
| 244 | - 'number' => - 1, |
|
| 244 | + 'number' => -1, |
|
| 245 | 245 | 'status' => $allowed_post_status, |
| 246 | 246 | ); |
| 247 | 247 | |
| 248 | - $attached_payments = give_get_payments( $attached_args ); |
|
| 248 | + $attached_payments = give_get_payments($attached_args); |
|
| 249 | 249 | |
| 250 | 250 | $unattached_args = array( |
| 251 | 251 | 'post__not_in' => $attached_payment_ids, |
| 252 | - 'number' => - 1, |
|
| 252 | + 'number' => -1, |
|
| 253 | 253 | 'status' => $allowed_post_status, |
| 254 | 254 | 'meta_query' => array( |
| 255 | 255 | array( |
@@ -259,11 +259,11 @@ discard block |
||
| 259 | 259 | ), |
| 260 | 260 | ); |
| 261 | 261 | |
| 262 | - $unattached_payments = give_get_payments( $unattached_args ); |
|
| 262 | + $unattached_payments = give_get_payments($unattached_args); |
|
| 263 | 263 | |
| 264 | - $payments = array_merge( $attached_payments, $unattached_payments ); |
|
| 264 | + $payments = array_merge($attached_payments, $unattached_payments); |
|
| 265 | 265 | |
| 266 | - $this->store_data( 'give_recount_customer_payments_' . $customer->id, $payments ); |
|
| 266 | + $this->store_data('give_recount_customer_payments_'.$customer->id, $payments); |
|
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | |
@@ -276,11 +276,11 @@ discard block |
||
| 276 | 276 | * |
| 277 | 277 | * @return mixed Returns the data from the database |
| 278 | 278 | */ |
| 279 | - private function get_stored_data( $key ) { |
|
| 279 | + private function get_stored_data($key) { |
|
| 280 | 280 | global $wpdb; |
| 281 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 281 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 282 | 282 | |
| 283 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
| 283 | + return empty($value) ? false : maybe_unserialize($value); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | /** |
@@ -293,10 +293,10 @@ discard block |
||
| 293 | 293 | * |
| 294 | 294 | * @return void |
| 295 | 295 | */ |
| 296 | - private function store_data( $key, $value ) { |
|
| 296 | + private function store_data($key, $value) { |
|
| 297 | 297 | global $wpdb; |
| 298 | 298 | |
| 299 | - $value = maybe_serialize( $value ); |
|
| 299 | + $value = maybe_serialize($value); |
|
| 300 | 300 | |
| 301 | 301 | $data = array( |
| 302 | 302 | 'option_name' => $key, |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | '%s', |
| 311 | 311 | ); |
| 312 | 312 | |
| 313 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 313 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | /** |
@@ -322,9 +322,9 @@ discard block |
||
| 322 | 322 | * |
| 323 | 323 | * @return void |
| 324 | 324 | */ |
| 325 | - private function delete_data( $key ) { |
|
| 325 | + private function delete_data($key) { |
|
| 326 | 326 | global $wpdb; |
| 327 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 327 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -19,10 +19,10 @@ discard block |
||
| 19 | 19 | * @since 1.5 |
| 20 | 20 | */ |
| 21 | 21 | function give_register_batch_recount_store_earnings_tool() { |
| 22 | - add_action( 'give_batch_export_class_include', 'give_include_recount_income_tool_batch_processor', 10, 1 ); |
|
| 22 | + add_action('give_batch_export_class_include', 'give_include_recount_income_tool_batch_processor', 10, 1); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -add_action( 'give_register_batch_exporter', 'give_register_batch_recount_store_earnings_tool', 10 ); |
|
| 25 | +add_action('give_register_batch_exporter', 'give_register_batch_recount_store_earnings_tool', 10); |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * Loads the tools batch processing class for recounting store earnings |
@@ -33,11 +33,11 @@ discard block |
||
| 33 | 33 | * |
| 34 | 34 | * @return void |
| 35 | 35 | */ |
| 36 | -function give_include_recount_income_tool_batch_processor( $class ) { |
|
| 36 | +function give_include_recount_income_tool_batch_processor($class) { |
|
| 37 | 37 | |
| 38 | - $file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-recount-income.php'; |
|
| 38 | + $file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-recount-income.php'; |
|
| 39 | 39 | |
| 40 | - if ( 'Give_Tools_Recount_Income' === $class && file_exists( $file_path ) ) { |
|
| 40 | + if ('Give_Tools_Recount_Income' === $class && file_exists($file_path)) { |
|
| 41 | 41 | require_once $file_path; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -49,10 +49,10 @@ discard block |
||
| 49 | 49 | * @since 1.5 |
| 50 | 50 | */ |
| 51 | 51 | function give_register_batch_recount_form_tool() { |
| 52 | - add_action( 'give_batch_export_class_include', 'give_include_recount_form_tool_batch_processor', 10, 1 ); |
|
| 52 | + add_action('give_batch_export_class_include', 'give_include_recount_form_tool_batch_processor', 10, 1); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | -add_action( 'give_register_batch_exporter', 'give_register_batch_recount_form_tool', 10 ); |
|
| 55 | +add_action('give_register_batch_exporter', 'give_register_batch_recount_form_tool', 10); |
|
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * Loads the tools batch processing class for recounting download stats |
@@ -63,11 +63,11 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @return void |
| 65 | 65 | */ |
| 66 | -function give_include_recount_form_tool_batch_processor( $class ) { |
|
| 66 | +function give_include_recount_form_tool_batch_processor($class) { |
|
| 67 | 67 | |
| 68 | - $file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-recount-form-stats.php'; |
|
| 68 | + $file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-recount-form-stats.php'; |
|
| 69 | 69 | |
| 70 | - if ( 'Give_Tools_Recount_Form_Stats' === $class && file_exists( $file_path ) ) { |
|
| 70 | + if ('Give_Tools_Recount_Form_Stats' === $class && file_exists($file_path)) { |
|
| 71 | 71 | require_once $file_path; |
| 72 | 72 | } |
| 73 | 73 | |
@@ -78,10 +78,10 @@ discard block |
||
| 78 | 78 | * @since 1.5 |
| 79 | 79 | */ |
| 80 | 80 | function give_register_batch_recount_all_tool() { |
| 81 | - add_action( 'give_batch_export_class_include', 'give_include_recount_all_tool_batch_processor', 10, 1 ); |
|
| 81 | + add_action('give_batch_export_class_include', 'give_include_recount_all_tool_batch_processor', 10, 1); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | -add_action( 'give_register_batch_exporter', 'give_register_batch_recount_all_tool', 10 ); |
|
| 84 | +add_action('give_register_batch_exporter', 'give_register_batch_recount_all_tool', 10); |
|
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | 87 | * Loads the tools batch processing class for recounting all stats |
@@ -92,9 +92,9 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @return void |
| 94 | 94 | */ |
| 95 | -function give_include_recount_all_tool_batch_processor( $class ) { |
|
| 96 | - $file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-recount-all-stats.php'; |
|
| 97 | - if ( 'Give_Tools_Recount_All_Stats' === $class && file_exists( $file_path ) ) { |
|
| 95 | +function give_include_recount_all_tool_batch_processor($class) { |
|
| 96 | + $file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-recount-all-stats.php'; |
|
| 97 | + if ('Give_Tools_Recount_All_Stats' === $class && file_exists($file_path)) { |
|
| 98 | 98 | require_once $file_path; |
| 99 | 99 | } |
| 100 | 100 | |
@@ -106,10 +106,10 @@ discard block |
||
| 106 | 106 | * @since 1.5 |
| 107 | 107 | */ |
| 108 | 108 | function give_register_batch_reset_tool() { |
| 109 | - add_action( 'give_batch_export_class_include', 'give_include_reset_tool_batch_processor', 10, 1 ); |
|
| 109 | + add_action('give_batch_export_class_include', 'give_include_reset_tool_batch_processor', 10, 1); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | -add_action( 'give_register_batch_exporter', 'give_register_batch_reset_tool', 10 ); |
|
| 112 | +add_action('give_register_batch_exporter', 'give_register_batch_reset_tool', 10); |
|
| 113 | 113 | |
| 114 | 114 | /** |
| 115 | 115 | * Loads the tools batch processing class for resetting store and product earnings |
@@ -120,11 +120,11 @@ discard block |
||
| 120 | 120 | * |
| 121 | 121 | * @return void |
| 122 | 122 | */ |
| 123 | -function give_include_reset_tool_batch_processor( $class ) { |
|
| 123 | +function give_include_reset_tool_batch_processor($class) { |
|
| 124 | 124 | |
| 125 | - $file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-reset-stats.php'; |
|
| 125 | + $file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-reset-stats.php'; |
|
| 126 | 126 | |
| 127 | - if ( 'Give_Tools_Reset_Stats' === $class && file_exists( $file_path ) ) { |
|
| 127 | + if ('Give_Tools_Reset_Stats' === $class && file_exists($file_path)) { |
|
| 128 | 128 | require_once $file_path; |
| 129 | 129 | } |
| 130 | 130 | |
@@ -135,10 +135,10 @@ discard block |
||
| 135 | 135 | * @since 1.5 |
| 136 | 136 | */ |
| 137 | 137 | function give_register_batch_customer_recount_tool() { |
| 138 | - add_action( 'give_batch_export_class_include', 'give_include_customer_recount_tool_batch_processor', 10, 1 ); |
|
| 138 | + add_action('give_batch_export_class_include', 'give_include_customer_recount_tool_batch_processor', 10, 1); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | -add_action( 'give_register_batch_exporter', 'give_register_batch_customer_recount_tool', 10 ); |
|
| 141 | +add_action('give_register_batch_exporter', 'give_register_batch_customer_recount_tool', 10); |
|
| 142 | 142 | |
| 143 | 143 | /** |
| 144 | 144 | * Loads the tools batch processing class for resetting all customer stats |
@@ -149,11 +149,11 @@ discard block |
||
| 149 | 149 | * |
| 150 | 150 | * @return void |
| 151 | 151 | */ |
| 152 | -function give_include_customer_recount_tool_batch_processor( $class ) { |
|
| 152 | +function give_include_customer_recount_tool_batch_processor($class) { |
|
| 153 | 153 | |
| 154 | - $file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-recount-customer-stats.php'; |
|
| 154 | + $file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-recount-customer-stats.php'; |
|
| 155 | 155 | |
| 156 | - if ( 'Give_Tools_Recount_Customer_Stats' === $class && file_exists( $file_path ) ) { |
|
| 156 | + if ('Give_Tools_Recount_Customer_Stats' === $class && file_exists($file_path)) { |
|
| 157 | 157 | require_once $file_path; |
| 158 | 158 | } |
| 159 | 159 | |
@@ -164,10 +164,10 @@ discard block |
||
| 164 | 164 | * @since 1.5 |
| 165 | 165 | */ |
| 166 | 166 | function give_register_batch_delete_test_transactions_tool() { |
| 167 | - add_action( 'give_batch_export_class_include', 'give_include_delete_test_transactions_batch_processor', 10, 1 ); |
|
| 167 | + add_action('give_batch_export_class_include', 'give_include_delete_test_transactions_batch_processor', 10, 1); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | -add_action( 'give_register_batch_exporter', 'give_register_batch_delete_test_transactions_tool', 10 ); |
|
| 170 | +add_action('give_register_batch_exporter', 'give_register_batch_delete_test_transactions_tool', 10); |
|
| 171 | 171 | |
| 172 | 172 | /** |
| 173 | 173 | * Loads the tools batch processing class for resetting all customer stats |
@@ -178,11 +178,11 @@ discard block |
||
| 178 | 178 | * |
| 179 | 179 | * @return void |
| 180 | 180 | */ |
| 181 | -function give_include_delete_test_transactions_batch_processor( $class ) { |
|
| 181 | +function give_include_delete_test_transactions_batch_processor($class) { |
|
| 182 | 182 | |
| 183 | - $file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-delete-test-transactions.php'; |
|
| 183 | + $file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-delete-test-transactions.php'; |
|
| 184 | 184 | |
| 185 | - if ( 'Give_Tools_Delete_Test_Transactions' === $class && file_exists( $file_path ) ) { |
|
| 185 | + if ('Give_Tools_Delete_Test_Transactions' === $class && file_exists($file_path)) { |
|
| 186 | 186 | require_once $file_path; |
| 187 | 187 | } |
| 188 | 188 | |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | * @since 1.5 |
| 51 | 51 | * @global object $wpdb Used to query the database using the WordPress |
| 52 | 52 | * Database API |
| 53 | - * @return array $data The data for the CSV file |
|
| 53 | + * @return boolean $data The data for the CSV file |
|
| 54 | 54 | */ |
| 55 | 55 | public function get_data() { |
| 56 | 56 | global $wpdb; |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -55,22 +55,22 @@ discard block |
||
| 55 | 55 | public function get_data() { |
| 56 | 56 | global $wpdb; |
| 57 | 57 | |
| 58 | - $items = $this->get_stored_data( 'give_temp_reset_ids' ); |
|
| 58 | + $items = $this->get_stored_data('give_temp_reset_ids'); |
|
| 59 | 59 | |
| 60 | - if ( ! is_array( $items ) ) { |
|
| 60 | + if ( ! is_array($items)) { |
|
| 61 | 61 | return false; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
| 65 | - $step_items = array_slice( $items, $offset, $this->per_step ); |
|
| 64 | + $offset = ($this->step - 1) * $this->per_step; |
|
| 65 | + $step_items = array_slice($items, $offset, $this->per_step); |
|
| 66 | 66 | |
| 67 | - if ( $step_items ) { |
|
| 67 | + if ($step_items) { |
|
| 68 | 68 | |
| 69 | 69 | $step_ids = array( |
| 70 | 70 | 'other' => array(), |
| 71 | 71 | ); |
| 72 | 72 | |
| 73 | - foreach ( $step_items as $item ) { |
|
| 73 | + foreach ($step_items as $item) { |
|
| 74 | 74 | |
| 75 | 75 | $step_ids['other'][] = $item['id']; |
| 76 | 76 | |
@@ -78,15 +78,15 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | $sql = array(); |
| 80 | 80 | |
| 81 | - foreach ( $step_ids as $type => $ids ) { |
|
| 81 | + foreach ($step_ids as $type => $ids) { |
|
| 82 | 82 | |
| 83 | - if ( empty( $ids ) ) { |
|
| 83 | + if (empty($ids)) { |
|
| 84 | 84 | continue; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - $ids = implode( ',', $ids ); |
|
| 87 | + $ids = implode(',', $ids); |
|
| 88 | 88 | |
| 89 | - switch ( $type ) { |
|
| 89 | + switch ($type) { |
|
| 90 | 90 | case 'other': |
| 91 | 91 | $sql[] = "DELETE FROM $wpdb->posts WHERE id IN ($ids)"; |
| 92 | 92 | $sql[] = "DELETE FROM $wpdb->postmeta WHERE post_id IN ($ids)"; |
@@ -97,9 +97,9 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - if ( ! empty( $sql ) ) { |
|
| 101 | - foreach ( $sql as $query ) { |
|
| 102 | - $wpdb->query( $query ); |
|
| 100 | + if ( ! empty($sql)) { |
|
| 101 | + foreach ($sql as $query) { |
|
| 102 | + $wpdb->query($query); |
|
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | |
@@ -119,16 +119,16 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | public function get_percentage_complete() { |
| 121 | 121 | |
| 122 | - $items = $this->get_stored_data( 'give_temp_reset_ids', false ); |
|
| 123 | - $total = count( $items ); |
|
| 122 | + $items = $this->get_stored_data('give_temp_reset_ids', false); |
|
| 123 | + $total = count($items); |
|
| 124 | 124 | |
| 125 | 125 | $percentage = 100; |
| 126 | 126 | |
| 127 | - if ( $total > 0 ) { |
|
| 128 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 127 | + if ($total > 0) { |
|
| 128 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - if ( $percentage > 100 ) { |
|
| 131 | + if ($percentage > 100) { |
|
| 132 | 132 | $percentage = 100; |
| 133 | 133 | } |
| 134 | 134 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * |
| 143 | 143 | * @param array $request The Form Data passed into the batch processing |
| 144 | 144 | */ |
| 145 | - public function set_properties( $request ) { |
|
| 145 | + public function set_properties($request) { |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -153,30 +153,30 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | public function process_step() { |
| 155 | 155 | |
| 156 | - if ( ! $this->can_export() ) { |
|
| 157 | - wp_die( esc_html__( 'You do not have permission to delete test transactions.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 156 | + if ( ! $this->can_export()) { |
|
| 157 | + wp_die(esc_html__('You do not have permission to delete test transactions.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | $had_data = $this->get_data(); |
| 161 | 161 | |
| 162 | - if ( $had_data ) { |
|
| 162 | + if ($had_data) { |
|
| 163 | 163 | $this->done = false; |
| 164 | 164 | |
| 165 | 165 | return true; |
| 166 | 166 | } else { |
| 167 | - update_option( 'give_earnings_total', 0 ); |
|
| 168 | - delete_transient( 'give_earnings_total' ); |
|
| 169 | - delete_transient( 'give_estimated_monthly_stats' . true ); |
|
| 170 | - delete_transient( 'give_estimated_monthly_stats' . false ); |
|
| 171 | - $this->delete_data( 'give_temp_reset_ids' ); |
|
| 167 | + update_option('give_earnings_total', 0); |
|
| 168 | + delete_transient('give_earnings_total'); |
|
| 169 | + delete_transient('give_estimated_monthly_stats'.true); |
|
| 170 | + delete_transient('give_estimated_monthly_stats'.false); |
|
| 171 | + $this->delete_data('give_temp_reset_ids'); |
|
| 172 | 172 | |
| 173 | 173 | // Reset the sequential order numbers |
| 174 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
| 175 | - delete_option( 'give_last_payment_number' ); |
|
| 174 | + if (give_get_option('enable_sequential')) { |
|
| 175 | + delete_option('give_last_payment_number'); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | $this->done = true; |
| 179 | - $this->message = esc_html__( 'Test transactions successfully deleted.', 'give' ); |
|
| 179 | + $this->message = esc_html__('Test transactions successfully deleted.', 'give'); |
|
| 180 | 180 | |
| 181 | 181 | return false; |
| 182 | 182 | } |
@@ -186,10 +186,10 @@ discard block |
||
| 186 | 186 | * Headers |
| 187 | 187 | */ |
| 188 | 188 | public function headers() { |
| 189 | - ignore_user_abort( true ); |
|
| 189 | + ignore_user_abort(true); |
|
| 190 | 190 | |
| 191 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 192 | - set_time_limit( 0 ); |
|
| 191 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 192 | + set_time_limit(0); |
|
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | 195 | |
@@ -213,26 +213,26 @@ discard block |
||
| 213 | 213 | */ |
| 214 | 214 | public function pre_fetch() { |
| 215 | 215 | |
| 216 | - if ( $this->step == 1 ) { |
|
| 217 | - $this->delete_data( 'give_temp_reset_ids' ); |
|
| 216 | + if ($this->step == 1) { |
|
| 217 | + $this->delete_data('give_temp_reset_ids'); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - $items = get_option( 'give_temp_reset_ids', false ); |
|
| 220 | + $items = get_option('give_temp_reset_ids', false); |
|
| 221 | 221 | |
| 222 | - if ( false === $items ) { |
|
| 222 | + if (false === $items) { |
|
| 223 | 223 | $items = array(); |
| 224 | 224 | |
| 225 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
| 225 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
| 226 | 226 | 'post_type' => 'give_payment', |
| 227 | 227 | 'post_status' => 'any', |
| 228 | - 'posts_per_page' => - 1, |
|
| 228 | + 'posts_per_page' => -1, |
|
| 229 | 229 | //ONLY TEST MODE TRANSACTIONS!!! |
| 230 | 230 | 'meta_key' => '_give_payment_mode', |
| 231 | 231 | 'meta_value' => 'test' |
| 232 | - ) ); |
|
| 232 | + )); |
|
| 233 | 233 | |
| 234 | - $posts = get_posts( $args ); |
|
| 235 | - foreach ( $posts as $post ) { |
|
| 234 | + $posts = get_posts($args); |
|
| 235 | + foreach ($posts as $post) { |
|
| 236 | 236 | $items[] = array( |
| 237 | 237 | 'id' => (int) $post->ID, |
| 238 | 238 | 'type' => $post->post_type, |
@@ -241,9 +241,9 @@ discard block |
||
| 241 | 241 | |
| 242 | 242 | // Allow filtering of items to remove with an unassociative array for each item |
| 243 | 243 | // The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method |
| 244 | - $items = apply_filters( 'give_reset_store_items', $items ); |
|
| 244 | + $items = apply_filters('give_reset_store_items', $items); |
|
| 245 | 245 | |
| 246 | - $this->store_data( 'give_temp_reset_ids', $items ); |
|
| 246 | + $this->store_data('give_temp_reset_ids', $items); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | } |
@@ -257,11 +257,11 @@ discard block |
||
| 257 | 257 | * |
| 258 | 258 | * @return mixed Returns the data from the database |
| 259 | 259 | */ |
| 260 | - private function get_stored_data( $key ) { |
|
| 260 | + private function get_stored_data($key) { |
|
| 261 | 261 | global $wpdb; |
| 262 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 262 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 263 | 263 | |
| 264 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
| 264 | + return empty($value) ? false : maybe_unserialize($value); |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | /** |
@@ -274,10 +274,10 @@ discard block |
||
| 274 | 274 | * |
| 275 | 275 | * @return void |
| 276 | 276 | */ |
| 277 | - private function store_data( $key, $value ) { |
|
| 277 | + private function store_data($key, $value) { |
|
| 278 | 278 | global $wpdb; |
| 279 | 279 | |
| 280 | - $value = maybe_serialize( $value ); |
|
| 280 | + $value = maybe_serialize($value); |
|
| 281 | 281 | |
| 282 | 282 | $data = array( |
| 283 | 283 | 'option_name' => $key, |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | '%s', |
| 292 | 292 | ); |
| 293 | 293 | |
| 294 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 294 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | /** |
@@ -303,9 +303,9 @@ discard block |
||
| 303 | 303 | * |
| 304 | 304 | * @return void |
| 305 | 305 | */ |
| 306 | - private function delete_data( $key ) { |
|
| 306 | + private function delete_data($key) { |
|
| 307 | 307 | global $wpdb; |
| 308 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 308 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | } |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | * @since 1.5 |
| 51 | 51 | * @global object $wpdb Used to query the database using the WordPress |
| 52 | 52 | * Database API |
| 53 | - * @return array $data The data for the CSV file |
|
| 53 | + * @return boolean $data The data for the CSV file |
|
| 54 | 54 | */ |
| 55 | 55 | public function get_data() { |
| 56 | 56 | global $wpdb; |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -55,26 +55,26 @@ discard block |
||
| 55 | 55 | public function get_data() { |
| 56 | 56 | global $give_logs, $wpdb; |
| 57 | 57 | |
| 58 | - $totals = $this->get_stored_data( 'give_temp_recount_all_stats' ); |
|
| 59 | - $payment_items = $this->get_stored_data( 'give_temp_payment_items' ); |
|
| 60 | - $processed_payments = $this->get_stored_data( 'give_temp_processed_payments' ); |
|
| 61 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
| 58 | + $totals = $this->get_stored_data('give_temp_recount_all_stats'); |
|
| 59 | + $payment_items = $this->get_stored_data('give_temp_payment_items'); |
|
| 60 | + $processed_payments = $this->get_stored_data('give_temp_processed_payments'); |
|
| 61 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
| 62 | 62 | |
| 63 | - if ( false === $totals ) { |
|
| 63 | + if (false === $totals) { |
|
| 64 | 64 | $totals = array(); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - if ( false === $payment_items ) { |
|
| 67 | + if (false === $payment_items) { |
|
| 68 | 68 | $payment_items = array(); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - if ( false === $processed_payments ) { |
|
| 71 | + if (false === $processed_payments) { |
|
| 72 | 72 | $processed_payments = array(); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - $all_forms = $this->get_stored_data( 'give_temp_form_ids' ); |
|
| 75 | + $all_forms = $this->get_stored_data('give_temp_form_ids'); |
|
| 76 | 76 | |
| 77 | - $args = apply_filters( 'give_recount_form_stats_args', array( |
|
| 77 | + $args = apply_filters('give_recount_form_stats_args', array( |
|
| 78 | 78 | 'post_parent__in' => $all_forms, |
| 79 | 79 | 'post_type' => 'give_log', |
| 80 | 80 | 'posts_per_page' => $this->per_step, |
@@ -82,73 +82,73 @@ discard block |
||
| 82 | 82 | 'paged' => $this->step, |
| 83 | 83 | 'log_type' => 'sale', |
| 84 | 84 | 'fields' => 'ids', |
| 85 | - ) ); |
|
| 85 | + )); |
|
| 86 | 86 | |
| 87 | - $log_ids = $give_logs->get_connected_logs( $args, 'sale' ); |
|
| 87 | + $log_ids = $give_logs->get_connected_logs($args, 'sale'); |
|
| 88 | 88 | |
| 89 | - if ( $log_ids ) { |
|
| 90 | - $log_ids = implode( ',', $log_ids ); |
|
| 89 | + if ($log_ids) { |
|
| 90 | + $log_ids = implode(',', $log_ids); |
|
| 91 | 91 | |
| 92 | - $payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)" ); |
|
| 93 | - unset( $log_ids ); |
|
| 92 | + $payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)"); |
|
| 93 | + unset($log_ids); |
|
| 94 | 94 | |
| 95 | - $payment_ids = implode( ',', $payment_ids ); |
|
| 96 | - $payments = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (" . $payment_ids . ")" ); |
|
| 97 | - unset( $payment_ids ); |
|
| 95 | + $payment_ids = implode(',', $payment_ids); |
|
| 96 | + $payments = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (".$payment_ids.")"); |
|
| 97 | + unset($payment_ids); |
|
| 98 | 98 | |
| 99 | 99 | //Loop through payments |
| 100 | - foreach ( $payments as $payment ) { |
|
| 100 | + foreach ($payments as $payment) { |
|
| 101 | 101 | |
| 102 | 102 | // Prevent payments that have all ready been retrieved from a previous sales log from counting again. |
| 103 | - if ( in_array( $payment->ID, $processed_payments ) ) { |
|
| 103 | + if (in_array($payment->ID, $processed_payments)) { |
|
| 104 | 104 | continue; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | //Verify accepted status' |
| 108 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
| 108 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
| 109 | 109 | $processed_payments[] = $payment->ID; |
| 110 | 110 | continue; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - $payment_item = $payment_items[ $payment->ID ]; |
|
| 113 | + $payment_item = $payment_items[$payment->ID]; |
|
| 114 | 114 | |
| 115 | 115 | |
| 116 | - $form_id = isset( $payment_item['id'] ) ? $payment_item['id'] : ''; |
|
| 116 | + $form_id = isset($payment_item['id']) ? $payment_item['id'] : ''; |
|
| 117 | 117 | |
| 118 | 118 | //Must have a form ID |
| 119 | - if ( empty( $form_id ) ) { |
|
| 119 | + if (empty($form_id)) { |
|
| 120 | 120 | continue; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | //Form ID must be within $all_forms array to be validated |
| 124 | - if ( ! in_array( $form_id, $all_forms ) ) { |
|
| 124 | + if ( ! in_array($form_id, $all_forms)) { |
|
| 125 | 125 | continue; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | //If array key doesn't exist, create it |
| 129 | - if ( ! array_key_exists( $form_id, $totals ) ) { |
|
| 130 | - $totals[ $form_id ] = array( |
|
| 129 | + if ( ! array_key_exists($form_id, $totals)) { |
|
| 130 | + $totals[$form_id] = array( |
|
| 131 | 131 | 'sales' => (int) 0, |
| 132 | 132 | 'earnings' => (float) 0, |
| 133 | 133 | ); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - $totals[ $form_id ]['sales'] ++; |
|
| 137 | - $totals[ $form_id ]['earnings'] += $payment_item['price']; |
|
| 136 | + $totals[$form_id]['sales']++; |
|
| 137 | + $totals[$form_id]['earnings'] += $payment_item['price']; |
|
| 138 | 138 | |
| 139 | 139 | $processed_payments[] = $payment->ID; |
| 140 | 140 | |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - $this->store_data( 'give_temp_processed_payments', $processed_payments ); |
|
| 144 | - $this->store_data( 'give_temp_recount_all_stats', $totals ); |
|
| 143 | + $this->store_data('give_temp_processed_payments', $processed_payments); |
|
| 144 | + $this->store_data('give_temp_recount_all_stats', $totals); |
|
| 145 | 145 | |
| 146 | 146 | return true; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - foreach ( $totals as $key => $stats ) { |
|
| 150 | - update_post_meta( $key, '_give_form_sales', $stats['sales'] ); |
|
| 151 | - update_post_meta( $key, '_give_form_earnings', $stats['earnings'] ); |
|
| 149 | + foreach ($totals as $key => $stats) { |
|
| 150 | + update_post_meta($key, '_give_form_sales', $stats['sales']); |
|
| 151 | + update_post_meta($key, '_give_form_earnings', $stats['earnings']); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | return false; |
@@ -163,20 +163,20 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | public function get_percentage_complete() { |
| 165 | 165 | |
| 166 | - $total = $this->get_stored_data( 'give_recount_all_total', false ); |
|
| 166 | + $total = $this->get_stored_data('give_recount_all_total', false); |
|
| 167 | 167 | |
| 168 | - if ( false === $total ) { |
|
| 168 | + if (false === $total) { |
|
| 169 | 169 | $this->pre_fetch(); |
| 170 | - $total = $this->get_stored_data( 'give_recount_all_total', 0 ); |
|
| 170 | + $total = $this->get_stored_data('give_recount_all_total', 0); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | $percentage = 100; |
| 174 | 174 | |
| 175 | - if ( $total > 0 ) { |
|
| 176 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 175 | + if ($total > 0) { |
|
| 176 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - if ( $percentage > 100 ) { |
|
| 179 | + if ($percentage > 100) { |
|
| 180 | 180 | $percentage = 100; |
| 181 | 181 | } |
| 182 | 182 | |
@@ -190,8 +190,8 @@ discard block |
||
| 190 | 190 | * |
| 191 | 191 | * @param array $request The Form Data passed into the batch processing |
| 192 | 192 | */ |
| 193 | - public function set_properties( $request ) { |
|
| 194 | - $this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false; |
|
| 193 | + public function set_properties($request) { |
|
| 194 | + $this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -202,34 +202,34 @@ discard block |
||
| 202 | 202 | */ |
| 203 | 203 | public function process_step() { |
| 204 | 204 | |
| 205 | - if ( ! $this->can_export() ) { |
|
| 206 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 205 | + if ( ! $this->can_export()) { |
|
| 206 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | $had_data = $this->get_data(); |
| 210 | 210 | |
| 211 | - if ( $had_data ) { |
|
| 211 | + if ($had_data) { |
|
| 212 | 212 | $this->done = false; |
| 213 | 213 | |
| 214 | 214 | return true; |
| 215 | 215 | } else { |
| 216 | - $this->delete_data( 'give_recount_all_total' ); |
|
| 217 | - $this->delete_data( 'give_temp_recount_all_stats' ); |
|
| 218 | - $this->delete_data( 'give_temp_payment_items' ); |
|
| 219 | - $this->delete_data( 'give_temp_form_ids' ); |
|
| 220 | - $this->delete_data( 'give_temp_processed_payments' ); |
|
| 216 | + $this->delete_data('give_recount_all_total'); |
|
| 217 | + $this->delete_data('give_temp_recount_all_stats'); |
|
| 218 | + $this->delete_data('give_temp_payment_items'); |
|
| 219 | + $this->delete_data('give_temp_form_ids'); |
|
| 220 | + $this->delete_data('give_temp_processed_payments'); |
|
| 221 | 221 | $this->done = true; |
| 222 | - $this->message = esc_html__( 'Donation form income amounts and donation counts stats successfully recounted.', 'give' ); |
|
| 222 | + $this->message = esc_html__('Donation form income amounts and donation counts stats successfully recounted.', 'give'); |
|
| 223 | 223 | |
| 224 | 224 | return false; |
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | public function headers() { |
| 229 | - ignore_user_abort( true ); |
|
| 229 | + ignore_user_abort(true); |
|
| 230 | 230 | |
| 231 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 232 | - set_time_limit( 0 ); |
|
| 231 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 232 | + set_time_limit(0); |
|
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | 235 | |
@@ -258,76 +258,76 @@ discard block |
||
| 258 | 258 | |
| 259 | 259 | global $give_logs, $wpdb; |
| 260 | 260 | |
| 261 | - if ( $this->step == 1 ) { |
|
| 262 | - $this->delete_data( 'give_temp_recount_all_total' ); |
|
| 263 | - $this->delete_data( 'give_temp_recount_all_stats' ); |
|
| 264 | - $this->delete_data( 'give_temp_payment_items' ); |
|
| 265 | - $this->delete_data( 'give_temp_processed_payments' ); |
|
| 261 | + if ($this->step == 1) { |
|
| 262 | + $this->delete_data('give_temp_recount_all_total'); |
|
| 263 | + $this->delete_data('give_temp_recount_all_stats'); |
|
| 264 | + $this->delete_data('give_temp_payment_items'); |
|
| 265 | + $this->delete_data('give_temp_processed_payments'); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
| 269 | - $total = $this->get_stored_data( 'give_temp_recount_all_total' ); |
|
| 268 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
| 269 | + $total = $this->get_stored_data('give_temp_recount_all_total'); |
|
| 270 | 270 | |
| 271 | - if ( false === $total ) { |
|
| 271 | + if (false === $total) { |
|
| 272 | 272 | $total = 0; |
| 273 | - $payment_items = $this->get_stored_data( 'give_temp_payment_items' ); |
|
| 273 | + $payment_items = $this->get_stored_data('give_temp_payment_items'); |
|
| 274 | 274 | |
| 275 | - if ( false === $payment_items ) { |
|
| 275 | + if (false === $payment_items) { |
|
| 276 | 276 | $payment_items = array(); |
| 277 | - $this->store_data( 'give_temp_payment_items', $payment_items ); |
|
| 277 | + $this->store_data('give_temp_payment_items', $payment_items); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - $all_forms = $this->get_stored_data( 'give_temp_form_ids' ); |
|
| 280 | + $all_forms = $this->get_stored_data('give_temp_form_ids'); |
|
| 281 | 281 | |
| 282 | - if ( false === $all_forms ) { |
|
| 282 | + if (false === $all_forms) { |
|
| 283 | 283 | $args = array( |
| 284 | 284 | 'post_status' => 'any', |
| 285 | 285 | 'post_type' => 'give_forms', |
| 286 | - 'posts_per_page' => - 1, |
|
| 286 | + 'posts_per_page' => -1, |
|
| 287 | 287 | 'fields' => 'ids', |
| 288 | 288 | ); |
| 289 | 289 | |
| 290 | - $all_forms = get_posts( $args ); |
|
| 291 | - $this->store_data( 'give_temp_form_ids', $all_forms ); |
|
| 290 | + $all_forms = get_posts($args); |
|
| 291 | + $this->store_data('give_temp_form_ids', $all_forms); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - $args = apply_filters( 'give_recount_form_stats_total_args', array( |
|
| 294 | + $args = apply_filters('give_recount_form_stats_total_args', array( |
|
| 295 | 295 | 'post_parent__in' => $all_forms, |
| 296 | 296 | 'post_type' => 'give_log', |
| 297 | 297 | 'post_status' => 'publish', |
| 298 | 298 | 'log_type' => 'sale', |
| 299 | 299 | 'fields' => 'ids', |
| 300 | 300 | 'nopaging' => true, |
| 301 | - ) ); |
|
| 301 | + )); |
|
| 302 | 302 | |
| 303 | - $all_logs = $give_logs->get_connected_logs( $args, 'sale' ); |
|
| 303 | + $all_logs = $give_logs->get_connected_logs($args, 'sale'); |
|
| 304 | 304 | |
| 305 | - if ( $all_logs ) { |
|
| 306 | - $log_ids = implode( ',', $all_logs ); |
|
| 307 | - $payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)" ); |
|
| 308 | - unset( $log_ids ); |
|
| 305 | + if ($all_logs) { |
|
| 306 | + $log_ids = implode(',', $all_logs); |
|
| 307 | + $payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)"); |
|
| 308 | + unset($log_ids); |
|
| 309 | 309 | |
| 310 | - $payment_ids = implode( ',', $payment_ids ); |
|
| 311 | - $payments = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (" . $payment_ids . ")" ); |
|
| 312 | - unset( $payment_ids ); |
|
| 310 | + $payment_ids = implode(',', $payment_ids); |
|
| 311 | + $payments = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (".$payment_ids.")"); |
|
| 312 | + unset($payment_ids); |
|
| 313 | 313 | |
| 314 | - foreach ( $payments as $payment ) { |
|
| 314 | + foreach ($payments as $payment) { |
|
| 315 | 315 | |
| 316 | - $payment = new Give_Payment( $payment->ID ); |
|
| 316 | + $payment = new Give_Payment($payment->ID); |
|
| 317 | 317 | $form_id = $payment->form_id; |
| 318 | 318 | |
| 319 | 319 | //If for some reason somehow the form_ID isn't set check payment meta |
| 320 | - if ( empty( $payment->form_id ) ) { |
|
| 320 | + if (empty($payment->form_id)) { |
|
| 321 | 321 | $payment_meta = $payment->get_meta(); |
| 322 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0; |
|
| 322 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0; |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
| 325 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
| 326 | 326 | continue; |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | - if ( ! array_key_exists( $payment->ID, $payment_items ) ) { |
|
| 330 | - $payment_items[ $payment->ID ] = array( |
|
| 329 | + if ( ! array_key_exists($payment->ID, $payment_items)) { |
|
| 330 | + $payment_items[$payment->ID] = array( |
|
| 331 | 331 | 'id' => $form_id, |
| 332 | 332 | 'payment_id' => $payment->ID, |
| 333 | 333 | 'price' => $payment->total |
@@ -336,11 +336,11 @@ discard block |
||
| 336 | 336 | |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | - $total = count( $all_logs ); |
|
| 339 | + $total = count($all_logs); |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - $this->store_data( 'give_temp_payment_items', $payment_items ); |
|
| 343 | - $this->store_data( 'give_recount_all_total', $total ); |
|
| 342 | + $this->store_data('give_temp_payment_items', $payment_items); |
|
| 343 | + $this->store_data('give_recount_all_total', $total); |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | } |
@@ -354,11 +354,11 @@ discard block |
||
| 354 | 354 | * |
| 355 | 355 | * @return mixed Returns the data from the database |
| 356 | 356 | */ |
| 357 | - private function get_stored_data( $key ) { |
|
| 357 | + private function get_stored_data($key) { |
|
| 358 | 358 | global $wpdb; |
| 359 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 359 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 360 | 360 | |
| 361 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
| 361 | + return empty($value) ? false : maybe_unserialize($value); |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | /** |
@@ -371,10 +371,10 @@ discard block |
||
| 371 | 371 | * |
| 372 | 372 | * @return void |
| 373 | 373 | */ |
| 374 | - private function store_data( $key, $value ) { |
|
| 374 | + private function store_data($key, $value) { |
|
| 375 | 375 | global $wpdb; |
| 376 | 376 | |
| 377 | - $value = maybe_serialize( $value ); |
|
| 377 | + $value = maybe_serialize($value); |
|
| 378 | 378 | |
| 379 | 379 | $data = array( |
| 380 | 380 | 'option_name' => $key, |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | '%s', |
| 389 | 389 | ); |
| 390 | 390 | |
| 391 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 391 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | /** |
@@ -400,9 +400,9 @@ discard block |
||
| 400 | 400 | * |
| 401 | 401 | * @return void |
| 402 | 402 | */ |
| 403 | - private function delete_data( $key ) { |
|
| 403 | + private function delete_data($key) { |
|
| 404 | 404 | global $wpdb; |
| 405 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 405 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | } |