← All changes
|
includes/admin/tools/data/class-give-tools-recount-income.php
+28
-18
2.3.1
→
4.18.0
View file →
| @@ -23,8 +23,9 @@ | ||
| 23 | 23 | class Give_Tools_Recount_Income extends Give_Batch_Export { |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Our export type. Used for export-type specific filters/actions |
| 27 | + * | |
| 27 | 28 | * @var string |
| 28 | 29 | * @since 1.5 |
| 29 | 30 | */ |
| 30 | 31 | public $export_type = ''; |
| @@ -30,8 +31,9 @@ | ||
| 30 | 31 | public $export_type = ''; |
| 31 | 32 | |
| 32 | 33 | /** |
| 33 | 34 | * Allows for a non-form batch processing to be run. |
| 35 | + * | |
| 34 | 36 | * @since 1.5 |
| 35 | 37 | * @var boolean |
| 36 | 38 | */ |
| 37 | 39 | public $is_void = true; |
| @@ -37,8 +39,9 @@ | ||
| 37 | 39 | public $is_void = true; |
| 38 | 40 | |
| 39 | 41 | /** |
| 40 | 42 | * Sets the number of items to pull on each step |
| 43 | + * | |
| 41 | 44 | * @since 1.5 |
| 42 | 45 | * @var integer |
| 43 | 46 | */ |
| 44 | 47 | public $per_step = 100; |
| @@ -71,15 +74,18 @@ | ||
| 71 | 74 | $total = (float) 0; |
| 72 | 75 | $this->store_data( 'give_temp_recount_earnings', $total ); |
| 73 | 76 | } |
| 74 | 77 | |
| 75 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); | |
| 78 | + $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', [ 'publish' ] ); | |
| 76 | 79 | |
| 77 | - $args = apply_filters( 'give_recount_earnings_args', array( | |
| 78 | - 'number' => $this->per_step, | |
| 79 | - 'page' => $this->step, | |
| 80 | - 'status' => $accepted_statuses, | |
| 81 | - ) ); | |
| 80 | + $args = apply_filters( | |
| 81 | + 'give_recount_earnings_args', | |
| 82 | + [ | |
| 83 | + 'number' => $this->per_step, | |
| 84 | + 'page' => $this->step, | |
| 85 | + 'status' => $accepted_statuses, | |
| 86 | + ] | |
| 87 | + ); | |
| 82 | 88 | |
| 83 | 89 | $payments = give_get_payments( $args ); |
| 84 | 90 | |
| 85 | 91 | if ( ! empty( $payments ) ) { |
| @@ -94,12 +100,16 @@ | ||
| 94 | 100 | * @since 2.1 |
| 95 | 101 | */ |
| 96 | 102 | $donation_amount = apply_filters( |
| 97 | 103 | 'give_donation_amount', |
| 98 | - give_format_amount( $payment_amount, array( 'donation_id' => $payment->ID ) ), | |
| 104 | + give_format_amount( $payment_amount, [ 'donation_id' => $payment->ID ] ), | |
| 99 | 105 | $payment->total, |
| 100 | 106 | $payment->ID, |
| 101 | - array( 'type' => 'stats', 'currency' => false, 'amount' => false ) | |
| 107 | + [ | |
| 108 | + 'type' => 'stats', | |
| 109 | + 'currency' => false, | |
| 110 | + 'amount' => false, | |
| 111 | + ] | |
| 102 | 112 | ); |
| 103 | 113 | |
| 104 | 114 | $total += (float) give_maybe_sanitize_amount( $donation_amount ); |
| 105 | 115 | } |
| @@ -132,9 +142,9 @@ | ||
| 132 | 142 | |
| 133 | 143 | $total = $this->get_stored_data( 'give_recount_earnings_total' ); |
| 134 | 144 | |
| 135 | 145 | if ( false === $total ) { |
| 136 | - $args = apply_filters( 'give_recount_earnings_total_args', array() ); | |
| 146 | + $args = apply_filters( 'give_recount_earnings_total_args', [] ); | |
| 137 | 147 | |
| 138 | 148 | $counts = give_count_payments( $args ); |
| 139 | 149 | $total = absint( $counts->publish ); |
| 140 | 150 | $total = apply_filters( 'give_recount_store_earnings_total', $total ); |
| @@ -173,9 +183,9 @@ | ||
| 173 | 183 | */ |
| 174 | 184 | public function process_step() { |
| 175 | 185 | |
| 176 | 186 | if ( ! $this->can_export() ) { |
| 177 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); | |
| 187 | + wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), [ 'response' => 403 ] ); | |
| 178 | 188 | } |
| 179 | 189 | |
| 180 | 190 | $had_data = $this->get_data(); |
| 181 | 191 | |
| @@ -186,9 +196,9 @@ | ||
| 186 | 196 | } else { |
| 187 | 197 | $this->delete_data( 'give_recount_earnings_total' ); |
| 188 | 198 | $this->delete_data( 'give_temp_recount_earnings' ); |
| 189 | 199 | $this->done = true; |
| 190 | - $this->message = esc_html__( 'Income stats have been successfully recounted.', 'give' ); | |
| 200 | + $this->message = esc_html__( 'Revenue stats have been successfully recounted.', 'give' ); | |
| 191 | 201 | |
| 192 | 202 | return false; |
| 193 | 203 | } |
| 194 | 204 | } |
| @@ -245,9 +255,9 @@ | ||
| 245 | 255 | * |
| 246 | 256 | * @since 1.5 |
| 247 | 257 | * |
| 248 | 258 | * @param string $key The option_name |
| 249 | - * @param mixed $value The value to store | |
| 259 | + * @param mixed $value The value to store | |
| 250 | 260 | * |
| 251 | 261 | * @return void |
| 252 | 262 | */ |
| 253 | 263 | private function store_data( $key, $value ) { |
| @@ -254,19 +264,19 @@ | ||
| 254 | 264 | global $wpdb; |
| 255 | 265 | |
| 256 | 266 | $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
| 257 | 267 | |
| 258 | - $data = array( | |
| 268 | + $data = [ | |
| 259 | 269 | 'option_name' => $key, |
| 260 | 270 | 'option_value' => $value, |
| 261 | 271 | 'autoload' => 'no', |
| 262 | - ); | |
| 272 | + ]; | |
| 263 | 273 | |
| 264 | - $formats = array( | |
| 274 | + $formats = [ | |
| 265 | 275 | '%s', |
| 266 | 276 | '%s', |
| 267 | 277 | '%s', |
| 268 | - ); | |
| 278 | + ]; | |
| 269 | 279 | |
| 270 | 280 | $wpdb->replace( $wpdb->options, $data, $formats ); |
| 271 | 281 | } |
| 272 | 282 | |
| @@ -280,9 +290,9 @@ | ||
| 280 | 290 | * @return void |
| 281 | 291 | */ |
| 282 | 292 | private function delete_data( $key ) { |
| 283 | 293 | global $wpdb; |
| 284 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); | |
| 294 | + $wpdb->delete( $wpdb->options, [ 'option_name' => $key ] ); | |
| 285 | 295 | } |
| 286 | 296 | |
| 287 | 297 | /** |
| 288 | 298 | * Unset the properties specific to the donors export. |
| @@ -288,9 +298,9 @@ | ||
| 288 | 298 | * Unset the properties specific to the donors export. |
| 289 | 299 | * |
| 290 | 300 | * @since 2.3.0 |
| 291 | 301 | * |
| 292 | - * @param array $request | |
| 302 | + * @param array $request | |
| 293 | 303 | * @param Give_Batch_Export $export |
| 294 | 304 | */ |
| 295 | 305 | public function unset_properties( $request, $export ) { |
| 296 | 306 | if ( $export->done ) { |